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