NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ndn-consumer.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
20 #ifndef NDN_CONSUMER_H
21 #define NDN_CONSUMER_H
22 
23 #include "ns3/ndnSIM/model/ndn-common.hpp"
24 
25 #include "ndn-app.hpp"
26 
27 #include "ns3/random-variable.h"
28 #include "ns3/nstime.h"
29 #include "ns3/data-rate.h"
30 
31 #include "ns3/ndnSIM/model/ndn-common.hpp"
32 #include "ns3/ndnSIM/utils/ndn-rtt-estimator.hpp"
33 #include "ns3/ndnSIM/utils/ndn-fw-hop-count-tag.hpp"
34 
35 #include <set>
36 #include <map>
37 
38 #include <boost/multi_index_container.hpp>
39 #include <boost/multi_index/tag.hpp>
40 #include <boost/multi_index/ordered_index.hpp>
41 #include <boost/multi_index/member.hpp>
42 
43 namespace ns3 {
44 namespace ndn {
45 
50 class Consumer : public App {
51 public:
52  static TypeId
53  GetTypeId();
54 
59  Consumer();
60  virtual ~Consumer(){};
61 
62  // From App
63  virtual void
64  OnData(shared_ptr<const Data> contentObject);
65 
70  virtual void
71  OnTimeout(uint32_t sequenceNumber);
72 
76  void
77  SendPacket();
78 
89  virtual void
90  WillSendOutInterest(uint32_t sequenceNumber);
91 
92 protected:
93  // from App
94  virtual void
96 
97  virtual void
99 
104  virtual void
105  ScheduleNextPacket() = 0;
106 
110  void
112 
117  void
118  SetRetxTimer(Time retxTimer);
119 
124  Time
125  GetRetxTimer() const;
126 
127 protected:
128  UniformVariable m_rand;
129 
130  uint32_t m_seq;
131  uint32_t m_seqMax;
133  Time m_retxTimer;
135 
136  Ptr<RttEstimator> m_rtt;
137 
138  Time m_offTime;
141 
143 
146  struct RetxSeqsContainer : public std::set<uint32_t> {
147  };
148 
149  RetxSeqsContainer m_retxSeqs;
150 
154  struct SeqTimeout {
155  SeqTimeout(uint32_t _seq, Time _time)
156  : seq(_seq)
157  , time(_time)
158  {
159  }
160 
161  uint32_t seq;
162  Time time;
163  };
165 
167  class i_seq {
168  };
169  class i_timestamp {
170  };
172 
174 
177  struct SeqTimeoutsContainer
178  : public boost::multi_index::
179  multi_index_container<SeqTimeout,
180  boost::multi_index::
181  indexed_by<boost::multi_index::
182  ordered_unique<boost::multi_index::tag<i_seq>,
183  boost::multi_index::
184  member<SeqTimeout, uint32_t,
185  &SeqTimeout::seq>>,
186  boost::multi_index::
187  ordered_non_unique<boost::multi_index::
188  tag<i_timestamp>,
189  boost::multi_index::
190  member<SeqTimeout, Time,
191  &SeqTimeout::time>>>> {
192  };
193 
194  SeqTimeoutsContainer m_seqTimeouts;
195 
196  SeqTimeoutsContainer m_seqLastDelay;
197  SeqTimeoutsContainer m_seqFullDelay;
198  std::map<uint32_t, uint32_t> m_seqRetxCounts;
199 
200  TracedCallback<Ptr<App> /* app */, uint32_t /* seqno */, Time /* delay */, int32_t /*hop count*/>
201  m_lastRetransmittedInterestDataDelay;
202  TracedCallback<Ptr<App> /* app */, uint32_t /* seqno */, Time /* delay */,
203  uint32_t /*retx count*/, int32_t /*hop count*/> m_firstInterestDataDelay;
204 
206 };
207 
208 } // namespace ndn
209 } // namespace ns3
210 
211 #endif
Time m_interestLifeTime
LifeTime for interest packet.
virtual void OnTimeout(uint32_t sequenceNumber)
Timeout event.
uint32_t m_seqMax
maximum number of sequence number
void SetRetxTimer(Time retxTimer)
Modifies the frequency of checking the retransmission timeouts.
Time m_offTime
Time interval between packets.
uint32_t m_seq
currently requested sequence number
Time m_retxTimer
Currently estimated retransmission timer.
Ptr< RttEstimator > m_rtt
RTT estimator.
Name m_interestName
NDN Name of the Interest (use Name)
void CheckRetxTimeout()
Checks if the packet need to be retransmitted becuase of retransmission timer expiration.
NDN application for sending out Interest packets.
virtual void OnData(shared_ptr< const Data > contentObject)
Method that will be called every time new Data arrives.
void SendPacket()
Actually send packet.
virtual void ScheduleNextPacket()=0
Constructs the Interest packet and sends it using a callback to the underlying NDN protocol...
Opaque type (shared_ptr) representing ID of a scheduled event.
UniformVariable m_rand
nonce generator
Base class that all NDN applications should be derived from.
Definition: ndn-app.hpp:47
Consumer()
Default constructor Sets up randomizer function and packet sequence number.
virtual void StopApplication()
Called at time specified by Stop.
EventId m_sendEvent
EventId of pending "send packet" event.
virtual void WillSendOutInterest(uint32_t sequenceNumber)
An event that is fired just before an Interest packet is actually send out (send is inevitable) ...
EventId m_retxEvent
Event to check whether or not retransmission should be performed.
static TypeId GetTypeId()
Time GetRetxTimer() const
Returns the frequency of checking the retransmission timeouts.
virtual void StartApplication()
Called at time specified by Start.