NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
ndn-l3-rate-tracer.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
20 #ifndef CCNX_RATE_L3_TRACER_H
21 #define CCNX_RATE_L3_TRACER_H
22 
23 #include "ns3/ndnSIM/model/ndn-common.hpp"
24 
25 #include "ndn-l3-tracer.hpp"
26 
27 #include "ns3/nstime.h"
28 #include "ns3/event-id.h"
29 #include "ns3/node-container.h"
30 
31 #include <tuple>
32 #include <map>
33 #include <list>
34 
35 namespace ns3 {
36 namespace ndn {
37 
42 class L3RateTracer : public L3Tracer {
43 public:
52  static void
53  InstallAll(const std::string& file, Time averagingPeriod = Seconds(0.5));
54 
63  static void
64  Install(const NodeContainer& nodes, const std::string& file, Time averagingPeriod = Seconds(0.5));
65 
74  static void
75  Install(Ptr<Node> node, const std::string& file, Time averagingPeriod = Seconds(0.5));
76 
83  static void
84  Destroy();
85 
91  L3RateTracer(shared_ptr<std::ostream> os, Ptr<Node> node);
92 
98  L3RateTracer(shared_ptr<std::ostream> os, const std::string& node);
99 
103  virtual ~L3RateTracer();
104 
117  static Ptr<L3RateTracer>
118  Install(Ptr<Node> node, shared_ptr<std::ostream> outputStream,
119  Time averagingPeriod = Seconds(0.5));
120 
121  // from L3Tracer
122  virtual void
123  PrintHeader(std::ostream& os) const;
124 
125  virtual void
126  Print(std::ostream& os) const;
127 
128 protected:
129  // from L3Tracer
130  virtual void
131  OutInterests(const Interest& interest, const Face& face);
132 
133  virtual void
134  InInterests(const Interest& interest, const Face& face);
135 
136  virtual void
137  OutData(const Data& data, const Face& face);
138 
139  virtual void
140  InData(const Data& data, const Face& face);
141 
142  virtual void
143  OutNack(const lp::Nack& nack, const Face& face);
144 
145  virtual void
146  InNack(const lp::Nack& nack, const Face& face);
147 
148  virtual void
149  SatisfiedInterests(const nfd::pit::Entry&, const Face&, const Data&);
150 
151  virtual void
153 
154 private:
155  void
156  SetAveragingPeriod(const Time& period);
157 
158  void
159  PeriodicPrinter();
160 
161  void
162  Reset();
163 
164  void
165  AddInfo(const Face& face);
166 
167 private:
168  shared_ptr<std::ostream> m_os;
169  Time m_period;
170  EventId m_printEvent;
171 
172  mutable std::map<nfd::FaceId, std::tuple<Stats, Stats, Stats, Stats>> m_stats;
173  std::map<nfd::FaceId, std::string> m_faceInfos; // needed, because face may no longer exists at the time of stat printing
174 };
175 
176 } // namespace ndn
177 } // namespace ns3
178 
179 #endif // CCNX_RATE_L3_TRACER_H
ns3::ndn::L3RateTracer::L3RateTracer
L3RateTracer(shared_ptr< std::ostream > os, Ptr< Node > node)
Trace constructor that attaches to the node using node pointer.
Definition: ndn-l3-rate-tracer.cpp:169
ns3::ndn::L3RateTracer::~L3RateTracer
virtual ~L3RateTracer()
Destructor.
Definition: ndn-l3-rate-tracer.cpp:183
ns3::ndn::L3RateTracer::Destroy
static void Destroy()
Explicit request to remove all statically created tracers.
Definition: ndn-l3-rate-tracer.cpp:44
ndn::tlv::Interest
@ Interest
Definition: tlv.hpp:65
ns3
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-app-link-service.cpp:32
ns3::ndn::L3RateTracer::InNack
virtual void InNack(const lp::Nack &nack, const Face &face)
Definition: ndn-l3-rate-tracer.cpp:352
ns3::ndn::L3RateTracer::TimedOutInterests
virtual void TimedOutInterests(const nfd::pit::Entry &)
Definition: ndn-l3-rate-tracer.cpp:380
ns3::ndn::L3RateTracer::InInterests
virtual void InInterests(const Interest &interest, const Face &face)
Definition: ndn-l3-rate-tracer.cpp:308
ns3::ndn::L3RateTracer::InData
virtual void InData(const Data &data, const Face &face)
Definition: ndn-l3-rate-tracer.cpp:330
ns3::ndn::L3Tracer
Base class for network-layer (incoming/outgoing Interests and Data) tracing of NDN stack.
Definition: ndn-l3-tracer.hpp:40
ns3::ndn::L3RateTracer::InstallAll
static void InstallAll(const std::string &file, Time averagingPeriod=Seconds(0.5))
Helper method to install tracers on all simulation nodes.
Definition: ndn-l3-rate-tracer.cpp:50
nfd::pit::Entry
An Interest table entry.
Definition: pit-entry.hpp:59
ns3::ndn::L3RateTracer::PrintHeader
virtual void PrintHeader(std::ostream &os) const
Print head of the trace (e.g., for post-processing)
Definition: ndn-l3-rate-tracer.cpp:206
ns3::ndn::L3RateTracer::SatisfiedInterests
virtual void SatisfiedInterests(const nfd::pit::Entry &, const Face &, const Data &)
Definition: ndn-l3-rate-tracer.cpp:363
Face
ndn Face
Definition: face-impl.hpp:41
ndn::tlv::Data
@ Data
Definition: tlv.hpp:66
ns3::ndn::L3RateTracer::OutInterests
virtual void OutInterests(const Interest &interest, const Face &face)
Definition: ndn-l3-rate-tracer.cpp:297
ndn::lp::Nack
represents a Network Nack
Definition: nack.hpp:39
ns3::ndn::L3RateTracer::OutNack
virtual void OutNack(const lp::Nack &nack, const Face &face)
Definition: ndn-l3-rate-tracer.cpp:341
ns3::ndn::L3RateTracer::OutData
virtual void OutData(const Data &data, const Face &face)
Definition: ndn-l3-rate-tracer.cpp:319
ns3::ndn::L3RateTracer
NDN network-layer rate tracer.
Definition: ndn-l3-rate-tracer.hpp:42
ndn-l3-tracer.hpp
ns3::ndn::L3RateTracer::Install
static void Install(const NodeContainer &nodes, const std::string &file, Time averagingPeriod=Seconds(0.5))
Helper method to install tracers on the selected simulation nodes.
Definition: ndn-l3-rate-tracer.cpp:84
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34
ns3::ndn::L3RateTracer::Print
virtual void Print(std::ostream &os) const
Print current trace data.
Definition: ndn-l3-rate-tracer.cpp:262