Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -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 | |
Alexander Afanasyev | 0c39537 | 2014-12-20 15:54:02 -0800 | [diff] [blame] | 21 | #include "ndn-l3-aggregate-tracer.hpp" |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 22 | |
| 23 | #include "ns3/node.h" |
| 24 | #include "ns3/packet.h" |
| 25 | #include "ns3/config.h" |
| 26 | #include "ns3/callback.h" |
Alexander Afanasyev | 0c39537 | 2014-12-20 15:54:02 -0800 | [diff] [blame] | 27 | #include "ns3/ndn-app.hpp" |
| 28 | #include "ns3/ndn-face.hpp" |
Alexander Afanasyev | 0c39537 | 2014-12-20 15:54:02 -0800 | [diff] [blame] | 29 | #include "ns3/ndn-pit-entry.hpp" |
Alexander Afanasyev | 37b84c5 | 2013-04-26 13:38:52 -0700 | [diff] [blame] | 30 | |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 31 | #include "ns3/simulator.h" |
| 32 | #include "ns3/node-list.h" |
| 33 | #include "ns3/log.h" |
| 34 | |
| 35 | #include <fstream> |
| 36 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 37 | NS_LOG_COMPONENT_DEFINE("ndn.L3AggregateTracer"); |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 38 | |
| 39 | namespace ns3 { |
| 40 | namespace ndn { |
| 41 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 42 | static std::list<boost::tuple<boost::shared_ptr<std::ostream>, std::list<Ptr<L3AggregateTracer>>>> |
| 43 | g_tracers; |
Alexander Afanasyev | 3fe94dc | 2013-08-09 17:12:12 -0700 | [diff] [blame] | 44 | |
Alexander Afanasyev | 5352af3 | 2013-07-15 09:51:28 -0700 | [diff] [blame] | 45 | template<class T> |
| 46 | static inline void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 47 | NullDeleter(T* ptr) |
Alexander Afanasyev | 5352af3 | 2013-07-15 09:51:28 -0700 | [diff] [blame] | 48 | { |
| 49 | } |
| 50 | |
Alexander Afanasyev | 3fe94dc | 2013-08-09 17:12:12 -0700 | [diff] [blame] | 51 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 52 | L3AggregateTracer::Destroy() |
Alexander Afanasyev | db5f3b6 | 2013-08-09 17:42:12 -0700 | [diff] [blame] | 53 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 54 | g_tracers.clear(); |
Alexander Afanasyev | db5f3b6 | 2013-08-09 17:42:12 -0700 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 58 | L3AggregateTracer::InstallAll(const std::string& file, Time averagingPeriod /* = Seconds (0.5)*/) |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 59 | { |
| 60 | using namespace boost; |
| 61 | using namespace std; |
Alexander Afanasyev | 37b84c5 | 2013-04-26 13:38:52 -0700 | [diff] [blame] | 62 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 63 | std::list<Ptr<L3AggregateTracer>> tracers; |
Alexander Afanasyev | 5352af3 | 2013-07-15 09:51:28 -0700 | [diff] [blame] | 64 | boost::shared_ptr<std::ostream> outputStream; |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 65 | if (file != "-") { |
| 66 | boost::shared_ptr<std::ofstream> os(new std::ofstream()); |
| 67 | os->open(file.c_str(), std::ios_base::out | std::ios_base::trunc); |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 68 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 69 | if (!os->is_open()) { |
| 70 | NS_LOG_ERROR("File " << file << " cannot be opened for writing. Tracing disabled"); |
| 71 | return; |
Alexander Afanasyev | 5352af3 | 2013-07-15 09:51:28 -0700 | [diff] [blame] | 72 | } |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 73 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 74 | outputStream = os; |
| 75 | } |
| 76 | else { |
| 77 | outputStream = boost::shared_ptr<std::ostream>(&std::cout, NullDeleter<std::ostream>); |
| 78 | } |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 79 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 80 | for (NodeList::Iterator node = NodeList::Begin(); node != NodeList::End(); node++) { |
| 81 | Ptr<L3AggregateTracer> trace = Install(*node, outputStream, averagingPeriod); |
| 82 | tracers.push_back(trace); |
| 83 | } |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 84 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 85 | if (tracers.size() > 0) { |
| 86 | // *m_l3RateTrace << "# "; // not necessary for R's read.table |
| 87 | tracers.front()->PrintHeader(*outputStream); |
| 88 | *outputStream << "\n"; |
| 89 | } |
| 90 | |
| 91 | g_tracers.push_back(boost::make_tuple(outputStream, tracers)); |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 92 | } |
| 93 | |
Alexander Afanasyev | 3fe94dc | 2013-08-09 17:12:12 -0700 | [diff] [blame] | 94 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 95 | L3AggregateTracer::Install(const NodeContainer& nodes, const std::string& file, |
| 96 | Time averagingPeriod /* = Seconds (0.5)*/) |
Alexander Afanasyev | a68783a | 2013-06-27 13:39:04 -0700 | [diff] [blame] | 97 | { |
| 98 | using namespace boost; |
| 99 | using namespace std; |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 100 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 101 | std::list<Ptr<L3AggregateTracer>> tracers; |
Alexander Afanasyev | 5352af3 | 2013-07-15 09:51:28 -0700 | [diff] [blame] | 102 | boost::shared_ptr<std::ostream> outputStream; |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 103 | if (file != "-") { |
| 104 | boost::shared_ptr<std::ofstream> os(new std::ofstream()); |
| 105 | os->open(file.c_str(), std::ios_base::out | std::ios_base::trunc); |
Alexander Afanasyev | a68783a | 2013-06-27 13:39:04 -0700 | [diff] [blame] | 106 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 107 | if (!os->is_open()) { |
| 108 | NS_LOG_ERROR("File " << file << " cannot be opened for writing. Tracing disabled"); |
| 109 | return; |
Alexander Afanasyev | 5352af3 | 2013-07-15 09:51:28 -0700 | [diff] [blame] | 110 | } |
Alexander Afanasyev | a68783a | 2013-06-27 13:39:04 -0700 | [diff] [blame] | 111 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 112 | outputStream = os; |
| 113 | } |
| 114 | else { |
| 115 | outputStream = boost::shared_ptr<std::ostream>(&std::cout, NullDeleter<std::ostream>); |
| 116 | } |
Alexander Afanasyev | a68783a | 2013-06-27 13:39:04 -0700 | [diff] [blame] | 117 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 118 | for (NodeContainer::Iterator node = nodes.Begin(); node != nodes.End(); node++) { |
| 119 | Ptr<L3AggregateTracer> trace = Install(*node, outputStream, averagingPeriod); |
| 120 | tracers.push_back(trace); |
| 121 | } |
Alexander Afanasyev | a68783a | 2013-06-27 13:39:04 -0700 | [diff] [blame] | 122 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 123 | if (tracers.size() > 0) { |
| 124 | // *m_l3RateTrace << "# "; // not necessary for R's read.table |
| 125 | tracers.front()->PrintHeader(*outputStream); |
| 126 | *outputStream << "\n"; |
| 127 | } |
| 128 | |
| 129 | g_tracers.push_back(boost::make_tuple(outputStream, tracers)); |
Alexander Afanasyev | a68783a | 2013-06-27 13:39:04 -0700 | [diff] [blame] | 130 | } |
| 131 | |
Alexander Afanasyev | 3fe94dc | 2013-08-09 17:12:12 -0700 | [diff] [blame] | 132 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 133 | L3AggregateTracer::Install(Ptr<Node> node, const std::string& file, |
| 134 | Time averagingPeriod /* = Seconds (0.5)*/) |
Alexander Afanasyev | a68783a | 2013-06-27 13:39:04 -0700 | [diff] [blame] | 135 | { |
| 136 | using namespace boost; |
| 137 | using namespace std; |
| 138 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 139 | std::list<Ptr<L3AggregateTracer>> tracers; |
Alexander Afanasyev | 5352af3 | 2013-07-15 09:51:28 -0700 | [diff] [blame] | 140 | boost::shared_ptr<std::ostream> outputStream; |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 141 | if (file != "-") { |
| 142 | boost::shared_ptr<std::ofstream> os(new std::ofstream()); |
| 143 | os->open(file.c_str(), std::ios_base::out | std::ios_base::trunc); |
Alexander Afanasyev | a68783a | 2013-06-27 13:39:04 -0700 | [diff] [blame] | 144 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 145 | if (!os->is_open()) { |
| 146 | NS_LOG_ERROR("File " << file << " cannot be opened for writing. Tracing disabled"); |
| 147 | return; |
Alexander Afanasyev | 5352af3 | 2013-07-15 09:51:28 -0700 | [diff] [blame] | 148 | } |
Alexander Afanasyev | a68783a | 2013-06-27 13:39:04 -0700 | [diff] [blame] | 149 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 150 | outputStream = os; |
| 151 | } |
| 152 | else { |
| 153 | outputStream = boost::shared_ptr<std::ostream>(&std::cout, NullDeleter<std::ostream>); |
| 154 | } |
Alexander Afanasyev | a68783a | 2013-06-27 13:39:04 -0700 | [diff] [blame] | 155 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 156 | Ptr<L3AggregateTracer> trace = Install(node, outputStream, averagingPeriod); |
| 157 | tracers.push_back(trace); |
Alexander Afanasyev | a68783a | 2013-06-27 13:39:04 -0700 | [diff] [blame] | 158 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 159 | if (tracers.size() > 0) { |
| 160 | // *m_l3RateTrace << "# "; // not necessary for R's read.table |
| 161 | tracers.front()->PrintHeader(*outputStream); |
| 162 | *outputStream << "\n"; |
| 163 | } |
| 164 | |
| 165 | g_tracers.push_back(boost::make_tuple(outputStream, tracers)); |
Alexander Afanasyev | a68783a | 2013-06-27 13:39:04 -0700 | [diff] [blame] | 166 | } |
| 167 | |
Alexander Afanasyev | a68783a | 2013-06-27 13:39:04 -0700 | [diff] [blame] | 168 | Ptr<L3AggregateTracer> |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 169 | L3AggregateTracer::Install(Ptr<Node> node, boost::shared_ptr<std::ostream> outputStream, |
| 170 | Time averagingPeriod /* = Seconds (0.5)*/) |
Alexander Afanasyev | a68783a | 2013-06-27 13:39:04 -0700 | [diff] [blame] | 171 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 172 | NS_LOG_DEBUG("Node: " << node->GetId()); |
Alexander Afanasyev | a68783a | 2013-06-27 13:39:04 -0700 | [diff] [blame] | 173 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 174 | Ptr<L3AggregateTracer> trace = Create<L3AggregateTracer>(outputStream, node); |
| 175 | trace->SetAveragingPeriod(averagingPeriod); |
Alexander Afanasyev | a68783a | 2013-06-27 13:39:04 -0700 | [diff] [blame] | 176 | |
| 177 | return trace; |
| 178 | } |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 179 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 180 | L3AggregateTracer::L3AggregateTracer(boost::shared_ptr<std::ostream> os, Ptr<Node> node) |
| 181 | : L3Tracer(node) |
| 182 | , m_os(os) |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 183 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 184 | Reset(); |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 185 | } |
| 186 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 187 | L3AggregateTracer::L3AggregateTracer(boost::shared_ptr<std::ostream> os, const std::string& node) |
| 188 | : L3Tracer(node) |
| 189 | , m_os(os) |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 190 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 191 | Reset(); |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 192 | } |
| 193 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 194 | L3AggregateTracer::~L3AggregateTracer(){}; |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 195 | |
| 196 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 197 | L3AggregateTracer::SetAveragingPeriod(const Time& period) |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 198 | { |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 199 | m_period = period; |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 200 | m_printEvent.Cancel(); |
| 201 | m_printEvent = Simulator::Schedule(m_period, &L3AggregateTracer::PeriodicPrinter, this); |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 202 | } |
| 203 | |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 204 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 205 | L3AggregateTracer::PeriodicPrinter() |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 206 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 207 | Print(*m_os); |
| 208 | Reset(); |
Alexander Afanasyev | 37b84c5 | 2013-04-26 13:38:52 -0700 | [diff] [blame] | 209 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 210 | m_printEvent = Simulator::Schedule(m_period, &L3AggregateTracer::PeriodicPrinter, this); |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 211 | } |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 212 | |
| 213 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 214 | L3AggregateTracer::PrintHeader(std::ostream& os) const |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 215 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 216 | os << "Time" |
| 217 | << "\t" |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 218 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 219 | << "Node" |
| 220 | << "\t" |
| 221 | << "FaceId" |
| 222 | << "\t" |
| 223 | << "FaceDescr" |
| 224 | << "\t" |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 225 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 226 | << "Type" |
| 227 | << "\t" |
| 228 | << "Packets" |
| 229 | << "\t" |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 230 | << "Kilobytes"; |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 234 | L3AggregateTracer::Reset() |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 235 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 236 | for (std::map<Ptr<const Face>, boost::tuple<Stats, Stats>>::iterator stats = m_stats.begin(); |
| 237 | stats != m_stats.end(); stats++) { |
| 238 | stats->second.get<0>().Reset(); |
| 239 | stats->second.get<1>().Reset(); |
| 240 | } |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 241 | } |
| 242 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 243 | #define STATS(INDEX) stats->second.get<INDEX>() |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 244 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 245 | #define PRINTER(printName, fieldName) \ |
| 246 | os << time.ToDouble(Time::S) << "\t" << m_node << "\t"; \ |
| 247 | if (stats->first) { \ |
| 248 | os << stats->first->GetId() << "\t" << *stats->first << "\t"; \ |
| 249 | } \ |
| 250 | else { \ |
| 251 | os << "-1\tall\t"; \ |
| 252 | } \ |
| 253 | os << printName << "\t" << STATS(0).fieldName << "\t" << STATS(1).fieldName / 1024.0 << "\n"; |
Alexander Afanasyev | 5931480 | 2012-11-26 14:56:04 -0800 | [diff] [blame] | 254 | |
| 255 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 256 | L3AggregateTracer::Print(std::ostream& os) const |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 257 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 258 | Time time = Simulator::Now(); |
Alexander Afanasyev | 37b84c5 | 2013-04-26 13:38:52 -0700 | [diff] [blame] | 259 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 260 | for (std::map<Ptr<const Face>, boost::tuple<Stats, Stats>>::iterator stats = m_stats.begin(); |
| 261 | stats != m_stats.end(); stats++) { |
| 262 | if (!stats->first) |
| 263 | continue; |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 264 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 265 | PRINTER("InInterests", m_inInterests); |
| 266 | PRINTER("OutInterests", m_outInterests); |
| 267 | PRINTER("DropInterests", m_dropInterests); |
Alexander Afanasyev | 37b84c5 | 2013-04-26 13:38:52 -0700 | [diff] [blame] | 268 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 269 | PRINTER("InNacks", m_inNacks); |
| 270 | PRINTER("OutNacks", m_outNacks); |
| 271 | PRINTER("DropNacks", m_dropNacks); |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 272 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 273 | PRINTER("InData", m_inData); |
| 274 | PRINTER("OutData", m_outData); |
| 275 | PRINTER("DropData", m_dropData); |
| 276 | } |
Alexander Afanasyev | 37b84c5 | 2013-04-26 13:38:52 -0700 | [diff] [blame] | 277 | |
| 278 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 279 | std::map<Ptr<const Face>, boost::tuple<Stats, Stats>>::iterator stats = |
| 280 | m_stats.find(Ptr<const Face>(0)); |
| 281 | if (stats != m_stats.end()) { |
| 282 | PRINTER("SatisfiedInterests", m_satisfiedInterests); |
| 283 | PRINTER("TimedOutInterests", m_timedOutInterests); |
| 284 | } |
Alexander Afanasyev | 37b84c5 | 2013-04-26 13:38:52 -0700 | [diff] [blame] | 285 | } |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | void |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame^] | 289 | L3AggregateTracer::OutInterests(shared_ptr<const Interest> interest, Ptr<const Face> face) |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 290 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 291 | m_stats[face].get<0>().m_outInterests++; |
| 292 | if (interest->GetWire()) { |
| 293 | m_stats[face].get<1>().m_outInterests += interest->GetWire()->GetSize(); |
| 294 | } |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | void |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame^] | 298 | L3AggregateTracer::InInterests(shared_ptr<const Interest> interest, Ptr<const Face> face) |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 299 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 300 | m_stats[face].get<0>().m_inInterests++; |
| 301 | if (interest->GetWire()) { |
| 302 | m_stats[face].get<1>().m_inInterests += interest->GetWire()->GetSize(); |
| 303 | } |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | void |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame^] | 307 | L3AggregateTracer::DropInterests(shared_ptr<const Interest> interest, Ptr<const Face> face) |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 308 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 309 | m_stats[face].get<0>().m_dropInterests++; |
| 310 | if (interest->GetWire()) { |
| 311 | m_stats[face].get<1>().m_dropInterests += interest->GetWire()->GetSize(); |
| 312 | } |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | void |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame^] | 316 | L3AggregateTracer::OutNacks(shared_ptr<const Interest> nack, Ptr<const Face> face) |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 317 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 318 | m_stats[face].get<0>().m_outNacks++; |
| 319 | if (nack->GetWire()) { |
| 320 | m_stats[face].get<1>().m_outNacks += nack->GetWire()->GetSize(); |
| 321 | } |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | void |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame^] | 325 | L3AggregateTracer::InNacks(shared_ptr<const Interest> nack, Ptr<const Face> face) |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 326 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 327 | m_stats[face].get<0>().m_inNacks++; |
| 328 | if (nack->GetWire()) { |
| 329 | m_stats[face].get<1>().m_inNacks += nack->GetWire()->GetSize(); |
| 330 | } |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | void |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame^] | 334 | L3AggregateTracer::DropNacks(shared_ptr<const Interest> nack, Ptr<const Face> face) |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 335 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 336 | m_stats[face].get<0>().m_dropNacks++; |
| 337 | if (nack->GetWire()) { |
| 338 | m_stats[face].get<1>().m_dropNacks += nack->GetWire()->GetSize(); |
| 339 | } |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | void |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame^] | 343 | L3AggregateTracer::OutData(shared_ptr<const Data> data, bool fromCache, Ptr<const Face> face) |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 344 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 345 | m_stats[face].get<0>().m_outData++; |
| 346 | if (data->GetWire()) { |
| 347 | m_stats[face].get<1>().m_outData += data->GetWire()->GetSize(); |
| 348 | } |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | void |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame^] | 352 | L3AggregateTracer::InData(shared_ptr<const Data> data, Ptr<const Face> face) |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 353 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 354 | m_stats[face].get<0>().m_inData++; |
| 355 | if (data->GetWire()) { |
| 356 | m_stats[face].get<1>().m_inData += data->GetWire()->GetSize(); |
| 357 | } |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | void |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame^] | 361 | L3AggregateTracer::DropData(shared_ptr<const Data> data, Ptr<const Face> face) |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 362 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 363 | m_stats[face].get<0>().m_dropData++; |
| 364 | if (data->GetWire()) { |
| 365 | m_stats[face].get<1>().m_dropData += data->GetWire()->GetSize(); |
| 366 | } |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 367 | } |
| 368 | |
Alexander Afanasyev | 37b84c5 | 2013-04-26 13:38:52 -0700 | [diff] [blame] | 369 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 370 | L3AggregateTracer::SatisfiedInterests(Ptr<const pit::Entry>) |
Alexander Afanasyev | 37b84c5 | 2013-04-26 13:38:52 -0700 | [diff] [blame] | 371 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 372 | m_stats[0].get<0>().m_satisfiedInterests++; |
Alexander Afanasyev | 37b84c5 | 2013-04-26 13:38:52 -0700 | [diff] [blame] | 373 | // no "size" stats |
| 374 | } |
| 375 | |
| 376 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 377 | L3AggregateTracer::TimedOutInterests(Ptr<const pit::Entry>) |
Alexander Afanasyev | 37b84c5 | 2013-04-26 13:38:52 -0700 | [diff] [blame] | 378 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 379 | m_stats[0].get<0>().m_timedOutInterests++; |
Alexander Afanasyev | 37b84c5 | 2013-04-26 13:38:52 -0700 | [diff] [blame] | 380 | // no "size" stats |
| 381 | } |
| 382 | |
Alexander Afanasyev | c9d5c1a | 2012-11-21 18:00:26 -0800 | [diff] [blame] | 383 | } // namespace ndn |
| 384 | } // namespace ns3 |