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 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 25 | #include "ndn-consumer.h" |
Alexander Afanasyev | e4c2ece | 2012-01-11 10:44:40 -0800 | [diff] [blame] | 26 | #include "ns3/traced-value.h" |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 27 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 28 | namespace ns3 { |
| 29 | namespace ndn { |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 30 | |
| 31 | /** |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 32 | * @ingroup ndn |
| 33 | * \brief Ndn application for sending out Interest packets (window-based) |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 34 | * |
| 35 | * !!! ATTENTION !!! This is highly experimental and relies on experimental features of the simulator. |
| 36 | * Behavior may be unpredictable if used incorrectly. |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 37 | */ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 38 | class ConsumerWindow: public Consumer |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 39 | { |
| 40 | public: |
| 41 | static TypeId GetTypeId (); |
| 42 | |
| 43 | /** |
| 44 | * \brief Default constructor |
| 45 | */ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 46 | ConsumerWindow (); |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 47 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 48 | // From App |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 49 | // virtual void |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 50 | // OnInterest (const Ptr<const InterestHeader> &interest); |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 51 | |
| 52 | virtual void |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 53 | OnNack (const Ptr<const InterestHeader> &interest, Ptr<Packet> payload); |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 54 | |
| 55 | virtual void |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 56 | OnContentObject (const Ptr<const ContentObjectHeader> &contentObject, |
Alexander Afanasyev | e9c9d72 | 2012-01-19 16:59:30 -0800 | [diff] [blame] | 57 | Ptr<Packet> payload); |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 58 | |
| 59 | virtual void |
| 60 | OnTimeout (uint32_t sequenceNumber); |
| 61 | |
| 62 | protected: |
| 63 | /** |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 64 | * \brief Constructs the Interest packet and sends it using a callback to the underlying NDN protocol |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 65 | */ |
| 66 | virtual void |
| 67 | ScheduleNextPacket (); |
| 68 | |
| 69 | private: |
| 70 | virtual void |
| 71 | SetWindow (uint32_t window); |
| 72 | |
| 73 | uint32_t |
| 74 | GetWindow () const; |
Alexander Afanasyev | b7ad232 | 2012-01-17 22:54:49 -0800 | [diff] [blame] | 75 | |
| 76 | virtual void |
| 77 | SetPayloadSize (uint32_t payload); |
| 78 | |
| 79 | uint32_t |
| 80 | GetPayloadSize () const; |
| 81 | |
| 82 | double |
| 83 | GetMaxSize () const; |
| 84 | |
| 85 | void |
| 86 | SetMaxSize (double size); |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 87 | |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 88 | private: |
Alexander Afanasyev | b7ad232 | 2012-01-17 22:54:49 -0800 | [diff] [blame] | 89 | uint32_t m_payloadSize; // expected payload size |
| 90 | double m_maxSize; // max size to request |
| 91 | |
Alexander Afanasyev | e4c2ece | 2012-01-11 10:44:40 -0800 | [diff] [blame] | 92 | TracedValue<uint32_t> m_window; |
Alexander Afanasyev | 06b42ec | 2012-01-11 19:05:36 -0800 | [diff] [blame] | 93 | TracedValue<uint32_t> m_inFlight; |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 94 | }; |
| 95 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 96 | } // namespace ndn |
Alexander Afanasyev | 359bfb7 | 2012-01-09 18:42:50 -0800 | [diff] [blame] | 97 | } // namespace ns3 |
| 98 | |
| 99 | #endif |