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