Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
ashiqopu | 3ad49db | 2018-10-20 22:38:47 +0000 | [diff] [blame] | 2 | /* |
Davide Pesavento | f56cf63 | 2024-01-27 22:22:06 -0500 | [diff] [blame] | 3 | * Copyright (c) 2014-2024, Regents of the University of California, |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 4 | * Arizona Board of Regents, |
| 5 | * Colorado State University, |
| 6 | * University Pierre & Marie Curie, Sorbonne University, |
| 7 | * Washington University in St. Louis, |
| 8 | * Beijing Institute of Technology, |
| 9 | * The University of Memphis. |
| 10 | * |
| 11 | * This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 12 | * See AUTHORS.md for complete list of NFD authors and contributors. |
| 13 | * |
| 14 | * NFD is free software: you can redistribute it and/or modify it under the terms |
| 15 | * of the GNU General Public License as published by the Free Software Foundation, |
| 16 | * either version 3 of the License, or (at your option) any later version. |
| 17 | * |
| 18 | * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 19 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 | * PURPOSE. See the GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License along with |
| 23 | * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 24 | */ |
| 25 | |
| 26 | /** \file |
| 27 | * This test suite tests localhost and localhop scope control in strategies. |
| 28 | */ |
| 29 | |
| 30 | // Strategies implementing namespace-based scope control, sorted alphabetically. |
| 31 | #include "fw/access-strategy.hpp" |
Ashlesh Gawande | 2a73f35 | 2016-12-01 15:37:03 +0000 | [diff] [blame] | 32 | #include "fw/asf-strategy.hpp" |
Davide Pesavento | 7922d12 | 2021-03-05 22:41:23 -0500 | [diff] [blame] | 33 | #include "fw/best-route-strategy.hpp" |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 34 | #include "fw/multicast-strategy.hpp" |
Klaus Schneider | cf1d0c0 | 2019-08-31 19:05:40 -0700 | [diff] [blame] | 35 | #include "fw/random-strategy.hpp" |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 36 | |
Davide Pesavento | cf7db2f | 2019-03-24 23:17:28 -0400 | [diff] [blame] | 37 | #include "tests/test-common.hpp" |
| 38 | #include "tests/daemon/face/dummy-face.hpp" |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 39 | #include "choose-strategy.hpp" |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 40 | #include "strategy-tester.hpp" |
Davide Pesavento | 3dade00 | 2019-03-19 11:29:56 -0600 | [diff] [blame] | 41 | |
Davide Pesavento | f56cf63 | 2024-01-27 22:22:06 -0500 | [diff] [blame] | 42 | #include <boost/mp11/list.hpp> |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 43 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 44 | namespace nfd::tests { |
| 45 | |
| 46 | using namespace nfd::fw; |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 47 | |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 48 | template<typename S> |
Davide Pesavento | cf7db2f | 2019-03-24 23:17:28 -0400 | [diff] [blame] | 49 | class StrategyScopeControlFixture : public GlobalIoTimeFixture |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 50 | { |
| 51 | public: |
| 52 | StrategyScopeControlFixture() |
| 53 | : limitedIo(this) |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 54 | , forwarder(faceTable) |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 55 | , strategy(choose<StrategyTester<S>>(forwarder)) |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 56 | , fib(forwarder.getFib()) |
| 57 | , pit(forwarder.getPit()) |
| 58 | , nonLocalFace1(make_shared<DummyFace>("dummy://1", "dummy://1", ndn::nfd::FACE_SCOPE_NON_LOCAL)) |
| 59 | , nonLocalFace2(make_shared<DummyFace>("dummy://2", "dummy://2", ndn::nfd::FACE_SCOPE_NON_LOCAL)) |
| 60 | , localFace3(make_shared<DummyFace>("dummy://3", "dummy://3", ndn::nfd::FACE_SCOPE_LOCAL)) |
| 61 | , localFace4(make_shared<DummyFace>("dummy://4", "dummy://4", ndn::nfd::FACE_SCOPE_LOCAL)) |
| 62 | { |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 63 | faceTable.add(nonLocalFace1); |
| 64 | faceTable.add(nonLocalFace2); |
| 65 | faceTable.add(localFace3); |
| 66 | faceTable.add(localFace4); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 67 | } |
| 68 | |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 69 | public: |
| 70 | LimitedIo limitedIo; |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 71 | |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 72 | FaceTable faceTable; |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 73 | Forwarder forwarder; |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 74 | StrategyTester<S>& strategy; |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 75 | Fib& fib; |
| 76 | Pit& pit; |
| 77 | |
| 78 | shared_ptr<Face> nonLocalFace1; |
| 79 | shared_ptr<Face> nonLocalFace2; |
| 80 | shared_ptr<Face> localFace3; |
| 81 | shared_ptr<Face> localFace4; |
| 82 | }; |
| 83 | |
| 84 | BOOST_AUTO_TEST_SUITE(Fw) |
| 85 | BOOST_AUTO_TEST_SUITE(TestStrategyScopeControl) |
| 86 | |
Davide Pesavento | 29abf4c | 2021-03-05 18:40:01 -0500 | [diff] [blame] | 87 | template<typename S, bool WillSendNackNoRoute, bool CanProcessNack, bool WillRejectPitEntry> |
Davide Pesavento | f56cf63 | 2024-01-27 22:22:06 -0500 | [diff] [blame] | 88 | struct Test |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 89 | { |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 90 | using Strategy = S; |
Davide Pesavento | f56cf63 | 2024-01-27 22:22:06 -0500 | [diff] [blame] | 91 | static constexpr bool canProcessNack = CanProcessNack; |
| 92 | static constexpr bool willRejectPitEntry = WillRejectPitEntry; |
| 93 | static constexpr bool willSendNackNoRoute = WillSendNackNoRoute; |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 94 | }; |
| 95 | |
Davide Pesavento | f56cf63 | 2024-01-27 22:22:06 -0500 | [diff] [blame] | 96 | using Tests = boost::mp11::mp_list< |
Davide Pesavento | 29abf4c | 2021-03-05 18:40:01 -0500 | [diff] [blame] | 97 | Test<AccessStrategy, false, false, true>, |
awlane | 9acba9c | 2024-01-26 18:10:39 -0600 | [diff] [blame] | 98 | Test<AsfStrategy, true, true, true>, |
Davide Pesavento | 7922d12 | 2021-03-05 22:41:23 -0500 | [diff] [blame] | 99 | Test<BestRouteStrategy, true, true, true>, |
Alexander Afanasyev | 4400e42 | 2021-02-17 11:17:33 -0500 | [diff] [blame] | 100 | Test<MulticastStrategy, false, false, false>, |
Davide Pesavento | 29abf4c | 2021-03-05 18:40:01 -0500 | [diff] [blame] | 101 | Test<RandomStrategy, true, true, true> |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 102 | >; |
| 103 | |
| 104 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhostInterestToLocal, |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 105 | T, Tests, StrategyScopeControlFixture<typename T::Strategy>) |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 106 | { |
| 107 | fib::Entry* fibEntry = this->fib.insert("/localhost/A").first; |
Ju Pan | d8315bf | 2019-07-31 06:59:07 +0000 | [diff] [blame] | 108 | this->fib.addOrUpdateNextHop(*fibEntry, *this->localFace4, 10); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 109 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 110 | auto interest = makeInterest("/localhost/A/1"); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 111 | shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first; |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 112 | pitEntry->insertOrUpdateInRecord(*this->localFace3, *interest); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 113 | |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 114 | BOOST_REQUIRE(this->strategy.waitForAction( |
Teng Liang | d94b7b3 | 2022-07-10 21:29:37 +0800 | [diff] [blame] | 115 | [&] { this->strategy.afterReceiveInterest(*interest, FaceEndpoint(*this->localFace3), pitEntry); }, |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 116 | this->limitedIo)); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 117 | |
| 118 | BOOST_CHECK_EQUAL(this->strategy.sendInterestHistory.size(), 1); |
| 119 | BOOST_CHECK_EQUAL(this->strategy.rejectPendingInterestHistory.size(), 0); |
| 120 | BOOST_CHECK_EQUAL(this->strategy.sendNackHistory.size(), 0); |
| 121 | } |
| 122 | |
| 123 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhostInterestToNonLocal, |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 124 | T, Tests, StrategyScopeControlFixture<typename T::Strategy>) |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 125 | { |
| 126 | fib::Entry* fibEntry = this->fib.insert("/localhost/A").first; |
Ju Pan | d8315bf | 2019-07-31 06:59:07 +0000 | [diff] [blame] | 127 | this->fib.addOrUpdateNextHop(*fibEntry, *this->nonLocalFace2, 10); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 128 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 129 | auto interest = makeInterest("/localhost/A/1"); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 130 | shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first; |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 131 | pitEntry->insertOrUpdateInRecord(*this->localFace3, *interest); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 132 | |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 133 | BOOST_REQUIRE(this->strategy.waitForAction( |
Teng Liang | d94b7b3 | 2022-07-10 21:29:37 +0800 | [diff] [blame] | 134 | [&] { this->strategy.afterReceiveInterest(*interest, FaceEndpoint(*this->localFace3), pitEntry); }, |
Davide Pesavento | f56cf63 | 2024-01-27 22:22:06 -0500 | [diff] [blame] | 135 | this->limitedIo, T::willRejectPitEntry + T::willSendNackNoRoute)); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 136 | |
| 137 | BOOST_CHECK_EQUAL(this->strategy.sendInterestHistory.size(), 0); |
Davide Pesavento | f56cf63 | 2024-01-27 22:22:06 -0500 | [diff] [blame] | 138 | BOOST_CHECK_EQUAL(this->strategy.rejectPendingInterestHistory.size(), T::willRejectPitEntry); |
| 139 | if (T::willSendNackNoRoute) { |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 140 | BOOST_REQUIRE_EQUAL(this->strategy.sendNackHistory.size(), 1); |
| 141 | BOOST_CHECK_EQUAL(this->strategy.sendNackHistory.back().header.getReason(), lp::NackReason::NO_ROUTE); |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhostInterestToLocalAndNonLocal, |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 146 | T, Tests, StrategyScopeControlFixture<typename T::Strategy>) |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 147 | { |
| 148 | fib::Entry* fibEntry = this->fib.insert("/localhost/A").first; |
Ju Pan | d8315bf | 2019-07-31 06:59:07 +0000 | [diff] [blame] | 149 | this->fib.addOrUpdateNextHop(*fibEntry, *this->nonLocalFace2, 10); |
| 150 | this->fib.addOrUpdateNextHop(*fibEntry, *this->localFace4, 20); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 151 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 152 | auto interest = makeInterest("/localhost/A/1"); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 153 | shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first; |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 154 | pitEntry->insertOrUpdateInRecord(*this->localFace3, *interest); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 155 | |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 156 | BOOST_REQUIRE(this->strategy.waitForAction( |
Teng Liang | d94b7b3 | 2022-07-10 21:29:37 +0800 | [diff] [blame] | 157 | [&] { this->strategy.afterReceiveInterest(*interest, FaceEndpoint(*this->localFace3), pitEntry); }, |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 158 | this->limitedIo)); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 159 | |
| 160 | BOOST_REQUIRE_EQUAL(this->strategy.sendInterestHistory.size(), 1); |
| 161 | BOOST_CHECK_EQUAL(this->strategy.sendInterestHistory.back().outFaceId, this->localFace4->getId()); |
| 162 | BOOST_CHECK_EQUAL(this->strategy.rejectPendingInterestHistory.size(), 0); |
| 163 | BOOST_CHECK_EQUAL(this->strategy.sendNackHistory.size(), 0); |
| 164 | } |
| 165 | |
| 166 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhopInterestToNonLocal, |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 167 | T, Tests, StrategyScopeControlFixture<typename T::Strategy>) |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 168 | { |
| 169 | fib::Entry* fibEntry = this->fib.insert("/localhop/A").first; |
Ju Pan | d8315bf | 2019-07-31 06:59:07 +0000 | [diff] [blame] | 170 | this->fib.addOrUpdateNextHop(*fibEntry, *this->nonLocalFace2, 10); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 171 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 172 | auto interest = makeInterest("/localhop/A/1"); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 173 | shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first; |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 174 | pitEntry->insertOrUpdateInRecord(*this->nonLocalFace1, *interest); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 175 | |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 176 | BOOST_REQUIRE(this->strategy.waitForAction( |
Teng Liang | d94b7b3 | 2022-07-10 21:29:37 +0800 | [diff] [blame] | 177 | [&] { this->strategy.afterReceiveInterest(*interest, FaceEndpoint(*this->nonLocalFace1), pitEntry); }, |
Davide Pesavento | f56cf63 | 2024-01-27 22:22:06 -0500 | [diff] [blame] | 178 | this->limitedIo, T::willRejectPitEntry + T::willSendNackNoRoute)); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 179 | |
| 180 | BOOST_CHECK_EQUAL(this->strategy.sendInterestHistory.size(), 0); |
Davide Pesavento | f56cf63 | 2024-01-27 22:22:06 -0500 | [diff] [blame] | 181 | BOOST_CHECK_EQUAL(this->strategy.rejectPendingInterestHistory.size(), T::willRejectPitEntry); |
| 182 | if (T::willSendNackNoRoute) { |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 183 | BOOST_REQUIRE_EQUAL(this->strategy.sendNackHistory.size(), 1); |
| 184 | BOOST_CHECK_EQUAL(this->strategy.sendNackHistory.back().header.getReason(), lp::NackReason::NO_ROUTE); |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhopInterestToNonLocalAndLocal, |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 189 | T, Tests, StrategyScopeControlFixture<typename T::Strategy>) |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 190 | { |
| 191 | fib::Entry* fibEntry = this->fib.insert("/localhop/A").first; |
Ju Pan | d8315bf | 2019-07-31 06:59:07 +0000 | [diff] [blame] | 192 | this->fib.addOrUpdateNextHop(*fibEntry, *this->nonLocalFace2, 10); |
| 193 | this->fib.addOrUpdateNextHop(*fibEntry, *this->localFace4, 20); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 194 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 195 | auto interest = makeInterest("/localhop/A/1"); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 196 | shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first; |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 197 | pitEntry->insertOrUpdateInRecord(*this->nonLocalFace1, *interest); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 198 | |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 199 | BOOST_REQUIRE(this->strategy.waitForAction( |
Teng Liang | d94b7b3 | 2022-07-10 21:29:37 +0800 | [diff] [blame] | 200 | [&] { this->strategy.afterReceiveInterest(*interest, FaceEndpoint(*this->nonLocalFace1), pitEntry); }, |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 201 | this->limitedIo)); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 202 | |
| 203 | BOOST_REQUIRE_EQUAL(this->strategy.sendInterestHistory.size(), 1); |
| 204 | BOOST_CHECK_EQUAL(this->strategy.sendInterestHistory.back().outFaceId, this->localFace4->getId()); |
| 205 | BOOST_CHECK_EQUAL(this->strategy.rejectPendingInterestHistory.size(), 0); |
| 206 | BOOST_CHECK_EQUAL(this->strategy.sendNackHistory.size(), 0); |
| 207 | } |
| 208 | |
| 209 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhostNackToNonLocal, |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 210 | T, Tests, StrategyScopeControlFixture<typename T::Strategy>) |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 211 | { |
| 212 | fib::Entry* fibEntry = this->fib.insert("/localhost/A").first; |
Ju Pan | d8315bf | 2019-07-31 06:59:07 +0000 | [diff] [blame] | 213 | this->fib.addOrUpdateNextHop(*fibEntry, *this->localFace4, 10); |
| 214 | this->fib.addOrUpdateNextHop(*fibEntry, *this->nonLocalFace2, 20); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 215 | |
Davide Pesavento | b7bfcb9 | 2022-05-22 23:55:23 -0400 | [diff] [blame] | 216 | auto interest = makeInterest("/localhost/A/1", false, std::nullopt, 1460); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 217 | shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first; |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 218 | pitEntry->insertOrUpdateInRecord(*this->localFace3, *interest); |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 219 | lp::Nack nack = makeNack(*interest, lp::NackReason::NO_ROUTE); |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 220 | pitEntry->insertOrUpdateOutRecord(*this->localFace4, *interest)->setIncomingNack(nack); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 221 | |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 222 | BOOST_REQUIRE(this->strategy.waitForAction( |
Teng Liang | d94b7b3 | 2022-07-10 21:29:37 +0800 | [diff] [blame] | 223 | [&] { this->strategy.afterReceiveNack(nack, FaceEndpoint(*this->localFace4), pitEntry); }, |
Davide Pesavento | f56cf63 | 2024-01-27 22:22:06 -0500 | [diff] [blame] | 224 | this->limitedIo, T::canProcessNack)); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 225 | |
| 226 | BOOST_CHECK_EQUAL(this->strategy.sendInterestHistory.size(), 0); |
| 227 | BOOST_CHECK_EQUAL(this->strategy.rejectPendingInterestHistory.size(), 0); |
Davide Pesavento | f56cf63 | 2024-01-27 22:22:06 -0500 | [diff] [blame] | 228 | if (T::canProcessNack) { |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 229 | BOOST_REQUIRE_EQUAL(this->strategy.sendNackHistory.size(), 1); |
| 230 | BOOST_CHECK_EQUAL(this->strategy.sendNackHistory.back().header.getReason(), lp::NackReason::NO_ROUTE); |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhopNackToNonLocal, |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 235 | T, Tests, StrategyScopeControlFixture<typename T::Strategy>) |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 236 | { |
| 237 | fib::Entry* fibEntry = this->fib.insert("/localhop/A").first; |
Ju Pan | d8315bf | 2019-07-31 06:59:07 +0000 | [diff] [blame] | 238 | this->fib.addOrUpdateNextHop(*fibEntry, *this->localFace4, 10); |
| 239 | this->fib.addOrUpdateNextHop(*fibEntry, *this->nonLocalFace2, 20); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 240 | |
Davide Pesavento | b7bfcb9 | 2022-05-22 23:55:23 -0400 | [diff] [blame] | 241 | auto interest = makeInterest("/localhop/A/1", false, std::nullopt, 1377); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 242 | shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first; |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 243 | pitEntry->insertOrUpdateInRecord(*this->nonLocalFace1, *interest); |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 244 | lp::Nack nack = makeNack(*interest, lp::NackReason::NO_ROUTE); |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 245 | pitEntry->insertOrUpdateOutRecord(*this->localFace4, *interest)->setIncomingNack(nack); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 246 | |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 247 | BOOST_REQUIRE(this->strategy.waitForAction( |
Teng Liang | d94b7b3 | 2022-07-10 21:29:37 +0800 | [diff] [blame] | 248 | [&] { this->strategy.afterReceiveNack(nack, FaceEndpoint(*this->localFace4), pitEntry); }, |
Davide Pesavento | f56cf63 | 2024-01-27 22:22:06 -0500 | [diff] [blame] | 249 | this->limitedIo, T::canProcessNack)); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 250 | |
| 251 | BOOST_CHECK_EQUAL(this->strategy.sendInterestHistory.size(), 0); |
| 252 | BOOST_CHECK_EQUAL(this->strategy.rejectPendingInterestHistory.size(), 0); |
Davide Pesavento | f56cf63 | 2024-01-27 22:22:06 -0500 | [diff] [blame] | 253 | if (T::canProcessNack) { |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 254 | BOOST_REQUIRE_EQUAL(this->strategy.sendNackHistory.size(), 1); |
| 255 | BOOST_CHECK_EQUAL(this->strategy.sendNackHistory.back().header.getReason(), lp::NackReason::NO_ROUTE); |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | BOOST_AUTO_TEST_SUITE_END() // TestStrategyScopeControl |
| 260 | BOOST_AUTO_TEST_SUITE_END() // Fw |
| 261 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 262 | } // namespace nfd::tests |