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