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