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
ndn-l3-rate-tracer.h
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2 /*
3  * Copyright (c) 2011 UCLA
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 CCNX_RATE_L3_TRACER_H
22 #define CCNX_RATE_L3_TRACER_H
23 
24 #include "ndn-l3-tracer.h"
25 
26 #include "ns3/nstime.h"
27 #include "ns3/event-id.h"
28 #include <ns3/node-container.h>
29 
30 #include <boost/tuple/tuple.hpp>
31 #include <boost/shared_ptr.hpp>
32 #include <map>
33 #include <list>
34 
35 namespace ns3 {
36 namespace ndn {
37 
42 class L3RateTracer : public L3Tracer
43 {
44 public:
52  static void
53  InstallAll (const std::string &file, Time averagingPeriod = Seconds (0.5));
54 
62  static void
63  Install (const NodeContainer &nodes, const std::string &file, Time averagingPeriod = Seconds (0.5));
64 
72  static void
73  Install (Ptr<Node> node, const std::string &file, Time averagingPeriod = Seconds (0.5));
74 
81  static void
82  Destroy ();
83 
89  L3RateTracer (boost::shared_ptr<std::ostream> os, Ptr<Node> node);
90 
96  L3RateTracer (boost::shared_ptr<std::ostream> os, const std::string &node);
97 
101  virtual ~L3RateTracer ();
102 
113  static Ptr<L3RateTracer>
114  Install (Ptr<Node> node, boost::shared_ptr<std::ostream> outputStream, Time averagingPeriod = Seconds (0.5));
115 
116  // from L3Tracer
117  virtual void
118  PrintHeader (std::ostream &os) const;
119 
120  virtual void
121  Print (std::ostream &os) const;
122 
123 protected:
124  // from L3Tracer
125  virtual void
126  OutInterests (Ptr<const Interest>, Ptr<const Face>);
127 
128  virtual void
129  InInterests (Ptr<const Interest>, Ptr<const Face>);
130 
131  virtual void
132  DropInterests (Ptr<const Interest>, Ptr<const Face>);
133 
134  virtual void
135  OutNacks (Ptr<const Interest>, Ptr<const Face>);
136 
137  virtual void
138  InNacks (Ptr<const Interest>, Ptr<const Face>);
139 
140  virtual void
141  DropNacks (Ptr<const Interest>, Ptr<const Face>);
142 
143  virtual void
144  OutData (Ptr<const Data>, bool fromCache, Ptr<const Face>);
145 
146  virtual void
147  InData (Ptr<const Data>, Ptr<const Face>);
148 
149  virtual void
150  DropData (Ptr<const Data>, Ptr<const Face>);
151 
152  virtual void
153  SatisfiedInterests (Ptr<const pit::Entry>);
154 
155  virtual void
156  TimedOutInterests (Ptr<const pit::Entry>);
157 
158 private:
159  void
160  SetAveragingPeriod (const Time &period);
161 
162  void
163  PeriodicPrinter ();
164 
165  void
166  Reset ();
167 
168 private:
169  boost::shared_ptr<std::ostream> m_os;
170  Time m_period;
171  EventId m_printEvent;
172 
173  mutable std::map<Ptr<const Face>, boost::tuple<Stats, Stats, Stats, Stats> > m_stats;
174 };
175 
176 } // namespace ndn
177 } // namespace ns3
178 
179 #endif // CCNX_RATE_L3_TRACER_H
virtual void Print(std::ostream &os) const
Print current trace data.
virtual ~L3RateTracer()
Destructor.
static void Destroy()
Explicit request to remove all statically created tracers.
static void InstallAll(const std::string &file, Time averagingPeriod=Seconds(0.5))
Helper method to install tracers on all simulation nodes.
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.
L3RateTracer(boost::shared_ptr< std::ostream > os, Ptr< Node > node)
Trace constructor that attaches to the node using node pointer.
Base class for network-layer (incoming/outgoing Interests and Data) tracing of NDN stack...
Definition: ndn-l3-tracer.h:52
virtual void PrintHeader(std::ostream &os) const
Print head of the trace (e.g., for post-processing)
NDN network-layer rate tracer.