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