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