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