Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 2 | /* |
Davide Pesavento | 1b22a8c | 2022-03-07 21:23:23 -0500 | [diff] [blame] | 3 | * Copyright (c) 2014-2022, Regents of the University of California, |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 4 | * Arizona Board of Regents, |
| 5 | * Colorado State University, |
| 6 | * University Pierre & Marie Curie, Sorbonne University, |
| 7 | * Washington University in St. Louis, |
| 8 | * Beijing Institute of Technology, |
| 9 | * The University of Memphis. |
| 10 | * |
| 11 | * This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 12 | * See AUTHORS.md for complete list of NFD authors and contributors. |
| 13 | * |
| 14 | * NFD is free software: you can redistribute it and/or modify it under the terms |
| 15 | * of the GNU General Public License as published by the Free Software Foundation, |
| 16 | * either version 3 of the License, or (at your option) any later version. |
| 17 | * |
| 18 | * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 19 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 | * PURPOSE. See the GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License along with |
| 23 | * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 24 | */ |
| 25 | |
| 26 | #include "face/lp-reliability.hpp" |
| 27 | #include "face/face.hpp" |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 28 | #include "face/generic-link-service.hpp" |
| 29 | |
| 30 | #include "tests/test-common.hpp" |
Davide Pesavento | cf7db2f | 2019-03-24 23:17:28 -0400 | [diff] [blame] | 31 | #include "tests/daemon/global-io-fixture.hpp" |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 32 | #include "dummy-face.hpp" |
| 33 | #include "dummy-transport.hpp" |
| 34 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 35 | #include <cstring> |
Davide Pesavento | b7bfcb9 | 2022-05-22 23:55:23 -0400 | [diff] [blame^] | 36 | #include <unordered_set> |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 37 | |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 38 | namespace nfd { |
| 39 | namespace face { |
| 40 | namespace tests { |
| 41 | |
| 42 | using namespace nfd::tests; |
| 43 | |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 44 | class DummyLpReliabilityLinkService : public GenericLinkService |
| 45 | { |
| 46 | public: |
| 47 | LpReliability* |
| 48 | getLpReliability() |
| 49 | { |
| 50 | return &m_reliability; |
| 51 | } |
| 52 | |
| 53 | void |
| 54 | sendLpPackets(std::vector<lp::Packet> frags) |
| 55 | { |
| 56 | if (frags.front().has<lp::FragmentField>()) { |
Eric Newberry | 41aba10 | 2017-11-01 16:42:13 -0700 | [diff] [blame] | 57 | Interest interest("/test/prefix"); |
| 58 | lp::Packet pkt; |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 59 | pkt.add<lp::FragmentField>({interest.wireEncode().begin(), interest.wireEncode().end()}); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 60 | assignSequences(frags); |
Eric Newberry | 41aba10 | 2017-11-01 16:42:13 -0700 | [diff] [blame] | 61 | m_reliability.handleOutgoing(frags, std::move(pkt), true); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 62 | } |
| 63 | |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 64 | for (auto frag : frags) { |
Teng Liang | f3bc3ae | 2020-06-08 10:19:25 -0700 | [diff] [blame] | 65 | this->sendLpPacket(std::move(frag)); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 66 | } |
| 67 | } |
| 68 | |
| 69 | private: |
| 70 | void |
Teng Liang | f3bc3ae | 2020-06-08 10:19:25 -0700 | [diff] [blame] | 71 | doSendInterest(const Interest&) final |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 72 | { |
Davide Pesavento | 5a89769 | 2019-10-31 01:28:43 -0400 | [diff] [blame] | 73 | BOOST_FAIL("unexpected doSendInterest"); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | void |
Teng Liang | f3bc3ae | 2020-06-08 10:19:25 -0700 | [diff] [blame] | 77 | doSendData(const Data&) final |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 78 | { |
Davide Pesavento | 5a89769 | 2019-10-31 01:28:43 -0400 | [diff] [blame] | 79 | BOOST_FAIL("unexpected doSendData"); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | void |
Teng Liang | f3bc3ae | 2020-06-08 10:19:25 -0700 | [diff] [blame] | 83 | doSendNack(const lp::Nack&) final |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 84 | { |
Davide Pesavento | 5a89769 | 2019-10-31 01:28:43 -0400 | [diff] [blame] | 85 | BOOST_FAIL("unexpected doSendNack"); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | void |
Davide Pesavento | b3a23ca | 2019-05-04 20:40:21 -0400 | [diff] [blame] | 89 | doReceivePacket(const Block&, const EndpointId&) final |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 90 | { |
Davide Pesavento | 5a89769 | 2019-10-31 01:28:43 -0400 | [diff] [blame] | 91 | BOOST_FAIL("unexpected doReceivePacket"); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 92 | } |
| 93 | }; |
| 94 | |
Davide Pesavento | cf7db2f | 2019-03-24 23:17:28 -0400 | [diff] [blame] | 95 | class LpReliabilityFixture : public GlobalIoTimeFixture |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 96 | { |
| 97 | public: |
| 98 | LpReliabilityFixture() |
| 99 | : linkService(make_unique<DummyLpReliabilityLinkService>()) |
| 100 | , transport(make_unique<DummyTransport>()) |
| 101 | , face(make_unique<DummyFace>()) |
| 102 | { |
| 103 | linkService->setFaceAndTransport(*face, *transport); |
| 104 | transport->setFaceAndLinkService(*face, *linkService); |
| 105 | |
| 106 | GenericLinkService::Options options; |
| 107 | options.reliabilityOptions.isEnabled = true; |
| 108 | linkService->setOptions(options); |
| 109 | |
| 110 | reliability = linkService->getLpReliability(); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 111 | reliability->m_lastTxSeqNo = 1; |
| 112 | } |
| 113 | |
| 114 | static bool |
| 115 | netPktHasUnackedFrag(const shared_ptr<LpReliability::NetPkt>& netPkt, lp::Sequence txSeq) |
| 116 | { |
| 117 | return std::any_of(netPkt->unackedFrags.begin(), netPkt->unackedFrags.end(), |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 118 | [txSeq] (auto fragIt) { return fragIt->first == txSeq; }); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 119 | } |
| 120 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 121 | /** \brief make an LpPacket with fragment of specified size |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 122 | * \param pktNum packet identifier, which can be extracted with \p getPktNum |
Davide Pesavento | b93fb6c | 2020-04-12 14:10:45 -0400 | [diff] [blame] | 123 | * \param payloadSize total payload size; must be >= 4 and <= 255 |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 124 | */ |
| 125 | static lp::Packet |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 126 | makeFrag(uint32_t pktNum, size_t payloadSize = 4) |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 127 | { |
Davide Pesavento | b93fb6c | 2020-04-12 14:10:45 -0400 | [diff] [blame] | 128 | BOOST_ASSERT(payloadSize >= 4 && payloadSize <= 255); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 129 | lp::Packet pkt; |
| 130 | ndn::Buffer buf(payloadSize); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 131 | std::memcpy(buf.data(), &pktNum, sizeof(pktNum)); |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 132 | pkt.set<lp::FragmentField>({buf.cbegin(), buf.cend()}); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 133 | return pkt; |
| 134 | } |
| 135 | |
| 136 | /** \brief extract packet identifier from LpPacket made with \p makeFrag |
| 137 | * \retval 0 packet identifier cannot be extracted |
| 138 | */ |
| 139 | static uint32_t |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 140 | getPktNum(const lp::Packet& pkt) |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 141 | { |
Davide Pesavento | b93fb6c | 2020-04-12 14:10:45 -0400 | [diff] [blame] | 142 | BOOST_REQUIRE(pkt.has<lp::FragmentField>()); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 143 | ndn::Buffer::const_iterator begin, end; |
| 144 | std::tie(begin, end) = pkt.get<lp::FragmentField>(); |
| 145 | if (std::distance(begin, end) < 4) { |
| 146 | return 0; |
| 147 | } |
| 148 | |
| 149 | uint32_t value = 0; |
| 150 | std::memcpy(&value, &*begin, sizeof(value)); |
| 151 | return value; |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 152 | } |
| 153 | |
Eric Newberry | 971d962 | 2018-03-30 23:29:26 -0700 | [diff] [blame] | 154 | protected: |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 155 | unique_ptr<DummyLpReliabilityLinkService> linkService; |
| 156 | unique_ptr<DummyTransport> transport; |
| 157 | unique_ptr<DummyFace> face; |
| 158 | LpReliability* reliability; |
| 159 | }; |
| 160 | |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 161 | BOOST_AUTO_TEST_SUITE(Face) |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 162 | BOOST_FIXTURE_TEST_SUITE(TestLpReliability, LpReliabilityFixture) |
| 163 | |
| 164 | BOOST_AUTO_TEST_CASE(SendNoFragmentField) |
| 165 | { |
| 166 | lp::Packet pkt; |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 167 | |
| 168 | linkService->sendLpPackets({pkt}); |
| 169 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 0); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 170 | BOOST_CHECK_EQUAL(reliability->m_ackQueue.size(), 0); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 171 | BOOST_CHECK_EQUAL(linkService->getCounters().nAcknowledged, 0); |
| 172 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetransmitted, 0); |
| 173 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetxExhausted, 0); |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 174 | BOOST_CHECK_EQUAL(linkService->getCounters().nInterestsExceededRetx, 0); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 175 | } |
| 176 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 177 | BOOST_AUTO_TEST_CASE(SendUnfragmentedRetx) |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 178 | { |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 179 | lp::Packet pkt1 = makeFrag(1024, 50); |
| 180 | lp::Packet pkt2 = makeFrag(3000, 30); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 181 | |
| 182 | linkService->sendLpPackets({pkt1}); |
Eric Newberry | 971d962 | 2018-03-30 23:29:26 -0700 | [diff] [blame] | 183 | BOOST_REQUIRE_EQUAL(transport->sentPackets.size(), 1); |
Teng Liang | 13d582a | 2020-07-21 20:23:11 -0700 | [diff] [blame] | 184 | lp::Packet cached1(transport->sentPackets.front()); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 185 | BOOST_REQUIRE(cached1.has<lp::TxSequenceField>()); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 186 | BOOST_CHECK(cached1.has<lp::SequenceField>()); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 187 | lp::Sequence firstTxSeq = cached1.get<lp::TxSequenceField>(); |
Eric Newberry | 971d962 | 2018-03-30 23:29:26 -0700 | [diff] [blame] | 188 | BOOST_CHECK_EQUAL(firstTxSeq, 2); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 189 | BOOST_CHECK_EQUAL(getPktNum(cached1), 1024); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 190 | BOOST_CHECK_EQUAL(linkService->getCounters().nAcknowledged, 0); |
| 191 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetransmitted, 0); |
| 192 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetxExhausted, 0); |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 193 | BOOST_CHECK_EQUAL(linkService->getCounters().nInterestsExceededRetx, 0); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 194 | |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 195 | // T+500ms |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 196 | // 1024 rto: 1000ms, txSeq: 2, started T+0ms, retx 0 |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 197 | advanceClocks(1_ms, 500); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 198 | linkService->sendLpPackets({pkt2}); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 199 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 2); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 200 | |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 201 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 2); |
| 202 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(firstTxSeq), 1); |
| 203 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(firstTxSeq + 1), 1); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 204 | BOOST_CHECK(reliability->m_unackedFrags.at(firstTxSeq).netPkt); |
| 205 | BOOST_CHECK(reliability->m_unackedFrags.at(firstTxSeq + 1).netPkt); |
| 206 | BOOST_CHECK_NE(reliability->m_unackedFrags.at(firstTxSeq).netPkt, |
Eric Newberry | 971d962 | 2018-03-30 23:29:26 -0700 | [diff] [blame] | 207 | reliability->m_unackedFrags.at(firstTxSeq + 1).netPkt); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 208 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(firstTxSeq).retxCount, 0); |
| 209 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(firstTxSeq + 1).retxCount, 0); |
| 210 | BOOST_CHECK_EQUAL(reliability->m_firstUnackedFrag->first, firstTxSeq); |
| 211 | BOOST_CHECK_EQUAL(reliability->m_ackQueue.size(), 0); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 212 | BOOST_CHECK_EQUAL(linkService->getCounters().nAcknowledged, 0); |
| 213 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetransmitted, 0); |
| 214 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetxExhausted, 0); |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 215 | BOOST_CHECK_EQUAL(linkService->getCounters().nInterestsExceededRetx, 0); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 216 | |
| 217 | // T+1250ms |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 218 | // 1024 rto: 1000ms, txSeq: 4, started T+1000ms, retx 1 |
| 219 | // 3000 rto: 1000ms, txSeq: 3, started T+500ms, retx 0 |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 220 | advanceClocks(1_ms, 750); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 221 | |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 222 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 2); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 223 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(firstTxSeq), 0); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 224 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(firstTxSeq + 2), 1); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 225 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(firstTxSeq + 2).retxCount, 1); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 226 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(firstTxSeq + 1), 1); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 227 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(firstTxSeq + 1).retxCount, 0); |
| 228 | BOOST_CHECK_EQUAL(reliability->m_firstUnackedFrag->first, firstTxSeq + 1); |
| 229 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 3); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 230 | BOOST_CHECK_EQUAL(linkService->getCounters().nAcknowledged, 0); |
| 231 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetransmitted, 0); |
| 232 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetxExhausted, 0); |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 233 | BOOST_CHECK_EQUAL(linkService->getCounters().nInterestsExceededRetx, 0); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 234 | |
| 235 | // T+2250ms |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 236 | // 1024 rto: 1000ms, txSeq: 6, started T+2000ms, retx 2 |
| 237 | // 3000 rto: 1000ms, txSeq: 5, started T+1500ms, retx 1 |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 238 | advanceClocks(1_ms, 1000); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 239 | |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 240 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 2); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 241 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(firstTxSeq + 1), 0); |
| 242 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(firstTxSeq + 2), 0); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 243 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(firstTxSeq + 4), 1); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 244 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(firstTxSeq + 4).retxCount, 2); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 245 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(firstTxSeq + 3), 1); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 246 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(firstTxSeq + 3).retxCount, 1); |
| 247 | BOOST_CHECK_EQUAL(reliability->m_firstUnackedFrag->first, firstTxSeq + 3); |
| 248 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 5); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 249 | BOOST_CHECK_EQUAL(linkService->getCounters().nAcknowledged, 0); |
| 250 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetransmitted, 0); |
| 251 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetxExhausted, 0); |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 252 | BOOST_CHECK_EQUAL(linkService->getCounters().nInterestsExceededRetx, 0); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 253 | |
| 254 | // T+3250ms |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 255 | // 1024 rto: 1000ms, txSeq: 8, started T+3000ms, retx 3 |
| 256 | // 3000 rto: 1000ms, txSeq: 7, started T+2500ms, retx 2 |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 257 | advanceClocks(1_ms, 1000); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 258 | |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 259 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 2); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 260 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(firstTxSeq + 3), 0); |
| 261 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(firstTxSeq + 4), 0); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 262 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(firstTxSeq + 6), 1); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 263 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(firstTxSeq + 6).retxCount, 3); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 264 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(firstTxSeq + 5), 1); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 265 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(firstTxSeq + 5).retxCount, 2); |
| 266 | BOOST_CHECK_EQUAL(reliability->m_firstUnackedFrag->first, firstTxSeq + 5); |
| 267 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 7); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 268 | BOOST_CHECK_EQUAL(linkService->getCounters().nAcknowledged, 0); |
| 269 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetransmitted, 0); |
| 270 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetxExhausted, 0); |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 271 | BOOST_CHECK_EQUAL(linkService->getCounters().nInterestsExceededRetx, 0); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 272 | |
| 273 | // T+4250ms |
| 274 | // 1024 rto: expired, removed |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 275 | // 3000 rto: 1000ms, txSeq: 9, started T+3500ms, retx 3 |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 276 | advanceClocks(1_ms, 1000); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 277 | |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 278 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 1); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 279 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(firstTxSeq + 5), 0); |
| 280 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(firstTxSeq + 6), 0); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 281 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(firstTxSeq + 7), 1); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 282 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(firstTxSeq + 7).retxCount, 3); |
| 283 | BOOST_CHECK_EQUAL(reliability->m_firstUnackedFrag->first, firstTxSeq + 7); |
| 284 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 8); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 285 | |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 286 | BOOST_CHECK_EQUAL(linkService->getCounters().nAcknowledged, 0); |
| 287 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetransmitted, 0); |
| 288 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetxExhausted, 1); |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 289 | BOOST_CHECK_EQUAL(linkService->getCounters().nInterestsExceededRetx, 1); |
Eric Newberry | 41aba10 | 2017-11-01 16:42:13 -0700 | [diff] [blame] | 290 | |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 291 | // T+4750ms |
| 292 | // 1024 rto: expired, removed |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 293 | // 3000 rto: expired, removed |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 294 | advanceClocks(1_ms, 1000); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 295 | |
| 296 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 0); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 297 | BOOST_CHECK_EQUAL(reliability->m_ackQueue.size(), 0); |
| 298 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 8); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 299 | BOOST_CHECK_EQUAL(linkService->getCounters().nAcknowledged, 0); |
| 300 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetransmitted, 0); |
| 301 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetxExhausted, 2); |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 302 | BOOST_CHECK_EQUAL(linkService->getCounters().nInterestsExceededRetx, 2); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 303 | } |
| 304 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 305 | BOOST_AUTO_TEST_CASE(SendFragmentedRetx) |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 306 | { |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 307 | lp::Packet pkt1 = makeFrag(2048, 30); |
| 308 | lp::Packet pkt2 = makeFrag(2049, 30); |
| 309 | lp::Packet pkt3 = makeFrag(2050, 10); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 310 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 311 | linkService->sendLpPackets({pkt1, pkt2, pkt3}); |
| 312 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 3); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 313 | |
Teng Liang | 13d582a | 2020-07-21 20:23:11 -0700 | [diff] [blame] | 314 | lp::Packet cached1(transport->sentPackets.at(0)); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 315 | BOOST_REQUIRE(cached1.has<lp::TxSequenceField>()); |
| 316 | BOOST_CHECK_EQUAL(cached1.get<lp::TxSequenceField>(), 2); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 317 | BOOST_CHECK(cached1.has<lp::SequenceField>()); |
| 318 | BOOST_CHECK_EQUAL(getPktNum(cached1), 2048); |
Teng Liang | 13d582a | 2020-07-21 20:23:11 -0700 | [diff] [blame] | 319 | lp::Packet cached2(transport->sentPackets.at(1)); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 320 | BOOST_REQUIRE(cached2.has<lp::TxSequenceField>()); |
| 321 | BOOST_CHECK_EQUAL(cached2.get<lp::TxSequenceField>(), 3); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 322 | BOOST_CHECK(cached2.has<lp::SequenceField>()); |
| 323 | BOOST_CHECK_EQUAL(getPktNum(cached2), 2049); |
Teng Liang | 13d582a | 2020-07-21 20:23:11 -0700 | [diff] [blame] | 324 | lp::Packet cached3(transport->sentPackets.at(2)); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 325 | BOOST_REQUIRE(cached3.has<lp::TxSequenceField>()); |
| 326 | BOOST_CHECK_EQUAL(cached3.get<lp::TxSequenceField>(), 4); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 327 | BOOST_CHECK(cached3.has<lp::SequenceField>()); |
| 328 | BOOST_CHECK_EQUAL(getPktNum(cached3), 2050); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 329 | BOOST_CHECK_EQUAL(linkService->getCounters().nAcknowledged, 0); |
| 330 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetransmitted, 0); |
| 331 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetxExhausted, 0); |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 332 | BOOST_CHECK_EQUAL(linkService->getCounters().nInterestsExceededRetx, 0); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 333 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 334 | // T+0ms |
| 335 | // 2048 rto: 1000ms, txSeq: 2, started T+0ms, retx 0 |
| 336 | // 2049 rto: 1000ms, txSeq: 3, started T+0ms, retx 0 |
| 337 | // 2050 rto: 1000ms, txSeq: 4, started T+0ms, retx 0 |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 338 | |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 339 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(2), 1); |
| 340 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(3), 1); |
| 341 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(4), 1); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 342 | BOOST_CHECK_EQUAL(getPktNum(reliability->m_unackedFrags.at(2).pkt), 2048); |
| 343 | BOOST_CHECK_EQUAL(getPktNum(reliability->m_unackedFrags.at(3).pkt), 2049); |
| 344 | BOOST_CHECK_EQUAL(getPktNum(reliability->m_unackedFrags.at(4).pkt), 2050); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 345 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(2).retxCount, 0); |
| 346 | BOOST_REQUIRE(reliability->m_unackedFrags.at(2).netPkt); |
| 347 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(3).retxCount, 0); |
| 348 | BOOST_REQUIRE(reliability->m_unackedFrags.at(3).netPkt); |
| 349 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(4).retxCount, 0); |
| 350 | BOOST_REQUIRE(reliability->m_unackedFrags.at(4).netPkt); |
| 351 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(2).netPkt, reliability->m_unackedFrags.at(3).netPkt); |
| 352 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(2).netPkt, reliability->m_unackedFrags.at(4).netPkt); |
| 353 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(2).netPkt->unackedFrags.size(), 3); |
| 354 | BOOST_CHECK(netPktHasUnackedFrag(reliability->m_unackedFrags.at(2).netPkt, 2)); |
| 355 | BOOST_CHECK(netPktHasUnackedFrag(reliability->m_unackedFrags.at(2).netPkt, 3)); |
| 356 | BOOST_CHECK(netPktHasUnackedFrag(reliability->m_unackedFrags.at(2).netPkt, 4)); |
| 357 | BOOST_CHECK_EQUAL(reliability->m_firstUnackedFrag->first, 2); |
| 358 | BOOST_CHECK_EQUAL(reliability->m_ackQueue.size(), 0); |
| 359 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 3); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 360 | BOOST_CHECK_EQUAL(linkService->getCounters().nAcknowledged, 0); |
| 361 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetransmitted, 0); |
| 362 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetxExhausted, 0); |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 363 | BOOST_CHECK_EQUAL(linkService->getCounters().nInterestsExceededRetx, 0); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 364 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 365 | // T+250ms |
| 366 | // 2048 rto: 1000ms, txSeq: 2, started T+0ms, retx 0 |
| 367 | // 2049 rto: 1000ms, txSeq: 5, started T+250ms, retx 1 |
| 368 | // 2050 rto: 1000ms, txSeq: 4, started T+0ms, retx 0 |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 369 | advanceClocks(1_ms, 250); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 370 | reliability->onLpPacketLost(3, true); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 371 | |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 372 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(2), 1); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 373 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(3), 0); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 374 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(5), 1); |
| 375 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(4), 1); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 376 | BOOST_CHECK_EQUAL(getPktNum(reliability->m_unackedFrags.at(2).pkt), 2048); |
| 377 | BOOST_CHECK_EQUAL(getPktNum(reliability->m_unackedFrags.at(5).pkt), 2049); |
| 378 | BOOST_CHECK_EQUAL(getPktNum(reliability->m_unackedFrags.at(4).pkt), 2050); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 379 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(2).retxCount, 0); |
| 380 | BOOST_REQUIRE(reliability->m_unackedFrags.at(2).netPkt); |
| 381 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(5).retxCount, 1); |
| 382 | BOOST_REQUIRE(reliability->m_unackedFrags.at(5).netPkt); |
| 383 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(4).retxCount, 0); |
| 384 | BOOST_REQUIRE(reliability->m_unackedFrags.at(4).netPkt); |
| 385 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(2).netPkt, reliability->m_unackedFrags.at(5).netPkt); |
| 386 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(2).netPkt, reliability->m_unackedFrags.at(4).netPkt); |
| 387 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(2).netPkt->unackedFrags.size(), 3); |
| 388 | BOOST_CHECK(netPktHasUnackedFrag(reliability->m_unackedFrags.at(2).netPkt, 2)); |
| 389 | BOOST_CHECK(!netPktHasUnackedFrag(reliability->m_unackedFrags.at(2).netPkt, 3)); |
| 390 | BOOST_CHECK(netPktHasUnackedFrag(reliability->m_unackedFrags.at(2).netPkt, 5)); |
| 391 | BOOST_CHECK(netPktHasUnackedFrag(reliability->m_unackedFrags.at(2).netPkt, 4)); |
| 392 | BOOST_CHECK_EQUAL(reliability->m_firstUnackedFrag->first, 2); |
| 393 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 4); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 394 | BOOST_CHECK_EQUAL(linkService->getCounters().nAcknowledged, 0); |
| 395 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetransmitted, 0); |
| 396 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetxExhausted, 0); |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 397 | BOOST_CHECK_EQUAL(linkService->getCounters().nInterestsExceededRetx, 0); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 398 | |
| 399 | // T+500ms |
| 400 | // 2048 rto: 1000ms, txSeq: 2, started T+0ms, retx 0 |
| 401 | // 2049 rto: 1000ms, txSeq: 6, started T+500ms, retx 2 |
| 402 | // 2050 rto: 1000ms, txSeq: 4, started T+0ms, retx 0 |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 403 | advanceClocks(1_ms, 250); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 404 | reliability->onLpPacketLost(5, true); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 405 | |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 406 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(2), 1); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 407 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(5), 0); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 408 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(6), 1); |
| 409 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(4), 1); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 410 | BOOST_CHECK_EQUAL(getPktNum(reliability->m_unackedFrags.at(2).pkt), 2048); |
| 411 | BOOST_CHECK_EQUAL(getPktNum(reliability->m_unackedFrags.at(6).pkt), 2049); |
| 412 | BOOST_CHECK_EQUAL(getPktNum(reliability->m_unackedFrags.at(4).pkt), 2050); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 413 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(2).retxCount, 0); |
| 414 | BOOST_REQUIRE(reliability->m_unackedFrags.at(2).netPkt); |
| 415 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(6).retxCount, 2); |
| 416 | BOOST_REQUIRE(reliability->m_unackedFrags.at(6).netPkt); |
| 417 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(4).retxCount, 0); |
| 418 | BOOST_REQUIRE(reliability->m_unackedFrags.at(4).netPkt); |
| 419 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(2).netPkt, reliability->m_unackedFrags.at(6).netPkt); |
| 420 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(2).netPkt, reliability->m_unackedFrags.at(4).netPkt); |
| 421 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(2).netPkt->unackedFrags.size(), 3); |
| 422 | BOOST_CHECK(netPktHasUnackedFrag(reliability->m_unackedFrags.at(2).netPkt, 2)); |
| 423 | BOOST_CHECK(!netPktHasUnackedFrag(reliability->m_unackedFrags.at(2).netPkt, 5)); |
| 424 | BOOST_CHECK(netPktHasUnackedFrag(reliability->m_unackedFrags.at(2).netPkt, 6)); |
| 425 | BOOST_CHECK(netPktHasUnackedFrag(reliability->m_unackedFrags.at(2).netPkt, 4)); |
| 426 | BOOST_CHECK_EQUAL(reliability->m_firstUnackedFrag->first, 2); |
| 427 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 5); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 428 | BOOST_CHECK_EQUAL(linkService->getCounters().nAcknowledged, 0); |
| 429 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetransmitted, 0); |
| 430 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetxExhausted, 0); |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 431 | BOOST_CHECK_EQUAL(linkService->getCounters().nInterestsExceededRetx, 0); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 432 | |
| 433 | // T+750ms |
| 434 | // 2048 rto: 1000ms, txSeq: 2, started T+0ms, retx 0 |
| 435 | // 2049 rto: 1000ms, txSeq: 7, started T+750ms, retx 3 |
| 436 | // 2050 rto: 1000ms, txSeq: 4, started T+0ms, retx 0 |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 437 | advanceClocks(1_ms, 250); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 438 | reliability->onLpPacketLost(6, true); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 439 | |
| 440 | BOOST_REQUIRE_EQUAL(reliability->m_unackedFrags.count(2), 1); |
| 441 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(6), 0); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 442 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(7), 1); |
| 443 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(4), 1); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 444 | BOOST_CHECK_EQUAL(getPktNum(reliability->m_unackedFrags.at(2).pkt), 2048); |
| 445 | BOOST_CHECK_EQUAL(getPktNum(reliability->m_unackedFrags.at(7).pkt), 2049); |
| 446 | BOOST_CHECK_EQUAL(getPktNum(reliability->m_unackedFrags.at(4).pkt), 2050); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 447 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(2).retxCount, 0); |
| 448 | BOOST_REQUIRE(reliability->m_unackedFrags.at(2).netPkt); |
| 449 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(7).retxCount, 3); |
| 450 | BOOST_REQUIRE(reliability->m_unackedFrags.at(7).netPkt); |
| 451 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(4).retxCount, 0); |
| 452 | BOOST_REQUIRE(reliability->m_unackedFrags.at(4).netPkt); |
| 453 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(2).netPkt, reliability->m_unackedFrags.at(7).netPkt); |
| 454 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(2).netPkt, reliability->m_unackedFrags.at(4).netPkt); |
| 455 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(2).netPkt->unackedFrags.size(), 3); |
| 456 | BOOST_CHECK(netPktHasUnackedFrag(reliability->m_unackedFrags.at(2).netPkt, 2)); |
| 457 | BOOST_CHECK(!netPktHasUnackedFrag(reliability->m_unackedFrags.at(2).netPkt, 6)); |
| 458 | BOOST_CHECK(netPktHasUnackedFrag(reliability->m_unackedFrags.at(2).netPkt, 7)); |
| 459 | BOOST_CHECK(netPktHasUnackedFrag(reliability->m_unackedFrags.at(2).netPkt, 4)); |
| 460 | BOOST_CHECK_EQUAL(reliability->m_firstUnackedFrag->first, 2); |
| 461 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 6); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 462 | BOOST_CHECK_EQUAL(linkService->getCounters().nAcknowledged, 0); |
| 463 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetransmitted, 0); |
| 464 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetxExhausted, 0); |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 465 | BOOST_CHECK_EQUAL(linkService->getCounters().nInterestsExceededRetx, 0); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 466 | |
| 467 | // T+850ms |
| 468 | // 2048 rto: expired, removed |
| 469 | // 2049 rto: expired, removed |
| 470 | // 2050 rto: expired, removed |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 471 | advanceClocks(1_ms, 100); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 472 | reliability->onLpPacketLost(7, true); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 473 | |
| 474 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 0); |
| 475 | BOOST_CHECK_EQUAL(reliability->m_ackQueue.size(), 0); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 476 | BOOST_CHECK_EQUAL(linkService->getCounters().nAcknowledged, 0); |
| 477 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetransmitted, 0); |
| 478 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetxExhausted, 1); |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 479 | BOOST_CHECK_EQUAL(linkService->getCounters().nInterestsExceededRetx, 1); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 480 | } |
| 481 | |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 482 | BOOST_AUTO_TEST_CASE(AckUnknownTxSeq) |
| 483 | { |
| 484 | linkService->sendLpPackets({makeFrag(1, 50)}); |
| 485 | |
| 486 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 1); |
| 487 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(2), 1); |
| 488 | BOOST_CHECK(reliability->m_unackedFrags.at(2).netPkt); |
| 489 | BOOST_CHECK_EQUAL(reliability->m_firstUnackedFrag->first, 2); |
| 490 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 1); |
| 491 | BOOST_CHECK_EQUAL(linkService->getCounters().nAcknowledged, 0); |
| 492 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetransmitted, 0); |
| 493 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetxExhausted, 0); |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 494 | BOOST_CHECK_EQUAL(linkService->getCounters().nInterestsExceededRetx, 0); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 495 | |
| 496 | lp::Packet ackPkt; |
| 497 | ackPkt.add<lp::AckField>(10101010); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 498 | BOOST_CHECK(reliability->processIncomingPacket(ackPkt)); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 499 | |
| 500 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 1); |
| 501 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(2), 1); |
| 502 | BOOST_CHECK(reliability->m_unackedFrags.at(2).netPkt); |
| 503 | BOOST_CHECK_EQUAL(reliability->m_firstUnackedFrag->first, 2); |
| 504 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 1); |
| 505 | BOOST_CHECK_EQUAL(linkService->getCounters().nAcknowledged, 0); |
| 506 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetransmitted, 0); |
| 507 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetxExhausted, 0); |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 508 | BOOST_CHECK_EQUAL(linkService->getCounters().nInterestsExceededRetx, 0); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 509 | } |
| 510 | |
Eric Newberry | 971d962 | 2018-03-30 23:29:26 -0700 | [diff] [blame] | 511 | BOOST_AUTO_TEST_CASE(LossByGreaterAcks) |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 512 | { |
Eric Newberry | 971d962 | 2018-03-30 23:29:26 -0700 | [diff] [blame] | 513 | // Detect loss by 3x greater Acks, also tests wraparound |
| 514 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 515 | reliability->m_lastTxSeqNo = 0xFFFFFFFFFFFFFFFE; |
| 516 | |
Eric Newberry | 971d962 | 2018-03-30 23:29:26 -0700 | [diff] [blame] | 517 | // Passed to sendLpPackets individually since they are |
| 518 | // from separate, non-fragmented network packets |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 519 | linkService->sendLpPackets({makeFrag(1, 50)}); |
| 520 | linkService->sendLpPackets({makeFrag(2, 50)}); |
| 521 | linkService->sendLpPackets({makeFrag(3, 50)}); |
| 522 | linkService->sendLpPackets({makeFrag(4, 50)}); |
| 523 | linkService->sendLpPackets({makeFrag(5, 50)}); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 524 | |
| 525 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 5); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 526 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(0xFFFFFFFFFFFFFFFF), 1); // pkt1 |
| 527 | BOOST_CHECK(reliability->m_unackedFrags.at(0xFFFFFFFFFFFFFFFF).netPkt); |
| 528 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(0), 1); // pkt2 |
| 529 | BOOST_CHECK(reliability->m_unackedFrags.at(0).netPkt); |
| 530 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(1), 1); // pkt3 |
| 531 | BOOST_CHECK(reliability->m_unackedFrags.at(1).netPkt); |
| 532 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(2), 1); // pkt4 |
| 533 | BOOST_CHECK(reliability->m_unackedFrags.at(2).netPkt); |
| 534 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(3), 1); // pkt5 |
| 535 | BOOST_CHECK(reliability->m_unackedFrags.at(3).netPkt); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 536 | BOOST_CHECK_EQUAL(reliability->m_firstUnackedFrag->first, 0xFFFFFFFFFFFFFFFF); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 537 | BOOST_CHECK_EQUAL(linkService->getCounters().nAcknowledged, 0); |
| 538 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetransmitted, 0); |
| 539 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetxExhausted, 0); |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 540 | BOOST_CHECK_EQUAL(linkService->getCounters().nInterestsExceededRetx, 0); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 541 | |
| 542 | lp::Packet ackPkt1; |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 543 | ackPkt1.add<lp::AckField>(0); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 544 | |
| 545 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 5); |
| 546 | |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 547 | BOOST_CHECK(reliability->processIncomingPacket(ackPkt1)); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 548 | |
| 549 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 4); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 550 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(0xFFFFFFFFFFFFFFFF), 1); // pkt1 |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 551 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(0xFFFFFFFFFFFFFFFF).retxCount, 0); |
| 552 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(0xFFFFFFFFFFFFFFFF).nGreaterSeqAcks, 1); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 553 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(0), 0); // pkt2 |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 554 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(1), 1); // pkt3 |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 555 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(1).retxCount, 0); |
| 556 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(1).nGreaterSeqAcks, 0); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 557 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(2), 1); // pkt4 |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 558 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(2).retxCount, 0); |
| 559 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(2).nGreaterSeqAcks, 0); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 560 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(3), 1); // pkt5 |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 561 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(3).retxCount, 0); |
| 562 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(3).nGreaterSeqAcks, 0); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 563 | BOOST_CHECK_EQUAL(reliability->m_firstUnackedFrag->first, 0xFFFFFFFFFFFFFFFF); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 564 | BOOST_REQUIRE_EQUAL(transport->sentPackets.size(), 5); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 565 | BOOST_CHECK_EQUAL(linkService->getCounters().nAcknowledged, 1); |
| 566 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetransmitted, 0); |
| 567 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetxExhausted, 0); |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 568 | BOOST_CHECK_EQUAL(linkService->getCounters().nInterestsExceededRetx, 0); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 569 | |
| 570 | lp::Packet ackPkt2; |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 571 | ackPkt2.add<lp::AckField>(2); |
| 572 | ackPkt1.add<lp::AckField>(101010); // Unknown TxSequence number - ignored |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 573 | |
| 574 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 5); |
| 575 | |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 576 | BOOST_CHECK(reliability->processIncomingPacket(ackPkt2)); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 577 | |
| 578 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 3); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 579 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(0xFFFFFFFFFFFFFFFF), 1); // pkt1 |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 580 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(0xFFFFFFFFFFFFFFFF).retxCount, 0); |
| 581 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(0xFFFFFFFFFFFFFFFF).nGreaterSeqAcks, 2); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 582 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(0), 0); // pkt2 |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 583 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(1), 1); // pkt3 |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 584 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(1).retxCount, 0); |
| 585 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(1).nGreaterSeqAcks, 1); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 586 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(2), 0); // pkt4 |
| 587 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(3), 1); // pkt5 |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 588 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(3).retxCount, 0); |
| 589 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(3).nGreaterSeqAcks, 0); |
| 590 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(101010), 0); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 591 | BOOST_CHECK_EQUAL(reliability->m_firstUnackedFrag->first, 0xFFFFFFFFFFFFFFFF); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 592 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 5); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 593 | BOOST_CHECK_EQUAL(linkService->getCounters().nAcknowledged, 2); |
| 594 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetransmitted, 0); |
| 595 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetxExhausted, 0); |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 596 | BOOST_CHECK_EQUAL(linkService->getCounters().nInterestsExceededRetx, 0); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 597 | |
| 598 | lp::Packet ackPkt3; |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 599 | ackPkt3.add<lp::AckField>(1); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 600 | |
| 601 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 5); |
| 602 | |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 603 | BOOST_CHECK(reliability->processIncomingPacket(ackPkt3)); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 604 | |
| 605 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 2); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 606 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(0xFFFFFFFFFFFFFFFF), 0); // pkt1 old TxSeq |
| 607 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(0), 0); // pkt2 |
| 608 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(1), 0); // pkt3 |
| 609 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(2), 0); // pkt4 |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 610 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(3), 1); // pkt5 |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 611 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(3).retxCount, 0); |
| 612 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(3).nGreaterSeqAcks, 0); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 613 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(4), 1); // pkt1 new TxSeq |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 614 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(4).retxCount, 1); |
| 615 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(4).nGreaterSeqAcks, 0); |
| 616 | BOOST_CHECK_EQUAL(reliability->m_firstUnackedFrag->first, 3); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 617 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 6); |
Teng Liang | 13d582a | 2020-07-21 20:23:11 -0700 | [diff] [blame] | 618 | lp::Packet sentRetxPkt(transport->sentPackets.back()); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 619 | BOOST_REQUIRE(sentRetxPkt.has<lp::TxSequenceField>()); |
| 620 | BOOST_CHECK_EQUAL(sentRetxPkt.get<lp::TxSequenceField>(), 4); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 621 | BOOST_CHECK_EQUAL(getPktNum(sentRetxPkt), 1); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 622 | BOOST_CHECK_EQUAL(linkService->getCounters().nAcknowledged, 3); |
| 623 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetransmitted, 0); |
| 624 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetxExhausted, 0); |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 625 | BOOST_CHECK_EQUAL(linkService->getCounters().nInterestsExceededRetx, 0); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 626 | |
| 627 | lp::Packet ackPkt4; |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 628 | ackPkt4.add<lp::AckField>(4); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 629 | |
| 630 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 6); |
| 631 | |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 632 | BOOST_CHECK(reliability->processIncomingPacket(ackPkt4)); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 633 | |
| 634 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 1); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 635 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(0xFFFFFFFFFFFFFFFF), 0); // pkt1 old TxSeq |
| 636 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(0), 0); // pkt2 |
| 637 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(1), 0); // pkt3 |
| 638 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(2), 0); // pkt4 |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 639 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(3), 1); // pkt5 |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 640 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(3).retxCount, 0); |
| 641 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(3).nGreaterSeqAcks, 1); |
| 642 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.count(4), 0); // pkt1 new TxSeq |
| 643 | BOOST_CHECK_EQUAL(reliability->m_firstUnackedFrag->first, 3); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 644 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 6); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 645 | BOOST_CHECK_EQUAL(linkService->getCounters().nAcknowledged, 3); |
| 646 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetransmitted, 1); |
| 647 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetxExhausted, 0); |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 648 | BOOST_CHECK_EQUAL(linkService->getCounters().nInterestsExceededRetx, 0); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 649 | } |
| 650 | |
Eric Newberry | 971d962 | 2018-03-30 23:29:26 -0700 | [diff] [blame] | 651 | BOOST_AUTO_TEST_CASE(SkipFragmentsRemovedInRtt) |
| 652 | { |
| 653 | auto opts = linkService->getOptions(); |
| 654 | opts.reliabilityOptions.maxRetx = 0; // just to make the test case shorter |
| 655 | opts.reliabilityOptions.seqNumLossThreshold = 3; |
| 656 | linkService->setOptions(opts); |
| 657 | |
| 658 | lp::Packet frag1 = makeFrag(5001); |
| 659 | lp::Packet frag2 = makeFrag(5002); |
| 660 | linkService->sendLpPackets({frag1, frag2}); // First packet has 2 fragments |
| 661 | linkService->sendLpPackets({makeFrag(5003)}); |
| 662 | linkService->sendLpPackets({makeFrag(5004)}); |
| 663 | linkService->sendLpPackets({makeFrag(5005)}); |
| 664 | |
| 665 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 5); |
| 666 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 5); |
| 667 | |
| 668 | lp::Sequence firstTxSeq = reliability->m_firstUnackedFrag->first; |
| 669 | |
| 670 | // Ack the last 2 packets |
| 671 | lp::Packet ackPkt1; |
| 672 | ackPkt1.add<lp::AckField>(firstTxSeq + 4); |
| 673 | ackPkt1.add<lp::AckField>(firstTxSeq + 3); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 674 | BOOST_CHECK(reliability->processIncomingPacket(ackPkt1)); |
Eric Newberry | 971d962 | 2018-03-30 23:29:26 -0700 | [diff] [blame] | 675 | |
| 676 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 3); |
| 677 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(firstTxSeq).nGreaterSeqAcks, 2); |
| 678 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.at(firstTxSeq + 1).nGreaterSeqAcks, 2); |
| 679 | |
| 680 | // Ack the third packet (5003) |
| 681 | // This triggers a "loss by greater Acks" for packets 5001 and 5002 |
| 682 | lp::Packet ackPkt2; |
| 683 | ackPkt2.add<lp::AckField>(firstTxSeq + 2); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 684 | BOOST_CHECK(reliability->processIncomingPacket(ackPkt2)); // tests crash/assert reported in bug #4479 |
Eric Newberry | 971d962 | 2018-03-30 23:29:26 -0700 | [diff] [blame] | 685 | |
| 686 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 0); |
| 687 | } |
| 688 | |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 689 | BOOST_AUTO_TEST_CASE(CancelLossNotificationOnAck) |
| 690 | { |
| 691 | reliability->onDroppedInterest.connect([] (const Interest&) { |
| 692 | BOOST_FAIL("Packet loss timeout should be cancelled when packet acknowledged"); |
| 693 | }); |
| 694 | |
| 695 | reliability->m_lastTxSeqNo = 0; |
| 696 | |
| 697 | linkService->sendLpPackets({makeFrag(1, 50)}); |
| 698 | |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 699 | advanceClocks(1_ms, 500); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 700 | |
| 701 | lp::Packet ackPkt; |
| 702 | ackPkt.add<lp::AckField>(1); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 703 | BOOST_CHECK(reliability->processIncomingPacket(ackPkt)); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 704 | |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 705 | advanceClocks(1_ms, 1000); |
Eric Newberry | 00d39fd | 2017-12-10 14:26:45 -0700 | [diff] [blame] | 706 | |
| 707 | BOOST_CHECK_EQUAL(linkService->getCounters().nAcknowledged, 1); |
| 708 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetransmitted, 0); |
| 709 | BOOST_CHECK_EQUAL(linkService->getCounters().nRetxExhausted, 0); |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 710 | BOOST_CHECK_EQUAL(linkService->getCounters().nInterestsExceededRetx, 0); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 711 | } |
| 712 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 713 | BOOST_AUTO_TEST_CASE(ProcessIncomingPacket) |
| 714 | { |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 715 | BOOST_CHECK(!reliability->m_idleAckTimer); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 716 | BOOST_CHECK_EQUAL(reliability->m_ackQueue.size(), 0); |
| 717 | |
| 718 | lp::Packet pkt1 = makeFrag(100, 40); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 719 | pkt1.add<lp::SequenceField>(123456); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 720 | pkt1.add<lp::TxSequenceField>(765432); |
| 721 | |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 722 | BOOST_CHECK(reliability->processIncomingPacket(pkt1)); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 723 | |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 724 | BOOST_CHECK(reliability->m_idleAckTimer); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 725 | BOOST_REQUIRE_EQUAL(reliability->m_ackQueue.size(), 1); |
| 726 | BOOST_CHECK_EQUAL(reliability->m_ackQueue.front(), 765432); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 727 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqs.size(), 1); |
| 728 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqs.count(123456), 1); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 729 | |
| 730 | lp::Packet pkt2 = makeFrag(276, 40); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 731 | pkt2.add<lp::SequenceField>(654321); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 732 | pkt2.add<lp::TxSequenceField>(234567); |
| 733 | |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 734 | BOOST_CHECK(reliability->processIncomingPacket(pkt2)); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 735 | |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 736 | BOOST_CHECK(reliability->m_idleAckTimer); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 737 | BOOST_REQUIRE_EQUAL(reliability->m_ackQueue.size(), 2); |
| 738 | BOOST_CHECK_EQUAL(reliability->m_ackQueue.front(), 765432); |
| 739 | BOOST_CHECK_EQUAL(reliability->m_ackQueue.back(), 234567); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 740 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqs.size(), 2); |
| 741 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqs.count(123456), 1); |
| 742 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqs.count(654321), 1); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 743 | |
| 744 | // T+5ms |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 745 | advanceClocks(1_ms, 5); |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 746 | BOOST_CHECK(!reliability->m_idleAckTimer); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 747 | } |
| 748 | |
| 749 | BOOST_AUTO_TEST_CASE(PiggybackAcks) |
| 750 | { |
| 751 | reliability->m_ackQueue.push(256); |
| 752 | reliability->m_ackQueue.push(257); |
| 753 | reliability->m_ackQueue.push(10); |
| 754 | |
| 755 | lp::Packet pkt; |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 756 | linkService->sendLpPackets({pkt}); |
| 757 | |
| 758 | BOOST_REQUIRE_EQUAL(transport->sentPackets.size(), 1); |
Teng Liang | 13d582a | 2020-07-21 20:23:11 -0700 | [diff] [blame] | 759 | lp::Packet sentPkt(transport->sentPackets.front()); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 760 | |
| 761 | BOOST_REQUIRE_EQUAL(sentPkt.count<lp::AckField>(), 3); |
| 762 | BOOST_CHECK_EQUAL(sentPkt.get<lp::AckField>(0), 256); |
| 763 | BOOST_CHECK_EQUAL(sentPkt.get<lp::AckField>(1), 257); |
| 764 | BOOST_CHECK_EQUAL(sentPkt.get<lp::AckField>(2), 10); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 765 | BOOST_CHECK(!sentPkt.has<lp::TxSequenceField>()); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 766 | |
| 767 | BOOST_CHECK_EQUAL(reliability->m_ackQueue.size(), 0); |
| 768 | } |
| 769 | |
| 770 | BOOST_AUTO_TEST_CASE(PiggybackAcksMtu) |
| 771 | { |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 772 | // MTU is 1500, payload has 60 octets plus 6 octets for LpPacket and Fragment TL and 10 octets |
| 773 | // each for Sequence and TxSequence, leaving 1414 octets for piggybacking. Each Ack header is 12 |
| 774 | // octets, so each LpPacket can carry 117 Acks, and it takes 9 LpPackets for 1000 Acks. |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 775 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 776 | transport->setMtu(1500); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 777 | |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 778 | std::unordered_set<lp::Sequence> expectedAcks; |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 779 | for (lp::Sequence i = 1000; i < 2000; i++) { |
| 780 | reliability->m_ackQueue.push(i); |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 781 | expectedAcks.insert(i); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 782 | } |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 783 | |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 784 | for (uint32_t i = 1; i <= 9; i++) { |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 785 | lp::Packet pkt = makeFrag(i, 60); |
| 786 | linkService->sendLpPackets({pkt}); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 787 | |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 788 | BOOST_REQUIRE_EQUAL(transport->sentPackets.size(), i); |
Teng Liang | 13d582a | 2020-07-21 20:23:11 -0700 | [diff] [blame] | 789 | lp::Packet sentPkt(transport->sentPackets.back()); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 790 | BOOST_CHECK_EQUAL(getPktNum(sentPkt), i); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 791 | BOOST_CHECK(sentPkt.has<lp::AckField>()); |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 792 | |
| 793 | for (lp::Sequence ack : sentPkt.list<lp::AckField>()) { |
| 794 | BOOST_CHECK_EQUAL(expectedAcks.erase(ack), 1); |
| 795 | } |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 796 | } |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 797 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 798 | BOOST_CHECK(reliability->m_ackQueue.empty()); |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 799 | BOOST_CHECK(expectedAcks.empty()); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 800 | } |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 801 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 802 | BOOST_AUTO_TEST_CASE(PiggybackAcksMtuNoSpace) |
| 803 | { |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 804 | // MTU is 64, payload has 34 octets plus 4 octets for LpPacket and Fragment TL and 10 octets each |
| 805 | // for Sequence and TxSequence, leaving 6 octets for piggybacking. Each Ack header is 12 octets, |
| 806 | // so there's no room to piggyback any Ack in LpPacket. |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 807 | |
Eric Newberry | cb6551e | 2020-03-02 14:12:16 -0800 | [diff] [blame] | 808 | transport->setMtu(MIN_MTU); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 809 | |
| 810 | for (lp::Sequence i = 1000; i < 1100; i++) { |
| 811 | reliability->m_ackQueue.push(i); |
| 812 | } |
| 813 | |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 814 | lp::Packet pkt = makeFrag(1, 34); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 815 | linkService->sendLpPackets({pkt}); |
| 816 | |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 817 | BOOST_REQUIRE_EQUAL(transport->sentPackets.size(), 1); |
Teng Liang | 13d582a | 2020-07-21 20:23:11 -0700 | [diff] [blame] | 818 | lp::Packet sentPkt(transport->sentPackets.back()); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 819 | BOOST_CHECK_EQUAL(getPktNum(sentPkt), 1); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 820 | BOOST_CHECK(!sentPkt.has<lp::AckField>()); |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 821 | |
| 822 | BOOST_CHECK_EQUAL(reliability->m_ackQueue.size(), 100); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 823 | } |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 824 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 825 | BOOST_AUTO_TEST_CASE(StartIdleAckTimer) |
| 826 | { |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 827 | BOOST_CHECK(!reliability->m_idleAckTimer); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 828 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 829 | lp::Packet pkt1 = makeFrag(1, 100); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 830 | pkt1.add<lp::SequenceField>(1); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 831 | pkt1.add<lp::TxSequenceField>(12); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 832 | BOOST_CHECK(reliability->processIncomingPacket({pkt1})); |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 833 | BOOST_CHECK(reliability->m_idleAckTimer); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 834 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 835 | // T+1ms |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 836 | advanceClocks(1_ms, 1); |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 837 | BOOST_CHECK(reliability->m_idleAckTimer); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 838 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 839 | lp::Packet pkt2 = makeFrag(2, 100); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 840 | pkt2.add<lp::SequenceField>(2); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 841 | pkt2.add<lp::TxSequenceField>(13); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 842 | BOOST_CHECK(reliability->processIncomingPacket({pkt2})); |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 843 | BOOST_CHECK(reliability->m_idleAckTimer); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 844 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 845 | // T+5ms |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 846 | advanceClocks(1_ms, 4); |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 847 | BOOST_CHECK(!reliability->m_idleAckTimer); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 848 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 849 | lp::Packet pkt3 = makeFrag(3, 100); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 850 | pkt3.add<lp::SequenceField>(3); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 851 | pkt3.add<lp::TxSequenceField>(15); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 852 | BOOST_CHECK(reliability->processIncomingPacket({pkt3})); |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 853 | BOOST_CHECK(reliability->m_idleAckTimer); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 854 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 855 | // T+9ms |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 856 | advanceClocks(1_ms, 4); |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 857 | BOOST_CHECK(reliability->m_idleAckTimer); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 858 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 859 | // T+10ms |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 860 | advanceClocks(1_ms, 1); |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 861 | BOOST_CHECK(!reliability->m_idleAckTimer); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 862 | } |
| 863 | |
| 864 | BOOST_AUTO_TEST_CASE(IdleAckTimer) |
| 865 | { |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 866 | // T+0ms: populate ack queue and start idle ack timer |
| 867 | std::unordered_set<lp::Sequence> expectedAcks; |
| 868 | for (lp::Sequence i = 1000; i < 1500; i++) { |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 869 | reliability->m_ackQueue.push(i); |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 870 | expectedAcks.insert(i); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 871 | } |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 872 | BOOST_CHECK(!reliability->m_idleAckTimer); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 873 | reliability->startIdleAckTimer(); |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 874 | BOOST_CHECK(reliability->m_idleAckTimer); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 875 | |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 876 | // T+4ms: idle ack timer has not yet expired, no IDLE packet generated |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 877 | advanceClocks(1_ms, 4); |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 878 | BOOST_CHECK(reliability->m_idleAckTimer); |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 879 | BOOST_CHECK_EQUAL(reliability->m_ackQueue.size(), 500); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 880 | BOOST_CHECK_EQUAL(reliability->m_ackQueue.front(), 1000); |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 881 | BOOST_CHECK_EQUAL(reliability->m_ackQueue.back(), 1499); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 882 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 0); |
| 883 | |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 884 | // T+5ms: idle ack timer expires, IDLE packet generated |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 885 | advanceClocks(1_ms, 1); |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 886 | BOOST_CHECK(!reliability->m_idleAckTimer); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 887 | BOOST_CHECK_EQUAL(reliability->m_ackQueue.size(), 0); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 888 | BOOST_REQUIRE_EQUAL(transport->sentPackets.size(), 1); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 889 | |
Teng Liang | 13d582a | 2020-07-21 20:23:11 -0700 | [diff] [blame] | 890 | lp::Packet sentPkt(transport->sentPackets.back()); |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 891 | BOOST_CHECK(!sentPkt.has<lp::TxSequenceField>()); |
| 892 | for (lp::Sequence ack : sentPkt.list<lp::AckField>()) { |
| 893 | BOOST_CHECK_EQUAL(expectedAcks.erase(ack), 1); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 894 | } |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 895 | BOOST_CHECK(expectedAcks.empty()); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 896 | } |
| 897 | |
| 898 | BOOST_AUTO_TEST_CASE(IdleAckTimerMtu) |
| 899 | { |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 900 | transport->setMtu(1500); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 901 | |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 902 | // T+0ms: populate ack queue and start idle ack timer |
| 903 | std::unordered_set<lp::Sequence> expectedAcks; |
| 904 | for (lp::Sequence i = 1000; i < 1500; i++) { |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 905 | reliability->m_ackQueue.push(i); |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 906 | expectedAcks.insert(i); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 907 | } |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 908 | BOOST_CHECK(!reliability->m_idleAckTimer); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 909 | reliability->startIdleAckTimer(); |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 910 | BOOST_CHECK(reliability->m_idleAckTimer); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 911 | |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 912 | // T+4ms: idle ack timer has not yet expired, no IDLE packet generated |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 913 | advanceClocks(1_ms, 4); |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 914 | BOOST_CHECK(reliability->m_idleAckTimer); |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 915 | BOOST_CHECK_EQUAL(reliability->m_ackQueue.size(), 500); |
| 916 | BOOST_CHECK_EQUAL(reliability->m_ackQueue.front(), 1000); |
| 917 | BOOST_CHECK_EQUAL(reliability->m_ackQueue.back(), 1499); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 918 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 0); |
| 919 | |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 920 | // T+5ms: idle ack timer expires, IDLE packets generated |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 921 | advanceClocks(1_ms, 1); |
Davide Pesavento | f190cfa | 2019-07-17 20:14:11 -0400 | [diff] [blame] | 922 | BOOST_CHECK(!reliability->m_idleAckTimer); |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 923 | BOOST_CHECK_EQUAL(reliability->m_ackQueue.size(), 0); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 924 | |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 925 | // MTU is 1500. LpPacket TL occupies 4 octets. Each Ack header is 12 octets. There are room for |
| 926 | // 124 Acks per LpPacket, and it takes 5 LpPackets to carry 500 Acks. |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 927 | BOOST_REQUIRE_EQUAL(transport->sentPackets.size(), 5); |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 928 | for (size_t i = 0; i < 5; i++) { |
Teng Liang | 13d582a | 2020-07-21 20:23:11 -0700 | [diff] [blame] | 929 | lp::Packet sentPkt(transport->sentPackets[i]); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 930 | BOOST_CHECK(!sentPkt.has<lp::TxSequenceField>()); |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 931 | BOOST_CHECK_EQUAL(sentPkt.count<lp::AckField>(), i == 4 ? 4 : 124); |
| 932 | for (lp::Sequence ack : sentPkt.list<lp::AckField>()) { |
| 933 | BOOST_CHECK_EQUAL(expectedAcks.erase(ack), 1); |
| 934 | } |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 935 | } |
| 936 | |
Junxiao Shi | 21e0193 | 2018-04-21 10:39:05 +0000 | [diff] [blame] | 937 | BOOST_CHECK(expectedAcks.empty()); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 938 | } |
| 939 | |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 940 | BOOST_AUTO_TEST_CASE(TrackRecentReceivedLpPackets) |
| 941 | { |
| 942 | lp::Packet pkt1 = makeFrag(1, 100); |
| 943 | pkt1.add<lp::SequenceField>(7); |
| 944 | pkt1.add<lp::TxSequenceField>(12); |
| 945 | BOOST_CHECK(reliability->processIncomingPacket({pkt1})); |
| 946 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqsQueue.size(), 1); |
| 947 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqsQueue.front(), 7); |
| 948 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqs.size(), 1); |
| 949 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqs.count(7), 1); |
| 950 | |
| 951 | // T+500ms |
| 952 | // Estimated RTO starts at 1000ms and we are not adding any measurements, so it should remain |
| 953 | // this value throughout the test case |
| 954 | advanceClocks(500_ms, 1); |
| 955 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqs.size(), 1); |
| 956 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqs.count(7), 1); |
| 957 | lp::Packet pkt2 = makeFrag(1, 100); |
| 958 | pkt2.add<lp::SequenceField>(23); |
| 959 | pkt2.add<lp::TxSequenceField>(13); |
| 960 | BOOST_CHECK(reliability->processIncomingPacket({pkt2})); |
| 961 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqsQueue.size(), 2); |
| 962 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqsQueue.front(), 7); |
| 963 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqs.size(), 2); |
| 964 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqs.count(7), 1); |
| 965 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqs.count(23), 1); |
| 966 | |
| 967 | // T+1250ms |
| 968 | // First received sequence should be removed after next received packet, but second should remain |
| 969 | advanceClocks(750_ms, 1); |
| 970 | lp::Packet pkt3 = makeFrag(1, 100); |
| 971 | pkt3.add<lp::SequenceField>(24); |
| 972 | pkt3.add<lp::TxSequenceField>(14); |
| 973 | BOOST_CHECK(reliability->processIncomingPacket({pkt3})); |
| 974 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqsQueue.size(), 2); |
| 975 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqsQueue.front(), 23); |
| 976 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqs.size(), 2); |
| 977 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqs.count(23), 1); |
| 978 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqs.count(24), 1); |
| 979 | |
| 980 | // T+1750ms |
| 981 | // Second received sequence should be removed |
| 982 | advanceClocks(500_ms, 1); |
| 983 | lp::Packet pkt4 = makeFrag(1, 100); |
| 984 | pkt4.add<lp::SequenceField>(25); |
| 985 | pkt4.add<lp::TxSequenceField>(15); |
| 986 | BOOST_CHECK(reliability->processIncomingPacket({pkt4})); |
| 987 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqsQueue.size(), 2); |
| 988 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqsQueue.front(), 24); |
| 989 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqs.size(), 2); |
| 990 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqs.count(24), 1); |
| 991 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqs.count(25), 1); |
| 992 | } |
| 993 | |
| 994 | BOOST_AUTO_TEST_CASE(DropDuplicateReceivedSequence) |
| 995 | { |
| 996 | Interest interest("/test/prefix"); |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 997 | lp::Packet pkt1; |
| 998 | pkt1.add<lp::FragmentField>({interest.wireEncode().begin(), interest.wireEncode().end()}); |
| 999 | pkt1.add<lp::SequenceField>(7); |
| 1000 | pkt1.add<lp::TxSequenceField>(12); |
| 1001 | BOOST_CHECK(reliability->processIncomingPacket({pkt1})); |
| 1002 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqs.size(), 1); |
| 1003 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqs.count(7), 1); |
| 1004 | |
| 1005 | lp::Packet pkt2; |
| 1006 | pkt2.add<lp::FragmentField>({interest.wireEncode().begin(), interest.wireEncode().end()}); |
| 1007 | pkt2.add<lp::SequenceField>(7); |
| 1008 | pkt2.add<lp::TxSequenceField>(13); |
| 1009 | BOOST_CHECK(!reliability->processIncomingPacket({pkt2})); |
| 1010 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqs.size(), 1); |
| 1011 | BOOST_CHECK_EQUAL(reliability->m_recentRecvSeqs.count(7), 1); |
| 1012 | } |
| 1013 | |
| 1014 | BOOST_AUTO_TEST_CASE(DropDuplicateAckForRetx) |
| 1015 | { |
| 1016 | lp::Packet pkt1 = makeFrag(1024, 50); |
| 1017 | linkService->sendLpPackets({pkt1}); |
| 1018 | |
| 1019 | // Will send out a single fragment |
| 1020 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 1); |
| 1021 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 1); |
| 1022 | lp::Sequence firstTxSeq = reliability->m_firstUnackedFrag->first; |
| 1023 | |
| 1024 | // RTO is initially 1 second, so will time out and retx |
| 1025 | advanceClocks(1250_ms, 1); |
| 1026 | BOOST_CHECK_EQUAL(transport->sentPackets.size(), 2); |
| 1027 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 1); |
| 1028 | |
| 1029 | // Acknowledge first transmission (RTO underestimation) |
| 1030 | // Ack will be dropped because unknown |
| 1031 | lp::Packet ackPkt1; |
| 1032 | ackPkt1.add<lp::AckField>(firstTxSeq); |
| 1033 | reliability->processIncomingPacket(ackPkt1); |
| 1034 | BOOST_REQUIRE_EQUAL(reliability->m_unackedFrags.size(), 1); // Required because collection used below |
| 1035 | |
| 1036 | // Acknowledge second transmission |
| 1037 | // Ack will acknowledge retx and remove unacked frag |
| 1038 | lp::Packet ackPkt2; |
| 1039 | ackPkt2.add<lp::AckField>(reliability->m_firstUnackedFrag->first); |
| 1040 | reliability->processIncomingPacket(ackPkt2); |
| 1041 | BOOST_CHECK_EQUAL(reliability->m_unackedFrags.size(), 0); |
| 1042 | } |
| 1043 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame] | 1044 | BOOST_AUTO_TEST_SUITE_END() // TestLpReliability |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 1045 | BOOST_AUTO_TEST_SUITE_END() // Face |
| 1046 | |
| 1047 | } // namespace tests |
| 1048 | } // namespace face |
| 1049 | } // namespace nfd |