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 | /* |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame^] | 3 | * Copyright (c) 2014-2021, 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" |
Ashlesh Gawande | 85998a1 | 2017-12-07 22:22:13 -0600 | [diff] [blame] | 22 | #include "../test-common.hpp" |
| 23 | #include "../control-commands.hpp" |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 24 | #include "adjacency-list.hpp" |
| 25 | #include "conf-parameter.hpp" |
| 26 | |
Muktadir R Chowdhury | c69da0a | 2015-12-18 13:24:38 -0600 | [diff] [blame] | 27 | #include <ndn-cxx/util/dummy-client-face.hpp> |
| 28 | |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 29 | namespace nlsr { |
| 30 | namespace test { |
| 31 | |
Muktadir Chowdhury | 3be6466 | 2015-05-01 14:50:53 -0500 | [diff] [blame] | 32 | class FibFixture : public UnitTestTimeFixture |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 33 | { |
| 34 | public: |
| 35 | FibFixture() |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame^] | 36 | : face(m_ioService, m_keyChain) |
| 37 | , conf(face, m_keyChain) |
| 38 | , adjacencies(conf.getAdjacencyList()) |
| 39 | , fib(face, m_scheduler, adjacencies, conf, m_keyChain) |
| 40 | , interests(face.sentInterests) |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 41 | { |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame^] | 42 | enableRegistrationReplyWithFaceId(); |
| 43 | advanceClocks(1_s); |
| 44 | |
Muktadir Chowdhury | f04f989 | 2017-08-20 20:42:56 -0500 | [diff] [blame] | 45 | Adjacent neighbor1(router1Name, ndn::FaceUri(router1FaceUri), 0, Adjacent::STATUS_ACTIVE, 0, router1FaceId); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 46 | adjacencies.insert(neighbor1); |
| 47 | |
Muktadir Chowdhury | f04f989 | 2017-08-20 20:42:56 -0500 | [diff] [blame] | 48 | Adjacent neighbor2(router2Name, ndn::FaceUri(router2FaceUri), 0, Adjacent::STATUS_ACTIVE, 0, router2FaceId); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 49 | adjacencies.insert(neighbor2); |
| 50 | |
Muktadir Chowdhury | f04f989 | 2017-08-20 20:42:56 -0500 | [diff] [blame] | 51 | Adjacent neighbor3(router3Name, ndn::FaceUri(router3FaceUri), 0, Adjacent::STATUS_ACTIVE, 0, router3FaceId); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 52 | adjacencies.insert(neighbor3); |
| 53 | |
| 54 | conf.setMaxFacesPerPrefix(2); |
| 55 | |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame^] | 56 | fib.setEntryRefreshTime(1); |
| 57 | } |
| 58 | |
| 59 | void |
| 60 | enableRegistrationReplyWithFaceId() { |
| 61 | face.onSendInterest.connect([this] (const ndn::Interest& interest) { |
| 62 | static const ndn::Name localhostRegistration("/localhost/nfd/rib"); |
| 63 | if (!localhostRegistration.isPrefixOf(interest.getName())) |
| 64 | return; |
| 65 | |
| 66 | ndn::nfd::ControlParameters params(interest.getName().get(-5).blockFromValue()); |
| 67 | if (!params.hasFaceId()) { |
| 68 | params.setFaceId(1); |
| 69 | } |
| 70 | params.setOrigin(ndn::nfd::ROUTE_ORIGIN_APP); |
| 71 | if (interest.getName().get(3) == ndn::name::Component("register")) { |
| 72 | params.setCost(0); |
| 73 | } |
| 74 | |
| 75 | ndn::nfd::ControlResponse resp; |
| 76 | resp.setCode(200); |
| 77 | resp.setBody(params.wireEncode()); |
| 78 | |
| 79 | ndn::Data data(interest.getName()); |
| 80 | data.setContent(resp.wireEncode()); |
| 81 | |
| 82 | m_keyChain.sign(data, ndn::security::SigningInfo(ndn::security::SigningInfo::SIGNER_TYPE_SHA256)); |
| 83 | |
| 84 | face.getIoService().post([this, data] { face.receive(data); }); |
| 85 | }); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | public: |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame^] | 89 | ndn::util::DummyClientFace face; |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 90 | |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 91 | ConfParameter conf; |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame^] | 92 | AdjacencyList& adjacencies; |
| 93 | Fib fib; |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 94 | std::vector<ndn::Interest>& interests; |
| 95 | |
| 96 | static const ndn::Name router1Name; |
| 97 | static const ndn::Name router2Name; |
| 98 | static const ndn::Name router3Name; |
| 99 | |
| 100 | static const std::string router1FaceUri; |
| 101 | static const std::string router2FaceUri; |
| 102 | static const std::string router3FaceUri; |
| 103 | |
| 104 | static const uint32_t router1FaceId; |
| 105 | static const uint32_t router2FaceId; |
| 106 | static const uint32_t router3FaceId; |
| 107 | }; |
| 108 | |
| 109 | const ndn::Name FibFixture::router1Name = "/ndn/router1"; |
| 110 | const ndn::Name FibFixture::router2Name = "/ndn/router2"; |
| 111 | const ndn::Name FibFixture::router3Name = "/ndn/router3"; |
| 112 | |
Nick Gordon | e9733ed | 2017-04-26 10:48:39 -0500 | [diff] [blame] | 113 | const std::string FibFixture::router1FaceUri = "udp4://10.0.0.1"; |
| 114 | const std::string FibFixture::router2FaceUri = "udp4://10.0.0.2"; |
| 115 | const std::string FibFixture::router3FaceUri = "udp4://10.0.0.3"; |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 116 | |
| 117 | const uint32_t FibFixture::router1FaceId = 1; |
| 118 | const uint32_t FibFixture::router2FaceId = 2; |
| 119 | const uint32_t FibFixture::router3FaceId = 3; |
| 120 | |
| 121 | BOOST_FIXTURE_TEST_SUITE(TestFib, FibFixture) |
| 122 | |
| 123 | BOOST_AUTO_TEST_CASE(NextHopsAdd) |
| 124 | { |
| 125 | NextHop hop1(router1FaceUri, 10); |
| 126 | NextHop hop2(router2FaceUri, 20); |
| 127 | |
| 128 | NexthopList hops; |
| 129 | hops.addNextHop(hop1); |
| 130 | hops.addNextHop(hop2); |
| 131 | |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame^] | 132 | fib.update("/ndn/name", hops); |
| 133 | face.processEvents(ndn::time::milliseconds(-1)); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 134 | |
| 135 | // Should register faces 1 and 2 for /ndn/name |
| 136 | BOOST_REQUIRE_EQUAL(interests.size(), 2); |
| 137 | |
| 138 | ndn::nfd::ControlParameters extractedParameters; |
| 139 | ndn::Name::Component verb; |
| 140 | std::vector<ndn::Interest>::iterator it = interests.begin(); |
| 141 | |
| 142 | extractRibCommandParameters(*it, verb, extractedParameters); |
| 143 | |
| 144 | BOOST_CHECK(extractedParameters.getName() == "/ndn/name" && |
| 145 | extractedParameters.getFaceId() == router1FaceId && |
| 146 | verb == ndn::Name::Component("register")); |
| 147 | |
| 148 | ++it; |
| 149 | extractRibCommandParameters(*it, verb, extractedParameters); |
| 150 | |
| 151 | BOOST_CHECK(extractedParameters.getName() == "/ndn/name" && |
| 152 | extractedParameters.getFaceId() == router2FaceId && |
| 153 | verb == ndn::Name::Component("register")); |
| 154 | } |
| 155 | |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 156 | BOOST_AUTO_TEST_CASE(NextHopsNoChange) |
| 157 | { |
| 158 | NextHop hop1(router1FaceUri, 10); |
| 159 | NextHop hop2(router2FaceUri, 20); |
| 160 | |
| 161 | NexthopList oldHops; |
| 162 | oldHops.addNextHop(hop1); |
| 163 | oldHops.addNextHop(hop2); |
| 164 | |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame^] | 165 | fib.update("/ndn/name", oldHops); |
| 166 | face.processEvents(ndn::time::milliseconds(-1)); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 167 | |
| 168 | BOOST_REQUIRE_EQUAL(interests.size(), 2); |
| 169 | interests.clear(); |
| 170 | |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame^] | 171 | fib.update("/ndn/name", oldHops); |
| 172 | face.processEvents(ndn::time::milliseconds(-1)); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 173 | |
| 174 | // Should register face 1 and 2 for /ndn/name |
| 175 | BOOST_REQUIRE_EQUAL(interests.size(), 2); |
| 176 | |
| 177 | ndn::nfd::ControlParameters extractedParameters; |
| 178 | ndn::Name::Component verb; |
| 179 | std::vector<ndn::Interest>::iterator it = interests.begin(); |
| 180 | |
| 181 | extractRibCommandParameters(*it, verb, extractedParameters); |
| 182 | |
| 183 | BOOST_CHECK(extractedParameters.getName() == "/ndn/name" && |
| 184 | extractedParameters.getFaceId() == router1FaceId && |
| 185 | verb == ndn::Name::Component("register")); |
| 186 | |
| 187 | ++it; |
| 188 | extractRibCommandParameters(*it, verb, extractedParameters); |
| 189 | |
| 190 | BOOST_CHECK(extractedParameters.getName() == "/ndn/name" && |
| 191 | extractedParameters.getFaceId() == router2FaceId && |
| 192 | verb == ndn::Name::Component("register")); |
| 193 | } |
| 194 | |
| 195 | BOOST_AUTO_TEST_CASE(NextHopsRemoveAll) |
| 196 | { |
| 197 | NextHop hop1(router1FaceUri, 10); |
| 198 | NextHop hop2(router2FaceUri, 20); |
| 199 | |
| 200 | NexthopList oldHops; |
| 201 | oldHops.addNextHop(hop1); |
| 202 | oldHops.addNextHop(hop2); |
| 203 | |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame^] | 204 | fib.update("/ndn/name", oldHops); |
| 205 | face.processEvents(ndn::time::milliseconds(-1)); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 206 | |
| 207 | BOOST_REQUIRE_EQUAL(interests.size(), 2); |
| 208 | interests.clear(); |
| 209 | |
| 210 | NexthopList empty; |
| 211 | |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame^] | 212 | fib.update("/ndn/name", empty); |
| 213 | face.processEvents(ndn::time::milliseconds(-1)); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 214 | |
| 215 | // Should unregister faces 1 and 2 for /ndn/name |
| 216 | BOOST_CHECK_EQUAL(interests.size(), 2); |
| 217 | |
| 218 | ndn::nfd::ControlParameters extractedParameters; |
| 219 | ndn::Name::Component verb; |
| 220 | std::vector<ndn::Interest>::iterator it = interests.begin(); |
| 221 | |
| 222 | extractRibCommandParameters(*it, verb, extractedParameters); |
| 223 | |
| 224 | BOOST_CHECK(extractedParameters.getName() == "/ndn/name" && |
| 225 | extractedParameters.getFaceId() == router1FaceId && |
| 226 | verb == ndn::Name::Component("unregister")); |
| 227 | |
| 228 | ++it; |
| 229 | extractRibCommandParameters(*it, verb, extractedParameters); |
| 230 | |
| 231 | BOOST_CHECK(extractedParameters.getName() == "/ndn/name" && |
| 232 | extractedParameters.getFaceId() == router2FaceId && |
| 233 | verb == ndn::Name::Component("unregister")); |
| 234 | } |
| 235 | |
| 236 | BOOST_AUTO_TEST_CASE(NextHopsMaxPrefixes) |
| 237 | { |
| 238 | NextHop hop1(router1FaceUri, 10); |
| 239 | NextHop hop2(router2FaceUri, 20); |
| 240 | NextHop hop3(router3FaceUri, 30); |
| 241 | |
| 242 | NexthopList hops; |
| 243 | hops.addNextHop(hop1); |
| 244 | hops.addNextHop(hop2); |
| 245 | hops.addNextHop(hop3); |
| 246 | |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame^] | 247 | fib.update("/ndn/name", hops); |
| 248 | face.processEvents(ndn::time::milliseconds(-1)); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 249 | |
| 250 | // Should only register faces 1 and 2 for /ndn/name |
| 251 | BOOST_CHECK_EQUAL(interests.size(), 2); |
| 252 | |
| 253 | ndn::nfd::ControlParameters extractedParameters; |
| 254 | ndn::Name::Component verb; |
| 255 | std::vector<ndn::Interest>::iterator it = interests.begin(); |
| 256 | |
| 257 | extractRibCommandParameters(*it, verb, extractedParameters); |
| 258 | |
| 259 | BOOST_CHECK(extractedParameters.getName() == "/ndn/name" && |
| 260 | extractedParameters.getFaceId() == router1FaceId && |
| 261 | verb == ndn::Name::Component("register")); |
| 262 | |
| 263 | ++it; |
| 264 | extractRibCommandParameters(*it, verb, extractedParameters); |
| 265 | |
| 266 | BOOST_CHECK(extractedParameters.getName() == "/ndn/name" && |
| 267 | extractedParameters.getFaceId() == router2FaceId && |
| 268 | verb == ndn::Name::Component("register")); |
| 269 | } |
| 270 | |
| 271 | BOOST_AUTO_TEST_CASE(NextHopsMaxPrefixesAfterRecalculation) |
| 272 | { |
| 273 | NextHop hop1(router1FaceUri, 10); |
| 274 | NextHop hop2(router2FaceUri, 20); |
| 275 | |
| 276 | NexthopList hops; |
| 277 | hops.addNextHop(hop1); |
| 278 | hops.addNextHop(hop2); |
| 279 | |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame^] | 280 | fib.update("/ndn/name", hops); |
| 281 | face.processEvents(ndn::time::milliseconds(-1)); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 282 | |
| 283 | // FIB |
| 284 | // Name NextHops |
| 285 | // /ndn/name (faceId=1, cost=10), (faceId=2, cost=20) |
| 286 | BOOST_REQUIRE_EQUAL(interests.size(), 2); |
| 287 | interests.clear(); |
| 288 | |
| 289 | // Routing table is recalculated; a new more optimal path is found |
| 290 | NextHop hop3(router3FaceUri, 5); |
| 291 | hops.addNextHop(hop3); |
| 292 | |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame^] | 293 | fib.update("/ndn/name", hops); |
| 294 | face.processEvents(ndn::time::milliseconds(-1)); |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 295 | |
| 296 | // To maintain a max 2 face requirement, face 3 should be registered and face 2 should be |
| 297 | // unregistered. Face 1 will also be re-registered. |
| 298 | // |
| 299 | // FIB |
| 300 | // Name NextHops |
| 301 | // /ndn/name (faceId=3, cost=5), (faceId=1, cost=10) |
| 302 | |
| 303 | BOOST_CHECK_EQUAL(interests.size(), 3); |
| 304 | |
| 305 | ndn::nfd::ControlParameters extractedParameters; |
| 306 | ndn::Name::Component verb; |
| 307 | std::vector<ndn::Interest>::iterator it = interests.begin(); |
| 308 | |
| 309 | extractRibCommandParameters(*it, verb, extractedParameters); |
| 310 | |
| 311 | BOOST_CHECK(extractedParameters.getName() == "/ndn/name" && |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame^] | 312 | extractedParameters.getFaceId() == router1FaceId && |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 313 | verb == ndn::Name::Component("register")); |
| 314 | |
| 315 | ++it; |
| 316 | extractRibCommandParameters(*it, verb, extractedParameters); |
| 317 | |
| 318 | BOOST_CHECK(extractedParameters.getName() == "/ndn/name" && |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame^] | 319 | extractedParameters.getFaceId() == router3FaceId && |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 320 | verb == ndn::Name::Component("register")); |
| 321 | |
| 322 | ++it; |
| 323 | extractRibCommandParameters(*it, verb, extractedParameters); |
| 324 | |
| 325 | BOOST_CHECK(extractedParameters.getName() == "/ndn/name" && |
| 326 | extractedParameters.getFaceId() == router2FaceId && |
| 327 | verb == ndn::Name::Component("unregister")); |
| 328 | } |
| 329 | |
Muktadir Chowdhury | 3be6466 | 2015-05-01 14:50:53 -0500 | [diff] [blame] | 330 | BOOST_FIXTURE_TEST_CASE(ScheduleFibEntryRefresh, FibFixture) |
| 331 | { |
| 332 | ndn::Name name1("/name/1"); |
Ashlesh Gawande | 7a231c0 | 2020-06-12 20:06:44 -0700 | [diff] [blame] | 333 | FibEntry fe; |
| 334 | fe.name = name1; |
| 335 | int origSeqNo = fe.seqNo; |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame^] | 336 | fib.m_table.emplace(name1, std::move(fe)); |
Muktadir Chowdhury | 3be6466 | 2015-05-01 14:50:53 -0500 | [diff] [blame] | 337 | |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame^] | 338 | fib.scheduleEntryRefresh(fe, |
Ashlesh Gawande | e6ba915 | 2018-03-30 01:15:00 -0500 | [diff] [blame] | 339 | [&] (FibEntry& entry) { |
Ashlesh Gawande | 7a231c0 | 2020-06-12 20:06:44 -0700 | [diff] [blame] | 340 | BOOST_CHECK_EQUAL(origSeqNo + 1, entry.seqNo); |
Muktadir Chowdhury | 3be6466 | 2015-05-01 14:50:53 -0500 | [diff] [blame] | 341 | }); |
| 342 | this->advanceClocks(ndn::time::milliseconds(10), 1); |
| 343 | } |
| 344 | |
Ashlesh Gawande | e5002b3 | 2018-12-20 21:07:31 -0600 | [diff] [blame] | 345 | BOOST_AUTO_TEST_CASE(ShouldNotRefreshNeighborRoute) // #4799 |
| 346 | { |
| 347 | NextHop hop1; |
| 348 | hop1.setConnectingFaceUri(router1FaceUri); |
| 349 | |
| 350 | NexthopList hops; |
| 351 | hops.addNextHop(hop1); |
| 352 | |
| 353 | // Simulate update for this neighbor from name prefix table |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame^] | 354 | fib.update(router1Name, hops); |
Ashlesh Gawande | e5002b3 | 2018-12-20 21:07:31 -0600 | [diff] [blame] | 355 | this->advanceClocks(ndn::time::seconds(1)); |
| 356 | |
| 357 | // Should not send the register interest |
Ashlesh Gawande | 6f0f35d | 2021-08-21 23:52:14 -0700 | [diff] [blame^] | 358 | BOOST_CHECK_EQUAL(face.sentInterests.size(), 0); |
| 359 | } |
| 360 | |
| 361 | BOOST_AUTO_TEST_CASE(PrefixWithdrawalFibUpdateBug) // #5179 |
| 362 | { |
| 363 | fib.setEntryRefreshTime(3600); |
| 364 | conf.setMaxFacesPerPrefix(3); |
| 365 | |
| 366 | // Three adjacencies of Neu |
| 367 | Adjacent neighbor1("/ndn/memphis/router-memphis", |
| 368 | ndn::FaceUri("udp4://10.0.0.9:6363"), 21, Adjacent::STATUS_ACTIVE, 0, router1FaceId); |
| 369 | adjacencies.insert(neighbor1); |
| 370 | |
| 371 | Adjacent neighbor2("/ndn/michigan/router-michigan", |
| 372 | ndn::FaceUri("udp4://10.0.0.13:6363"), 14, Adjacent::STATUS_ACTIVE, 0, router2FaceId); |
| 373 | adjacencies.insert(neighbor2); |
| 374 | |
| 375 | Adjacent neighbor3("/ndn/savi/router-savi", |
| 376 | ndn::FaceUri("udp4://10.0.0.26:6363"), 15, Adjacent::STATUS_ACTIVE, 0, router3FaceId); |
| 377 | adjacencies.insert(neighbor3); |
| 378 | |
| 379 | // Wustl advertises /test |
| 380 | NexthopList nhl1; |
| 381 | nhl1.addNextHop(NextHop("udp4://10.0.0.13:6363", 28)); |
| 382 | nhl1.addNextHop(NextHop("udp4://10.0.0.9:6363", 38)); |
| 383 | nhl1.addNextHop(NextHop("udp4://10.0.0.26:6363", 44)); |
| 384 | fib.update("/test", nhl1); |
| 385 | |
| 386 | // Memphis advertises /test |
| 387 | NexthopList nhl2; |
| 388 | nhl2.addNextHop(NextHop("udp4://10.0.0.9:6363", 21)); |
| 389 | nhl2.addNextHop(NextHop("udp4://10.0.0.13:6363", 26)); |
| 390 | nhl2.addNextHop(NextHop("udp4://10.0.0.26:6363", 42)); |
| 391 | fib.update("/test", nhl2); |
| 392 | |
| 393 | advanceClocks(10_ms); |
| 394 | face.sentInterests.clear(); |
| 395 | // Memphis withdraws /test |
| 396 | // NamePrefixTable calls this saying we need to install the Wu routes |
| 397 | // instead of the existing Memphis' cheaper routes |
| 398 | fib.update("/test", nhl1); |
| 399 | |
| 400 | advanceClocks(10_ms); |
| 401 | int numRegister = 0; |
| 402 | // Do not expect any unregisters, just registers which will update the cost in NFD |
| 403 | for (const auto& i : face.sentInterests) { |
| 404 | if (i.getName().getPrefix(4) == "/localhost/nfd/rib/unregister/") { |
| 405 | BOOST_CHECK(false); |
| 406 | } |
| 407 | else { |
| 408 | ++numRegister; |
| 409 | } |
| 410 | } |
| 411 | BOOST_CHECK_EQUAL(numRegister, 3); |
Ashlesh Gawande | e5002b3 | 2018-12-20 21:07:31 -0600 | [diff] [blame] | 412 | } |
| 413 | |
Vince Lehman | 942eb7b | 2014-10-02 10:09:27 -0500 | [diff] [blame] | 414 | BOOST_AUTO_TEST_SUITE_END() |
| 415 | |
Nick Gordon | fad8e25 | 2016-08-11 14:21:38 -0500 | [diff] [blame] | 416 | } // namespace test |
| 417 | } // namespace nlsr |