NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
ndn-l3-tracer.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
20 #ifndef NDN_L3_TRACER_H
21 #define NDN_L3_TRACER_H
22 
23 #include "ns3/ndnSIM/model/ndn-common.hpp"
24 
25 #include "ns3/ptr.h"
26 #include "ns3/simple-ref-count.h"
27 
28 namespace nfd {
29 namespace pit {
30 class Entry;
31 } // namespace pit
32 } // namespace nfd
33 
34 namespace ns3 {
35 
36 class Node;
37 class Packet;
38 
39 namespace ndn {
40 
45 class L3Tracer : public SimpleRefCount<L3Tracer> {
46 public:
51  L3Tracer(Ptr<Node> node);
52 
57  L3Tracer(const std::string& node);
58 
62  virtual ~L3Tracer();
63 
69  virtual void
70  PrintHeader(std::ostream& os) const = 0;
71 
77  virtual void
78  Print(std::ostream& os) const = 0;
79 
80 protected:
81  void
82  Connect();
83 
84  virtual void
85  OutInterests(const Interest&, const Face&) = 0;
86 
87  virtual void
88  InInterests(const Interest&, const Face&) = 0;
89 
90  virtual void
91  OutData(const Data&, const Face&) = 0;
92 
93  virtual void
94  InData(const Data&, const Face&) = 0;
95 
96  virtual void
97  OutNack(const lp::Nack& nack, const Face&) = 0;
98 
99  virtual void
100  InNack(const lp::Nack&, const Face&) = 0;
101 
102  virtual void
103  SatisfiedInterests(const nfd::pit::Entry&, const Face&, const Data&) = 0;
104 
105  virtual void
106  TimedOutInterests(const nfd::pit::Entry&) = 0;
107 
108 protected:
109  std::string m_node;
110  Ptr<Node> m_nodePtr;
111 
112  struct Stats {
113  inline void
115  {
116  m_inInterests = 0;
117  m_outInterests = 0;
118  m_inData = 0;
119  m_outData = 0;
120  m_inNack = 0;
121  m_outNack = 0;
122  m_satisfiedInterests = 0;
123  m_timedOutInterests = 0;
124 
125  m_outSatisfiedInterests = 0;
126  m_outTimedOutInterests = 0;
127  }
128 
131  double m_inData;
132  double m_outData;
133  double m_inNack;
134  double m_outNack;
139  };
140 };
141 
145 inline std::ostream&
146 operator<<(std::ostream& os, const L3Tracer& tracer)
147 {
148  os << "# ";
149  tracer.PrintHeader(os);
150  os << "\n";
151  tracer.Print(os);
152  return os;
153 }
154 
155 } // namespace ndn
156 } // namespace ns3
157 
158 #endif // NDN_L3_TRACER_H
Copyright (c) 2011-2015 Regents of the University of California.
Base class for network-layer (incoming/outgoing Interests and Data) tracing of NDN stack...
represents a Network Nack
Definition: nack.hpp:40
virtual void Print(std::ostream &os) const =0
Print current trace data.
std::ostream & operator<<(std::ostream &os, const Network &network)
Definition: network.cpp:93
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
an Interest table entry
Definition: pit-entry.hpp:57
Copyright (c) 2011-2015 Regents of the University of California.
virtual void PrintHeader(std::ostream &os) const =0
Print head of the trace (e.g., for post-processing)