blob: 03a842fd47edd16603889382cd40126d75ee9268 [file] [log] [blame]
Davide Pesaventobf1c0692017-01-15 19:15:09 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Chavoosh Ghasemi4d36ed52017-10-31 22:26:25 +00002/*
Junxiao Shi7664b122019-01-23 16:45:17 +00003 * Copyright (c) 2016-2019, Regents of the University of California,
Davide Pesaventocd65c2c2017-01-15 16:10:38 -05004 * Colorado State University,
5 * University Pierre & Marie Curie, Sorbonne University.
Weiwei Liu245d7912016-07-28 00:04:25 -07006 *
7 * This file is part of ndn-tools (Named Data Networking Essential Tools).
8 * See AUTHORS.md for complete list of ndn-tools authors and contributors.
9 *
10 * ndn-tools is free software: you can redistribute it and/or modify it under the terms
11 * of the GNU General Public License as published by the Free Software Foundation,
12 * either version 3 of the License, or (at your option) any later version.
13 *
14 * ndn-tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 * PURPOSE. See the GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along with
19 * ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
20 *
21 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
22 *
23 * @author Shuo Yang
24 * @author Weiwei Liu
Chavoosh Ghasemi4d36ed52017-10-31 22:26:25 +000025 * @author Chavoosh Ghasemi
schneiderklausd8197df2019-03-16 11:31:40 -070026 * @author Klaus Schneider
Weiwei Liu245d7912016-07-28 00:04:25 -070027 */
28
schneiderklausd8197df2019-03-16 11:31:40 -070029#include "pipeline-interests-adaptive.hpp"
Davide Pesavento44b3b232017-12-23 16:58:25 -050030#include "data-fetcher.hpp"
Weiwei Liu245d7912016-07-28 00:04:25 -070031
32#include <cmath>
Chavoosh Ghasemi3dae1092017-12-21 12:39:08 -070033#include <iomanip>
Weiwei Liu245d7912016-07-28 00:04:25 -070034
35namespace ndn {
36namespace chunks {
Weiwei Liu245d7912016-07-28 00:04:25 -070037
schneiderklausd8197df2019-03-16 11:31:40 -070038constexpr double PipelineInterestsAdaptive::MIN_SSTHRESH;
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +000039
schneiderklausd8197df2019-03-16 11:31:40 -070040PipelineInterestsAdaptive::PipelineInterestsAdaptive(Face& face, RttEstimator& rttEstimator,
41 const Options& options)
Weiwei Liu245d7912016-07-28 00:04:25 -070042 : PipelineInterests(face)
43 , m_options(options)
Klaus Schneider9e5122b2019-03-19 17:03:25 -070044 , m_cwnd(m_options.initCwnd)
45 , m_ssthresh(m_options.initSsthresh)
Weiwei Liu245d7912016-07-28 00:04:25 -070046 , m_rttEstimator(rttEstimator)
47 , m_scheduler(m_face.getIoService())
Weiwei Liu245d7912016-07-28 00:04:25 -070048 , m_highData(0)
49 , m_highInterest(0)
50 , m_recPoint(0)
51 , m_nInFlight(0)
schneiderklaus8ff3abd2019-03-12 22:15:12 -070052 , m_nLossDecr(0)
53 , m_nMarkDecr(0)
54 , m_nTimeouts(0)
55 , m_nSkippedRetx(0)
Weiwei Liu245d7912016-07-28 00:04:25 -070056 , m_nRetransmitted(0)
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +000057 , m_nCongMarks(0)
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -040058 , m_nSent(0)
Weiwei Liu245d7912016-07-28 00:04:25 -070059 , m_hasFailure(false)
60 , m_failedSegNo(0)
61{
Weiwei Liu245d7912016-07-28 00:04:25 -070062}
63
schneiderklausd8197df2019-03-16 11:31:40 -070064PipelineInterestsAdaptive::~PipelineInterestsAdaptive()
Weiwei Liu245d7912016-07-28 00:04:25 -070065{
66 cancel();
67}
68
69void
schneiderklausd8197df2019-03-16 11:31:40 -070070PipelineInterestsAdaptive::doRun()
Weiwei Liu245d7912016-07-28 00:04:25 -070071{
Ryan Wickman034f30f2018-06-06 11:11:11 -050072 if (allSegmentsReceived()) {
73 cancel();
74 if (!m_options.isQuiet) {
75 printSummary();
76 }
77 return;
78 }
79
Weiwei Liu245d7912016-07-28 00:04:25 -070080 // schedule the event to check retransmission timer
Davide Pesaventobf2c5172019-03-20 19:08:09 -040081 m_checkRtoEvent = m_scheduler.schedule(m_options.rtoCheckInterval, [this] { checkRto(); });
Weiwei Liu245d7912016-07-28 00:04:25 -070082
Davide Pesavento958896e2017-01-19 00:52:04 -050083 schedulePackets();
Weiwei Liu245d7912016-07-28 00:04:25 -070084}
85
86void
schneiderklausd8197df2019-03-16 11:31:40 -070087PipelineInterestsAdaptive::doCancel()
Weiwei Liu245d7912016-07-28 00:04:25 -070088{
Davide Pesaventocd65c2c2017-01-15 16:10:38 -050089 m_checkRtoEvent.cancel();
Weiwei Liu245d7912016-07-28 00:04:25 -070090 m_segmentInfo.clear();
Weiwei Liu245d7912016-07-28 00:04:25 -070091}
92
93void
schneiderklausd8197df2019-03-16 11:31:40 -070094PipelineInterestsAdaptive::checkRto()
Weiwei Liu245d7912016-07-28 00:04:25 -070095{
96 if (isStopping())
97 return;
98
Davide Pesavento958896e2017-01-19 00:52:04 -050099 bool hasTimeout = false;
Weiwei Liu245d7912016-07-28 00:04:25 -0700100
101 for (auto& entry : m_segmentInfo) {
102 SegmentInfo& segInfo = entry.second;
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500103 if (segInfo.state != SegmentState::InRetxQueue) { // skip segments already in the retx queue
Weiwei Liu245d7912016-07-28 00:04:25 -0700104 Milliseconds timeElapsed = time::steady_clock::now() - segInfo.timeSent;
105 if (timeElapsed.count() > segInfo.rto.count()) { // timer expired?
schneiderklaus8ff3abd2019-03-12 22:15:12 -0700106 m_nTimeouts++;
Davide Pesavento958896e2017-01-19 00:52:04 -0500107 hasTimeout = true;
108 enqueueForRetransmission(entry.first);
Weiwei Liu245d7912016-07-28 00:04:25 -0700109 }
110 }
111 }
112
Davide Pesavento958896e2017-01-19 00:52:04 -0500113 if (hasTimeout) {
114 recordTimeout();
115 schedulePackets();
Weiwei Liu245d7912016-07-28 00:04:25 -0700116 }
117
118 // schedule the next check after predefined interval
Davide Pesaventobf2c5172019-03-20 19:08:09 -0400119 m_checkRtoEvent = m_scheduler.schedule(m_options.rtoCheckInterval, [this] { checkRto(); });
Weiwei Liu245d7912016-07-28 00:04:25 -0700120}
121
122void
schneiderklausd8197df2019-03-16 11:31:40 -0700123PipelineInterestsAdaptive::sendInterest(uint64_t segNo, bool isRetransmission)
Weiwei Liu245d7912016-07-28 00:04:25 -0700124{
125 if (isStopping())
126 return;
127
Ryan Wickman034f30f2018-06-06 11:11:11 -0500128 if (m_hasFinalBlockId && segNo > m_lastSegmentNo)
Weiwei Liu245d7912016-07-28 00:04:25 -0700129 return;
130
131 if (!isRetransmission && m_hasFailure)
132 return;
133
134 if (m_options.isVerbose) {
Davide Pesavento958896e2017-01-19 00:52:04 -0500135 std::cerr << (isRetransmission ? "Retransmitting" : "Requesting")
136 << " segment #" << segNo << std::endl;
Weiwei Liu245d7912016-07-28 00:04:25 -0700137 }
138
139 if (isRetransmission) {
Davide Pesavento958896e2017-01-19 00:52:04 -0500140 // keep track of retx count for this segment
141 auto ret = m_retxCount.emplace(segNo, 1);
Weiwei Liu245d7912016-07-28 00:04:25 -0700142 if (ret.second == false) { // not the first retransmission
143 m_retxCount[segNo] += 1;
Davide Pesavento44b3b232017-12-23 16:58:25 -0500144 if (m_options.maxRetriesOnTimeoutOrNack != DataFetcher::MAX_RETRIES_INFINITE &&
145 m_retxCount[segNo] > m_options.maxRetriesOnTimeoutOrNack) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700146 return handleFail(segNo, "Reached the maximum number of retries (" +
147 to_string(m_options.maxRetriesOnTimeoutOrNack) +
148 ") while retrieving segment #" + to_string(segNo));
149 }
150
151 if (m_options.isVerbose) {
152 std::cerr << "# of retries for segment #" << segNo
153 << " is " << m_retxCount[segNo] << std::endl;
154 }
155 }
Weiwei Liu245d7912016-07-28 00:04:25 -0700156 }
157
158 Interest interest(Name(m_prefix).appendSegment(segNo));
159 interest.setInterestLifetime(m_options.interestLifetime);
160 interest.setMustBeFresh(m_options.mustBeFresh);
161 interest.setMaxSuffixComponents(1);
162
Junxiao Shi06d008c2019-02-04 08:26:59 +0000163 SegmentInfo& segInfo = m_segmentInfo[segNo];
164 segInfo.interestHdl = m_face.expressInterest(interest,
schneiderklausd8197df2019-03-16 11:31:40 -0700165 bind(&PipelineInterestsAdaptive::handleData, this, _1, _2),
166 bind(&PipelineInterestsAdaptive::handleNack, this, _1, _2),
167 bind(&PipelineInterestsAdaptive::handleLifetimeExpiration, this, _1));
Junxiao Shi06d008c2019-02-04 08:26:59 +0000168 segInfo.timeSent = time::steady_clock::now();
169 segInfo.rto = m_rttEstimator.getEstimatedRto();
170
Weiwei Liu245d7912016-07-28 00:04:25 -0700171 m_nInFlight++;
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -0400172 m_nSent++;
Weiwei Liu245d7912016-07-28 00:04:25 -0700173
174 if (isRetransmission) {
Davide Pesavento958896e2017-01-19 00:52:04 -0500175 segInfo.state = SegmentState::Retransmitted;
Weiwei Liu245d7912016-07-28 00:04:25 -0700176 m_nRetransmitted++;
177 }
178 else {
179 m_highInterest = segNo;
Junxiao Shi06d008c2019-02-04 08:26:59 +0000180 segInfo.state = SegmentState::FirstTimeSent;
Weiwei Liu245d7912016-07-28 00:04:25 -0700181 }
182}
183
184void
schneiderklausd8197df2019-03-16 11:31:40 -0700185PipelineInterestsAdaptive::schedulePackets()
Weiwei Liu245d7912016-07-28 00:04:25 -0700186{
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500187 BOOST_ASSERT(m_nInFlight >= 0);
188 auto availableWindowSize = static_cast<int64_t>(m_cwnd) - m_nInFlight;
189
Weiwei Liu245d7912016-07-28 00:04:25 -0700190 while (availableWindowSize > 0) {
191 if (!m_retxQueue.empty()) { // do retransmission first
192 uint64_t retxSegNo = m_retxQueue.front();
193 m_retxQueue.pop();
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500194 if (m_segmentInfo.count(retxSegNo) == 0) {
schneiderklaus8ff3abd2019-03-12 22:15:12 -0700195 m_nSkippedRetx++;
Weiwei Liu245d7912016-07-28 00:04:25 -0700196 continue;
197 }
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500198 // the segment is still in the map, that means it needs to be retransmitted
Weiwei Liu245d7912016-07-28 00:04:25 -0700199 sendInterest(retxSegNo, true);
200 }
201 else { // send next segment
202 sendInterest(getNextSegmentNo(), false);
203 }
204 availableWindowSize--;
205 }
206}
207
208void
schneiderklausd8197df2019-03-16 11:31:40 -0700209PipelineInterestsAdaptive::handleData(const Interest& interest, const Data& data)
Weiwei Liu245d7912016-07-28 00:04:25 -0700210{
211 if (isStopping())
212 return;
213
214 // Data name will not have extra components because MaxSuffixComponents is set to 1
215 BOOST_ASSERT(data.getName().equals(interest.getName()));
216
Davide Pesavento969cd5a2018-04-20 16:27:47 -0400217 if (!m_hasFinalBlockId && data.getFinalBlock()) {
218 m_lastSegmentNo = data.getFinalBlock()->toSegment();
Weiwei Liu245d7912016-07-28 00:04:25 -0700219 m_hasFinalBlockId = true;
220 cancelInFlightSegmentsGreaterThan(m_lastSegmentNo);
221 if (m_hasFailure && m_lastSegmentNo >= m_failedSegNo) {
222 // previously failed segment is part of the content
223 return onFailure(m_failureReason);
Chavoosh Ghasemi4d36ed52017-10-31 22:26:25 +0000224 }
225 else {
Weiwei Liu245d7912016-07-28 00:04:25 -0700226 m_hasFailure = false;
227 }
228 }
229
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500230 uint64_t recvSegNo = getSegmentFromPacket(data);
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500231 auto segIt = m_segmentInfo.find(recvSegNo);
232 if (segIt == m_segmentInfo.end()) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700233 return; // ignore already-received segment
234 }
235
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500236 SegmentInfo& segInfo = segIt->second;
Weiwei Liu245d7912016-07-28 00:04:25 -0700237 Milliseconds rtt = time::steady_clock::now() - segInfo.timeSent;
Weiwei Liu245d7912016-07-28 00:04:25 -0700238 if (m_options.isVerbose) {
239 std::cerr << "Received segment #" << recvSegNo
240 << ", rtt=" << rtt.count() << "ms"
241 << ", rto=" << segInfo.rto.count() << "ms" << std::endl;
242 }
243
Davide Pesavento958896e2017-01-19 00:52:04 -0500244 if (m_highData < recvSegNo) {
245 m_highData = recvSegNo;
246 }
247
248 // for segments in retx queue, we must not decrement m_nInFlight
249 // because it was already decremented when the segment timed out
250 if (segInfo.state != SegmentState::InRetxQueue) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700251 m_nInFlight--;
252 }
253
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000254 // upon finding congestion mark, decrease the window size
255 // without retransmitting any packet
256 if (data.getCongestionMark() > 0) {
257 m_nCongMarks++;
258 if (!m_options.ignoreCongMarks) {
259 if (m_options.disableCwa || m_highData > m_recPoint) {
260 m_recPoint = m_highInterest; // react to only one congestion event (timeout or congestion mark)
261 // per RTT (conservative window adaptation)
schneiderklaus8ff3abd2019-03-12 22:15:12 -0700262 m_nMarkDecr++;
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000263 decreaseWindow();
264
265 if (m_options.isVerbose) {
266 std::cerr << "Received congestion mark, value = " << data.getCongestionMark()
267 << ", new cwnd = " << m_cwnd << std::endl;
268 }
269 }
270 }
271 else {
272 increaseWindow();
273 }
274 }
275 else {
276 increaseWindow();
277 }
278
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400279 onData(data);
Weiwei Liu245d7912016-07-28 00:04:25 -0700280
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500281 // do not sample RTT for retransmitted segments
282 if ((segInfo.state == SegmentState::FirstTimeSent ||
283 segInfo.state == SegmentState::InRetxQueue) &&
284 m_retxCount.count(recvSegNo) == 0) {
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500285 auto nExpectedSamples = std::max<int64_t>((m_nInFlight + 1) >> 1, 1);
286 BOOST_ASSERT(nExpectedSamples > 0);
287 m_rttEstimator.addMeasurement(recvSegNo, rtt, static_cast<size_t>(nExpectedSamples));
Weiwei Liu245d7912016-07-28 00:04:25 -0700288 }
289
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500290 // remove the entry associated with the received segment
291 m_segmentInfo.erase(segIt);
292
Ryan Wickman034f30f2018-06-06 11:11:11 -0500293 if (allSegmentsReceived()) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700294 cancel();
Davide Pesaventof6991e12018-01-08 20:58:50 -0500295 if (!m_options.isQuiet) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700296 printSummary();
297 }
298 }
299 else {
300 schedulePackets();
301 }
302}
303
304void
schneiderklausd8197df2019-03-16 11:31:40 -0700305PipelineInterestsAdaptive::handleNack(const Interest& interest, const lp::Nack& nack)
Weiwei Liu245d7912016-07-28 00:04:25 -0700306{
307 if (isStopping())
308 return;
309
310 if (m_options.isVerbose)
311 std::cerr << "Received Nack with reason " << nack.getReason()
312 << " for Interest " << interest << std::endl;
313
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500314 uint64_t segNo = getSegmentFromPacket(interest);
Weiwei Liu245d7912016-07-28 00:04:25 -0700315
316 switch (nack.getReason()) {
Davide Pesavento958896e2017-01-19 00:52:04 -0500317 case lp::NackReason::DUPLICATE:
318 // ignore duplicates
Weiwei Liu245d7912016-07-28 00:04:25 -0700319 break;
Davide Pesavento958896e2017-01-19 00:52:04 -0500320 case lp::NackReason::CONGESTION:
321 // treated the same as timeout for now
322 enqueueForRetransmission(segNo);
323 recordTimeout();
324 schedulePackets();
325 break;
326 default:
Weiwei Liu245d7912016-07-28 00:04:25 -0700327 handleFail(segNo, "Could not retrieve data for " + interest.getName().toUri() +
328 ", reason: " + boost::lexical_cast<std::string>(nack.getReason()));
329 break;
Weiwei Liu245d7912016-07-28 00:04:25 -0700330 }
331}
332
333void
schneiderklausd8197df2019-03-16 11:31:40 -0700334PipelineInterestsAdaptive::handleLifetimeExpiration(const Interest& interest)
Weiwei Liu245d7912016-07-28 00:04:25 -0700335{
336 if (isStopping())
337 return;
338
schneiderklaus8ff3abd2019-03-12 22:15:12 -0700339 m_nTimeouts++;
Davide Pesavento958896e2017-01-19 00:52:04 -0500340 enqueueForRetransmission(getSegmentFromPacket(interest));
341 recordTimeout();
342 schedulePackets();
Weiwei Liu245d7912016-07-28 00:04:25 -0700343}
344
345void
schneiderklausd8197df2019-03-16 11:31:40 -0700346PipelineInterestsAdaptive::recordTimeout()
Weiwei Liu245d7912016-07-28 00:04:25 -0700347{
Weiwei Liu245d7912016-07-28 00:04:25 -0700348 if (m_options.disableCwa || m_highData > m_recPoint) {
349 // react to only one timeout per RTT (conservative window adaptation)
350 m_recPoint = m_highInterest;
351
352 decreaseWindow();
353 m_rttEstimator.backoffRto();
schneiderklaus8ff3abd2019-03-12 22:15:12 -0700354 m_nLossDecr++;
Weiwei Liu245d7912016-07-28 00:04:25 -0700355
356 if (m_options.isVerbose) {
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000357 std::cerr << "Packet loss event, new cwnd = " << m_cwnd
Weiwei Liu245d7912016-07-28 00:04:25 -0700358 << ", ssthresh = " << m_ssthresh << std::endl;
359 }
360 }
Davide Pesavento958896e2017-01-19 00:52:04 -0500361}
Weiwei Liu245d7912016-07-28 00:04:25 -0700362
Davide Pesavento958896e2017-01-19 00:52:04 -0500363void
schneiderklausd8197df2019-03-16 11:31:40 -0700364PipelineInterestsAdaptive::enqueueForRetransmission(uint64_t segNo)
Davide Pesavento958896e2017-01-19 00:52:04 -0500365{
366 BOOST_ASSERT(m_nInFlight > 0);
367 m_nInFlight--;
368 m_retxQueue.push(segNo);
369 m_segmentInfo.at(segNo).state = SegmentState::InRetxQueue;
Weiwei Liu245d7912016-07-28 00:04:25 -0700370}
371
372void
schneiderklausd8197df2019-03-16 11:31:40 -0700373PipelineInterestsAdaptive::handleFail(uint64_t segNo, const std::string& reason)
Weiwei Liu245d7912016-07-28 00:04:25 -0700374{
375 if (isStopping())
376 return;
377
378 // if the failed segment is definitely part of the content, raise a fatal error
379 if (m_hasFinalBlockId && segNo <= m_lastSegmentNo)
380 return onFailure(reason);
381
382 if (!m_hasFinalBlockId) {
383 m_segmentInfo.erase(segNo);
Davide Pesavento958896e2017-01-19 00:52:04 -0500384 m_nInFlight--;
Weiwei Liu245d7912016-07-28 00:04:25 -0700385
386 if (m_segmentInfo.empty()) {
387 onFailure("Fetching terminated but no final segment number has been found");
388 }
389 else {
390 cancelInFlightSegmentsGreaterThan(segNo);
391 m_hasFailure = true;
392 m_failedSegNo = segNo;
393 m_failureReason = reason;
394 }
395 }
396}
397
398void
schneiderklausd8197df2019-03-16 11:31:40 -0700399PipelineInterestsAdaptive::cancelInFlightSegmentsGreaterThan(uint64_t segNo)
Weiwei Liu245d7912016-07-28 00:04:25 -0700400{
401 for (auto it = m_segmentInfo.begin(); it != m_segmentInfo.end();) {
402 // cancel fetching all segments that follow
Davide Pesavento958896e2017-01-19 00:52:04 -0500403 if (it->first > segNo) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700404 it = m_segmentInfo.erase(it);
Davide Pesavento958896e2017-01-19 00:52:04 -0500405 m_nInFlight--;
Weiwei Liu245d7912016-07-28 00:04:25 -0700406 }
407 else {
408 ++it;
409 }
410 }
411}
412
413void
schneiderklausd8197df2019-03-16 11:31:40 -0700414PipelineInterestsAdaptive::printSummary() const
Weiwei Liu245d7912016-07-28 00:04:25 -0700415{
Chavoosh Ghasemi4d36ed52017-10-31 22:26:25 +0000416 PipelineInterests::printSummary();
schneiderklaus8ff3abd2019-03-12 22:15:12 -0700417 std::cerr << "Congestion marks: " << m_nCongMarks << " (caused " << m_nMarkDecr << " window decreases)\n"
418 << "Timeouts: " << m_nTimeouts << " (caused " << m_nLossDecr << " window decreases)\n"
419 << "Retransmitted segments: " << m_nRetransmitted
420 << " (" << (m_nSent == 0 ? 0 : (static_cast<double>(m_nRetransmitted) / m_nSent * 100.0)) << "%)"
421 << ", skipped: " << m_nSkippedRetx << "\n"
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -0400422 << "RTT ";
423
424 if (m_rttEstimator.getMinRtt() == std::numeric_limits<double>::max() ||
425 m_rttEstimator.getMaxRtt() == std::numeric_limits<double>::min()) {
426 std::cerr << "stats unavailable\n";
427 }
428 else {
429 std::cerr << "min/avg/max = " << std::fixed << std::setprecision(3)
430 << m_rttEstimator.getMinRtt() << "/"
431 << m_rttEstimator.getAvgRtt() << "/"
432 << m_rttEstimator.getMaxRtt() << " ms\n";
433 }
Weiwei Liu245d7912016-07-28 00:04:25 -0700434}
435
436std::ostream&
437operator<<(std::ostream& os, SegmentState state)
438{
439 switch (state) {
440 case SegmentState::FirstTimeSent:
441 os << "FirstTimeSent";
442 break;
443 case SegmentState::InRetxQueue:
444 os << "InRetxQueue";
445 break;
446 case SegmentState::Retransmitted:
447 os << "Retransmitted";
448 break;
Weiwei Liu245d7912016-07-28 00:04:25 -0700449 }
Weiwei Liu245d7912016-07-28 00:04:25 -0700450 return os;
451}
452
453std::ostream&
schneiderklausd8197df2019-03-16 11:31:40 -0700454operator<<(std::ostream& os, const PipelineInterestsAdaptiveOptions& options)
Weiwei Liu245d7912016-07-28 00:04:25 -0700455{
schneiderklausd8197df2019-03-16 11:31:40 -0700456 os << "Adaptive pipeline parameters:\n"
Weiwei Liu245d7912016-07-28 00:04:25 -0700457 << "\tInitial congestion window size = " << options.initCwnd << "\n"
458 << "\tInitial slow start threshold = " << options.initSsthresh << "\n"
Weiwei Liu245d7912016-07-28 00:04:25 -0700459 << "\tAdditive increase step = " << options.aiStep << "\n"
Davide Pesavento958896e2017-01-19 00:52:04 -0500460 << "\tMultiplicative decrease factor = " << options.mdCoef << "\n"
Weiwei Liu245d7912016-07-28 00:04:25 -0700461 << "\tRTO check interval = " << options.rtoCheckInterval << "\n"
Davide Pesavento44b3b232017-12-23 16:58:25 -0500462 << "\tMax retries on timeout or Nack = " << (options.maxRetriesOnTimeoutOrNack == DataFetcher::MAX_RETRIES_INFINITE ?
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500463 "infinite" : to_string(options.maxRetriesOnTimeoutOrNack)) << "\n"
Klaus Schneider9e5122b2019-03-19 17:03:25 -0700464 << "\tReact to congestion marks = " << (options.ignoreCongMarks ? "no" : "yes") << "\n"
465 << "\tConservative window adaptation = " << (options.disableCwa ? "no" : "yes") << "\n"
466 << "\tResetting window to " << (options.resetCwndToInit ? "initCwnd" : "ssthresh") << " upon loss event\n";
Weiwei Liu245d7912016-07-28 00:04:25 -0700467 return os;
468}
469
Weiwei Liu245d7912016-07-28 00:04:25 -0700470} // namespace chunks
471} // namespace ndn