fw: use ndn-cxx's RttEstimator in AccessStrategy
Refs: #4887
Change-Id: I7e404df953f99374e676c7eb29897c45d0868eef
diff --git a/daemon/fw/access-strategy.cpp b/daemon/fw/access-strategy.cpp
index b82ba40..6ae2767 100644
--- a/daemon/fw/access-strategy.cpp
+++ b/daemon/fw/access-strategy.cpp
@@ -36,7 +36,8 @@
AccessStrategy::AccessStrategy(Forwarder& forwarder, const Name& name)
: Strategy(forwarder)
- , m_removeFaceInfoConn(beforeRemoveFace.connect([this] (const Face& face) { removeFaceInfo(face); }))
+ , m_rttEstimatorOpts(make_shared<RttEstimator::Options>()) // use the default options
+ , m_removeFaceConn(beforeRemoveFace.connect([this] (const Face& face) { m_fit.erase(face.getId()); }))
{
ParsedInstanceName parsed = parseInstanceName(name);
if (!parsed.parameters.empty()) {
@@ -139,7 +140,7 @@
return false;
}
- auto rto = mi.rtt.computeRto();
+ auto rto = mi.rtt.getEstimatedRto();
NFD_LOG_DEBUG(pitEntry->getInterest() << " interestTo " << mi.lastNexthop
<< " last-nexthop rto=" << time::duration_cast<time::microseconds>(rto).count());
@@ -147,10 +148,11 @@
// schedule RTO timeout
PitInfo* pi = pitEntry->insertStrategyInfo<PitInfo>().first;
- pi->rtoTimer = getScheduler().schedule(rto, [=] {
- afterRtoTimeout(weak_ptr<pit::Entry>(pitEntry),
- ingress.face.getId(), ingress.endpoint, mi.lastNexthop);
- });
+ pi->rtoTimer = getScheduler().schedule(rto,
+ [this, pitWeak = weak_ptr<pit::Entry>(pitEntry), face = ingress.face.getId(),
+ endpoint = ingress.endpoint, lastNexthop = mi.lastNexthop] {
+ afterRtoTimeout(pitWeak, face, endpoint, lastNexthop);
+ });
return true;
}
@@ -226,15 +228,16 @@
auto rtt = time::steady_clock::now() - outRecord->getLastRenewed();
NFD_LOG_DEBUG(pitEntry->getInterest() << " dataFrom " << ingress
<< " rtt=" << time::duration_cast<time::microseconds>(rtt).count());
- this->updateMeasurements(ingress.face, data, time::duration_cast<RttEstimator::Duration>(rtt));
+ this->updateMeasurements(ingress.face, data, rtt);
}
void
-AccessStrategy::updateMeasurements(const Face& inFace, const Data& data,
- const RttEstimator::Duration& rtt)
+AccessStrategy::updateMeasurements(const Face& inFace, const Data& data, time::nanoseconds rtt)
{
- ///\todo move FaceInfoTable out of AccessStrategy instance, to Measurements or somewhere else
- FaceInfo& fi = m_fit[inFace.getId()];
+ auto ret = m_fit.emplace(std::piecewise_construct,
+ std::forward_as_tuple(inFace.getId()),
+ std::forward_as_tuple(m_rttEstimatorOpts));
+ FaceInfo& fi = ret.first->second;
fi.rtt.addMeasurement(rtt);
MtInfo* mi = this->addPrefixMeasurements(data);
@@ -276,14 +279,7 @@
}
this->getMeasurements().extendLifetime(*me, 8_s);
-
- return me->insertStrategyInfo<MtInfo>().first;
-}
-
-void
-AccessStrategy::removeFaceInfo(const Face& face)
-{
- m_fit.erase(face.getId());
+ return me->insertStrategyInfo<MtInfo>(m_rttEstimatorOpts).first;
}
} // namespace fw