NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: 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  SatisfiedInterests(const nfd::pit::Entry&, const Face&, const Data&) = 0;
98 
99  virtual void
100  TimedOutInterests(const nfd::pit::Entry&) = 0;
101 
102 protected:
103  std::string m_node;
104  Ptr<Node> m_nodePtr;
105 
106  struct Stats {
107  inline void
109  {
110  m_inInterests = 0;
111  m_outInterests = 0;
112  m_inData = 0;
113  m_outData = 0;
114  m_satisfiedInterests = 0;
115  m_timedOutInterests = 0;
116 
117  m_outSatisfiedInterests = 0;
118  m_outTimedOutInterests = 0;
119  }
120 
123  double m_inData;
124  double m_outData;
129  };
130 };
131 
135 inline std::ostream&
136 operator<<(std::ostream& os, const L3Tracer& tracer)
137 {
138  os << "# ";
139  tracer.PrintHeader(os);
140  os << "\n";
141  tracer.Print(os);
142  return os;
143 }
144 
145 } // namespace ndn
146 } // namespace ns3
147 
148 #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...
virtual void Print(std::ostream &os) const =0
Print current trace data.
std::ostream & operator<<(std::ostream &os, const Network &network)
Definition: network.cpp:58
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
represents a PIT entry
Definition: pit-entry.hpp:69
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)