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