Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Junxiao Shi | fc2e13d | 2017-07-25 02:08:48 +0000 | [diff] [blame] | 2 | /* |
Junxiao Shi | 727b610 | 2022-01-11 18:40:04 +0000 | [diff] [blame] | 3 | * Copyright (c) 2014-2022, Regents of the University of California, |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +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 | |
Davide Pesavento | 7922d12 | 2021-03-05 22:41:23 -0500 | [diff] [blame] | 26 | #include "fw/best-route-strategy.hpp" |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 27 | |
Davide Pesavento | cf7db2f | 2019-03-24 23:17:28 -0400 | [diff] [blame] | 28 | #include "tests/daemon/global-io-fixture.hpp" |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 29 | #include "topology-tester.hpp" |
| 30 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 31 | namespace nfd::tests { |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 32 | |
Junxiao Shi | 727b610 | 2022-01-11 18:40:04 +0000 | [diff] [blame] | 33 | #define CHECK_FH_EQUAL(actual, ...) \ |
| 34 | do { \ |
| 35 | std::vector<Name> expected({__VA_ARGS__}); \ |
| 36 | BOOST_CHECK_EQUAL_COLLECTIONS( \ |
| 37 | (actual).getForwardingHint().begin(), (actual).getForwardingHint().end(), \ |
| 38 | expected.begin(), expected.end()); \ |
| 39 | } while (false) |
| 40 | |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 41 | BOOST_AUTO_TEST_SUITE(Fw) |
Junxiao Shi | fc2e13d | 2017-07-25 02:08:48 +0000 | [diff] [blame] | 42 | BOOST_AUTO_TEST_SUITE(TestForwardingHint) |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 43 | |
| 44 | /** |
| 45 | * /arizona/cs/avenir |
| 46 | * | |
| 47 | * v |
| 48 | * /arizona/cs/hobo |
| 49 | * | | |
| 50 | * v v |
| 51 | * /telia/terabits /ucsd/caida/click |
| 52 | * | | |
| 53 | * v v |
| 54 | * /net/ndnsim /ucla/cs/spurs |
| 55 | * (serverP) | |
| 56 | * v |
| 57 | * /net/ndnsim |
| 58 | * (serverQ) |
| 59 | */ |
Davide Pesavento | cf7db2f | 2019-03-24 23:17:28 -0400 | [diff] [blame] | 60 | class NdnsimTeliaUclaTopologyFixture : public GlobalIoTimeFixture |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 61 | { |
| 62 | public: |
| 63 | NdnsimTeliaUclaTopologyFixture() |
| 64 | { |
| 65 | topo.enablePcap(); |
| 66 | |
| 67 | nodeA = topo.addForwarder("avenir"); |
| 68 | nodeH = topo.addForwarder("hobo"); |
| 69 | nodeT = topo.addForwarder("terabits"); |
| 70 | nodeP = topo.addForwarder("serverP"); |
| 71 | nodeC = topo.addForwarder("click"); |
| 72 | nodeS = topo.addForwarder("spurs"); |
| 73 | nodeQ = topo.addForwarder("serverQ"); |
Davide Pesavento | 7922d12 | 2021-03-05 22:41:23 -0500 | [diff] [blame] | 74 | for (auto node : {nodeA, nodeH, nodeT, nodeP, nodeC, nodeS, nodeQ}) { |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 75 | topo.setStrategy<fw::BestRouteStrategy>(node); |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 76 | } |
| 77 | |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 78 | topo.getForwarder(nodeH).getNetworkRegionTable().insert("/arizona/cs/hobo"); |
| 79 | topo.getForwarder(nodeT).getNetworkRegionTable().insert("/telia/terabits/router"); |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 80 | topo.getForwarder(nodeC).getNetworkRegionTable().insert("/ucsd/caida/click"); |
| 81 | topo.getForwarder(nodeS).getNetworkRegionTable().insert("/ucla/cs/spurs"); |
Junxiao Shi | f9858fd | 2017-02-01 16:22:44 +0000 | [diff] [blame] | 82 | // NetworkRegionTable configuration is unnecessary on end hosts |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 83 | |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 84 | linkAH = topo.addLink("AH", 10_ms, {nodeA, nodeH}); |
| 85 | linkHT = topo.addLink("HT", 10_ms, {nodeH, nodeT}); |
| 86 | linkTP = topo.addLink("TP", 10_ms, {nodeT, nodeP}); |
| 87 | linkHC = topo.addLink("HC", 10_ms, {nodeH, nodeC}); |
| 88 | linkCS = topo.addLink("CS", 10_ms, {nodeC, nodeS}); |
| 89 | linkSQ = topo.addLink("SQ", 10_ms, {nodeS, nodeQ}); |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 90 | consumerA = topo.addAppFace("avenir", nodeA); |
| 91 | producerP = topo.addAppFace("ndnsimP", nodeP, "/net/ndnsim"); |
| 92 | producerQ = topo.addAppFace("ndnsimQ", nodeQ, "/net/ndnsim"); |
| 93 | |
| 94 | topo.addEchoProducer(producerP->getClientFace()); |
| 95 | topo.addEchoProducer(producerQ->getClientFace()); |
| 96 | |
| 97 | topo.registerPrefix(nodeA, linkAH->getFace(nodeA), "/", 10); |
| 98 | topo.registerPrefix(nodeH, linkHT->getFace(nodeH), "/telia", 10); |
| 99 | topo.registerPrefix(nodeT, linkTP->getFace(nodeT), "/net/ndnsim", 10); |
| 100 | topo.registerPrefix(nodeH, linkHC->getFace(nodeH), "/ucla", 20); |
| 101 | topo.registerPrefix(nodeC, linkCS->getFace(nodeC), "/ucla", 10); |
| 102 | topo.registerPrefix(nodeS, linkSQ->getFace(nodeS), "/net/ndnsim", 10); |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 103 | } |
| 104 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 105 | /** \brief Express an Interest with Link object from consumerA. |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 106 | */ |
| 107 | void |
| 108 | consumerExpressInterest(int seq) |
| 109 | { |
| 110 | auto interest = makeInterest(Name("/net/ndnsim").appendNumber(seq)); |
Junxiao Shi | 727b610 | 2022-01-11 18:40:04 +0000 | [diff] [blame] | 111 | interest->setForwardingHint({nameTelia, nameUcla}); |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 112 | consumerA->getClientFace().expressInterest(*interest, nullptr, nullptr, nullptr); |
| 113 | } |
| 114 | |
| 115 | public: |
| 116 | TopologyTester topo; |
| 117 | TopologyNode nodeA, nodeH, nodeT, nodeP, nodeC, nodeS, nodeQ; |
| 118 | shared_ptr<TopologyLink> linkAH, linkHT, linkTP, linkHC, linkCS, linkSQ; |
| 119 | shared_ptr<TopologyAppLink> consumerA, producerP, producerQ; |
Junxiao Shi | fc2e13d | 2017-07-25 02:08:48 +0000 | [diff] [blame] | 120 | |
Junxiao Shi | 727b610 | 2022-01-11 18:40:04 +0000 | [diff] [blame] | 121 | Name nameTelia = "/telia/terabits"; |
| 122 | Name nameUcla = "/ucla/cs"; |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 123 | }; |
| 124 | |
| 125 | BOOST_FIXTURE_TEST_SUITE(NdnsimTeliaUclaTopology, NdnsimTeliaUclaTopologyFixture) |
| 126 | |
| 127 | BOOST_AUTO_TEST_CASE(FetchTelia) |
| 128 | { |
| 129 | this->consumerExpressInterest(1); |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 130 | this->advanceClocks(11_ms, 20); |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 131 | |
Junxiao Shi | fc2e13d | 2017-07-25 02:08:48 +0000 | [diff] [blame] | 132 | // A forwards Interest according to default route, no change to forwarding hint |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 133 | BOOST_CHECK_EQUAL(linkAH->getFace(nodeA).getCounters().nOutInterests, 1); |
| 134 | const Interest& interestAH = topo.getPcap(linkAH->getFace(nodeA)).sentInterests.at(0); |
Junxiao Shi | 727b610 | 2022-01-11 18:40:04 +0000 | [diff] [blame] | 135 | CHECK_FH_EQUAL(interestAH, nameTelia, nameUcla); |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 136 | |
Junxiao Shi | fc2e13d | 2017-07-25 02:08:48 +0000 | [diff] [blame] | 137 | // H prefers T, no change to forwarding hint |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 138 | BOOST_CHECK_EQUAL(linkHT->getFace(nodeH).getCounters().nOutInterests, 1); |
| 139 | const Interest& interestHT = topo.getPcap(linkHT->getFace(nodeH)).sentInterests.at(0); |
Junxiao Shi | 727b610 | 2022-01-11 18:40:04 +0000 | [diff] [blame] | 140 | CHECK_FH_EQUAL(interestHT, nameTelia, nameUcla); |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 141 | |
Junxiao Shi | fc2e13d | 2017-07-25 02:08:48 +0000 | [diff] [blame] | 142 | // T forwards to P, forwarding hint stripped when Interest reaches producer region |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 143 | BOOST_CHECK_EQUAL(linkTP->getFace(nodeT).getCounters().nOutInterests, 1); |
| 144 | const Interest& interestTP = topo.getPcap(linkTP->getFace(nodeT)).sentInterests.at(0); |
Junxiao Shi | fc2e13d | 2017-07-25 02:08:48 +0000 | [diff] [blame] | 145 | BOOST_CHECK(interestTP.getForwardingHint().empty()); |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 146 | |
| 147 | // Data is served by P and reaches A |
| 148 | BOOST_CHECK_EQUAL(producerP->getForwarderFace().getCounters().nInData, 1); |
| 149 | BOOST_CHECK_EQUAL(consumerA->getForwarderFace().getCounters().nOutData, 1); |
| 150 | } |
| 151 | |
| 152 | BOOST_AUTO_TEST_CASE(FetchUcla) |
| 153 | { |
| 154 | // disconnect H-T and delete FIB entry |
| 155 | linkHT->fail(); |
| 156 | topo.getForwarder(nodeH).getFib().erase("/telia"); |
| 157 | |
| 158 | this->consumerExpressInterest(1); |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 159 | this->advanceClocks(11_ms, 20); |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 160 | |
Junxiao Shi | fc2e13d | 2017-07-25 02:08:48 +0000 | [diff] [blame] | 161 | // A forwards Interest according to default route, no change to forwarding hint |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 162 | BOOST_CHECK_EQUAL(linkAH->getFace(nodeA).getCounters().nOutInterests, 1); |
| 163 | const Interest& interestAH = topo.getPcap(linkAH->getFace(nodeA)).sentInterests.at(0); |
Junxiao Shi | 727b610 | 2022-01-11 18:40:04 +0000 | [diff] [blame] | 164 | CHECK_FH_EQUAL(interestAH, nameTelia, nameUcla); |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 165 | |
Junxiao Shi | fc2e13d | 2017-07-25 02:08:48 +0000 | [diff] [blame] | 166 | // H forwards to C, no change to forwarding hint |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 167 | BOOST_CHECK_EQUAL(linkHC->getFace(nodeH).getCounters().nOutInterests, 1); |
| 168 | const Interest& interestHC = topo.getPcap(linkHC->getFace(nodeH)).sentInterests.at(0); |
Junxiao Shi | 727b610 | 2022-01-11 18:40:04 +0000 | [diff] [blame] | 169 | CHECK_FH_EQUAL(interestHC, nameTelia, nameUcla); |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 170 | |
Junxiao Shi | fc2e13d | 2017-07-25 02:08:48 +0000 | [diff] [blame] | 171 | // C forwards to S, no change to forwarding hint |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 172 | BOOST_CHECK_EQUAL(linkCS->getFace(nodeC).getCounters().nOutInterests, 1); |
| 173 | const Interest& interestCS = topo.getPcap(linkCS->getFace(nodeC)).sentInterests.at(0); |
Junxiao Shi | 727b610 | 2022-01-11 18:40:04 +0000 | [diff] [blame] | 174 | CHECK_FH_EQUAL(interestCS, nameTelia, nameUcla); |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 175 | |
Junxiao Shi | fc2e13d | 2017-07-25 02:08:48 +0000 | [diff] [blame] | 176 | // S forwards to Q, forwarding hint stripped when Interest reaches producer region |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 177 | BOOST_CHECK_EQUAL(linkSQ->getFace(nodeS).getCounters().nOutInterests, 1); |
| 178 | const Interest& interestSQ = topo.getPcap(linkSQ->getFace(nodeS)).sentInterests.at(0); |
Junxiao Shi | fc2e13d | 2017-07-25 02:08:48 +0000 | [diff] [blame] | 179 | BOOST_CHECK(interestSQ.getForwardingHint().empty()); |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 180 | |
| 181 | // Data is served by Q and reaches A |
| 182 | BOOST_CHECK_EQUAL(producerQ->getForwarderFace().getCounters().nInData, 1); |
| 183 | BOOST_CHECK_EQUAL(consumerA->getForwarderFace().getCounters().nOutData, 1); |
| 184 | } |
| 185 | |
| 186 | BOOST_AUTO_TEST_SUITE_END() // NdnsimTeliaUclaTopology |
| 187 | |
Junxiao Shi | fc2e13d | 2017-07-25 02:08:48 +0000 | [diff] [blame] | 188 | BOOST_AUTO_TEST_SUITE_END() // TestForwardingHint |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 189 | BOOST_AUTO_TEST_SUITE_END() // Fw |
| 190 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 191 | } // namespace nfd::tests |