Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [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 | bf1c069 | 2017-01-15 19:15:09 -0500 | [diff] [blame] | 4 | * Colorado State University, |
| 5 | * University Pierre & Marie Curie, Sorbonne University. |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [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 Andrea Tosatto |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame^] | 24 | * @author Chavoosh Ghasemi |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 25 | */ |
| 26 | |
Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 27 | #include "tools/chunks/catchunks/pipeline-interests-fixed-window.hpp" |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 28 | #include "tools/chunks/catchunks/data-fetcher.hpp" |
| 29 | |
Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 30 | #include "pipeline-interests-fixture.hpp" |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 31 | |
| 32 | namespace ndn { |
| 33 | namespace chunks { |
| 34 | namespace tests { |
| 35 | |
Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 36 | class PipelineInterestFixedWindowFixture : public PipelineInterestsFixture |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 37 | { |
| 38 | public: |
Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 39 | PipelineInterestFixedWindowFixture() |
Davide Pesavento | f6991e1 | 2018-01-08 20:58:50 -0500 | [diff] [blame] | 40 | : opt(makeOptions()) |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 41 | { |
Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 42 | setPipeline(make_unique<PipelineInterestsFixedWindow>(face, PipelineInterestsFixedWindow::Options(opt))); |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 43 | } |
Davide Pesavento | e9c6985 | 2017-11-04 18:08:37 -0400 | [diff] [blame] | 44 | |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 45 | private: |
Davide Pesavento | f6991e1 | 2018-01-08 20:58:50 -0500 | [diff] [blame] | 46 | static PipelineInterestsFixedWindow::Options |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 47 | makeOptions() |
| 48 | { |
Davide Pesavento | f6991e1 | 2018-01-08 20:58:50 -0500 | [diff] [blame] | 49 | PipelineInterestsFixedWindow::Options options; |
| 50 | options.isQuiet = true; |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 51 | options.isVerbose = false; |
| 52 | options.interestLifetime = time::seconds(1); |
| 53 | options.maxRetriesOnTimeoutOrNack = 3; |
| 54 | options.maxPipelineSize = 5; |
| 55 | return options; |
| 56 | } |
Davide Pesavento | f6991e1 | 2018-01-08 20:58:50 -0500 | [diff] [blame] | 57 | |
| 58 | protected: |
| 59 | PipelineInterestsFixedWindow::Options opt; |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | BOOST_AUTO_TEST_SUITE(Chunks) |
Davide Pesavento | e9c6985 | 2017-11-04 18:08:37 -0400 | [diff] [blame] | 63 | BOOST_FIXTURE_TEST_SUITE(TestPipelineInterestsFixedWindow, PipelineInterestFixedWindowFixture) |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 64 | |
Davide Pesavento | e9c6985 | 2017-11-04 18:08:37 -0400 | [diff] [blame] | 65 | BOOST_AUTO_TEST_CASE(FullPipeline) |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 66 | { |
| 67 | nDataSegments = 13; |
| 68 | BOOST_ASSERT(nDataSegments > opt.maxPipelineSize); |
| 69 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame^] | 70 | run(name); |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 71 | advanceClocks(io, time::nanoseconds(1), 1); |
| 72 | BOOST_REQUIRE_EQUAL(face.sentInterests.size(), opt.maxPipelineSize); |
| 73 | |
| 74 | for (uint64_t i = 0; i < nDataSegments - 1; ++i) { |
| 75 | face.receive(*makeDataWithSegment(i)); |
| 76 | advanceClocks(io, time::nanoseconds(1), 1); |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame^] | 77 | BOOST_CHECK_EQUAL(pipeline->m_nReceived, i + 1); |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 78 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame^] | 79 | if (i < nDataSegments - opt.maxPipelineSize) { |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 80 | BOOST_REQUIRE_EQUAL(face.sentInterests.size(), opt.maxPipelineSize + i + 1); |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame^] | 81 | // check if the interest for the segment i is well formed |
Davide Pesavento | bf1c069 | 2017-01-15 19:15:09 -0500 | [diff] [blame] | 82 | const auto& sentInterest = face.sentInterests[i]; |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 83 | BOOST_CHECK_EQUAL(sentInterest.getExclude().size(), 0); |
| 84 | BOOST_CHECK_EQUAL(sentInterest.getMaxSuffixComponents(), 1); |
| 85 | BOOST_CHECK_EQUAL(sentInterest.getMustBeFresh(), opt.mustBeFresh); |
| 86 | BOOST_CHECK_EQUAL(Name(name).isPrefixOf(sentInterest.getName()), true); |
Davide Pesavento | bf1c069 | 2017-01-15 19:15:09 -0500 | [diff] [blame] | 87 | BOOST_CHECK_EQUAL(getSegmentFromPacket(sentInterest), i); |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 88 | } |
| 89 | else { |
| 90 | // all the interests have been sent for all the segments |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame^] | 91 | BOOST_CHECK_EQUAL(face.sentInterests.size(), nDataSegments); |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 92 | } |
| 93 | } |
| 94 | |
| 95 | BOOST_CHECK_EQUAL(hasFailed, false); |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame^] | 96 | |
| 97 | advanceClocks(io, ndn::DEFAULT_INTEREST_LIFETIME, opt.maxRetriesOnTimeoutOrNack + 1); |
| 98 | BOOST_CHECK_EQUAL(hasFailed, true); |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 99 | } |
| 100 | |
Davide Pesavento | e9c6985 | 2017-11-04 18:08:37 -0400 | [diff] [blame] | 101 | BOOST_AUTO_TEST_CASE(TimeoutAllSegments) |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 102 | { |
| 103 | nDataSegments = 13; |
| 104 | BOOST_ASSERT(nDataSegments > opt.maxPipelineSize); |
| 105 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame^] | 106 | run(name); |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 107 | advanceClocks(io, time::nanoseconds(1), 1); |
| 108 | BOOST_REQUIRE_EQUAL(face.sentInterests.size(), opt.maxPipelineSize); |
| 109 | |
| 110 | for (int i = 0; i < opt.maxRetriesOnTimeoutOrNack; ++i) { |
| 111 | advanceClocks(io, opt.interestLifetime, 1); |
| 112 | BOOST_REQUIRE_EQUAL(face.sentInterests.size(), opt.maxPipelineSize * (i + 2)); |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame^] | 113 | BOOST_CHECK_EQUAL(pipeline->m_nReceived, 0); |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 114 | |
| 115 | // A single retry for every pipeline element |
| 116 | for (size_t j = 0; j < opt.maxPipelineSize; ++j) { |
Davide Pesavento | bf1c069 | 2017-01-15 19:15:09 -0500 | [diff] [blame] | 117 | const auto& interest = face.sentInterests[(opt.maxPipelineSize * (i + 1)) + j]; |
| 118 | BOOST_CHECK_EQUAL(static_cast<size_t>(getSegmentFromPacket(interest)), j); |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 119 | } |
| 120 | } |
| 121 | |
| 122 | advanceClocks(io, opt.interestLifetime, 1); |
| 123 | BOOST_CHECK_EQUAL(hasFailed, true); |
| 124 | } |
| 125 | |
Davide Pesavento | e9c6985 | 2017-11-04 18:08:37 -0400 | [diff] [blame] | 126 | BOOST_AUTO_TEST_CASE(TimeoutAfterFinalBlockIdReceived) |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 127 | { |
| 128 | // the FinalBlockId is sent with the first segment, after the first segment failure the pipeline |
| 129 | // should fail |
| 130 | |
| 131 | nDataSegments = 18; |
| 132 | BOOST_ASSERT(nDataSegments > opt.maxPipelineSize); |
| 133 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame^] | 134 | run(name); |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 135 | advanceClocks(io, time::nanoseconds(1), 1); |
| 136 | BOOST_REQUIRE_EQUAL(face.sentInterests.size(), opt.maxPipelineSize); |
| 137 | |
| 138 | // send a single segment for each pipeline element but not the first element |
| 139 | advanceClocks(io, opt.interestLifetime, 1); |
| 140 | for (uint64_t i = 1; i < opt.maxPipelineSize; ++i) { |
| 141 | face.receive(*makeDataWithSegment(i)); |
| 142 | advanceClocks(io, time::nanoseconds(1), 1); |
| 143 | } |
| 144 | |
| 145 | // send a single data packet for each pipeline element |
| 146 | advanceClocks(io, opt.interestLifetime, opt.maxRetriesOnTimeoutOrNack - 1); |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame^] | 147 | for (uint64_t i = 0; i < opt.maxPipelineSize; ++i) { |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 148 | face.receive(*makeDataWithSegment(opt.maxPipelineSize + i)); |
| 149 | advanceClocks(io, time::nanoseconds(1), 1); |
| 150 | } |
| 151 | advanceClocks(io, opt.interestLifetime, 1); |
| 152 | |
| 153 | size_t interestAfterFailure = face.sentInterests.size(); |
| 154 | |
| 155 | BOOST_CHECK_EQUAL(face.getNPendingInterests(), 0); |
| 156 | BOOST_CHECK_EQUAL(hasFailed, true); |
| 157 | |
| 158 | // these new segments should not generate new interests |
| 159 | advanceClocks(io, opt.interestLifetime, 1); |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame^] | 160 | for (uint64_t i = 0; i < opt.maxPipelineSize; ++i) { |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 161 | face.receive(*makeDataWithSegment(opt.maxPipelineSize * 2 + i - 1)); |
| 162 | advanceClocks(io, time::nanoseconds(1), 1); |
| 163 | } |
| 164 | |
| 165 | // no more interests after a failure |
| 166 | advanceClocks(io, opt.interestLifetime, opt.maxRetriesOnTimeoutOrNack); |
| 167 | BOOST_CHECK_EQUAL(interestAfterFailure, face.sentInterests.size()); |
| 168 | BOOST_CHECK_EQUAL(face.getNPendingInterests(), 0); |
| 169 | } |
| 170 | |
Davide Pesavento | e9c6985 | 2017-11-04 18:08:37 -0400 | [diff] [blame] | 171 | BOOST_AUTO_TEST_CASE(TimeoutBeforeFinalBlockIdReceived) |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 172 | { |
| 173 | // the FinalBlockId is sent only with the last segment, all segments are sent except for the |
| 174 | // second one (segment #1); all segments are received correctly until the FinalBlockId is received |
| 175 | |
| 176 | nDataSegments = 22; |
| 177 | BOOST_ASSERT(nDataSegments > opt.maxPipelineSize); |
| 178 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame^] | 179 | run(name); |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 180 | advanceClocks(io, time::nanoseconds(1), 1); |
| 181 | BOOST_REQUIRE_EQUAL(face.sentInterests.size(), opt.maxPipelineSize); |
| 182 | |
| 183 | advanceClocks(io, opt.interestLifetime, 1); |
| 184 | for (uint64_t i = 2; i < opt.maxPipelineSize; ++i) { |
| 185 | face.receive(*makeDataWithSegment(i, false)); |
| 186 | advanceClocks(io, time::nanoseconds(1), 1); |
| 187 | |
Davide Pesavento | bf1c069 | 2017-01-15 19:15:09 -0500 | [diff] [blame] | 188 | const auto& lastInterest = face.sentInterests.back(); |
| 189 | BOOST_CHECK_EQUAL(getSegmentFromPacket(lastInterest), opt.maxPipelineSize + i - 2); |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 190 | } |
| 191 | BOOST_REQUIRE_EQUAL(face.sentInterests.size(), opt.maxPipelineSize * 3 - 2); |
| 192 | |
| 193 | // nack for the first pipeline element (segment #0) |
| 194 | auto nack = make_shared<lp::Nack>(face.sentInterests[opt.maxPipelineSize]); |
| 195 | nack->setReason(lp::NackReason::DUPLICATE); |
| 196 | face.receive(*nack); |
| 197 | |
| 198 | // all the pipeline elements are two retries near the timeout error, but not the |
| 199 | // second (segment #1) that is only one retry near the timeout |
| 200 | advanceClocks(io, opt.interestLifetime, opt.maxRetriesOnTimeoutOrNack - 1); |
| 201 | BOOST_CHECK_EQUAL(hasFailed, false); |
| 202 | |
| 203 | // data for the first pipeline element (segment #0) |
| 204 | face.receive(*makeDataWithSegment(0, false)); |
| 205 | BOOST_CHECK_EQUAL(hasFailed, false); |
| 206 | |
| 207 | // data for all the pipeline element, but not the second (segment #1) |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame^] | 208 | for (uint64_t i = opt.maxPipelineSize; i < nDataSegments; ++i) { |
| 209 | if (i == nDataSegments - 1) { |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 210 | face.receive(*makeDataWithSegment(i, true)); |
| 211 | } |
| 212 | else { |
| 213 | face.receive(*makeDataWithSegment(i, false)); |
| 214 | } |
| 215 | advanceClocks(io, time::nanoseconds(1), 1); |
| 216 | } |
| 217 | // timeout for the second pipeline element (segment #1), this should trigger an error |
| 218 | advanceClocks(io, opt.interestLifetime, 1); |
| 219 | |
Davide Pesavento | e9c6985 | 2017-11-04 18:08:37 -0400 | [diff] [blame] | 220 | BOOST_CHECK_EQUAL(pipeline->m_nReceived, nDataSegments - 1); |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 221 | BOOST_CHECK_EQUAL(hasFailed, true); |
| 222 | } |
| 223 | |
Davide Pesavento | e9c6985 | 2017-11-04 18:08:37 -0400 | [diff] [blame] | 224 | BOOST_AUTO_TEST_CASE(SegmentReceivedAfterTimeout) |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 225 | { |
| 226 | // the FinalBlockId is never sent, all the pipeline elements with a segment number greater than |
| 227 | // segment #0 will fail, after this failure also segment #0 fail and this should trigger an error |
| 228 | |
| 229 | nDataSegments = 22; |
| 230 | BOOST_ASSERT(nDataSegments > opt.maxPipelineSize); |
| 231 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame^] | 232 | run(name); |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 233 | advanceClocks(io, time::nanoseconds(1), 1); |
| 234 | BOOST_REQUIRE_EQUAL(face.sentInterests.size(), opt.maxPipelineSize); |
| 235 | |
| 236 | advanceClocks(io, opt.interestLifetime, 1); |
| 237 | |
| 238 | // nack for the first pipeline element (segment #0) |
| 239 | auto nack = make_shared<lp::Nack>(face.sentInterests[opt.maxPipelineSize]); |
| 240 | nack->setReason(lp::NackReason::DUPLICATE); |
| 241 | face.receive(*nack); |
| 242 | BOOST_CHECK_EQUAL(hasFailed, false); |
| 243 | |
| 244 | // timeout for all the pipeline elements, but not the first (segment #0) |
| 245 | advanceClocks(io, opt.interestLifetime, opt.maxRetriesOnTimeoutOrNack); |
| 246 | BOOST_CHECK_EQUAL(hasFailed, false); |
| 247 | |
| 248 | // data for the first pipeline element (segment #0), this should trigger an error because the |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame^] | 249 | // other pipeline elements failed |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 250 | face.receive(*makeDataWithSegment(0, false)); |
| 251 | advanceClocks(io, time::nanoseconds(1), 1); |
| 252 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame^] | 253 | BOOST_CHECK_EQUAL(pipeline->m_nReceived, 1); |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 254 | BOOST_CHECK_EQUAL(hasFailed, true); |
| 255 | } |
| 256 | |
Davide Pesavento | e9c6985 | 2017-11-04 18:08:37 -0400 | [diff] [blame] | 257 | BOOST_AUTO_TEST_CASE(CongestionAllSegments) |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 258 | { |
| 259 | nDataSegments = 13; |
| 260 | BOOST_ASSERT(nDataSegments > opt.maxPipelineSize); |
| 261 | |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame^] | 262 | run(name); |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 263 | advanceClocks(io, time::nanoseconds(1), 1); |
| 264 | BOOST_REQUIRE_EQUAL(face.sentInterests.size(), opt.maxPipelineSize); |
| 265 | |
| 266 | // send nack for all the pipeline elements first interest |
Chavoosh Ghasemi | 5cb6701 | 2019-02-15 09:56:57 -0800 | [diff] [blame^] | 267 | for (size_t i = 0; i < opt.maxPipelineSize; i++) { |
| 268 | auto nack = make_shared<lp::Nack>(face.sentInterests[i]); |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 269 | nack->setReason(lp::NackReason::CONGESTION); |
| 270 | face.receive(*nack); |
| 271 | advanceClocks(io, time::nanoseconds(1), 1); |
| 272 | } |
| 273 | |
| 274 | // send nack for all the pipeline elements interests after the first |
| 275 | for (int i = 1; i <= opt.maxRetriesOnTimeoutOrNack; ++i) { |
| 276 | time::milliseconds backoffTime(static_cast<uint64_t>(std::pow(2, i))); |
| 277 | if (backoffTime > DataFetcher::MAX_CONGESTION_BACKOFF_TIME) |
| 278 | backoffTime = DataFetcher::MAX_CONGESTION_BACKOFF_TIME; |
| 279 | |
| 280 | advanceClocks(io, backoffTime, 1); |
| 281 | BOOST_REQUIRE_EQUAL(face.sentInterests.size(), opt.maxPipelineSize * (i +1)); |
| 282 | |
| 283 | // A single retry for every pipeline element |
| 284 | for (size_t j = 0; j < opt.maxPipelineSize; ++j) { |
Davide Pesavento | bf1c069 | 2017-01-15 19:15:09 -0500 | [diff] [blame] | 285 | const auto& interest = face.sentInterests[(opt.maxPipelineSize * i) + j]; |
| 286 | BOOST_CHECK_LT(static_cast<size_t>(getSegmentFromPacket(interest)), opt.maxPipelineSize); |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | for (size_t j = 0; j < opt.maxPipelineSize; j++) { |
| 290 | auto nack = make_shared<lp::Nack>(face.sentInterests[(opt.maxPipelineSize * i) + j]); |
| 291 | nack->setReason(lp::NackReason::CONGESTION); |
| 292 | face.receive(*nack); |
| 293 | advanceClocks(io, time::nanoseconds(1), 1); |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | BOOST_CHECK_EQUAL(hasFailed, true); |
| 298 | } |
| 299 | |
| 300 | BOOST_AUTO_TEST_SUITE_END() // TestPipelineInterests |
| 301 | BOOST_AUTO_TEST_SUITE_END() // Chunks |
| 302 | |
| 303 | } // namespace tests |
| 304 | } // namespace chunks |
| 305 | } // namespace ndn |