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