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
ipv4-rate-l3-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 IPV4_RATE_L3_TRACER_H
22 #define IPV4_RATE_L3_TRACER_H
23 
24 #include "ipv4-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 
34 namespace ns3 {
35 
41 {
42 public:
46  Ipv4RateL3Tracer (boost::shared_ptr<std::ostream> os, Ptr<Node> node);
47  virtual ~Ipv4RateL3Tracer ();
48 
60  static boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<Ipv4RateL3Tracer> > >
61  InstallAll (const std::string &file, Time averagingPeriod = Seconds (0.5));
62 
74  static boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<Ipv4RateL3Tracer> > >
75  Install (const NodeContainer &nodes, const std::string &file, Time averagingPeriod = Seconds (0.5));
76 
88  static boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<Ipv4RateL3Tracer> > >
89  Install (Ptr<Node> node, const std::string &file, Time averagingPeriod = Seconds (0.5));
90 
101  static Ptr<Ipv4RateL3Tracer>
102  Install (Ptr<Node> node, boost::shared_ptr<std::ostream> outputStream, Time averagingPeriod = Seconds (0.5));
103 
104  void
105  SetAveragingPeriod (const Time &period);
106 
107  virtual void
108  PrintHeader (std::ostream &os) const;
109 
110  virtual void
111  Print (std::ostream &os) const;
112 
113  virtual void
114  Rx (Ptr<const Packet>, Ptr<Ipv4>, uint32_t);
115 
116  virtual void
117  Tx (Ptr<const Packet>, Ptr<Ipv4>, uint32_t);
118 
119  virtual void
120  Drop (const Ipv4Header &, Ptr<const Packet>, Ipv4L3Protocol::DropReason, Ptr<Ipv4>, uint32_t);
121 
122 private:
123  void
124  PeriodicPrinter ();
125 
126  void
127  Reset ();
128 
129 private:
130  boost::shared_ptr<std::ostream> m_os;
131  Time m_period;
132  EventId m_printEvent;
133 
134  mutable std::map<uint32_t, boost::tuple<Stats, Stats, Stats, Stats> > m_stats;
135 };
136 
137 } // namespace ns3
138 
139 #endif // IPV4_RATE_L3_TRACER_H
static boost::tuple< boost::shared_ptr< std::ostream >, std::list< Ptr< Ipv4RateL3Tracer > > > Install(const NodeContainer &nodes, const std::string &file, Time averagingPeriod=Seconds(0.5))
Helper method to install tracers on the selected simulation nodes.
static boost::tuple< boost::shared_ptr< std::ostream >, std::list< Ptr< Ipv4RateL3Tracer > > > InstallAll(const std::string &file, Time averagingPeriod=Seconds(0.5))
Helper method to install tracers on all simulation nodes.
Base class for IPv4 network-layer tracers.
Ipv4RateL3Tracer(boost::shared_ptr< std::ostream > os, Ptr< Node > node)
Network layer tracer constructor.
IPv4 network-layer rate tracer.