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