Alexander Afanasyev | b3e4b85 | 2011-12-23 15:58:20 -0800 | [diff] [blame] | 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 | |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 24 | #include "ndn-l3-tracer.h" |
Alexander Afanasyev | b3e4b85 | 2011-12-23 15:58:20 -0800 | [diff] [blame] | 25 | |
| 26 | #include "ns3/nstime.h" |
| 27 | #include "ns3/event-id.h" |
| 28 | |
| 29 | #include <boost/tuple/tuple.hpp> |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 30 | #include <boost/shared_ptr.hpp> |
Alexander Afanasyev | b3e4b85 | 2011-12-23 15:58:20 -0800 | [diff] [blame] | 31 | #include <map> |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 32 | #include <list> |
Alexander Afanasyev | b3e4b85 | 2011-12-23 15:58:20 -0800 | [diff] [blame] | 33 | |
| 34 | namespace ns3 { |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 35 | namespace ndn { |
Alexander Afanasyev | b3e4b85 | 2011-12-23 15:58:20 -0800 | [diff] [blame] | 36 | |
| 37 | /** |
| 38 | * @ingroup ccnx |
| 39 | * @brief CCNx network-layer rate tracer |
| 40 | */ |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 41 | class L3RateTracer : public L3Tracer |
Alexander Afanasyev | b3e4b85 | 2011-12-23 15:58:20 -0800 | [diff] [blame] | 42 | { |
| 43 | public: |
| 44 | /** |
| 45 | * @brief Network layer tracer constructor |
| 46 | */ |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 47 | 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 Afanasyev | b3e4b85 | 2011-12-23 15:58:20 -0800 | [diff] [blame] | 50 | |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 51 | 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 Afanasyev | b3e4b85 | 2011-12-23 15:58:20 -0800 | [diff] [blame] | 54 | 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 Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 65 | Ptr<const InterestHeader>, Ptr<const Face>); |
Alexander Afanasyev | b3e4b85 | 2011-12-23 15:58:20 -0800 | [diff] [blame] | 66 | |
| 67 | virtual void |
| 68 | InInterests (std::string context, |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 69 | Ptr<const InterestHeader>, Ptr<const Face>); |
Alexander Afanasyev | b3e4b85 | 2011-12-23 15:58:20 -0800 | [diff] [blame] | 70 | |
| 71 | virtual void |
| 72 | DropInterests (std::string context, |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 73 | Ptr<const InterestHeader>, Ptr<const Face>); |
Alexander Afanasyev | b3e4b85 | 2011-12-23 15:58:20 -0800 | [diff] [blame] | 74 | |
| 75 | virtual void |
| 76 | OutNacks (std::string context, |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 77 | Ptr<const InterestHeader>, Ptr<const Face>); |
Alexander Afanasyev | b3e4b85 | 2011-12-23 15:58:20 -0800 | [diff] [blame] | 78 | |
| 79 | virtual void |
| 80 | InNacks (std::string context, |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 81 | Ptr<const InterestHeader>, Ptr<const Face>); |
Alexander Afanasyev | b3e4b85 | 2011-12-23 15:58:20 -0800 | [diff] [blame] | 82 | |
| 83 | virtual void |
| 84 | DropNacks (std::string context, |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 85 | Ptr<const InterestHeader>, Ptr<const Face>); |
Alexander Afanasyev | b3e4b85 | 2011-12-23 15:58:20 -0800 | [diff] [blame] | 86 | |
| 87 | virtual void |
| 88 | OutData (std::string context, |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 89 | Ptr<const ContentObjectHeader>, Ptr<const Packet>, bool fromCache, Ptr<const Face>); |
Alexander Afanasyev | b3e4b85 | 2011-12-23 15:58:20 -0800 | [diff] [blame] | 90 | |
| 91 | virtual void |
| 92 | InData (std::string context, |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 93 | Ptr<const ContentObjectHeader>, Ptr<const Packet>, Ptr<const Face>); |
Alexander Afanasyev | b3e4b85 | 2011-12-23 15:58:20 -0800 | [diff] [blame] | 94 | |
| 95 | virtual void |
| 96 | DropData (std::string context, |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 97 | Ptr<const ContentObjectHeader>, Ptr<const Packet>, Ptr<const Face>); |
Alexander Afanasyev | b3e4b85 | 2011-12-23 15:58:20 -0800 | [diff] [blame] | 98 | |
| 99 | private: |
| 100 | void |
| 101 | PeriodicPrinter (); |
| 102 | |
| 103 | void |
| 104 | Reset (); |
| 105 | |
| 106 | private: |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 107 | boost::shared_ptr<std::ostream> m_os; |
Alexander Afanasyev | b3e4b85 | 2011-12-23 15:58:20 -0800 | [diff] [blame] | 108 | Time m_period; |
| 109 | EventId m_printEvent; |
| 110 | |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 111 | mutable std::map<Ptr<const Face>, boost::tuple<Stats, Stats, Stats, Stats> > m_stats; |
Alexander Afanasyev | b3e4b85 | 2011-12-23 15:58:20 -0800 | [diff] [blame] | 112 | }; |
| 113 | |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 114 | } // namespace ndn |
Alexander Afanasyev | b3e4b85 | 2011-12-23 15:58:20 -0800 | [diff] [blame] | 115 | } // namespace ns3 |
| 116 | |
| 117 | #endif // CCNX_RATE_L3_TRACER_H |