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