blob: 4688ee4f6d681de667a326996a90684a3633bfa7 [file] [log] [blame]
Weiwei Liu245d7912016-07-28 00:04:25 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesaventoe9c69852017-11-04 18:08:37 -04002/*
Davide Pesavento5748e822024-01-26 18:40:22 -05003 * Copyright (c) 2016-2024, Regents of the University of California,
Davide Pesavento958896e2017-01-19 00:52:04 -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 Weiwei Liu
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +000024 * @author Chavoosh Ghasemi
schneiderklausd8197df2019-03-16 11:31:40 -070025 * @author Klaus Schneider
Weiwei Liu245d7912016-07-28 00:04:25 -070026 */
27
Klaus Schneider9e5122b2019-03-19 17:03:25 -070028#include "tools/chunks/catchunks/pipeline-interests-aimd.hpp"
Weiwei Liu245d7912016-07-28 00:04:25 -070029
30#include "pipeline-interests-fixture.hpp"
31
Davide Pesavento5748e822024-01-26 18:40:22 -050032#include <cmath>
33
Davide Pesaventob3570c62022-02-19 19:19:00 -050034namespace ndn::chunks::tests {
Weiwei Liu245d7912016-07-28 00:04:25 -070035
36using namespace ndn::tests;
37
Klaus Schneider9e5122b2019-03-19 17:03:25 -070038class PipelineInterestAimdFixture : public PipelineInterestsFixture
Weiwei Liu245d7912016-07-28 00:04:25 -070039{
Davide Pesaventob3570c62022-02-19 19:19:00 -050040protected:
Klaus Schneider9e5122b2019-03-19 17:03:25 -070041 PipelineInterestAimdFixture()
Weiwei Liu245d7912016-07-28 00:04:25 -070042 {
Davide Pesavento97a33b22019-10-17 22:10:47 -040043 opt.isQuiet = true;
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +000044 createPipeline();
45 }
46
47 void
48 createPipeline()
49 {
Davide Pesavento5748e822024-01-26 18:40:22 -050050 auto pline = std::make_unique<PipelineInterestsAimd>(face, rttEstimator, opt);
schneiderklausd8197df2019-03-16 11:31:40 -070051 pipeline = pline.get();
Weiwei Liu245d7912016-07-28 00:04:25 -070052 setPipeline(std::move(pline));
53 }
54
55private:
Davide Pesavento5748e822024-01-26 18:40:22 -050056 static std::shared_ptr<RttEstimatorWithStats::Options>
Weiwei Liu245d7912016-07-28 00:04:25 -070057 makeRttEstimatorOptions()
58 {
Davide Pesavento5748e822024-01-26 18:40:22 -050059 auto rttOptions = std::make_shared<RttEstimatorWithStats::Options>();
Davide Pesavento5e3773d2019-08-22 15:35:08 -040060 rttOptions->alpha = 0.125;
61 rttOptions->beta = 0.25;
62 rttOptions->k = 4;
63 rttOptions->initialRto = 1_s;
64 rttOptions->minRto = 200_ms;
65 rttOptions->maxRto = 4_s;
66 rttOptions->rtoBackoffMultiplier = 2;
Weiwei Liu245d7912016-07-28 00:04:25 -070067 return rttOptions;
68 }
69
70protected:
Davide Pesavento97a33b22019-10-17 22:10:47 -040071 Options opt;
Davide Pesaventob3570c62022-02-19 19:19:00 -050072 RttEstimatorWithStats rttEstimator{makeRttEstimatorOptions()};
schneiderklausd8197df2019-03-16 11:31:40 -070073 PipelineInterestsAdaptive* pipeline;
Davide Pesaventoba560662019-06-26 22:45:44 -040074 static constexpr double MARGIN = 0.001;
Weiwei Liu245d7912016-07-28 00:04:25 -070075};
76
77BOOST_AUTO_TEST_SUITE(Chunks)
Klaus Schneider9e5122b2019-03-19 17:03:25 -070078BOOST_FIXTURE_TEST_SUITE(TestPipelineInterestsAimd, PipelineInterestAimdFixture)
Weiwei Liu245d7912016-07-28 00:04:25 -070079
80BOOST_AUTO_TEST_CASE(SlowStart)
81{
82 nDataSegments = 4;
schneiderklausd8197df2019-03-16 11:31:40 -070083 pipeline->m_ssthresh = 8.0;
Klaus Schneider4a2e89d2019-10-27 10:04:39 -070084 BOOST_REQUIRE_CLOSE(pipeline->m_cwnd, 2, MARGIN);
Weiwei Liu245d7912016-07-28 00:04:25 -070085
schneiderklausd8197df2019-03-16 11:31:40 -070086 double preCwnd = pipeline->m_cwnd;
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -080087 run(name);
Davide Pesavento66777622020-10-09 18:46:03 -040088 advanceClocks(time::nanoseconds(1));
Klaus Schneider4a2e89d2019-10-27 10:04:39 -070089 BOOST_CHECK_EQUAL(face.sentInterests.size(), 2);
Weiwei Liu245d7912016-07-28 00:04:25 -070090
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -080091 for (uint64_t i = 0; i < nDataSegments - 1; ++i) {
Weiwei Liu245d7912016-07-28 00:04:25 -070092 face.receive(*makeDataWithSegment(i));
Davide Pesavento66777622020-10-09 18:46:03 -040093 advanceClocks(time::nanoseconds(1));
schneiderklausd8197df2019-03-16 11:31:40 -070094 BOOST_CHECK_CLOSE(pipeline->m_cwnd - preCwnd, 1, MARGIN);
95 preCwnd = pipeline->m_cwnd;
Weiwei Liu245d7912016-07-28 00:04:25 -070096 }
Davide Pesaventoe9c69852017-11-04 18:08:37 -040097
98 BOOST_CHECK_EQUAL(pipeline->m_nReceived, nDataSegments - 1);
Weiwei Liu245d7912016-07-28 00:04:25 -070099}
100
101BOOST_AUTO_TEST_CASE(CongestionAvoidance)
102{
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800103 nDataSegments = 7;
schneiderklausd8197df2019-03-16 11:31:40 -0700104 pipeline->m_ssthresh = 4.0;
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700105 BOOST_REQUIRE_CLOSE(pipeline->m_cwnd, 2, MARGIN);
Weiwei Liu245d7912016-07-28 00:04:25 -0700106
schneiderklausd8197df2019-03-16 11:31:40 -0700107 double preCwnd = pipeline->m_cwnd;
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800108 run(name);
Davide Pesavento66777622020-10-09 18:46:03 -0400109 advanceClocks(time::nanoseconds(1));
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700110 BOOST_CHECK_EQUAL(face.sentInterests.size(), 2);
Weiwei Liu245d7912016-07-28 00:04:25 -0700111
schneiderklausd8197df2019-03-16 11:31:40 -0700112 for (uint64_t i = 0; i < pipeline->m_ssthresh; ++i) { // slow start
Weiwei Liu245d7912016-07-28 00:04:25 -0700113 face.receive(*makeDataWithSegment(i));
Davide Pesavento66777622020-10-09 18:46:03 -0400114 advanceClocks(time::nanoseconds(1));
schneiderklausd8197df2019-03-16 11:31:40 -0700115 preCwnd = pipeline->m_cwnd;
Weiwei Liu245d7912016-07-28 00:04:25 -0700116 }
117
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700118 BOOST_CHECK_CLOSE(preCwnd, 4.5, MARGIN);
Weiwei Liu245d7912016-07-28 00:04:25 -0700119
schneiderklausd8197df2019-03-16 11:31:40 -0700120 for (uint64_t i = pipeline->m_ssthresh; i < nDataSegments - 1; ++i) { // congestion avoidance
Weiwei Liu245d7912016-07-28 00:04:25 -0700121 face.receive(*makeDataWithSegment(i));
Davide Pesavento66777622020-10-09 18:46:03 -0400122 advanceClocks(time::nanoseconds(1));
Davide Pesavento5748e822024-01-26 18:40:22 -0500123 BOOST_CHECK_CLOSE(pipeline->m_cwnd - preCwnd, opt.aiStep / std::floor(preCwnd), MARGIN);
schneiderklausd8197df2019-03-16 11:31:40 -0700124 preCwnd = pipeline->m_cwnd;
Weiwei Liu245d7912016-07-28 00:04:25 -0700125 }
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400126
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700127 BOOST_CHECK_EQUAL(pipeline->m_nReceived, nDataSegments -1);
Weiwei Liu245d7912016-07-28 00:04:25 -0700128}
129
130BOOST_AUTO_TEST_CASE(Timeout)
131{
132 nDataSegments = 8;
schneiderklausd8197df2019-03-16 11:31:40 -0700133 pipeline->m_ssthresh = 4.0;
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700134 BOOST_REQUIRE_CLOSE(pipeline->m_cwnd, 2, MARGIN);
Weiwei Liu245d7912016-07-28 00:04:25 -0700135
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800136 run(name);
Davide Pesavento66777622020-10-09 18:46:03 -0400137 advanceClocks(time::nanoseconds(1));
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700138 BOOST_CHECK_EQUAL(face.sentInterests.size(), 2);
Weiwei Liu245d7912016-07-28 00:04:25 -0700139
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800140 // receive segment 0, 1, and 2
141 for (uint64_t i = 0; i < 3; ++i) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700142 face.receive(*makeDataWithSegment(i));
Davide Pesavento66777622020-10-09 18:46:03 -0400143 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700144 }
145
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400146 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 3);
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700147 BOOST_CHECK_CLOSE(pipeline->m_cwnd, 4.25, MARGIN);
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800148 BOOST_CHECK_EQUAL(face.sentInterests.size(), 7); // request for segment 7 has been sent
Weiwei Liu245d7912016-07-28 00:04:25 -0700149
Davide Pesavento66777622020-10-09 18:46:03 -0400150 advanceClocks(time::milliseconds(100));
Weiwei Liu245d7912016-07-28 00:04:25 -0700151
152 // receive segment 4
153 face.receive(*makeDataWithSegment(4));
Davide Pesavento66777622020-10-09 18:46:03 -0400154 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700155
156 // receive segment 5
157 face.receive(*makeDataWithSegment(5));
Davide Pesavento66777622020-10-09 18:46:03 -0400158 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700159
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400160 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 5);
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700161 BOOST_CHECK_CLOSE(pipeline->m_cwnd, 4.75, MARGIN);
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800162 BOOST_CHECK_EQUAL(face.sentInterests.size(), nDataSegments); // all the segment requests have been sent
Weiwei Liu245d7912016-07-28 00:04:25 -0700163
schneiderklausd8197df2019-03-16 11:31:40 -0700164 BOOST_CHECK_EQUAL(pipeline->m_nTimeouts, 0);
165 BOOST_CHECK_EQUAL(pipeline->m_nLossDecr, 0);
166 BOOST_CHECK_EQUAL(pipeline->m_nMarkDecr, 0);
167 BOOST_CHECK_EQUAL(pipeline->m_nRetransmitted, 0);
168 BOOST_CHECK_EQUAL(pipeline->m_nSkippedRetx, 0);
169 BOOST_CHECK_EQUAL(pipeline->m_nCongMarks, 0);
schneiderklaus8ff3abd2019-03-12 22:15:12 -0700170
171 // timeout segment 3 & 6
Davide Pesavento66777622020-10-09 18:46:03 -0400172 advanceClocks(time::milliseconds(150));
schneiderklausd8197df2019-03-16 11:31:40 -0700173 BOOST_CHECK_EQUAL(pipeline->m_nTimeouts, 2);
174 BOOST_CHECK_EQUAL(pipeline->m_nRetransmitted, 1);
175 BOOST_CHECK_EQUAL(pipeline->m_nLossDecr, 1);
176 BOOST_CHECK_EQUAL(pipeline->m_nSkippedRetx, 0);
Weiwei Liu245d7912016-07-28 00:04:25 -0700177
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400178 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 5);
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700179 BOOST_CHECK_CLOSE(pipeline->m_cwnd, 2.375, MARGIN); // window size drop to 1/2 of previous size
schneiderklausd8197df2019-03-16 11:31:40 -0700180 BOOST_CHECK_EQUAL(pipeline->m_retxQueue.size(), 1);
Weiwei Liu245d7912016-07-28 00:04:25 -0700181
182 // receive segment 6, retransmit 3
183 face.receive(*makeDataWithSegment(6));
Davide Pesavento66777622020-10-09 18:46:03 -0400184 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700185
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400186 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 6);
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700187 BOOST_CHECK_CLOSE(pipeline->m_cwnd, 2.875, MARGIN); // congestion avoidance
schneiderklausd8197df2019-03-16 11:31:40 -0700188 BOOST_CHECK_EQUAL(pipeline->m_retxQueue.size(), 0);
189 BOOST_CHECK_EQUAL(pipeline->m_retxCount[3], 1);
schneiderklaus8ff3abd2019-03-12 22:15:12 -0700190
schneiderklausd8197df2019-03-16 11:31:40 -0700191 BOOST_CHECK_EQUAL(pipeline->m_nTimeouts, 2);
192 BOOST_CHECK_EQUAL(pipeline->m_nRetransmitted, 2);
Sichen Song40eae032022-05-01 16:33:00 -0700193 BOOST_CHECK_EQUAL(pipeline->m_nTimeouts, pipeline->m_nRetransmitted + pipeline->m_nSkippedRetx);
Weiwei Liu245d7912016-07-28 00:04:25 -0700194}
195
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000196BOOST_AUTO_TEST_CASE(CongestionMarksWithCwa)
197{
198 nDataSegments = 7;
schneiderklausd8197df2019-03-16 11:31:40 -0700199 pipeline->m_ssthresh = 4.0;
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700200 BOOST_REQUIRE_CLOSE(pipeline->m_cwnd, 2, MARGIN);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000201
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800202 run(name);
Davide Pesavento66777622020-10-09 18:46:03 -0400203 advanceClocks(time::nanoseconds(1));
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700204 BOOST_CHECK_EQUAL(face.sentInterests.size(), 2);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000205
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800206 // receive segments 0 to 4
207 for (uint64_t i = 0; i < 5; ++i) {
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000208 face.receive(*makeDataWithSegment(i));
Davide Pesavento66777622020-10-09 18:46:03 -0400209 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000210 }
211
212 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 5);
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700213 BOOST_CHECK_CLOSE(pipeline->m_cwnd, 4.75, MARGIN);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000214
215 // receive segment 5 with congestion mark
216 face.receive(*makeDataWithSegmentAndCongMark(5));
Davide Pesavento66777622020-10-09 18:46:03 -0400217 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000218
219 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 6);
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700220 BOOST_CHECK_CLOSE(pipeline->m_cwnd, 2.375, MARGIN); // window size drops to 1/2 of previous size
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800221 BOOST_CHECK_EQUAL(face.sentInterests.size(), nDataSegments); // all interests have been sent
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000222
223 // receive the last segment with congestion mark
224 face.receive(*makeDataWithSegmentAndCongMark(nDataSegments - 1));
Davide Pesavento66777622020-10-09 18:46:03 -0400225 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000226
227 BOOST_CHECK_EQUAL(pipeline->m_nReceived, nDataSegments);
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700228 BOOST_CHECK_CLOSE(pipeline->m_cwnd, 2.375, MARGIN); // conservative window adaption (window size should not decrease)
schneiderklausd8197df2019-03-16 11:31:40 -0700229 BOOST_CHECK_EQUAL(pipeline->m_retxQueue.size(), 0);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000230
231 // make sure no interest is retransmitted for marked data packets
schneiderklausd8197df2019-03-16 11:31:40 -0700232 BOOST_CHECK_EQUAL(pipeline->m_retxCount[5], 0);
233 BOOST_CHECK_EQUAL(pipeline->m_retxCount[nDataSegments - 1], 0);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000234
235 // check number of received marked data packets
schneiderklausd8197df2019-03-16 11:31:40 -0700236 BOOST_CHECK_EQUAL(pipeline->m_nCongMarks, 2);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000237}
238
239BOOST_AUTO_TEST_CASE(CongestionMarksWithoutCwa)
240{
241 opt.disableCwa = true;
242 createPipeline();
243
244 nDataSegments = 7;
schneiderklausd8197df2019-03-16 11:31:40 -0700245 pipeline->m_ssthresh = 4.0;
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700246 BOOST_REQUIRE_CLOSE(pipeline->m_cwnd, 2, MARGIN);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000247
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800248 run(name);
Davide Pesavento66777622020-10-09 18:46:03 -0400249 advanceClocks(time::nanoseconds(1));
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700250 BOOST_CHECK_EQUAL(face.sentInterests.size(), 2);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000251
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800252 // receive segments 0 to 4
253 for (uint64_t i = 0; i < 5; ++i) {
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000254 face.receive(*makeDataWithSegment(i));
Davide Pesavento66777622020-10-09 18:46:03 -0400255 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000256 }
257
258 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 5);
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700259 BOOST_CHECK_CLOSE(pipeline->m_cwnd, 4.75, MARGIN);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000260
261 // receive segment 5 with congestion mark
262 face.receive(*makeDataWithSegmentAndCongMark(5));
Davide Pesavento66777622020-10-09 18:46:03 -0400263 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000264
265 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 6);
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700266 BOOST_CHECK_CLOSE(pipeline->m_cwnd, 2.375, MARGIN); // window size drops to 1/2 of previous size
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800267 BOOST_CHECK_EQUAL(face.sentInterests.size(), nDataSegments); // all interests have been sent
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000268
269 // receive the last segment with congestion mark
270 face.receive(*makeDataWithSegmentAndCongMark(nDataSegments - 1));
Davide Pesavento66777622020-10-09 18:46:03 -0400271 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000272
273 BOOST_CHECK_EQUAL(pipeline->m_nReceived, nDataSegments);
schneiderklausd8197df2019-03-16 11:31:40 -0700274 BOOST_CHECK_CLOSE(pipeline->m_cwnd, PipelineInterestsAdaptive::MIN_SSTHRESH,
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000275 MARGIN); // window size should decrease, as cwa is disabled
schneiderklausd8197df2019-03-16 11:31:40 -0700276 BOOST_CHECK_EQUAL(pipeline->m_retxQueue.size(), 0);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000277
278 // make sure no interest is retransmitted for marked data packets
schneiderklausd8197df2019-03-16 11:31:40 -0700279 BOOST_CHECK_EQUAL(pipeline->m_retxCount[5], 0);
280 BOOST_CHECK_EQUAL(pipeline->m_retxCount[nDataSegments - 1], 0);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000281
282 // check number of received marked data packets
schneiderklausd8197df2019-03-16 11:31:40 -0700283 BOOST_CHECK_EQUAL(pipeline->m_nCongMarks, 2);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000284}
285
286BOOST_AUTO_TEST_CASE(IgnoreCongestionMarks)
287{
288 opt.ignoreCongMarks = true;
289 createPipeline();
290
291 nDataSegments = 7;
schneiderklausd8197df2019-03-16 11:31:40 -0700292 pipeline->m_ssthresh = 4.0;
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700293 BOOST_REQUIRE_CLOSE(pipeline->m_cwnd, 2, MARGIN);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000294
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800295 run(name);
Davide Pesavento66777622020-10-09 18:46:03 -0400296 advanceClocks(time::nanoseconds(1));
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700297 BOOST_CHECK_EQUAL(face.sentInterests.size(), 2);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000298
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800299 // receive segments 0 to 5
300 for (uint64_t i = 0; i < 6; ++i) {
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000301 face.receive(*makeDataWithSegment(i));
Davide Pesavento66777622020-10-09 18:46:03 -0400302 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000303 }
304
305 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 6);
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700306 BOOST_CHECK_CLOSE(pipeline->m_cwnd, 5.0, MARGIN);
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800307 BOOST_CHECK_EQUAL(face.sentInterests.size(), nDataSegments); // all interests have been sent
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000308
309 // receive the last segment with congestion mark
310 face.receive(*makeDataWithSegmentAndCongMark(nDataSegments - 1));
Davide Pesavento66777622020-10-09 18:46:03 -0400311 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000312
313 BOOST_CHECK_EQUAL(pipeline->m_nReceived, nDataSegments);
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700314 BOOST_CHECK_CLOSE(pipeline->m_cwnd, 5.2, MARGIN); // window size increases
schneiderklausd8197df2019-03-16 11:31:40 -0700315 BOOST_CHECK_EQUAL(pipeline->m_retxQueue.size(), 0);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000316
317 // make sure no interest is retransmitted for marked data packet
schneiderklausd8197df2019-03-16 11:31:40 -0700318 BOOST_CHECK_EQUAL(pipeline->m_retxCount[nDataSegments - 1], 0);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000319
320 // check number of received marked data packets
schneiderklausd8197df2019-03-16 11:31:40 -0700321 BOOST_CHECK_EQUAL(pipeline->m_nCongMarks, 1);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000322}
323
Weiwei Liu245d7912016-07-28 00:04:25 -0700324BOOST_AUTO_TEST_CASE(Nack)
325{
326 nDataSegments = 5;
schneiderklausd8197df2019-03-16 11:31:40 -0700327 pipeline->m_cwnd = 10.0;
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800328 run(name);
Davide Pesavento66777622020-10-09 18:46:03 -0400329 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800330
331 face.receive(*makeDataWithSegment(0));
Davide Pesavento66777622020-10-09 18:46:03 -0400332 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700333
334 face.receive(*makeDataWithSegment(1));
Davide Pesavento66777622020-10-09 18:46:03 -0400335 advanceClocks(time::nanoseconds(1));
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400336
337 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 2);
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800338 BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 10);
Weiwei Liu245d7912016-07-28 00:04:25 -0700339
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800340 // receive a nack with NackReason::DUPLICATE for segment 1
Weiwei Liu245d7912016-07-28 00:04:25 -0700341 auto nack1 = makeNack(face.sentInterests[1], lp::NackReason::DUPLICATE);
342 face.receive(nack1);
Davide Pesavento66777622020-10-09 18:46:03 -0400343 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700344
345 // nack1 is ignored
346 BOOST_CHECK_EQUAL(hasFailed, false);
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400347 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 2);
schneiderklausd8197df2019-03-16 11:31:40 -0700348 BOOST_CHECK_EQUAL(pipeline->m_retxQueue.size(), 0);
Weiwei Liu245d7912016-07-28 00:04:25 -0700349
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800350 // receive a nack with NackReason::CONGESTION for segment 2
Weiwei Liu245d7912016-07-28 00:04:25 -0700351 auto nack2 = makeNack(face.sentInterests[2], lp::NackReason::CONGESTION);
352 face.receive(nack2);
Davide Pesavento66777622020-10-09 18:46:03 -0400353 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700354
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800355 // segment 2 is retransmitted
schneiderklausd8197df2019-03-16 11:31:40 -0700356 BOOST_CHECK_EQUAL(pipeline->m_retxCount[2], 1);
Weiwei Liu245d7912016-07-28 00:04:25 -0700357
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800358 // receive a nack with NackReason::NONE for segment 3
Weiwei Liu245d7912016-07-28 00:04:25 -0700359 auto nack3 = makeNack(face.sentInterests[3], lp::NackReason::NONE);
360 face.receive(nack3);
Davide Pesavento66777622020-10-09 18:46:03 -0400361 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700362
363 // Other types of Nack will trigger a failure
364 BOOST_CHECK_EQUAL(hasFailed, true);
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400365 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 2);
Weiwei Liu245d7912016-07-28 00:04:25 -0700366}
367
368BOOST_AUTO_TEST_CASE(FinalBlockIdNotSetAtBeginning)
369{
370 nDataSegments = 4;
schneiderklausd8197df2019-03-16 11:31:40 -0700371 pipeline->m_cwnd = 4;
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800372 run(name);
Davide Pesavento66777622020-10-09 18:46:03 -0400373 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700374
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800375 // receive segment 0 without FinalBlockId
376 face.receive(*makeDataWithSegment(0, false));
Davide Pesavento66777622020-10-09 18:46:03 -0400377 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700378
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800379 // interests for segment 0 - 5 have been sent
Weiwei Liu245d7912016-07-28 00:04:25 -0700380 BOOST_CHECK_EQUAL(face.sentInterests.size(), 6);
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800381 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 1);
schneiderklausd8197df2019-03-16 11:31:40 -0700382 BOOST_CHECK_EQUAL(pipeline->m_hasFinalBlockId, false);
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800383 // pending interests: segment 1, 2, 3, 4, 5
Weiwei Liu245d7912016-07-28 00:04:25 -0700384 BOOST_CHECK_EQUAL(face.getNPendingInterests(), 5);
385
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800386 // receive segment 1 with FinalBlockId
387 face.receive(*makeDataWithSegment(1));
Davide Pesavento66777622020-10-09 18:46:03 -0400388 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800389 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 2);
schneiderklausd8197df2019-03-16 11:31:40 -0700390 BOOST_CHECK_EQUAL(pipeline->m_hasFinalBlockId, true);
Weiwei Liu245d7912016-07-28 00:04:25 -0700391
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800392 // pending interests for segment 1, 4, 5 haven been removed
393 BOOST_CHECK_EQUAL(face.getNPendingInterests(), 2);
Weiwei Liu245d7912016-07-28 00:04:25 -0700394}
395
396BOOST_AUTO_TEST_CASE(FailureBeforeFinalBlockIdReceived)
397{
398 // failed to retrieve segNo while the FinalBlockId has not yet been
399 // set, and later received a FinalBlockId >= segNo, i.e. segNo is
400 // part of the content.
401
402 nDataSegments = 4;
schneiderklausd8197df2019-03-16 11:31:40 -0700403 pipeline->m_cwnd = 4;
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800404 run(name);
Davide Pesavento66777622020-10-09 18:46:03 -0400405 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800406
407 // receive segment 0 without FinalBlockId
408 face.receive(*makeDataWithSegment(0, false));
Davide Pesavento66777622020-10-09 18:46:03 -0400409 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700410
411 // receive segment 1 without FinalBlockId
412 face.receive(*makeDataWithSegment(1, false));
Davide Pesavento66777622020-10-09 18:46:03 -0400413 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800414
415 // interests for segment 0 - 7 have been sent
416 BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 8);
Weiwei Liu245d7912016-07-28 00:04:25 -0700417
418 // receive nack with NackReason::NONE for segment 3
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800419 auto nack = makeNack(face.sentInterests[3], lp::NackReason::NONE);
Weiwei Liu245d7912016-07-28 00:04:25 -0700420 face.receive(nack);
Davide Pesavento66777622020-10-09 18:46:03 -0400421 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700422
423 // error not triggered
424 // pending interests for segment > 3 haven been removed
425 BOOST_CHECK_EQUAL(hasFailed, false);
426 BOOST_CHECK_EQUAL(face.getNPendingInterests(), 1);
427
428 // receive segment 2 with FinalBlockId
429 face.receive(*makeDataWithSegment(2));
Davide Pesavento66777622020-10-09 18:46:03 -0400430 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700431
432 // error triggered since segment 3 is part of the content
433 BOOST_CHECK_EQUAL(hasFailed, true);
434}
435
436BOOST_AUTO_TEST_CASE(SpuriousFailureBeforeFinalBlockIdReceived)
437{
438 // failed to retrieve segNo while the FinalBlockId has not yet been
439 // set, and later received a FinalBlockId < segNo, i.e. segNo is
440 // not part of the content, and it was actually a spurious failure
441
442 nDataSegments = 4;
schneiderklausd8197df2019-03-16 11:31:40 -0700443 pipeline->m_cwnd = 4;
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800444 run(name);
Davide Pesavento66777622020-10-09 18:46:03 -0400445 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800446
447 // receive segment 0 without FinalBlockId
448 face.receive(*makeDataWithSegment(0, false));
Davide Pesavento66777622020-10-09 18:46:03 -0400449 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700450
451 // receive segment 1 without FinalBlockId
452 face.receive(*makeDataWithSegment(1, false));
Davide Pesavento66777622020-10-09 18:46:03 -0400453 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800454
455 // interests for segment 0 - 7 have been sent
456 BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 8);
Weiwei Liu245d7912016-07-28 00:04:25 -0700457
458 // receive nack with NackReason::NONE for segment 4
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800459 auto nack = makeNack(face.sentInterests[4], lp::NackReason::NONE);
Weiwei Liu245d7912016-07-28 00:04:25 -0700460 face.receive(nack);
Davide Pesavento66777622020-10-09 18:46:03 -0400461 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700462
463 // error not triggered
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800464 // pending interests for segment > 3 have been removed
Weiwei Liu245d7912016-07-28 00:04:25 -0700465 BOOST_CHECK_EQUAL(hasFailed, false);
466 BOOST_CHECK_EQUAL(face.getNPendingInterests(), 2);
467
468 // receive segment 2 with FinalBlockId
469 face.receive(*makeDataWithSegment(2));
Davide Pesavento66777622020-10-09 18:46:03 -0400470 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700471
472 // timeout segment 3
Davide Pesavento66777622020-10-09 18:46:03 -0400473 advanceClocks(time::seconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700474
475 // segment 3 is retransmitted
schneiderklausd8197df2019-03-16 11:31:40 -0700476 BOOST_CHECK_EQUAL(pipeline->m_retxCount[3], 1);
Weiwei Liu245d7912016-07-28 00:04:25 -0700477
478 // receive segment 3
479 face.receive(*makeDataWithSegment(3));
Davide Pesavento66777622020-10-09 18:46:03 -0400480 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700481
482 BOOST_CHECK_EQUAL(hasFailed, false);
483}
484
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500485BOOST_AUTO_TEST_CASE(SegmentInfoMaintenance)
486{
487 // test that m_segmentInfo is properly maintained when
488 // a segment is received after two consecutive timeouts
489
490 nDataSegments = 3;
491
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800492 run(name);
Davide Pesavento66777622020-10-09 18:46:03 -0400493 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800494
495 // receive segment 0
496 face.receive(*makeDataWithSegment(0));
Davide Pesavento66777622020-10-09 18:46:03 -0400497 advanceClocks(time::nanoseconds(1));
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500498
499 // receive segment 1
500 face.receive(*makeDataWithSegment(1));
Davide Pesavento66777622020-10-09 18:46:03 -0400501 advanceClocks(time::nanoseconds(1));
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500502
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800503 BOOST_CHECK_EQUAL(face.sentInterests.size(), 3);
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500504
505 // check if segment 2's state is FirstTimeSent
schneiderklausd8197df2019-03-16 11:31:40 -0700506 auto it = pipeline->m_segmentInfo.find(2);
507 BOOST_REQUIRE(it != pipeline->m_segmentInfo.end());
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500508 BOOST_CHECK(it->second.state == SegmentState::FirstTimeSent);
509
510 // timeout segment 2 twice
Davide Pesavento66777622020-10-09 18:46:03 -0400511 advanceClocks(time::milliseconds(400), 3);
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500512
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800513 BOOST_CHECK_EQUAL(face.sentInterests.size(), 5);
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500514
515 // check if segment 2's state is Retransmitted
schneiderklausd8197df2019-03-16 11:31:40 -0700516 it = pipeline->m_segmentInfo.find(2);
517 BOOST_REQUIRE(it != pipeline->m_segmentInfo.end());
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500518 BOOST_CHECK(it->second.state == SegmentState::Retransmitted);
519
520 // check if segment 2 was retransmitted twice
schneiderklausd8197df2019-03-16 11:31:40 -0700521 BOOST_CHECK_EQUAL(pipeline->m_retxCount.at(2), 2);
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500522
523 // receive segment 2 the first time
524 face.receive(*makeDataWithSegment(2));
Davide Pesavento66777622020-10-09 18:46:03 -0400525 advanceClocks(time::nanoseconds(1));
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500526
527 // check if segment 2 was erased from m_segmentInfo
schneiderklausd8197df2019-03-16 11:31:40 -0700528 it = pipeline->m_segmentInfo.find(2);
529 BOOST_CHECK(it == pipeline->m_segmentInfo.end());
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500530
531 auto prevRtt = rttEstimator.getAvgRtt();
532 auto prevRto = rttEstimator.getEstimatedRto();
533
534 // receive segment 2 the second time
535 face.receive(*makeDataWithSegment(2));
Davide Pesavento66777622020-10-09 18:46:03 -0400536 advanceClocks(time::nanoseconds(1));
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500537
538 // nothing changed
schneiderklausd8197df2019-03-16 11:31:40 -0700539 it = pipeline->m_segmentInfo.find(2);
540 BOOST_CHECK(it == pipeline->m_segmentInfo.end());
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800541 BOOST_CHECK_EQUAL(face.sentInterests.size(), 5);
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500542 BOOST_CHECK_EQUAL(rttEstimator.getAvgRtt(), prevRtt);
543 BOOST_CHECK_EQUAL(rttEstimator.getEstimatedRto(), prevRto);
544}
545
Sichen Song40eae032022-05-01 16:33:00 -0700546BOOST_AUTO_TEST_CASE(Bug5202)
547{
548 // If an interest is pending during a window decrease, it should not trigger
549 // another window decrease when it times out.
550 // This test emulates a network where RTT = 20ms and transmission time = 1ms.
551
552 // adding small sample to RTT estimator. This should set rto = 200ms
553 rttEstimator.addMeasurement(time::nanoseconds(1));
554 BOOST_REQUIRE_EQUAL(rttEstimator.getEstimatedRto(), time::milliseconds(200));
555
556 nDataSegments = 300;
557 pipeline->m_ssthresh = 0;
558 pipeline->m_cwnd = 20;
559
560 run(name);
561
562 advanceClocks(time::nanoseconds(1));
563 BOOST_CHECK_EQUAL(face.sentInterests.size(), 20);
564 advanceClocks(time::milliseconds(20));
565
566 // Segment 1 is lost. Receive segment 0 and 2-99
567 face.receive(*makeDataWithSegment(0));
568 advanceClocks(time::milliseconds(1));
569 for (uint64_t i = 2; i <= 99; ++i) {
570 face.receive(*makeDataWithSegment(i));
571 advanceClocks(time::milliseconds(1));
572 }
573
574 // Segment 100 is lost. Receive segment 100 to 181
575 for (uint64_t i = 101; i <= 181; ++i) {
576 face.receive(*makeDataWithSegment(i));
577 advanceClocks(time::milliseconds(1));
578 }
579
580 // 200ms passed after sending segment 1, check for timeout
581 BOOST_CHECK_GT(pipeline->m_cwnd, 27./2);
582 BOOST_CHECK_LT(pipeline->m_cwnd, 28./2);
583 BOOST_CHECK_EQUAL(pipeline->m_nTimeouts, 1);
584 BOOST_CHECK_EQUAL(pipeline->m_nLossDecr, 1);
585
586 // Receive segment 182 to 300
587 for (uint64_t i = 182; i <= 300; ++i) {
588 face.receive(*makeDataWithSegment(i));
589 advanceClocks(time::milliseconds(1));
590 }
591
592 // The second packet should timeout now
593 BOOST_CHECK_EQUAL(pipeline->m_nTimeouts, 2);
594 // This timeout should NOT trigger another window decrease
595 BOOST_CHECK_EQUAL(pipeline->m_nLossDecr, 1);
596}
597
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -0400598BOOST_AUTO_TEST_CASE(PrintSummaryWithNoRttMeasurements)
599{
600 // test the console ouptut when no RTT measurement is available,
601 // to make sure a proper message will be printed out
602
603 std::stringstream ss;
604
605 // change the underlying buffer and save the old buffer
606 auto oldBuf = std::cerr.rdbuf(ss.rdbuf());
607
schneiderklausd8197df2019-03-16 11:31:40 -0700608 pipeline->printSummary();
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -0400609 std::string line;
610
611 bool found = false;
612 while (std::getline(ss, line)) {
613 if (line == "RTT stats unavailable") {
614 found = true;
615 break;
616 }
617 }
618 BOOST_CHECK(found);
619 std::cerr.rdbuf(oldBuf); // reset
620}
621
Ryan Wickman034f30f2018-06-06 11:11:11 -0500622BOOST_AUTO_TEST_CASE(StopsWhenFileSizeLessThanChunkSize)
623{
624 // test to see if the program doesn't hang,
625 // when transfer is complete, for files less than the chunk size
626 // (i.e. when only one segment is sent/received)
627
628 createPipeline();
629 nDataSegments = 1;
630
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800631 run(name);
Davide Pesavento66777622020-10-09 18:46:03 -0400632 advanceClocks(time::nanoseconds(1));
Ryan Wickman034f30f2018-06-06 11:11:11 -0500633
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800634 face.receive(*makeDataWithSegment(0));
Davide Pesavento66777622020-10-09 18:46:03 -0400635 advanceClocks(time::nanoseconds(1));
Ryan Wickman034f30f2018-06-06 11:11:11 -0500636
schneiderklausd8197df2019-03-16 11:31:40 -0700637 BOOST_CHECK_EQUAL(pipeline->m_hasFinalBlockId, true);
638 BOOST_CHECK_EQUAL(pipeline->m_segmentInfo.size(), 0);
Ryan Wickman034f30f2018-06-06 11:11:11 -0500639 BOOST_CHECK_EQUAL(face.getNPendingInterests(), 0);
640}
641
Klaus Schneider9e5122b2019-03-19 17:03:25 -0700642BOOST_AUTO_TEST_SUITE_END() // TestPipelineInterestsAimd
Weiwei Liu245d7912016-07-28 00:04:25 -0700643BOOST_AUTO_TEST_SUITE_END() // Chunks
644
Davide Pesaventob3570c62022-02-19 19:19:00 -0500645} // namespace ndn::chunks::tests