Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | cf7db2f | 2019-03-24 23:17:28 -0400 | [diff] [blame] | 2 | /* |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 3 | * Copyright (c) 2014-2022, Regents of the University of California, |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [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 | #include "fw/access-strategy.hpp" |
| 27 | |
Junxiao Shi | 890afe9 | 2016-12-15 14:34:34 +0000 | [diff] [blame] | 28 | #include "strategy-tester.hpp" |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [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 | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 32 | |
Junxiao Shi | 890afe9 | 2016-12-15 14:34:34 +0000 | [diff] [blame] | 33 | // The tester is unused in this file, but it's used in various templated test suites. |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 34 | using AccessStrategyTester = StrategyTester<fw::AccessStrategy>; |
Junxiao Shi | 890afe9 | 2016-12-15 14:34:34 +0000 | [diff] [blame] | 35 | NFD_REGISTER_STRATEGY(AccessStrategyTester); |
| 36 | |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 37 | // This test suite tests AccessStrategy's behavior as a black box, |
| 38 | // without accessing its internals. |
| 39 | // |
| 40 | // Many test assertions are qualitative rather than quantitative. |
| 41 | // They capture the design highlights of the strategy without requiring a definite value, |
| 42 | // so that the test suite is not fragile to minor changes in the strategy implementation. |
| 43 | // |
| 44 | // Topology graphes in this test suite are shown in ASCII art, |
| 45 | // in a style similar to ns-3 and ndnSIM examples. |
| 46 | // They are enclosed in multi-line comments, which is an intentional violation of |
| 47 | // code style rule 3.25. This is necessary because some lines ends with '\' which |
| 48 | // would cause "multi-line comment" compiler warning if '//' comments are used. |
| 49 | |
Davide Pesavento | cf7db2f | 2019-03-24 23:17:28 -0400 | [diff] [blame] | 50 | class TwoLaptopsFixture : public GlobalIoTimeFixture |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 51 | { |
| 52 | protected: |
| 53 | TwoLaptopsFixture() |
| 54 | { |
| 55 | /* |
| 56 | * +--------+ |
| 57 | * +----->| router |<------+ |
| 58 | * | +--------+ | |
| 59 | * 10ms | | 20ms |
| 60 | * v v |
| 61 | * +---------+ +---------+ |
| 62 | * | laptopA | | laptopB | |
| 63 | * +---------+ +---------+ |
| 64 | */ |
| 65 | |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 66 | router = topo.addForwarder("R"); |
| 67 | laptopA = topo.addForwarder("A"); |
| 68 | laptopB = topo.addForwarder("B"); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 69 | |
| 70 | topo.setStrategy<fw::AccessStrategy>(router); |
| 71 | |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 72 | linkA = topo.addLink("RA", 10_ms, {router, laptopA}); |
| 73 | linkB = topo.addLink("RB", 20_ms, {router, laptopB}); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | protected: |
| 77 | TopologyTester topo; |
| 78 | |
| 79 | TopologyNode router; |
| 80 | TopologyNode laptopA; |
| 81 | TopologyNode laptopB; |
| 82 | shared_ptr<TopologyLink> linkA; |
| 83 | shared_ptr<TopologyLink> linkB; |
| 84 | }; |
| 85 | |
Junxiao Shi | 91f6ee0 | 2016-12-29 21:44:44 +0000 | [diff] [blame] | 86 | BOOST_AUTO_TEST_SUITE(Fw) |
| 87 | BOOST_FIXTURE_TEST_SUITE(TestAccessStrategy, TwoLaptopsFixture) |
| 88 | |
| 89 | BOOST_AUTO_TEST_CASE(OneProducer) |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 90 | { |
| 91 | /* |
| 92 | * /------------------\ |
| 93 | * | intervalConsumer | |
| 94 | * \------------------/ |
| 95 | * ^ v |
| 96 | * | v /laptops/A |
| 97 | * | |
| 98 | * v |
| 99 | * /laptops << +--------+ >> /laptops |
| 100 | * +----->| router |<------+ |
| 101 | * | +--------+ | |
| 102 | * 10ms | | 20ms |
| 103 | * v v |
| 104 | * +---------+ +---------+ |
| 105 | * | laptopA | | laptopB | |
| 106 | * +---------+ +---------+ |
| 107 | * ^ v |
| 108 | * | v /laptops/A |
| 109 | * v |
| 110 | * /--------------\ |
| 111 | * | echoProducer | |
| 112 | * \--------------/ |
| 113 | */ |
| 114 | |
| 115 | // two laptops have same prefix in router FIB |
| 116 | topo.registerPrefix(router, linkA->getFace(router), "ndn:/laptops"); |
| 117 | topo.registerPrefix(router, linkB->getFace(router), "ndn:/laptops"); |
| 118 | |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 119 | shared_ptr<TopologyAppLink> producer = topo.addAppFace("p", laptopA, "ndn:/laptops/A"); |
| 120 | topo.addEchoProducer(producer->getClientFace()); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 121 | |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 122 | shared_ptr<TopologyAppLink> consumer = topo.addAppFace("c", router); |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 123 | topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/laptops/A", 100_ms, 100); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 124 | |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 125 | this->advanceClocks(5_ms, 12_s); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 126 | |
| 127 | // most Interests should be satisfied, and few Interests can go to wrong laptop |
Junxiao Shi | da93f1f | 2015-11-11 06:13:16 -0700 | [diff] [blame] | 128 | BOOST_CHECK_GE(consumer->getForwarderFace().getCounters().nOutData, 97); |
| 129 | BOOST_CHECK_GE(linkA->getFace(router).getCounters().nOutInterests, 97); |
| 130 | BOOST_CHECK_LE(linkB->getFace(router).getCounters().nOutInterests, 5); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 131 | } |
| 132 | |
Junxiao Shi | 91f6ee0 | 2016-12-29 21:44:44 +0000 | [diff] [blame] | 133 | BOOST_AUTO_TEST_CASE(FastSlowProducer) |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 134 | { |
| 135 | /* |
| 136 | * /------------------\ |
| 137 | * | intervalConsumer | |
| 138 | * \------------------/ |
| 139 | * ^ v |
| 140 | * | v /laptops/BOTH |
| 141 | * | |
| 142 | * v |
| 143 | * /laptops << +--------+ >> /laptops |
| 144 | * +----->| router |<------+ |
| 145 | * | +--------+ | |
| 146 | * 10ms | | 20ms |
| 147 | * v v |
| 148 | * +---------+ +---------+ |
| 149 | * | laptopA | | laptopB | |
| 150 | * +---------+ +---------+ |
| 151 | * ^ v ^ v |
| 152 | * | v /laptops/BOTH | v /laptops/BOTH |
| 153 | * v v |
| 154 | * /--------------\ /--------------\ |
| 155 | * | echoProducer | | echoProducer | |
| 156 | * \--------------/ \--------------/ |
| 157 | */ |
| 158 | |
| 159 | // two laptops have same prefix in router FIB |
| 160 | topo.registerPrefix(router, linkA->getFace(router), "ndn:/laptops"); |
| 161 | topo.registerPrefix(router, linkB->getFace(router), "ndn:/laptops"); |
| 162 | |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 163 | shared_ptr<TopologyAppLink> producerA = topo.addAppFace("pA", laptopA, "ndn:/laptops/BOTH"); |
| 164 | topo.addEchoProducer(producerA->getClientFace()); |
| 165 | shared_ptr<TopologyAppLink> producerB = topo.addAppFace("pB", laptopB, "ndn:/laptops/BOTH"); |
| 166 | topo.addEchoProducer(producerB->getClientFace()); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 167 | |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 168 | shared_ptr<TopologyAppLink> consumer = topo.addAppFace("c", router); |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 169 | topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/laptops/BOTH", 100_ms, 100); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 170 | |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 171 | this->advanceClocks(5_ms, 12_s); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 172 | |
| 173 | // most Interests should be satisfied, and few Interests can go to slower laptopB |
Junxiao Shi | da93f1f | 2015-11-11 06:13:16 -0700 | [diff] [blame] | 174 | BOOST_CHECK_GE(consumer->getForwarderFace().getCounters().nOutData, 97); |
| 175 | BOOST_CHECK_GE(linkA->getFace(router).getCounters().nOutInterests, 90); |
| 176 | BOOST_CHECK_LE(linkB->getFace(router).getCounters().nOutInterests, 15); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 177 | } |
| 178 | |
Junxiao Shi | 91f6ee0 | 2016-12-29 21:44:44 +0000 | [diff] [blame] | 179 | BOOST_AUTO_TEST_CASE(ProducerMobility) |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 180 | { |
| 181 | /* |
| 182 | * /------------------\ /------------------\ |
| 183 | * | intervalConsumer | | intervalConsumer | |
| 184 | * \------------------/ A \------------------/ |
| 185 | * ^ v f ^ v |
| 186 | * | v /laptops/M t | v /laptops/M |
| 187 | * | e | |
| 188 | * v r v |
| 189 | * /laptops << +--------+ >> /laptops /laptops << +--------+ >> /laptops |
| 190 | * +----->| router |<------+ 6 +----->| router |<------+ |
| 191 | * | +--------+ | | +--------+ | |
| 192 | * 10ms | | 20ms === s ==> 10ms | | 20ms |
| 193 | * v v e v v |
| 194 | * +---------+ +---------+ c +---------+ +---------+ |
| 195 | * | laptopA | | laptopB | o | laptopA | | laptopB | |
| 196 | * +---------+ +---------+ n +---------+ +---------+ |
| 197 | * ^ v d v ^ |
| 198 | * | v /laptops/M s /laptops/M v | |
| 199 | * v v |
| 200 | * /--------------\ /--------------\ |
| 201 | * | echoProducer | | echoProducer | |
| 202 | * \--------------/ \--------------/ |
| 203 | */ |
| 204 | |
| 205 | // two laptops have same prefix in router FIB |
| 206 | topo.registerPrefix(router, linkA->getFace(router), "ndn:/laptops"); |
| 207 | topo.registerPrefix(router, linkB->getFace(router), "ndn:/laptops"); |
| 208 | |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 209 | shared_ptr<TopologyAppLink> producerA = topo.addAppFace("pA", laptopA, "ndn:/laptops/M"); |
| 210 | topo.addEchoProducer(producerA->getClientFace()); |
| 211 | shared_ptr<TopologyAppLink> producerB = topo.addAppFace("pB", laptopB, "ndn:/laptops/M"); |
| 212 | topo.addEchoProducer(producerB->getClientFace()); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 213 | |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 214 | shared_ptr<TopologyAppLink> consumer = topo.addAppFace("c", router); |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 215 | topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/laptops/M", 100_ms, 100); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 216 | |
| 217 | // producer is initially on laptopA |
| 218 | producerB->fail(); |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 219 | this->advanceClocks(5_ms, 6_s); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 220 | |
| 221 | // few Interests can go to laptopB |
Junxiao Shi | da93f1f | 2015-11-11 06:13:16 -0700 | [diff] [blame] | 222 | BOOST_CHECK_LE(linkB->getFace(router).getCounters().nOutInterests, 5); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 223 | |
| 224 | // producer moves to laptopB |
| 225 | producerA->fail(); |
| 226 | producerB->recover(); |
Junxiao Shi | da93f1f | 2015-11-11 06:13:16 -0700 | [diff] [blame] | 227 | PacketCounter::rep nInterestsToA_beforeMove = linkA->getFace(router).getCounters().nOutInterests; |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 228 | this->advanceClocks(5_ms, 6_s); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 229 | |
| 230 | // few additional Interests can go to laptopA |
Junxiao Shi | da93f1f | 2015-11-11 06:13:16 -0700 | [diff] [blame] | 231 | BOOST_CHECK_LE(linkA->getFace(router).getCounters().nOutInterests - nInterestsToA_beforeMove, 5); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 232 | |
| 233 | // most Interests should be satisfied |
Junxiao Shi | da93f1f | 2015-11-11 06:13:16 -0700 | [diff] [blame] | 234 | BOOST_CHECK_GE(consumer->getForwarderFace().getCounters().nOutData, 97); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 235 | } |
| 236 | |
Junxiao Shi | 91f6ee0 | 2016-12-29 21:44:44 +0000 | [diff] [blame] | 237 | BOOST_AUTO_TEST_CASE(Bidirectional) |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 238 | { |
| 239 | /* |
| 240 | * /laptops << +--------+ >> /laptops |
| 241 | * +----->| router |<------+ |
| 242 | * | +--------+ | |
| 243 | * ^ 10ms | | 20ms ^ |
| 244 | * / ^ v v ^ / |
| 245 | * +---------+ +---------+ |
| 246 | * +----->| laptopA | | laptopB |<------------+ |
| 247 | * | +---------+ +---------+ | |
| 248 | * | ^ v /laptops/A ^ v /laptops/B | |
| 249 | * ^ | | v | v | ^ |
| 250 | * /laptops/B ^ v v v v ^ /laptops/A |
| 251 | * /------------------\ /--------------\ /--------------\ /------------------\ |
| 252 | * | intervalConsumer | | echoProducer | | echoProducer | | intervalConsumer | |
| 253 | * \------------------/ \--------------/ \--------------/ \------------------/ |
| 254 | */ |
| 255 | |
| 256 | // laptops have default routes toward the router |
| 257 | topo.registerPrefix(laptopA, linkA->getFace(laptopA), "ndn:/"); |
| 258 | topo.registerPrefix(laptopB, linkB->getFace(laptopB), "ndn:/"); |
| 259 | |
| 260 | // two laptops have same prefix in router FIB |
| 261 | topo.registerPrefix(router, linkA->getFace(router), "ndn:/laptops"); |
| 262 | topo.registerPrefix(router, linkB->getFace(router), "ndn:/laptops"); |
| 263 | |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 264 | shared_ptr<TopologyAppLink> producerA = topo.addAppFace("pA", laptopA, "ndn:/laptops/A"); |
| 265 | topo.addEchoProducer(producerA->getClientFace()); |
| 266 | shared_ptr<TopologyAppLink> producerB = topo.addAppFace("pB", laptopB, "ndn:/laptops/B"); |
| 267 | topo.addEchoProducer(producerB->getClientFace()); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 268 | |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 269 | shared_ptr<TopologyAppLink> consumerAB = topo.addAppFace("cAB", laptopA); |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 270 | topo.addIntervalConsumer(consumerAB->getClientFace(), "ndn:/laptops/B", 100_ms, 100); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 271 | shared_ptr<TopologyAppLink> consumerBA = topo.addAppFace("cBA", laptopB); |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 272 | topo.addIntervalConsumer(consumerBA->getClientFace(), "ndn:/laptops/A", 100_ms, 100); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 273 | |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 274 | this->advanceClocks(5_ms, 12_s); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 275 | |
| 276 | // most Interests should be satisfied |
Junxiao Shi | da93f1f | 2015-11-11 06:13:16 -0700 | [diff] [blame] | 277 | BOOST_CHECK_GE(consumerAB->getForwarderFace().getCounters().nOutData, 97); |
| 278 | BOOST_CHECK_GE(consumerBA->getForwarderFace().getCounters().nOutData, 97); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 279 | } |
| 280 | |
Junxiao Shi | 91f6ee0 | 2016-12-29 21:44:44 +0000 | [diff] [blame] | 281 | BOOST_AUTO_TEST_CASE(PacketLoss) |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 282 | { |
| 283 | /* |
| 284 | * test case Interests |
| 285 | * | |
| 286 | * v |
| 287 | * +--------+ |
| 288 | * | router | |
| 289 | * +--------+ |
| 290 | * | v |
| 291 | * 10ms | v /laptops |
| 292 | * v |
| 293 | * +---------+ |
| 294 | * | laptopA | |
| 295 | * +---------+ |
| 296 | * ^ v |
| 297 | * | v /laptops/A |
| 298 | * v |
| 299 | * /--------------\ |
| 300 | * | echoProducer | |
| 301 | * \--------------/ |
| 302 | */ |
| 303 | |
| 304 | // laptopA has prefix in router FIB; laptopB is unused in this test case |
| 305 | topo.registerPrefix(router, linkA->getFace(router), "ndn:/laptops"); |
| 306 | |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 307 | shared_ptr<TopologyAppLink> producerA = topo.addAppFace("pA", laptopA, "ndn:/laptops/A"); |
| 308 | topo.addEchoProducer(producerA->getClientFace()); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 309 | |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 310 | shared_ptr<TopologyAppLink> consumer = topo.addAppFace("c", router); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 311 | |
| 312 | // Interest 1 completes normally |
| 313 | shared_ptr<Interest> interest1 = makeInterest("ndn:/laptops/A/1"); |
| 314 | bool hasData1 = false; |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 315 | consumer->getClientFace().expressInterest(*interest1, |
Davide Pesavento | 412c982 | 2021-07-02 00:21:05 -0400 | [diff] [blame] | 316 | [&] (auto&&...) { hasData1 = true; }, |
Junxiao Shi | 352fc82 | 2016-08-09 03:53:05 +0000 | [diff] [blame] | 317 | nullptr, nullptr); |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 318 | this->advanceClocks(5_ms, 1_s); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 319 | BOOST_CHECK_EQUAL(hasData1, true); |
| 320 | |
| 321 | // Interest 2 experiences a packet loss on initial transmission |
| 322 | shared_ptr<Interest> interest2a = makeInterest("ndn:/laptops/A/2"); |
| 323 | bool hasData2a = false, hasTimeout2a = false; |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 324 | consumer->getClientFace().expressInterest(*interest2a, |
Davide Pesavento | 412c982 | 2021-07-02 00:21:05 -0400 | [diff] [blame] | 325 | [&] (auto&&...) { hasData2a = true; }, |
Junxiao Shi | 352fc82 | 2016-08-09 03:53:05 +0000 | [diff] [blame] | 326 | nullptr, |
Davide Pesavento | 412c982 | 2021-07-02 00:21:05 -0400 | [diff] [blame] | 327 | [&] (auto&&...) { hasTimeout2a = true; }); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 328 | producerA->fail(); |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 329 | this->advanceClocks(5_ms, 60_ms); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 330 | BOOST_CHECK_EQUAL(hasData2a, false); |
| 331 | BOOST_CHECK_EQUAL(hasTimeout2a, false); |
| 332 | |
| 333 | // Interest 2 retransmission is suppressed |
| 334 | shared_ptr<Interest> interest2b = makeInterest("ndn:/laptops/A/2"); |
| 335 | bool hasData2b = false; |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 336 | consumer->getClientFace().expressInterest(*interest2b, |
Davide Pesavento | 412c982 | 2021-07-02 00:21:05 -0400 | [diff] [blame] | 337 | [&] (auto&&...) { hasData2b = true; }, |
Junxiao Shi | 352fc82 | 2016-08-09 03:53:05 +0000 | [diff] [blame] | 338 | nullptr, nullptr); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 339 | producerA->recover(); |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 340 | this->advanceClocks(5_ms, 1_s); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 341 | BOOST_CHECK_EQUAL(hasData2b, false); |
| 342 | |
| 343 | // Interest 2 retransmission gets through, and is answered |
| 344 | shared_ptr<Interest> interest2c = makeInterest("ndn:/laptops/A/2"); |
| 345 | bool hasData2c = false; |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 346 | consumer->getClientFace().expressInterest(*interest2c, |
Davide Pesavento | 412c982 | 2021-07-02 00:21:05 -0400 | [diff] [blame] | 347 | [&] (auto&&...) { hasData2c = true; }, |
Junxiao Shi | 352fc82 | 2016-08-09 03:53:05 +0000 | [diff] [blame] | 348 | nullptr, nullptr); |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 349 | this->advanceClocks(5_ms, 1_s); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 350 | BOOST_CHECK_EQUAL(hasData2c, true); |
| 351 | } |
| 352 | |
Junxiao Shi | 91f6ee0 | 2016-12-29 21:44:44 +0000 | [diff] [blame] | 353 | BOOST_AUTO_TEST_CASE(Bug2831) |
Junxiao Shi | 965d3a4 | 2015-06-01 06:55:23 -0700 | [diff] [blame] | 354 | { |
| 355 | // make a two-node loop |
| 356 | topo.registerPrefix(laptopA, linkA->getFace(laptopA), "ndn:/net"); |
| 357 | topo.registerPrefix(router, linkA->getFace(router), "ndn:/net"); |
| 358 | |
| 359 | // send Interests from laptopA to router |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 360 | shared_ptr<TopologyAppLink> consumer = topo.addAppFace("c", laptopA); |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 361 | topo.addIntervalConsumer(consumer->getClientFace(), "ndn:/net", 100_ms, 10); |
Junxiao Shi | 965d3a4 | 2015-06-01 06:55:23 -0700 | [diff] [blame] | 362 | |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 363 | this->advanceClocks(5_ms, 2_s); |
Junxiao Shi | 965d3a4 | 2015-06-01 06:55:23 -0700 | [diff] [blame] | 364 | |
| 365 | // Interest shouldn't loop back from router |
Junxiao Shi | da93f1f | 2015-11-11 06:13:16 -0700 | [diff] [blame] | 366 | BOOST_CHECK_EQUAL(linkA->getFace(router).getCounters().nOutInterests, 0); |
Junxiao Shi | 965d3a4 | 2015-06-01 06:55:23 -0700 | [diff] [blame] | 367 | } |
| 368 | |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 369 | BOOST_AUTO_TEST_SUITE_END() // TestAccessStrategy |
| 370 | BOOST_AUTO_TEST_SUITE_END() // Fw |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 371 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 372 | } // namespace nfd::tests |