Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [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 | /* |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 3 | * Copyright (c) 2014-2020, Regents of the University of California, |
Alexander Afanasyev | 319f2c8 | 2015-01-07 14:56:53 -0800 | [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. |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 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/>. |
Junxiao Shi | 82e7f58 | 2014-09-07 15:15:40 -0700 | [diff] [blame] | 24 | */ |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 25 | |
| 26 | #include "fw/forwarder.hpp" |
Davide Pesavento | 2cae8ca | 2019-04-18 20:48:05 -0400 | [diff] [blame] | 27 | #include "common/global.hpp" |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 28 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 29 | #include "tests/test-common.hpp" |
Davide Pesavento | cf7db2f | 2019-03-24 23:17:28 -0400 | [diff] [blame] | 30 | #include "tests/daemon/global-io-fixture.hpp" |
Junxiao Shi | 06a1eab | 2017-09-04 13:13:02 +0000 | [diff] [blame] | 31 | #include "tests/daemon/face/dummy-face.hpp" |
| 32 | #include "choose-strategy.hpp" |
| 33 | #include "dummy-strategy.hpp" |
| 34 | |
| 35 | #include <ndn-cxx/lp/tags.hpp> |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 36 | |
| 37 | namespace nfd { |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 38 | namespace tests { |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 39 | |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 40 | class ForwarderFixture : public GlobalIoTimeFixture |
| 41 | { |
| 42 | protected: |
| 43 | template<typename ...Args> |
| 44 | shared_ptr<DummyFace> |
| 45 | addFace(Args&&... args) |
| 46 | { |
| 47 | auto face = make_shared<DummyFace>(std::forward<Args>(args)...); |
| 48 | faceTable.add(face); |
| 49 | return face; |
| 50 | } |
| 51 | |
| 52 | protected: |
| 53 | FaceTable faceTable; |
| 54 | Forwarder forwarder{faceTable}; |
| 55 | }; |
| 56 | |
Junxiao Shi | 0355e9f | 2015-09-02 07:24:53 -0700 | [diff] [blame] | 57 | BOOST_AUTO_TEST_SUITE(Fw) |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 58 | BOOST_FIXTURE_TEST_SUITE(TestForwarder, ForwarderFixture) |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 59 | |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 60 | BOOST_AUTO_TEST_CASE(SimpleExchange) |
| 61 | { |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 62 | auto face1 = addFace(); |
| 63 | auto face2 = addFace(); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 64 | |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 65 | Fib& fib = forwarder.getFib(); |
Ju Pan | d8315bf | 2019-07-31 06:59:07 +0000 | [diff] [blame] | 66 | fib::Entry* entry = fib.insert("/A").first; |
| 67 | fib.addOrUpdateNextHop(*entry, *face2, 0); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 68 | |
Junxiao Shi | da93f1f | 2015-11-11 06:13:16 -0700 | [diff] [blame] | 69 | BOOST_CHECK_EQUAL(forwarder.getCounters().nInInterests, 0); |
| 70 | BOOST_CHECK_EQUAL(forwarder.getCounters().nOutInterests, 0); |
Junxiao Shi | 06a1eab | 2017-09-04 13:13:02 +0000 | [diff] [blame] | 71 | BOOST_CHECK_EQUAL(forwarder.getCounters().nCsHits, 0); |
| 72 | BOOST_CHECK_EQUAL(forwarder.getCounters().nCsMisses, 0); |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 73 | face1->receiveInterest(*makeInterest("/A/B"), 0); |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 74 | this->advanceClocks(100_ms, 1_s); |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 75 | BOOST_REQUIRE_EQUAL(face2->sentInterests.size(), 1); |
Junxiao Shi | a6de429 | 2016-07-12 02:08:10 +0000 | [diff] [blame] | 76 | BOOST_CHECK_EQUAL(face2->sentInterests[0].getName(), "/A/B"); |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 77 | BOOST_REQUIRE(face2->sentInterests[0].getTag<lp::IncomingFaceIdTag>() != nullptr); |
| 78 | BOOST_CHECK_EQUAL(*face2->sentInterests[0].getTag<lp::IncomingFaceIdTag>(), face1->getId()); |
Junxiao Shi | da93f1f | 2015-11-11 06:13:16 -0700 | [diff] [blame] | 79 | BOOST_CHECK_EQUAL(forwarder.getCounters().nInInterests, 1); |
| 80 | BOOST_CHECK_EQUAL(forwarder.getCounters().nOutInterests, 1); |
Junxiao Shi | 06a1eab | 2017-09-04 13:13:02 +0000 | [diff] [blame] | 81 | BOOST_CHECK_EQUAL(forwarder.getCounters().nCsHits, 0); |
| 82 | BOOST_CHECK_EQUAL(forwarder.getCounters().nCsMisses, 1); |
Alex Lane | 6bead9b | 2020-05-12 19:08:20 -0500 | [diff] [blame^] | 83 | BOOST_CHECK_EQUAL(forwarder.getCounters().nSatisfiedInterests, 0); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 84 | |
Junxiao Shi | da93f1f | 2015-11-11 06:13:16 -0700 | [diff] [blame] | 85 | BOOST_CHECK_EQUAL(forwarder.getCounters().nInData, 0); |
| 86 | BOOST_CHECK_EQUAL(forwarder.getCounters().nOutData, 0); |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 87 | face2->receiveData(*makeData("/A/B"), 0); |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 88 | this->advanceClocks(100_ms, 1_s); |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 89 | BOOST_REQUIRE_EQUAL(face1->sentData.size(), 1); |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 90 | BOOST_CHECK_EQUAL(face1->sentData[0].getName(), "/A/B"); |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 91 | BOOST_REQUIRE(face1->sentData[0].getTag<lp::IncomingFaceIdTag>() != nullptr); |
| 92 | BOOST_CHECK_EQUAL(*face1->sentData[0].getTag<lp::IncomingFaceIdTag>(), face2->getId()); |
Junxiao Shi | da93f1f | 2015-11-11 06:13:16 -0700 | [diff] [blame] | 93 | BOOST_CHECK_EQUAL(forwarder.getCounters().nInData, 1); |
| 94 | BOOST_CHECK_EQUAL(forwarder.getCounters().nOutData, 1); |
Alex Lane | 6bead9b | 2020-05-12 19:08:20 -0500 | [diff] [blame^] | 95 | BOOST_CHECK_EQUAL(forwarder.getCounters().nInNacks, 0); |
| 96 | BOOST_CHECK_EQUAL(forwarder.getCounters().nOutNacks, 0); |
| 97 | BOOST_CHECK_EQUAL(forwarder.getCounters().nSatisfiedInterests, 1); |
| 98 | BOOST_CHECK_EQUAL(forwarder.getCounters().nUnsolicitedData, 0); |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 99 | } |
| 100 | |
Junxiao Shi | ad3f1cb | 2014-08-18 11:12:30 -0700 | [diff] [blame] | 101 | BOOST_AUTO_TEST_CASE(CsMatched) |
| 102 | { |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 103 | auto face1 = addFace(); |
| 104 | auto face2 = addFace(); |
| 105 | auto face3 = addFace(); |
Junxiao Shi | ad3f1cb | 2014-08-18 11:12:30 -0700 | [diff] [blame] | 106 | |
Junxiao Shi | ad3f1cb | 2014-08-18 11:12:30 -0700 | [diff] [blame] | 107 | Fib& fib = forwarder.getFib(); |
Ju Pan | d8315bf | 2019-07-31 06:59:07 +0000 | [diff] [blame] | 108 | fib::Entry* entry = fib.insert("/A").first; |
| 109 | fib.addOrUpdateNextHop(*entry, *face2, 0); |
Junxiao Shi | ad3f1cb | 2014-08-18 11:12:30 -0700 | [diff] [blame] | 110 | |
| 111 | Pit& pit = forwarder.getPit(); |
| 112 | BOOST_CHECK_EQUAL(pit.size(), 0); |
| 113 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 114 | auto data = makeData("/A/B"); |
| 115 | data->setTag(make_shared<lp::IncomingFaceIdTag>(face3->getId())); |
| 116 | forwarder.getCs().insert(*data); |
Junxiao Shi | ad3f1cb | 2014-08-18 11:12:30 -0700 | [diff] [blame] | 117 | |
Junxiao Shi | 06a1eab | 2017-09-04 13:13:02 +0000 | [diff] [blame] | 118 | BOOST_CHECK_EQUAL(forwarder.getCounters().nCsHits, 0); |
| 119 | BOOST_CHECK_EQUAL(forwarder.getCounters().nCsMisses, 0); |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 120 | face1->receiveInterest(*makeInterest("/A", true), 0); |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 121 | this->advanceClocks(1_ms, 5_ms); |
Junxiao Shi | ad3f1cb | 2014-08-18 11:12:30 -0700 | [diff] [blame] | 122 | // Interest matching ContentStore should not be forwarded |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 123 | BOOST_REQUIRE_EQUAL(face2->sentInterests.size(), 0); |
Junxiao Shi | 06a1eab | 2017-09-04 13:13:02 +0000 | [diff] [blame] | 124 | BOOST_CHECK_EQUAL(forwarder.getCounters().nCsHits, 1); |
| 125 | BOOST_CHECK_EQUAL(forwarder.getCounters().nCsMisses, 0); |
Junxiao Shi | ad3f1cb | 2014-08-18 11:12:30 -0700 | [diff] [blame] | 126 | |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 127 | BOOST_REQUIRE_EQUAL(face1->sentData.size(), 1); |
Junxiao Shi | ad3f1cb | 2014-08-18 11:12:30 -0700 | [diff] [blame] | 128 | // IncomingFaceId field should be reset to represent CS |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 129 | BOOST_CHECK_EQUAL(face1->sentData[0].getName(), "/A/B"); |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 130 | BOOST_REQUIRE(face1->sentData[0].getTag<lp::IncomingFaceIdTag>() != nullptr); |
| 131 | BOOST_CHECK_EQUAL(*face1->sentData[0].getTag<lp::IncomingFaceIdTag>(), face::FACEID_CONTENT_STORE); |
Junxiao Shi | ad3f1cb | 2014-08-18 11:12:30 -0700 | [diff] [blame] | 132 | |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 133 | this->advanceClocks(100_ms, 500_ms); |
Junxiao Shi | ad3f1cb | 2014-08-18 11:12:30 -0700 | [diff] [blame] | 134 | // PIT entry should not be left behind |
| 135 | BOOST_CHECK_EQUAL(pit.size(), 0); |
| 136 | } |
| 137 | |
Junxiao Shi | 891f47b | 2016-06-20 00:02:11 +0000 | [diff] [blame] | 138 | BOOST_AUTO_TEST_CASE(OutgoingInterest) |
| 139 | { |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 140 | auto face1 = addFace(); |
| 141 | auto face2 = addFace(); |
Junxiao Shi | 891f47b | 2016-06-20 00:02:11 +0000 | [diff] [blame] | 142 | |
| 143 | Pit& pit = forwarder.getPit(); |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 144 | auto interestA1 = makeInterest("/A", false, nullopt, 8378); |
Junxiao Shi | 891f47b | 2016-06-20 00:02:11 +0000 | [diff] [blame] | 145 | shared_ptr<pit::Entry> pitA = pit.insert(*interestA1).first; |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 146 | pitA->insertOrUpdateInRecord(*face1, *interestA1); |
Junxiao Shi | 891f47b | 2016-06-20 00:02:11 +0000 | [diff] [blame] | 147 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 148 | auto interestA2 = makeInterest("/A", false, nullopt, 1698); |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 149 | forwarder.onOutgoingInterest(pitA, FaceEndpoint(*face2, 0), *interestA2); |
Junxiao Shi | 891f47b | 2016-06-20 00:02:11 +0000 | [diff] [blame] | 150 | |
Alex Lane | 6bead9b | 2020-05-12 19:08:20 -0500 | [diff] [blame^] | 151 | auto outA2 = pitA->getOutRecord(*face2); |
Junxiao Shi | c5f651f | 2016-11-17 22:58:12 +0000 | [diff] [blame] | 152 | BOOST_REQUIRE(outA2 != pitA->out_end()); |
| 153 | BOOST_CHECK_EQUAL(outA2->getLastNonce(), 1698); |
Junxiao Shi | 891f47b | 2016-06-20 00:02:11 +0000 | [diff] [blame] | 154 | |
Junxiao Shi | 891f47b | 2016-06-20 00:02:11 +0000 | [diff] [blame] | 155 | BOOST_REQUIRE_EQUAL(face2->sentInterests.size(), 1); |
Junxiao Shi | c5f651f | 2016-11-17 22:58:12 +0000 | [diff] [blame] | 156 | BOOST_CHECK_EQUAL(face2->sentInterests.back().getNonce(), 1698); |
Junxiao Shi | 891f47b | 2016-06-20 00:02:11 +0000 | [diff] [blame] | 157 | } |
| 158 | |
Junxiao Shi | e342e8d | 2016-09-18 16:48:00 +0000 | [diff] [blame] | 159 | BOOST_AUTO_TEST_CASE(NextHopFaceId) |
| 160 | { |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 161 | auto face1 = addFace(); |
| 162 | auto face2 = addFace(); |
| 163 | auto face3 = addFace(); |
Junxiao Shi | e342e8d | 2016-09-18 16:48:00 +0000 | [diff] [blame] | 164 | |
| 165 | Fib& fib = forwarder.getFib(); |
Ju Pan | d8315bf | 2019-07-31 06:59:07 +0000 | [diff] [blame] | 166 | fib::Entry* entry = fib.insert("/A").first; |
| 167 | fib.addOrUpdateNextHop(*entry, *face3, 0); |
Junxiao Shi | e342e8d | 2016-09-18 16:48:00 +0000 | [diff] [blame] | 168 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 169 | auto interest = makeInterest("/A/B"); |
Junxiao Shi | e342e8d | 2016-09-18 16:48:00 +0000 | [diff] [blame] | 170 | interest->setTag(make_shared<lp::NextHopFaceIdTag>(face2->getId())); |
| 171 | |
ashiqopu | 075bb7d | 2019-03-10 01:38:21 +0000 | [diff] [blame] | 172 | face1->receiveInterest(*interest, 0); |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 173 | this->advanceClocks(100_ms, 1_s); |
Junxiao Shi | e342e8d | 2016-09-18 16:48:00 +0000 | [diff] [blame] | 174 | BOOST_CHECK_EQUAL(face3->sentInterests.size(), 0); |
| 175 | BOOST_REQUIRE_EQUAL(face2->sentInterests.size(), 1); |
| 176 | BOOST_CHECK_EQUAL(face2->sentInterests.front().getName(), "/A/B"); |
| 177 | } |
| 178 | |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 179 | BOOST_AUTO_TEST_CASE(HopLimit) |
| 180 | { |
| 181 | auto faceIn = addFace(); |
| 182 | auto faceRemote = addFace("dummy://", "dummy://", ndn::nfd::FACE_SCOPE_NON_LOCAL); |
| 183 | auto faceLocal = addFace("dummy://", "dummy://", ndn::nfd::FACE_SCOPE_LOCAL); |
| 184 | Fib& fib = forwarder.getFib(); |
| 185 | fib::Entry* entryRemote = fib.insert("/remote").first; |
| 186 | fib.addOrUpdateNextHop(*entryRemote, *faceRemote, 0); |
| 187 | fib::Entry* entryLocal = fib.insert("/local").first; |
| 188 | fib.addOrUpdateNextHop(*entryLocal, *faceLocal, 0); |
| 189 | |
| 190 | // Incoming interest w/o HopLimit will not be dropped on send or receive paths |
| 191 | auto interestNoHopLimit = makeInterest("/remote/abcdefgh"); |
| 192 | faceIn->receiveInterest(*interestNoHopLimit, 0); |
| 193 | this->advanceClocks(100_ms, 1_s); |
| 194 | BOOST_CHECK_EQUAL(faceRemote->sentInterests.size(), 1); |
| 195 | BOOST_CHECK_EQUAL(faceRemote->getCounters().nInHopLimitZero, 0); |
| 196 | BOOST_CHECK_EQUAL(faceRemote->getCounters().nOutHopLimitZero, 0); |
| 197 | BOOST_REQUIRE_EQUAL(faceRemote->sentInterests.size(), 1); |
| 198 | BOOST_CHECK(!faceRemote->sentInterests.back().getHopLimit()); |
| 199 | |
| 200 | // Incoming interest w/ HopLimit > 1 will not be dropped on send/receive |
| 201 | auto interestHopLimit2 = makeInterest("/remote/ijklmnop"); |
| 202 | interestHopLimit2->setHopLimit(2); |
| 203 | faceIn->receiveInterest(*interestHopLimit2, 0); |
| 204 | this->advanceClocks(100_ms, 1_s); |
| 205 | BOOST_CHECK_EQUAL(faceRemote->getCounters().nOutInterests, 2); |
| 206 | BOOST_CHECK_EQUAL(faceRemote->getCounters().nInHopLimitZero, 0); |
| 207 | BOOST_CHECK_EQUAL(faceRemote->getCounters().nOutHopLimitZero, 0); |
| 208 | BOOST_REQUIRE_EQUAL(faceRemote->sentInterests.size(), 2); |
| 209 | BOOST_REQUIRE(faceRemote->sentInterests.back().getHopLimit()); |
| 210 | BOOST_CHECK_EQUAL(*faceRemote->sentInterests.back().getHopLimit(), 1); |
| 211 | |
| 212 | // Incoming interest w/ HopLimit == 1 will be dropped on send path if going out on remote face |
| 213 | auto interestHopLimit1Remote = makeInterest("/remote/qrstuvwx"); |
| 214 | interestHopLimit1Remote->setHopLimit(1); |
| 215 | faceIn->receiveInterest(*interestHopLimit1Remote, 0); |
| 216 | this->advanceClocks(100_ms, 1_s); |
| 217 | BOOST_CHECK_EQUAL(faceRemote->getCounters().nOutInterests, 2); |
| 218 | BOOST_CHECK_EQUAL(faceRemote->getCounters().nInHopLimitZero, 0); |
| 219 | BOOST_CHECK_EQUAL(faceRemote->getCounters().nOutHopLimitZero, 1); |
| 220 | BOOST_CHECK_EQUAL(faceRemote->sentInterests.size(), 2); |
| 221 | |
| 222 | // Incoming interest w/ HopLimit == 1 will not be dropped on send path if going out on local face |
| 223 | auto interestHopLimit1Local = makeInterest("/local/abcdefgh"); |
| 224 | interestHopLimit1Local->setHopLimit(1); |
| 225 | faceIn->receiveInterest(*interestHopLimit1Local, 0); |
| 226 | this->advanceClocks(100_ms, 1_s); |
| 227 | BOOST_CHECK_EQUAL(faceLocal->getCounters().nOutInterests, 1); |
| 228 | BOOST_CHECK_EQUAL(faceLocal->getCounters().nInHopLimitZero, 0); |
| 229 | BOOST_CHECK_EQUAL(faceLocal->getCounters().nOutHopLimitZero, 0); |
| 230 | BOOST_REQUIRE_EQUAL(faceLocal->sentInterests.size(), 1); |
| 231 | BOOST_REQUIRE(faceLocal->sentInterests.back().getHopLimit()); |
| 232 | BOOST_CHECK_EQUAL(*faceLocal->sentInterests.back().getHopLimit(), 0); |
| 233 | |
| 234 | // Interest w/ HopLimit == 0 will be dropped on receive path |
| 235 | auto interestHopLimit0 = makeInterest("/remote/yzabcdef"); |
| 236 | interestHopLimit0->setHopLimit(0); |
| 237 | faceIn->receiveInterest(*interestHopLimit0, 0); |
| 238 | this->advanceClocks(100_ms, 1_s); |
| 239 | BOOST_CHECK_EQUAL(faceRemote->getCounters().nOutInterests, 2); |
| 240 | BOOST_CHECK_EQUAL(faceIn->getCounters().nInHopLimitZero, 1); |
| 241 | BOOST_CHECK_EQUAL(faceRemote->getCounters().nOutHopLimitZero, 1); |
| 242 | BOOST_CHECK_EQUAL(faceRemote->sentInterests.size(), 2); |
| 243 | } |
| 244 | |
Junxiao Shi | 9b27bd2 | 2014-02-26 20:29:58 -0700 | [diff] [blame] | 245 | class ScopeLocalhostIncomingTestForwarder : public Forwarder |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 246 | { |
| 247 | public: |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 248 | using Forwarder::Forwarder; |
| 249 | |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 250 | protected: |
Junxiao Shi | 2fe3af0 | 2017-03-04 17:24:19 +0000 | [diff] [blame] | 251 | void |
Davide Pesavento | b31206e | 2019-04-20 22:34:12 -0400 | [diff] [blame] | 252 | dispatchToStrategy(pit::Entry&, std::function<void(fw::Strategy&)>) final |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 253 | { |
Junxiao Shi | 0355e9f | 2015-09-02 07:24:53 -0700 | [diff] [blame] | 254 | ++dispatchToStrategy_count; |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | public: |
Davide Pesavento | b31206e | 2019-04-20 22:34:12 -0400 | [diff] [blame] | 258 | int dispatchToStrategy_count = 0; |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 259 | }; |
| 260 | |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 261 | BOOST_FIXTURE_TEST_CASE(ScopeLocalhostIncoming, GlobalIoTimeFixture) |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 262 | { |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 263 | FaceTable faceTable; |
| 264 | ScopeLocalhostIncomingTestForwarder forwarder(faceTable); |
| 265 | |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 266 | auto face1 = make_shared<DummyFace>("dummy://", "dummy://", ndn::nfd::FACE_SCOPE_LOCAL); |
| 267 | auto face2 = make_shared<DummyFace>(); |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 268 | faceTable.add(face1); |
| 269 | faceTable.add(face2); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 270 | |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 271 | // local face, /localhost: OK |
Junxiao Shi | 0355e9f | 2015-09-02 07:24:53 -0700 | [diff] [blame] | 272 | forwarder.dispatchToStrategy_count = 0; |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 273 | auto i1 = makeInterest("/localhost/A1"); |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 274 | forwarder.onIncomingInterest(FaceEndpoint(*face1, 0), *i1); |
Junxiao Shi | 0355e9f | 2015-09-02 07:24:53 -0700 | [diff] [blame] | 275 | BOOST_CHECK_EQUAL(forwarder.dispatchToStrategy_count, 1); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 276 | |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 277 | // non-local face, /localhost: violate |
Junxiao Shi | 0355e9f | 2015-09-02 07:24:53 -0700 | [diff] [blame] | 278 | forwarder.dispatchToStrategy_count = 0; |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 279 | auto i2 = makeInterest("/localhost/A2"); |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 280 | forwarder.onIncomingInterest(FaceEndpoint(*face2, 0), *i2); |
Junxiao Shi | 0355e9f | 2015-09-02 07:24:53 -0700 | [diff] [blame] | 281 | BOOST_CHECK_EQUAL(forwarder.dispatchToStrategy_count, 0); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 282 | |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 283 | // local face, non-/localhost: OK |
Junxiao Shi | 0355e9f | 2015-09-02 07:24:53 -0700 | [diff] [blame] | 284 | forwarder.dispatchToStrategy_count = 0; |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 285 | auto i3 = makeInterest("/A3"); |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 286 | forwarder.onIncomingInterest(FaceEndpoint(*face1, 0), *i3); |
Junxiao Shi | 0355e9f | 2015-09-02 07:24:53 -0700 | [diff] [blame] | 287 | BOOST_CHECK_EQUAL(forwarder.dispatchToStrategy_count, 1); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 288 | |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 289 | // non-local face, non-/localhost: OK |
Junxiao Shi | 0355e9f | 2015-09-02 07:24:53 -0700 | [diff] [blame] | 290 | forwarder.dispatchToStrategy_count = 0; |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 291 | auto i4 = makeInterest("/A4"); |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 292 | forwarder.onIncomingInterest(FaceEndpoint(*face2, 0), *i4); |
Junxiao Shi | 0355e9f | 2015-09-02 07:24:53 -0700 | [diff] [blame] | 293 | BOOST_CHECK_EQUAL(forwarder.dispatchToStrategy_count, 1); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 294 | |
Alex Lane | 6bead9b | 2020-05-12 19:08:20 -0500 | [diff] [blame^] | 295 | BOOST_CHECK_EQUAL(forwarder.getCounters().nUnsolicitedData, 0); |
| 296 | |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 297 | // local face, /localhost: OK |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 298 | auto d1 = makeData("/localhost/B1"); |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 299 | forwarder.onIncomingData(FaceEndpoint(*face1, 0), *d1); |
Alex Lane | 6bead9b | 2020-05-12 19:08:20 -0500 | [diff] [blame^] | 300 | BOOST_CHECK_EQUAL(forwarder.getCounters().nUnsolicitedData, 1); |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 301 | |
| 302 | // non-local face, /localhost: OK |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 303 | auto d2 = makeData("/localhost/B2"); |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 304 | forwarder.onIncomingData(FaceEndpoint(*face2, 0), *d2); |
Alex Lane | 6bead9b | 2020-05-12 19:08:20 -0500 | [diff] [blame^] | 305 | BOOST_CHECK_EQUAL(forwarder.getCounters().nUnsolicitedData, 1); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 306 | |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 307 | // local face, non-/localhost: OK |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 308 | auto d3 = makeData("/B3"); |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 309 | forwarder.onIncomingData(FaceEndpoint(*face1, 0), *d3); |
Alex Lane | 6bead9b | 2020-05-12 19:08:20 -0500 | [diff] [blame^] | 310 | BOOST_CHECK_EQUAL(forwarder.getCounters().nUnsolicitedData, 2); |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 311 | |
| 312 | // non-local face, non-/localhost: OK |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 313 | auto d4 = makeData("/B4"); |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 314 | forwarder.onIncomingData(FaceEndpoint(*face2, 0), *d4); |
Alex Lane | 6bead9b | 2020-05-12 19:08:20 -0500 | [diff] [blame^] | 315 | BOOST_CHECK_EQUAL(forwarder.getCounters().nUnsolicitedData, 3); |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 316 | } |
| 317 | |
Junxiao Shi | 0355e9f | 2015-09-02 07:24:53 -0700 | [diff] [blame] | 318 | BOOST_AUTO_TEST_CASE(IncomingInterestStrategyDispatch) |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 319 | { |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 320 | auto face1 = addFace(); |
| 321 | auto face2 = addFace(); |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 322 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 323 | DummyStrategy& strategyA = choose<DummyStrategy>(forwarder, "/", DummyStrategy::getStrategyName()); |
| 324 | DummyStrategy& strategyB = choose<DummyStrategy>(forwarder, "/B", DummyStrategy::getStrategyName()); |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 325 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 326 | auto interest1 = makeInterest("/A/1"); |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 327 | strategyA.afterReceiveInterest_count = 0; |
| 328 | strategyA.interestOutFace = face2; |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 329 | forwarder.startProcessInterest(FaceEndpoint(*face1, 0), *interest1); |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 330 | BOOST_CHECK_EQUAL(strategyA.afterReceiveInterest_count, 1); |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 331 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 332 | auto interest2 = makeInterest("/B/2", true); |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 333 | strategyB.afterReceiveInterest_count = 0; |
| 334 | strategyB.interestOutFace = face2; |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 335 | forwarder.startProcessInterest(FaceEndpoint(*face1, 0), *interest2); |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 336 | BOOST_CHECK_EQUAL(strategyB.afterReceiveInterest_count, 1); |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 337 | |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 338 | this->advanceClocks(1_ms, 5_ms); |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 339 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 340 | auto data1 = makeData("/A/1"); |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 341 | strategyA.beforeSatisfyInterest_count = 0; |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 342 | forwarder.startProcessData(FaceEndpoint(*face2, 0), *data1); |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 343 | BOOST_CHECK_EQUAL(strategyA.beforeSatisfyInterest_count, 1); |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 344 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 345 | auto data2 = makeData("/B/2/b"); |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 346 | strategyB.beforeSatisfyInterest_count = 0; |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 347 | forwarder.startProcessData(FaceEndpoint(*face2, 0), *data2); |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 348 | BOOST_CHECK_EQUAL(strategyB.beforeSatisfyInterest_count, 1); |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 349 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 350 | auto interest3 = makeInterest("/A/3", false, 30_ms); |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 351 | forwarder.startProcessInterest(FaceEndpoint(*face1, 0), *interest3); |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 352 | auto interest4 = makeInterest("/B/4", false, 5_s); |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 353 | forwarder.startProcessInterest(FaceEndpoint(*face1, 0), *interest4); |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 354 | } |
| 355 | |
Junxiao Shi | da006f5 | 2014-05-16 11:18:00 -0700 | [diff] [blame] | 356 | BOOST_AUTO_TEST_CASE(IncomingData) |
| 357 | { |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 358 | auto face1 = addFace(); |
| 359 | auto face2 = addFace(); |
| 360 | auto face3 = addFace(); |
| 361 | auto face4 = addFace(); |
Junxiao Shi | da006f5 | 2014-05-16 11:18:00 -0700 | [diff] [blame] | 362 | |
| 363 | Pit& pit = forwarder.getPit(); |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 364 | auto interestD = makeInterest("/A/B/C/D"); |
| 365 | shared_ptr<pit::Entry> pitD = pit.insert(*interestD).first; |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 366 | pitD->insertOrUpdateInRecord(*face1, *interestD); |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 367 | auto interestA = makeInterest("/A", true); |
Junxiao Shi | da006f5 | 2014-05-16 11:18:00 -0700 | [diff] [blame] | 368 | shared_ptr<pit::Entry> pitA = pit.insert(*interestA).first; |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 369 | pitA->insertOrUpdateInRecord(*face2, *interestA); |
| 370 | pitA->insertOrUpdateInRecord(*face3, *interestA); |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 371 | auto interestC = makeInterest("/A/B/C", true); |
Junxiao Shi | da006f5 | 2014-05-16 11:18:00 -0700 | [diff] [blame] | 372 | shared_ptr<pit::Entry> pitC = pit.insert(*interestC).first; |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 373 | pitC->insertOrUpdateInRecord(*face3, *interestC); |
| 374 | pitC->insertOrUpdateInRecord(*face4, *interestC); |
Junxiao Shi | da006f5 | 2014-05-16 11:18:00 -0700 | [diff] [blame] | 375 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 376 | auto dataD = makeData("/A/B/C/D"); |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 377 | forwarder.onIncomingData(FaceEndpoint(*face3, 0), *dataD); |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 378 | this->advanceClocks(1_ms, 5_ms); |
Junxiao Shi | da006f5 | 2014-05-16 11:18:00 -0700 | [diff] [blame] | 379 | |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 380 | BOOST_CHECK_EQUAL(face1->sentData.size(), 1); |
| 381 | BOOST_CHECK_EQUAL(face2->sentData.size(), 1); |
| 382 | BOOST_CHECK_EQUAL(face3->sentData.size(), 0); |
| 383 | BOOST_CHECK_EQUAL(face4->sentData.size(), 1); |
Alex Lane | 6bead9b | 2020-05-12 19:08:20 -0500 | [diff] [blame^] | 384 | |
| 385 | BOOST_CHECK_EQUAL(forwarder.getCounters().nInData, 1); |
| 386 | BOOST_CHECK_EQUAL(forwarder.getCounters().nOutData, 3); |
| 387 | BOOST_CHECK_EQUAL(forwarder.getCounters().nUnsolicitedData, 0); |
Junxiao Shi | da006f5 | 2014-05-16 11:18:00 -0700 | [diff] [blame] | 388 | } |
| 389 | |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 390 | BOOST_AUTO_TEST_CASE(IncomingNack) |
| 391 | { |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 392 | auto face1 = addFace(); |
| 393 | auto face2 = addFace(); |
| 394 | auto face3 = addFace("dummy://", "dummy://", |
| 395 | ndn::nfd::FACE_SCOPE_NON_LOCAL, |
| 396 | ndn::nfd::FACE_PERSISTENCY_PERSISTENT, |
| 397 | ndn::nfd::LINK_TYPE_MULTI_ACCESS); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 398 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 399 | DummyStrategy& strategyA = choose<DummyStrategy>(forwarder, "/", DummyStrategy::getStrategyName()); |
| 400 | DummyStrategy& strategyB = choose<DummyStrategy>(forwarder, "/B", DummyStrategy::getStrategyName()); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 401 | |
| 402 | Pit& pit = forwarder.getPit(); |
| 403 | |
| 404 | // dispatch to the correct strategy |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 405 | auto interest1 = makeInterest("/A/AYJqayrzF", false, nullopt, 562); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 406 | shared_ptr<pit::Entry> pit1 = pit.insert(*interest1).first; |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 407 | pit1->insertOrUpdateOutRecord(*face1, *interest1); |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 408 | auto interest2 = makeInterest("/B/EVyP73ru", false, nullopt, 221); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 409 | shared_ptr<pit::Entry> pit2 = pit.insert(*interest2).first; |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 410 | pit2->insertOrUpdateOutRecord(*face1, *interest2); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 411 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 412 | lp::Nack nack1 = makeNack(*interest1, lp::NackReason::CONGESTION); |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 413 | strategyA.afterReceiveNack_count = 0; |
| 414 | strategyB.afterReceiveNack_count = 0; |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 415 | forwarder.onIncomingNack(FaceEndpoint(*face1, 0), nack1); |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 416 | BOOST_CHECK_EQUAL(strategyA.afterReceiveNack_count, 1); |
| 417 | BOOST_CHECK_EQUAL(strategyB.afterReceiveNack_count, 0); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 418 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 419 | lp::Nack nack2 = makeNack(*interest2, lp::NackReason::CONGESTION); |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 420 | strategyA.afterReceiveNack_count = 0; |
| 421 | strategyB.afterReceiveNack_count = 0; |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 422 | forwarder.onIncomingNack(FaceEndpoint(*face1, 0), nack2); |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 423 | BOOST_CHECK_EQUAL(strategyA.afterReceiveNack_count, 0); |
| 424 | BOOST_CHECK_EQUAL(strategyB.afterReceiveNack_count, 1); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 425 | |
| 426 | // record Nack on PIT out-record |
Alex Lane | 6bead9b | 2020-05-12 19:08:20 -0500 | [diff] [blame^] | 427 | auto outRecord1 = pit1->getOutRecord(*face1); |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 428 | BOOST_REQUIRE(outRecord1 != pit1->out_end()); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 429 | BOOST_REQUIRE(outRecord1->getIncomingNack() != nullptr); |
| 430 | BOOST_CHECK_EQUAL(outRecord1->getIncomingNack()->getReason(), lp::NackReason::CONGESTION); |
| 431 | |
| 432 | // drop if no PIT entry |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 433 | lp::Nack nack3 = makeNack(*makeInterest("/yEcw5HhdM", false, nullopt, 243), lp::NackReason::CONGESTION); |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 434 | strategyA.afterReceiveNack_count = 0; |
| 435 | strategyB.afterReceiveNack_count = 0; |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 436 | forwarder.onIncomingNack(FaceEndpoint(*face1, 0), nack3); |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 437 | BOOST_CHECK_EQUAL(strategyA.afterReceiveNack_count, 0); |
| 438 | BOOST_CHECK_EQUAL(strategyB.afterReceiveNack_count, 0); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 439 | |
| 440 | // drop if no out-record |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 441 | auto interest4 = makeInterest("/Etab4KpY", false, nullopt, 157); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 442 | shared_ptr<pit::Entry> pit4 = pit.insert(*interest4).first; |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 443 | pit4->insertOrUpdateOutRecord(*face1, *interest4); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 444 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 445 | lp::Nack nack4a = makeNack(*interest4, lp::NackReason::CONGESTION); |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 446 | strategyA.afterReceiveNack_count = 0; |
| 447 | strategyB.afterReceiveNack_count = 0; |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 448 | forwarder.onIncomingNack(FaceEndpoint(*face2, 0), nack4a); |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 449 | BOOST_CHECK_EQUAL(strategyA.afterReceiveNack_count, 0); |
| 450 | BOOST_CHECK_EQUAL(strategyB.afterReceiveNack_count, 0); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 451 | |
| 452 | // drop if Nonce does not match out-record |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 453 | lp::Nack nack4b = makeNack(*makeInterest("/Etab4KpY", false, nullopt, 294), lp::NackReason::CONGESTION); |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 454 | strategyA.afterReceiveNack_count = 0; |
| 455 | strategyB.afterReceiveNack_count = 0; |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 456 | forwarder.onIncomingNack(FaceEndpoint(*face1, 0), nack4b); |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 457 | BOOST_CHECK_EQUAL(strategyA.afterReceiveNack_count, 0); |
| 458 | BOOST_CHECK_EQUAL(strategyB.afterReceiveNack_count, 0); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 459 | |
| 460 | // drop if inFace is multi-access |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 461 | pit4->insertOrUpdateOutRecord(*face3, *interest4); |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 462 | strategyA.afterReceiveNack_count = 0; |
| 463 | strategyB.afterReceiveNack_count = 0; |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 464 | forwarder.onIncomingNack(FaceEndpoint(*face3, 0), nack4a); |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 465 | BOOST_CHECK_EQUAL(strategyA.afterReceiveNack_count, 0); |
| 466 | BOOST_CHECK_EQUAL(strategyB.afterReceiveNack_count, 0); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 467 | } |
| 468 | |
| 469 | BOOST_AUTO_TEST_CASE(OutgoingNack) |
| 470 | { |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 471 | auto face1 = addFace(); |
| 472 | auto face2 = addFace(); |
| 473 | auto face3 = addFace("dummy://", "dummy://", |
| 474 | ndn::nfd::FACE_SCOPE_NON_LOCAL, |
| 475 | ndn::nfd::FACE_PERSISTENCY_PERSISTENT, |
| 476 | ndn::nfd::LINK_TYPE_MULTI_ACCESS); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 477 | |
| 478 | Pit& pit = forwarder.getPit(); |
| 479 | |
| 480 | lp::NackHeader nackHeader; |
| 481 | nackHeader.setReason(lp::NackReason::CONGESTION); |
| 482 | |
| 483 | // don't send Nack if there's no in-record |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 484 | auto interest1 = makeInterest("/fM5IVEtC", false, nullopt, 719); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 485 | shared_ptr<pit::Entry> pit1 = pit.insert(*interest1).first; |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 486 | pit1->insertOrUpdateInRecord(*face1, *interest1); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 487 | |
| 488 | face2->sentNacks.clear(); |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 489 | forwarder.onOutgoingNack(pit1, FaceEndpoint(*face2, 0), nackHeader); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 490 | BOOST_CHECK_EQUAL(face2->sentNacks.size(), 0); |
| 491 | |
| 492 | // send Nack with correct Nonce |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 493 | auto interest2a = makeInterest("/Vi8tRm9MG3", false, nullopt, 152); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 494 | shared_ptr<pit::Entry> pit2 = pit.insert(*interest2a).first; |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 495 | pit2->insertOrUpdateInRecord(*face1, *interest2a); |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 496 | auto interest2b = makeInterest("/Vi8tRm9MG3", false, nullopt, 808); |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 497 | pit2->insertOrUpdateInRecord(*face2, *interest2b); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 498 | |
| 499 | face1->sentNacks.clear(); |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 500 | forwarder.onOutgoingNack(pit2, FaceEndpoint(*face1, 0), nackHeader); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 501 | BOOST_REQUIRE_EQUAL(face1->sentNacks.size(), 1); |
| 502 | BOOST_CHECK_EQUAL(face1->sentNacks.back().getReason(), lp::NackReason::CONGESTION); |
| 503 | BOOST_CHECK_EQUAL(face1->sentNacks.back().getInterest().getNonce(), 152); |
| 504 | |
| 505 | // erase in-record |
Alex Lane | 6bead9b | 2020-05-12 19:08:20 -0500 | [diff] [blame^] | 506 | auto inRecord2a = pit2->getInRecord(*face1); |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 507 | BOOST_CHECK(inRecord2a == pit2->in_end()); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 508 | |
| 509 | // send Nack with correct Nonce |
| 510 | face2->sentNacks.clear(); |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 511 | forwarder.onOutgoingNack(pit2, FaceEndpoint(*face2, 0), nackHeader); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 512 | BOOST_REQUIRE_EQUAL(face2->sentNacks.size(), 1); |
| 513 | BOOST_CHECK_EQUAL(face2->sentNacks.back().getReason(), lp::NackReason::CONGESTION); |
| 514 | BOOST_CHECK_EQUAL(face2->sentNacks.back().getInterest().getNonce(), 808); |
| 515 | |
| 516 | // erase in-record |
Alex Lane | 6bead9b | 2020-05-12 19:08:20 -0500 | [diff] [blame^] | 517 | auto inRecord2b = pit2->getInRecord(*face1); |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 518 | BOOST_CHECK(inRecord2b == pit2->in_end()); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 519 | |
| 520 | // don't send Nack to multi-access face |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 521 | auto interest2c = makeInterest("/Vi8tRm9MG3", false, nullopt, 228); |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 522 | pit2->insertOrUpdateInRecord(*face3, *interest2c); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 523 | |
| 524 | face3->sentNacks.clear(); |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 525 | forwarder.onOutgoingNack(pit1, FaceEndpoint(*face3, 0), nackHeader); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 526 | BOOST_CHECK_EQUAL(face3->sentNacks.size(), 0); |
| 527 | } |
| 528 | |
| 529 | BOOST_AUTO_TEST_CASE(InterestLoopNack) |
| 530 | { |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 531 | auto face1 = addFace(); |
| 532 | auto face2 = addFace(); |
| 533 | auto face3 = addFace("dummy://", "dummy://", |
| 534 | ndn::nfd::FACE_SCOPE_NON_LOCAL, |
| 535 | ndn::nfd::FACE_PERSISTENCY_PERSISTENT, |
| 536 | ndn::nfd::LINK_TYPE_MULTI_ACCESS); |
| 537 | auto face4 = addFace(); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 538 | |
| 539 | Fib& fib = forwarder.getFib(); |
Ju Pan | d8315bf | 2019-07-31 06:59:07 +0000 | [diff] [blame] | 540 | fib::Entry* entry = fib.insert("/zT4XwK0Hnx").first; |
| 541 | fib.addOrUpdateNextHop(*entry, *face4, 0); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 542 | |
| 543 | // receive Interest on face1 |
| 544 | face1->sentNacks.clear(); |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 545 | auto interest1a = makeInterest("/zT4XwK0Hnx/28JBUvbEzc", false, nullopt, 732); |
ashiqopu | 075bb7d | 2019-03-10 01:38:21 +0000 | [diff] [blame] | 546 | face1->receiveInterest(*interest1a, 0); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 547 | BOOST_CHECK(face1->sentNacks.empty()); |
| 548 | |
Junxiao Shi | 2fe3af0 | 2017-03-04 17:24:19 +0000 | [diff] [blame] | 549 | // receive Interest with duplicate Nonce on face1: legit retransmission |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 550 | face1->sentNacks.clear(); |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 551 | auto interest1b = makeInterest("/zT4XwK0Hnx/28JBUvbEzc", false, nullopt, 732); |
ashiqopu | 075bb7d | 2019-03-10 01:38:21 +0000 | [diff] [blame] | 552 | face1->receiveInterest(*interest1b, 0); |
Junxiao Shi | 2fe3af0 | 2017-03-04 17:24:19 +0000 | [diff] [blame] | 553 | BOOST_CHECK(face1->sentNacks.empty()); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 554 | |
| 555 | // receive Interest with duplicate Nonce on face2 |
| 556 | face2->sentNacks.clear(); |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 557 | auto interest2a = makeInterest("/zT4XwK0Hnx/28JBUvbEzc", false, nullopt, 732); |
ashiqopu | 075bb7d | 2019-03-10 01:38:21 +0000 | [diff] [blame] | 558 | face2->receiveInterest(*interest2a, 0); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 559 | BOOST_REQUIRE_EQUAL(face2->sentNacks.size(), 1); |
Davide Pesavento | 7890a9f | 2019-08-25 23:11:18 -0400 | [diff] [blame] | 560 | BOOST_CHECK_EQUAL(face2->sentNacks.back().getInterest().wireEncode(), interest2a->wireEncode()); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 561 | BOOST_CHECK_EQUAL(face2->sentNacks.back().getReason(), lp::NackReason::DUPLICATE); |
| 562 | |
| 563 | // receive Interest with new Nonce on face2 |
| 564 | face2->sentNacks.clear(); |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 565 | auto interest2b = makeInterest("/zT4XwK0Hnx/28JBUvbEzc", false, nullopt, 944); |
ashiqopu | 075bb7d | 2019-03-10 01:38:21 +0000 | [diff] [blame] | 566 | face2->receiveInterest(*interest2b, 0); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 567 | BOOST_CHECK(face2->sentNacks.empty()); |
| 568 | |
| 569 | // receive Interest with duplicate Nonce on face3, don't send Nack to multi-access face |
| 570 | face3->sentNacks.clear(); |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 571 | auto interest3a = makeInterest("/zT4XwK0Hnx/28JBUvbEzc", false, nullopt, 732); |
ashiqopu | 075bb7d | 2019-03-10 01:38:21 +0000 | [diff] [blame] | 572 | face3->receiveInterest(*interest3a, 0); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 573 | BOOST_CHECK(face3->sentNacks.empty()); |
| 574 | } |
| 575 | |
Davide Pesavento | cf7db2f | 2019-03-24 23:17:28 -0400 | [diff] [blame] | 576 | BOOST_AUTO_TEST_CASE(InterestLoopWithShortLifetime) // Bug 1953 |
Junxiao Shi | a110f26 | 2014-10-12 12:35:20 -0700 | [diff] [blame] | 577 | { |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 578 | auto face1 = addFace(); |
| 579 | auto face2 = addFace(); |
Junxiao Shi | a110f26 | 2014-10-12 12:35:20 -0700 | [diff] [blame] | 580 | |
| 581 | // cause an Interest sent out of face2 to loop back into face1 after a delay |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 582 | face2->afterSend.connect([face1, face2] (uint32_t pktType) { |
| 583 | if (pktType == tlv::Interest) { |
| 584 | auto interest = make_shared<Interest>(face2->sentInterests.back()); |
ashiqopu | 075bb7d | 2019-03-10 01:38:21 +0000 | [diff] [blame] | 585 | getScheduler().schedule(170_ms, [face1, interest] { face1->receiveInterest(*interest, 0); }); |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 586 | } |
Junxiao Shi | c099ddb | 2014-12-25 20:53:20 -0700 | [diff] [blame] | 587 | }); |
Junxiao Shi | a110f26 | 2014-10-12 12:35:20 -0700 | [diff] [blame] | 588 | |
| 589 | Fib& fib = forwarder.getFib(); |
Ju Pan | d8315bf | 2019-07-31 06:59:07 +0000 | [diff] [blame] | 590 | fib::Entry* entry = fib.insert("/A").first; |
| 591 | fib.addOrUpdateNextHop(*entry, *face2, 0); |
Junxiao Shi | a110f26 | 2014-10-12 12:35:20 -0700 | [diff] [blame] | 592 | |
Junxiao Shi | 455581d | 2014-11-17 18:38:40 -0700 | [diff] [blame] | 593 | // receive an Interest |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 594 | auto interest = makeInterest("/A/1", false, 50_ms, 82101183); |
ashiqopu | 075bb7d | 2019-03-10 01:38:21 +0000 | [diff] [blame] | 595 | face1->receiveInterest(*interest, 0); |
Junxiao Shi | a110f26 | 2014-10-12 12:35:20 -0700 | [diff] [blame] | 596 | |
Junxiao Shi | 455581d | 2014-11-17 18:38:40 -0700 | [diff] [blame] | 597 | // interest should be forwarded only once, as long as Nonce is in Dead Nonce List |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 598 | BOOST_ASSERT(25_ms * 40 < forwarder.getDeadNonceList().getLifetime()); |
| 599 | this->advanceClocks(25_ms, 40); |
Junxiao Shi | a110f26 | 2014-10-12 12:35:20 -0700 | [diff] [blame] | 600 | |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 601 | BOOST_CHECK_EQUAL(face2->sentInterests.size(), 1); |
Junxiao Shi | 455581d | 2014-11-17 18:38:40 -0700 | [diff] [blame] | 602 | |
| 603 | // It's unnecessary to check that Interest with duplicate Nonce can be forwarded again |
| 604 | // after it's gone from Dead Nonce List, because the entry lifetime of Dead Nonce List |
| 605 | // is an implementation decision. NDN protocol requires Name+Nonce to be unique, |
| 606 | // without specifying when Name+Nonce could repeat. Forwarder is permitted to suppress |
| 607 | // an Interest if its Name+Nonce has appeared any point in the past. |
Junxiao Shi | a110f26 | 2014-10-12 12:35:20 -0700 | [diff] [blame] | 608 | } |
| 609 | |
Junxiao Shi | d41d607 | 2016-06-19 23:35:27 +0000 | [diff] [blame] | 610 | BOOST_AUTO_TEST_CASE(PitLeak) // Bug 3484 |
Junxiao Shi | 330136a | 2016-03-10 04:53:08 -0700 | [diff] [blame] | 611 | { |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 612 | auto face1 = addFace(); |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 613 | auto interest = makeInterest("/hcLSAsQ9A", false, 2_s, 61883075); |
Junxiao Shi | 330136a | 2016-03-10 04:53:08 -0700 | [diff] [blame] | 614 | |
| 615 | DeadNonceList& dnl = forwarder.getDeadNonceList(); |
| 616 | dnl.add(interest->getName(), interest->getNonce()); |
| 617 | Pit& pit = forwarder.getPit(); |
| 618 | BOOST_REQUIRE_EQUAL(pit.size(), 0); |
| 619 | |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 620 | forwarder.startProcessInterest(FaceEndpoint(*face1, 0), *interest); |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 621 | this->advanceClocks(100_ms, 20_s); |
Junxiao Shi | 330136a | 2016-03-10 04:53:08 -0700 | [diff] [blame] | 622 | BOOST_CHECK_EQUAL(pit.size(), 0); |
| 623 | } |
| 624 | |
Alex Lane | 6bead9b | 2020-05-12 19:08:20 -0500 | [diff] [blame^] | 625 | BOOST_AUTO_TEST_CASE(UnsolicitedData) |
| 626 | { |
| 627 | auto face1 = addFace(); |
| 628 | auto data = makeData("/A"); |
| 629 | |
| 630 | BOOST_CHECK_EQUAL(forwarder.getCounters().nUnsolicitedData, 0); |
| 631 | forwarder.onIncomingData(FaceEndpoint(*face1, 0), *data); |
| 632 | this->advanceClocks(1_ms, 10_ms); |
| 633 | BOOST_CHECK_EQUAL(forwarder.getCounters().nUnsolicitedData, 1); |
| 634 | } |
| 635 | |
Davide Pesavento | cf7db2f | 2019-03-24 23:17:28 -0400 | [diff] [blame] | 636 | BOOST_AUTO_TEST_SUITE_END() // TestForwarder |
| 637 | BOOST_AUTO_TEST_SUITE_END() // Fw |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 638 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 639 | } // namespace tests |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 640 | } // namespace nfd |