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