Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | e9c6985 | 2017-11-04 18:08:37 -0400 | [diff] [blame] | 2 | /* |
Davide Pesavento | b3570c6 | 2022-02-19 19:19:00 -0500 | [diff] [blame^] | 3 | * Copyright (c) 2016-2022, Regents of the University of California, |
Davide Pesavento | 958896e | 2017-01-19 00:52:04 -0500 | [diff] [blame] | 4 | * Colorado State University, |
| 5 | * University Pierre & Marie Curie, Sorbonne University. |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 6 | * |
| 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 Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 24 | * @author Chavoosh Ghasemi |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 25 | * @author Klaus Schneider |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 26 | */ |
| 27 | |
Klaus Schneider | 9e5122b | 2019-03-19 17:03:25 -0700 | [diff] [blame] | 28 | #include "tools/chunks/catchunks/pipeline-interests-aimd.hpp" |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 29 | |
| 30 | #include "pipeline-interests-fixture.hpp" |
| 31 | |
Davide Pesavento | b3570c6 | 2022-02-19 19:19:00 -0500 | [diff] [blame^] | 32 | namespace ndn::chunks::tests { |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 33 | |
| 34 | using namespace ndn::tests; |
| 35 | |
Klaus Schneider | 9e5122b | 2019-03-19 17:03:25 -0700 | [diff] [blame] | 36 | class PipelineInterestAimdFixture : public PipelineInterestsFixture |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 37 | { |
Davide Pesavento | b3570c6 | 2022-02-19 19:19:00 -0500 | [diff] [blame^] | 38 | protected: |
Klaus Schneider | 9e5122b | 2019-03-19 17:03:25 -0700 | [diff] [blame] | 39 | PipelineInterestAimdFixture() |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 40 | { |
Davide Pesavento | 97a33b2 | 2019-10-17 22:10:47 -0400 | [diff] [blame] | 41 | opt.isQuiet = true; |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 42 | createPipeline(); |
| 43 | } |
| 44 | |
| 45 | void |
| 46 | createPipeline() |
| 47 | { |
Klaus Schneider | 9e5122b | 2019-03-19 17:03:25 -0700 | [diff] [blame] | 48 | auto pline = make_unique<PipelineInterestsAimd>(face, rttEstimator, opt); |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 49 | pipeline = pline.get(); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 50 | setPipeline(std::move(pline)); |
| 51 | } |
| 52 | |
| 53 | private: |
Davide Pesavento | 5e3773d | 2019-08-22 15:35:08 -0400 | [diff] [blame] | 54 | static shared_ptr<RttEstimatorWithStats::Options> |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 55 | makeRttEstimatorOptions() |
| 56 | { |
Davide Pesavento | 5e3773d | 2019-08-22 15:35:08 -0400 | [diff] [blame] | 57 | 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 Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 65 | return rttOptions; |
| 66 | } |
| 67 | |
| 68 | protected: |
Davide Pesavento | 97a33b2 | 2019-10-17 22:10:47 -0400 | [diff] [blame] | 69 | Options opt; |
Davide Pesavento | b3570c6 | 2022-02-19 19:19:00 -0500 | [diff] [blame^] | 70 | RttEstimatorWithStats rttEstimator{makeRttEstimatorOptions()}; |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 71 | PipelineInterestsAdaptive* pipeline; |
Davide Pesavento | ba56066 | 2019-06-26 22:45:44 -0400 | [diff] [blame] | 72 | static constexpr double MARGIN = 0.001; |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 73 | }; |
| 74 | |
Klaus Schneider | 9e5122b | 2019-03-19 17:03:25 -0700 | [diff] [blame] | 75 | constexpr double PipelineInterestAimdFixture::MARGIN; |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 76 | |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 77 | BOOST_AUTO_TEST_SUITE(Chunks) |
Klaus Schneider | 9e5122b | 2019-03-19 17:03:25 -0700 | [diff] [blame] | 78 | BOOST_FIXTURE_TEST_SUITE(TestPipelineInterestsAimd, PipelineInterestAimdFixture) |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 79 | |
| 80 | BOOST_AUTO_TEST_CASE(SlowStart) |
| 81 | { |
| 82 | nDataSegments = 4; |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 83 | pipeline->m_ssthresh = 8.0; |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 84 | BOOST_REQUIRE_CLOSE(pipeline->m_cwnd, 2, MARGIN); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 85 | |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 86 | double preCwnd = pipeline->m_cwnd; |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 87 | run(name); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 88 | advanceClocks(time::nanoseconds(1)); |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 89 | BOOST_CHECK_EQUAL(face.sentInterests.size(), 2); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 90 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 91 | for (uint64_t i = 0; i < nDataSegments - 1; ++i) { |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 92 | face.receive(*makeDataWithSegment(i)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 93 | advanceClocks(time::nanoseconds(1)); |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 94 | BOOST_CHECK_CLOSE(pipeline->m_cwnd - preCwnd, 1, MARGIN); |
| 95 | preCwnd = pipeline->m_cwnd; |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 96 | } |
Davide Pesavento | e9c6985 | 2017-11-04 18:08:37 -0400 | [diff] [blame] | 97 | |
| 98 | BOOST_CHECK_EQUAL(pipeline->m_nReceived, nDataSegments - 1); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | BOOST_AUTO_TEST_CASE(CongestionAvoidance) |
| 102 | { |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 103 | nDataSegments = 7; |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 104 | pipeline->m_ssthresh = 4.0; |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 105 | BOOST_REQUIRE_CLOSE(pipeline->m_cwnd, 2, MARGIN); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 106 | |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 107 | double preCwnd = pipeline->m_cwnd; |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 108 | run(name); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 109 | advanceClocks(time::nanoseconds(1)); |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 110 | BOOST_CHECK_EQUAL(face.sentInterests.size(), 2); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 111 | |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 112 | for (uint64_t i = 0; i < pipeline->m_ssthresh; ++i) { // slow start |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 113 | face.receive(*makeDataWithSegment(i)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 114 | advanceClocks(time::nanoseconds(1)); |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 115 | preCwnd = pipeline->m_cwnd; |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 116 | } |
| 117 | |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 118 | BOOST_CHECK_CLOSE(preCwnd, 4.5, MARGIN); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 119 | |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 120 | for (uint64_t i = pipeline->m_ssthresh; i < nDataSegments - 1; ++i) { // congestion avoidance |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 121 | face.receive(*makeDataWithSegment(i)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 122 | advanceClocks(time::nanoseconds(1)); |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 123 | BOOST_CHECK_CLOSE(pipeline->m_cwnd - preCwnd, opt.aiStep / floor(preCwnd), MARGIN); |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 124 | preCwnd = pipeline->m_cwnd; |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 125 | } |
Davide Pesavento | e9c6985 | 2017-11-04 18:08:37 -0400 | [diff] [blame] | 126 | |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 127 | BOOST_CHECK_EQUAL(pipeline->m_nReceived, nDataSegments -1); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | BOOST_AUTO_TEST_CASE(Timeout) |
| 131 | { |
| 132 | nDataSegments = 8; |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 133 | pipeline->m_ssthresh = 4.0; |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 134 | BOOST_REQUIRE_CLOSE(pipeline->m_cwnd, 2, MARGIN); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 135 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 136 | run(name); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 137 | advanceClocks(time::nanoseconds(1)); |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 138 | BOOST_CHECK_EQUAL(face.sentInterests.size(), 2); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 139 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 140 | // receive segment 0, 1, and 2 |
| 141 | for (uint64_t i = 0; i < 3; ++i) { |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 142 | face.receive(*makeDataWithSegment(i)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 143 | advanceClocks(time::nanoseconds(1)); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 144 | } |
| 145 | |
Davide Pesavento | e9c6985 | 2017-11-04 18:08:37 -0400 | [diff] [blame] | 146 | BOOST_CHECK_EQUAL(pipeline->m_nReceived, 3); |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 147 | BOOST_CHECK_CLOSE(pipeline->m_cwnd, 4.25, MARGIN); |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 148 | BOOST_CHECK_EQUAL(face.sentInterests.size(), 7); // request for segment 7 has been sent |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 149 | |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 150 | advanceClocks(time::milliseconds(100)); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 151 | |
| 152 | // receive segment 4 |
| 153 | face.receive(*makeDataWithSegment(4)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 154 | advanceClocks(time::nanoseconds(1)); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 155 | |
| 156 | // receive segment 5 |
| 157 | face.receive(*makeDataWithSegment(5)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 158 | advanceClocks(time::nanoseconds(1)); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 159 | |
Davide Pesavento | e9c6985 | 2017-11-04 18:08:37 -0400 | [diff] [blame] | 160 | BOOST_CHECK_EQUAL(pipeline->m_nReceived, 5); |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 161 | BOOST_CHECK_CLOSE(pipeline->m_cwnd, 4.75, MARGIN); |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 162 | BOOST_CHECK_EQUAL(face.sentInterests.size(), nDataSegments); // all the segment requests have been sent |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 163 | |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 164 | 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); |
schneiderklaus | 8ff3abd | 2019-03-12 22:15:12 -0700 | [diff] [blame] | 170 | |
| 171 | // timeout segment 3 & 6 |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 172 | advanceClocks(time::milliseconds(150)); |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 173 | 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 Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 177 | |
Davide Pesavento | e9c6985 | 2017-11-04 18:08:37 -0400 | [diff] [blame] | 178 | BOOST_CHECK_EQUAL(pipeline->m_nReceived, 5); |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 179 | BOOST_CHECK_CLOSE(pipeline->m_cwnd, 2.375, MARGIN); // window size drop to 1/2 of previous size |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 180 | BOOST_CHECK_EQUAL(pipeline->m_retxQueue.size(), 1); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 181 | |
| 182 | // receive segment 6, retransmit 3 |
| 183 | face.receive(*makeDataWithSegment(6)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 184 | advanceClocks(time::nanoseconds(1)); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 185 | |
Davide Pesavento | e9c6985 | 2017-11-04 18:08:37 -0400 | [diff] [blame] | 186 | BOOST_CHECK_EQUAL(pipeline->m_nReceived, 6); |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 187 | BOOST_CHECK_CLOSE(pipeline->m_cwnd, 2.875, MARGIN); // congestion avoidance |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 188 | BOOST_CHECK_EQUAL(pipeline->m_retxQueue.size(), 0); |
| 189 | BOOST_CHECK_EQUAL(pipeline->m_retxCount[3], 1); |
schneiderklaus | 8ff3abd | 2019-03-12 22:15:12 -0700 | [diff] [blame] | 190 | |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 191 | BOOST_CHECK_EQUAL(pipeline->m_nTimeouts, 2); |
| 192 | BOOST_CHECK_EQUAL(pipeline->m_nRetransmitted, 2); |
| 193 | BOOST_CHECK_EQUAL(pipeline->m_nTimeouts, |
| 194 | pipeline->m_nRetransmitted + pipeline->m_nSkippedRetx); |
schneiderklaus | 8ff3abd | 2019-03-12 22:15:12 -0700 | [diff] [blame] | 195 | |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 196 | } |
| 197 | |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 198 | BOOST_AUTO_TEST_CASE(CongestionMarksWithCwa) |
| 199 | { |
| 200 | nDataSegments = 7; |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 201 | pipeline->m_ssthresh = 4.0; |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 202 | BOOST_REQUIRE_CLOSE(pipeline->m_cwnd, 2, MARGIN); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 203 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 204 | run(name); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 205 | advanceClocks(time::nanoseconds(1)); |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 206 | BOOST_CHECK_EQUAL(face.sentInterests.size(), 2); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 207 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 208 | // receive segments 0 to 4 |
| 209 | for (uint64_t i = 0; i < 5; ++i) { |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 210 | face.receive(*makeDataWithSegment(i)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 211 | advanceClocks(time::nanoseconds(1)); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | BOOST_CHECK_EQUAL(pipeline->m_nReceived, 5); |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 215 | BOOST_CHECK_CLOSE(pipeline->m_cwnd, 4.75, MARGIN); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 216 | |
| 217 | // receive segment 5 with congestion mark |
| 218 | face.receive(*makeDataWithSegmentAndCongMark(5)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 219 | advanceClocks(time::nanoseconds(1)); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 220 | |
| 221 | BOOST_CHECK_EQUAL(pipeline->m_nReceived, 6); |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 222 | BOOST_CHECK_CLOSE(pipeline->m_cwnd, 2.375, MARGIN); // window size drops to 1/2 of previous size |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 223 | BOOST_CHECK_EQUAL(face.sentInterests.size(), nDataSegments); // all interests have been sent |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 224 | |
| 225 | // receive the last segment with congestion mark |
| 226 | face.receive(*makeDataWithSegmentAndCongMark(nDataSegments - 1)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 227 | advanceClocks(time::nanoseconds(1)); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 228 | |
| 229 | BOOST_CHECK_EQUAL(pipeline->m_nReceived, nDataSegments); |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 230 | BOOST_CHECK_CLOSE(pipeline->m_cwnd, 2.375, MARGIN); // conservative window adaption (window size should not decrease) |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 231 | BOOST_CHECK_EQUAL(pipeline->m_retxQueue.size(), 0); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 232 | |
| 233 | // make sure no interest is retransmitted for marked data packets |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 234 | BOOST_CHECK_EQUAL(pipeline->m_retxCount[5], 0); |
| 235 | BOOST_CHECK_EQUAL(pipeline->m_retxCount[nDataSegments - 1], 0); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 236 | |
| 237 | // check number of received marked data packets |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 238 | BOOST_CHECK_EQUAL(pipeline->m_nCongMarks, 2); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | BOOST_AUTO_TEST_CASE(CongestionMarksWithoutCwa) |
| 242 | { |
| 243 | opt.disableCwa = true; |
| 244 | createPipeline(); |
| 245 | |
| 246 | nDataSegments = 7; |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 247 | pipeline->m_ssthresh = 4.0; |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 248 | BOOST_REQUIRE_CLOSE(pipeline->m_cwnd, 2, MARGIN); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 249 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 250 | run(name); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 251 | advanceClocks(time::nanoseconds(1)); |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 252 | BOOST_CHECK_EQUAL(face.sentInterests.size(), 2); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 253 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 254 | // receive segments 0 to 4 |
| 255 | for (uint64_t i = 0; i < 5; ++i) { |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 256 | face.receive(*makeDataWithSegment(i)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 257 | advanceClocks(time::nanoseconds(1)); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | BOOST_CHECK_EQUAL(pipeline->m_nReceived, 5); |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 261 | BOOST_CHECK_CLOSE(pipeline->m_cwnd, 4.75, MARGIN); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 262 | |
| 263 | // receive segment 5 with congestion mark |
| 264 | face.receive(*makeDataWithSegmentAndCongMark(5)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 265 | advanceClocks(time::nanoseconds(1)); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 266 | |
| 267 | BOOST_CHECK_EQUAL(pipeline->m_nReceived, 6); |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 268 | BOOST_CHECK_CLOSE(pipeline->m_cwnd, 2.375, MARGIN); // window size drops to 1/2 of previous size |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 269 | BOOST_CHECK_EQUAL(face.sentInterests.size(), nDataSegments); // all interests have been sent |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 270 | |
| 271 | // receive the last segment with congestion mark |
| 272 | face.receive(*makeDataWithSegmentAndCongMark(nDataSegments - 1)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 273 | advanceClocks(time::nanoseconds(1)); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 274 | |
| 275 | BOOST_CHECK_EQUAL(pipeline->m_nReceived, nDataSegments); |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 276 | BOOST_CHECK_CLOSE(pipeline->m_cwnd, PipelineInterestsAdaptive::MIN_SSTHRESH, |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 277 | MARGIN); // window size should decrease, as cwa is disabled |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 278 | BOOST_CHECK_EQUAL(pipeline->m_retxQueue.size(), 0); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 279 | |
| 280 | // make sure no interest is retransmitted for marked data packets |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 281 | BOOST_CHECK_EQUAL(pipeline->m_retxCount[5], 0); |
| 282 | BOOST_CHECK_EQUAL(pipeline->m_retxCount[nDataSegments - 1], 0); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 283 | |
| 284 | // check number of received marked data packets |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 285 | BOOST_CHECK_EQUAL(pipeline->m_nCongMarks, 2); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | BOOST_AUTO_TEST_CASE(IgnoreCongestionMarks) |
| 289 | { |
| 290 | opt.ignoreCongMarks = true; |
| 291 | createPipeline(); |
| 292 | |
| 293 | nDataSegments = 7; |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 294 | pipeline->m_ssthresh = 4.0; |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 295 | BOOST_REQUIRE_CLOSE(pipeline->m_cwnd, 2, MARGIN); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 296 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 297 | run(name); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 298 | advanceClocks(time::nanoseconds(1)); |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 299 | BOOST_CHECK_EQUAL(face.sentInterests.size(), 2); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 300 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 301 | // receive segments 0 to 5 |
| 302 | for (uint64_t i = 0; i < 6; ++i) { |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 303 | face.receive(*makeDataWithSegment(i)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 304 | advanceClocks(time::nanoseconds(1)); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | BOOST_CHECK_EQUAL(pipeline->m_nReceived, 6); |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 308 | BOOST_CHECK_CLOSE(pipeline->m_cwnd, 5.0, MARGIN); |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 309 | BOOST_CHECK_EQUAL(face.sentInterests.size(), nDataSegments); // all interests have been sent |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 310 | |
| 311 | // receive the last segment with congestion mark |
| 312 | face.receive(*makeDataWithSegmentAndCongMark(nDataSegments - 1)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 313 | advanceClocks(time::nanoseconds(1)); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 314 | |
| 315 | BOOST_CHECK_EQUAL(pipeline->m_nReceived, nDataSegments); |
Klaus Schneider | 4a2e89d | 2019-10-27 10:04:39 -0700 | [diff] [blame] | 316 | BOOST_CHECK_CLOSE(pipeline->m_cwnd, 5.2, MARGIN); // window size increases |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 317 | BOOST_CHECK_EQUAL(pipeline->m_retxQueue.size(), 0); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 318 | |
| 319 | // make sure no interest is retransmitted for marked data packet |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 320 | BOOST_CHECK_EQUAL(pipeline->m_retxCount[nDataSegments - 1], 0); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 321 | |
| 322 | // check number of received marked data packets |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 323 | BOOST_CHECK_EQUAL(pipeline->m_nCongMarks, 1); |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 324 | } |
| 325 | |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 326 | BOOST_AUTO_TEST_CASE(Nack) |
| 327 | { |
| 328 | nDataSegments = 5; |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 329 | pipeline->m_cwnd = 10.0; |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 330 | run(name); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 331 | advanceClocks(time::nanoseconds(1)); |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 332 | |
| 333 | face.receive(*makeDataWithSegment(0)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 334 | advanceClocks(time::nanoseconds(1)); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 335 | |
| 336 | face.receive(*makeDataWithSegment(1)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 337 | advanceClocks(time::nanoseconds(1)); |
Davide Pesavento | e9c6985 | 2017-11-04 18:08:37 -0400 | [diff] [blame] | 338 | |
| 339 | BOOST_CHECK_EQUAL(pipeline->m_nReceived, 2); |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 340 | BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 10); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 341 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 342 | // receive a nack with NackReason::DUPLICATE for segment 1 |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 343 | auto nack1 = makeNack(face.sentInterests[1], lp::NackReason::DUPLICATE); |
| 344 | face.receive(nack1); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 345 | advanceClocks(time::nanoseconds(1)); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 346 | |
| 347 | // nack1 is ignored |
| 348 | BOOST_CHECK_EQUAL(hasFailed, false); |
Davide Pesavento | e9c6985 | 2017-11-04 18:08:37 -0400 | [diff] [blame] | 349 | BOOST_CHECK_EQUAL(pipeline->m_nReceived, 2); |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 350 | BOOST_CHECK_EQUAL(pipeline->m_retxQueue.size(), 0); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 351 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 352 | // receive a nack with NackReason::CONGESTION for segment 2 |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 353 | auto nack2 = makeNack(face.sentInterests[2], lp::NackReason::CONGESTION); |
| 354 | face.receive(nack2); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 355 | advanceClocks(time::nanoseconds(1)); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 356 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 357 | // segment 2 is retransmitted |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 358 | BOOST_CHECK_EQUAL(pipeline->m_retxCount[2], 1); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 359 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 360 | // receive a nack with NackReason::NONE for segment 3 |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 361 | auto nack3 = makeNack(face.sentInterests[3], lp::NackReason::NONE); |
| 362 | face.receive(nack3); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 363 | advanceClocks(time::nanoseconds(1)); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 364 | |
| 365 | // Other types of Nack will trigger a failure |
| 366 | BOOST_CHECK_EQUAL(hasFailed, true); |
Davide Pesavento | e9c6985 | 2017-11-04 18:08:37 -0400 | [diff] [blame] | 367 | BOOST_CHECK_EQUAL(pipeline->m_nReceived, 2); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | BOOST_AUTO_TEST_CASE(FinalBlockIdNotSetAtBeginning) |
| 371 | { |
| 372 | nDataSegments = 4; |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 373 | pipeline->m_cwnd = 4; |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 374 | run(name); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 375 | advanceClocks(time::nanoseconds(1)); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 376 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 377 | // receive segment 0 without FinalBlockId |
| 378 | face.receive(*makeDataWithSegment(0, false)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 379 | advanceClocks(time::nanoseconds(1)); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 380 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 381 | // interests for segment 0 - 5 have been sent |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 382 | BOOST_CHECK_EQUAL(face.sentInterests.size(), 6); |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 383 | BOOST_CHECK_EQUAL(pipeline->m_nReceived, 1); |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 384 | BOOST_CHECK_EQUAL(pipeline->m_hasFinalBlockId, false); |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 385 | // pending interests: segment 1, 2, 3, 4, 5 |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 386 | BOOST_CHECK_EQUAL(face.getNPendingInterests(), 5); |
| 387 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 388 | // receive segment 1 with FinalBlockId |
| 389 | face.receive(*makeDataWithSegment(1)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 390 | advanceClocks(time::nanoseconds(1)); |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 391 | BOOST_CHECK_EQUAL(pipeline->m_nReceived, 2); |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 392 | BOOST_CHECK_EQUAL(pipeline->m_hasFinalBlockId, true); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 393 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 394 | // pending interests for segment 1, 4, 5 haven been removed |
| 395 | BOOST_CHECK_EQUAL(face.getNPendingInterests(), 2); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | BOOST_AUTO_TEST_CASE(FailureBeforeFinalBlockIdReceived) |
| 399 | { |
| 400 | // failed to retrieve segNo while the FinalBlockId has not yet been |
| 401 | // set, and later received a FinalBlockId >= segNo, i.e. segNo is |
| 402 | // part of the content. |
| 403 | |
| 404 | nDataSegments = 4; |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 405 | pipeline->m_cwnd = 4; |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 406 | run(name); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 407 | advanceClocks(time::nanoseconds(1)); |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 408 | |
| 409 | // receive segment 0 without FinalBlockId |
| 410 | face.receive(*makeDataWithSegment(0, false)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 411 | advanceClocks(time::nanoseconds(1)); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 412 | |
| 413 | // receive segment 1 without FinalBlockId |
| 414 | face.receive(*makeDataWithSegment(1, false)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 415 | advanceClocks(time::nanoseconds(1)); |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 416 | |
| 417 | // interests for segment 0 - 7 have been sent |
| 418 | BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 8); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 419 | |
| 420 | // receive nack with NackReason::NONE for segment 3 |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 421 | auto nack = makeNack(face.sentInterests[3], lp::NackReason::NONE); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 422 | face.receive(nack); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 423 | advanceClocks(time::nanoseconds(1)); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 424 | |
| 425 | // error not triggered |
| 426 | // pending interests for segment > 3 haven been removed |
| 427 | BOOST_CHECK_EQUAL(hasFailed, false); |
| 428 | BOOST_CHECK_EQUAL(face.getNPendingInterests(), 1); |
| 429 | |
| 430 | // receive segment 2 with FinalBlockId |
| 431 | face.receive(*makeDataWithSegment(2)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 432 | advanceClocks(time::nanoseconds(1)); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 433 | |
| 434 | // error triggered since segment 3 is part of the content |
| 435 | BOOST_CHECK_EQUAL(hasFailed, true); |
| 436 | } |
| 437 | |
| 438 | BOOST_AUTO_TEST_CASE(SpuriousFailureBeforeFinalBlockIdReceived) |
| 439 | { |
| 440 | // failed to retrieve segNo while the FinalBlockId has not yet been |
| 441 | // set, and later received a FinalBlockId < segNo, i.e. segNo is |
| 442 | // not part of the content, and it was actually a spurious failure |
| 443 | |
| 444 | nDataSegments = 4; |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 445 | pipeline->m_cwnd = 4; |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 446 | run(name); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 447 | advanceClocks(time::nanoseconds(1)); |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 448 | |
| 449 | // receive segment 0 without FinalBlockId |
| 450 | face.receive(*makeDataWithSegment(0, false)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 451 | advanceClocks(time::nanoseconds(1)); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 452 | |
| 453 | // receive segment 1 without FinalBlockId |
| 454 | face.receive(*makeDataWithSegment(1, false)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 455 | advanceClocks(time::nanoseconds(1)); |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 456 | |
| 457 | // interests for segment 0 - 7 have been sent |
| 458 | BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 8); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 459 | |
| 460 | // receive nack with NackReason::NONE for segment 4 |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 461 | auto nack = makeNack(face.sentInterests[4], lp::NackReason::NONE); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 462 | face.receive(nack); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 463 | advanceClocks(time::nanoseconds(1)); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 464 | |
| 465 | // error not triggered |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 466 | // pending interests for segment > 3 have been removed |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 467 | BOOST_CHECK_EQUAL(hasFailed, false); |
| 468 | BOOST_CHECK_EQUAL(face.getNPendingInterests(), 2); |
| 469 | |
| 470 | // receive segment 2 with FinalBlockId |
| 471 | face.receive(*makeDataWithSegment(2)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 472 | advanceClocks(time::nanoseconds(1)); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 473 | |
| 474 | // timeout segment 3 |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 475 | advanceClocks(time::seconds(1)); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 476 | |
| 477 | // segment 3 is retransmitted |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 478 | BOOST_CHECK_EQUAL(pipeline->m_retxCount[3], 1); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 479 | |
| 480 | // receive segment 3 |
| 481 | face.receive(*makeDataWithSegment(3)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 482 | advanceClocks(time::nanoseconds(1)); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 483 | |
| 484 | BOOST_CHECK_EQUAL(hasFailed, false); |
| 485 | } |
| 486 | |
Ryan Wickman | 2c9933c | 2018-06-12 11:51:51 -0500 | [diff] [blame] | 487 | BOOST_AUTO_TEST_CASE(SegmentInfoMaintenance) |
| 488 | { |
| 489 | // test that m_segmentInfo is properly maintained when |
| 490 | // a segment is received after two consecutive timeouts |
| 491 | |
| 492 | nDataSegments = 3; |
| 493 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 494 | run(name); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 495 | advanceClocks(time::nanoseconds(1)); |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 496 | |
| 497 | // receive segment 0 |
| 498 | face.receive(*makeDataWithSegment(0)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 499 | advanceClocks(time::nanoseconds(1)); |
Ryan Wickman | 2c9933c | 2018-06-12 11:51:51 -0500 | [diff] [blame] | 500 | |
| 501 | // receive segment 1 |
| 502 | face.receive(*makeDataWithSegment(1)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 503 | advanceClocks(time::nanoseconds(1)); |
Ryan Wickman | 2c9933c | 2018-06-12 11:51:51 -0500 | [diff] [blame] | 504 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 505 | BOOST_CHECK_EQUAL(face.sentInterests.size(), 3); |
Ryan Wickman | 2c9933c | 2018-06-12 11:51:51 -0500 | [diff] [blame] | 506 | |
| 507 | // check if segment 2's state is FirstTimeSent |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 508 | auto it = pipeline->m_segmentInfo.find(2); |
| 509 | BOOST_REQUIRE(it != pipeline->m_segmentInfo.end()); |
Ryan Wickman | 2c9933c | 2018-06-12 11:51:51 -0500 | [diff] [blame] | 510 | BOOST_CHECK(it->second.state == SegmentState::FirstTimeSent); |
| 511 | |
| 512 | // timeout segment 2 twice |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 513 | advanceClocks(time::milliseconds(400), 3); |
Ryan Wickman | 2c9933c | 2018-06-12 11:51:51 -0500 | [diff] [blame] | 514 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 515 | BOOST_CHECK_EQUAL(face.sentInterests.size(), 5); |
Ryan Wickman | 2c9933c | 2018-06-12 11:51:51 -0500 | [diff] [blame] | 516 | |
| 517 | // check if segment 2's state is Retransmitted |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 518 | it = pipeline->m_segmentInfo.find(2); |
| 519 | BOOST_REQUIRE(it != pipeline->m_segmentInfo.end()); |
Ryan Wickman | 2c9933c | 2018-06-12 11:51:51 -0500 | [diff] [blame] | 520 | BOOST_CHECK(it->second.state == SegmentState::Retransmitted); |
| 521 | |
| 522 | // check if segment 2 was retransmitted twice |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 523 | BOOST_CHECK_EQUAL(pipeline->m_retxCount.at(2), 2); |
Ryan Wickman | 2c9933c | 2018-06-12 11:51:51 -0500 | [diff] [blame] | 524 | |
| 525 | // receive segment 2 the first time |
| 526 | face.receive(*makeDataWithSegment(2)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 527 | advanceClocks(time::nanoseconds(1)); |
Ryan Wickman | 2c9933c | 2018-06-12 11:51:51 -0500 | [diff] [blame] | 528 | |
| 529 | // check if segment 2 was erased from m_segmentInfo |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 530 | it = pipeline->m_segmentInfo.find(2); |
| 531 | BOOST_CHECK(it == pipeline->m_segmentInfo.end()); |
Ryan Wickman | 2c9933c | 2018-06-12 11:51:51 -0500 | [diff] [blame] | 532 | |
| 533 | auto prevRtt = rttEstimator.getAvgRtt(); |
| 534 | auto prevRto = rttEstimator.getEstimatedRto(); |
| 535 | |
| 536 | // receive segment 2 the second time |
| 537 | face.receive(*makeDataWithSegment(2)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 538 | advanceClocks(time::nanoseconds(1)); |
Ryan Wickman | 2c9933c | 2018-06-12 11:51:51 -0500 | [diff] [blame] | 539 | |
| 540 | // nothing changed |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 541 | it = pipeline->m_segmentInfo.find(2); |
| 542 | BOOST_CHECK(it == pipeline->m_segmentInfo.end()); |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 543 | BOOST_CHECK_EQUAL(face.sentInterests.size(), 5); |
Ryan Wickman | 2c9933c | 2018-06-12 11:51:51 -0500 | [diff] [blame] | 544 | BOOST_CHECK_EQUAL(rttEstimator.getAvgRtt(), prevRtt); |
| 545 | BOOST_CHECK_EQUAL(rttEstimator.getEstimatedRto(), prevRto); |
| 546 | } |
| 547 | |
Chavoosh Ghasemi | 75309ae | 2018-03-26 14:46:24 -0400 | [diff] [blame] | 548 | BOOST_AUTO_TEST_CASE(PrintSummaryWithNoRttMeasurements) |
| 549 | { |
| 550 | // test the console ouptut when no RTT measurement is available, |
| 551 | // to make sure a proper message will be printed out |
| 552 | |
| 553 | std::stringstream ss; |
| 554 | |
| 555 | // change the underlying buffer and save the old buffer |
| 556 | auto oldBuf = std::cerr.rdbuf(ss.rdbuf()); |
| 557 | |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 558 | pipeline->printSummary(); |
Chavoosh Ghasemi | 75309ae | 2018-03-26 14:46:24 -0400 | [diff] [blame] | 559 | std::string line; |
| 560 | |
| 561 | bool found = false; |
| 562 | while (std::getline(ss, line)) { |
| 563 | if (line == "RTT stats unavailable") { |
| 564 | found = true; |
| 565 | break; |
| 566 | } |
| 567 | } |
| 568 | BOOST_CHECK(found); |
| 569 | std::cerr.rdbuf(oldBuf); // reset |
| 570 | } |
| 571 | |
Ryan Wickman | 034f30f | 2018-06-06 11:11:11 -0500 | [diff] [blame] | 572 | BOOST_AUTO_TEST_CASE(StopsWhenFileSizeLessThanChunkSize) |
| 573 | { |
| 574 | // test to see if the program doesn't hang, |
| 575 | // when transfer is complete, for files less than the chunk size |
| 576 | // (i.e. when only one segment is sent/received) |
| 577 | |
| 578 | createPipeline(); |
| 579 | nDataSegments = 1; |
| 580 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 581 | run(name); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 582 | advanceClocks(time::nanoseconds(1)); |
Ryan Wickman | 034f30f | 2018-06-06 11:11:11 -0500 | [diff] [blame] | 583 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame] | 584 | face.receive(*makeDataWithSegment(0)); |
Davide Pesavento | 6677762 | 2020-10-09 18:46:03 -0400 | [diff] [blame] | 585 | advanceClocks(time::nanoseconds(1)); |
Ryan Wickman | 034f30f | 2018-06-06 11:11:11 -0500 | [diff] [blame] | 586 | |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 587 | BOOST_CHECK_EQUAL(pipeline->m_hasFinalBlockId, true); |
| 588 | BOOST_CHECK_EQUAL(pipeline->m_segmentInfo.size(), 0); |
Ryan Wickman | 034f30f | 2018-06-06 11:11:11 -0500 | [diff] [blame] | 589 | BOOST_CHECK_EQUAL(face.getNPendingInterests(), 0); |
| 590 | } |
| 591 | |
| 592 | |
Klaus Schneider | 9e5122b | 2019-03-19 17:03:25 -0700 | [diff] [blame] | 593 | BOOST_AUTO_TEST_SUITE_END() // TestPipelineInterestsAimd |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 594 | BOOST_AUTO_TEST_SUITE_END() // Chunks |
| 595 | |
Davide Pesavento | b3570c6 | 2022-02-19 19:19:00 -0500 | [diff] [blame^] | 596 | } // namespace ndn::chunks::tests |