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
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;
139  EventId m_sendEvent;
140  Time m_retxTimer;
141  EventId m_retxEvent;
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
ndn-app.hpp
ns3::ndn::Consumer::FirstInterestDataDelayCallback
void(* FirstInterestDataDelayCallback)(Ptr< App > app, uint32_t seqno, Time delay, uint32_t retxCount, int32_t hopCount)
Definition: ndn-consumer.hpp:97
ns3::ndn::Consumer::GetRetxTimer
Time GetRetxTimer() const
Returns the frequency of checking the retransmission timeouts.
Definition: ndn-consumer.cpp:105
ns3::ndn::Consumer::m_rand
Ptr< UniformRandomVariable > m_rand
nonce generator
Definition: ndn-consumer.hpp:135
ns3
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-app-link-service.cpp:32
ns3::ndn::Consumer::~Consumer
virtual ~Consumer()
Definition: ndn-consumer.hpp:59
ns3::ndn::Consumer::Consumer
Consumer()
Default constructor Sets up randomizer function and packet sequence number.
Definition: ndn-consumer.cpp:81
ns3::ndn::Consumer::m_sendEvent
EventId m_sendEvent
EventId of pending "send packet" event.
Definition: ndn-consumer.hpp:139
ns3::ndn::Consumer::GetTypeId
static TypeId GetTypeId()
Definition: ndn-consumer.cpp:48
ns3::ndn::Consumer::WillSendOutInterest
virtual void WillSendOutInterest(uint32_t sequenceNumber)
An event that is fired just before an Interest packet is actually send out (send is inevitable)
Definition: ndn-consumer.cpp:280
ns3::ndn::Consumer::LastRetransmittedInterestDataDelayCallback
void(* LastRetransmittedInterestDataDelayCallback)(Ptr< App > app, uint32_t seqno, Time delay, int32_t hopCount)
Definition: ndn-consumer.hpp:96
ns3::ndn::Consumer::m_seqMax
uint32_t m_seqMax
maximum number of sequence number
Definition: ndn-consumer.hpp:138
ns3::ndn::Name
Name
Definition: ndn-common.cpp:25
ns3::ndn::Consumer::StartApplication
virtual void StartApplication()
Called at time specified by Start.
Definition: ndn-consumer.cpp:136
ns3::ndn::Consumer::SetRetxTimer
void SetRetxTimer(Time retxTimer)
Modifies the frequency of checking the retransmission timeouts.
Definition: ndn-consumer.cpp:92
ndn::time
Definition: time-custom-clock.hpp:28
ns3::ndn::Consumer
NDN application for sending out Interest packets.
Definition: ndn-consumer.hpp:49
ns3::ndn::Consumer::StopApplication
virtual void StopApplication()
Called at time specified by Stop.
Definition: ndn-consumer.cpp:147
ns3::ndn::Consumer::m_retxEvent
EventId m_retxEvent
Event to check whether or not retransmission should be performed.
Definition: ndn-consumer.hpp:141
ns3::ndn::Consumer::OnTimeout
virtual void OnTimeout(uint32_t sequenceNumber)
Timeout event.
Definition: ndn-consumer.cpp:266
ns3::ndn::Consumer::m_seq
uint32_t m_seq
currently requested sequence number
Definition: ndn-consumer.hpp:137
ns3::ndn::Consumer::m_interestLifeTime
Time m_interestLifeTime
LifeTime for interest packet.
Definition: ndn-consumer.hpp:147
ns3::ndn::App
Base class that all NDN applications should be derived from.
Definition: ndn-app.hpp:48
ns3::ndn::Consumer::ScheduleNextPacket
virtual void ScheduleNextPacket()=0
Constructs the Interest packet and sends it using a callback to the underlying NDN protocol.
ns3::ndn::Consumer::m_offTime
Time m_offTime
Time interval between packets.
Definition: ndn-consumer.hpp:145
ns3::ndn::Consumer::m_interestName
Name m_interestName
NDN Name of the Interest (use Name)
Definition: ndn-consumer.hpp:146
ns3::ndn::Consumer::m_retxTimer
Time m_retxTimer
Currently estimated retransmission timer.
Definition: ndn-consumer.hpp:140
ns3::ndn::Consumer::OnData
virtual void OnData(shared_ptr< const Data > contentObject)
Method that will be called every time new Data arrives.
Definition: ndn-consumer.cpp:213
ns3::ndn::Consumer::m_rtt
Ptr< RttEstimator > m_rtt
RTT estimator.
Definition: ndn-consumer.hpp:143
ns3::ndn::Consumer::SendPacket
void SendPacket()
Actually send packet.
Definition: ndn-consumer.cpp:159
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34
ns3::ndn::Consumer::OnNack
virtual void OnNack(shared_ptr< const lp::Nack > nack)
Method that will be called every time new Nack arrives.
Definition: ndn-consumer.cpp:256
ns3::ndn::Consumer::CheckRetxTimeout
void CheckRetxTimeout()
Checks if the packet need to be retransmitted becuase of retransmission timer expiration.
Definition: ndn-consumer.cpp:111