Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Ashlesh Gawande | 7a231c0 | 2020-06-12 20:06:44 -0700 | [diff] [blame] | 2 | /* |
Davide Pesavento | 288141a | 2024-02-13 17:30:35 -0500 | [diff] [blame^] | 3 | * Copyright (c) 2014-2024, The University of Memphis, |
Nick Gordon | f8b5bcd | 2016-08-11 15:06:50 -0500 | [diff] [blame] | 4 | * Regents of the University of California |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 5 | * |
| 6 | * This file is part of NLSR (Named-data Link State Routing). |
| 7 | * See AUTHORS.md for complete list of NLSR authors and contributors. |
| 8 | * |
| 9 | * NLSR is free software: you can redistribute it and/or modify it under the terms |
| 10 | * of the GNU General Public License as published by the Free Software Foundation, |
| 11 | * either version 3 of the License, or (at your option) any later version. |
| 12 | * |
| 13 | * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 14 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 15 | * PURPOSE. See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along with |
| 18 | * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
Ashlesh Gawande | 7a231c0 | 2020-06-12 20:06:44 -0700 | [diff] [blame] | 19 | */ |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 20 | |
Nick Gordon | 5867b52 | 2017-09-06 17:41:37 -0500 | [diff] [blame] | 21 | #include "route/fib.hpp" |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 22 | #include "adjacency-list.hpp" |
| 23 | #include "conf-parameter.hpp" |
| 24 | |
Davide Pesavento | 8de8a8b | 2022-05-12 01:26:43 -0400 | [diff] [blame] | 25 | #include "tests/boost-test.hpp" |
| 26 | #include "tests/io-key-chain-fixture.hpp" |
Davide Pesavento | d1f1df8 | 2022-03-12 16:40:37 -0500 | [diff] [blame] | 27 | |
Davide Pesavento | 8de8a8b | 2022-05-12 01:26:43 -0400 | [diff] [blame] | 28 | #include <ndn-cxx/mgmt/nfd/control-parameters.hpp> |
Muktadir R Chowdhury | c69da0a | 2015-12-18 13:24:38 -0600 | [diff] [blame] | 29 | #include <ndn-cxx/util/dummy-client-face.hpp> |
| 30 | |
Davide Pesavento | 288141a | 2024-02-13 17:30:35 -0500 | [diff] [blame^] | 31 | namespace nlsr::tests { |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 32 | |
Junxiao Shi | 6593a43 | 2023-08-21 10:50:28 +0000 | [diff] [blame] | 33 | static const ndn::Name router1Name = "/ndn/router1"; |
| 34 | static const ndn::Name router2Name = "/ndn/router2"; |
| 35 | static const ndn::Name router3Name = "/ndn/router3"; |
| 36 | static const ndn::FaceUri router1FaceUri("udp4://10.0.0.1:6363"); |
| 37 | static const ndn::FaceUri router2FaceUri("udp4://10.0.0.2:6363"); |
| 38 | static const ndn::FaceUri router3FaceUri("udp4://10.0.0.3:6363"); |
| 39 | constexpr uint32_t router1FaceId = 1; |
| 40 | constexpr uint32_t router2FaceId = 2; |
| 41 | constexpr uint32_t router3FaceId = 3; |
| 42 | |
Davide Pesavento | 8de8a8b | 2022-05-12 01:26:43 -0400 | [diff] [blame] | 43 | class FibFixture : public IoKeyChainFixture |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 44 | { |
| 45 | public: |
| 46 | FibFixture() |
Davide Pesavento | 8de8a8b | 2022-05-12 01:26:43 -0400 | [diff] [blame] | 47 | : adjacencies(conf.getAdjacencyList()) |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame] | 48 | , fib(face, m_scheduler, adjacencies, conf, m_keyChain) |
| 49 | , interests(face.sentInterests) |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 50 | { |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame] | 51 | advanceClocks(1_s); |
| 52 | |
Junxiao Shi | 6593a43 | 2023-08-21 10:50:28 +0000 | [diff] [blame] | 53 | Adjacent neighbor1(router1Name, router1FaceUri, 0, Adjacent::STATUS_ACTIVE, 0, router1FaceId); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 54 | adjacencies.insert(neighbor1); |
| 55 | |
Junxiao Shi | 6593a43 | 2023-08-21 10:50:28 +0000 | [diff] [blame] | 56 | Adjacent neighbor2(router2Name, router2FaceUri, 0, Adjacent::STATUS_ACTIVE, 0, router2FaceId); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 57 | adjacencies.insert(neighbor2); |
| 58 | |
Junxiao Shi | 6593a43 | 2023-08-21 10:50:28 +0000 | [diff] [blame] | 59 | Adjacent neighbor3(router3Name, router3FaceUri, 0, Adjacent::STATUS_ACTIVE, 0, router3FaceId); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 60 | adjacencies.insert(neighbor3); |
| 61 | |
| 62 | conf.setMaxFacesPerPrefix(2); |
| 63 | |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame] | 64 | fib.setEntryRefreshTime(1); |
| 65 | } |
| 66 | |
Davide Pesavento | 8de8a8b | 2022-05-12 01:26:43 -0400 | [diff] [blame] | 67 | static void |
Davide Pesavento | 69904fc | 2022-10-14 09:45:34 -0400 | [diff] [blame] | 68 | extractRibCommandParameters(const ndn::Interest& interest, |
| 69 | ndn::Name::Component& verb, |
| 70 | ndn::nfd::ControlParameters& params) |
Davide Pesavento | 8de8a8b | 2022-05-12 01:26:43 -0400 | [diff] [blame] | 71 | { |
Davide Pesavento | 8de8a8b | 2022-05-12 01:26:43 -0400 | [diff] [blame] | 72 | const auto& name = interest.getName(); |
Davide Pesavento | 69904fc | 2022-10-14 09:45:34 -0400 | [diff] [blame] | 73 | verb = name.at(RIB_COMMAND_PREFIX.size()); |
| 74 | params.wireDecode(name.at(RIB_COMMAND_PREFIX.size() + 1).blockFromValue()); |
Davide Pesavento | 8de8a8b | 2022-05-12 01:26:43 -0400 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | private: |
Davide Pesavento | 69904fc | 2022-10-14 09:45:34 -0400 | [diff] [blame] | 78 | static inline const ndn::Name RIB_COMMAND_PREFIX{"/localhost/nfd/rib"}; |
| 79 | |
Davide Pesavento | 8de8a8b | 2022-05-12 01:26:43 -0400 | [diff] [blame] | 80 | ndn::Scheduler m_scheduler{m_io}; |
| 81 | |
| 82 | public: |
Junxiao Shi | 43f37a0 | 2023-08-09 00:09:00 +0000 | [diff] [blame] | 83 | ndn::DummyClientFace face{m_io, m_keyChain, [] { |
| 84 | ndn::DummyClientFace::Options opts; |
Junxiao Shi | 771a0de | 2023-08-09 00:03:21 +0000 | [diff] [blame] | 85 | opts.enableRegistrationReply = true; |
| 86 | opts.registrationReplyFaceId = 128; |
| 87 | return opts; |
| 88 | } ()}; |
Davide Pesavento | 8de8a8b | 2022-05-12 01:26:43 -0400 | [diff] [blame] | 89 | ConfParameter conf{face, m_keyChain}; |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame] | 90 | AdjacencyList& adjacencies; |
| 91 | Fib fib; |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 92 | std::vector<ndn::Interest>& interests; |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 93 | }; |
| 94 | |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 95 | BOOST_FIXTURE_TEST_SUITE(TestFib, FibFixture) |
| 96 | |
| 97 | BOOST_AUTO_TEST_CASE(NextHopsAdd) |
| 98 | { |
| 99 | NextHop hop1(router1FaceUri, 10); |
| 100 | NextHop hop2(router2FaceUri, 20); |
| 101 | |
| 102 | NexthopList hops; |
| 103 | hops.addNextHop(hop1); |
| 104 | hops.addNextHop(hop2); |
| 105 | |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame] | 106 | fib.update("/ndn/name", hops); |
| 107 | face.processEvents(ndn::time::milliseconds(-1)); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 108 | |
| 109 | // Should register faces 1 and 2 for /ndn/name |
| 110 | BOOST_REQUIRE_EQUAL(interests.size(), 2); |
| 111 | |
| 112 | ndn::nfd::ControlParameters extractedParameters; |
| 113 | ndn::Name::Component verb; |
Davide Pesavento | 288141a | 2024-02-13 17:30:35 -0500 | [diff] [blame^] | 114 | auto it = interests.begin(); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 115 | |
| 116 | extractRibCommandParameters(*it, verb, extractedParameters); |
| 117 | |
| 118 | BOOST_CHECK(extractedParameters.getName() == "/ndn/name" && |
| 119 | extractedParameters.getFaceId() == router1FaceId && |
| 120 | verb == ndn::Name::Component("register")); |
| 121 | |
| 122 | ++it; |
| 123 | extractRibCommandParameters(*it, verb, extractedParameters); |
| 124 | |
| 125 | BOOST_CHECK(extractedParameters.getName() == "/ndn/name" && |
| 126 | extractedParameters.getFaceId() == router2FaceId && |
| 127 | verb == ndn::Name::Component("register")); |
| 128 | } |
| 129 | |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 130 | BOOST_AUTO_TEST_CASE(NextHopsNoChange) |
| 131 | { |
| 132 | NextHop hop1(router1FaceUri, 10); |
| 133 | NextHop hop2(router2FaceUri, 20); |
| 134 | |
| 135 | NexthopList oldHops; |
| 136 | oldHops.addNextHop(hop1); |
| 137 | oldHops.addNextHop(hop2); |
| 138 | |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame] | 139 | fib.update("/ndn/name", oldHops); |
| 140 | face.processEvents(ndn::time::milliseconds(-1)); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 141 | |
| 142 | BOOST_REQUIRE_EQUAL(interests.size(), 2); |
| 143 | interests.clear(); |
| 144 | |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame] | 145 | fib.update("/ndn/name", oldHops); |
| 146 | face.processEvents(ndn::time::milliseconds(-1)); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 147 | |
| 148 | // Should register face 1 and 2 for /ndn/name |
| 149 | BOOST_REQUIRE_EQUAL(interests.size(), 2); |
| 150 | |
| 151 | ndn::nfd::ControlParameters extractedParameters; |
| 152 | ndn::Name::Component verb; |
Davide Pesavento | 288141a | 2024-02-13 17:30:35 -0500 | [diff] [blame^] | 153 | auto it = interests.begin(); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 154 | |
| 155 | extractRibCommandParameters(*it, verb, extractedParameters); |
| 156 | |
| 157 | BOOST_CHECK(extractedParameters.getName() == "/ndn/name" && |
| 158 | extractedParameters.getFaceId() == router1FaceId && |
| 159 | verb == ndn::Name::Component("register")); |
| 160 | |
| 161 | ++it; |
| 162 | extractRibCommandParameters(*it, verb, extractedParameters); |
| 163 | |
| 164 | BOOST_CHECK(extractedParameters.getName() == "/ndn/name" && |
| 165 | extractedParameters.getFaceId() == router2FaceId && |
| 166 | verb == ndn::Name::Component("register")); |
| 167 | } |
| 168 | |
| 169 | BOOST_AUTO_TEST_CASE(NextHopsRemoveAll) |
| 170 | { |
| 171 | NextHop hop1(router1FaceUri, 10); |
| 172 | NextHop hop2(router2FaceUri, 20); |
| 173 | |
| 174 | NexthopList oldHops; |
| 175 | oldHops.addNextHop(hop1); |
| 176 | oldHops.addNextHop(hop2); |
| 177 | |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame] | 178 | fib.update("/ndn/name", oldHops); |
| 179 | face.processEvents(ndn::time::milliseconds(-1)); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 180 | |
| 181 | BOOST_REQUIRE_EQUAL(interests.size(), 2); |
| 182 | interests.clear(); |
| 183 | |
| 184 | NexthopList empty; |
| 185 | |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame] | 186 | fib.update("/ndn/name", empty); |
| 187 | face.processEvents(ndn::time::milliseconds(-1)); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 188 | |
| 189 | // Should unregister faces 1 and 2 for /ndn/name |
| 190 | BOOST_CHECK_EQUAL(interests.size(), 2); |
| 191 | |
| 192 | ndn::nfd::ControlParameters extractedParameters; |
| 193 | ndn::Name::Component verb; |
Davide Pesavento | 288141a | 2024-02-13 17:30:35 -0500 | [diff] [blame^] | 194 | auto it = interests.begin(); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 195 | |
| 196 | extractRibCommandParameters(*it, verb, extractedParameters); |
| 197 | |
| 198 | BOOST_CHECK(extractedParameters.getName() == "/ndn/name" && |
| 199 | extractedParameters.getFaceId() == router1FaceId && |
| 200 | verb == ndn::Name::Component("unregister")); |
| 201 | |
| 202 | ++it; |
| 203 | extractRibCommandParameters(*it, verb, extractedParameters); |
| 204 | |
| 205 | BOOST_CHECK(extractedParameters.getName() == "/ndn/name" && |
| 206 | extractedParameters.getFaceId() == router2FaceId && |
| 207 | verb == ndn::Name::Component("unregister")); |
| 208 | } |
| 209 | |
| 210 | BOOST_AUTO_TEST_CASE(NextHopsMaxPrefixes) |
| 211 | { |
| 212 | NextHop hop1(router1FaceUri, 10); |
| 213 | NextHop hop2(router2FaceUri, 20); |
| 214 | NextHop hop3(router3FaceUri, 30); |
| 215 | |
| 216 | NexthopList hops; |
| 217 | hops.addNextHop(hop1); |
| 218 | hops.addNextHop(hop2); |
| 219 | hops.addNextHop(hop3); |
| 220 | |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame] | 221 | fib.update("/ndn/name", hops); |
| 222 | face.processEvents(ndn::time::milliseconds(-1)); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 223 | |
| 224 | // Should only register faces 1 and 2 for /ndn/name |
| 225 | BOOST_CHECK_EQUAL(interests.size(), 2); |
| 226 | |
| 227 | ndn::nfd::ControlParameters extractedParameters; |
| 228 | ndn::Name::Component verb; |
Davide Pesavento | 288141a | 2024-02-13 17:30:35 -0500 | [diff] [blame^] | 229 | auto it = interests.begin(); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 230 | |
| 231 | extractRibCommandParameters(*it, verb, extractedParameters); |
| 232 | |
| 233 | BOOST_CHECK(extractedParameters.getName() == "/ndn/name" && |
| 234 | extractedParameters.getFaceId() == router1FaceId && |
| 235 | verb == ndn::Name::Component("register")); |
| 236 | |
| 237 | ++it; |
| 238 | extractRibCommandParameters(*it, verb, extractedParameters); |
| 239 | |
| 240 | BOOST_CHECK(extractedParameters.getName() == "/ndn/name" && |
| 241 | extractedParameters.getFaceId() == router2FaceId && |
| 242 | verb == ndn::Name::Component("register")); |
| 243 | } |
| 244 | |
| 245 | BOOST_AUTO_TEST_CASE(NextHopsMaxPrefixesAfterRecalculation) |
| 246 | { |
| 247 | NextHop hop1(router1FaceUri, 10); |
| 248 | NextHop hop2(router2FaceUri, 20); |
| 249 | |
| 250 | NexthopList hops; |
| 251 | hops.addNextHop(hop1); |
| 252 | hops.addNextHop(hop2); |
| 253 | |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame] | 254 | fib.update("/ndn/name", hops); |
| 255 | face.processEvents(ndn::time::milliseconds(-1)); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 256 | |
| 257 | // FIB |
| 258 | // Name NextHops |
| 259 | // /ndn/name (faceId=1, cost=10), (faceId=2, cost=20) |
| 260 | BOOST_REQUIRE_EQUAL(interests.size(), 2); |
| 261 | interests.clear(); |
| 262 | |
| 263 | // Routing table is recalculated; a new more optimal path is found |
| 264 | NextHop hop3(router3FaceUri, 5); |
| 265 | hops.addNextHop(hop3); |
| 266 | |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame] | 267 | fib.update("/ndn/name", hops); |
| 268 | face.processEvents(ndn::time::milliseconds(-1)); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 269 | |
| 270 | // To maintain a max 2 face requirement, face 3 should be registered and face 2 should be |
| 271 | // unregistered. Face 1 will also be re-registered. |
| 272 | // |
| 273 | // FIB |
| 274 | // Name NextHops |
| 275 | // /ndn/name (faceId=3, cost=5), (faceId=1, cost=10) |
| 276 | |
| 277 | BOOST_CHECK_EQUAL(interests.size(), 3); |
| 278 | |
| 279 | ndn::nfd::ControlParameters extractedParameters; |
| 280 | ndn::Name::Component verb; |
Davide Pesavento | 288141a | 2024-02-13 17:30:35 -0500 | [diff] [blame^] | 281 | auto it = interests.begin(); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 282 | |
| 283 | extractRibCommandParameters(*it, verb, extractedParameters); |
| 284 | |
| 285 | BOOST_CHECK(extractedParameters.getName() == "/ndn/name" && |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame] | 286 | extractedParameters.getFaceId() == router1FaceId && |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 287 | verb == ndn::Name::Component("register")); |
| 288 | |
| 289 | ++it; |
| 290 | extractRibCommandParameters(*it, verb, extractedParameters); |
| 291 | |
| 292 | BOOST_CHECK(extractedParameters.getName() == "/ndn/name" && |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame] | 293 | extractedParameters.getFaceId() == router3FaceId && |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 294 | verb == ndn::Name::Component("register")); |
| 295 | |
| 296 | ++it; |
| 297 | extractRibCommandParameters(*it, verb, extractedParameters); |
| 298 | |
| 299 | BOOST_CHECK(extractedParameters.getName() == "/ndn/name" && |
| 300 | extractedParameters.getFaceId() == router2FaceId && |
| 301 | verb == ndn::Name::Component("unregister")); |
| 302 | } |
| 303 | |
Muktadir Chowdhury | 3be6466 | 2015-05-01 14:50:53 -0500 | [diff] [blame] | 304 | BOOST_FIXTURE_TEST_CASE(ScheduleFibEntryRefresh, FibFixture) |
| 305 | { |
| 306 | ndn::Name name1("/name/1"); |
Ashlesh Gawande | 7a231c0 | 2020-06-12 20:06:44 -0700 | [diff] [blame] | 307 | FibEntry fe; |
| 308 | fe.name = name1; |
| 309 | int origSeqNo = fe.seqNo; |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame] | 310 | fib.m_table.emplace(name1, std::move(fe)); |
Muktadir Chowdhury | 3be6466 | 2015-05-01 14:50:53 -0500 | [diff] [blame] | 311 | |
Davide Pesavento | d1f1df8 | 2022-03-12 16:40:37 -0500 | [diff] [blame] | 312 | fib.scheduleEntryRefresh(fe, [&] (auto& entry) { BOOST_CHECK_EQUAL(origSeqNo + 1, entry.seqNo); }); |
Muktadir Chowdhury | 3be6466 | 2015-05-01 14:50:53 -0500 | [diff] [blame] | 313 | this->advanceClocks(ndn::time::milliseconds(10), 1); |
Davide Pesavento | d1f1df8 | 2022-03-12 16:40:37 -0500 | [diff] [blame] | 314 | |
| 315 | // avoid "test case [...] did not check any assertions" message from Boost.Test |
| 316 | BOOST_CHECK(true); |
Muktadir Chowdhury | 3be6466 | 2015-05-01 14:50:53 -0500 | [diff] [blame] | 317 | } |
| 318 | |
Ashlesh Gawande | e5002b3 | 2018-12-20 21:07:31 -0600 | [diff] [blame] | 319 | BOOST_AUTO_TEST_CASE(ShouldNotRefreshNeighborRoute) // #4799 |
| 320 | { |
| 321 | NextHop hop1; |
| 322 | hop1.setConnectingFaceUri(router1FaceUri); |
| 323 | |
| 324 | NexthopList hops; |
| 325 | hops.addNextHop(hop1); |
| 326 | |
| 327 | // Simulate update for this neighbor from name prefix table |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame] | 328 | fib.update(router1Name, hops); |
Ashlesh Gawande | e5002b3 | 2018-12-20 21:07:31 -0600 | [diff] [blame] | 329 | this->advanceClocks(ndn::time::seconds(1)); |
| 330 | |
| 331 | // Should not send the register interest |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame] | 332 | BOOST_CHECK_EQUAL(face.sentInterests.size(), 0); |
| 333 | } |
| 334 | |
| 335 | BOOST_AUTO_TEST_CASE(PrefixWithdrawalFibUpdateBug) // #5179 |
| 336 | { |
| 337 | fib.setEntryRefreshTime(3600); |
| 338 | conf.setMaxFacesPerPrefix(3); |
| 339 | |
| 340 | // Three adjacencies of Neu |
| 341 | Adjacent neighbor1("/ndn/memphis/router-memphis", |
| 342 | ndn::FaceUri("udp4://10.0.0.9:6363"), 21, Adjacent::STATUS_ACTIVE, 0, router1FaceId); |
| 343 | adjacencies.insert(neighbor1); |
| 344 | |
| 345 | Adjacent neighbor2("/ndn/michigan/router-michigan", |
| 346 | ndn::FaceUri("udp4://10.0.0.13:6363"), 14, Adjacent::STATUS_ACTIVE, 0, router2FaceId); |
| 347 | adjacencies.insert(neighbor2); |
| 348 | |
| 349 | Adjacent neighbor3("/ndn/savi/router-savi", |
| 350 | ndn::FaceUri("udp4://10.0.0.26:6363"), 15, Adjacent::STATUS_ACTIVE, 0, router3FaceId); |
| 351 | adjacencies.insert(neighbor3); |
| 352 | |
| 353 | // Wustl advertises /test |
| 354 | NexthopList nhl1; |
Junxiao Shi | 6593a43 | 2023-08-21 10:50:28 +0000 | [diff] [blame] | 355 | nhl1.addNextHop(NextHop(ndn::FaceUri("udp4://10.0.0.13:6363"), 28)); |
| 356 | nhl1.addNextHop(NextHop(ndn::FaceUri("udp4://10.0.0.9:6363"), 38)); |
| 357 | nhl1.addNextHop(NextHop(ndn::FaceUri("udp4://10.0.0.26:6363"), 44)); |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame] | 358 | fib.update("/test", nhl1); |
| 359 | |
| 360 | // Memphis advertises /test |
| 361 | NexthopList nhl2; |
Junxiao Shi | 6593a43 | 2023-08-21 10:50:28 +0000 | [diff] [blame] | 362 | nhl2.addNextHop(NextHop(ndn::FaceUri("udp4://10.0.0.9:6363"), 21)); |
| 363 | nhl2.addNextHop(NextHop(ndn::FaceUri("udp4://10.0.0.13:6363"), 26)); |
| 364 | nhl2.addNextHop(NextHop(ndn::FaceUri("udp4://10.0.0.26:6363"), 42)); |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame] | 365 | fib.update("/test", nhl2); |
| 366 | |
| 367 | advanceClocks(10_ms); |
| 368 | face.sentInterests.clear(); |
| 369 | // Memphis withdraws /test |
| 370 | // NamePrefixTable calls this saying we need to install the Wu routes |
| 371 | // instead of the existing Memphis' cheaper routes |
| 372 | fib.update("/test", nhl1); |
| 373 | |
| 374 | advanceClocks(10_ms); |
| 375 | int numRegister = 0; |
| 376 | // Do not expect any unregisters, just registers which will update the cost in NFD |
| 377 | for (const auto& i : face.sentInterests) { |
Davide Pesavento | 8de8a8b | 2022-05-12 01:26:43 -0400 | [diff] [blame] | 378 | if (i.getName().getPrefix(4) == "/localhost/nfd/rib/unregister") { |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame] | 379 | BOOST_CHECK(false); |
| 380 | } |
| 381 | else { |
| 382 | ++numRegister; |
| 383 | } |
| 384 | } |
| 385 | BOOST_CHECK_EQUAL(numRegister, 3); |
Ashlesh Gawande | e5002b3 | 2018-12-20 21:07:31 -0600 | [diff] [blame] | 386 | } |
| 387 | |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 388 | BOOST_AUTO_TEST_SUITE_END() |
| 389 | |
Davide Pesavento | 288141a | 2024-02-13 17:30:35 -0500 | [diff] [blame^] | 390 | } // namespace nlsr::tests |