akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 2 | /** |
Nick Gordon | feae557 | 2017-01-13 12:06:26 -0600 | [diff] [blame] | 3 | * Copyright (c) 2014-2017, The University of Memphis, |
Vince Lehman | c2e51f6 | 2015-01-20 15:03:11 -0600 | [diff] [blame] | 4 | * Regents of the University of California, |
| 5 | * Arizona Board of Regents. |
akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 6 | * |
| 7 | * This file is part of NLSR (Named-data Link State Routing). |
| 8 | * See AUTHORS.md for complete list of NLSR authors and contributors. |
| 9 | * |
| 10 | * NLSR 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 | * NLSR 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 | * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 20 | **/ |
Vince Lehman | 7c60329 | 2014-09-11 17:48:16 -0500 | [diff] [blame] | 21 | |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 22 | #include "lsdb.hpp" |
Nick Gordon | 098aae4 | 2017-08-23 15:18:46 -0500 | [diff] [blame^] | 23 | #include "test-common.hpp" |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 24 | #include "nlsr.hpp" |
| 25 | #include "lsa.hpp" |
| 26 | #include "name-prefix-list.hpp" |
| 27 | #include <boost/test/unit_test.hpp> |
| 28 | |
Muktadir R Chowdhury | c69da0a | 2015-12-18 13:24:38 -0600 | [diff] [blame] | 29 | #include <ndn-cxx/util/dummy-client-face.hpp> |
Muktadir R Chowdhury | aa3b085 | 2015-08-06 13:08:56 -0500 | [diff] [blame] | 30 | #include <ndn-cxx/util/segment-fetcher.hpp> |
Muktadir R Chowdhury | c69da0a | 2015-12-18 13:24:38 -0600 | [diff] [blame] | 31 | |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 32 | namespace nlsr { |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 33 | namespace test { |
| 34 | |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 35 | using std::shared_ptr; |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 36 | |
| 37 | class LsdbFixture : public BaseFixture |
| 38 | { |
| 39 | public: |
| 40 | LsdbFixture() |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 41 | : face(std::make_shared<ndn::util::DummyClientFace>(g_ioService)) |
| 42 | , nlsr(g_ioService, g_scheduler, std::ref(*face), g_keyChain) |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 43 | , sync(*face, nlsr.getLsdb(), nlsr.getConfParameter()) |
Vince Lehman | f1aa523 | 2014-10-06 17:57:35 -0500 | [diff] [blame] | 44 | , lsdb(nlsr.getLsdb()) |
| 45 | , conf(nlsr.getConfParameter()) |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 46 | , REGISTER_COMMAND_PREFIX("/localhost/nfd/rib") |
| 47 | , REGISTER_VERB("register") |
| 48 | { |
Vince Lehman | f1aa523 | 2014-10-06 17:57:35 -0500 | [diff] [blame] | 49 | conf.setNetwork("/ndn"); |
| 50 | conf.setSiteName("/site"); |
| 51 | conf.setRouterName("/%C1.router/this-router"); |
| 52 | |
| 53 | nlsr.initialize(); |
| 54 | |
| 55 | face->processEvents(ndn::time::milliseconds(1)); |
Muktadir R Chowdhury | c69da0a | 2015-12-18 13:24:38 -0600 | [diff] [blame] | 56 | face->sentInterests.clear(); |
Ashlesh Gawande | 5bf8317 | 2014-09-19 12:38:17 -0500 | [diff] [blame] | 57 | |
| 58 | INIT_LOGGERS("/tmp", "DEBUG"); |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 59 | } |
| 60 | |
Vince Lehman | f1aa523 | 2014-10-06 17:57:35 -0500 | [diff] [blame] | 61 | void |
| 62 | extractParameters(ndn::Interest& interest, ndn::Name::Component& verb, |
| 63 | ndn::nfd::ControlParameters& extractedParameters) |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 64 | { |
| 65 | const ndn::Name& name = interest.getName(); |
| 66 | verb = name[REGISTER_COMMAND_PREFIX.size()]; |
| 67 | const ndn::Name::Component& parameterComponent = name[REGISTER_COMMAND_PREFIX.size() + 1]; |
| 68 | |
| 69 | ndn::Block rawParameters = parameterComponent.blockFromValue(); |
| 70 | extractedParameters.wireDecode(rawParameters); |
| 71 | } |
| 72 | |
Vince Lehman | f1aa523 | 2014-10-06 17:57:35 -0500 | [diff] [blame] | 73 | void |
| 74 | areNamePrefixListsEqual(NamePrefixList& lhs, NamePrefixList& rhs) |
| 75 | { |
Nick Gordon | f14ec35 | 2017-07-24 16:09:58 -0500 | [diff] [blame] | 76 | |
Vince Lehman | f1aa523 | 2014-10-06 17:57:35 -0500 | [diff] [blame] | 77 | typedef std::list<ndn::Name> NameList; |
| 78 | |
Nick Gordon | f14ec35 | 2017-07-24 16:09:58 -0500 | [diff] [blame] | 79 | NameList lhsList = lhs.getNames(); |
| 80 | NameList rhsList = rhs.getNames(); |
Vince Lehman | f1aa523 | 2014-10-06 17:57:35 -0500 | [diff] [blame] | 81 | |
| 82 | BOOST_REQUIRE_EQUAL(lhsList.size(), rhsList.size()); |
| 83 | |
| 84 | NameList::iterator i = lhsList.begin(); |
| 85 | NameList::iterator j = rhsList.begin(); |
| 86 | |
| 87 | for (; i != lhsList.end(); ++i, ++j) { |
| 88 | BOOST_CHECK_EQUAL(*i, *j); |
| 89 | } |
| 90 | } |
| 91 | |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 92 | public: |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 93 | std::shared_ptr<ndn::util::DummyClientFace> face; |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 94 | Nlsr nlsr; |
| 95 | SyncLogicHandler sync; |
| 96 | |
Vince Lehman | f1aa523 | 2014-10-06 17:57:35 -0500 | [diff] [blame] | 97 | Lsdb& lsdb; |
| 98 | ConfParameter& conf; |
| 99 | |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 100 | ndn::Name REGISTER_COMMAND_PREFIX; |
| 101 | ndn::Name::Component REGISTER_VERB; |
| 102 | }; |
| 103 | |
| 104 | BOOST_FIXTURE_TEST_SUITE(TestLsdb, LsdbFixture) |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 105 | |
Ashlesh Gawande | 5bf8317 | 2014-09-19 12:38:17 -0500 | [diff] [blame] | 106 | BOOST_AUTO_TEST_CASE(LsdbSync) |
| 107 | { |
| 108 | ndn::Name interestName("/ndn/NLSR/LSA/cs/%C1.Router/router2/name"); |
| 109 | uint64_t oldSeqNo = 82; |
| 110 | |
| 111 | ndn::Name oldInterestName = interestName; |
| 112 | oldInterestName.appendNumber(oldSeqNo); |
| 113 | |
| 114 | lsdb.expressInterest(oldInterestName, 0); |
| 115 | face->processEvents(ndn::time::milliseconds(1)); |
| 116 | |
Muktadir R Chowdhury | c69da0a | 2015-12-18 13:24:38 -0600 | [diff] [blame] | 117 | std::vector<ndn::Interest>& interests = face->sentInterests; |
Ashlesh Gawande | 5bf8317 | 2014-09-19 12:38:17 -0500 | [diff] [blame] | 118 | |
| 119 | BOOST_REQUIRE(interests.size() > 0); |
Ashlesh Gawande | 5bf8317 | 2014-09-19 12:38:17 -0500 | [diff] [blame] | 120 | |
Nick Gordon | 098aae4 | 2017-08-23 15:18:46 -0500 | [diff] [blame^] | 121 | bool didFindInterest = false; |
| 122 | for (const auto& interest : interests) { |
| 123 | didFindInterest = didFindInterest || interest.getName() == oldInterestName; |
| 124 | } |
| 125 | |
| 126 | BOOST_CHECK(didFindInterest); |
Ashlesh Gawande | 5bf8317 | 2014-09-19 12:38:17 -0500 | [diff] [blame] | 127 | interests.clear(); |
| 128 | |
Nick Gordon | e98480b | 2017-05-24 11:23:03 -0500 | [diff] [blame] | 129 | ndn::time::steady_clock::TimePoint deadline = ndn::time::steady_clock::now() + |
| 130 | ndn::time::seconds(LSA_REFRESH_TIME_MAX); |
Ashlesh Gawande | 5bf8317 | 2014-09-19 12:38:17 -0500 | [diff] [blame] | 131 | |
| 132 | // Simulate an LSA interest timeout |
Muktadir R Chowdhury | aa3b085 | 2015-08-06 13:08:56 -0500 | [diff] [blame] | 133 | lsdb.onFetchLsaError(ndn::util::SegmentFetcher::ErrorCode::INTEREST_TIMEOUT, "Timeout", |
| 134 | oldInterestName, 0, deadline, interestName, oldSeqNo); |
Ashlesh Gawande | 5bf8317 | 2014-09-19 12:38:17 -0500 | [diff] [blame] | 135 | face->processEvents(ndn::time::milliseconds(1)); |
| 136 | |
| 137 | BOOST_REQUIRE(interests.size() > 0); |
Ashlesh Gawande | 5bf8317 | 2014-09-19 12:38:17 -0500 | [diff] [blame] | 138 | |
Nick Gordon | 098aae4 | 2017-08-23 15:18:46 -0500 | [diff] [blame^] | 139 | didFindInterest = false; |
| 140 | for (const auto& interest : interests) { |
| 141 | didFindInterest = didFindInterest || interest.getName() == oldInterestName; |
| 142 | } |
| 143 | |
| 144 | BOOST_CHECK(didFindInterest); |
Ashlesh Gawande | 5bf8317 | 2014-09-19 12:38:17 -0500 | [diff] [blame] | 145 | interests.clear(); |
| 146 | |
| 147 | uint64_t newSeqNo = 83; |
| 148 | |
| 149 | ndn::Name newInterestName = interestName; |
| 150 | newInterestName.appendNumber(newSeqNo); |
| 151 | |
| 152 | lsdb.expressInterest(newInterestName, 0); |
| 153 | face->processEvents(ndn::time::milliseconds(1)); |
| 154 | |
| 155 | BOOST_REQUIRE(interests.size() > 0); |
Ashlesh Gawande | 5bf8317 | 2014-09-19 12:38:17 -0500 | [diff] [blame] | 156 | |
Nick Gordon | 098aae4 | 2017-08-23 15:18:46 -0500 | [diff] [blame^] | 157 | didFindInterest = false; |
| 158 | for (const auto& interest : interests) { |
| 159 | didFindInterest = didFindInterest || interest.getName() == newInterestName; |
| 160 | } |
| 161 | |
| 162 | BOOST_CHECK(didFindInterest); |
| 163 | |
Ashlesh Gawande | 5bf8317 | 2014-09-19 12:38:17 -0500 | [diff] [blame] | 164 | interests.clear(); |
| 165 | |
| 166 | // Simulate an LSA interest timeout where the sequence number is outdated |
Muktadir R Chowdhury | aa3b085 | 2015-08-06 13:08:56 -0500 | [diff] [blame] | 167 | lsdb.onFetchLsaError(ndn::util::SegmentFetcher::ErrorCode::INTEREST_TIMEOUT, "Timeout", |
| 168 | oldInterestName, 0, deadline, interestName, oldSeqNo); |
Ashlesh Gawande | 5bf8317 | 2014-09-19 12:38:17 -0500 | [diff] [blame] | 169 | face->processEvents(ndn::time::milliseconds(1)); |
| 170 | |
| 171 | // Interest should not be expressed for outdated sequence number |
| 172 | BOOST_CHECK_EQUAL(interests.size(), 0); |
| 173 | } |
| 174 | |
Muktadir R Chowdhury | aa3b085 | 2015-08-06 13:08:56 -0500 | [diff] [blame] | 175 | BOOST_AUTO_TEST_CASE(SegmentLsaData) |
| 176 | { |
| 177 | ndn::Name router("/ndn/cs/%C1.Router/router1"); |
| 178 | uint64_t seqNo = 12; |
| 179 | NamePrefixList prefixList; |
| 180 | |
| 181 | NameLsa lsa(router, seqNo, ndn::time::system_clock::now(), prefixList); |
| 182 | |
| 183 | ndn::Name prefix("/ndn/edu/memphis/netlab/research/nlsr/test/prefix/"); |
| 184 | |
| 185 | int nPrefixes = 0; |
| 186 | while (lsa.getData().size() < ndn::MAX_NDN_PACKET_SIZE) { |
| 187 | lsa.addName(ndn::Name(prefix).appendNumber(++nPrefixes)); |
| 188 | } |
| 189 | |
| 190 | std::string expectedDataContent = lsa.getData(); |
| 191 | lsdb.installNameLsa(lsa); |
| 192 | |
| 193 | ndn::Name interestName("/ndn/NLSR/LSA/cs/%C1.Router/router1/name/"); |
| 194 | interestName.appendNumber(seqNo); |
| 195 | |
| 196 | ndn::Interest interest(interestName); |
| 197 | |
| 198 | lsdb.processInterest(ndn::Name(), interest); |
| 199 | face->processEvents(ndn::time::milliseconds(1)); |
| 200 | |
| 201 | std::vector<ndn::Data> data = face->sentData; |
| 202 | std::string recvDataContent; |
| 203 | for (unsigned int i = 0; i < data.size(); ++i) |
| 204 | { |
| 205 | const ndn::Block& nameBlock = data[i].getContent(); |
| 206 | |
| 207 | std::string nameBlockContent(reinterpret_cast<char const*>(nameBlock.value()), |
| 208 | nameBlock.value_size()); |
| 209 | recvDataContent += nameBlockContent; |
| 210 | } |
| 211 | |
| 212 | BOOST_CHECK_EQUAL(expectedDataContent, recvDataContent); |
| 213 | } |
| 214 | |
| 215 | BOOST_AUTO_TEST_CASE(ReceiveSegmentedLsaData) |
| 216 | { |
| 217 | ndn::Name router("/ndn/cs/%C1.Router/router1"); |
| 218 | uint64_t seqNo = 12; |
| 219 | NamePrefixList prefixList; |
| 220 | |
| 221 | NameLsa lsa(router, seqNo, ndn::time::system_clock::now(), prefixList); |
| 222 | |
| 223 | ndn::Name prefix("/prefix/"); |
| 224 | |
| 225 | for (int nPrefixes = 0; nPrefixes < 3; ++nPrefixes) { |
| 226 | lsa.addName(ndn::Name(prefix).appendNumber(nPrefixes)); |
| 227 | } |
| 228 | |
| 229 | ndn::Name interestName("/ndn/NLSR/LSA/cs/%C1.Router/router1/name/"); |
| 230 | interestName.appendNumber(seqNo); |
| 231 | |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 232 | const ndn::ConstBufferPtr bufferPtr = std::make_shared<ndn::Buffer>(lsa.getData().c_str(), |
Muktadir R Chowdhury | aa3b085 | 2015-08-06 13:08:56 -0500 | [diff] [blame] | 233 | lsa.getData().size()); |
| 234 | lsdb.afterFetchLsa(bufferPtr, interestName); |
| 235 | |
| 236 | NameLsa* foundLsa = lsdb.findNameLsa(lsa.getKey()); |
| 237 | BOOST_REQUIRE(foundLsa != nullptr); |
| 238 | |
| 239 | BOOST_CHECK_EQUAL(foundLsa->getData(), lsa.getData()); |
| 240 | } |
| 241 | |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 242 | BOOST_AUTO_TEST_CASE(LsdbRemoveAndExists) |
| 243 | { |
akmhoque | c7a79b2 | 2014-05-26 08:06:19 -0500 | [diff] [blame] | 244 | ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now(); |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 245 | NamePrefixList npl1; |
| 246 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 247 | std::string s1 = "name1"; |
| 248 | std::string s2 = "name2"; |
| 249 | std::string router1 = "router1/1"; |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 250 | |
| 251 | npl1.insert(s1); |
| 252 | npl1.insert(s2); |
| 253 | |
Vince Lehman | 904c241 | 2014-09-23 19:36:11 -0500 | [diff] [blame] | 254 | //For NameLsa lsType is name. |
| 255 | //12 is seqNo, randomly generated. |
| 256 | //1800 is the default life time. |
Ashlesh Gawande | d02c388 | 2015-12-29 16:02:51 -0600 | [diff] [blame] | 257 | NameLsa nlsa1(ndn::Name("/router1/1"), 12, testTimePoint, npl1); |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 258 | |
Ashlesh Gawande | 3e105a0 | 2017-05-16 17:36:56 -0500 | [diff] [blame] | 259 | Lsdb lsdb1(nlsr, g_scheduler); |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 260 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 261 | lsdb1.installNameLsa(nlsa1); |
Alexander Afanasyev | 411ee4b | 2014-08-16 23:17:03 -0700 | [diff] [blame] | 262 | lsdb1.writeNameLsdbLog(); |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 263 | |
alvy | 49b1c0c | 2014-12-19 13:57:46 -0600 | [diff] [blame] | 264 | BOOST_CHECK(lsdb1.doesLsaExist(ndn::Name("/router1/1/name"), NameLsa::TYPE_STRING)); |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 265 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 266 | lsdb1.removeNameLsa(router1); |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 267 | |
alvy | 49b1c0c | 2014-12-19 13:57:46 -0600 | [diff] [blame] | 268 | BOOST_CHECK_EQUAL(lsdb1.doesLsaExist(ndn::Name("/router1/1"), NameLsa::TYPE_STRING), false); |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 269 | } |
| 270 | |
Vince Lehman | f1aa523 | 2014-10-06 17:57:35 -0500 | [diff] [blame] | 271 | BOOST_AUTO_TEST_CASE(InstallNameLsa) |
| 272 | { |
| 273 | // Install lsa with name1 and name2 |
| 274 | ndn::Name name1("/ndn/name1"); |
| 275 | ndn::Name name2("/ndn/name2"); |
| 276 | |
| 277 | NamePrefixList prefixes; |
| 278 | prefixes.insert(name1); |
| 279 | prefixes.insert(name2); |
| 280 | |
| 281 | std::string otherRouter("/ndn/site/%C1.router/other-router"); |
| 282 | ndn::time::system_clock::TimePoint MAX_TIME = ndn::time::system_clock::TimePoint::max(); |
| 283 | |
Ashlesh Gawande | d02c388 | 2015-12-29 16:02:51 -0600 | [diff] [blame] | 284 | NameLsa lsa(otherRouter, 1, MAX_TIME, prefixes); |
Vince Lehman | f1aa523 | 2014-10-06 17:57:35 -0500 | [diff] [blame] | 285 | lsdb.installNameLsa(lsa); |
| 286 | |
alvy | 49b1c0c | 2014-12-19 13:57:46 -0600 | [diff] [blame] | 287 | BOOST_REQUIRE_EQUAL(lsdb.doesLsaExist(otherRouter + "/name", NameLsa::TYPE_STRING), true); |
Vince Lehman | f1aa523 | 2014-10-06 17:57:35 -0500 | [diff] [blame] | 288 | NamePrefixList& nameList = lsdb.findNameLsa(otherRouter + "/name")->getNpl(); |
| 289 | |
Nick Gordon | f14ec35 | 2017-07-24 16:09:58 -0500 | [diff] [blame] | 290 | BOOST_CHECK_EQUAL(nameList, prefixes); |
| 291 | //areNamePrefixListsEqual(nameList, prefixes); |
Vince Lehman | f1aa523 | 2014-10-06 17:57:35 -0500 | [diff] [blame] | 292 | |
| 293 | // Add a prefix: name3 |
| 294 | ndn::Name name3("/ndn/name3"); |
| 295 | prefixes.insert(name3); |
| 296 | |
Ashlesh Gawande | d02c388 | 2015-12-29 16:02:51 -0600 | [diff] [blame] | 297 | NameLsa addLsa(otherRouter, 2, MAX_TIME, prefixes); |
Vince Lehman | f1aa523 | 2014-10-06 17:57:35 -0500 | [diff] [blame] | 298 | lsdb.installNameLsa(addLsa); |
| 299 | |
| 300 | // Lsa should include name1, name2, and name3 |
Nick Gordon | f14ec35 | 2017-07-24 16:09:58 -0500 | [diff] [blame] | 301 | BOOST_CHECK_EQUAL(nameList, prefixes); |
Vince Lehman | f1aa523 | 2014-10-06 17:57:35 -0500 | [diff] [blame] | 302 | |
| 303 | // Remove a prefix: name2 |
| 304 | prefixes.remove(name2); |
| 305 | |
Ashlesh Gawande | d02c388 | 2015-12-29 16:02:51 -0600 | [diff] [blame] | 306 | NameLsa removeLsa(otherRouter, 3, MAX_TIME, prefixes); |
Vince Lehman | f1aa523 | 2014-10-06 17:57:35 -0500 | [diff] [blame] | 307 | lsdb.installNameLsa(removeLsa); |
| 308 | |
| 309 | // Lsa should include name1 and name3 |
Nick Gordon | f14ec35 | 2017-07-24 16:09:58 -0500 | [diff] [blame] | 310 | BOOST_CHECK_EQUAL(nameList, prefixes); |
Vince Lehman | f1aa523 | 2014-10-06 17:57:35 -0500 | [diff] [blame] | 311 | |
| 312 | // Add and remove a prefix: add name2, remove name3 |
| 313 | prefixes.insert(name2); |
| 314 | prefixes.remove(name3); |
| 315 | |
Ashlesh Gawande | d02c388 | 2015-12-29 16:02:51 -0600 | [diff] [blame] | 316 | NameLsa addAndRemoveLsa(otherRouter, 4, MAX_TIME, prefixes); |
Vince Lehman | f1aa523 | 2014-10-06 17:57:35 -0500 | [diff] [blame] | 317 | lsdb.installNameLsa(addAndRemoveLsa); |
| 318 | |
| 319 | // Lsa should include name1 and name2 |
Nick Gordon | f14ec35 | 2017-07-24 16:09:58 -0500 | [diff] [blame] | 320 | BOOST_CHECK_EQUAL(nameList, prefixes); |
Vince Lehman | f1aa523 | 2014-10-06 17:57:35 -0500 | [diff] [blame] | 321 | |
| 322 | // Install a completely new list of prefixes |
| 323 | ndn::Name name4("/ndn/name4"); |
| 324 | ndn::Name name5("/ndn/name5"); |
| 325 | |
| 326 | NamePrefixList newPrefixes; |
| 327 | newPrefixes.insert(name4); |
| 328 | newPrefixes.insert(name5); |
| 329 | |
Ashlesh Gawande | d02c388 | 2015-12-29 16:02:51 -0600 | [diff] [blame] | 330 | NameLsa newLsa(otherRouter, 5, MAX_TIME, newPrefixes); |
Vince Lehman | f1aa523 | 2014-10-06 17:57:35 -0500 | [diff] [blame] | 331 | lsdb.installNameLsa(newLsa); |
| 332 | |
| 333 | // Lsa should include name4 and name5 |
Nick Gordon | f14ec35 | 2017-07-24 16:09:58 -0500 | [diff] [blame] | 334 | BOOST_CHECK_EQUAL(nameList, newPrefixes); |
Vince Lehman | f1aa523 | 2014-10-06 17:57:35 -0500 | [diff] [blame] | 335 | } |
| 336 | |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 337 | BOOST_AUTO_TEST_SUITE_END() |
| 338 | |
Nick Gordon | fad8e25 | 2016-08-11 14:21:38 -0500 | [diff] [blame] | 339 | } // namespace test |
| 340 | } // namespace nlsr |