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