NS-3 based Named Data Networking (NDN) simulator
ndnSIM: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
l2-tracer.h
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2 /*
3  * Copyright (c) 2013 University of California, Los Angeles
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19  */
20 
21 #ifndef L2_TRACER_H
22 #define L2_TRACER_H
23 
24 #include "ns3/ptr.h"
25 #include "ns3/simple-ref-count.h"
26 #include "ns3/packet.h"
27 
28 namespace ns3 {
29 
30 class Node;
31 
38 class L2Tracer : public SimpleRefCount<L2Tracer>
39 {
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  {
65  void Reset ()
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
Link-layer tracer.
Definition: l2-tracer.h:38
std::ostream & operator<<(std::ostream &os, const Batches &batch)
Output contents of the Batches to the std::ostream.
Definition: batches.cc:28