blob: b802e348461bc23f1f65568740c85d1ef608282b [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)
schneiderklaus8ff3abd2019-03-12 22:15:12 -070050 , m_nLossDecr(0)
51 , m_nMarkDecr(0)
52 , m_nTimeouts(0)
53 , m_nSkippedRetx(0)
Weiwei Liu245d7912016-07-28 00:04:25 -070054 , m_nRetransmitted(0)
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +000055 , m_nCongMarks(0)
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -040056 , m_nSent(0)
Weiwei Liu245d7912016-07-28 00:04:25 -070057 , m_cwnd(m_options.initCwnd)
58 , m_ssthresh(m_options.initSsthresh)
59 , m_hasFailure(false)
60 , m_failedSegNo(0)
61{
62 if (m_options.isVerbose) {
63 std::cerr << m_options;
64 }
65}
66
67PipelineInterestsAimd::~PipelineInterestsAimd()
68{
69 cancel();
70}
71
72void
73PipelineInterestsAimd::doRun()
74{
Ryan Wickman034f30f2018-06-06 11:11:11 -050075 if (allSegmentsReceived()) {
76 cancel();
77 if (!m_options.isQuiet) {
78 printSummary();
79 }
80 return;
81 }
82
Weiwei Liu245d7912016-07-28 00:04:25 -070083 // schedule the event to check retransmission timer
Davide Pesaventocd65c2c2017-01-15 16:10:38 -050084 m_checkRtoEvent = m_scheduler.scheduleEvent(m_options.rtoCheckInterval, [this] { checkRto(); });
Weiwei Liu245d7912016-07-28 00:04:25 -070085
Davide Pesavento958896e2017-01-19 00:52:04 -050086 schedulePackets();
Weiwei Liu245d7912016-07-28 00:04:25 -070087}
88
89void
90PipelineInterestsAimd::doCancel()
91{
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?
schneiderklaus8ff3abd2019-03-12 22:15:12 -0700109 m_nTimeouts++;
Davide Pesavento958896e2017-01-19 00:52:04 -0500110 hasTimeout = true;
111 enqueueForRetransmission(entry.first);
Weiwei Liu245d7912016-07-28 00:04:25 -0700112 }
113 }
114 }
115
Davide Pesavento958896e2017-01-19 00:52:04 -0500116 if (hasTimeout) {
117 recordTimeout();
118 schedulePackets();
Weiwei Liu245d7912016-07-28 00:04:25 -0700119 }
120
121 // schedule the next check after predefined interval
Davide Pesaventocd65c2c2017-01-15 16:10:38 -0500122 m_checkRtoEvent = m_scheduler.scheduleEvent(m_options.rtoCheckInterval, [this] { checkRto(); });
Weiwei Liu245d7912016-07-28 00:04:25 -0700123}
124
125void
126PipelineInterestsAimd::sendInterest(uint64_t segNo, bool isRetransmission)
127{
128 if (isStopping())
129 return;
130
Ryan Wickman034f30f2018-06-06 11:11:11 -0500131 if (m_hasFinalBlockId && segNo > m_lastSegmentNo)
Weiwei Liu245d7912016-07-28 00:04:25 -0700132 return;
133
134 if (!isRetransmission && m_hasFailure)
135 return;
136
137 if (m_options.isVerbose) {
Davide Pesavento958896e2017-01-19 00:52:04 -0500138 std::cerr << (isRetransmission ? "Retransmitting" : "Requesting")
139 << " segment #" << segNo << std::endl;
Weiwei Liu245d7912016-07-28 00:04:25 -0700140 }
141
142 if (isRetransmission) {
Davide Pesavento958896e2017-01-19 00:52:04 -0500143 // keep track of retx count for this segment
144 auto ret = m_retxCount.emplace(segNo, 1);
Weiwei Liu245d7912016-07-28 00:04:25 -0700145 if (ret.second == false) { // not the first retransmission
146 m_retxCount[segNo] += 1;
Davide Pesavento44b3b232017-12-23 16:58:25 -0500147 if (m_options.maxRetriesOnTimeoutOrNack != DataFetcher::MAX_RETRIES_INFINITE &&
148 m_retxCount[segNo] > m_options.maxRetriesOnTimeoutOrNack) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700149 return handleFail(segNo, "Reached the maximum number of retries (" +
150 to_string(m_options.maxRetriesOnTimeoutOrNack) +
151 ") while retrieving segment #" + to_string(segNo));
152 }
153
154 if (m_options.isVerbose) {
155 std::cerr << "# of retries for segment #" << segNo
156 << " is " << m_retxCount[segNo] << std::endl;
157 }
158 }
Weiwei Liu245d7912016-07-28 00:04:25 -0700159 }
160
161 Interest interest(Name(m_prefix).appendSegment(segNo));
162 interest.setInterestLifetime(m_options.interestLifetime);
163 interest.setMustBeFresh(m_options.mustBeFresh);
164 interest.setMaxSuffixComponents(1);
165
Junxiao Shi06d008c2019-02-04 08:26:59 +0000166 SegmentInfo& segInfo = m_segmentInfo[segNo];
167 segInfo.interestHdl = m_face.expressInterest(interest,
168 bind(&PipelineInterestsAimd::handleData, this, _1, _2),
169 bind(&PipelineInterestsAimd::handleNack, this, _1, _2),
170 bind(&PipelineInterestsAimd::handleLifetimeExpiration, this, _1));
171 segInfo.timeSent = time::steady_clock::now();
172 segInfo.rto = m_rttEstimator.getEstimatedRto();
173
Weiwei Liu245d7912016-07-28 00:04:25 -0700174 m_nInFlight++;
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -0400175 m_nSent++;
Weiwei Liu245d7912016-07-28 00:04:25 -0700176
177 if (isRetransmission) {
Davide Pesavento958896e2017-01-19 00:52:04 -0500178 segInfo.state = SegmentState::Retransmitted;
Weiwei Liu245d7912016-07-28 00:04:25 -0700179 m_nRetransmitted++;
180 }
181 else {
182 m_highInterest = segNo;
Junxiao Shi06d008c2019-02-04 08:26:59 +0000183 segInfo.state = SegmentState::FirstTimeSent;
Weiwei Liu245d7912016-07-28 00:04:25 -0700184 }
185}
186
187void
188PipelineInterestsAimd::schedulePackets()
189{
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500190 BOOST_ASSERT(m_nInFlight >= 0);
191 auto availableWindowSize = static_cast<int64_t>(m_cwnd) - m_nInFlight;
192
Weiwei Liu245d7912016-07-28 00:04:25 -0700193 while (availableWindowSize > 0) {
194 if (!m_retxQueue.empty()) { // do retransmission first
195 uint64_t retxSegNo = m_retxQueue.front();
196 m_retxQueue.pop();
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500197 if (m_segmentInfo.count(retxSegNo) == 0) {
schneiderklaus8ff3abd2019-03-12 22:15:12 -0700198 m_nSkippedRetx++;
Weiwei Liu245d7912016-07-28 00:04:25 -0700199 continue;
200 }
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500201 // the segment is still in the map, that means it needs to be retransmitted
Weiwei Liu245d7912016-07-28 00:04:25 -0700202 sendInterest(retxSegNo, true);
203 }
204 else { // send next segment
205 sendInterest(getNextSegmentNo(), false);
206 }
207 availableWindowSize--;
208 }
209}
210
211void
212PipelineInterestsAimd::handleData(const Interest& interest, const Data& data)
213{
214 if (isStopping())
215 return;
216
217 // Data name will not have extra components because MaxSuffixComponents is set to 1
218 BOOST_ASSERT(data.getName().equals(interest.getName()));
219
Davide Pesavento969cd5a2018-04-20 16:27:47 -0400220 if (!m_hasFinalBlockId && data.getFinalBlock()) {
221 m_lastSegmentNo = data.getFinalBlock()->toSegment();
Weiwei Liu245d7912016-07-28 00:04:25 -0700222 m_hasFinalBlockId = true;
223 cancelInFlightSegmentsGreaterThan(m_lastSegmentNo);
224 if (m_hasFailure && m_lastSegmentNo >= m_failedSegNo) {
225 // previously failed segment is part of the content
226 return onFailure(m_failureReason);
Chavoosh Ghasemi4d36ed52017-10-31 22:26:25 +0000227 }
228 else {
Weiwei Liu245d7912016-07-28 00:04:25 -0700229 m_hasFailure = false;
230 }
231 }
232
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500233 uint64_t recvSegNo = getSegmentFromPacket(data);
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500234 auto segIt = m_segmentInfo.find(recvSegNo);
235 if (segIt == m_segmentInfo.end()) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700236 return; // ignore already-received segment
237 }
238
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500239 SegmentInfo& segInfo = segIt->second;
Weiwei Liu245d7912016-07-28 00:04:25 -0700240 Milliseconds rtt = time::steady_clock::now() - segInfo.timeSent;
Weiwei Liu245d7912016-07-28 00:04:25 -0700241 if (m_options.isVerbose) {
242 std::cerr << "Received segment #" << recvSegNo
243 << ", rtt=" << rtt.count() << "ms"
244 << ", rto=" << segInfo.rto.count() << "ms" << std::endl;
245 }
246
Davide Pesavento958896e2017-01-19 00:52:04 -0500247 if (m_highData < recvSegNo) {
248 m_highData = recvSegNo;
249 }
250
251 // for segments in retx queue, we must not decrement m_nInFlight
252 // because it was already decremented when the segment timed out
253 if (segInfo.state != SegmentState::InRetxQueue) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700254 m_nInFlight--;
255 }
256
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000257 // upon finding congestion mark, decrease the window size
258 // without retransmitting any packet
259 if (data.getCongestionMark() > 0) {
260 m_nCongMarks++;
261 if (!m_options.ignoreCongMarks) {
262 if (m_options.disableCwa || m_highData > m_recPoint) {
263 m_recPoint = m_highInterest; // react to only one congestion event (timeout or congestion mark)
264 // per RTT (conservative window adaptation)
schneiderklaus8ff3abd2019-03-12 22:15:12 -0700265 m_nMarkDecr++;
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000266 decreaseWindow();
267
268 if (m_options.isVerbose) {
269 std::cerr << "Received congestion mark, value = " << data.getCongestionMark()
270 << ", new cwnd = " << m_cwnd << std::endl;
271 }
272 }
273 }
274 else {
275 increaseWindow();
276 }
277 }
278 else {
279 increaseWindow();
280 }
281
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400282 onData(data);
Weiwei Liu245d7912016-07-28 00:04:25 -0700283
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500284 // do not sample RTT for retransmitted segments
285 if ((segInfo.state == SegmentState::FirstTimeSent ||
286 segInfo.state == SegmentState::InRetxQueue) &&
287 m_retxCount.count(recvSegNo) == 0) {
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500288 auto nExpectedSamples = std::max<int64_t>((m_nInFlight + 1) >> 1, 1);
289 BOOST_ASSERT(nExpectedSamples > 0);
290 m_rttEstimator.addMeasurement(recvSegNo, rtt, static_cast<size_t>(nExpectedSamples));
Weiwei Liu245d7912016-07-28 00:04:25 -0700291 }
292
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500293 // remove the entry associated with the received segment
294 m_segmentInfo.erase(segIt);
295
Ryan Wickman034f30f2018-06-06 11:11:11 -0500296 if (allSegmentsReceived()) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700297 cancel();
Davide Pesaventof6991e12018-01-08 20:58:50 -0500298 if (!m_options.isQuiet) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700299 printSummary();
300 }
301 }
302 else {
303 schedulePackets();
304 }
305}
306
307void
308PipelineInterestsAimd::handleNack(const Interest& interest, const lp::Nack& nack)
309{
310 if (isStopping())
311 return;
312
313 if (m_options.isVerbose)
314 std::cerr << "Received Nack with reason " << nack.getReason()
315 << " for Interest " << interest << std::endl;
316
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500317 uint64_t segNo = getSegmentFromPacket(interest);
Weiwei Liu245d7912016-07-28 00:04:25 -0700318
319 switch (nack.getReason()) {
Davide Pesavento958896e2017-01-19 00:52:04 -0500320 case lp::NackReason::DUPLICATE:
321 // ignore duplicates
Weiwei Liu245d7912016-07-28 00:04:25 -0700322 break;
Davide Pesavento958896e2017-01-19 00:52:04 -0500323 case lp::NackReason::CONGESTION:
324 // treated the same as timeout for now
325 enqueueForRetransmission(segNo);
326 recordTimeout();
327 schedulePackets();
328 break;
329 default:
Weiwei Liu245d7912016-07-28 00:04:25 -0700330 handleFail(segNo, "Could not retrieve data for " + interest.getName().toUri() +
331 ", reason: " + boost::lexical_cast<std::string>(nack.getReason()));
332 break;
Weiwei Liu245d7912016-07-28 00:04:25 -0700333 }
334}
335
336void
337PipelineInterestsAimd::handleLifetimeExpiration(const Interest& interest)
338{
339 if (isStopping())
340 return;
341
schneiderklaus8ff3abd2019-03-12 22:15:12 -0700342 m_nTimeouts++;
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();
schneiderklaus8ff3abd2019-03-12 22:15:12 -0700357 m_nLossDecr++;
Weiwei Liu245d7912016-07-28 00:04:25 -0700358
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 it = m_segmentInfo.erase(it);
Davide Pesavento958896e2017-01-19 00:52:04 -0500431 m_nInFlight--;
Weiwei Liu245d7912016-07-28 00:04:25 -0700432 }
433 else {
434 ++it;
435 }
436 }
437}
438
439void
440PipelineInterestsAimd::printSummary() const
441{
Chavoosh Ghasemi4d36ed52017-10-31 22:26:25 +0000442 PipelineInterests::printSummary();
schneiderklaus8ff3abd2019-03-12 22:15:12 -0700443 std::cerr << "Congestion marks: " << m_nCongMarks << " (caused " << m_nMarkDecr << " window decreases)\n"
444 << "Timeouts: " << m_nTimeouts << " (caused " << m_nLossDecr << " window decreases)\n"
445 << "Retransmitted segments: " << m_nRetransmitted
446 << " (" << (m_nSent == 0 ? 0 : (static_cast<double>(m_nRetransmitted) / m_nSent * 100.0)) << "%)"
447 << ", skipped: " << m_nSkippedRetx << "\n"
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -0400448 << "RTT ";
449
450 if (m_rttEstimator.getMinRtt() == std::numeric_limits<double>::max() ||
451 m_rttEstimator.getMaxRtt() == std::numeric_limits<double>::min()) {
452 std::cerr << "stats unavailable\n";
453 }
454 else {
455 std::cerr << "min/avg/max = " << std::fixed << std::setprecision(3)
456 << m_rttEstimator.getMinRtt() << "/"
457 << m_rttEstimator.getAvgRtt() << "/"
458 << m_rttEstimator.getMaxRtt() << " ms\n";
459 }
Weiwei Liu245d7912016-07-28 00:04:25 -0700460}
461
462std::ostream&
463operator<<(std::ostream& os, SegmentState state)
464{
465 switch (state) {
466 case SegmentState::FirstTimeSent:
467 os << "FirstTimeSent";
468 break;
469 case SegmentState::InRetxQueue:
470 os << "InRetxQueue";
471 break;
472 case SegmentState::Retransmitted:
473 os << "Retransmitted";
474 break;
Weiwei Liu245d7912016-07-28 00:04:25 -0700475 }
Weiwei Liu245d7912016-07-28 00:04:25 -0700476 return os;
477}
478
479std::ostream&
480operator<<(std::ostream& os, const PipelineInterestsAimdOptions& options)
481{
Davide Pesavento44b3b232017-12-23 16:58:25 -0500482 os << "AIMD pipeline parameters:\n"
Weiwei Liu245d7912016-07-28 00:04:25 -0700483 << "\tInitial congestion window size = " << options.initCwnd << "\n"
484 << "\tInitial slow start threshold = " << options.initSsthresh << "\n"
Weiwei Liu245d7912016-07-28 00:04:25 -0700485 << "\tAdditive increase step = " << options.aiStep << "\n"
Davide Pesavento958896e2017-01-19 00:52:04 -0500486 << "\tMultiplicative decrease factor = " << options.mdCoef << "\n"
Weiwei Liu245d7912016-07-28 00:04:25 -0700487 << "\tRTO check interval = " << options.rtoCheckInterval << "\n"
Davide Pesavento44b3b232017-12-23 16:58:25 -0500488 << "\tMax retries on timeout or Nack = " << (options.maxRetriesOnTimeoutOrNack == DataFetcher::MAX_RETRIES_INFINITE ?
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500489 "infinite" : to_string(options.maxRetriesOnTimeoutOrNack)) << "\n"
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000490 << "\tReaction to congestion marks " << (options.ignoreCongMarks ? "disabled" : "enabled") << "\n"
Davide Pesavento44b3b232017-12-23 16:58:25 -0500491 << "\tConservative window adaptation " << (options.disableCwa ? "disabled" : "enabled") << "\n"
Davide Pesavento958896e2017-01-19 00:52:04 -0500492 << "\tResetting cwnd to " << (options.resetCwndToInit ? "initCwnd" : "ssthresh") << " upon loss event\n";
Weiwei Liu245d7912016-07-28 00:04:25 -0700493 return os;
494}
495
496} // namespace aimd
497} // namespace chunks
498} // namespace ndn