From a918bd36475c7515cb4121b571426de7b4a7ae3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Rodr=C3=ADguez=20P=C3=A9rez?= Date: Tue, 14 Dec 2021 12:30:13 +0000 Subject: [PATCH] Connect forwarder cache hit and miss signals This lets the CsTracer provide stats again after their removal in commit 8fbcc642ff0d8. --- utils/tracers/ndn-cs-tracer.cpp | 18 ++++++++++++------ utils/tracers/ndn-cs-tracer.hpp | 4 ++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/utils/tracers/ndn-cs-tracer.cpp b/utils/tracers/ndn-cs-tracer.cpp index e58a00553..080bf85e0 100644 --- a/utils/tracers/ndn-cs-tracer.cpp +++ b/utils/tracers/ndn-cs-tracer.cpp @@ -18,6 +18,8 @@ **/ #include "ndn-cs-tracer.hpp" +#include "fw/forwarder.hpp" +#include "model/ndn-l3-protocol.hpp" #include "ns3/node.h" #include "ns3/packet.h" #include "ns3/config.h" @@ -199,10 +201,14 @@ CsTracer::~CsTracer(){}; void CsTracer::Connect() { - // // @TODO Do the same with NFD content store... - // Ptr cs = m_nodePtr->GetObject(); - // cs->TraceConnectWithoutContext("CacheHits", MakeCallback(&CsTracer::CacheHits, this)); - // cs->TraceConnectWithoutContext("CacheMisses", MakeCallback(&CsTracer::CacheMisses, this)); + auto l3proto = m_nodePtr->GetObject(); + auto fwd = l3proto->getForwarder(); + + fwd->afterCsHit.connect( + [this](Interest interest, Data data) { CacheHits(interest, data); }); + + fwd->afterCsMiss.connect( + [this](Interest interest) { CacheMisses(interest); }); Reset(); } @@ -259,13 +265,13 @@ CsTracer::Print(std::ostream& os) const } void -CsTracer::CacheHits(shared_ptr, shared_ptr) +CsTracer::CacheHits(const Interest&, const Data&) { m_stats.m_cacheHits++; } void -CsTracer::CacheMisses(shared_ptr) +CsTracer::CacheMisses(const Interest&) { m_stats.m_cacheMisses++; } diff --git a/utils/tracers/ndn-cs-tracer.hpp b/utils/tracers/ndn-cs-tracer.hpp index f4da1a770..89c25f839 100644 --- a/utils/tracers/ndn-cs-tracer.hpp +++ b/utils/tracers/ndn-cs-tracer.hpp @@ -173,10 +173,10 @@ class CsTracer : public SimpleRefCount { Connect(); void - CacheHits(shared_ptr, shared_ptr); + CacheHits(const Interest&, const Data&); void - CacheMisses(shared_ptr); + CacheMisses(const Interest&); private: void