Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2011 University of California, Los Angeles |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation; |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | * |
| 18 | * Author: Ilya Moiseenko <iliamo@cs.ucla.edu> |
| 19 | * Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 20 | */ |
| 21 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 22 | #ifndef NDN_CONSUMER_WINDOW_H |
| 23 | #define NDN_CONSUMER_WINDOW_H |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 24 | |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame] | 25 | #include "ns3/ndnSIM/model/ndn-common.hpp" |
| 26 | |
Alexander Afanasyev | 0c39537 | 2014-12-20 15:54:02 -0800 | [diff] [blame] | 27 | #include "ndn-consumer.hpp" |
Alexander Afanasyev | e4c2ece | 2012-01-11 10:44:40 -0800 | [diff] [blame] | 28 | #include "ns3/traced-value.h" |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 29 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 30 | namespace ns3 { |
| 31 | namespace ndn { |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 32 | |
| 33 | /** |
Alexander Afanasyev | 7920651 | 2013-07-27 16:49:12 -0700 | [diff] [blame] | 34 | * @ingroup ndn-apps |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 35 | * \brief Ndn application for sending out Interest packets (window-based) |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 36 | * |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 37 | * !!! ATTENTION !!! This is highly experimental and relies on experimental features of the |
| 38 | *simulator. |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 39 | * Behavior may be unpredictable if used incorrectly. |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 40 | */ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 41 | class ConsumerWindow : public Consumer { |
Alexander Afanasyev | d1f7c7b | 2013-01-31 13:34:37 -0800 | [diff] [blame] | 42 | public: |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 43 | static TypeId |
| 44 | GetTypeId(); |
Alexander Afanasyev | d1f7c7b | 2013-01-31 13:34:37 -0800 | [diff] [blame] | 45 | |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 46 | /** |
Alexander Afanasyev | d1f7c7b | 2013-01-31 13:34:37 -0800 | [diff] [blame] | 47 | * \brief Default constructor |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 48 | */ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 49 | ConsumerWindow(); |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 50 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 51 | // From App |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 52 | // virtual void |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame] | 53 | // OnInterest (const shared_ptr<const Interest> &interest); |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 54 | |
| 55 | virtual void |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame] | 56 | OnNack(shared_ptr<const Interest> interest); |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 57 | |
| 58 | virtual void |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame] | 59 | OnData(shared_ptr<const Data> contentObject); |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 60 | |
| 61 | virtual void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 62 | OnTimeout(uint32_t sequenceNumber); |
Alexander Afanasyev | d1f7c7b | 2013-01-31 13:34:37 -0800 | [diff] [blame] | 63 | |
Alexander Afanasyev | 79b2fb3 | 2013-04-12 11:24:55 -0700 | [diff] [blame] | 64 | virtual void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 65 | WillSendOutInterest(uint32_t sequenceNumber); |
Alexander Afanasyev | 79b2fb3 | 2013-04-12 11:24:55 -0700 | [diff] [blame] | 66 | |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 67 | protected: |
| 68 | /** |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 69 | * \brief Constructs the Interest packet and sends it using a callback to the underlying NDN |
| 70 | * protocol |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 71 | */ |
| 72 | virtual void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 73 | ScheduleNextPacket(); |
Alexander Afanasyev | d1f7c7b | 2013-01-31 13:34:37 -0800 | [diff] [blame] | 74 | |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 75 | private: |
| 76 | virtual void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 77 | SetWindow(uint32_t window); |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 78 | |
| 79 | uint32_t |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 80 | GetWindow() const; |
Alexander Afanasyev | b7ad232 | 2012-01-17 22:54:49 -0800 | [diff] [blame] | 81 | |
| 82 | virtual void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 83 | SetPayloadSize(uint32_t payload); |
Alexander Afanasyev | b7ad232 | 2012-01-17 22:54:49 -0800 | [diff] [blame] | 84 | |
| 85 | uint32_t |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 86 | GetPayloadSize() const; |
Alexander Afanasyev | b7ad232 | 2012-01-17 22:54:49 -0800 | [diff] [blame] | 87 | |
| 88 | double |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 89 | GetMaxSize() const; |
Alexander Afanasyev | b7ad232 | 2012-01-17 22:54:49 -0800 | [diff] [blame] | 90 | |
| 91 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 92 | SetMaxSize(double size); |
Alexander Afanasyev | d1f7c7b | 2013-01-31 13:34:37 -0800 | [diff] [blame] | 93 | |
Alexander Afanasyev | fdd4541 | 2013-05-16 22:24:33 -0700 | [diff] [blame] | 94 | uint32_t |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 95 | GetSeqMax() const; |
Alexander Afanasyev | fdd4541 | 2013-05-16 22:24:33 -0700 | [diff] [blame] | 96 | |
| 97 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 98 | SetSeqMax(uint32_t seqMax); |
Alexander Afanasyev | fdd4541 | 2013-05-16 22:24:33 -0700 | [diff] [blame] | 99 | |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 100 | private: |
Alexander Afanasyev | b7ad232 | 2012-01-17 22:54:49 -0800 | [diff] [blame] | 101 | uint32_t m_payloadSize; // expected payload size |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 102 | double m_maxSize; // max size to request |
Alexander Afanasyev | b7ad232 | 2012-01-17 22:54:49 -0800 | [diff] [blame] | 103 | |
Alexander Afanasyev | d1f7c7b | 2013-01-31 13:34:37 -0800 | [diff] [blame] | 104 | uint32_t m_initialWindow; |
| 105 | bool m_setInitialWindowOnTimeout; |
| 106 | |
Alexander Afanasyev | e4c2ece | 2012-01-11 10:44:40 -0800 | [diff] [blame] | 107 | TracedValue<uint32_t> m_window; |
Alexander Afanasyev | 06b42ec | 2012-01-11 19:05:36 -0800 | [diff] [blame] | 108 | TracedValue<uint32_t> m_inFlight; |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 109 | }; |
| 110 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 111 | } // namespace ndn |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 112 | } // namespace ns3 |
| 113 | |
| 114 | #endif |