blob: 73e22c53958c1a76e8bec72deb5dbb888da9afb9 [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{
89 for (const auto& entry : m_segmentInfo) {
Davide Pesaventocd65c2c2017-01-15 16:10:38 -050090 m_face.removePendingInterest(entry.second.interestId);
Weiwei Liu245d7912016-07-28 00:04:25 -070091 }
Davide Pesaventocd65c2c2017-01-15 16:10:38 -050092 m_checkRtoEvent.cancel();
Weiwei Liu245d7912016-07-28 00:04:25 -070093 m_segmentInfo.clear();
Weiwei Liu245d7912016-07-28 00:04:25 -070094}
95
96void
97PipelineInterestsAimd::checkRto()
98{
99 if (isStopping())
100 return;
101
Davide Pesavento958896e2017-01-19 00:52:04 -0500102 bool hasTimeout = false;
Weiwei Liu245d7912016-07-28 00:04:25 -0700103
104 for (auto& entry : m_segmentInfo) {
105 SegmentInfo& segInfo = entry.second;
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500106 if (segInfo.state != SegmentState::InRetxQueue) { // skip segments already in the retx queue
Weiwei Liu245d7912016-07-28 00:04:25 -0700107 Milliseconds timeElapsed = time::steady_clock::now() - segInfo.timeSent;
108 if (timeElapsed.count() > segInfo.rto.count()) { // timer expired?
Davide Pesavento958896e2017-01-19 00:52:04 -0500109 hasTimeout = true;
110 enqueueForRetransmission(entry.first);
Weiwei Liu245d7912016-07-28 00:04:25 -0700111 }
112 }
113 }
114
Davide Pesavento958896e2017-01-19 00:52:04 -0500115 if (hasTimeout) {
116 recordTimeout();
117 schedulePackets();
Weiwei Liu245d7912016-07-28 00:04:25 -0700118 }
119
120 // schedule the next check after predefined interval
Davide Pesaventocd65c2c2017-01-15 16:10:38 -0500121 m_checkRtoEvent = m_scheduler.scheduleEvent(m_options.rtoCheckInterval, [this] { checkRto(); });
Weiwei Liu245d7912016-07-28 00:04:25 -0700122}
123
124void
125PipelineInterestsAimd::sendInterest(uint64_t segNo, bool isRetransmission)
126{
127 if (isStopping())
128 return;
129
Ryan Wickman034f30f2018-06-06 11:11:11 -0500130 if (m_hasFinalBlockId && segNo > m_lastSegmentNo)
Weiwei Liu245d7912016-07-28 00:04:25 -0700131 return;
132
133 if (!isRetransmission && m_hasFailure)
134 return;
135
136 if (m_options.isVerbose) {
Davide Pesavento958896e2017-01-19 00:52:04 -0500137 std::cerr << (isRetransmission ? "Retransmitting" : "Requesting")
138 << " segment #" << segNo << std::endl;
Weiwei Liu245d7912016-07-28 00:04:25 -0700139 }
140
141 if (isRetransmission) {
Davide Pesavento958896e2017-01-19 00:52:04 -0500142 // keep track of retx count for this segment
143 auto ret = m_retxCount.emplace(segNo, 1);
Weiwei Liu245d7912016-07-28 00:04:25 -0700144 if (ret.second == false) { // not the first retransmission
145 m_retxCount[segNo] += 1;
Davide Pesavento44b3b232017-12-23 16:58:25 -0500146 if (m_options.maxRetriesOnTimeoutOrNack != DataFetcher::MAX_RETRIES_INFINITE &&
147 m_retxCount[segNo] > m_options.maxRetriesOnTimeoutOrNack) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700148 return handleFail(segNo, "Reached the maximum number of retries (" +
149 to_string(m_options.maxRetriesOnTimeoutOrNack) +
150 ") while retrieving segment #" + to_string(segNo));
151 }
152
153 if (m_options.isVerbose) {
154 std::cerr << "# of retries for segment #" << segNo
155 << " is " << m_retxCount[segNo] << std::endl;
156 }
157 }
158
159 m_face.removePendingInterest(m_segmentInfo[segNo].interestId);
160 }
161
162 Interest interest(Name(m_prefix).appendSegment(segNo));
163 interest.setInterestLifetime(m_options.interestLifetime);
164 interest.setMustBeFresh(m_options.mustBeFresh);
165 interest.setMaxSuffixComponents(1);
166
167 auto interestId = m_face.expressInterest(interest,
168 bind(&PipelineInterestsAimd::handleData, this, _1, _2),
169 bind(&PipelineInterestsAimd::handleNack, this, _1, _2),
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400170 bind(&PipelineInterestsAimd::handleLifetimeExpiration, this, _1));
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) {
175 SegmentInfo& segInfo = m_segmentInfo[segNo];
Weiwei Liu245d7912016-07-28 00:04:25 -0700176 segInfo.timeSent = time::steady_clock::now();
Davide Pesavento958896e2017-01-19 00:52:04 -0500177 segInfo.rto = m_rttEstimator.getEstimatedRto();
178 segInfo.state = SegmentState::Retransmitted;
Weiwei Liu245d7912016-07-28 00:04:25 -0700179 m_nRetransmitted++;
180 }
181 else {
182 m_highInterest = segNo;
Davide Pesavento958896e2017-01-19 00:52:04 -0500183 m_segmentInfo[segNo] = {interestId,
184 time::steady_clock::now(),
185 m_rttEstimator.getEstimatedRto(),
186 SegmentState::FirstTimeSent};
Weiwei Liu245d7912016-07-28 00:04:25 -0700187 }
188}
189
190void
191PipelineInterestsAimd::schedulePackets()
192{
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500193 BOOST_ASSERT(m_nInFlight >= 0);
194 auto availableWindowSize = static_cast<int64_t>(m_cwnd) - m_nInFlight;
195
Weiwei Liu245d7912016-07-28 00:04:25 -0700196 while (availableWindowSize > 0) {
197 if (!m_retxQueue.empty()) { // do retransmission first
198 uint64_t retxSegNo = m_retxQueue.front();
199 m_retxQueue.pop();
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500200 if (m_segmentInfo.count(retxSegNo) == 0) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700201 continue;
202 }
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500203 // the segment is still in the map, that means it needs to be retransmitted
Weiwei Liu245d7912016-07-28 00:04:25 -0700204 sendInterest(retxSegNo, true);
205 }
206 else { // send next segment
207 sendInterest(getNextSegmentNo(), false);
208 }
209 availableWindowSize--;
210 }
211}
212
213void
214PipelineInterestsAimd::handleData(const Interest& interest, const Data& data)
215{
216 if (isStopping())
217 return;
218
219 // Data name will not have extra components because MaxSuffixComponents is set to 1
220 BOOST_ASSERT(data.getName().equals(interest.getName()));
221
Davide Pesavento969cd5a2018-04-20 16:27:47 -0400222 if (!m_hasFinalBlockId && data.getFinalBlock()) {
223 m_lastSegmentNo = data.getFinalBlock()->toSegment();
Weiwei Liu245d7912016-07-28 00:04:25 -0700224 m_hasFinalBlockId = true;
225 cancelInFlightSegmentsGreaterThan(m_lastSegmentNo);
226 if (m_hasFailure && m_lastSegmentNo >= m_failedSegNo) {
227 // previously failed segment is part of the content
228 return onFailure(m_failureReason);
Chavoosh Ghasemi4d36ed52017-10-31 22:26:25 +0000229 }
230 else {
Weiwei Liu245d7912016-07-28 00:04:25 -0700231 m_hasFailure = false;
232 }
233 }
234
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500235 uint64_t recvSegNo = getSegmentFromPacket(data);
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500236 auto segIt = m_segmentInfo.find(recvSegNo);
237 if (segIt == m_segmentInfo.end()) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700238 return; // ignore already-received segment
239 }
240
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500241 SegmentInfo& segInfo = segIt->second;
Weiwei Liu245d7912016-07-28 00:04:25 -0700242 Milliseconds rtt = time::steady_clock::now() - segInfo.timeSent;
Weiwei Liu245d7912016-07-28 00:04:25 -0700243 if (m_options.isVerbose) {
244 std::cerr << "Received segment #" << recvSegNo
245 << ", rtt=" << rtt.count() << "ms"
246 << ", rto=" << segInfo.rto.count() << "ms" << std::endl;
247 }
248
Davide Pesavento958896e2017-01-19 00:52:04 -0500249 if (m_highData < recvSegNo) {
250 m_highData = recvSegNo;
251 }
252
253 // for segments in retx queue, we must not decrement m_nInFlight
254 // because it was already decremented when the segment timed out
255 if (segInfo.state != SegmentState::InRetxQueue) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700256 m_nInFlight--;
257 }
258
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000259 // upon finding congestion mark, decrease the window size
260 // without retransmitting any packet
261 if (data.getCongestionMark() > 0) {
262 m_nCongMarks++;
263 if (!m_options.ignoreCongMarks) {
264 if (m_options.disableCwa || m_highData > m_recPoint) {
265 m_recPoint = m_highInterest; // react to only one congestion event (timeout or congestion mark)
266 // per RTT (conservative window adaptation)
267 decreaseWindow();
268
269 if (m_options.isVerbose) {
270 std::cerr << "Received congestion mark, value = " << data.getCongestionMark()
271 << ", new cwnd = " << m_cwnd << std::endl;
272 }
273 }
274 }
275 else {
276 increaseWindow();
277 }
278 }
279 else {
280 increaseWindow();
281 }
282
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400283 onData(data);
Weiwei Liu245d7912016-07-28 00:04:25 -0700284
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500285 // do not sample RTT for retransmitted segments
286 if ((segInfo.state == SegmentState::FirstTimeSent ||
287 segInfo.state == SegmentState::InRetxQueue) &&
288 m_retxCount.count(recvSegNo) == 0) {
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500289 auto nExpectedSamples = std::max<int64_t>((m_nInFlight + 1) >> 1, 1);
290 BOOST_ASSERT(nExpectedSamples > 0);
291 m_rttEstimator.addMeasurement(recvSegNo, rtt, static_cast<size_t>(nExpectedSamples));
Weiwei Liu245d7912016-07-28 00:04:25 -0700292 }
293
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500294 // remove the entry associated with the received segment
295 m_segmentInfo.erase(segIt);
296
Ryan Wickman034f30f2018-06-06 11:11:11 -0500297 if (allSegmentsReceived()) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700298 cancel();
Davide Pesaventof6991e12018-01-08 20:58:50 -0500299 if (!m_options.isQuiet) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700300 printSummary();
301 }
302 }
303 else {
304 schedulePackets();
305 }
306}
307
308void
309PipelineInterestsAimd::handleNack(const Interest& interest, const lp::Nack& nack)
310{
311 if (isStopping())
312 return;
313
314 if (m_options.isVerbose)
315 std::cerr << "Received Nack with reason " << nack.getReason()
316 << " for Interest " << interest << std::endl;
317
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500318 uint64_t segNo = getSegmentFromPacket(interest);
Weiwei Liu245d7912016-07-28 00:04:25 -0700319
320 switch (nack.getReason()) {
Davide Pesavento958896e2017-01-19 00:52:04 -0500321 case lp::NackReason::DUPLICATE:
322 // ignore duplicates
Weiwei Liu245d7912016-07-28 00:04:25 -0700323 break;
Davide Pesavento958896e2017-01-19 00:52:04 -0500324 case lp::NackReason::CONGESTION:
325 // treated the same as timeout for now
326 enqueueForRetransmission(segNo);
327 recordTimeout();
328 schedulePackets();
329 break;
330 default:
Weiwei Liu245d7912016-07-28 00:04:25 -0700331 handleFail(segNo, "Could not retrieve data for " + interest.getName().toUri() +
332 ", reason: " + boost::lexical_cast<std::string>(nack.getReason()));
333 break;
Weiwei Liu245d7912016-07-28 00:04:25 -0700334 }
335}
336
337void
338PipelineInterestsAimd::handleLifetimeExpiration(const Interest& interest)
339{
340 if (isStopping())
341 return;
342
Davide Pesavento958896e2017-01-19 00:52:04 -0500343 enqueueForRetransmission(getSegmentFromPacket(interest));
344 recordTimeout();
345 schedulePackets();
Weiwei Liu245d7912016-07-28 00:04:25 -0700346}
347
348void
Davide Pesavento958896e2017-01-19 00:52:04 -0500349PipelineInterestsAimd::recordTimeout()
Weiwei Liu245d7912016-07-28 00:04:25 -0700350{
Weiwei Liu245d7912016-07-28 00:04:25 -0700351 if (m_options.disableCwa || m_highData > m_recPoint) {
352 // react to only one timeout per RTT (conservative window adaptation)
353 m_recPoint = m_highInterest;
354
355 decreaseWindow();
356 m_rttEstimator.backoffRto();
357 m_nLossEvents++;
358
359 if (m_options.isVerbose) {
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000360 std::cerr << "Packet loss event, new cwnd = " << m_cwnd
Weiwei Liu245d7912016-07-28 00:04:25 -0700361 << ", ssthresh = " << m_ssthresh << std::endl;
362 }
363 }
Davide Pesavento958896e2017-01-19 00:52:04 -0500364}
Weiwei Liu245d7912016-07-28 00:04:25 -0700365
Davide Pesavento958896e2017-01-19 00:52:04 -0500366void
367PipelineInterestsAimd::enqueueForRetransmission(uint64_t segNo)
368{
369 BOOST_ASSERT(m_nInFlight > 0);
370 m_nInFlight--;
371 m_retxQueue.push(segNo);
372 m_segmentInfo.at(segNo).state = SegmentState::InRetxQueue;
Weiwei Liu245d7912016-07-28 00:04:25 -0700373}
374
375void
376PipelineInterestsAimd::handleFail(uint64_t segNo, const std::string& reason)
377{
378 if (isStopping())
379 return;
380
381 // if the failed segment is definitely part of the content, raise a fatal error
382 if (m_hasFinalBlockId && segNo <= m_lastSegmentNo)
383 return onFailure(reason);
384
385 if (!m_hasFinalBlockId) {
386 m_segmentInfo.erase(segNo);
Davide Pesavento958896e2017-01-19 00:52:04 -0500387 m_nInFlight--;
Weiwei Liu245d7912016-07-28 00:04:25 -0700388
389 if (m_segmentInfo.empty()) {
390 onFailure("Fetching terminated but no final segment number has been found");
391 }
392 else {
393 cancelInFlightSegmentsGreaterThan(segNo);
394 m_hasFailure = true;
395 m_failedSegNo = segNo;
396 m_failureReason = reason;
397 }
398 }
399}
400
401void
402PipelineInterestsAimd::increaseWindow()
403{
404 if (m_cwnd < m_ssthresh) {
405 m_cwnd += m_options.aiStep; // additive increase
Chavoosh Ghasemi4d36ed52017-10-31 22:26:25 +0000406 }
407 else {
Weiwei Liu245d7912016-07-28 00:04:25 -0700408 m_cwnd += m_options.aiStep / std::floor(m_cwnd); // congestion avoidance
409 }
Davide Pesavento958896e2017-01-19 00:52:04 -0500410
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500411 afterCwndChange(time::steady_clock::now() - getStartTime(), m_cwnd);
Weiwei Liu245d7912016-07-28 00:04:25 -0700412}
413
414void
415PipelineInterestsAimd::decreaseWindow()
416{
417 // please refer to RFC 5681, Section 3.1 for the rationale behind it
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000418 m_ssthresh = std::max(MIN_SSTHRESH, m_cwnd * m_options.mdCoef); // multiplicative decrease
Weiwei Liu245d7912016-07-28 00:04:25 -0700419 m_cwnd = m_options.resetCwndToInit ? m_options.initCwnd : m_ssthresh;
Davide Pesavento958896e2017-01-19 00:52:04 -0500420
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500421 afterCwndChange(time::steady_clock::now() - getStartTime(), m_cwnd);
Weiwei Liu245d7912016-07-28 00:04:25 -0700422}
423
Weiwei Liu245d7912016-07-28 00:04:25 -0700424void
Davide Pesavento958896e2017-01-19 00:52:04 -0500425PipelineInterestsAimd::cancelInFlightSegmentsGreaterThan(uint64_t segNo)
Weiwei Liu245d7912016-07-28 00:04:25 -0700426{
427 for (auto it = m_segmentInfo.begin(); it != m_segmentInfo.end();) {
428 // cancel fetching all segments that follow
Davide Pesavento958896e2017-01-19 00:52:04 -0500429 if (it->first > segNo) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700430 m_face.removePendingInterest(it->second.interestId);
431 it = m_segmentInfo.erase(it);
Davide Pesavento958896e2017-01-19 00:52:04 -0500432 m_nInFlight--;
Weiwei Liu245d7912016-07-28 00:04:25 -0700433 }
434 else {
435 ++it;
436 }
437 }
438}
439
440void
441PipelineInterestsAimd::printSummary() const
442{
Chavoosh Ghasemi4d36ed52017-10-31 22:26:25 +0000443 PipelineInterests::printSummary();
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -0400444 std::cerr << "Total # of lost/retransmitted segments: " << m_nRetransmitted
445 << " (caused " << m_nLossEvents << " window decreases)\n"
Weiwei Liu245d7912016-07-28 00:04:25 -0700446 << "Packet loss rate: "
Ryan Wickman034f30f2018-06-06 11:11:11 -0500447 << (m_nSent == 0 ? 0 : (static_cast<double>(m_nRetransmitted) / static_cast<double>(m_nSent) * 100)) << "%\n"
Chavoosh Ghasemi3dae1092017-12-21 12:39:08 -0700448 << "Total # of received congestion marks: " << m_nCongMarks << "\n"
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -0400449 << "RTT ";
450
451 if (m_rttEstimator.getMinRtt() == std::numeric_limits<double>::max() ||
452 m_rttEstimator.getMaxRtt() == std::numeric_limits<double>::min()) {
453 std::cerr << "stats unavailable\n";
454 }
455 else {
456 std::cerr << "min/avg/max = " << std::fixed << std::setprecision(3)
457 << m_rttEstimator.getMinRtt() << "/"
458 << m_rttEstimator.getAvgRtt() << "/"
459 << m_rttEstimator.getMaxRtt() << " ms\n";
460 }
Weiwei Liu245d7912016-07-28 00:04:25 -0700461}
462
463std::ostream&
464operator<<(std::ostream& os, SegmentState state)
465{
466 switch (state) {
467 case SegmentState::FirstTimeSent:
468 os << "FirstTimeSent";
469 break;
470 case SegmentState::InRetxQueue:
471 os << "InRetxQueue";
472 break;
473 case SegmentState::Retransmitted:
474 os << "Retransmitted";
475 break;
Weiwei Liu245d7912016-07-28 00:04:25 -0700476 }
Weiwei Liu245d7912016-07-28 00:04:25 -0700477 return os;
478}
479
480std::ostream&
481operator<<(std::ostream& os, const PipelineInterestsAimdOptions& options)
482{
Davide Pesavento44b3b232017-12-23 16:58:25 -0500483 os << "AIMD pipeline parameters:\n"
Weiwei Liu245d7912016-07-28 00:04:25 -0700484 << "\tInitial congestion window size = " << options.initCwnd << "\n"
485 << "\tInitial slow start threshold = " << options.initSsthresh << "\n"
Weiwei Liu245d7912016-07-28 00:04:25 -0700486 << "\tAdditive increase step = " << options.aiStep << "\n"
Davide Pesavento958896e2017-01-19 00:52:04 -0500487 << "\tMultiplicative decrease factor = " << options.mdCoef << "\n"
Weiwei Liu245d7912016-07-28 00:04:25 -0700488 << "\tRTO check interval = " << options.rtoCheckInterval << "\n"
Davide Pesavento44b3b232017-12-23 16:58:25 -0500489 << "\tMax retries on timeout or Nack = " << (options.maxRetriesOnTimeoutOrNack == DataFetcher::MAX_RETRIES_INFINITE ?
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500490 "infinite" : to_string(options.maxRetriesOnTimeoutOrNack)) << "\n"
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000491 << "\tReaction to congestion marks " << (options.ignoreCongMarks ? "disabled" : "enabled") << "\n"
Davide Pesavento44b3b232017-12-23 16:58:25 -0500492 << "\tConservative window adaptation " << (options.disableCwa ? "disabled" : "enabled") << "\n"
Davide Pesavento958896e2017-01-19 00:52:04 -0500493 << "\tResetting cwnd to " << (options.resetCwndToInit ? "initCwnd" : "ssthresh") << " upon loss event\n";
Weiwei Liu245d7912016-07-28 00:04:25 -0700494 return os;
495}
496
497} // namespace aimd
498} // namespace chunks
499} // namespace ndn