chunks: show correct packet loss stats in AIMD pipeline output

Besides, AIMD pipeline prints a proper message when no RTT
measurements are available.

Change-Id: I9cbda88a005ba33cba753468f8f60f0d39281ab7
refs: #4437, #4551
This commit is contained in:
Chavoosh Ghasemi committed 2018-04-01 23:25:36 -04:00
1 parent e7d95a72ba
commit 75309aeedb
3 files changed
+44 -8

No files matched your search

@@ -472,6 +472,30 @@ BOOST_AUTO_TEST_CASE(SpuriousFailureBeforeFinalBlockIdReceived)
BOOST_CHECK_EQUAL(hasFailed, false);
}
BOOST_AUTO_TEST_CASE(PrintSummaryWithNoRttMeasurements)
{
// test the console ouptut when no RTT measurement is available,
// to make sure a proper message will be printed out
std::stringstream ss;
// change the underlying buffer and save the old buffer
auto oldBuf = std::cerr.rdbuf(ss.rdbuf());
aimdPipeline->printSummary();
std::string line;
bool found = false;
while (std::getline(ss, line)) {
if (line == "RTT stats unavailable") {
found = true;
break;
}
}
BOOST_CHECK(found);
std::cerr.rdbuf(oldBuf); // reset
}
BOOST_AUTO_TEST_SUITE_END() // TestPipelineInterestsAimd
BOOST_AUTO_TEST_SUITE_END() // Chunks
@@ -51,6 +51,7 @@ PipelineInterestsAimd::PipelineInterestsAimd(Face& face, RttEstimator& rttEstima
, m_nLossEvents(0)
, m_nRetransmitted(0)
, m_nCongMarks(0)
, m_nSent(0)
, m_cwnd(m_options.initCwnd)
, m_ssthresh(m_options.initSsthresh)
, m_hasFailure(false)
@@ -162,6 +163,7 @@ PipelineInterestsAimd::sendInterest(uint64_t segNo, bool isRetransmission)
bind(&PipelineInterestsAimd::handleNack, this, _1, _2),
bind(&PipelineInterestsAimd::handleLifetimeExpiration, this, _1));
m_nInFlight++;
m_nSent++;
if (isRetransmission) {
SegmentInfo& segInfo = m_segmentInfo[segNo];
@@ -437,15 +439,23 @@ void
PipelineInterestsAimd::printSummary() const
{
PipelineInterests::printSummary();
std::cerr << "Total # of packet loss events: " << m_nLossEvents << "\n"
std::cerr << "Total # of lost/retransmitted segments: " << m_nRetransmitted
<< " (caused " << m_nLossEvents << " window decreases)\n"
<< "Packet loss rate: "
<< static_cast<double>(m_nLossEvents) / static_cast<double>(m_nReceived) << "\n"
<< "Total # of retransmitted segments: " << m_nRetransmitted << "\n"
<< (static_cast<double>(m_nRetransmitted) / static_cast<double>(m_nSent)) * 100 << "%\n"
<< "Total # of received congestion marks: " << m_nCongMarks << "\n"
<< "RTT min/avg/max = " << std::fixed << std::setprecision(3)
<< m_rttEstimator.getMinRtt() << "/"
<< m_rttEstimator.getAvgRtt() << "/"
<< m_rttEstimator.getMaxRtt() << " ms\n";
<< "RTT ";
if (m_rttEstimator.getMinRtt() == std::numeric_limits<double>::max() ||
m_rttEstimator.getMaxRtt() == std::numeric_limits<double>::min()) {
std::cerr << "stats unavailable\n";
}
else {
std::cerr << "min/avg/max = " << std::fixed << std::setprecision(3)
<< m_rttEstimator.getMinRtt() << "/"
<< m_rttEstimator.getAvgRtt() << "/"
<< m_rttEstimator.getMaxRtt() << " ms\n";
}
}
std::ostream&
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2016-2017, Regents of the University of California,
* Copyright (c) 2016-2018, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -184,6 +184,7 @@ private:
void
cancelInFlightSegmentsGreaterThan(uint64_t segNo);
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
void
printSummary() const final;
@@ -203,6 +204,7 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
int64_t m_nLossEvents; ///< # of loss events occurred
int64_t m_nRetransmitted; ///< # of segments retransmitted
int64_t m_nCongMarks; ///< # of data packets with congestion mark
int64_t m_nSent; ///< # of interest packets sent out (including retransmissions)
double m_cwnd; ///< current congestion window size (in segments)
double m_ssthresh; ///< current slow start threshold