blob: 961a0641959b42ac45b6839d82aa3a91e66cdb92 [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/*
Chavoosh Ghasemi3dae1092017-12-21 12:39:08 -07003 * Copyright (c) 2016-2018, 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())
Davide Pesaventocd65c2c2017-01-15 16:10:38 -050046 , m_checkRtoEvent(m_scheduler)
Weiwei Liu245d7912016-07-28 00:04:25 -070047 , m_highData(0)
48 , m_highInterest(0)
49 , m_recPoint(0)
50 , m_nInFlight(0)
Weiwei Liu245d7912016-07-28 00:04:25 -070051 , m_nLossEvents(0)
52 , m_nRetransmitted(0)
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +000053 , m_nCongMarks(0)
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -040054 , m_nSent(0)
Weiwei Liu245d7912016-07-28 00:04:25 -070055 , m_cwnd(m_options.initCwnd)
56 , m_ssthresh(m_options.initSsthresh)
57 , m_hasFailure(false)
58 , m_failedSegNo(0)
59{
60 if (m_options.isVerbose) {
61 std::cerr << m_options;
62 }
63}
64
65PipelineInterestsAimd::~PipelineInterestsAimd()
66{
67 cancel();
68}
69
70void
71PipelineInterestsAimd::doRun()
72{
Ryan Wickman034f30f2018-06-06 11:11:11 -050073 if (allSegmentsReceived()) {
74 cancel();
75 if (!m_options.isQuiet) {
76 printSummary();
77 }
78 return;
79 }
80
Weiwei Liu245d7912016-07-28 00:04:25 -070081 // schedule the event to check retransmission timer
Davide Pesaventocd65c2c2017-01-15 16:10:38 -050082 m_checkRtoEvent = m_scheduler.scheduleEvent(m_options.rtoCheckInterval, [this] { checkRto(); });
Weiwei Liu245d7912016-07-28 00:04:25 -070083
Davide Pesavento958896e2017-01-19 00:52:04 -050084 schedulePackets();
Weiwei Liu245d7912016-07-28 00:04:25 -070085}
86
87void
88PipelineInterestsAimd::doCancel()
89{
90 for (const auto& entry : m_segmentInfo) {
Davide Pesaventocd65c2c2017-01-15 16:10:38 -050091 m_face.removePendingInterest(entry.second.interestId);
Weiwei Liu245d7912016-07-28 00:04:25 -070092 }
Davide Pesaventocd65c2c2017-01-15 16:10:38 -050093 m_checkRtoEvent.cancel();
Weiwei Liu245d7912016-07-28 00:04:25 -070094 m_segmentInfo.clear();
Weiwei Liu245d7912016-07-28 00:04:25 -070095}
96
97void
98PipelineInterestsAimd::checkRto()
99{
100 if (isStopping())
101 return;
102
Davide Pesavento958896e2017-01-19 00:52:04 -0500103 bool hasTimeout = false;
Weiwei Liu245d7912016-07-28 00:04:25 -0700104
105 for (auto& entry : m_segmentInfo) {
106 SegmentInfo& segInfo = entry.second;
107 if (segInfo.state != SegmentState::InRetxQueue && // do not check segments currently in the retx queue
108 segInfo.state != SegmentState::RetxReceived) { // or already-received retransmitted segments
109 Milliseconds timeElapsed = time::steady_clock::now() - segInfo.timeSent;
110 if (timeElapsed.count() > segInfo.rto.count()) { // timer expired?
Davide Pesavento958896e2017-01-19 00:52:04 -0500111 hasTimeout = true;
112 enqueueForRetransmission(entry.first);
Weiwei Liu245d7912016-07-28 00:04:25 -0700113 }
114 }
115 }
116
Davide Pesavento958896e2017-01-19 00:52:04 -0500117 if (hasTimeout) {
118 recordTimeout();
119 schedulePackets();
Weiwei Liu245d7912016-07-28 00:04:25 -0700120 }
121
122 // schedule the next check after predefined interval
Davide Pesaventocd65c2c2017-01-15 16:10:38 -0500123 m_checkRtoEvent = m_scheduler.scheduleEvent(m_options.rtoCheckInterval, [this] { checkRto(); });
Weiwei Liu245d7912016-07-28 00:04:25 -0700124}
125
126void
127PipelineInterestsAimd::sendInterest(uint64_t segNo, bool isRetransmission)
128{
129 if (isStopping())
130 return;
131
Ryan Wickman034f30f2018-06-06 11:11:11 -0500132 if (m_hasFinalBlockId && segNo > m_lastSegmentNo)
Weiwei Liu245d7912016-07-28 00:04:25 -0700133 return;
134
135 if (!isRetransmission && m_hasFailure)
136 return;
137
138 if (m_options.isVerbose) {
Davide Pesavento958896e2017-01-19 00:52:04 -0500139 std::cerr << (isRetransmission ? "Retransmitting" : "Requesting")
140 << " segment #" << segNo << std::endl;
Weiwei Liu245d7912016-07-28 00:04:25 -0700141 }
142
143 if (isRetransmission) {
Davide Pesavento958896e2017-01-19 00:52:04 -0500144 // keep track of retx count for this segment
145 auto ret = m_retxCount.emplace(segNo, 1);
Weiwei Liu245d7912016-07-28 00:04:25 -0700146 if (ret.second == false) { // not the first retransmission
147 m_retxCount[segNo] += 1;
Davide Pesavento44b3b232017-12-23 16:58:25 -0500148 if (m_options.maxRetriesOnTimeoutOrNack != DataFetcher::MAX_RETRIES_INFINITE &&
149 m_retxCount[segNo] > m_options.maxRetriesOnTimeoutOrNack) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700150 return handleFail(segNo, "Reached the maximum number of retries (" +
151 to_string(m_options.maxRetriesOnTimeoutOrNack) +
152 ") while retrieving segment #" + to_string(segNo));
153 }
154
155 if (m_options.isVerbose) {
156 std::cerr << "# of retries for segment #" << segNo
157 << " is " << m_retxCount[segNo] << std::endl;
158 }
159 }
160
161 m_face.removePendingInterest(m_segmentInfo[segNo].interestId);
162 }
163
164 Interest interest(Name(m_prefix).appendSegment(segNo));
165 interest.setInterestLifetime(m_options.interestLifetime);
166 interest.setMustBeFresh(m_options.mustBeFresh);
167 interest.setMaxSuffixComponents(1);
168
169 auto interestId = m_face.expressInterest(interest,
170 bind(&PipelineInterestsAimd::handleData, this, _1, _2),
171 bind(&PipelineInterestsAimd::handleNack, this, _1, _2),
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400172 bind(&PipelineInterestsAimd::handleLifetimeExpiration, this, _1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700173 m_nInFlight++;
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -0400174 m_nSent++;
Weiwei Liu245d7912016-07-28 00:04:25 -0700175
176 if (isRetransmission) {
177 SegmentInfo& segInfo = m_segmentInfo[segNo];
Weiwei Liu245d7912016-07-28 00:04:25 -0700178 segInfo.timeSent = time::steady_clock::now();
Davide Pesavento958896e2017-01-19 00:52:04 -0500179 segInfo.rto = m_rttEstimator.getEstimatedRto();
180 segInfo.state = SegmentState::Retransmitted;
Weiwei Liu245d7912016-07-28 00:04:25 -0700181 m_nRetransmitted++;
182 }
183 else {
184 m_highInterest = segNo;
Davide Pesavento958896e2017-01-19 00:52:04 -0500185 m_segmentInfo[segNo] = {interestId,
186 time::steady_clock::now(),
187 m_rttEstimator.getEstimatedRto(),
188 SegmentState::FirstTimeSent};
Weiwei Liu245d7912016-07-28 00:04:25 -0700189 }
190}
191
192void
193PipelineInterestsAimd::schedulePackets()
194{
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500195 BOOST_ASSERT(m_nInFlight >= 0);
196 auto availableWindowSize = static_cast<int64_t>(m_cwnd) - m_nInFlight;
197
Weiwei Liu245d7912016-07-28 00:04:25 -0700198 while (availableWindowSize > 0) {
199 if (!m_retxQueue.empty()) { // do retransmission first
200 uint64_t retxSegNo = m_retxQueue.front();
201 m_retxQueue.pop();
202
203 auto it = m_segmentInfo.find(retxSegNo);
204 if (it == m_segmentInfo.end()) {
205 continue;
206 }
207 // the segment is still in the map, it means that it needs to be retransmitted
208 sendInterest(retxSegNo, true);
209 }
210 else { // send next segment
211 sendInterest(getNextSegmentNo(), false);
212 }
213 availableWindowSize--;
214 }
215}
216
217void
218PipelineInterestsAimd::handleData(const Interest& interest, const Data& data)
219{
220 if (isStopping())
221 return;
222
223 // Data name will not have extra components because MaxSuffixComponents is set to 1
224 BOOST_ASSERT(data.getName().equals(interest.getName()));
225
Davide Pesavento969cd5a2018-04-20 16:27:47 -0400226 if (!m_hasFinalBlockId && data.getFinalBlock()) {
227 m_lastSegmentNo = data.getFinalBlock()->toSegment();
Weiwei Liu245d7912016-07-28 00:04:25 -0700228 m_hasFinalBlockId = true;
229 cancelInFlightSegmentsGreaterThan(m_lastSegmentNo);
230 if (m_hasFailure && m_lastSegmentNo >= m_failedSegNo) {
231 // previously failed segment is part of the content
232 return onFailure(m_failureReason);
Chavoosh Ghasemi4d36ed52017-10-31 22:26:25 +0000233 }
234 else {
Weiwei Liu245d7912016-07-28 00:04:25 -0700235 m_hasFailure = false;
236 }
237 }
238
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500239 uint64_t recvSegNo = getSegmentFromPacket(data);
Weiwei Liu245d7912016-07-28 00:04:25 -0700240 SegmentInfo& segInfo = m_segmentInfo[recvSegNo];
241 if (segInfo.state == SegmentState::RetxReceived) {
242 m_segmentInfo.erase(recvSegNo);
243 return; // ignore already-received segment
244 }
245
246 Milliseconds rtt = time::steady_clock::now() - segInfo.timeSent;
Weiwei Liu245d7912016-07-28 00:04:25 -0700247 if (m_options.isVerbose) {
248 std::cerr << "Received segment #" << recvSegNo
249 << ", rtt=" << rtt.count() << "ms"
250 << ", rto=" << segInfo.rto.count() << "ms" << std::endl;
251 }
252
Davide Pesavento958896e2017-01-19 00:52:04 -0500253 if (m_highData < recvSegNo) {
254 m_highData = recvSegNo;
255 }
256
257 // for segments in retx queue, we must not decrement m_nInFlight
258 // because it was already decremented when the segment timed out
259 if (segInfo.state != SegmentState::InRetxQueue) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700260 m_nInFlight--;
261 }
262
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000263 // upon finding congestion mark, decrease the window size
264 // without retransmitting any packet
265 if (data.getCongestionMark() > 0) {
266 m_nCongMarks++;
267 if (!m_options.ignoreCongMarks) {
268 if (m_options.disableCwa || m_highData > m_recPoint) {
269 m_recPoint = m_highInterest; // react to only one congestion event (timeout or congestion mark)
270 // per RTT (conservative window adaptation)
271 decreaseWindow();
272
273 if (m_options.isVerbose) {
274 std::cerr << "Received congestion mark, value = " << data.getCongestionMark()
275 << ", new cwnd = " << m_cwnd << std::endl;
276 }
277 }
278 }
279 else {
280 increaseWindow();
281 }
282 }
283 else {
284 increaseWindow();
285 }
286
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400287 onData(data);
Weiwei Liu245d7912016-07-28 00:04:25 -0700288
289 if (segInfo.state == SegmentState::FirstTimeSent ||
290 segInfo.state == SegmentState::InRetxQueue) { // do not sample RTT for retransmitted segments
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500291 auto nExpectedSamples = std::max<int64_t>((m_nInFlight + 1) >> 1, 1);
292 BOOST_ASSERT(nExpectedSamples > 0);
293 m_rttEstimator.addMeasurement(recvSegNo, rtt, static_cast<size_t>(nExpectedSamples));
Weiwei Liu245d7912016-07-28 00:04:25 -0700294 m_segmentInfo.erase(recvSegNo); // remove the entry associated with the received segment
295 }
296 else { // retransmission
Davide Pesavento958896e2017-01-19 00:52:04 -0500297 BOOST_ASSERT(segInfo.state == SegmentState::Retransmitted);
Weiwei Liu245d7912016-07-28 00:04:25 -0700298 segInfo.state = SegmentState::RetxReceived;
299 }
300
301 BOOST_ASSERT(m_nReceived > 0);
Ryan Wickman034f30f2018-06-06 11:11:11 -0500302 if (allSegmentsReceived()) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700303 cancel();
Davide Pesaventof6991e12018-01-08 20:58:50 -0500304 if (!m_options.isQuiet) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700305 printSummary();
306 }
307 }
308 else {
309 schedulePackets();
310 }
311}
312
313void
314PipelineInterestsAimd::handleNack(const Interest& interest, const lp::Nack& nack)
315{
316 if (isStopping())
317 return;
318
319 if (m_options.isVerbose)
320 std::cerr << "Received Nack with reason " << nack.getReason()
321 << " for Interest " << interest << std::endl;
322
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500323 uint64_t segNo = getSegmentFromPacket(interest);
Weiwei Liu245d7912016-07-28 00:04:25 -0700324
325 switch (nack.getReason()) {
Davide Pesavento958896e2017-01-19 00:52:04 -0500326 case lp::NackReason::DUPLICATE:
327 // ignore duplicates
Weiwei Liu245d7912016-07-28 00:04:25 -0700328 break;
Davide Pesavento958896e2017-01-19 00:52:04 -0500329 case lp::NackReason::CONGESTION:
330 // treated the same as timeout for now
331 enqueueForRetransmission(segNo);
332 recordTimeout();
333 schedulePackets();
334 break;
335 default:
Weiwei Liu245d7912016-07-28 00:04:25 -0700336 handleFail(segNo, "Could not retrieve data for " + interest.getName().toUri() +
337 ", reason: " + boost::lexical_cast<std::string>(nack.getReason()));
338 break;
Weiwei Liu245d7912016-07-28 00:04:25 -0700339 }
340}
341
342void
343PipelineInterestsAimd::handleLifetimeExpiration(const Interest& interest)
344{
345 if (isStopping())
346 return;
347
Davide Pesavento958896e2017-01-19 00:52:04 -0500348 enqueueForRetransmission(getSegmentFromPacket(interest));
349 recordTimeout();
350 schedulePackets();
Weiwei Liu245d7912016-07-28 00:04:25 -0700351}
352
353void
Davide Pesavento958896e2017-01-19 00:52:04 -0500354PipelineInterestsAimd::recordTimeout()
Weiwei Liu245d7912016-07-28 00:04:25 -0700355{
Weiwei Liu245d7912016-07-28 00:04:25 -0700356 if (m_options.disableCwa || m_highData > m_recPoint) {
357 // react to only one timeout per RTT (conservative window adaptation)
358 m_recPoint = m_highInterest;
359
360 decreaseWindow();
361 m_rttEstimator.backoffRto();
362 m_nLossEvents++;
363
364 if (m_options.isVerbose) {
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000365 std::cerr << "Packet loss event, new cwnd = " << m_cwnd
Weiwei Liu245d7912016-07-28 00:04:25 -0700366 << ", ssthresh = " << m_ssthresh << std::endl;
367 }
368 }
Davide Pesavento958896e2017-01-19 00:52:04 -0500369}
Weiwei Liu245d7912016-07-28 00:04:25 -0700370
Davide Pesavento958896e2017-01-19 00:52:04 -0500371void
372PipelineInterestsAimd::enqueueForRetransmission(uint64_t segNo)
373{
374 BOOST_ASSERT(m_nInFlight > 0);
375 m_nInFlight--;
376 m_retxQueue.push(segNo);
377 m_segmentInfo.at(segNo).state = SegmentState::InRetxQueue;
Weiwei Liu245d7912016-07-28 00:04:25 -0700378}
379
380void
381PipelineInterestsAimd::handleFail(uint64_t segNo, const std::string& reason)
382{
383 if (isStopping())
384 return;
385
386 // if the failed segment is definitely part of the content, raise a fatal error
387 if (m_hasFinalBlockId && segNo <= m_lastSegmentNo)
388 return onFailure(reason);
389
390 if (!m_hasFinalBlockId) {
391 m_segmentInfo.erase(segNo);
Davide Pesavento958896e2017-01-19 00:52:04 -0500392 m_nInFlight--;
Weiwei Liu245d7912016-07-28 00:04:25 -0700393
394 if (m_segmentInfo.empty()) {
395 onFailure("Fetching terminated but no final segment number has been found");
396 }
397 else {
398 cancelInFlightSegmentsGreaterThan(segNo);
399 m_hasFailure = true;
400 m_failedSegNo = segNo;
401 m_failureReason = reason;
402 }
403 }
404}
405
406void
407PipelineInterestsAimd::increaseWindow()
408{
409 if (m_cwnd < m_ssthresh) {
410 m_cwnd += m_options.aiStep; // additive increase
Chavoosh Ghasemi4d36ed52017-10-31 22:26:25 +0000411 }
412 else {
Weiwei Liu245d7912016-07-28 00:04:25 -0700413 m_cwnd += m_options.aiStep / std::floor(m_cwnd); // congestion avoidance
414 }
Davide Pesavento958896e2017-01-19 00:52:04 -0500415
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500416 afterCwndChange(time::steady_clock::now() - getStartTime(), m_cwnd);
Weiwei Liu245d7912016-07-28 00:04:25 -0700417}
418
419void
420PipelineInterestsAimd::decreaseWindow()
421{
422 // please refer to RFC 5681, Section 3.1 for the rationale behind it
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000423 m_ssthresh = std::max(MIN_SSTHRESH, m_cwnd * m_options.mdCoef); // multiplicative decrease
Weiwei Liu245d7912016-07-28 00:04:25 -0700424 m_cwnd = m_options.resetCwndToInit ? m_options.initCwnd : m_ssthresh;
Davide Pesavento958896e2017-01-19 00:52:04 -0500425
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500426 afterCwndChange(time::steady_clock::now() - getStartTime(), m_cwnd);
Weiwei Liu245d7912016-07-28 00:04:25 -0700427}
428
Weiwei Liu245d7912016-07-28 00:04:25 -0700429void
Davide Pesavento958896e2017-01-19 00:52:04 -0500430PipelineInterestsAimd::cancelInFlightSegmentsGreaterThan(uint64_t segNo)
Weiwei Liu245d7912016-07-28 00:04:25 -0700431{
432 for (auto it = m_segmentInfo.begin(); it != m_segmentInfo.end();) {
433 // cancel fetching all segments that follow
Davide Pesavento958896e2017-01-19 00:52:04 -0500434 if (it->first > segNo) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700435 m_face.removePendingInterest(it->second.interestId);
436 it = m_segmentInfo.erase(it);
Davide Pesavento958896e2017-01-19 00:52:04 -0500437 m_nInFlight--;
Weiwei Liu245d7912016-07-28 00:04:25 -0700438 }
439 else {
440 ++it;
441 }
442 }
443}
444
Ryan Wickman034f30f2018-06-06 11:11:11 -0500445bool
446PipelineInterestsAimd::allSegmentsReceived() const
447{
448 return m_hasFinalBlockId && static_cast<uint64_t>(m_nReceived - 1) >= m_lastSegmentNo;
449}
450
Weiwei Liu245d7912016-07-28 00:04:25 -0700451void
452PipelineInterestsAimd::printSummary() const
453{
Chavoosh Ghasemi4d36ed52017-10-31 22:26:25 +0000454 PipelineInterests::printSummary();
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -0400455 std::cerr << "Total # of lost/retransmitted segments: " << m_nRetransmitted
456 << " (caused " << m_nLossEvents << " window decreases)\n"
Weiwei Liu245d7912016-07-28 00:04:25 -0700457 << "Packet loss rate: "
Ryan Wickman034f30f2018-06-06 11:11:11 -0500458 << (m_nSent == 0 ? 0 : (static_cast<double>(m_nRetransmitted) / static_cast<double>(m_nSent) * 100)) << "%\n"
Chavoosh Ghasemi3dae1092017-12-21 12:39:08 -0700459 << "Total # of received congestion marks: " << m_nCongMarks << "\n"
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -0400460 << "RTT ";
461
462 if (m_rttEstimator.getMinRtt() == std::numeric_limits<double>::max() ||
463 m_rttEstimator.getMaxRtt() == std::numeric_limits<double>::min()) {
464 std::cerr << "stats unavailable\n";
465 }
466 else {
467 std::cerr << "min/avg/max = " << std::fixed << std::setprecision(3)
468 << m_rttEstimator.getMinRtt() << "/"
469 << m_rttEstimator.getAvgRtt() << "/"
470 << m_rttEstimator.getMaxRtt() << " ms\n";
471 }
Weiwei Liu245d7912016-07-28 00:04:25 -0700472}
473
474std::ostream&
475operator<<(std::ostream& os, SegmentState state)
476{
477 switch (state) {
478 case SegmentState::FirstTimeSent:
479 os << "FirstTimeSent";
480 break;
481 case SegmentState::InRetxQueue:
482 os << "InRetxQueue";
483 break;
484 case SegmentState::Retransmitted:
485 os << "Retransmitted";
486 break;
487 case SegmentState::RetxReceived:
488 os << "RetxReceived";
489 break;
490 }
Weiwei Liu245d7912016-07-28 00:04:25 -0700491 return os;
492}
493
494std::ostream&
495operator<<(std::ostream& os, const PipelineInterestsAimdOptions& options)
496{
Davide Pesavento44b3b232017-12-23 16:58:25 -0500497 os << "AIMD pipeline parameters:\n"
Weiwei Liu245d7912016-07-28 00:04:25 -0700498 << "\tInitial congestion window size = " << options.initCwnd << "\n"
499 << "\tInitial slow start threshold = " << options.initSsthresh << "\n"
Weiwei Liu245d7912016-07-28 00:04:25 -0700500 << "\tAdditive increase step = " << options.aiStep << "\n"
Davide Pesavento958896e2017-01-19 00:52:04 -0500501 << "\tMultiplicative decrease factor = " << options.mdCoef << "\n"
Weiwei Liu245d7912016-07-28 00:04:25 -0700502 << "\tRTO check interval = " << options.rtoCheckInterval << "\n"
Davide Pesavento44b3b232017-12-23 16:58:25 -0500503 << "\tMax retries on timeout or Nack = " << (options.maxRetriesOnTimeoutOrNack == DataFetcher::MAX_RETRIES_INFINITE ?
504 "infinite" : to_string(options.maxRetriesOnTimeoutOrNack)) << "\n"
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000505 << "\tReaction to congestion marks " << (options.ignoreCongMarks ? "disabled" : "enabled") << "\n"
Davide Pesavento44b3b232017-12-23 16:58:25 -0500506 << "\tConservative window adaptation " << (options.disableCwa ? "disabled" : "enabled") << "\n"
Davide Pesavento958896e2017-01-19 00:52:04 -0500507 << "\tResetting cwnd to " << (options.resetCwndToInit ? "initCwnd" : "ssthresh") << " upon loss event\n";
Weiwei Liu245d7912016-07-28 00:04:25 -0700508 return os;
509}
510
511} // namespace aimd
512} // namespace chunks
513} // namespace ndn