blob: 71fd4f996c9fd511f75e392715079de54f27c8ba [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 Afanasyevc9d5c1a2012-11-21 18:00:26 -080029#include <fstream>
30#include <boost/lexical_cast.hpp>
31
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080032NS_LOG_COMPONENT_DEFINE("ndn.L3RateTracer");
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080033
34namespace ns3 {
35namespace ndn {
36
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080037static std::list<std::tuple<shared_ptr<std::ostream>, std::list<Ptr<L3RateTracer>>>>
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080038 g_tracers;
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -070039
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -070040void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080041L3RateTracer::Destroy()
Alexander Afanasyevdb5f3b62013-08-09 17:42:12 -070042{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080043 g_tracers.clear();
Alexander Afanasyevdb5f3b62013-08-09 17:42:12 -070044}
45
46void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080047L3RateTracer::InstallAll(const std::string& file, Time averagingPeriod /* = Seconds (0.5)*/)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080048{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080049 std::list<Ptr<L3RateTracer>> tracers;
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080050 shared_ptr<std::ostream> outputStream;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080051 if (file != "-") {
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080052 shared_ptr<std::ofstream> os(new std::ofstream());
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080053 os->open(file.c_str(), std::ios_base::out | std::ios_base::trunc);
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080054
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080055 if (!os->is_open()) {
56 NS_LOG_ERROR("File " << file << " cannot be opened for writing. Tracing disabled");
57 return;
Alexander Afanasyev5352af32013-07-15 09:51:28 -070058 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080059
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080060 outputStream = os;
61 }
62 else {
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080063 outputStream = shared_ptr<std::ostream>(&std::cout, std::bind([]{}));
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080064 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080065
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080066 for (NodeList::Iterator node = NodeList::Begin(); node != NodeList::End(); node++) {
67 Ptr<L3RateTracer> trace = Install(*node, outputStream, averagingPeriod);
68 tracers.push_back(trace);
69 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080070
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080071 if (tracers.size() > 0) {
72 // *m_l3RateTrace << "# "; // not necessary for R's read.table
73 tracers.front()->PrintHeader(*outputStream);
74 *outputStream << "\n";
75 }
76
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080077 g_tracers.push_back(std::make_tuple(outputStream, tracers));
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -080078}
79
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -070080void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080081L3RateTracer::Install(const NodeContainer& nodes, const std::string& file,
82 Time averagingPeriod /* = Seconds (0.5)*/)
Alexander Afanasyev5352af32013-07-15 09:51:28 -070083{
84 using namespace boost;
85 using namespace std;
86
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080087 std::list<Ptr<L3RateTracer>> tracers;
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080088 shared_ptr<std::ostream> outputStream;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080089 if (file != "-") {
Spyridon Mastorakisda904f22014-11-05 16:23:33 -080090 shared_ptr<std::ofstream> os(new std::ofstream());
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080091 os->open(file.c_str(), std::ios_base::out | std::ios_base::trunc);
Alexander Afanasyev5352af32013-07-15 09:51:28 -070092
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080093 if (!os->is_open()) {
94 NS_LOG_ERROR("File " << file << " cannot be opened for writing. Tracing disabled");
95 return;
Alexander Afanasyev5352af32013-07-15 09:51:28 -070096 }
97
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080098 outputStream = os;
99 }
100 else {
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800101 outputStream = shared_ptr<std::ostream>(&std::cout, std::bind([]{}));
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800102 }
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700103
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800104 for (NodeContainer::Iterator node = nodes.Begin(); node != nodes.End(); node++) {
105 Ptr<L3RateTracer> trace = Install(*node, outputStream, averagingPeriod);
106 tracers.push_back(trace);
107 }
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700108
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800109 if (tracers.size() > 0) {
110 // *m_l3RateTrace << "# "; // not necessary for R's read.table
111 tracers.front()->PrintHeader(*outputStream);
112 *outputStream << "\n";
113 }
114
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800115 g_tracers.push_back(std::make_tuple(outputStream, tracers));
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700116}
117
Alexander Afanasyev3fe94dc2013-08-09 17:12:12 -0700118void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800119L3RateTracer::Install(Ptr<Node> node, const std::string& file,
120 Time averagingPeriod /* = Seconds (0.5)*/)
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700121{
122 using namespace boost;
123 using namespace std;
124
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800125 std::list<Ptr<L3RateTracer>> tracers;
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800126 shared_ptr<std::ostream> outputStream;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800127 if (file != "-") {
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800128 shared_ptr<std::ofstream> os(new std::ofstream());
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800129 os->open(file.c_str(), std::ios_base::out | std::ios_base::trunc);
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700130
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800131 if (!os->is_open()) {
132 NS_LOG_ERROR("File " << file << " cannot be opened for writing. Tracing disabled");
133 return;
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700134 }
135
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800136 outputStream = os;
137 }
138 else {
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800139 outputStream = shared_ptr<std::ostream>(&std::cout, std::bind([]{}));
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800140 }
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700141
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800142 Ptr<L3RateTracer> trace = Install(node, outputStream, averagingPeriod);
143 tracers.push_back(trace);
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700144
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800145 if (tracers.size() > 0) {
146 // *m_l3RateTrace << "# "; // not necessary for R's read.table
147 tracers.front()->PrintHeader(*outputStream);
148 *outputStream << "\n";
149 }
150
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800151 g_tracers.push_back(std::make_tuple(outputStream, tracers));
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700152}
153
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700154Ptr<L3RateTracer>
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800155L3RateTracer::Install(Ptr<Node> node, shared_ptr<std::ostream> outputStream,
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800156 Time averagingPeriod /* = Seconds (0.5)*/)
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700157{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800158 NS_LOG_DEBUG("Node: " << node->GetId());
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700159
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800160 Ptr<L3RateTracer> trace = Create<L3RateTracer>(outputStream, node);
161 trace->SetAveragingPeriod(averagingPeriod);
Alexander Afanasyev5352af32013-07-15 09:51:28 -0700162
163 return trace;
164}
165
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800166L3RateTracer::L3RateTracer(shared_ptr<std::ostream> os, Ptr<Node> node)
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800167 : L3Tracer(node)
168 , m_os(os)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800169{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800170 SetAveragingPeriod(Seconds(1.0));
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800171}
172
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800173L3RateTracer::L3RateTracer(shared_ptr<std::ostream> os, const std::string& node)
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800174 : L3Tracer(node)
175 , m_os(os)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800176{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800177 SetAveragingPeriod(Seconds(1.0));
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800178}
179
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800180L3RateTracer::~L3RateTracer()
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800181{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800182 m_printEvent.Cancel();
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800183}
184
185void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800186L3RateTracer::SetAveragingPeriod(const Time& period)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800187{
188 m_period = period;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800189 m_printEvent.Cancel();
190 m_printEvent = Simulator::Schedule(m_period, &L3RateTracer::PeriodicPrinter, this);
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800191}
192
193void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800194L3RateTracer::PeriodicPrinter()
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800195{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800196 Print(*m_os);
197 Reset();
Alexander Afanasyev37b84c52013-04-26 13:38:52 -0700198
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800199 m_printEvent = Simulator::Schedule(m_period, &L3RateTracer::PeriodicPrinter, this);
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800200}
201
202void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800203L3RateTracer::PrintHeader(std::ostream& os) const
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800204{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800205 os << "Time"
206 << "\t"
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800207
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800208 << "Node"
209 << "\t"
210 << "FaceId"
211 << "\t"
212 << "FaceDescr"
213 << "\t"
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800214
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800215 << "Type"
216 << "\t"
217 << "Packets"
218 << "\t"
219 << "Kilobytes"
220 << "\t"
221 << "PacketRaw"
222 << "\t"
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800223 << "KilobytesRaw";
224}
225
226void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800227L3RateTracer::Reset()
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800228{
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800229 for (std::map<shared_ptr<const Face>, std::tuple<Stats, Stats, Stats, Stats>>::iterator stats =
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800230 m_stats.begin();
231 stats != m_stats.end(); stats++) {
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800232 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
Spyridon Mastorakisda904f22014-11-05 16:23:33 -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"; \
Spyridon Mastorakisda904f22014-11-05 16:23:33 -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
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800263 for (std::map<shared_ptr<const Face>, std::tuple<Stats, Stats, Stats, Stats>>::iterator stats =
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800264 m_stats.begin();
265 stats != m_stats.end(); stats++) {
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800266 if (stats->first == nullptr)
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800267 continue;
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800268
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800269 PRINTER("InInterests", m_inInterests);
270 PRINTER("OutInterests", m_outInterests);
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800271
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800272 PRINTER("InData", m_inData);
273 PRINTER("OutData", m_outData);
Alexander Afanasyevbf939292013-07-15 10:10:01 -0700274
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800275 // PRINTER("InSatisfiedInterests", m_satisfiedInterests);
276 // PRINTER("InTimedOutInterests", m_timedOutInterests);
Alexander Afanasyevbf939292013-07-15 10:10:01 -0700277
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800278 // PRINTER("OutSatisfiedInterests", m_outSatisfiedInterests);
279 // PRINTER("OutTimedOutInterests", m_outTimedOutInterests);
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800280 }
Alexander Afanasyev37b84c52013-04-26 13:38:52 -0700281
282 {
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800283 // std::map<shared_ptr<const Face>, boost::tuple<Stats, Stats, Stats, Stats>>::iterator stats =
284 // m_stats.find(shared_ptr<const Face>(0));
285 // if (stats != m_stats.end()) {
286 // PRINTER("SatisfiedInterests", m_satisfiedInterests);
287 // PRINTER("TimedOutInterests", m_timedOutInterests);
288 // }
Alexander Afanasyev37b84c52013-04-26 13:38:52 -0700289 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800290}
291
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800292void
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800293L3RateTracer::OutInterests(const Interest& interest, const Face& face)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800294{
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800295 std::get<0>(m_stats[(const_cast<Face*>(&face))->shared_from_this()]).m_outInterests++;
296 if (interest.hasWire()) {
297 std::get<1>(m_stats[(const_cast<Face*>(&face))->shared_from_this()]).m_outInterests +=
298 interest.wireEncode().size();
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800299 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800300}
301
302void
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800303L3RateTracer::InInterests(const Interest& interest, const Face& face)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800304{
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800305 std::get<0>(m_stats[(const_cast<Face*>(&face))->shared_from_this()]).m_inInterests++;
306 if (interest.hasWire()) {
307 std::get<1>(m_stats[(const_cast<Face*>(&face))->shared_from_this()]).m_inInterests +=
308 interest.wireEncode().size();
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800309 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800310}
311
312void
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800313L3RateTracer::OutData(const Data& data, const Face& face)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800314{
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800315 std::get<0>(m_stats[(const_cast<Face*>(&face))->shared_from_this()]).m_outData++;
316 if (data.hasWire()) {
317 std::get<1>(m_stats[(const_cast<Face*>(&face))->shared_from_this()]).m_outData +=
318 data.wireEncode().size();
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800319 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800320}
321
322void
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800323L3RateTracer::InData(const Data& data, const Face& face)
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800324{
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800325 std::get<0>(m_stats[(const_cast<Face*>(&face))->shared_from_this()]).m_inData++;
326 if (data.hasWire()) {
327 std::get<1>(m_stats[(const_cast<Face*>(&face))->shared_from_this()]).m_inData +=
328 data.wireEncode().size();
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800329 }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800330}
331
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800332// void
333// L3RateTracer::SatisfiedInterests (Ptr<const pit::Entry> entry)
334// {
335// m_stats[0].std::get<0> ().m_satisfiedInterests ++;
336// // no "size" stats
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800337
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800338// for (::nfd::pit::Entry::in_container::const_iterator i = entry->GetIncoming ().begin ();
339// i != entry->GetIncoming ().end ();
340// i++)
341// {
342// m_stats[i->m_face].std::get<0> ().m_satisfiedInterests ++;
343// }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800344
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800345// for (::nfd::pit::Entry::out_container::const_iterator i = entry->GetOutgoing ().begin ();
346// i != entry->GetOutgoing ().end ();
347// i++)
348// {
349// m_stats[i->m_face].std::get<0> ().m_outSatisfiedInterests ++;
350// }
351// }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800352
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800353// void
354// L3RateTracer::TimedOutInterests (Ptr<const pit::Entry> entry)
355// {
356// m_stats[0].std::get<0> ().m_timedOutInterests ++;
357// // no "size" stats
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800358
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800359// for (pit::Entry::in_container::const_iterator i = entry->GetIncoming ().begin ();
360// i != entry->GetIncoming ().end ();
361// i++)
362// {
363// m_stats[i->m_face].std::get<0> ().m_timedOutInterests ++;
364// }
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800365
Spyridon Mastorakisda904f22014-11-05 16:23:33 -0800366// for (pit::Entry::out_container::const_iterator i = entry->GetOutgoing ().begin ();
367// i != entry->GetOutgoing ().end ();
368// i++)
369// {
370// m_stats[i->m_face].std::get<0> ().m_outTimedOutInterests ++;
371// }
372// }
Alexander Afanasyev37b84c52013-04-26 13:38:52 -0700373
Alexander Afanasyevc9d5c1a2012-11-21 18:00:26 -0800374} // namespace ndn
375} // namespace ns3