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