blob: ced3113932921bc522dfa91da522dd54bdf3cd96 [file] [log] [blame]
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -08001/* -*- 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
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080024#include "ndn-l3-tracer.h"
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -080025
26#include "ns3/nstime.h"
27#include "ns3/event-id.h"
28
29#include <boost/tuple/tuple.hpp>
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080030#include <boost/shared_ptr.hpp>
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -080031#include <map>
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080032#include <list>
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -080033
34namespace ns3 {
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080035namespace ndn {
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -080036
37/**
38 * @ingroup ccnx
39 * @brief CCNx network-layer rate tracer
40 */
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080041class L3RateTracer : public L3Tracer
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -080042{
43public:
44 /**
45 * @brief Network layer tracer constructor
46 */
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080047 L3RateTracer (boost::shared_ptr<std::ostream> os, Ptr<Node> node);
48 L3RateTracer (boost::shared_ptr<std::ostream> os, const std::string &node);
49 virtual ~L3RateTracer ();
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -080050
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080051 static boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<L3RateTracer> > >
52 InstallAll (const std::string &file, Time averagingPeriod = Seconds (0.5));
53
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -080054 void
55 SetAveragingPeriod (const Time &period);
56
57 virtual void
58 PrintHeader (std::ostream &os) const;
59
60 virtual void
61 Print (std::ostream &os) const;
62
63 virtual void
64 OutInterests (std::string context,
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080065 Ptr<const InterestHeader>, Ptr<const Face>);
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -080066
67 virtual void
68 InInterests (std::string context,
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080069 Ptr<const InterestHeader>, Ptr<const Face>);
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -080070
71 virtual void
72 DropInterests (std::string context,
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080073 Ptr<const InterestHeader>, Ptr<const Face>);
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -080074
75 virtual void
76 OutNacks (std::string context,
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080077 Ptr<const InterestHeader>, Ptr<const Face>);
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -080078
79 virtual void
80 InNacks (std::string context,
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080081 Ptr<const InterestHeader>, Ptr<const Face>);
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -080082
83 virtual void
84 DropNacks (std::string context,
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080085 Ptr<const InterestHeader>, Ptr<const Face>);
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -080086
87 virtual void
88 OutData (std::string context,
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080089 Ptr<const ContentObjectHeader>, Ptr<const Packet>, bool fromCache, Ptr<const Face>);
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -080090
91 virtual void
92 InData (std::string context,
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080093 Ptr<const ContentObjectHeader>, Ptr<const Packet>, Ptr<const Face>);
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -080094
95 virtual void
96 DropData (std::string context,
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080097 Ptr<const ContentObjectHeader>, Ptr<const Packet>, Ptr<const Face>);
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -080098
99private:
100 void
101 PeriodicPrinter ();
102
103 void
104 Reset ();
105
106private:
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800107 boost::shared_ptr<std::ostream> m_os;
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -0800108 Time m_period;
109 EventId m_printEvent;
110
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800111 mutable std::map<Ptr<const Face>, boost::tuple<Stats, Stats, Stats, Stats> > m_stats;
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -0800112};
113
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800114} // namespace ndn
Alexander Afanasyevb3e4b852011-12-23 15:58:20 -0800115} // namespace ns3
116
117#endif // CCNX_RATE_L3_TRACER_H