Skip to content

Commit 963a44b

Browse files
committed
Connect forwarder cache hit and miss signals
This lets the CsTracer provide stats again after their removel in commit #8fbcc642ff0d8.
1 parent 28da73c commit 963a44b

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

utils/tracers/ndn-cs-tracer.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
**/
1919

2020
#include "ndn-cs-tracer.hpp"
21+
#include "fw/forwarder.hpp"
22+
#include "model/ndn-l3-protocol.hpp"
2123
#include "ns3/node.h"
2224
#include "ns3/packet.h"
2325
#include "ns3/config.h"
@@ -199,10 +201,14 @@ CsTracer::~CsTracer(){};
199201
void
200202
CsTracer::Connect()
201203
{
202-
// // @TODO Do the same with NFD content store...
203-
// Ptr<ContentStore> cs = m_nodePtr->GetObject<ContentStore>();
204-
// cs->TraceConnectWithoutContext("CacheHits", MakeCallback(&CsTracer::CacheHits, this));
205-
// cs->TraceConnectWithoutContext("CacheMisses", MakeCallback(&CsTracer::CacheMisses, this));
204+
auto l3proto = m_nodePtr->GetObject<ndn::L3Protocol>();
205+
auto fwd = l3proto->getForwarder();
206+
207+
fwd->afterCsHit.connect(
208+
[this](Interest interest, Data data) { CacheHits(interest, data); });
209+
210+
fwd->afterCsMiss.connect(
211+
[this](Interest interest) { CacheMisses(interest); });
206212

207213
Reset();
208214
}
@@ -259,13 +265,13 @@ CsTracer::Print(std::ostream& os) const
259265
}
260266

261267
void
262-
CsTracer::CacheHits(shared_ptr<const Interest>, shared_ptr<const Data>)
268+
CsTracer::CacheHits(const Interest&, const Data&)
263269
{
264270
m_stats.m_cacheHits++;
265271
}
266272

267273
void
268-
CsTracer::CacheMisses(shared_ptr<const Interest>)
274+
CsTracer::CacheMisses(const Interest&)
269275
{
270276
m_stats.m_cacheMisses++;
271277
}

utils/tracers/ndn-cs-tracer.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ class CsTracer : public SimpleRefCount<CsTracer> {
173173
Connect();
174174

175175
void
176-
CacheHits(shared_ptr<const Interest>, shared_ptr<const Data>);
176+
CacheHits(const Interest&, const Data&);
177177

178178
void
179-
CacheMisses(shared_ptr<const Interest>);
179+
CacheMisses(const Interest&);
180180

181181
private:
182182
void

0 commit comments

Comments
 (0)