fw: Use ndn-cxx's RttEstimator in AsfStrategy

Refs: #4887
Change-Id: Ice718be99f2b96f183bb35c5df84930be54a9f8e
diff --git a/daemon/fw/asf-measurements.cpp b/daemon/fw/asf-measurements.cpp
index 404fc85..cf3a317 100644
--- a/daemon/fw/asf-measurements.cpp
+++ b/daemon/fw/asf-measurements.cpp
@@ -32,8 +32,8 @@
 
 NFD_LOG_INIT(AsfMeasurements);
 
-const RttStats::Rtt RttStats::RTT_TIMEOUT(-1.0);
-const RttStats::Rtt RttStats::RTT_NO_MEASUREMENT(0.0);
+const time::nanoseconds RttStats::RTT_TIMEOUT(-1);
+const time::nanoseconds RttStats::RTT_NO_MEASUREMENT(0);
 const double RttStats::ALPHA = 0.125;
 
 RttStats::RttStats()
@@ -43,23 +43,11 @@
 }
 
 void
-RttStats::addRttMeasurement(RttEstimator::Duration& durationRtt)
+RttStats::addRttMeasurement(time::nanoseconds durationRtt)
 {
-  m_rtt = static_cast<RttStats::Rtt>(durationRtt.count());
-
-  m_rttEstimator.addMeasurement(durationRtt);
-
-  m_srtt = computeSrtt(m_srtt, m_rtt);
-}
-
-RttStats::Rtt
-RttStats::computeSrtt(Rtt previousSrtt, Rtt currentRtt)
-{
-  if (previousSrtt == RTT_NO_MEASUREMENT) {
-    return currentRtt;
-  }
-
-  return Rtt(ALPHA * currentRtt + (1 - ALPHA) * previousSrtt);
+  m_rtt = durationRtt;
+  m_rttEstimator.addMeasurement(durationRtt, 1);
+  m_srtt = m_rttEstimator.getSmoothedRtt();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -122,14 +110,9 @@
     return;
   }
 
-  time::steady_clock::Duration steadyRtt = time::steady_clock::now() - outRecord->getLastRenewed();
-  auto durationRtt = time::duration_cast<RttEstimator::Duration>(steadyRtt);
-
-  m_rttStats.addRttMeasurement(durationRtt);
-
+  m_rttStats.addRttMeasurement(time::steady_clock::now() - outRecord->getLastRenewed());
   NFD_LOG_TRACE("Recording RTT for FaceId: " << inFace.getId()
-                                             << " RTT: "    << m_rttStats.getRtt()
-                                             << " SRTT: "   << m_rttStats.getSrtt());
+                << " RTT: " << m_rttStats.getRtt() << " SRTT: " << m_rttStats.getSrtt());
 }
 
 void
@@ -167,9 +150,10 @@
   FaceInfo* info = nullptr;
 
   if (it == m_fit.end()) {
-    const auto& pair = m_fit.emplace(faceId, FaceInfo());
+    const auto& pair = m_fit.emplace(std::piecewise_construct,
+                                     std::forward_as_tuple(faceId),
+                                     std::forward_as_tuple());
     info = &pair.first->second;
-
     extendFaceInfoLifetime(*info, faceId);
   }
   else {