blob: eea122e4f83f24bb1dd19df94f493ed38dc42c55 [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
Weiwei Liu245d7912016-07-28 00:04:25 -070026 */
27
28#include "pipeline-interests-aimd.hpp"
Davide Pesavento44b3b232017-12-23 16:58:25 -050029#include "data-fetcher.hpp"
Weiwei Liu245d7912016-07-28 00:04:25 -070030
31#include <cmath>
Chavoosh Ghasemi3dae1092017-12-21 12:39:08 -070032#include <iomanip>
Weiwei Liu245d7912016-07-28 00:04:25 -070033
34namespace ndn {
35namespace chunks {
36namespace aimd {
37
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +000038constexpr double PipelineInterestsAimd::MIN_SSTHRESH;
39
Weiwei Liu245d7912016-07-28 00:04:25 -070040PipelineInterestsAimd::PipelineInterestsAimd(Face& face, RttEstimator& rttEstimator,
41 const Options& options)
42 : PipelineInterests(face)
43 , m_options(options)
44 , m_rttEstimator(rttEstimator)
45 , m_scheduler(m_face.getIoService())
Weiwei Liu245d7912016-07-28 00:04:25 -070046 , m_highData(0)
47 , m_highInterest(0)
48 , m_recPoint(0)
49 , m_nInFlight(0)
Weiwei Liu245d7912016-07-28 00:04:25 -070050 , m_nLossEvents(0)
51 , m_nRetransmitted(0)
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +000052 , m_nCongMarks(0)
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -040053 , m_nSent(0)
Weiwei Liu245d7912016-07-28 00:04:25 -070054 , m_cwnd(m_options.initCwnd)
55 , m_ssthresh(m_options.initSsthresh)
56 , m_hasFailure(false)
57 , m_failedSegNo(0)
58{
59 if (m_options.isVerbose) {
60 std::cerr << m_options;
61 }
62}
63
64PipelineInterestsAimd::~PipelineInterestsAimd()
65{
66 cancel();
67}
68
69void
70PipelineInterestsAimd::doRun()
71{
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 Pesaventocd65c2c2017-01-15 16:10:38 -050081 m_checkRtoEvent = m_scheduler.scheduleEvent(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
87PipelineInterestsAimd::doCancel()
88{
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
94PipelineInterestsAimd::checkRto()
95{
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?
Davide Pesavento958896e2017-01-19 00:52:04 -0500106 hasTimeout = true;
107 enqueueForRetransmission(entry.first);
Weiwei Liu245d7912016-07-28 00:04:25 -0700108 }
109 }
110 }
111
Davide Pesavento958896e2017-01-19 00:52:04 -0500112 if (hasTimeout) {
113 recordTimeout();
114 schedulePackets();
Weiwei Liu245d7912016-07-28 00:04:25 -0700115 }
116
117 // schedule the next check after predefined interval
Davide Pesaventocd65c2c2017-01-15 16:10:38 -0500118 m_checkRtoEvent = m_scheduler.scheduleEvent(m_options.rtoCheckInterval, [this] { checkRto(); });
Weiwei Liu245d7912016-07-28 00:04:25 -0700119}
120
121void
122PipelineInterestsAimd::sendInterest(uint64_t segNo, bool isRetransmission)
123{
124 if (isStopping())
125 return;
126
Ryan Wickman034f30f2018-06-06 11:11:11 -0500127 if (m_hasFinalBlockId && segNo > m_lastSegmentNo)
Weiwei Liu245d7912016-07-28 00:04:25 -0700128 return;
129
130 if (!isRetransmission && m_hasFailure)
131 return;
132
133 if (m_options.isVerbose) {
Davide Pesavento958896e2017-01-19 00:52:04 -0500134 std::cerr << (isRetransmission ? "Retransmitting" : "Requesting")
135 << " segment #" << segNo << std::endl;
Weiwei Liu245d7912016-07-28 00:04:25 -0700136 }
137
138 if (isRetransmission) {
Davide Pesavento958896e2017-01-19 00:52:04 -0500139 // keep track of retx count for this segment
140 auto ret = m_retxCount.emplace(segNo, 1);
Weiwei Liu245d7912016-07-28 00:04:25 -0700141 if (ret.second == false) { // not the first retransmission
142 m_retxCount[segNo] += 1;
Davide Pesavento44b3b232017-12-23 16:58:25 -0500143 if (m_options.maxRetriesOnTimeoutOrNack != DataFetcher::MAX_RETRIES_INFINITE &&
144 m_retxCount[segNo] > m_options.maxRetriesOnTimeoutOrNack) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700145 return handleFail(segNo, "Reached the maximum number of retries (" +
146 to_string(m_options.maxRetriesOnTimeoutOrNack) +
147 ") while retrieving segment #" + to_string(segNo));
148 }
149
150 if (m_options.isVerbose) {
151 std::cerr << "# of retries for segment #" << segNo
152 << " is " << m_retxCount[segNo] << std::endl;
153 }
154 }
Weiwei Liu245d7912016-07-28 00:04:25 -0700155 }
156
157 Interest interest(Name(m_prefix).appendSegment(segNo));
158 interest.setInterestLifetime(m_options.interestLifetime);
159 interest.setMustBeFresh(m_options.mustBeFresh);
160 interest.setMaxSuffixComponents(1);
161
Junxiao Shi06d008c2019-02-04 08:26:59 +0000162 SegmentInfo& segInfo = m_segmentInfo[segNo];
163 segInfo.interestHdl = m_face.expressInterest(interest,
164 bind(&PipelineInterestsAimd::handleData, this, _1, _2),
165 bind(&PipelineInterestsAimd::handleNack, this, _1, _2),
166 bind(&PipelineInterestsAimd::handleLifetimeExpiration, this, _1));
167 segInfo.timeSent = time::steady_clock::now();
168 segInfo.rto = m_rttEstimator.getEstimatedRto();
169
Weiwei Liu245d7912016-07-28 00:04:25 -0700170 m_nInFlight++;
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -0400171 m_nSent++;
Weiwei Liu245d7912016-07-28 00:04:25 -0700172
173 if (isRetransmission) {
Davide Pesavento958896e2017-01-19 00:52:04 -0500174 segInfo.state = SegmentState::Retransmitted;
Weiwei Liu245d7912016-07-28 00:04:25 -0700175 m_nRetransmitted++;
176 }
177 else {
178 m_highInterest = segNo;
Junxiao Shi06d008c2019-02-04 08:26:59 +0000179 segInfo.state = SegmentState::FirstTimeSent;
Weiwei Liu245d7912016-07-28 00:04:25 -0700180 }
181}
182
183void
184PipelineInterestsAimd::schedulePackets()
185{
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500186 BOOST_ASSERT(m_nInFlight >= 0);
187 auto availableWindowSize = static_cast<int64_t>(m_cwnd) - m_nInFlight;
188
Weiwei Liu245d7912016-07-28 00:04:25 -0700189 while (availableWindowSize > 0) {
190 if (!m_retxQueue.empty()) { // do retransmission first
191 uint64_t retxSegNo = m_retxQueue.front();
192 m_retxQueue.pop();
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500193 if (m_segmentInfo.count(retxSegNo) == 0) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700194 continue;
195 }
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500196 // the segment is still in the map, that means it needs to be retransmitted
Weiwei Liu245d7912016-07-28 00:04:25 -0700197 sendInterest(retxSegNo, true);
198 }
199 else { // send next segment
200 sendInterest(getNextSegmentNo(), false);
201 }
202 availableWindowSize--;
203 }
204}
205
206void
207PipelineInterestsAimd::handleData(const Interest& interest, const Data& data)
208{
209 if (isStopping())
210 return;
211
212 // Data name will not have extra components because MaxSuffixComponents is set to 1
213 BOOST_ASSERT(data.getName().equals(interest.getName()));
214
Davide Pesavento969cd5a2018-04-20 16:27:47 -0400215 if (!m_hasFinalBlockId && data.getFinalBlock()) {
216 m_lastSegmentNo = data.getFinalBlock()->toSegment();
Weiwei Liu245d7912016-07-28 00:04:25 -0700217 m_hasFinalBlockId = true;
218 cancelInFlightSegmentsGreaterThan(m_lastSegmentNo);
219 if (m_hasFailure && m_lastSegmentNo >= m_failedSegNo) {
220 // previously failed segment is part of the content
221 return onFailure(m_failureReason);
Chavoosh Ghasemi4d36ed52017-10-31 22:26:25 +0000222 }
223 else {
Weiwei Liu245d7912016-07-28 00:04:25 -0700224 m_hasFailure = false;
225 }
226 }
227
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500228 uint64_t recvSegNo = getSegmentFromPacket(data);
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500229 auto segIt = m_segmentInfo.find(recvSegNo);
230 if (segIt == m_segmentInfo.end()) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700231 return; // ignore already-received segment
232 }
233
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500234 SegmentInfo& segInfo = segIt->second;
Weiwei Liu245d7912016-07-28 00:04:25 -0700235 Milliseconds rtt = time::steady_clock::now() - segInfo.timeSent;
Weiwei Liu245d7912016-07-28 00:04:25 -0700236 if (m_options.isVerbose) {
237 std::cerr << "Received segment #" << recvSegNo
238 << ", rtt=" << rtt.count() << "ms"
239 << ", rto=" << segInfo.rto.count() << "ms" << std::endl;
240 }
241
Davide Pesavento958896e2017-01-19 00:52:04 -0500242 if (m_highData < recvSegNo) {
243 m_highData = recvSegNo;
244 }
245
246 // for segments in retx queue, we must not decrement m_nInFlight
247 // because it was already decremented when the segment timed out
248 if (segInfo.state != SegmentState::InRetxQueue) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700249 m_nInFlight--;
250 }
251
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000252 // upon finding congestion mark, decrease the window size
253 // without retransmitting any packet
254 if (data.getCongestionMark() > 0) {
255 m_nCongMarks++;
256 if (!m_options.ignoreCongMarks) {
257 if (m_options.disableCwa || m_highData > m_recPoint) {
258 m_recPoint = m_highInterest; // react to only one congestion event (timeout or congestion mark)
259 // per RTT (conservative window adaptation)
260 decreaseWindow();
261
262 if (m_options.isVerbose) {
263 std::cerr << "Received congestion mark, value = " << data.getCongestionMark()
264 << ", new cwnd = " << m_cwnd << std::endl;
265 }
266 }
267 }
268 else {
269 increaseWindow();
270 }
271 }
272 else {
273 increaseWindow();
274 }
275
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400276 onData(data);
Weiwei Liu245d7912016-07-28 00:04:25 -0700277
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500278 // do not sample RTT for retransmitted segments
279 if ((segInfo.state == SegmentState::FirstTimeSent ||
280 segInfo.state == SegmentState::InRetxQueue) &&
281 m_retxCount.count(recvSegNo) == 0) {
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500282 auto nExpectedSamples = std::max<int64_t>((m_nInFlight + 1) >> 1, 1);
283 BOOST_ASSERT(nExpectedSamples > 0);
284 m_rttEstimator.addMeasurement(recvSegNo, rtt, static_cast<size_t>(nExpectedSamples));
Weiwei Liu245d7912016-07-28 00:04:25 -0700285 }
286
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500287 // remove the entry associated with the received segment
288 m_segmentInfo.erase(segIt);
289
Ryan Wickman034f30f2018-06-06 11:11:11 -0500290 if (allSegmentsReceived()) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700291 cancel();
Davide Pesaventof6991e12018-01-08 20:58:50 -0500292 if (!m_options.isQuiet) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700293 printSummary();
294 }
295 }
296 else {
297 schedulePackets();
298 }
299}
300
301void
302PipelineInterestsAimd::handleNack(const Interest& interest, const lp::Nack& nack)
303{
304 if (isStopping())
305 return;
306
307 if (m_options.isVerbose)
308 std::cerr << "Received Nack with reason " << nack.getReason()
309 << " for Interest " << interest << std::endl;
310
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500311 uint64_t segNo = getSegmentFromPacket(interest);
Weiwei Liu245d7912016-07-28 00:04:25 -0700312
313 switch (nack.getReason()) {
Davide Pesavento958896e2017-01-19 00:52:04 -0500314 case lp::NackReason::DUPLICATE:
315 // ignore duplicates
Weiwei Liu245d7912016-07-28 00:04:25 -0700316 break;
Davide Pesavento958896e2017-01-19 00:52:04 -0500317 case lp::NackReason::CONGESTION:
318 // treated the same as timeout for now
319 enqueueForRetransmission(segNo);
320 recordTimeout();
321 schedulePackets();
322 break;
323 default:
Weiwei Liu245d7912016-07-28 00:04:25 -0700324 handleFail(segNo, "Could not retrieve data for " + interest.getName().toUri() +
325 ", reason: " + boost::lexical_cast<std::string>(nack.getReason()));
326 break;
Weiwei Liu245d7912016-07-28 00:04:25 -0700327 }
328}
329
330void
331PipelineInterestsAimd::handleLifetimeExpiration(const Interest& interest)
332{
333 if (isStopping())
334 return;
335
Davide Pesavento958896e2017-01-19 00:52:04 -0500336 enqueueForRetransmission(getSegmentFromPacket(interest));
337 recordTimeout();
338 schedulePackets();
Weiwei Liu245d7912016-07-28 00:04:25 -0700339}
340
341void
Davide Pesavento958896e2017-01-19 00:52:04 -0500342PipelineInterestsAimd::recordTimeout()
Weiwei Liu245d7912016-07-28 00:04:25 -0700343{
Weiwei Liu245d7912016-07-28 00:04:25 -0700344 if (m_options.disableCwa || m_highData > m_recPoint) {
345 // react to only one timeout per RTT (conservative window adaptation)
346 m_recPoint = m_highInterest;
347
348 decreaseWindow();
349 m_rttEstimator.backoffRto();
350 m_nLossEvents++;
351
352 if (m_options.isVerbose) {
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000353 std::cerr << "Packet loss event, new cwnd = " << m_cwnd
Weiwei Liu245d7912016-07-28 00:04:25 -0700354 << ", ssthresh = " << m_ssthresh << std::endl;
355 }
356 }
Davide Pesavento958896e2017-01-19 00:52:04 -0500357}
Weiwei Liu245d7912016-07-28 00:04:25 -0700358
Davide Pesavento958896e2017-01-19 00:52:04 -0500359void
360PipelineInterestsAimd::enqueueForRetransmission(uint64_t segNo)
361{
362 BOOST_ASSERT(m_nInFlight > 0);
363 m_nInFlight--;
364 m_retxQueue.push(segNo);
365 m_segmentInfo.at(segNo).state = SegmentState::InRetxQueue;
Weiwei Liu245d7912016-07-28 00:04:25 -0700366}
367
368void
369PipelineInterestsAimd::handleFail(uint64_t segNo, const std::string& reason)
370{
371 if (isStopping())
372 return;
373
374 // if the failed segment is definitely part of the content, raise a fatal error
375 if (m_hasFinalBlockId && segNo <= m_lastSegmentNo)
376 return onFailure(reason);
377
378 if (!m_hasFinalBlockId) {
379 m_segmentInfo.erase(segNo);
Davide Pesavento958896e2017-01-19 00:52:04 -0500380 m_nInFlight--;
Weiwei Liu245d7912016-07-28 00:04:25 -0700381
382 if (m_segmentInfo.empty()) {
383 onFailure("Fetching terminated but no final segment number has been found");
384 }
385 else {
386 cancelInFlightSegmentsGreaterThan(segNo);
387 m_hasFailure = true;
388 m_failedSegNo = segNo;
389 m_failureReason = reason;
390 }
391 }
392}
393
394void
395PipelineInterestsAimd::increaseWindow()
396{
397 if (m_cwnd < m_ssthresh) {
398 m_cwnd += m_options.aiStep; // additive increase
Chavoosh Ghasemi4d36ed52017-10-31 22:26:25 +0000399 }
400 else {
Weiwei Liu245d7912016-07-28 00:04:25 -0700401 m_cwnd += m_options.aiStep / std::floor(m_cwnd); // congestion avoidance
402 }
Davide Pesavento958896e2017-01-19 00:52:04 -0500403
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500404 afterCwndChange(time::steady_clock::now() - getStartTime(), m_cwnd);
Weiwei Liu245d7912016-07-28 00:04:25 -0700405}
406
407void
408PipelineInterestsAimd::decreaseWindow()
409{
410 // please refer to RFC 5681, Section 3.1 for the rationale behind it
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000411 m_ssthresh = std::max(MIN_SSTHRESH, m_cwnd * m_options.mdCoef); // multiplicative decrease
Weiwei Liu245d7912016-07-28 00:04:25 -0700412 m_cwnd = m_options.resetCwndToInit ? m_options.initCwnd : m_ssthresh;
Davide Pesavento958896e2017-01-19 00:52:04 -0500413
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500414 afterCwndChange(time::steady_clock::now() - getStartTime(), m_cwnd);
Weiwei Liu245d7912016-07-28 00:04:25 -0700415}
416
Weiwei Liu245d7912016-07-28 00:04:25 -0700417void
Davide Pesavento958896e2017-01-19 00:52:04 -0500418PipelineInterestsAimd::cancelInFlightSegmentsGreaterThan(uint64_t segNo)
Weiwei Liu245d7912016-07-28 00:04:25 -0700419{
420 for (auto it = m_segmentInfo.begin(); it != m_segmentInfo.end();) {
421 // cancel fetching all segments that follow
Davide Pesavento958896e2017-01-19 00:52:04 -0500422 if (it->first > segNo) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700423 it = m_segmentInfo.erase(it);
Davide Pesavento958896e2017-01-19 00:52:04 -0500424 m_nInFlight--;
Weiwei Liu245d7912016-07-28 00:04:25 -0700425 }
426 else {
427 ++it;
428 }
429 }
430}
431
432void
433PipelineInterestsAimd::printSummary() const
434{
Chavoosh Ghasemi4d36ed52017-10-31 22:26:25 +0000435 PipelineInterests::printSummary();
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -0400436 std::cerr << "Total # of lost/retransmitted segments: " << m_nRetransmitted
437 << " (caused " << m_nLossEvents << " window decreases)\n"
Weiwei Liu245d7912016-07-28 00:04:25 -0700438 << "Packet loss rate: "
Ryan Wickman034f30f2018-06-06 11:11:11 -0500439 << (m_nSent == 0 ? 0 : (static_cast<double>(m_nRetransmitted) / static_cast<double>(m_nSent) * 100)) << "%\n"
Chavoosh Ghasemi3dae1092017-12-21 12:39:08 -0700440 << "Total # of received congestion marks: " << m_nCongMarks << "\n"
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -0400441 << "RTT ";
442
443 if (m_rttEstimator.getMinRtt() == std::numeric_limits<double>::max() ||
444 m_rttEstimator.getMaxRtt() == std::numeric_limits<double>::min()) {
445 std::cerr << "stats unavailable\n";
446 }
447 else {
448 std::cerr << "min/avg/max = " << std::fixed << std::setprecision(3)
449 << m_rttEstimator.getMinRtt() << "/"
450 << m_rttEstimator.getAvgRtt() << "/"
451 << m_rttEstimator.getMaxRtt() << " ms\n";
452 }
Weiwei Liu245d7912016-07-28 00:04:25 -0700453}
454
455std::ostream&
456operator<<(std::ostream& os, SegmentState state)
457{
458 switch (state) {
459 case SegmentState::FirstTimeSent:
460 os << "FirstTimeSent";
461 break;
462 case SegmentState::InRetxQueue:
463 os << "InRetxQueue";
464 break;
465 case SegmentState::Retransmitted:
466 os << "Retransmitted";
467 break;
Weiwei Liu245d7912016-07-28 00:04:25 -0700468 }
Weiwei Liu245d7912016-07-28 00:04:25 -0700469 return os;
470}
471
472std::ostream&
473operator<<(std::ostream& os, const PipelineInterestsAimdOptions& options)
474{
Davide Pesavento44b3b232017-12-23 16:58:25 -0500475 os << "AIMD pipeline parameters:\n"
Weiwei Liu245d7912016-07-28 00:04:25 -0700476 << "\tInitial congestion window size = " << options.initCwnd << "\n"
477 << "\tInitial slow start threshold = " << options.initSsthresh << "\n"
Weiwei Liu245d7912016-07-28 00:04:25 -0700478 << "\tAdditive increase step = " << options.aiStep << "\n"
Davide Pesavento958896e2017-01-19 00:52:04 -0500479 << "\tMultiplicative decrease factor = " << options.mdCoef << "\n"
Weiwei Liu245d7912016-07-28 00:04:25 -0700480 << "\tRTO check interval = " << options.rtoCheckInterval << "\n"
Davide Pesavento44b3b232017-12-23 16:58:25 -0500481 << "\tMax retries on timeout or Nack = " << (options.maxRetriesOnTimeoutOrNack == DataFetcher::MAX_RETRIES_INFINITE ?
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500482 "infinite" : to_string(options.maxRetriesOnTimeoutOrNack)) << "\n"
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000483 << "\tReaction to congestion marks " << (options.ignoreCongMarks ? "disabled" : "enabled") << "\n"
Davide Pesavento44b3b232017-12-23 16:58:25 -0500484 << "\tConservative window adaptation " << (options.disableCwa ? "disabled" : "enabled") << "\n"
Davide Pesavento958896e2017-01-19 00:52:04 -0500485 << "\tResetting cwnd to " << (options.resetCwndToInit ? "initCwnd" : "ssthresh") << " upon loss event\n";
Weiwei Liu245d7912016-07-28 00:04:25 -0700486 return os;
487}
488
489} // namespace aimd
490} // namespace chunks
491} // namespace ndn