blob: efb09b10f1fd6b94f60ee0471f412a5b2b8e0e63 [file] [log] [blame]
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2011-2015 Regents of the University of California.
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -08004 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08005 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -08007 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08008 * ndnSIM is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080011 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080012 * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080015 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080016 * You should have received a copy of the GNU General Public License along with
17 * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 **/
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080019
Alexander Afanasyev0c395372014-12-20 15:54:02 -080020#include "ndn-l3-rate-tracer.hpp"
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080021#include "ns3/node.h"
22#include "ns3/packet.h"
23#include "ns3/config.h"
24#include "ns3/callback.h"
25#include "ns3/simulator.h"
26#include "ns3/log.h"
27#include "ns3/node-list.h"
28
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -080029#include "daemon/table/pit-entry.hpp"
30
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080031#include <fstream>
32#include <boost/lexical_cast.hpp>
33
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080034NS_LOG_COMPONENT_DEFINE("ndn.L3RateTracer");
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080035
36namespace ns3 {
37namespace ndn {
38
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080039static std::list<std::tuple<shared_ptr<std::ostream>, std::list<Ptr<L3RateTracer>>>>
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080040 g_tracers;
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -070041
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -070042void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080043L3RateTracer::Destroy()
Alexander Afanasyevdb5f3b62013-08-09 17:42:12 -070044{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080045 g_tracers.clear();
Alexander Afanasyevdb5f3b62013-08-09 17:42:12 -070046}
47
48void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080049L3RateTracer::InstallAll(const std::string& file, Time averagingPeriod /* = Seconds (0.5)*/)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080050{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080051 std::list<Ptr<L3RateTracer>> tracers;
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080052 shared_ptr<std::ostream> outputStream;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080053 if (file != "-") {
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080054 shared_ptr<std::ofstream> os(new std::ofstream());
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080055 os->open(file.c_str(), std::ios_base::out | std::ios_base::trunc);
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080056
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080057 if (!os->is_open()) {
58 NS_LOG_ERROR("File " << file << " cannot be opened for writing. Tracing disabled");
59 return;
Alexander Afanasyev5352af32013-07-15 09:51:28 -070060 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080061
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080062 outputStream = os;
63 }
64 else {
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080065 outputStream = shared_ptr<std::ostream>(&std::cout, std::bind([]{}));
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080066 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080067
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080068 for (NodeList::Iterator node = NodeList::Begin(); node != NodeList::End(); node++) {
69 Ptr<L3RateTracer> trace = Install(*node, outputStream, averagingPeriod);
70 tracers.push_back(trace);
71 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080072
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080073 if (tracers.size() > 0) {
74 // *m_l3RateTrace << "# "; // not necessary for R's read.table
75 tracers.front()->PrintHeader(*outputStream);
76 *outputStream << "\n";
77 }
78
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080079 g_tracers.push_back(std::make_tuple(outputStream, tracers));
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080080}
81
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -070082void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080083L3RateTracer::Install(const NodeContainer& nodes, const std::string& file,
84 Time averagingPeriod /* = Seconds (0.5)*/)
Alexander Afanasyev5352af32013-07-15 09:51:28 -070085{
86 using namespace boost;
87 using namespace std;
88
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080089 std::list<Ptr<L3RateTracer>> tracers;
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080090 shared_ptr<std::ostream> outputStream;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080091 if (file != "-") {
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080092 shared_ptr<std::ofstream> os(new std::ofstream());
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080093 os->open(file.c_str(), std::ios_base::out | std::ios_base::trunc);
Alexander Afanasyev5352af32013-07-15 09:51:28 -070094
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080095 if (!os->is_open()) {
96 NS_LOG_ERROR("File " << file << " cannot be opened for writing. Tracing disabled");
97 return;
Alexander Afanasyev5352af32013-07-15 09:51:28 -070098 }
99
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800100 outputStream = os;
101 }
102 else {
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800103 outputStream = shared_ptr<std::ostream>(&std::cout, std::bind([]{}));
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800104 }
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700105
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800106 for (NodeContainer::Iterator node = nodes.Begin(); node != nodes.End(); node++) {
107 Ptr<L3RateTracer> trace = Install(*node, outputStream, averagingPeriod);
108 tracers.push_back(trace);
109 }
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700110
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800111 if (tracers.size() > 0) {
112 // *m_l3RateTrace << "# "; // not necessary for R's read.table
113 tracers.front()->PrintHeader(*outputStream);
114 *outputStream << "\n";
115 }
116
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800117 g_tracers.push_back(std::make_tuple(outputStream, tracers));
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700118}
119
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -0700120void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800121L3RateTracer::Install(Ptr<Node> node, const std::string& file,
122 Time averagingPeriod /* = Seconds (0.5)*/)
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700123{
124 using namespace boost;
125 using namespace std;
126
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800127 std::list<Ptr<L3RateTracer>> tracers;
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800128 shared_ptr<std::ostream> outputStream;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800129 if (file != "-") {
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800130 shared_ptr<std::ofstream> os(new std::ofstream());
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800131 os->open(file.c_str(), std::ios_base::out | std::ios_base::trunc);
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700132
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800133 if (!os->is_open()) {
134 NS_LOG_ERROR("File " << file << " cannot be opened for writing. Tracing disabled");
135 return;
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700136 }
137
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800138 outputStream = os;
139 }
140 else {
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800141 outputStream = shared_ptr<std::ostream>(&std::cout, std::bind([]{}));
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800142 }
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700143
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800144 Ptr<L3RateTracer> trace = Install(node, outputStream, averagingPeriod);
145 tracers.push_back(trace);
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700146
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800147 if (tracers.size() > 0) {
148 // *m_l3RateTrace << "# "; // not necessary for R's read.table
149 tracers.front()->PrintHeader(*outputStream);
150 *outputStream << "\n";
151 }
152
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800153 g_tracers.push_back(std::make_tuple(outputStream, tracers));
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700154}
155
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700156Ptr<L3RateTracer>
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800157L3RateTracer::Install(Ptr<Node> node, shared_ptr<std::ostream> outputStream,
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800158 Time averagingPeriod /* = Seconds (0.5)*/)
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700159{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800160 NS_LOG_DEBUG("Node: " << node->GetId());
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700161
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800162 Ptr<L3RateTracer> trace = Create<L3RateTracer>(outputStream, node);
163 trace->SetAveragingPeriod(averagingPeriod);
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700164
165 return trace;
166}
167
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800168L3RateTracer::L3RateTracer(shared_ptr<std::ostream> os, Ptr<Node> node)
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800169 : L3Tracer(node)
170 , m_os(os)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800171{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800172 SetAveragingPeriod(Seconds(1.0));
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800173}
174
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800175L3RateTracer::L3RateTracer(shared_ptr<std::ostream> os, const std::string& node)
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800176 : L3Tracer(node)
177 , m_os(os)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800178{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800179 SetAveragingPeriod(Seconds(1.0));
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800180}
181
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800182L3RateTracer::~L3RateTracer()
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800183{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800184 m_printEvent.Cancel();
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800185}
186
187void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800188L3RateTracer::SetAveragingPeriod(const Time& period)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800189{
190 m_period = period;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800191 m_printEvent.Cancel();
192 m_printEvent = Simulator::Schedule(m_period, &L3RateTracer::PeriodicPrinter, this);
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800193}
194
195void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800196L3RateTracer::PeriodicPrinter()
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800197{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800198 Print(*m_os);
199 Reset();
Alexander Afanasyev37b84c52013-04-26 13:38:52 -0700200
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800201 m_printEvent = Simulator::Schedule(m_period, &L3RateTracer::PeriodicPrinter, this);
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800202}
203
204void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800205L3RateTracer::PrintHeader(std::ostream& os) const
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800206{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800207 os << "Time"
208 << "\t"
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800209
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800210 << "Node"
211 << "\t"
212 << "FaceId"
213 << "\t"
214 << "FaceDescr"
215 << "\t"
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800216
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800217 << "Type"
218 << "\t"
219 << "Packets"
220 << "\t"
221 << "Kilobytes"
222 << "\t"
223 << "PacketRaw"
224 << "\t"
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800225 << "KilobytesRaw";
226}
227
228void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800229L3RateTracer::Reset()
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800230{
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800231 for (auto& stats : m_stats) {
232 std::get<0>(stats.second).Reset();
233 std::get<1>(stats.second).Reset();
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800234 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800235}
236
237const double alpha = 0.8;
238
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800239#define STATS(INDEX) std::get<INDEX>(stats.second)
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800240#define RATE(INDEX, fieldName) STATS(INDEX).fieldName / m_period.ToDouble(Time::S)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800241
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800242#define PRINTER(printName, fieldName) \
243 STATS(2).fieldName = \
244 /*new value*/ alpha * RATE(0, fieldName) + /*old value*/ (1 - alpha) * STATS(2).fieldName; \
245 STATS(3).fieldName = /*new value*/ alpha * RATE(1, fieldName) / 1024.0 \
246 + /*old value*/ (1 - alpha) * STATS(3).fieldName; \
247 \
248 os << time.ToDouble(Time::S) << "\t" << m_node << "\t"; \
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800249 if (stats.first != nullptr) { \
250 os << stats.first->getId() << "\t" << stats.first->getLocalUri() << "\t"; \
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800251 } \
252 else { \
253 os << "-1\tall\t"; \
254 } \
255 os << printName << "\t" << STATS(2).fieldName << "\t" << STATS(3).fieldName << "\t" \
256 << STATS(0).fieldName << "\t" << STATS(1).fieldName / 1024.0 << "\n";
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800257
258void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800259L3RateTracer::Print(std::ostream& os) const
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800260{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800261 Time time = Simulator::Now();
Alexander Afanasyev37b84c52013-04-26 13:38:52 -0700262
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800263 for (auto& stats : m_stats) {
264 if (stats.first == nullptr)
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800265 continue;
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800266
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800267 PRINTER("InInterests", m_inInterests);
268 PRINTER("OutInterests", m_outInterests);
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800269
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800270 PRINTER("InData", m_inData);
271 PRINTER("OutData", m_outData);
Alexander Afanasyevbf939292013-07-15 10:10:01 -0700272
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800273 PRINTER("InSatisfiedInterests", m_satisfiedInterests);
274 PRINTER("InTimedOutInterests", m_timedOutInterests);
Alexander Afanasyevbf939292013-07-15 10:10:01 -0700275
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800276 PRINTER("OutSatisfiedInterests", m_outSatisfiedInterests);
277 PRINTER("OutTimedOutInterests", m_outTimedOutInterests);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800278 }
Alexander Afanasyev37b84c52013-04-26 13:38:52 -0700279
280 {
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800281 auto i = m_stats.find(nullptr);
282 if (i != m_stats.end()) {
283 auto& stats = *i;
284 PRINTER("SatisfiedInterests", m_satisfiedInterests);
285 PRINTER("TimedOutInterests", m_timedOutInterests);
286 }
Alexander Afanasyev37b84c52013-04-26 13:38:52 -0700287 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800288}
289
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800290void
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800291L3RateTracer::OutInterests(const Interest& interest, const Face& face)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800292{
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800293 std::get<0>(m_stats[face.shared_from_this()]).m_outInterests++;
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800294 if (interest.hasWire()) {
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800295 std::get<1>(m_stats[face.shared_from_this()]).m_outInterests +=
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800296 interest.wireEncode().size();
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800297 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800298}
299
300void
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800301L3RateTracer::InInterests(const Interest& interest, const Face& face)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800302{
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800303 std::get<0>(m_stats[face.shared_from_this()]).m_inInterests++;
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800304 if (interest.hasWire()) {
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800305 std::get<1>(m_stats[face.shared_from_this()]).m_inInterests +=
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800306 interest.wireEncode().size();
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800307 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800308}
309
310void
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800311L3RateTracer::OutData(const Data& data, const Face& face)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800312{
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800313 std::get<0>(m_stats[face.shared_from_this()]).m_outData++;
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800314 if (data.hasWire()) {
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800315 std::get<1>(m_stats[face.shared_from_this()]).m_outData +=
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800316 data.wireEncode().size();
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800317 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800318}
319
320void
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800321L3RateTracer::InData(const Data& data, const Face& face)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800322{
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800323 std::get<0>(m_stats[face.shared_from_this()]).m_inData++;
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800324 if (data.hasWire()) {
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800325 std::get<1>(m_stats[face.shared_from_this()]).m_inData +=
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800326 data.wireEncode().size();
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800327 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800328}
329
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800330void
331L3RateTracer::SatisfiedInterests(const nfd::pit::Entry& entry, const Face&, const Data&)
332{
333 std::get<0>(m_stats[nullptr]).m_satisfiedInterests++;
334 // no "size" stats
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800335
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800336 for (const auto& in : entry.getInRecords()) {
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -0800337 std::get<0>(m_stats[(in.getFace()).shared_from_this()]).m_satisfiedInterests ++;
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800338 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800339
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800340 for (const auto& out : entry.getOutRecords()) {
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -0800341 std::get<0>(m_stats[(out.getFace()).shared_from_this()]).m_outSatisfiedInterests ++;
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800342 }
343}
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800344
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800345void
346L3RateTracer::TimedOutInterests(const nfd::pit::Entry& entry)
347{
348 std::get<0>(m_stats[nullptr]).m_timedOutInterests++;
349 // no "size" stats
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800350
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800351 for (const auto& in : entry.getInRecords()) {
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -0800352 std::get<0>(m_stats[(in.getFace()).shared_from_this()]).m_timedOutInterests++;
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800353 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800354
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800355 for (const auto& out : entry.getOutRecords()) {
Spyridon Mastorakisb0b22412016-12-07 14:33:46 -0800356 std::get<0>(m_stats[(out.getFace()).shared_from_this()]).m_outTimedOutInterests++;
Alexander Afanasyevdc6fae82015-01-08 21:44:15 -0800357 }
358}
Alexander Afanasyev37b84c52013-04-26 13:38:52 -0700359
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800360} // namespace ndn
361} // namespace ns3