model+utils: Enable SatisfiedInterests and TimedOutInterests trace sources in L3Protocol
This commit also fixes L3Tracers to re-enable use of SatisfiedInterests and
TimedOutInterests traces
Change-Id: Ib657a3fdba941d022a33d789e4d10c3547d232ff
Refs: #2349
diff --git a/model/ndn-l3-protocol.cpp b/model/ndn-l3-protocol.cpp
index 39ce2ca..dd9f4dc 100644
--- a/model/ndn-l3-protocol.cpp
+++ b/model/ndn-l3-protocol.cpp
@@ -77,7 +77,15 @@
////////////////////////////////////////////////////////////////////
.AddTraceSource("OutData", "OutData", MakeTraceSourceAccessor(&L3Protocol::m_outData))
- .AddTraceSource("InData", "InData", MakeTraceSourceAccessor(&L3Protocol::m_inData));
+ .AddTraceSource("InData", "InData", MakeTraceSourceAccessor(&L3Protocol::m_inData))
+
+ ////////////////////////////////////////////////////////////////////
+
+ .AddTraceSource("SatisfiedInterests", "SatisfiedInterests",
+ MakeTraceSourceAccessor(&L3Protocol::m_satisfiedInterests))
+ .AddTraceSource("TimedOutInterests", "TimedOutInterests",
+ MakeTraceSourceAccessor(&L3Protocol::m_timedOutInterests))
+ ;
return tid;
}
@@ -172,9 +180,9 @@
initializeManagement();
m_impl->m_forwarder->getFaceTable().addReserved(make_shared<nfd::NullFace>(), nfd::FACEID_NULL);
- m_impl->m_forwarder->getFaceTable().addReserved(make_shared<nfd::NullFace>(
- FaceUri("contentstore://")),
- nfd::FACEID_CONTENT_STORE);
+
+ m_impl->m_forwarder->beforeSatisfyInterest.connect(std::ref(m_satisfiedInterests));
+ m_impl->m_forwarder->beforeExpirePendingInterest.connect(std::ref(m_timedOutInterests));
}
class IgnoreSections
diff --git a/model/ndn-l3-protocol.hpp b/model/ndn-l3-protocol.hpp
index 79583c1..ffd3bc2 100644
--- a/model/ndn-l3-protocol.hpp
+++ b/model/ndn-l3-protocol.hpp
@@ -38,6 +38,9 @@
class FibManager;
class StrategyChoiceManager;
typedef boost::property_tree::ptree ConfigSection;
+namespace pit {
+class Entry;
+} // namespace pit
} // namespace nfd
namespace ns3 {
@@ -186,6 +189,9 @@
TracedCallback<const Data&, const Face&> m_outData; ///< @brief trace of outgoing Data
TracedCallback<const Data&, const Face&> m_inData; ///< @brief trace of incoming Data
+
+ TracedCallback<const nfd::pit::Entry&, const Face&/*in face*/, const Data&> m_satisfiedInterests;
+ TracedCallback<const nfd::pit::Entry&> m_timedOutInterests;
};
} // namespace ndn
diff --git a/utils/tracers/ndn-l3-rate-tracer.cpp b/utils/tracers/ndn-l3-rate-tracer.cpp
index 71fd4f9..8d27225 100644
--- a/utils/tracers/ndn-l3-rate-tracer.cpp
+++ b/utils/tracers/ndn-l3-rate-tracer.cpp
@@ -26,6 +26,8 @@
#include "ns3/log.h"
#include "ns3/node-list.h"
+#include "daemon/table/pit-entry.hpp"
+
#include <fstream>
#include <boost/lexical_cast.hpp>
@@ -226,17 +228,15 @@
void
L3RateTracer::Reset()
{
- for (std::map<shared_ptr<const Face>, std::tuple<Stats, Stats, Stats, Stats>>::iterator stats =
- m_stats.begin();
- stats != m_stats.end(); stats++) {
- std::get<0>(stats->second).Reset();
- std::get<1>(stats->second).Reset();
+ for (auto& stats : m_stats) {
+ std::get<0>(stats.second).Reset();
+ std::get<1>(stats.second).Reset();
}
}
const double alpha = 0.8;
-#define STATS(INDEX) std::get<INDEX>(stats->second)
+#define STATS(INDEX) std::get<INDEX>(stats.second)
#define RATE(INDEX, fieldName) STATS(INDEX).fieldName / m_period.ToDouble(Time::S)
#define PRINTER(printName, fieldName) \
@@ -246,8 +246,8 @@
+ /*old value*/ (1 - alpha) * STATS(3).fieldName; \
\
os << time.ToDouble(Time::S) << "\t" << m_node << "\t"; \
- if (stats->first != nullptr) { \
- os << stats->first->getId() << "\t" << stats->first->getLocalUri() << "\t"; \
+ if (stats.first != nullptr) { \
+ os << stats.first->getId() << "\t" << stats.first->getLocalUri() << "\t"; \
} \
else { \
os << "-1\tall\t"; \
@@ -260,10 +260,8 @@
{
Time time = Simulator::Now();
- for (std::map<shared_ptr<const Face>, std::tuple<Stats, Stats, Stats, Stats>>::iterator stats =
- m_stats.begin();
- stats != m_stats.end(); stats++) {
- if (stats->first == nullptr)
+ for (auto& stats : m_stats) {
+ if (stats.first == nullptr)
continue;
PRINTER("InInterests", m_inInterests);
@@ -272,29 +270,29 @@
PRINTER("InData", m_inData);
PRINTER("OutData", m_outData);
- // PRINTER("InSatisfiedInterests", m_satisfiedInterests);
- // PRINTER("InTimedOutInterests", m_timedOutInterests);
+ PRINTER("InSatisfiedInterests", m_satisfiedInterests);
+ PRINTER("InTimedOutInterests", m_timedOutInterests);
- // PRINTER("OutSatisfiedInterests", m_outSatisfiedInterests);
- // PRINTER("OutTimedOutInterests", m_outTimedOutInterests);
+ PRINTER("OutSatisfiedInterests", m_outSatisfiedInterests);
+ PRINTER("OutTimedOutInterests", m_outTimedOutInterests);
}
{
- // std::map<shared_ptr<const Face>, boost::tuple<Stats, Stats, Stats, Stats>>::iterator stats =
- // m_stats.find(shared_ptr<const Face>(0));
- // if (stats != m_stats.end()) {
- // PRINTER("SatisfiedInterests", m_satisfiedInterests);
- // PRINTER("TimedOutInterests", m_timedOutInterests);
- // }
+ auto i = m_stats.find(nullptr);
+ if (i != m_stats.end()) {
+ auto& stats = *i;
+ PRINTER("SatisfiedInterests", m_satisfiedInterests);
+ PRINTER("TimedOutInterests", m_timedOutInterests);
+ }
}
}
void
L3RateTracer::OutInterests(const Interest& interest, const Face& face)
{
- std::get<0>(m_stats[(const_cast<Face*>(&face))->shared_from_this()]).m_outInterests++;
+ std::get<0>(m_stats[face.shared_from_this()]).m_outInterests++;
if (interest.hasWire()) {
- std::get<1>(m_stats[(const_cast<Face*>(&face))->shared_from_this()]).m_outInterests +=
+ std::get<1>(m_stats[face.shared_from_this()]).m_outInterests +=
interest.wireEncode().size();
}
}
@@ -302,9 +300,9 @@
void
L3RateTracer::InInterests(const Interest& interest, const Face& face)
{
- std::get<0>(m_stats[(const_cast<Face*>(&face))->shared_from_this()]).m_inInterests++;
+ std::get<0>(m_stats[face.shared_from_this()]).m_inInterests++;
if (interest.hasWire()) {
- std::get<1>(m_stats[(const_cast<Face*>(&face))->shared_from_this()]).m_inInterests +=
+ std::get<1>(m_stats[face.shared_from_this()]).m_inInterests +=
interest.wireEncode().size();
}
}
@@ -312,9 +310,9 @@
void
L3RateTracer::OutData(const Data& data, const Face& face)
{
- std::get<0>(m_stats[(const_cast<Face*>(&face))->shared_from_this()]).m_outData++;
+ std::get<0>(m_stats[face.shared_from_this()]).m_outData++;
if (data.hasWire()) {
- std::get<1>(m_stats[(const_cast<Face*>(&face))->shared_from_this()]).m_outData +=
+ std::get<1>(m_stats[face.shared_from_this()]).m_outData +=
data.wireEncode().size();
}
}
@@ -322,54 +320,42 @@
void
L3RateTracer::InData(const Data& data, const Face& face)
{
- std::get<0>(m_stats[(const_cast<Face*>(&face))->shared_from_this()]).m_inData++;
+ std::get<0>(m_stats[face.shared_from_this()]).m_inData++;
if (data.hasWire()) {
- std::get<1>(m_stats[(const_cast<Face*>(&face))->shared_from_this()]).m_inData +=
+ std::get<1>(m_stats[face.shared_from_this()]).m_inData +=
data.wireEncode().size();
}
}
-// void
-// L3RateTracer::SatisfiedInterests (Ptr<const pit::Entry> entry)
-// {
-// m_stats[0].std::get<0> ().m_satisfiedInterests ++;
-// // no "size" stats
+void
+L3RateTracer::SatisfiedInterests(const nfd::pit::Entry& entry, const Face&, const Data&)
+{
+ std::get<0>(m_stats[nullptr]).m_satisfiedInterests++;
+ // no "size" stats
-// for (::nfd::pit::Entry::in_container::const_iterator i = entry->GetIncoming ().begin ();
-// i != entry->GetIncoming ().end ();
-// i++)
-// {
-// m_stats[i->m_face].std::get<0> ().m_satisfiedInterests ++;
-// }
+ for (const auto& in : entry.getInRecords()) {
+ std::get<0>(m_stats[in.getFace()]).m_satisfiedInterests ++;
+ }
-// for (::nfd::pit::Entry::out_container::const_iterator i = entry->GetOutgoing ().begin ();
-// i != entry->GetOutgoing ().end ();
-// i++)
-// {
-// m_stats[i->m_face].std::get<0> ().m_outSatisfiedInterests ++;
-// }
-// }
+ for (const auto& out : entry.getOutRecords()) {
+ std::get<0>(m_stats[out.getFace()]).m_outSatisfiedInterests ++;
+ }
+}
-// void
-// L3RateTracer::TimedOutInterests (Ptr<const pit::Entry> entry)
-// {
-// m_stats[0].std::get<0> ().m_timedOutInterests ++;
-// // no "size" stats
+void
+L3RateTracer::TimedOutInterests(const nfd::pit::Entry& entry)
+{
+ std::get<0>(m_stats[nullptr]).m_timedOutInterests++;
+ // no "size" stats
-// for (pit::Entry::in_container::const_iterator i = entry->GetIncoming ().begin ();
-// i != entry->GetIncoming ().end ();
-// i++)
-// {
-// m_stats[i->m_face].std::get<0> ().m_timedOutInterests ++;
-// }
+ for (const auto& in : entry.getInRecords()) {
+ std::get<0>(m_stats[in.getFace()]).m_timedOutInterests++;
+ }
-// for (pit::Entry::out_container::const_iterator i = entry->GetOutgoing ().begin ();
-// i != entry->GetOutgoing ().end ();
-// i++)
-// {
-// m_stats[i->m_face].std::get<0> ().m_outTimedOutInterests ++;
-// }
-// }
+ for (const auto& out : entry.getOutRecords()) {
+ std::get<0>(m_stats[out.getFace()]).m_outTimedOutInterests++;
+ }
+}
} // namespace ndn
} // namespace ns3
diff --git a/utils/tracers/ndn-l3-rate-tracer.hpp b/utils/tracers/ndn-l3-rate-tracer.hpp
index 69a8c0f..6370c26 100644
--- a/utils/tracers/ndn-l3-rate-tracer.hpp
+++ b/utils/tracers/ndn-l3-rate-tracer.hpp
@@ -139,11 +139,11 @@
virtual void
InData(const Data& data, const Face& face);
- // virtual void
- // SatisfiedInterests(Ptr<const pit::Entry>);
+ virtual void
+ SatisfiedInterests(const nfd::pit::Entry&, const Face&, const Data&);
- // virtual void
- // TimedOutInterests(Ptr<const pit::Entry>);
+ virtual void
+ TimedOutInterests(const nfd::pit::Entry&);
private:
void
diff --git a/utils/tracers/ndn-l3-tracer.cpp b/utils/tracers/ndn-l3-tracer.cpp
index 6fc6b16..e19439b 100644
--- a/utils/tracers/ndn-l3-tracer.cpp
+++ b/utils/tracers/ndn-l3-tracer.cpp
@@ -62,11 +62,12 @@
l3->TraceConnectWithoutContext("OutData", MakeCallback(&L3Tracer::OutData, this));
l3->TraceConnectWithoutContext("InData", MakeCallback(&L3Tracer::InData, this));
- // // satisfied/timed out PIs
- // l3->TraceConnectWithoutContext("SatisfiedInterests",
- // MakeCallback(&L3Tracer::SatisfiedInterests, this));
- // l3->TraceConnectWithoutContext("TimedOutInterests",
- // MakeCallback(&L3Tracer::TimedOutInterests, this));
+ // satisfied/timed out PIs
+ l3->TraceConnectWithoutContext("SatisfiedInterests",
+ MakeCallback(&L3Tracer::SatisfiedInterests, this));
+
+ l3->TraceConnectWithoutContext("TimedOutInterests",
+ MakeCallback(&L3Tracer::TimedOutInterests, this));
}
} // namespace ndn
diff --git a/utils/tracers/ndn-l3-tracer.hpp b/utils/tracers/ndn-l3-tracer.hpp
index f11e317..a938113 100644
--- a/utils/tracers/ndn-l3-tracer.hpp
+++ b/utils/tracers/ndn-l3-tracer.hpp
@@ -26,6 +26,12 @@
#include "ns3/ptr.h"
#include "ns3/simple-ref-count.h"
+namespace nfd {
+namespace pit {
+class Entry;
+} // namespace pit
+} // namespace nfd
+
namespace ns3 {
class Node;
@@ -88,11 +94,11 @@
virtual void
InData(const Data&, const Face&) = 0;
- // virtual void
- // SatisfiedInterests(Ptr<const pit::Entry>) = 0;
+ virtual void
+ SatisfiedInterests(const nfd::pit::Entry&, const Face&, const Data&) = 0;
- // virtual void
- // TimedOutInterests(Ptr<const pit::Entry>) = 0;
+ virtual void
+ TimedOutInterests(const nfd::pit::Entry&) = 0;
protected:
std::string m_node;
@@ -106,21 +112,21 @@
m_outInterests = 0;
m_inData = 0;
m_outData = 0;
- // m_satisfiedInterests = 0;
- // m_timedOutInterests = 0;
+ m_satisfiedInterests = 0;
+ m_timedOutInterests = 0;
- // m_outSatisfiedInterests = 0;
- // m_outTimedOutInterests = 0;
+ m_outSatisfiedInterests = 0;
+ m_outTimedOutInterests = 0;
}
double m_inInterests;
double m_outInterests;
double m_inData;
double m_outData;
- // double m_satisfiedInterests;
- // double m_timedOutInterests;
- // double m_outSatisfiedInterests;
- // double m_outTimedOutInterests;
+ double m_satisfiedInterests;
+ double m_timedOutInterests;
+ double m_outSatisfiedInterests;
+ double m_outTimedOutInterests;
};
};