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