chunks: include RTT stats in final summary

Change-Id: I9cc7cba4c8fe1f7d7a2d68c96a7db2c04774bc19
Refs: #4406
diff --git a/tests/chunks/aimd-rtt-estimator.t.cpp b/tests/chunks/aimd-rtt-estimator.t.cpp
index 38db749..9241fee 100644
--- a/tests/chunks/aimd-rtt-estimator.t.cpp
+++ b/tests/chunks/aimd-rtt-estimator.t.cpp
@@ -1,8 +1,8 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2016,  Regents of the University of California,
- *                      Colorado State University,
- *                      University Pierre & Marie Curie, Sorbonne University.
+/*
+ * Copyright (c) 2016-2018,  Regents of the University of California,
+ *                           Colorado State University,
+ *                           University Pierre & Marie Curie, Sorbonne University.
  *
  * This file is part of ndn-tools (Named Data Networking Essential Tools).
  * See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -21,12 +21,15 @@
  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
  *
  * @author Weiwei Liu
+ * @author Chavoosh Ghasemi
  */
 
 #include "tools/chunks/catchunks/aimd-rtt-estimator.hpp"
 
 #include "tests/test-common.hpp"
 
+#include <limits>
+
 namespace ndn {
 namespace chunks {
 namespace aimd {
@@ -62,6 +65,39 @@
 BOOST_AUTO_TEST_SUITE(Chunks)
 BOOST_FIXTURE_TEST_SUITE(TestAimdRttEstimator, RttEstimatorFixture)
 
+BOOST_AUTO_TEST_CASE(MinAvgMaxRtt)
+{
+  // check initial values
+  BOOST_CHECK_CLOSE(rttEstimator.m_rttMin, std::numeric_limits<double>::max(), 0.1);
+  BOOST_CHECK_CLOSE(rttEstimator.m_rttAvg, 0.0, 0.1);
+  BOOST_CHECK_CLOSE(rttEstimator.m_rttMax, std::numeric_limits<double>::min(), 0.1);
+  BOOST_CHECK_EQUAL(rttEstimator.m_nRttSamples, 0);
+
+  // start with three samples
+  rttEstimator.addMeasurement(1, Milliseconds(100), 1);
+  rttEstimator.addMeasurement(2, Milliseconds(400), 1);
+  rttEstimator.addMeasurement(3, Milliseconds(250), 1);
+
+  BOOST_CHECK_CLOSE(rttEstimator.m_rttMin, 100, 0.1);
+  BOOST_CHECK_CLOSE(rttEstimator.m_rttAvg, 250, 0.1);
+  BOOST_CHECK_CLOSE(rttEstimator.m_rttMax, 400, 0.1);
+  BOOST_CHECK_EQUAL(rttEstimator.m_nRttSamples, 3);
+
+  // add another sample (new minimum)
+  rttEstimator.addMeasurement(4, Milliseconds(50), 2);
+  BOOST_CHECK_CLOSE(rttEstimator.m_rttMin, 50, 0.1);
+  BOOST_CHECK_CLOSE(rttEstimator.m_rttAvg, 200, 0.1);
+  BOOST_CHECK_CLOSE(rttEstimator.m_rttMax, 400, 0.1);
+  BOOST_CHECK_EQUAL(rttEstimator.m_nRttSamples, 4);
+
+  // add another sample (new maximum)
+  rttEstimator.addMeasurement(5, Milliseconds(700), 1);
+  BOOST_CHECK_CLOSE(rttEstimator.m_rttMin, 50, 0.1);
+  BOOST_CHECK_CLOSE(rttEstimator.m_rttAvg, 300, 0.1);
+  BOOST_CHECK_CLOSE(rttEstimator.m_rttMax, 700, 0.1);
+  BOOST_CHECK_EQUAL(rttEstimator.m_nRttSamples, 5);
+}
+
 BOOST_AUTO_TEST_CASE(MeasureRtt)
 {
   BOOST_REQUIRE(std::isnan(rttEstimator.m_sRtt.count()));
@@ -71,9 +107,9 @@
   // first measurement
   rttEstimator.addMeasurement(1, Milliseconds(100), 1);
 
-  BOOST_CHECK_CLOSE(rttEstimator.m_sRtt.count(), 100, 1);
-  BOOST_CHECK_CLOSE(rttEstimator.m_rttVar.count(), 50, 1);
-  BOOST_CHECK_CLOSE(rttEstimator.m_rto.count(), 300, 1);
+  BOOST_CHECK_CLOSE(rttEstimator.m_sRtt.count(), 100, 0.1);
+  BOOST_CHECK_CLOSE(rttEstimator.m_rttVar.count(), 50, 0.1);
+  BOOST_CHECK_CLOSE(rttEstimator.m_rto.count(), 300, 0.1);
 
   rttEstimator.m_sRtt = Milliseconds(500.0);
   rttEstimator.m_rttVar = Milliseconds(100.0);
@@ -82,16 +118,16 @@
   size_t nExpectedSamples = 1;
   rttEstimator.addMeasurement(1, Milliseconds(100), nExpectedSamples);
 
-  BOOST_CHECK_CLOSE(rttEstimator.m_sRtt.count(), 450, 1);
-  BOOST_CHECK_CLOSE(rttEstimator.m_rttVar.count(), 175, 1);
+  BOOST_CHECK_CLOSE(rttEstimator.m_sRtt.count(), 450, 0.1);
+  BOOST_CHECK_CLOSE(rttEstimator.m_rttVar.count(), 175, 0.1);
   BOOST_CHECK_CLOSE(rttEstimator.m_rto.count(), 1150, 0.1);
 
-  // expected Samples larger than 1
+  // expected samples larger than 1
   nExpectedSamples = 5;
   rttEstimator.addMeasurement(1, Milliseconds(100), nExpectedSamples);
 
-  BOOST_CHECK_CLOSE(rttEstimator.m_sRtt.count(), 441.25, 1);
-  BOOST_CHECK_CLOSE(rttEstimator.m_rttVar.count(), 183.75, 1);
+  BOOST_CHECK_CLOSE(rttEstimator.m_sRtt.count(), 441.25, 0.1);
+  BOOST_CHECK_CLOSE(rttEstimator.m_rttVar.count(), 183.75, 0.1);
   BOOST_CHECK_CLOSE(rttEstimator.m_rto.count(), 1176.25, 0.1);
 
   rttEstimator.m_sRtt = Milliseconds(100.0);
@@ -102,9 +138,9 @@
   nExpectedSamples = 1;
   rttEstimator.addMeasurement(1, Milliseconds(100), nExpectedSamples);
 
-  BOOST_CHECK_CLOSE(rttEstimator.m_sRtt.count(), 100, 1);
-  BOOST_CHECK_CLOSE(rttEstimator.m_rttVar.count(), 22.5, 1);
-  BOOST_CHECK_CLOSE(rttEstimator.m_rto.count(), 200, 1);
+  BOOST_CHECK_CLOSE(rttEstimator.m_sRtt.count(), 100, 0.1);
+  BOOST_CHECK_CLOSE(rttEstimator.m_rttVar.count(), 22.5, 0.1);
+  BOOST_CHECK_CLOSE(rttEstimator.m_rto.count(), 200, 0.1);
 
   rttEstimator.m_sRtt = Milliseconds(2000.0);
   rttEstimator.m_rttVar = Milliseconds(400.0);