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