NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
l2-tracer.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
20 #ifndef L2_TRACER_H
21 #define L2_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 #include "ns3/packet.h"
28 
29 namespace ns3 {
30 
31 class Node;
32 
39 class L2Tracer : public SimpleRefCount<L2Tracer> {
40 public:
41  L2Tracer(Ptr<Node> node);
42  virtual ~L2Tracer(){};
43 
44  void
45  Connect();
46 
47  virtual void
48  PrintHeader(std::ostream& os) const = 0;
49 
50  virtual void
51  Print(std::ostream& os) const = 0;
52 
53  virtual void
54  Drop(Ptr<const Packet>) = 0;
55 
56  // Rx/Tx is NetDevice specific
57  // please refer to pyviz.cc in order to extend this tracer
58 
59 protected:
60  std::string m_node;
61  Ptr<Node> m_nodePtr;
62 
63  struct Stats {
64  void
66  {
67  m_in = 0;
68  m_out = 0;
69  m_drop = 0;
70  }
71 
72  uint64_t m_in;
73  uint64_t m_out;
74  uint64_t m_drop;
75  };
76 };
77 
78 inline std::ostream&
79 operator<<(std::ostream& os, const L2Tracer& tracer)
80 {
81  os << "# ";
82  tracer.PrintHeader(os);
83  os << "\n";
84  tracer.Print(os);
85  return os;
86 }
87 
88 } // namespace ns3
89 
90 #endif // L2_TRACER_H
ns3::L2Tracer::Stats::m_drop
uint64_t m_drop
Definition: l2-tracer.hpp:74
ns3
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-app-link-service.cpp:32
ns3::L2Tracer::~L2Tracer
virtual ~L2Tracer()
Definition: l2-tracer.hpp:42
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Batches &batch)
Output contents of the Batches to the std::ostream.
Definition: batches.cpp:27
ns3::L2Tracer::m_node
std::string m_node
Definition: l2-tracer.hpp:60
ns3::L2Tracer::m_nodePtr
Ptr< Node > m_nodePtr
Definition: l2-tracer.hpp:61
ns3::L2Tracer::L2Tracer
L2Tracer(Ptr< Node > node)
Definition: l2-tracer.cpp:33
ns3::L2Tracer::PrintHeader
virtual void PrintHeader(std::ostream &os) const =0
ns3::L2Tracer::Stats::m_in
uint64_t m_in
Definition: l2-tracer.hpp:72
ns3::L2Tracer::Stats::m_out
uint64_t m_out
Definition: l2-tracer.hpp:73
ns3::L2Tracer::Print
virtual void Print(std::ostream &os) const =0
ns3::L2Tracer::Connect
void Connect()
Definition: l2-tracer.cpp:47
ns3::L2Tracer::Stats::Reset
void Reset()
Definition: l2-tracer.hpp:65
ns3::L2Tracer::Drop
virtual void Drop(Ptr< const Packet >)=0
ns3::L2Tracer
Link-layer tracer.
Definition: l2-tracer.hpp:39
ns3::L2Tracer::Stats
Definition: l2-tracer.hpp:63