blob: 6bba93bf193a1515b1df50b8245afcb2b31d5b56 [file] [log] [blame]
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -08001/* -*- 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 Afanasyev0c395372014-12-20 15:54:02 -080021#include "ndn-l3-rate-tracer.hpp"
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080022#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
Alexander Afanasyev0c395372014-12-20 15:54:02 -080030#include "ns3/ndn-app.hpp"
31#include "ns3/ndn-face.hpp"
Alexander Afanasyev0c395372014-12-20 15:54:02 -080032#include "ns3/ndn-pit-entry.hpp"
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080033
34#include <fstream>
35#include <boost/lexical_cast.hpp>
36
37using namespace boost;
38using namespace std;
39
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080040NS_LOG_COMPONENT_DEFINE("ndn.L3RateTracer");
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080041
42namespace ns3 {
43namespace ndn {
44
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080045static std::list<boost::tuple<boost::shared_ptr<std::ostream>, std::list<Ptr<L3RateTracer>>>>
46 g_tracers;
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -070047
Alexander Afanasyev5352af32013-07-15 09:51:28 -070048template<class T>
49static inline void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080050NullDeleter(T* ptr)
Alexander Afanasyev5352af32013-07-15 09:51:28 -070051{
52}
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080053
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -070054void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080055L3RateTracer::Destroy()
Alexander Afanasyevdb5f3b62013-08-09 17:42:12 -070056{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080057 g_tracers.clear();
Alexander Afanasyevdb5f3b62013-08-09 17:42:12 -070058}
59
60void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080061L3RateTracer::InstallAll(const std::string& file, Time averagingPeriod /* = Seconds (0.5)*/)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080062{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080063 std::list<Ptr<L3RateTracer>> tracers;
Alexander Afanasyev5352af32013-07-15 09:51:28 -070064 boost::shared_ptr<std::ostream> outputStream;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080065 if (file != "-") {
66 boost::shared_ptr<std::ofstream> os(new std::ofstream());
67 os->open(file.c_str(), std::ios_base::out | std::ios_base::trunc);
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080068
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080069 if (!os->is_open()) {
70 NS_LOG_ERROR("File " << file << " cannot be opened for writing. Tracing disabled");
71 return;
Alexander Afanasyev5352af32013-07-15 09:51:28 -070072 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080073
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080074 outputStream = os;
75 }
76 else {
77 outputStream = boost::shared_ptr<std::ostream>(&std::cout, NullDeleter<std::ostream>);
78 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080079
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080080 for (NodeList::Iterator node = NodeList::Begin(); node != NodeList::End(); node++) {
81 Ptr<L3RateTracer> trace = Install(*node, outputStream, averagingPeriod);
82 tracers.push_back(trace);
83 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080084
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080085 if (tracers.size() > 0) {
86 // *m_l3RateTrace << "# "; // not necessary for R's read.table
87 tracers.front()->PrintHeader(*outputStream);
88 *outputStream << "\n";
89 }
90
91 g_tracers.push_back(boost::make_tuple(outputStream, tracers));
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080092}
93
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -070094void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080095L3RateTracer::Install(const NodeContainer& nodes, const std::string& file,
96 Time averagingPeriod /* = Seconds (0.5)*/)
Alexander Afanasyev5352af32013-07-15 09:51:28 -070097{
98 using namespace boost;
99 using namespace std;
100
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800101 std::list<Ptr<L3RateTracer>> tracers;
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700102 boost::shared_ptr<std::ostream> outputStream;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800103 if (file != "-") {
104 boost::shared_ptr<std::ofstream> os(new std::ofstream());
105 os->open(file.c_str(), std::ios_base::out | std::ios_base::trunc);
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700106
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800107 if (!os->is_open()) {
108 NS_LOG_ERROR("File " << file << " cannot be opened for writing. Tracing disabled");
109 return;
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700110 }
111
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800112 outputStream = os;
113 }
114 else {
115 outputStream = boost::shared_ptr<std::ostream>(&std::cout, NullDeleter<std::ostream>);
116 }
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700117
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800118 for (NodeContainer::Iterator node = nodes.Begin(); node != nodes.End(); node++) {
119 Ptr<L3RateTracer> trace = Install(*node, outputStream, averagingPeriod);
120 tracers.push_back(trace);
121 }
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700122
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800123 if (tracers.size() > 0) {
124 // *m_l3RateTrace << "# "; // not necessary for R's read.table
125 tracers.front()->PrintHeader(*outputStream);
126 *outputStream << "\n";
127 }
128
129 g_tracers.push_back(boost::make_tuple(outputStream, tracers));
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700130}
131
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -0700132void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800133L3RateTracer::Install(Ptr<Node> node, const std::string& file,
134 Time averagingPeriod /* = Seconds (0.5)*/)
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700135{
136 using namespace boost;
137 using namespace std;
138
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800139 std::list<Ptr<L3RateTracer>> tracers;
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700140 boost::shared_ptr<std::ostream> outputStream;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800141 if (file != "-") {
142 boost::shared_ptr<std::ofstream> os(new std::ofstream());
143 os->open(file.c_str(), std::ios_base::out | std::ios_base::trunc);
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700144
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800145 if (!os->is_open()) {
146 NS_LOG_ERROR("File " << file << " cannot be opened for writing. Tracing disabled");
147 return;
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700148 }
149
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800150 outputStream = os;
151 }
152 else {
153 outputStream = boost::shared_ptr<std::ostream>(&std::cout, NullDeleter<std::ostream>);
154 }
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700155
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800156 Ptr<L3RateTracer> trace = Install(node, outputStream, averagingPeriod);
157 tracers.push_back(trace);
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700158
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800159 if (tracers.size() > 0) {
160 // *m_l3RateTrace << "# "; // not necessary for R's read.table
161 tracers.front()->PrintHeader(*outputStream);
162 *outputStream << "\n";
163 }
164
165 g_tracers.push_back(boost::make_tuple(outputStream, tracers));
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700166}
167
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700168Ptr<L3RateTracer>
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800169L3RateTracer::Install(Ptr<Node> node, boost::shared_ptr<std::ostream> outputStream,
170 Time averagingPeriod /* = Seconds (0.5)*/)
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700171{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800172 NS_LOG_DEBUG("Node: " << node->GetId());
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700173
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800174 Ptr<L3RateTracer> trace = Create<L3RateTracer>(outputStream, node);
175 trace->SetAveragingPeriod(averagingPeriod);
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700176
177 return trace;
178}
179
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800180L3RateTracer::L3RateTracer(boost::shared_ptr<std::ostream> os, Ptr<Node> node)
181 : L3Tracer(node)
182 , m_os(os)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800183{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800184 SetAveragingPeriod(Seconds(1.0));
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800185}
186
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800187L3RateTracer::L3RateTracer(boost::shared_ptr<std::ostream> os, const std::string& node)
188 : L3Tracer(node)
189 , m_os(os)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800190{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800191 SetAveragingPeriod(Seconds(1.0));
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800192}
193
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800194L3RateTracer::~L3RateTracer()
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800195{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800196 m_printEvent.Cancel();
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800197}
198
199void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800200L3RateTracer::SetAveragingPeriod(const Time& period)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800201{
202 m_period = period;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800203 m_printEvent.Cancel();
204 m_printEvent = Simulator::Schedule(m_period, &L3RateTracer::PeriodicPrinter, this);
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800205}
206
207void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800208L3RateTracer::PeriodicPrinter()
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800209{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800210 Print(*m_os);
211 Reset();
Alexander Afanasyev37b84c52013-04-26 13:38:52 -0700212
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800213 m_printEvent = Simulator::Schedule(m_period, &L3RateTracer::PeriodicPrinter, this);
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800214}
215
216void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800217L3RateTracer::PrintHeader(std::ostream& os) const
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800218{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800219 os << "Time"
220 << "\t"
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800221
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800222 << "Node"
223 << "\t"
224 << "FaceId"
225 << "\t"
226 << "FaceDescr"
227 << "\t"
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800228
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800229 << "Type"
230 << "\t"
231 << "Packets"
232 << "\t"
233 << "Kilobytes"
234 << "\t"
235 << "PacketRaw"
236 << "\t"
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800237 << "KilobytesRaw";
238}
239
240void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800241L3RateTracer::Reset()
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800242{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800243 for (std::map<Ptr<const Face>, boost::tuple<Stats, Stats, Stats, Stats>>::iterator stats =
244 m_stats.begin();
245 stats != m_stats.end(); stats++) {
246 stats->second.get<0>().Reset();
247 stats->second.get<1>().Reset();
248 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800249}
250
251const double alpha = 0.8;
252
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800253#define STATS(INDEX) stats->second.get<INDEX>()
254#define RATE(INDEX, fieldName) STATS(INDEX).fieldName / m_period.ToDouble(Time::S)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800255
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800256#define PRINTER(printName, fieldName) \
257 STATS(2).fieldName = \
258 /*new value*/ alpha * RATE(0, fieldName) + /*old value*/ (1 - alpha) * STATS(2).fieldName; \
259 STATS(3).fieldName = /*new value*/ alpha * RATE(1, fieldName) / 1024.0 \
260 + /*old value*/ (1 - alpha) * STATS(3).fieldName; \
261 \
262 os << time.ToDouble(Time::S) << "\t" << m_node << "\t"; \
263 if (stats->first) { \
264 os << stats->first->GetId() << "\t" << *stats->first << "\t"; \
265 } \
266 else { \
267 os << "-1\tall\t"; \
268 } \
269 os << printName << "\t" << STATS(2).fieldName << "\t" << STATS(3).fieldName << "\t" \
270 << STATS(0).fieldName << "\t" << STATS(1).fieldName / 1024.0 << "\n";
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800271
272void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800273L3RateTracer::Print(std::ostream& os) const
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800274{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800275 Time time = Simulator::Now();
Alexander Afanasyev37b84c52013-04-26 13:38:52 -0700276
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800277 for (std::map<Ptr<const Face>, boost::tuple<Stats, Stats, Stats, Stats>>::iterator stats =
278 m_stats.begin();
279 stats != m_stats.end(); stats++) {
280 if (!stats->first)
281 continue;
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800282
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800283 PRINTER("InInterests", m_inInterests);
284 PRINTER("OutInterests", m_outInterests);
285 PRINTER("DropInterests", m_dropInterests);
Alexander Afanasyev37b84c52013-04-26 13:38:52 -0700286
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800287 PRINTER("InNacks", m_inNacks);
288 PRINTER("OutNacks", m_outNacks);
289 PRINTER("DropNacks", m_dropNacks);
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800290
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800291 PRINTER("InData", m_inData);
292 PRINTER("OutData", m_outData);
293 PRINTER("DropData", m_dropData);
Alexander Afanasyevbf939292013-07-15 10:10:01 -0700294
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800295 PRINTER("InSatisfiedInterests", m_satisfiedInterests);
296 PRINTER("InTimedOutInterests", m_timedOutInterests);
Alexander Afanasyevbf939292013-07-15 10:10:01 -0700297
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800298 PRINTER("OutSatisfiedInterests", m_outSatisfiedInterests);
299 PRINTER("OutTimedOutInterests", m_outTimedOutInterests);
300 }
Alexander Afanasyev37b84c52013-04-26 13:38:52 -0700301
302 {
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800303 std::map<Ptr<const Face>, boost::tuple<Stats, Stats, Stats, Stats>>::iterator stats =
304 m_stats.find(Ptr<const Face>(0));
305 if (stats != m_stats.end()) {
306 PRINTER("SatisfiedInterests", m_satisfiedInterests);
307 PRINTER("TimedOutInterests", m_timedOutInterests);
308 }
Alexander Afanasyev37b84c52013-04-26 13:38:52 -0700309 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800310}
311
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800312void
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -0700313L3RateTracer::OutInterests(shared_ptr<const Interest> interest, Ptr<const Face> face)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800314{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800315 m_stats[face].get<0>().m_outInterests++;
316 if (interest->GetWire()) {
317 m_stats[face].get<1>().m_outInterests += interest->GetWire()->GetSize();
318 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800319}
320
321void
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -0700322L3RateTracer::InInterests(shared_ptr<const Interest> interest, Ptr<const Face> face)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800323{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800324 m_stats[face].get<0>().m_inInterests++;
325 if (interest->GetWire()) {
326 m_stats[face].get<1>().m_inInterests += interest->GetWire()->GetSize();
327 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800328}
329
330void
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -0700331L3RateTracer::DropInterests(shared_ptr<const Interest> interest, Ptr<const Face> face)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800332{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800333 m_stats[face].get<0>().m_dropInterests++;
334 if (interest->GetWire()) {
335 m_stats[face].get<1>().m_dropInterests += interest->GetWire()->GetSize();
336 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800337}
338
339void
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -0700340L3RateTracer::OutNacks(shared_ptr<const Interest> interest, Ptr<const Face> face)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800341{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800342 m_stats[face].get<0>().m_outNacks++;
343 if (interest->GetWire()) {
344 m_stats[face].get<1>().m_outNacks += interest->GetWire()->GetSize();
345 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800346}
347
348void
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -0700349L3RateTracer::InNacks(shared_ptr<const Interest> interest, Ptr<const Face> face)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800350{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800351 m_stats[face].get<0>().m_inNacks++;
352 if (interest->GetWire()) {
353 m_stats[face].get<1>().m_inNacks += interest->GetWire()->GetSize();
354 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800355}
356
357void
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -0700358L3RateTracer::DropNacks(shared_ptr<const Interest> interest, Ptr<const Face> face)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800359{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800360 m_stats[face].get<0>().m_dropNacks++;
361 if (interest->GetWire()) {
362 m_stats[face].get<1>().m_dropNacks += interest->GetWire()->GetSize();
363 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800364}
365
366void
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -0700367L3RateTracer::OutData(shared_ptr<const Data> data, bool fromCache, Ptr<const Face> face)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800368{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800369 m_stats[face].get<0>().m_outData++;
370 if (data->GetWire()) {
371 m_stats[face].get<1>().m_outData += data->GetWire()->GetSize();
372 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800373}
374
375void
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -0700376L3RateTracer::InData(shared_ptr<const Data> data, Ptr<const Face> face)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800377{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800378 m_stats[face].get<0>().m_inData++;
379 if (data->GetWire()) {
380 m_stats[face].get<1>().m_inData += data->GetWire()->GetSize();
381 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800382}
383
384void
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -0700385L3RateTracer::DropData(shared_ptr<const Data> data, Ptr<const Face> face)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800386{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800387 m_stats[face].get<0>().m_dropData++;
388 if (data->GetWire()) {
389 m_stats[face].get<1>().m_dropData += data->GetWire()->GetSize();
390 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800391}
392
Alexander Afanasyev37b84c52013-04-26 13:38:52 -0700393void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800394L3RateTracer::SatisfiedInterests(Ptr<const pit::Entry> entry)
Alexander Afanasyev37b84c52013-04-26 13:38:52 -0700395{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800396 m_stats[0].get<0>().m_satisfiedInterests++;
Alexander Afanasyev37b84c52013-04-26 13:38:52 -0700397 // no "size" stats
Alexander Afanasyevbf939292013-07-15 10:10:01 -0700398
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800399 for (pit::Entry::in_container::const_iterator i = entry->GetIncoming().begin();
400 i != entry->GetIncoming().end(); i++) {
401 m_stats[i->m_face].get<0>().m_satisfiedInterests++;
402 }
Alexander Afanasyevbf939292013-07-15 10:10:01 -0700403
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800404 for (pit::Entry::out_container::const_iterator i = entry->GetOutgoing().begin();
405 i != entry->GetOutgoing().end(); i++) {
406 m_stats[i->m_face].get<0>().m_outSatisfiedInterests++;
407 }
Alexander Afanasyev37b84c52013-04-26 13:38:52 -0700408}
409
410void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800411L3RateTracer::TimedOutInterests(Ptr<const pit::Entry> entry)
Alexander Afanasyev37b84c52013-04-26 13:38:52 -0700412{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800413 m_stats[0].get<0>().m_timedOutInterests++;
Alexander Afanasyev37b84c52013-04-26 13:38:52 -0700414 // no "size" stats
Alexander Afanasyevbf939292013-07-15 10:10:01 -0700415
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800416 for (pit::Entry::in_container::const_iterator i = entry->GetIncoming().begin();
417 i != entry->GetIncoming().end(); i++) {
418 m_stats[i->m_face].get<0>().m_timedOutInterests++;
419 }
Alexander Afanasyev37b84c52013-04-26 13:38:52 -0700420
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800421 for (pit::Entry::out_container::const_iterator i = entry->GetOutgoing().begin();
422 i != entry->GetOutgoing().end(); i++) {
423 m_stats[i->m_face].get<0>().m_outTimedOutInterests++;
424 }
425}
Alexander Afanasyev37b84c52013-04-26 13:38:52 -0700426
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800427} // namespace ndn
428} // namespace ns3