NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
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-stream.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 
34 #include <set>
35 #include <map>
36 
37 #include <boost/multi_index_container.hpp>
38 #include <boost/multi_index/tag.hpp>
39 #include <boost/multi_index/ordered_index.hpp>
40 #include <boost/multi_index/member.hpp>
41 
42 namespace ns3 {
43 namespace ndn {
44 
49 class Consumer : public App {
50 public:
51  static TypeId
52  GetTypeId();
53 
58  Consumer();
59  virtual ~Consumer(){};
60 
61  // From App
62  virtual void
63  OnData(shared_ptr<const Data> contentObject);
64 
65  // From App
66  virtual void
67  OnNack(shared_ptr<const lp::Nack> nack);
68 
73  virtual void
74  OnTimeout(uint32_t sequenceNumber);
75 
79  void
80  SendPacket();
81 
92  virtual void
93  WillSendOutInterest(uint32_t sequenceNumber);
94 
95 public:
96  typedef void (*LastRetransmittedInterestDataDelayCallback)(Ptr<App> app, uint32_t seqno, Time delay, int32_t hopCount);
97  typedef void (*FirstInterestDataDelayCallback)(Ptr<App> app, uint32_t seqno, Time delay, uint32_t retxCount, int32_t hopCount);
98 
99 protected:
100  // from App
101  virtual void
103 
104  virtual void
105  StopApplication();
106 
111  virtual void
112  ScheduleNextPacket() = 0;
113 
117  void
119 
124  void
125  SetRetxTimer(Time retxTimer);
126 
131  Time
132  GetRetxTimer() const;
133 
134 protected:
135  Ptr<UniformRandomVariable> m_rand;
136 
137  uint32_t m_seq;
138  uint32_t m_seqMax;
140  Time m_retxTimer;
142 
143  Ptr<RttEstimator> m_rtt;
144 
145  Time m_offTime;
148 
150 
153  struct RetxSeqsContainer : public std::set<uint32_t> {
154  };
155 
156  RetxSeqsContainer m_retxSeqs;
157 
161  struct SeqTimeout {
162  SeqTimeout(uint32_t _seq, Time _time)
163  : seq(_seq)
164  , time(_time)
165  {
166  }
167 
168  uint32_t seq;
169  Time time;
170  };
172 
174  class i_seq {
175  };
176  class i_timestamp {
177  };
179 
181 
184  struct SeqTimeoutsContainer
185  : public boost::multi_index::
186  multi_index_container<SeqTimeout,
187  boost::multi_index::
188  indexed_by<boost::multi_index::
189  ordered_unique<boost::multi_index::tag<i_seq>,
190  boost::multi_index::
191  member<SeqTimeout, uint32_t,
192  &SeqTimeout::seq>>,
193  boost::multi_index::
194  ordered_non_unique<boost::multi_index::
195  tag<i_timestamp>,
196  boost::multi_index::
197  member<SeqTimeout, Time,
198  &SeqTimeout::time>>>> {
199  };
200 
201  SeqTimeoutsContainer m_seqTimeouts;
202 
203  SeqTimeoutsContainer m_seqLastDelay;
204  SeqTimeoutsContainer m_seqFullDelay;
205  std::map<uint32_t, uint32_t> m_seqRetxCounts;
206 
207  TracedCallback<Ptr<App> /* app */, uint32_t /* seqno */, Time /* delay */, int32_t /*hop count*/>
208  m_lastRetransmittedInterestDataDelay;
209  TracedCallback<Ptr<App> /* app */, uint32_t /* seqno */, Time /* delay */,
210  uint32_t /*retx count*/, int32_t /*hop count*/> m_firstInterestDataDelay;
211 
213 };
214 
215 } // namespace ndn
216 } // namespace ns3
217 
218 #endif
void(* LastRetransmittedInterestDataDelayCallback)(Ptr< App > app, uint32_t seqno, Time delay, int32_t hopCount)
Time m_interestLifeTime
LifeTime for interest packet.
virtual void OnTimeout(uint32_t sequenceNumber)
Timeout event.
uint32_t m_seqMax
maximum number of sequence number
Copyright (c) 2011-2015 Regents of the University of California.
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.
Time GetRetxTimer() const
Returns the frequency of checking the retransmission timeouts.
virtual void OnNack(shared_ptr< const lp::Nack > nack)
Method that will be called every time new Nack arrives.
Copyright (c) 2011-2015 Regents of the University of California.
void(* FirstInterestDataDelayCallback)(Ptr< App > app, uint32_t seqno, Time delay, uint32_t retxCount, int32_t hopCount)
Base class that all NDN applications should be derived from.
Definition: ndn-app.hpp:48
Ptr< UniformRandomVariable > m_rand
nonce generator
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()
virtual void StartApplication()
Called at time specified by Start.