blob: b9f7080b59f432974fbb15bb64fd3817bb99649c [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;
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500107 if (segInfo.state != SegmentState::InRetxQueue) { // skip segments already in the retx queue
Weiwei Liu245d7912016-07-28 00:04:25 -0700108 Milliseconds timeElapsed = time::steady_clock::now() - segInfo.timeSent;
109 if (timeElapsed.count() > segInfo.rto.count()) { // timer expired?
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 }
159
160 m_face.removePendingInterest(m_segmentInfo[segNo].interestId);
161 }
162
163 Interest interest(Name(m_prefix).appendSegment(segNo));
164 interest.setInterestLifetime(m_options.interestLifetime);
165 interest.setMustBeFresh(m_options.mustBeFresh);
166 interest.setMaxSuffixComponents(1);
167
168 auto interestId = m_face.expressInterest(interest,
169 bind(&PipelineInterestsAimd::handleData, this, _1, _2),
170 bind(&PipelineInterestsAimd::handleNack, this, _1, _2),
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400171 bind(&PipelineInterestsAimd::handleLifetimeExpiration, this, _1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700172 m_nInFlight++;
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -0400173 m_nSent++;
Weiwei Liu245d7912016-07-28 00:04:25 -0700174
175 if (isRetransmission) {
176 SegmentInfo& segInfo = m_segmentInfo[segNo];
Weiwei Liu245d7912016-07-28 00:04:25 -0700177 segInfo.timeSent = time::steady_clock::now();
Davide Pesavento958896e2017-01-19 00:52:04 -0500178 segInfo.rto = m_rttEstimator.getEstimatedRto();
179 segInfo.state = SegmentState::Retransmitted;
Weiwei Liu245d7912016-07-28 00:04:25 -0700180 m_nRetransmitted++;
181 }
182 else {
183 m_highInterest = segNo;
Davide Pesavento958896e2017-01-19 00:52:04 -0500184 m_segmentInfo[segNo] = {interestId,
185 time::steady_clock::now(),
186 m_rttEstimator.getEstimatedRto(),
187 SegmentState::FirstTimeSent};
Weiwei Liu245d7912016-07-28 00:04:25 -0700188 }
189}
190
191void
192PipelineInterestsAimd::schedulePackets()
193{
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500194 BOOST_ASSERT(m_nInFlight >= 0);
195 auto availableWindowSize = static_cast<int64_t>(m_cwnd) - m_nInFlight;
196
Weiwei Liu245d7912016-07-28 00:04:25 -0700197 while (availableWindowSize > 0) {
198 if (!m_retxQueue.empty()) { // do retransmission first
199 uint64_t retxSegNo = m_retxQueue.front();
200 m_retxQueue.pop();
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500201 if (m_segmentInfo.count(retxSegNo) == 0) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700202 continue;
203 }
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500204 // the segment is still in the map, that means it needs to be retransmitted
Weiwei Liu245d7912016-07-28 00:04:25 -0700205 sendInterest(retxSegNo, true);
206 }
207 else { // send next segment
208 sendInterest(getNextSegmentNo(), false);
209 }
210 availableWindowSize--;
211 }
212}
213
214void
215PipelineInterestsAimd::handleData(const Interest& interest, const Data& data)
216{
217 if (isStopping())
218 return;
219
220 // Data name will not have extra components because MaxSuffixComponents is set to 1
221 BOOST_ASSERT(data.getName().equals(interest.getName()));
222
Davide Pesavento969cd5a2018-04-20 16:27:47 -0400223 if (!m_hasFinalBlockId && data.getFinalBlock()) {
224 m_lastSegmentNo = data.getFinalBlock()->toSegment();
Weiwei Liu245d7912016-07-28 00:04:25 -0700225 m_hasFinalBlockId = true;
226 cancelInFlightSegmentsGreaterThan(m_lastSegmentNo);
227 if (m_hasFailure && m_lastSegmentNo >= m_failedSegNo) {
228 // previously failed segment is part of the content
229 return onFailure(m_failureReason);
Chavoosh Ghasemi4d36ed52017-10-31 22:26:25 +0000230 }
231 else {
Weiwei Liu245d7912016-07-28 00:04:25 -0700232 m_hasFailure = false;
233 }
234 }
235
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500236 uint64_t recvSegNo = getSegmentFromPacket(data);
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500237 auto segIt = m_segmentInfo.find(recvSegNo);
238 if (segIt == m_segmentInfo.end()) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700239 return; // ignore already-received segment
240 }
241
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500242 SegmentInfo& segInfo = segIt->second;
Weiwei Liu245d7912016-07-28 00:04:25 -0700243 Milliseconds rtt = time::steady_clock::now() - segInfo.timeSent;
Weiwei Liu245d7912016-07-28 00:04:25 -0700244 if (m_options.isVerbose) {
245 std::cerr << "Received segment #" << recvSegNo
246 << ", rtt=" << rtt.count() << "ms"
247 << ", rto=" << segInfo.rto.count() << "ms" << std::endl;
248 }
249
Davide Pesavento958896e2017-01-19 00:52:04 -0500250 if (m_highData < recvSegNo) {
251 m_highData = recvSegNo;
252 }
253
254 // for segments in retx queue, we must not decrement m_nInFlight
255 // because it was already decremented when the segment timed out
256 if (segInfo.state != SegmentState::InRetxQueue) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700257 m_nInFlight--;
258 }
259
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000260 // upon finding congestion mark, decrease the window size
261 // without retransmitting any packet
262 if (data.getCongestionMark() > 0) {
263 m_nCongMarks++;
264 if (!m_options.ignoreCongMarks) {
265 if (m_options.disableCwa || m_highData > m_recPoint) {
266 m_recPoint = m_highInterest; // react to only one congestion event (timeout or congestion mark)
267 // per RTT (conservative window adaptation)
268 decreaseWindow();
269
270 if (m_options.isVerbose) {
271 std::cerr << "Received congestion mark, value = " << data.getCongestionMark()
272 << ", new cwnd = " << m_cwnd << std::endl;
273 }
274 }
275 }
276 else {
277 increaseWindow();
278 }
279 }
280 else {
281 increaseWindow();
282 }
283
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400284 onData(data);
Weiwei Liu245d7912016-07-28 00:04:25 -0700285
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500286 // do not sample RTT for retransmitted segments
287 if ((segInfo.state == SegmentState::FirstTimeSent ||
288 segInfo.state == SegmentState::InRetxQueue) &&
289 m_retxCount.count(recvSegNo) == 0) {
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500290 auto nExpectedSamples = std::max<int64_t>((m_nInFlight + 1) >> 1, 1);
291 BOOST_ASSERT(nExpectedSamples > 0);
292 m_rttEstimator.addMeasurement(recvSegNo, rtt, static_cast<size_t>(nExpectedSamples));
Weiwei Liu245d7912016-07-28 00:04:25 -0700293 }
294
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500295 // remove the entry associated with the received segment
296 m_segmentInfo.erase(segIt);
297
Ryan Wickman034f30f2018-06-06 11:11:11 -0500298 if (allSegmentsReceived()) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700299 cancel();
Davide Pesaventof6991e12018-01-08 20:58:50 -0500300 if (!m_options.isQuiet) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700301 printSummary();
302 }
303 }
304 else {
305 schedulePackets();
306 }
307}
308
309void
310PipelineInterestsAimd::handleNack(const Interest& interest, const lp::Nack& nack)
311{
312 if (isStopping())
313 return;
314
315 if (m_options.isVerbose)
316 std::cerr << "Received Nack with reason " << nack.getReason()
317 << " for Interest " << interest << std::endl;
318
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500319 uint64_t segNo = getSegmentFromPacket(interest);
Weiwei Liu245d7912016-07-28 00:04:25 -0700320
321 switch (nack.getReason()) {
Davide Pesavento958896e2017-01-19 00:52:04 -0500322 case lp::NackReason::DUPLICATE:
323 // ignore duplicates
Weiwei Liu245d7912016-07-28 00:04:25 -0700324 break;
Davide Pesavento958896e2017-01-19 00:52:04 -0500325 case lp::NackReason::CONGESTION:
326 // treated the same as timeout for now
327 enqueueForRetransmission(segNo);
328 recordTimeout();
329 schedulePackets();
330 break;
331 default:
Weiwei Liu245d7912016-07-28 00:04:25 -0700332 handleFail(segNo, "Could not retrieve data for " + interest.getName().toUri() +
333 ", reason: " + boost::lexical_cast<std::string>(nack.getReason()));
334 break;
Weiwei Liu245d7912016-07-28 00:04:25 -0700335 }
336}
337
338void
339PipelineInterestsAimd::handleLifetimeExpiration(const Interest& interest)
340{
341 if (isStopping())
342 return;
343
Davide Pesavento958896e2017-01-19 00:52:04 -0500344 enqueueForRetransmission(getSegmentFromPacket(interest));
345 recordTimeout();
346 schedulePackets();
Weiwei Liu245d7912016-07-28 00:04:25 -0700347}
348
349void
Davide Pesavento958896e2017-01-19 00:52:04 -0500350PipelineInterestsAimd::recordTimeout()
Weiwei Liu245d7912016-07-28 00:04:25 -0700351{
Weiwei Liu245d7912016-07-28 00:04:25 -0700352 if (m_options.disableCwa || m_highData > m_recPoint) {
353 // react to only one timeout per RTT (conservative window adaptation)
354 m_recPoint = m_highInterest;
355
356 decreaseWindow();
357 m_rttEstimator.backoffRto();
358 m_nLossEvents++;
359
360 if (m_options.isVerbose) {
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000361 std::cerr << "Packet loss event, new cwnd = " << m_cwnd
Weiwei Liu245d7912016-07-28 00:04:25 -0700362 << ", ssthresh = " << m_ssthresh << std::endl;
363 }
364 }
Davide Pesavento958896e2017-01-19 00:52:04 -0500365}
Weiwei Liu245d7912016-07-28 00:04:25 -0700366
Davide Pesavento958896e2017-01-19 00:52:04 -0500367void
368PipelineInterestsAimd::enqueueForRetransmission(uint64_t segNo)
369{
370 BOOST_ASSERT(m_nInFlight > 0);
371 m_nInFlight--;
372 m_retxQueue.push(segNo);
373 m_segmentInfo.at(segNo).state = SegmentState::InRetxQueue;
Weiwei Liu245d7912016-07-28 00:04:25 -0700374}
375
376void
377PipelineInterestsAimd::handleFail(uint64_t segNo, const std::string& reason)
378{
379 if (isStopping())
380 return;
381
382 // if the failed segment is definitely part of the content, raise a fatal error
383 if (m_hasFinalBlockId && segNo <= m_lastSegmentNo)
384 return onFailure(reason);
385
386 if (!m_hasFinalBlockId) {
387 m_segmentInfo.erase(segNo);
Davide Pesavento958896e2017-01-19 00:52:04 -0500388 m_nInFlight--;
Weiwei Liu245d7912016-07-28 00:04:25 -0700389
390 if (m_segmentInfo.empty()) {
391 onFailure("Fetching terminated but no final segment number has been found");
392 }
393 else {
394 cancelInFlightSegmentsGreaterThan(segNo);
395 m_hasFailure = true;
396 m_failedSegNo = segNo;
397 m_failureReason = reason;
398 }
399 }
400}
401
402void
403PipelineInterestsAimd::increaseWindow()
404{
405 if (m_cwnd < m_ssthresh) {
406 m_cwnd += m_options.aiStep; // additive increase
Chavoosh Ghasemi4d36ed52017-10-31 22:26:25 +0000407 }
408 else {
Weiwei Liu245d7912016-07-28 00:04:25 -0700409 m_cwnd += m_options.aiStep / std::floor(m_cwnd); // congestion avoidance
410 }
Davide Pesavento958896e2017-01-19 00:52:04 -0500411
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500412 afterCwndChange(time::steady_clock::now() - getStartTime(), m_cwnd);
Weiwei Liu245d7912016-07-28 00:04:25 -0700413}
414
415void
416PipelineInterestsAimd::decreaseWindow()
417{
418 // please refer to RFC 5681, Section 3.1 for the rationale behind it
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000419 m_ssthresh = std::max(MIN_SSTHRESH, m_cwnd * m_options.mdCoef); // multiplicative decrease
Weiwei Liu245d7912016-07-28 00:04:25 -0700420 m_cwnd = m_options.resetCwndToInit ? m_options.initCwnd : m_ssthresh;
Davide Pesavento958896e2017-01-19 00:52:04 -0500421
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500422 afterCwndChange(time::steady_clock::now() - getStartTime(), m_cwnd);
Weiwei Liu245d7912016-07-28 00:04:25 -0700423}
424
Weiwei Liu245d7912016-07-28 00:04:25 -0700425void
Davide Pesavento958896e2017-01-19 00:52:04 -0500426PipelineInterestsAimd::cancelInFlightSegmentsGreaterThan(uint64_t segNo)
Weiwei Liu245d7912016-07-28 00:04:25 -0700427{
428 for (auto it = m_segmentInfo.begin(); it != m_segmentInfo.end();) {
429 // cancel fetching all segments that follow
Davide Pesavento958896e2017-01-19 00:52:04 -0500430 if (it->first > segNo) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700431 m_face.removePendingInterest(it->second.interestId);
432 it = m_segmentInfo.erase(it);
Davide Pesavento958896e2017-01-19 00:52:04 -0500433 m_nInFlight--;
Weiwei Liu245d7912016-07-28 00:04:25 -0700434 }
435 else {
436 ++it;
437 }
438 }
439}
440
441void
442PipelineInterestsAimd::printSummary() const
443{
Chavoosh Ghasemi4d36ed52017-10-31 22:26:25 +0000444 PipelineInterests::printSummary();
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -0400445 std::cerr << "Total # of lost/retransmitted segments: " << m_nRetransmitted
446 << " (caused " << m_nLossEvents << " window decreases)\n"
Weiwei Liu245d7912016-07-28 00:04:25 -0700447 << "Packet loss rate: "
Ryan Wickman034f30f2018-06-06 11:11:11 -0500448 << (m_nSent == 0 ? 0 : (static_cast<double>(m_nRetransmitted) / static_cast<double>(m_nSent) * 100)) << "%\n"
Chavoosh Ghasemi3dae1092017-12-21 12:39:08 -0700449 << "Total # of received congestion marks: " << m_nCongMarks << "\n"
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -0400450 << "RTT ";
451
452 if (m_rttEstimator.getMinRtt() == std::numeric_limits<double>::max() ||
453 m_rttEstimator.getMaxRtt() == std::numeric_limits<double>::min()) {
454 std::cerr << "stats unavailable\n";
455 }
456 else {
457 std::cerr << "min/avg/max = " << std::fixed << std::setprecision(3)
458 << m_rttEstimator.getMinRtt() << "/"
459 << m_rttEstimator.getAvgRtt() << "/"
460 << m_rttEstimator.getMaxRtt() << " ms\n";
461 }
Weiwei Liu245d7912016-07-28 00:04:25 -0700462}
463
464std::ostream&
465operator<<(std::ostream& os, SegmentState state)
466{
467 switch (state) {
468 case SegmentState::FirstTimeSent:
469 os << "FirstTimeSent";
470 break;
471 case SegmentState::InRetxQueue:
472 os << "InRetxQueue";
473 break;
474 case SegmentState::Retransmitted:
475 os << "Retransmitted";
476 break;
Weiwei Liu245d7912016-07-28 00:04:25 -0700477 }
Weiwei Liu245d7912016-07-28 00:04:25 -0700478 return os;
479}
480
481std::ostream&
482operator<<(std::ostream& os, const PipelineInterestsAimdOptions& options)
483{
Davide Pesavento44b3b232017-12-23 16:58:25 -0500484 os << "AIMD pipeline parameters:\n"
Weiwei Liu245d7912016-07-28 00:04:25 -0700485 << "\tInitial congestion window size = " << options.initCwnd << "\n"
486 << "\tInitial slow start threshold = " << options.initSsthresh << "\n"
Weiwei Liu245d7912016-07-28 00:04:25 -0700487 << "\tAdditive increase step = " << options.aiStep << "\n"
Davide Pesavento958896e2017-01-19 00:52:04 -0500488 << "\tMultiplicative decrease factor = " << options.mdCoef << "\n"
Weiwei Liu245d7912016-07-28 00:04:25 -0700489 << "\tRTO check interval = " << options.rtoCheckInterval << "\n"
Davide Pesavento44b3b232017-12-23 16:58:25 -0500490 << "\tMax retries on timeout or Nack = " << (options.maxRetriesOnTimeoutOrNack == DataFetcher::MAX_RETRIES_INFINITE ?
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500491 "infinite" : to_string(options.maxRetriesOnTimeoutOrNack)) << "\n"
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000492 << "\tReaction to congestion marks " << (options.ignoreCongMarks ? "disabled" : "enabled") << "\n"
Davide Pesavento44b3b232017-12-23 16:58:25 -0500493 << "\tConservative window adaptation " << (options.disableCwa ? "disabled" : "enabled") << "\n"
Davide Pesavento958896e2017-01-19 00:52:04 -0500494 << "\tResetting cwnd to " << (options.resetCwndToInit ? "initCwnd" : "ssthresh") << " upon loss event\n";
Weiwei Liu245d7912016-07-28 00:04:25 -0700495 return os;
496}
497
498} // namespace aimd
499} // namespace chunks
500} // namespace ndn