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