blob: 12eeaa50f1c694d811dd13c3dd4c3a501e6e3fbd [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 Pesaventob3570c62022-02-19 19:19:00 -05003 * Copyright (c) 2016-2022, 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 Pesaventob3570c62022-02-19 19:19:00 -050032namespace ndn::chunks::tests {
Weiwei Liu245d7912016-07-28 00:04:25 -070033
34using namespace ndn::tests;
35
Klaus Schneider9e5122b2019-03-19 17:03:25 -070036class PipelineInterestAimdFixture : public PipelineInterestsFixture
Weiwei Liu245d7912016-07-28 00:04:25 -070037{
Davide Pesaventob3570c62022-02-19 19:19:00 -050038protected:
Klaus Schneider9e5122b2019-03-19 17:03:25 -070039 PipelineInterestAimdFixture()
Weiwei Liu245d7912016-07-28 00:04:25 -070040 {
Davide Pesavento97a33b22019-10-17 22:10:47 -040041 opt.isQuiet = true;
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +000042 createPipeline();
43 }
44
45 void
46 createPipeline()
47 {
Klaus Schneider9e5122b2019-03-19 17:03:25 -070048 auto pline = make_unique<PipelineInterestsAimd>(face, rttEstimator, opt);
schneiderklausd8197df2019-03-16 11:31:40 -070049 pipeline = pline.get();
Weiwei Liu245d7912016-07-28 00:04:25 -070050 setPipeline(std::move(pline));
51 }
52
53private:
Davide Pesavento5e3773d2019-08-22 15:35:08 -040054 static shared_ptr<RttEstimatorWithStats::Options>
Weiwei Liu245d7912016-07-28 00:04:25 -070055 makeRttEstimatorOptions()
56 {
Davide Pesavento5e3773d2019-08-22 15:35:08 -040057 auto rttOptions = make_shared<RttEstimatorWithStats::Options>();
58 rttOptions->alpha = 0.125;
59 rttOptions->beta = 0.25;
60 rttOptions->k = 4;
61 rttOptions->initialRto = 1_s;
62 rttOptions->minRto = 200_ms;
63 rttOptions->maxRto = 4_s;
64 rttOptions->rtoBackoffMultiplier = 2;
Weiwei Liu245d7912016-07-28 00:04:25 -070065 return rttOptions;
66 }
67
68protected:
Davide Pesavento97a33b22019-10-17 22:10:47 -040069 Options opt;
Davide Pesaventob3570c62022-02-19 19:19:00 -050070 RttEstimatorWithStats rttEstimator{makeRttEstimatorOptions()};
schneiderklausd8197df2019-03-16 11:31:40 -070071 PipelineInterestsAdaptive* pipeline;
Davide Pesaventoba560662019-06-26 22:45:44 -040072 static constexpr double MARGIN = 0.001;
Weiwei Liu245d7912016-07-28 00:04:25 -070073};
74
75BOOST_AUTO_TEST_SUITE(Chunks)
Klaus Schneider9e5122b2019-03-19 17:03:25 -070076BOOST_FIXTURE_TEST_SUITE(TestPipelineInterestsAimd, PipelineInterestAimdFixture)
Weiwei Liu245d7912016-07-28 00:04:25 -070077
78BOOST_AUTO_TEST_CASE(SlowStart)
79{
80 nDataSegments = 4;
schneiderklausd8197df2019-03-16 11:31:40 -070081 pipeline->m_ssthresh = 8.0;
Klaus Schneider4a2e89d2019-10-27 10:04:39 -070082 BOOST_REQUIRE_CLOSE(pipeline->m_cwnd, 2, MARGIN);
Weiwei Liu245d7912016-07-28 00:04:25 -070083
schneiderklausd8197df2019-03-16 11:31:40 -070084 double preCwnd = pipeline->m_cwnd;
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -080085 run(name);
Davide Pesavento66777622020-10-09 18:46:03 -040086 advanceClocks(time::nanoseconds(1));
Klaus Schneider4a2e89d2019-10-27 10:04:39 -070087 BOOST_CHECK_EQUAL(face.sentInterests.size(), 2);
Weiwei Liu245d7912016-07-28 00:04:25 -070088
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -080089 for (uint64_t i = 0; i < nDataSegments - 1; ++i) {
Weiwei Liu245d7912016-07-28 00:04:25 -070090 face.receive(*makeDataWithSegment(i));
Davide Pesavento66777622020-10-09 18:46:03 -040091 advanceClocks(time::nanoseconds(1));
schneiderklausd8197df2019-03-16 11:31:40 -070092 BOOST_CHECK_CLOSE(pipeline->m_cwnd - preCwnd, 1, MARGIN);
93 preCwnd = pipeline->m_cwnd;
Weiwei Liu245d7912016-07-28 00:04:25 -070094 }
Davide Pesaventoe9c69852017-11-04 18:08:37 -040095
96 BOOST_CHECK_EQUAL(pipeline->m_nReceived, nDataSegments - 1);
Weiwei Liu245d7912016-07-28 00:04:25 -070097}
98
99BOOST_AUTO_TEST_CASE(CongestionAvoidance)
100{
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800101 nDataSegments = 7;
schneiderklausd8197df2019-03-16 11:31:40 -0700102 pipeline->m_ssthresh = 4.0;
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700103 BOOST_REQUIRE_CLOSE(pipeline->m_cwnd, 2, MARGIN);
Weiwei Liu245d7912016-07-28 00:04:25 -0700104
schneiderklausd8197df2019-03-16 11:31:40 -0700105 double preCwnd = pipeline->m_cwnd;
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800106 run(name);
Davide Pesavento66777622020-10-09 18:46:03 -0400107 advanceClocks(time::nanoseconds(1));
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700108 BOOST_CHECK_EQUAL(face.sentInterests.size(), 2);
Weiwei Liu245d7912016-07-28 00:04:25 -0700109
schneiderklausd8197df2019-03-16 11:31:40 -0700110 for (uint64_t i = 0; i < pipeline->m_ssthresh; ++i) { // slow start
Weiwei Liu245d7912016-07-28 00:04:25 -0700111 face.receive(*makeDataWithSegment(i));
Davide Pesavento66777622020-10-09 18:46:03 -0400112 advanceClocks(time::nanoseconds(1));
schneiderklausd8197df2019-03-16 11:31:40 -0700113 preCwnd = pipeline->m_cwnd;
Weiwei Liu245d7912016-07-28 00:04:25 -0700114 }
115
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700116 BOOST_CHECK_CLOSE(preCwnd, 4.5, MARGIN);
Weiwei Liu245d7912016-07-28 00:04:25 -0700117
schneiderklausd8197df2019-03-16 11:31:40 -0700118 for (uint64_t i = pipeline->m_ssthresh; i < nDataSegments - 1; ++i) { // congestion avoidance
Weiwei Liu245d7912016-07-28 00:04:25 -0700119 face.receive(*makeDataWithSegment(i));
Davide Pesavento66777622020-10-09 18:46:03 -0400120 advanceClocks(time::nanoseconds(1));
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700121 BOOST_CHECK_CLOSE(pipeline->m_cwnd - preCwnd, opt.aiStep / floor(preCwnd), MARGIN);
schneiderklausd8197df2019-03-16 11:31:40 -0700122 preCwnd = pipeline->m_cwnd;
Weiwei Liu245d7912016-07-28 00:04:25 -0700123 }
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400124
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700125 BOOST_CHECK_EQUAL(pipeline->m_nReceived, nDataSegments -1);
Weiwei Liu245d7912016-07-28 00:04:25 -0700126}
127
128BOOST_AUTO_TEST_CASE(Timeout)
129{
130 nDataSegments = 8;
schneiderklausd8197df2019-03-16 11:31:40 -0700131 pipeline->m_ssthresh = 4.0;
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700132 BOOST_REQUIRE_CLOSE(pipeline->m_cwnd, 2, MARGIN);
Weiwei Liu245d7912016-07-28 00:04:25 -0700133
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800134 run(name);
Davide Pesavento66777622020-10-09 18:46:03 -0400135 advanceClocks(time::nanoseconds(1));
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700136 BOOST_CHECK_EQUAL(face.sentInterests.size(), 2);
Weiwei Liu245d7912016-07-28 00:04:25 -0700137
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800138 // receive segment 0, 1, and 2
139 for (uint64_t i = 0; i < 3; ++i) {
Weiwei Liu245d7912016-07-28 00:04:25 -0700140 face.receive(*makeDataWithSegment(i));
Davide Pesavento66777622020-10-09 18:46:03 -0400141 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700142 }
143
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400144 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 3);
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700145 BOOST_CHECK_CLOSE(pipeline->m_cwnd, 4.25, MARGIN);
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800146 BOOST_CHECK_EQUAL(face.sentInterests.size(), 7); // request for segment 7 has been sent
Weiwei Liu245d7912016-07-28 00:04:25 -0700147
Davide Pesavento66777622020-10-09 18:46:03 -0400148 advanceClocks(time::milliseconds(100));
Weiwei Liu245d7912016-07-28 00:04:25 -0700149
150 // receive segment 4
151 face.receive(*makeDataWithSegment(4));
Davide Pesavento66777622020-10-09 18:46:03 -0400152 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700153
154 // receive segment 5
155 face.receive(*makeDataWithSegment(5));
Davide Pesavento66777622020-10-09 18:46:03 -0400156 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700157
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400158 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 5);
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700159 BOOST_CHECK_CLOSE(pipeline->m_cwnd, 4.75, MARGIN);
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800160 BOOST_CHECK_EQUAL(face.sentInterests.size(), nDataSegments); // all the segment requests have been sent
Weiwei Liu245d7912016-07-28 00:04:25 -0700161
schneiderklausd8197df2019-03-16 11:31:40 -0700162 BOOST_CHECK_EQUAL(pipeline->m_nTimeouts, 0);
163 BOOST_CHECK_EQUAL(pipeline->m_nLossDecr, 0);
164 BOOST_CHECK_EQUAL(pipeline->m_nMarkDecr, 0);
165 BOOST_CHECK_EQUAL(pipeline->m_nRetransmitted, 0);
166 BOOST_CHECK_EQUAL(pipeline->m_nSkippedRetx, 0);
167 BOOST_CHECK_EQUAL(pipeline->m_nCongMarks, 0);
schneiderklaus8ff3abd2019-03-12 22:15:12 -0700168
169 // timeout segment 3 & 6
Davide Pesavento66777622020-10-09 18:46:03 -0400170 advanceClocks(time::milliseconds(150));
schneiderklausd8197df2019-03-16 11:31:40 -0700171 BOOST_CHECK_EQUAL(pipeline->m_nTimeouts, 2);
172 BOOST_CHECK_EQUAL(pipeline->m_nRetransmitted, 1);
173 BOOST_CHECK_EQUAL(pipeline->m_nLossDecr, 1);
174 BOOST_CHECK_EQUAL(pipeline->m_nSkippedRetx, 0);
Weiwei Liu245d7912016-07-28 00:04:25 -0700175
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400176 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 5);
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700177 BOOST_CHECK_CLOSE(pipeline->m_cwnd, 2.375, MARGIN); // window size drop to 1/2 of previous size
schneiderklausd8197df2019-03-16 11:31:40 -0700178 BOOST_CHECK_EQUAL(pipeline->m_retxQueue.size(), 1);
Weiwei Liu245d7912016-07-28 00:04:25 -0700179
180 // receive segment 6, retransmit 3
181 face.receive(*makeDataWithSegment(6));
Davide Pesavento66777622020-10-09 18:46:03 -0400182 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700183
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400184 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 6);
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700185 BOOST_CHECK_CLOSE(pipeline->m_cwnd, 2.875, MARGIN); // congestion avoidance
schneiderklausd8197df2019-03-16 11:31:40 -0700186 BOOST_CHECK_EQUAL(pipeline->m_retxQueue.size(), 0);
187 BOOST_CHECK_EQUAL(pipeline->m_retxCount[3], 1);
schneiderklaus8ff3abd2019-03-12 22:15:12 -0700188
schneiderklausd8197df2019-03-16 11:31:40 -0700189 BOOST_CHECK_EQUAL(pipeline->m_nTimeouts, 2);
190 BOOST_CHECK_EQUAL(pipeline->m_nRetransmitted, 2);
Sichen Song40eae032022-05-01 16:33:00 -0700191 BOOST_CHECK_EQUAL(pipeline->m_nTimeouts, pipeline->m_nRetransmitted + pipeline->m_nSkippedRetx);
Weiwei Liu245d7912016-07-28 00:04:25 -0700192}
193
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000194BOOST_AUTO_TEST_CASE(CongestionMarksWithCwa)
195{
196 nDataSegments = 7;
schneiderklausd8197df2019-03-16 11:31:40 -0700197 pipeline->m_ssthresh = 4.0;
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700198 BOOST_REQUIRE_CLOSE(pipeline->m_cwnd, 2, MARGIN);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000199
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800200 run(name);
Davide Pesavento66777622020-10-09 18:46:03 -0400201 advanceClocks(time::nanoseconds(1));
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700202 BOOST_CHECK_EQUAL(face.sentInterests.size(), 2);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000203
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800204 // receive segments 0 to 4
205 for (uint64_t i = 0; i < 5; ++i) {
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000206 face.receive(*makeDataWithSegment(i));
Davide Pesavento66777622020-10-09 18:46:03 -0400207 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000208 }
209
210 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 5);
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700211 BOOST_CHECK_CLOSE(pipeline->m_cwnd, 4.75, MARGIN);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000212
213 // receive segment 5 with congestion mark
214 face.receive(*makeDataWithSegmentAndCongMark(5));
Davide Pesavento66777622020-10-09 18:46:03 -0400215 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000216
217 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 6);
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700218 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 -0800219 BOOST_CHECK_EQUAL(face.sentInterests.size(), nDataSegments); // all interests have been sent
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000220
221 // receive the last segment with congestion mark
222 face.receive(*makeDataWithSegmentAndCongMark(nDataSegments - 1));
Davide Pesavento66777622020-10-09 18:46:03 -0400223 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000224
225 BOOST_CHECK_EQUAL(pipeline->m_nReceived, nDataSegments);
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700226 BOOST_CHECK_CLOSE(pipeline->m_cwnd, 2.375, MARGIN); // conservative window adaption (window size should not decrease)
schneiderklausd8197df2019-03-16 11:31:40 -0700227 BOOST_CHECK_EQUAL(pipeline->m_retxQueue.size(), 0);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000228
229 // make sure no interest is retransmitted for marked data packets
schneiderklausd8197df2019-03-16 11:31:40 -0700230 BOOST_CHECK_EQUAL(pipeline->m_retxCount[5], 0);
231 BOOST_CHECK_EQUAL(pipeline->m_retxCount[nDataSegments - 1], 0);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000232
233 // check number of received marked data packets
schneiderklausd8197df2019-03-16 11:31:40 -0700234 BOOST_CHECK_EQUAL(pipeline->m_nCongMarks, 2);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000235}
236
237BOOST_AUTO_TEST_CASE(CongestionMarksWithoutCwa)
238{
239 opt.disableCwa = true;
240 createPipeline();
241
242 nDataSegments = 7;
schneiderklausd8197df2019-03-16 11:31:40 -0700243 pipeline->m_ssthresh = 4.0;
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700244 BOOST_REQUIRE_CLOSE(pipeline->m_cwnd, 2, MARGIN);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000245
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800246 run(name);
Davide Pesavento66777622020-10-09 18:46:03 -0400247 advanceClocks(time::nanoseconds(1));
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700248 BOOST_CHECK_EQUAL(face.sentInterests.size(), 2);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000249
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800250 // receive segments 0 to 4
251 for (uint64_t i = 0; i < 5; ++i) {
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000252 face.receive(*makeDataWithSegment(i));
Davide Pesavento66777622020-10-09 18:46:03 -0400253 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000254 }
255
256 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 5);
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700257 BOOST_CHECK_CLOSE(pipeline->m_cwnd, 4.75, MARGIN);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000258
259 // receive segment 5 with congestion mark
260 face.receive(*makeDataWithSegmentAndCongMark(5));
Davide Pesavento66777622020-10-09 18:46:03 -0400261 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000262
263 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 6);
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700264 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 -0800265 BOOST_CHECK_EQUAL(face.sentInterests.size(), nDataSegments); // all interests have been sent
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000266
267 // receive the last segment with congestion mark
268 face.receive(*makeDataWithSegmentAndCongMark(nDataSegments - 1));
Davide Pesavento66777622020-10-09 18:46:03 -0400269 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000270
271 BOOST_CHECK_EQUAL(pipeline->m_nReceived, nDataSegments);
schneiderklausd8197df2019-03-16 11:31:40 -0700272 BOOST_CHECK_CLOSE(pipeline->m_cwnd, PipelineInterestsAdaptive::MIN_SSTHRESH,
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000273 MARGIN); // window size should decrease, as cwa is disabled
schneiderklausd8197df2019-03-16 11:31:40 -0700274 BOOST_CHECK_EQUAL(pipeline->m_retxQueue.size(), 0);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000275
276 // make sure no interest is retransmitted for marked data packets
schneiderklausd8197df2019-03-16 11:31:40 -0700277 BOOST_CHECK_EQUAL(pipeline->m_retxCount[5], 0);
278 BOOST_CHECK_EQUAL(pipeline->m_retxCount[nDataSegments - 1], 0);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000279
280 // check number of received marked data packets
schneiderklausd8197df2019-03-16 11:31:40 -0700281 BOOST_CHECK_EQUAL(pipeline->m_nCongMarks, 2);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000282}
283
284BOOST_AUTO_TEST_CASE(IgnoreCongestionMarks)
285{
286 opt.ignoreCongMarks = true;
287 createPipeline();
288
289 nDataSegments = 7;
schneiderklausd8197df2019-03-16 11:31:40 -0700290 pipeline->m_ssthresh = 4.0;
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700291 BOOST_REQUIRE_CLOSE(pipeline->m_cwnd, 2, MARGIN);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000292
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800293 run(name);
Davide Pesavento66777622020-10-09 18:46:03 -0400294 advanceClocks(time::nanoseconds(1));
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700295 BOOST_CHECK_EQUAL(face.sentInterests.size(), 2);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000296
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800297 // receive segments 0 to 5
298 for (uint64_t i = 0; i < 6; ++i) {
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000299 face.receive(*makeDataWithSegment(i));
Davide Pesavento66777622020-10-09 18:46:03 -0400300 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000301 }
302
303 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 6);
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700304 BOOST_CHECK_CLOSE(pipeline->m_cwnd, 5.0, MARGIN);
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800305 BOOST_CHECK_EQUAL(face.sentInterests.size(), nDataSegments); // all interests have been sent
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000306
307 // receive the last segment with congestion mark
308 face.receive(*makeDataWithSegmentAndCongMark(nDataSegments - 1));
Davide Pesavento66777622020-10-09 18:46:03 -0400309 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000310
311 BOOST_CHECK_EQUAL(pipeline->m_nReceived, nDataSegments);
Klaus Schneider4a2e89d2019-10-27 10:04:39 -0700312 BOOST_CHECK_CLOSE(pipeline->m_cwnd, 5.2, MARGIN); // window size increases
schneiderklausd8197df2019-03-16 11:31:40 -0700313 BOOST_CHECK_EQUAL(pipeline->m_retxQueue.size(), 0);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000314
315 // make sure no interest is retransmitted for marked data packet
schneiderklausd8197df2019-03-16 11:31:40 -0700316 BOOST_CHECK_EQUAL(pipeline->m_retxCount[nDataSegments - 1], 0);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000317
318 // check number of received marked data packets
schneiderklausd8197df2019-03-16 11:31:40 -0700319 BOOST_CHECK_EQUAL(pipeline->m_nCongMarks, 1);
Chavoosh Ghasemi641f5932017-11-06 22:45:11 +0000320}
321
Weiwei Liu245d7912016-07-28 00:04:25 -0700322BOOST_AUTO_TEST_CASE(Nack)
323{
324 nDataSegments = 5;
schneiderklausd8197df2019-03-16 11:31:40 -0700325 pipeline->m_cwnd = 10.0;
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800326 run(name);
Davide Pesavento66777622020-10-09 18:46:03 -0400327 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800328
329 face.receive(*makeDataWithSegment(0));
Davide Pesavento66777622020-10-09 18:46:03 -0400330 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700331
332 face.receive(*makeDataWithSegment(1));
Davide Pesavento66777622020-10-09 18:46:03 -0400333 advanceClocks(time::nanoseconds(1));
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400334
335 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 2);
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800336 BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 10);
Weiwei Liu245d7912016-07-28 00:04:25 -0700337
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800338 // receive a nack with NackReason::DUPLICATE for segment 1
Weiwei Liu245d7912016-07-28 00:04:25 -0700339 auto nack1 = makeNack(face.sentInterests[1], lp::NackReason::DUPLICATE);
340 face.receive(nack1);
Davide Pesavento66777622020-10-09 18:46:03 -0400341 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700342
343 // nack1 is ignored
344 BOOST_CHECK_EQUAL(hasFailed, false);
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400345 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 2);
schneiderklausd8197df2019-03-16 11:31:40 -0700346 BOOST_CHECK_EQUAL(pipeline->m_retxQueue.size(), 0);
Weiwei Liu245d7912016-07-28 00:04:25 -0700347
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800348 // receive a nack with NackReason::CONGESTION for segment 2
Weiwei Liu245d7912016-07-28 00:04:25 -0700349 auto nack2 = makeNack(face.sentInterests[2], lp::NackReason::CONGESTION);
350 face.receive(nack2);
Davide Pesavento66777622020-10-09 18:46:03 -0400351 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700352
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800353 // segment 2 is retransmitted
schneiderklausd8197df2019-03-16 11:31:40 -0700354 BOOST_CHECK_EQUAL(pipeline->m_retxCount[2], 1);
Weiwei Liu245d7912016-07-28 00:04:25 -0700355
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800356 // receive a nack with NackReason::NONE for segment 3
Weiwei Liu245d7912016-07-28 00:04:25 -0700357 auto nack3 = makeNack(face.sentInterests[3], lp::NackReason::NONE);
358 face.receive(nack3);
Davide Pesavento66777622020-10-09 18:46:03 -0400359 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700360
361 // Other types of Nack will trigger a failure
362 BOOST_CHECK_EQUAL(hasFailed, true);
Davide Pesaventoe9c69852017-11-04 18:08:37 -0400363 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 2);
Weiwei Liu245d7912016-07-28 00:04:25 -0700364}
365
366BOOST_AUTO_TEST_CASE(FinalBlockIdNotSetAtBeginning)
367{
368 nDataSegments = 4;
schneiderklausd8197df2019-03-16 11:31:40 -0700369 pipeline->m_cwnd = 4;
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800370 run(name);
Davide Pesavento66777622020-10-09 18:46:03 -0400371 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700372
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800373 // receive segment 0 without FinalBlockId
374 face.receive(*makeDataWithSegment(0, false));
Davide Pesavento66777622020-10-09 18:46:03 -0400375 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700376
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800377 // interests for segment 0 - 5 have been sent
Weiwei Liu245d7912016-07-28 00:04:25 -0700378 BOOST_CHECK_EQUAL(face.sentInterests.size(), 6);
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800379 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 1);
schneiderklausd8197df2019-03-16 11:31:40 -0700380 BOOST_CHECK_EQUAL(pipeline->m_hasFinalBlockId, false);
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800381 // pending interests: segment 1, 2, 3, 4, 5
Weiwei Liu245d7912016-07-28 00:04:25 -0700382 BOOST_CHECK_EQUAL(face.getNPendingInterests(), 5);
383
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800384 // receive segment 1 with FinalBlockId
385 face.receive(*makeDataWithSegment(1));
Davide Pesavento66777622020-10-09 18:46:03 -0400386 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800387 BOOST_CHECK_EQUAL(pipeline->m_nReceived, 2);
schneiderklausd8197df2019-03-16 11:31:40 -0700388 BOOST_CHECK_EQUAL(pipeline->m_hasFinalBlockId, true);
Weiwei Liu245d7912016-07-28 00:04:25 -0700389
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800390 // pending interests for segment 1, 4, 5 haven been removed
391 BOOST_CHECK_EQUAL(face.getNPendingInterests(), 2);
Weiwei Liu245d7912016-07-28 00:04:25 -0700392}
393
394BOOST_AUTO_TEST_CASE(FailureBeforeFinalBlockIdReceived)
395{
396 // failed to retrieve segNo while the FinalBlockId has not yet been
397 // set, and later received a FinalBlockId >= segNo, i.e. segNo is
398 // part of the content.
399
400 nDataSegments = 4;
schneiderklausd8197df2019-03-16 11:31:40 -0700401 pipeline->m_cwnd = 4;
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800402 run(name);
Davide Pesavento66777622020-10-09 18:46:03 -0400403 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800404
405 // receive segment 0 without FinalBlockId
406 face.receive(*makeDataWithSegment(0, false));
Davide Pesavento66777622020-10-09 18:46:03 -0400407 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700408
409 // receive segment 1 without FinalBlockId
410 face.receive(*makeDataWithSegment(1, false));
Davide Pesavento66777622020-10-09 18:46:03 -0400411 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800412
413 // interests for segment 0 - 7 have been sent
414 BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 8);
Weiwei Liu245d7912016-07-28 00:04:25 -0700415
416 // receive nack with NackReason::NONE for segment 3
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800417 auto nack = makeNack(face.sentInterests[3], lp::NackReason::NONE);
Weiwei Liu245d7912016-07-28 00:04:25 -0700418 face.receive(nack);
Davide Pesavento66777622020-10-09 18:46:03 -0400419 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700420
421 // error not triggered
422 // pending interests for segment > 3 haven been removed
423 BOOST_CHECK_EQUAL(hasFailed, false);
424 BOOST_CHECK_EQUAL(face.getNPendingInterests(), 1);
425
426 // receive segment 2 with FinalBlockId
427 face.receive(*makeDataWithSegment(2));
Davide Pesavento66777622020-10-09 18:46:03 -0400428 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700429
430 // error triggered since segment 3 is part of the content
431 BOOST_CHECK_EQUAL(hasFailed, true);
432}
433
434BOOST_AUTO_TEST_CASE(SpuriousFailureBeforeFinalBlockIdReceived)
435{
436 // failed to retrieve segNo while the FinalBlockId has not yet been
437 // set, and later received a FinalBlockId < segNo, i.e. segNo is
438 // not part of the content, and it was actually a spurious failure
439
440 nDataSegments = 4;
schneiderklausd8197df2019-03-16 11:31:40 -0700441 pipeline->m_cwnd = 4;
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800442 run(name);
Davide Pesavento66777622020-10-09 18:46:03 -0400443 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800444
445 // receive segment 0 without FinalBlockId
446 face.receive(*makeDataWithSegment(0, false));
Davide Pesavento66777622020-10-09 18:46:03 -0400447 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700448
449 // receive segment 1 without FinalBlockId
450 face.receive(*makeDataWithSegment(1, false));
Davide Pesavento66777622020-10-09 18:46:03 -0400451 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800452
453 // interests for segment 0 - 7 have been sent
454 BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 8);
Weiwei Liu245d7912016-07-28 00:04:25 -0700455
456 // receive nack with NackReason::NONE for segment 4
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800457 auto nack = makeNack(face.sentInterests[4], lp::NackReason::NONE);
Weiwei Liu245d7912016-07-28 00:04:25 -0700458 face.receive(nack);
Davide Pesavento66777622020-10-09 18:46:03 -0400459 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700460
461 // error not triggered
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800462 // pending interests for segment > 3 have been removed
Weiwei Liu245d7912016-07-28 00:04:25 -0700463 BOOST_CHECK_EQUAL(hasFailed, false);
464 BOOST_CHECK_EQUAL(face.getNPendingInterests(), 2);
465
466 // receive segment 2 with FinalBlockId
467 face.receive(*makeDataWithSegment(2));
Davide Pesavento66777622020-10-09 18:46:03 -0400468 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700469
470 // timeout segment 3
Davide Pesavento66777622020-10-09 18:46:03 -0400471 advanceClocks(time::seconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700472
473 // segment 3 is retransmitted
schneiderklausd8197df2019-03-16 11:31:40 -0700474 BOOST_CHECK_EQUAL(pipeline->m_retxCount[3], 1);
Weiwei Liu245d7912016-07-28 00:04:25 -0700475
476 // receive segment 3
477 face.receive(*makeDataWithSegment(3));
Davide Pesavento66777622020-10-09 18:46:03 -0400478 advanceClocks(time::nanoseconds(1));
Weiwei Liu245d7912016-07-28 00:04:25 -0700479
480 BOOST_CHECK_EQUAL(hasFailed, false);
481}
482
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500483BOOST_AUTO_TEST_CASE(SegmentInfoMaintenance)
484{
485 // test that m_segmentInfo is properly maintained when
486 // a segment is received after two consecutive timeouts
487
488 nDataSegments = 3;
489
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800490 run(name);
Davide Pesavento66777622020-10-09 18:46:03 -0400491 advanceClocks(time::nanoseconds(1));
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800492
493 // receive segment 0
494 face.receive(*makeDataWithSegment(0));
Davide Pesavento66777622020-10-09 18:46:03 -0400495 advanceClocks(time::nanoseconds(1));
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500496
497 // receive segment 1
498 face.receive(*makeDataWithSegment(1));
Davide Pesavento66777622020-10-09 18:46:03 -0400499 advanceClocks(time::nanoseconds(1));
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500500
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800501 BOOST_CHECK_EQUAL(face.sentInterests.size(), 3);
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500502
503 // check if segment 2's state is FirstTimeSent
schneiderklausd8197df2019-03-16 11:31:40 -0700504 auto it = pipeline->m_segmentInfo.find(2);
505 BOOST_REQUIRE(it != pipeline->m_segmentInfo.end());
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500506 BOOST_CHECK(it->second.state == SegmentState::FirstTimeSent);
507
508 // timeout segment 2 twice
Davide Pesavento66777622020-10-09 18:46:03 -0400509 advanceClocks(time::milliseconds(400), 3);
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500510
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800511 BOOST_CHECK_EQUAL(face.sentInterests.size(), 5);
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500512
513 // check if segment 2's state is Retransmitted
schneiderklausd8197df2019-03-16 11:31:40 -0700514 it = pipeline->m_segmentInfo.find(2);
515 BOOST_REQUIRE(it != pipeline->m_segmentInfo.end());
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500516 BOOST_CHECK(it->second.state == SegmentState::Retransmitted);
517
518 // check if segment 2 was retransmitted twice
schneiderklausd8197df2019-03-16 11:31:40 -0700519 BOOST_CHECK_EQUAL(pipeline->m_retxCount.at(2), 2);
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500520
521 // receive segment 2 the first time
522 face.receive(*makeDataWithSegment(2));
Davide Pesavento66777622020-10-09 18:46:03 -0400523 advanceClocks(time::nanoseconds(1));
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500524
525 // check if segment 2 was erased from m_segmentInfo
schneiderklausd8197df2019-03-16 11:31:40 -0700526 it = pipeline->m_segmentInfo.find(2);
527 BOOST_CHECK(it == pipeline->m_segmentInfo.end());
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500528
529 auto prevRtt = rttEstimator.getAvgRtt();
530 auto prevRto = rttEstimator.getEstimatedRto();
531
532 // receive segment 2 the second time
533 face.receive(*makeDataWithSegment(2));
Davide Pesavento66777622020-10-09 18:46:03 -0400534 advanceClocks(time::nanoseconds(1));
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500535
536 // nothing changed
schneiderklausd8197df2019-03-16 11:31:40 -0700537 it = pipeline->m_segmentInfo.find(2);
538 BOOST_CHECK(it == pipeline->m_segmentInfo.end());
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800539 BOOST_CHECK_EQUAL(face.sentInterests.size(), 5);
Ryan Wickman2c9933c2018-06-12 11:51:51 -0500540 BOOST_CHECK_EQUAL(rttEstimator.getAvgRtt(), prevRtt);
541 BOOST_CHECK_EQUAL(rttEstimator.getEstimatedRto(), prevRto);
542}
543
Sichen Song40eae032022-05-01 16:33:00 -0700544BOOST_AUTO_TEST_CASE(Bug5202)
545{
546 // If an interest is pending during a window decrease, it should not trigger
547 // another window decrease when it times out.
548 // This test emulates a network where RTT = 20ms and transmission time = 1ms.
549
550 // adding small sample to RTT estimator. This should set rto = 200ms
551 rttEstimator.addMeasurement(time::nanoseconds(1));
552 BOOST_REQUIRE_EQUAL(rttEstimator.getEstimatedRto(), time::milliseconds(200));
553
554 nDataSegments = 300;
555 pipeline->m_ssthresh = 0;
556 pipeline->m_cwnd = 20;
557
558 run(name);
559
560 advanceClocks(time::nanoseconds(1));
561 BOOST_CHECK_EQUAL(face.sentInterests.size(), 20);
562 advanceClocks(time::milliseconds(20));
563
564 // Segment 1 is lost. Receive segment 0 and 2-99
565 face.receive(*makeDataWithSegment(0));
566 advanceClocks(time::milliseconds(1));
567 for (uint64_t i = 2; i <= 99; ++i) {
568 face.receive(*makeDataWithSegment(i));
569 advanceClocks(time::milliseconds(1));
570 }
571
572 // Segment 100 is lost. Receive segment 100 to 181
573 for (uint64_t i = 101; i <= 181; ++i) {
574 face.receive(*makeDataWithSegment(i));
575 advanceClocks(time::milliseconds(1));
576 }
577
578 // 200ms passed after sending segment 1, check for timeout
579 BOOST_CHECK_GT(pipeline->m_cwnd, 27./2);
580 BOOST_CHECK_LT(pipeline->m_cwnd, 28./2);
581 BOOST_CHECK_EQUAL(pipeline->m_nTimeouts, 1);
582 BOOST_CHECK_EQUAL(pipeline->m_nLossDecr, 1);
583
584 // Receive segment 182 to 300
585 for (uint64_t i = 182; i <= 300; ++i) {
586 face.receive(*makeDataWithSegment(i));
587 advanceClocks(time::milliseconds(1));
588 }
589
590 // The second packet should timeout now
591 BOOST_CHECK_EQUAL(pipeline->m_nTimeouts, 2);
592 // This timeout should NOT trigger another window decrease
593 BOOST_CHECK_EQUAL(pipeline->m_nLossDecr, 1);
594}
595
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -0400596BOOST_AUTO_TEST_CASE(PrintSummaryWithNoRttMeasurements)
597{
598 // test the console ouptut when no RTT measurement is available,
599 // to make sure a proper message will be printed out
600
601 std::stringstream ss;
602
603 // change the underlying buffer and save the old buffer
604 auto oldBuf = std::cerr.rdbuf(ss.rdbuf());
605
schneiderklausd8197df2019-03-16 11:31:40 -0700606 pipeline->printSummary();
Chavoosh Ghasemi75309ae2018-03-26 14:46:24 -0400607 std::string line;
608
609 bool found = false;
610 while (std::getline(ss, line)) {
611 if (line == "RTT stats unavailable") {
612 found = true;
613 break;
614 }
615 }
616 BOOST_CHECK(found);
617 std::cerr.rdbuf(oldBuf); // reset
618}
619
Ryan Wickman034f30f2018-06-06 11:11:11 -0500620BOOST_AUTO_TEST_CASE(StopsWhenFileSizeLessThanChunkSize)
621{
622 // test to see if the program doesn't hang,
623 // when transfer is complete, for files less than the chunk size
624 // (i.e. when only one segment is sent/received)
625
626 createPipeline();
627 nDataSegments = 1;
628
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800629 run(name);
Davide Pesavento66777622020-10-09 18:46:03 -0400630 advanceClocks(time::nanoseconds(1));
Ryan Wickman034f30f2018-06-06 11:11:11 -0500631
Chavoosh Ghasemi5cb67012019-02-15 09:56:57 -0800632 face.receive(*makeDataWithSegment(0));
Davide Pesavento66777622020-10-09 18:46:03 -0400633 advanceClocks(time::nanoseconds(1));
Ryan Wickman034f30f2018-06-06 11:11:11 -0500634
schneiderklausd8197df2019-03-16 11:31:40 -0700635 BOOST_CHECK_EQUAL(pipeline->m_hasFinalBlockId, true);
636 BOOST_CHECK_EQUAL(pipeline->m_segmentInfo.size(), 0);
Ryan Wickman034f30f2018-06-06 11:11:11 -0500637 BOOST_CHECK_EQUAL(face.getNPendingInterests(), 0);
638}
639
Klaus Schneider9e5122b2019-03-19 17:03:25 -0700640BOOST_AUTO_TEST_SUITE_END() // TestPipelineInterestsAimd
Weiwei Liu245d7912016-07-28 00:04:25 -0700641BOOST_AUTO_TEST_SUITE_END() // Chunks
642
Davide Pesaventob3570c62022-02-19 19:19:00 -0500643} // namespace ndn::chunks::tests