blob: 3b3e0cde471265f1d185735b80bb4813f7ede3d5 [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/*
Davide Pesaventob3570c62022-02-19 19:19:00 -05003 * Copyright (c) 2016-2022, 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
schneiderklausd8197df2019-03-16 11:31:40 -070026 * @author Klaus Schneider
Weiwei Liu245d7912016-07-28 00:04:25 -070027 */
28
schneiderklausd8197df2019-03-16 11:31:40 -070029#include "pipeline-interests-adaptive.hpp"
Davide Pesavento44b3b232017-12-23 16:58:25 -050030#include "data-fetcher.hpp"
Weiwei Liu245d7912016-07-28 00:04:25 -070031
32#include <cmath>
Chavoosh Ghasemi3dae1092017-12-21 12:39:08 -070033#include <iomanip>
Weiwei Liu245d7912016-07-28 00:04:25 -070034
Davide Pesaventob3570c62022-02-19 19:19:00 -050035namespace ndn::chunks {
Weiwei Liu245d7912016-07-28 00:04:25 -070036
schneiderklausd8197df2019-03-16 11:31:40 -070037constexpr double PipelineInterestsAdaptive::MIN_SSTHRESH;
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +000038
Davide Pesavento5e3773d2019-08-22 15:35:08 -040039PipelineInterestsAdaptive::PipelineInterestsAdaptive(Face& face,
40 RttEstimatorWithStats& rttEstimator,
Davide Pesavento97a33b22019-10-17 22:10:47 -040041 const Options& opts)
42 : PipelineInterests(face, opts)
Klaus Schneider9e5122b2019-03-19 17:03:25 -070043 , m_cwnd(m_options.initCwnd)
44 , m_ssthresh(m_options.initSsthresh)
Weiwei Liu245d7912016-07-28 00:04:25 -070045 , m_rttEstimator(rttEstimator)
46 , m_scheduler(m_face.getIoService())
Weiwei Liu245d7912016-07-28 00:04:25 -070047{
Weiwei Liu245d7912016-07-28 00:04:25 -070048}
49
schneiderklausd8197df2019-03-16 11:31:40 -070050PipelineInterestsAdaptive::~PipelineInterestsAdaptive()
Weiwei Liu245d7912016-07-28 00:04:25 -070051{
52 cancel();
53}
54
55void
schneiderklausd8197df2019-03-16 11:31:40 -070056PipelineInterestsAdaptive::doRun()
Weiwei Liu245d7912016-07-28 00:04:25 -070057{
Ryan Wickman034f30f2018-06-06 11:11:11 -050058 if (allSegmentsReceived()) {
59 cancel();
60 if (!m_options.isQuiet) {
61 printSummary();
62 }
63 return;
64 }
65
Weiwei Liu245d7912016-07-28 00:04:25 -070066 // schedule the event to check retransmission timer
Davide Pesaventobf2c5172019-03-20 19:08:09 -040067 m_checkRtoEvent = m_scheduler.schedule(m_options.rtoCheckInterval, [this] { checkRto(); });
Weiwei Liu245d7912016-07-28 00:04:25 -070068
Davide Pesavento958896e2017-01-19 00:52:04 -050069 schedulePackets();
Weiwei Liu245d7912016-07-28 00:04:25 -070070}
71
72void
schneiderklausd8197df2019-03-16 11:31:40 -070073PipelineInterestsAdaptive::doCancel()
Weiwei Liu245d7912016-07-28 00:04:25 -070074{
Davide Pesaventocd65c2c2017-01-15 16:10:38 -050075 m_checkRtoEvent.cancel();
Weiwei Liu245d7912016-07-28 00:04:25 -070076 m_segmentInfo.clear();
Weiwei Liu245d7912016-07-28 00:04:25 -070077}
78
79void
schneiderklausd8197df2019-03-16 11:31:40 -070080PipelineInterestsAdaptive::checkRto()
Weiwei Liu245d7912016-07-28 00:04:25 -070081{
82 if (isStopping())
83 return;
84
Davide Pesavento958896e2017-01-19 00:52:04 -050085 bool hasTimeout = false;
Weiwei Liu245d7912016-07-28 00:04:25 -070086
87 for (auto& entry : m_segmentInfo) {
88 SegmentInfo& segInfo = entry.second;
Ryan Wickman2c9933c2018-06-12 11:51:51 -050089 if (segInfo.state != SegmentState::InRetxQueue) { // skip segments already in the retx queue
Davide Pesavento70576402019-06-07 16:42:21 -040090 auto timeElapsed = time::steady_clock::now() - segInfo.timeSent;
91 if (timeElapsed > segInfo.rto) { // timer expired?
schneiderklaus8ff3abd2019-03-12 22:15:12 -070092 m_nTimeouts++;
Davide Pesavento958896e2017-01-19 00:52:04 -050093 hasTimeout = true;
94 enqueueForRetransmission(entry.first);
Weiwei Liu245d7912016-07-28 00:04:25 -070095 }
96 }
97 }
98
Davide Pesavento958896e2017-01-19 00:52:04 -050099 if (hasTimeout) {
100 recordTimeout();
101 schedulePackets();
Weiwei Liu245d7912016-07-28 00:04:25 -0700102 }
103
104 // schedule the next check after predefined interval
Davide Pesaventobf2c5172019-03-20 19:08:09 -0400105 m_checkRtoEvent = m_scheduler.schedule(m_options.rtoCheckInterval, [this] { checkRto(); });
Weiwei Liu245d7912016-07-28 00:04:25 -0700106}
107
108void
schneiderklausd8197df2019-03-16 11:31:40 -0700109PipelineInterestsAdaptive::sendInterest(uint64_t segNo, bool isRetransmission)
Weiwei Liu245d7912016-07-28 00:04:25 -0700110{
111 if (isStopping())
112 return;
113
Ryan Wickman034f30f2018-06-06 11:11:11 -0500114 if (m_hasFinalBlockId && segNo > m_lastSegmentNo)
Weiwei Liu245d7912016-07-28 00:04:25 -0700115 return;
116
117 if (!isRetransmission && m_hasFailure)
118 return;
119
120 if (m_options.isVerbose) {
Davide Pesavento958896e2017-01-19 00:52:04 -0500121 std::cerr << (isRetransmission ? "Retransmitting" : "Requesting")
Davide Pesaventof8d9a532021-07-03 16:04:12 -0400122 << " segment #" << segNo << "\n";
Weiwei Liu245d7912016-07-28 00:04:25 -0700123 }
124
125 if (isRetransmission) {
Davide Pesavento958896e2017-01-19 00:52:04 -0500126 // keep track of retx count for this segment
127 auto ret = m_retxCount.emplace(segNo, 1);
Davide Pesaventob3570c62022-02-19 19:19:00 -0500128 if (!ret.second) { // not the first retransmission
Weiwei Liu245d7912016-07-28 00:04:25 -0700129 m_retxCount[segNo] += 1;
Davide Pesavento44b3b232017-12-23 16:58:25 -0500130 if (m_options.maxRetriesOnTimeoutOrNack != DataFetcher::MAX_RETRIES_INFINITE &&
131 m_retxCount[segNo] > m_options.maxRetriesOnTimeoutOrNack) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700132 return handleFail(segNo, "Reached the maximum number of retries (" +
133 to_string(m_options.maxRetriesOnTimeoutOrNack) +
134 ") while retrieving segment #" + to_string(segNo));
135 }
136
137 if (m_options.isVerbose) {
138 std::cerr << "# of retries for segment #" << segNo
Davide Pesaventof8d9a532021-07-03 16:04:12 -0400139 << " is " << m_retxCount[segNo] << "\n";
Weiwei Liu245d7912016-07-28 00:04:25 -0700140 }
141 }
Weiwei Liu245d7912016-07-28 00:04:25 -0700142 }
143
Davide Pesavento84d84772019-04-07 14:40:07 -0400144 auto interest = Interest()
145 .setName(Name(m_prefix).appendSegment(segNo))
Davide Pesavento84d84772019-04-07 14:40:07 -0400146 .setMustBeFresh(m_options.mustBeFresh)
147 .setInterestLifetime(m_options.interestLifetime);
Weiwei Liu245d7912016-07-28 00:04:25 -0700148
Junxiao Shi06d008c2019-02-04 08:26:59 +0000149 SegmentInfo& segInfo = m_segmentInfo[segNo];
150 segInfo.interestHdl = m_face.expressInterest(interest,
Davide Pesaventof8d9a532021-07-03 16:04:12 -0400151 FORWARD_TO_MEM_FN(handleData),
152 FORWARD_TO_MEM_FN(handleNack),
153 FORWARD_TO_MEM_FN(handleLifetimeExpiration));
Junxiao Shi06d008c2019-02-04 08:26:59 +0000154 segInfo.timeSent = time::steady_clock::now();
155 segInfo.rto = m_rttEstimator.getEstimatedRto();
156
Weiwei Liu245d7912016-07-28 00:04:25 -0700157 m_nInFlight++;
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -0400158 m_nSent++;
Weiwei Liu245d7912016-07-28 00:04:25 -0700159
160 if (isRetransmission) {
Davide Pesavento958896e2017-01-19 00:52:04 -0500161 segInfo.state = SegmentState::Retransmitted;
Weiwei Liu245d7912016-07-28 00:04:25 -0700162 m_nRetransmitted++;
163 }
164 else {
165 m_highInterest = segNo;
Junxiao Shi06d008c2019-02-04 08:26:59 +0000166 segInfo.state = SegmentState::FirstTimeSent;
Weiwei Liu245d7912016-07-28 00:04:25 -0700167 }
168}
169
170void
schneiderklausd8197df2019-03-16 11:31:40 -0700171PipelineInterestsAdaptive::schedulePackets()
Weiwei Liu245d7912016-07-28 00:04:25 -0700172{
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500173 BOOST_ASSERT(m_nInFlight >= 0);
174 auto availableWindowSize = static_cast<int64_t>(m_cwnd) - m_nInFlight;
175
Weiwei Liu245d7912016-07-28 00:04:25 -0700176 while (availableWindowSize > 0) {
177 if (!m_retxQueue.empty()) { // do retransmission first
178 uint64_t retxSegNo = m_retxQueue.front();
179 m_retxQueue.pop();
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500180 if (m_segmentInfo.count(retxSegNo) == 0) {
schneiderklaus8ff3abd2019-03-12 22:15:12 -0700181 m_nSkippedRetx++;
Weiwei Liu245d7912016-07-28 00:04:25 -0700182 continue;
183 }
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500184 // the segment is still in the map, that means it needs to be retransmitted
Weiwei Liu245d7912016-07-28 00:04:25 -0700185 sendInterest(retxSegNo, true);
186 }
187 else { // send next segment
188 sendInterest(getNextSegmentNo(), false);
189 }
190 availableWindowSize--;
191 }
192}
193
194void
schneiderklausd8197df2019-03-16 11:31:40 -0700195PipelineInterestsAdaptive::handleData(const Interest& interest, const Data& data)
Weiwei Liu245d7912016-07-28 00:04:25 -0700196{
197 if (isStopping())
198 return;
199
Davide Pesavento84d84772019-04-07 14:40:07 -0400200 // Interest was expressed with CanBePrefix=false
Weiwei Liu245d7912016-07-28 00:04:25 -0700201 BOOST_ASSERT(data.getName().equals(interest.getName()));
202
Davide Pesavento969cd5a2018-04-20 16:27:47 -0400203 if (!m_hasFinalBlockId && data.getFinalBlock()) {
204 m_lastSegmentNo = data.getFinalBlock()->toSegment();
Weiwei Liu245d7912016-07-28 00:04:25 -0700205 m_hasFinalBlockId = true;
206 cancelInFlightSegmentsGreaterThan(m_lastSegmentNo);
207 if (m_hasFailure && m_lastSegmentNo >= m_failedSegNo) {
208 // previously failed segment is part of the content
209 return onFailure(m_failureReason);
Chavoosh Ghasemi4d36ed52017-10-31 22:26:25 +0000210 }
211 else {
Weiwei Liu245d7912016-07-28 00:04:25 -0700212 m_hasFailure = false;
213 }
214 }
215
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500216 uint64_t recvSegNo = getSegmentFromPacket(data);
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500217 auto segIt = m_segmentInfo.find(recvSegNo);
218 if (segIt == m_segmentInfo.end()) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700219 return; // ignore already-received segment
220 }
221
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500222 SegmentInfo& segInfo = segIt->second;
Davide Pesaventoba560662019-06-26 22:45:44 -0400223 time::nanoseconds rtt = time::steady_clock::now() - segInfo.timeSent;
Weiwei Liu245d7912016-07-28 00:04:25 -0700224 if (m_options.isVerbose) {
225 std::cerr << "Received segment #" << recvSegNo
Davide Pesaventoba560662019-06-26 22:45:44 -0400226 << ", rtt=" << rtt.count() / 1e6 << "ms"
Davide Pesaventof8d9a532021-07-03 16:04:12 -0400227 << ", rto=" << segInfo.rto.count() / 1e6 << "ms\n";
Weiwei Liu245d7912016-07-28 00:04:25 -0700228 }
229
Davide Pesavento958896e2017-01-19 00:52:04 -0500230 if (m_highData < recvSegNo) {
231 m_highData = recvSegNo;
232 }
233
234 // for segments in retx queue, we must not decrement m_nInFlight
235 // because it was already decremented when the segment timed out
236 if (segInfo.state != SegmentState::InRetxQueue) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700237 m_nInFlight--;
238 }
239
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000240 // upon finding congestion mark, decrease the window size
241 // without retransmitting any packet
242 if (data.getCongestionMark() > 0) {
243 m_nCongMarks++;
244 if (!m_options.ignoreCongMarks) {
245 if (m_options.disableCwa || m_highData > m_recPoint) {
246 m_recPoint = m_highInterest; // react to only one congestion event (timeout or congestion mark)
247 // per RTT (conservative window adaptation)
schneiderklaus8ff3abd2019-03-12 22:15:12 -0700248 m_nMarkDecr++;
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000249 decreaseWindow();
250
251 if (m_options.isVerbose) {
252 std::cerr << "Received congestion mark, value = " << data.getCongestionMark()
Davide Pesaventof8d9a532021-07-03 16:04:12 -0400253 << ", new cwnd = " << m_cwnd << "\n";
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000254 }
255 }
256 }
257 else {
258 increaseWindow();
259 }
260 }
261 else {
262 increaseWindow();
263 }
264
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400265 onData(data);
Weiwei Liu245d7912016-07-28 00:04:25 -0700266
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500267 // do not sample RTT for retransmitted segments
268 if ((segInfo.state == SegmentState::FirstTimeSent ||
269 segInfo.state == SegmentState::InRetxQueue) &&
270 m_retxCount.count(recvSegNo) == 0) {
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500271 auto nExpectedSamples = std::max<int64_t>((m_nInFlight + 1) >> 1, 1);
272 BOOST_ASSERT(nExpectedSamples > 0);
Davide Pesavento5e3773d2019-08-22 15:35:08 -0400273 m_rttEstimator.addMeasurement(rtt, static_cast<size_t>(nExpectedSamples));
274 afterRttMeasurement({recvSegNo, rtt,
275 m_rttEstimator.getSmoothedRtt(),
276 m_rttEstimator.getRttVariation(),
277 m_rttEstimator.getEstimatedRto()});
Weiwei Liu245d7912016-07-28 00:04:25 -0700278 }
279
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500280 // remove the entry associated with the received segment
281 m_segmentInfo.erase(segIt);
282
Ryan Wickman034f30f2018-06-06 11:11:11 -0500283 if (allSegmentsReceived()) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700284 cancel();
Davide Pesaventof6991e12018-01-08 20:58:50 -0500285 if (!m_options.isQuiet) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700286 printSummary();
287 }
288 }
289 else {
290 schedulePackets();
291 }
292}
293
294void
schneiderklausd8197df2019-03-16 11:31:40 -0700295PipelineInterestsAdaptive::handleNack(const Interest& interest, const lp::Nack& nack)
Weiwei Liu245d7912016-07-28 00:04:25 -0700296{
297 if (isStopping())
298 return;
299
300 if (m_options.isVerbose)
301 std::cerr << "Received Nack with reason " << nack.getReason()
Davide Pesaventof8d9a532021-07-03 16:04:12 -0400302 << " for Interest " << interest << "\n";
Weiwei Liu245d7912016-07-28 00:04:25 -0700303
Davide Pesaventobf1c0692017-01-15 19:15:09 -0500304 uint64_t segNo = getSegmentFromPacket(interest);
Weiwei Liu245d7912016-07-28 00:04:25 -0700305
306 switch (nack.getReason()) {
Davide Pesavento958896e2017-01-19 00:52:04 -0500307 case lp::NackReason::DUPLICATE:
308 // ignore duplicates
Weiwei Liu245d7912016-07-28 00:04:25 -0700309 break;
Davide Pesavento958896e2017-01-19 00:52:04 -0500310 case lp::NackReason::CONGESTION:
311 // treated the same as timeout for now
312 enqueueForRetransmission(segNo);
313 recordTimeout();
314 schedulePackets();
315 break;
316 default:
Weiwei Liu245d7912016-07-28 00:04:25 -0700317 handleFail(segNo, "Could not retrieve data for " + interest.getName().toUri() +
318 ", reason: " + boost::lexical_cast<std::string>(nack.getReason()));
319 break;
Weiwei Liu245d7912016-07-28 00:04:25 -0700320 }
321}
322
323void
schneiderklausd8197df2019-03-16 11:31:40 -0700324PipelineInterestsAdaptive::handleLifetimeExpiration(const Interest& interest)
Weiwei Liu245d7912016-07-28 00:04:25 -0700325{
326 if (isStopping())
327 return;
328
schneiderklaus8ff3abd2019-03-12 22:15:12 -0700329 m_nTimeouts++;
Davide Pesavento958896e2017-01-19 00:52:04 -0500330 enqueueForRetransmission(getSegmentFromPacket(interest));
331 recordTimeout();
332 schedulePackets();
Weiwei Liu245d7912016-07-28 00:04:25 -0700333}
334
335void
schneiderklausd8197df2019-03-16 11:31:40 -0700336PipelineInterestsAdaptive::recordTimeout()
Weiwei Liu245d7912016-07-28 00:04:25 -0700337{
Weiwei Liu245d7912016-07-28 00:04:25 -0700338 if (m_options.disableCwa || m_highData > m_recPoint) {
339 // react to only one timeout per RTT (conservative window adaptation)
340 m_recPoint = m_highInterest;
341
342 decreaseWindow();
343 m_rttEstimator.backoffRto();
schneiderklaus8ff3abd2019-03-12 22:15:12 -0700344 m_nLossDecr++;
Weiwei Liu245d7912016-07-28 00:04:25 -0700345
346 if (m_options.isVerbose) {
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000347 std::cerr << "Packet loss event, new cwnd = " << m_cwnd
Davide Pesaventof8d9a532021-07-03 16:04:12 -0400348 << ", ssthresh = " << m_ssthresh << "\n";
Weiwei Liu245d7912016-07-28 00:04:25 -0700349 }
350 }
Davide Pesavento958896e2017-01-19 00:52:04 -0500351}
Weiwei Liu245d7912016-07-28 00:04:25 -0700352
Davide Pesavento958896e2017-01-19 00:52:04 -0500353void
schneiderklausd8197df2019-03-16 11:31:40 -0700354PipelineInterestsAdaptive::enqueueForRetransmission(uint64_t segNo)
Davide Pesavento958896e2017-01-19 00:52:04 -0500355{
356 BOOST_ASSERT(m_nInFlight > 0);
357 m_nInFlight--;
358 m_retxQueue.push(segNo);
359 m_segmentInfo.at(segNo).state = SegmentState::InRetxQueue;
Weiwei Liu245d7912016-07-28 00:04:25 -0700360}
361
362void
schneiderklausd8197df2019-03-16 11:31:40 -0700363PipelineInterestsAdaptive::handleFail(uint64_t segNo, const std::string& reason)
Weiwei Liu245d7912016-07-28 00:04:25 -0700364{
365 if (isStopping())
366 return;
367
368 // if the failed segment is definitely part of the content, raise a fatal error
369 if (m_hasFinalBlockId && segNo <= m_lastSegmentNo)
370 return onFailure(reason);
371
372 if (!m_hasFinalBlockId) {
373 m_segmentInfo.erase(segNo);
Davide Pesavento958896e2017-01-19 00:52:04 -0500374 m_nInFlight--;
Weiwei Liu245d7912016-07-28 00:04:25 -0700375
376 if (m_segmentInfo.empty()) {
377 onFailure("Fetching terminated but no final segment number has been found");
378 }
379 else {
380 cancelInFlightSegmentsGreaterThan(segNo);
381 m_hasFailure = true;
382 m_failedSegNo = segNo;
383 m_failureReason = reason;
384 }
385 }
386}
387
388void
schneiderklausd8197df2019-03-16 11:31:40 -0700389PipelineInterestsAdaptive::cancelInFlightSegmentsGreaterThan(uint64_t segNo)
Weiwei Liu245d7912016-07-28 00:04:25 -0700390{
391 for (auto it = m_segmentInfo.begin(); it != m_segmentInfo.end();) {
392 // cancel fetching all segments that follow
Davide Pesavento958896e2017-01-19 00:52:04 -0500393 if (it->first > segNo) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700394 it = m_segmentInfo.erase(it);
Davide Pesavento958896e2017-01-19 00:52:04 -0500395 m_nInFlight--;
Weiwei Liu245d7912016-07-28 00:04:25 -0700396 }
397 else {
398 ++it;
399 }
400 }
401}
402
403void
Davide Pesavento97a33b22019-10-17 22:10:47 -0400404PipelineInterestsAdaptive::printOptions() const
405{
406 PipelineInterests::printOptions();
407 std::cerr
408 << "\tInitial congestion window size = " << m_options.initCwnd << "\n"
409 << "\tInitial slow start threshold = " << m_options.initSsthresh << "\n"
410 << "\tAdditive increase step = " << m_options.aiStep << "\n"
411 << "\tMultiplicative decrease factor = " << m_options.mdCoef << "\n"
412 << "\tRTO check interval = " << m_options.rtoCheckInterval << "\n"
413 << "\tReact to congestion marks = " << (m_options.ignoreCongMarks ? "no" : "yes") << "\n"
414 << "\tConservative window adaptation = " << (m_options.disableCwa ? "no" : "yes") << "\n"
415 << "\tResetting window to " << (m_options.resetCwndToInit ?
416 "initial value" : "ssthresh") << " upon loss event\n";
417}
418
419void
schneiderklausd8197df2019-03-16 11:31:40 -0700420PipelineInterestsAdaptive::printSummary() const
Weiwei Liu245d7912016-07-28 00:04:25 -0700421{
Chavoosh Ghasemi4d36ed52017-10-31 22:26:25 +0000422 PipelineInterests::printSummary();
schneiderklaus8ff3abd2019-03-12 22:15:12 -0700423 std::cerr << "Congestion marks: " << m_nCongMarks << " (caused " << m_nMarkDecr << " window decreases)\n"
424 << "Timeouts: " << m_nTimeouts << " (caused " << m_nLossDecr << " window decreases)\n"
425 << "Retransmitted segments: " << m_nRetransmitted
Davide Pesaventoba560662019-06-26 22:45:44 -0400426 << " (" << (m_nSent == 0 ? 0 : (m_nRetransmitted * 100.0 / m_nSent)) << "%)"
schneiderklaus8ff3abd2019-03-12 22:15:12 -0700427 << ", skipped: " << m_nSkippedRetx << "\n"
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -0400428 << "RTT ";
429
Davide Pesaventoba560662019-06-26 22:45:44 -0400430 if (m_rttEstimator.getMinRtt() == time::nanoseconds::max() ||
431 m_rttEstimator.getMaxRtt() == time::nanoseconds::min()) {
Davide Pesavento70576402019-06-07 16:42:21 -0400432 std::cerr << "stats unavailable\n";
433 }
434 else {
435 std::cerr << "min/avg/max = " << std::fixed << std::setprecision(3)
Davide Pesaventoba560662019-06-26 22:45:44 -0400436 << m_rttEstimator.getMinRtt().count() / 1e6 << "/"
437 << m_rttEstimator.getAvgRtt().count() / 1e6 << "/"
438 << m_rttEstimator.getMaxRtt().count() / 1e6 << " ms\n";
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -0400439 }
Weiwei Liu245d7912016-07-28 00:04:25 -0700440}
441
442std::ostream&
443operator<<(std::ostream& os, SegmentState state)
444{
445 switch (state) {
446 case SegmentState::FirstTimeSent:
447 os << "FirstTimeSent";
448 break;
449 case SegmentState::InRetxQueue:
450 os << "InRetxQueue";
451 break;
452 case SegmentState::Retransmitted:
453 os << "Retransmitted";
454 break;
Weiwei Liu245d7912016-07-28 00:04:25 -0700455 }
Weiwei Liu245d7912016-07-28 00:04:25 -0700456 return os;
457}
458
Davide Pesaventob3570c62022-02-19 19:19:00 -0500459} // namespace ndn::chunks