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 "lp-reliability.hpp" |
| 27 | #include "generic-link-service.hpp" |
| 28 | #include "transport.hpp" |
| 29 | |
| 30 | namespace nfd { |
| 31 | namespace face { |
| 32 | |
| 33 | LpReliability::LpReliability(const LpReliability::Options& options, GenericLinkService* linkService) |
| 34 | : m_options(options) |
| 35 | , m_linkService(linkService) |
| 36 | , m_firstUnackedFrag(m_unackedFrags.begin()) |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 37 | , m_lastTxSeqNo(-1) // set to "-1" to start TxSequence numbers at 0 |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 38 | , m_isIdleAckTimerRunning(false) |
| 39 | { |
| 40 | BOOST_ASSERT(m_linkService != nullptr); |
| 41 | |
| 42 | BOOST_ASSERT(m_options.idleAckTimerPeriod > time::nanoseconds::zero()); |
| 43 | } |
| 44 | |
| 45 | void |
| 46 | LpReliability::setOptions(const Options& options) |
| 47 | { |
| 48 | BOOST_ASSERT(options.idleAckTimerPeriod > time::nanoseconds::zero()); |
| 49 | |
| 50 | if (m_options.isEnabled && !options.isEnabled) { |
| 51 | this->stopIdleAckTimer(); |
| 52 | } |
| 53 | |
| 54 | m_options = options; |
| 55 | } |
| 56 | |
| 57 | const GenericLinkService* |
| 58 | LpReliability::getLinkService() const |
| 59 | { |
| 60 | return m_linkService; |
| 61 | } |
| 62 | |
| 63 | void |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 64 | LpReliability::handleOutgoing(std::vector<lp::Packet>& frags) |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 65 | { |
| 66 | BOOST_ASSERT(m_options.isEnabled); |
| 67 | |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 68 | auto unackedFragsIt = m_unackedFrags.begin(); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 69 | auto sendTime = time::steady_clock::now(); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 70 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 71 | auto netPkt = make_shared<NetPkt>(); |
| 72 | netPkt->unackedFrags.reserve(frags.size()); |
| 73 | |
| 74 | for (lp::Packet& frag : frags) { |
| 75 | // Assign TxSequence number |
| 76 | lp::Sequence txSeq = assignTxSequence(frag); |
| 77 | |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 78 | // Store LpPacket for future retransmissions |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 79 | unackedFragsIt = m_unackedFrags.emplace_hint(unackedFragsIt, |
| 80 | std::piecewise_construct, |
| 81 | std::forward_as_tuple(txSeq), |
| 82 | std::forward_as_tuple(frag)); |
| 83 | unackedFragsIt->second.sendTime = sendTime; |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 84 | unackedFragsIt->second.rtoTimer = |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 85 | scheduler::schedule(m_rto.computeRto(), bind(&LpReliability::onLpPacketLost, this, unackedFragsIt)); |
| 86 | unackedFragsIt->second.netPkt = netPkt; |
| 87 | |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 88 | if (m_unackedFrags.size() == 1) { |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 89 | m_firstUnackedFrag = m_unackedFrags.begin(); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 90 | } |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 91 | |
| 92 | // Add to associated NetPkt |
| 93 | netPkt->unackedFrags.push_back(unackedFragsIt); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 94 | } |
| 95 | } |
| 96 | |
| 97 | void |
| 98 | LpReliability::processIncomingPacket(const lp::Packet& pkt) |
| 99 | { |
| 100 | BOOST_ASSERT(m_options.isEnabled); |
| 101 | |
| 102 | auto now = time::steady_clock::now(); |
| 103 | |
| 104 | // Extract and parse Acks |
| 105 | for (lp::Sequence ackSeq : pkt.list<lp::AckField>()) { |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 106 | auto fragIt = m_unackedFrags.find(ackSeq); |
| 107 | if (fragIt == m_unackedFrags.end()) { |
| 108 | // Ignore an Ack for an unknown TxSequence number |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 109 | continue; |
| 110 | } |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 111 | auto& frag = fragIt->second; |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 112 | |
| 113 | // Cancel the RTO timer for the acknowledged fragment |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 114 | frag.rtoTimer.cancel(); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 115 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 116 | if (frag.retxCount == 0) { |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 117 | // This sequence had no retransmissions, so use it to calculate the RTO |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 118 | m_rto.addMeasurement(time::duration_cast<RttEstimator::Duration>(now - frag.sendTime)); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 119 | } |
| 120 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 121 | // Look for frags with TxSequence numbers < ackSeq (allowing for wraparound) and consider them |
| 122 | // lost if a configurable number of Acks containing greater TxSequence numbers have been |
| 123 | // received. |
| 124 | auto lostLpPackets = findLostLpPackets(fragIt); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 125 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 126 | // Remove the fragment from the map of unacknowledged fragments and from its associated network |
| 127 | // packet. Potentially increment the start of the window. |
| 128 | onLpPacketAcknowledged(fragIt); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 129 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 130 | // Resend or fail fragments considered lost. Potentially increment the start of the window. |
| 131 | for (UnackedFrags::iterator txSeqIt : lostLpPackets) { |
| 132 | this->onLpPacketLost(txSeqIt); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 133 | } |
| 134 | } |
| 135 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 136 | // If packet has Fragment and TxSequence fields, extract TxSequence and add to AckQueue |
| 137 | if (pkt.has<lp::FragmentField>() && pkt.has<lp::TxSequenceField>()) { |
| 138 | m_ackQueue.push(pkt.get<lp::TxSequenceField>()); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 139 | if (!m_isIdleAckTimerRunning) { |
| 140 | this->startIdleAckTimer(); |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | void |
| 146 | LpReliability::piggyback(lp::Packet& pkt, ssize_t mtu) |
| 147 | { |
| 148 | BOOST_ASSERT(m_options.isEnabled); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 149 | BOOST_ASSERT(pkt.wireEncode().type() == lp::tlv::LpPacket); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 150 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 151 | // up to 2 extra octets reserved for potential TLV-LENGTH size increases |
| 152 | ssize_t pktSize = pkt.wireEncode().size(); |
| 153 | ssize_t reservedSpace = tlv::sizeOfVarNumber(ndn::MAX_NDN_PACKET_SIZE) - |
| 154 | tlv::sizeOfVarNumber(pktSize); |
| 155 | ssize_t remainingSpace = (mtu == MTU_UNLIMITED ? ndn::MAX_NDN_PACKET_SIZE : mtu) - reservedSpace; |
| 156 | remainingSpace -= pktSize; |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 157 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 158 | while (!m_ackQueue.empty()) { |
| 159 | lp::Sequence ackSeq = m_ackQueue.front(); |
| 160 | // Ack Size = Ack Type (3 octets) + Ack Length (1 octet) + Value (1, 2, 4, or 8 octets) |
| 161 | ssize_t ackSize = tlv::sizeOfVarNumber(lp::tlv::Ack) + |
| 162 | tlv::sizeOfVarNumber( |
| 163 | tlv::sizeOfNonNegativeInteger(std::numeric_limits<lp::Sequence>::max())) + |
| 164 | tlv::sizeOfNonNegativeInteger(ackSeq); |
| 165 | |
| 166 | if (ackSize > remainingSpace) { |
| 167 | break; |
| 168 | } |
| 169 | |
| 170 | pkt.add<lp::AckField>(ackSeq); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 171 | m_ackQueue.pop(); |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 172 | remainingSpace -= ackSize; |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 173 | } |
| 174 | } |
| 175 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 176 | lp::Sequence |
| 177 | LpReliability::assignTxSequence(lp::Packet& frag) |
| 178 | { |
| 179 | lp::Sequence txSeq = ++m_lastTxSeqNo; |
| 180 | frag.set<lp::TxSequenceField>(txSeq); |
| 181 | if (m_unackedFrags.size() > 0 && m_lastTxSeqNo == m_firstUnackedFrag->first) { |
| 182 | BOOST_THROW_EXCEPTION(std::length_error("TxSequence range exceeded")); |
| 183 | } |
| 184 | return m_lastTxSeqNo; |
| 185 | } |
| 186 | |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 187 | void |
| 188 | LpReliability::startIdleAckTimer() |
| 189 | { |
| 190 | BOOST_ASSERT(!m_isIdleAckTimerRunning); |
| 191 | m_isIdleAckTimerRunning = true; |
| 192 | |
| 193 | m_idleAckTimer = scheduler::schedule(m_options.idleAckTimerPeriod, [this] { |
| 194 | while (!m_ackQueue.empty()) { |
| 195 | m_linkService->requestIdlePacket(); |
| 196 | } |
| 197 | |
| 198 | m_isIdleAckTimerRunning = false; |
| 199 | }); |
| 200 | } |
| 201 | |
| 202 | void |
| 203 | LpReliability::stopIdleAckTimer() |
| 204 | { |
| 205 | m_idleAckTimer.cancel(); |
| 206 | m_isIdleAckTimerRunning = false; |
| 207 | } |
| 208 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 209 | std::vector<LpReliability::UnackedFrags::iterator> |
| 210 | LpReliability::findLostLpPackets(LpReliability::UnackedFrags::iterator ackIt) |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 211 | { |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 212 | std::vector<UnackedFrags::iterator> lostLpPackets; |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 213 | |
| 214 | for (auto it = m_firstUnackedFrag; ; ++it) { |
| 215 | if (it == m_unackedFrags.end()) { |
| 216 | it = m_unackedFrags.begin(); |
| 217 | } |
| 218 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 219 | if (it->first == ackIt->first) { |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 220 | break; |
| 221 | } |
| 222 | |
| 223 | auto& unackedFrag = it->second; |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 224 | unackedFrag.nGreaterSeqAcks++; |
| 225 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 226 | if (unackedFrag.nGreaterSeqAcks >= m_options.seqNumLossThreshold) { |
| 227 | lostLpPackets.push_back(it); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 228 | } |
| 229 | } |
| 230 | |
| 231 | return lostLpPackets; |
| 232 | } |
| 233 | |
| 234 | void |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 235 | LpReliability::onLpPacketLost(UnackedFrags::iterator txSeqIt) |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 236 | { |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 237 | BOOST_ASSERT(m_unackedFrags.count(txSeqIt->first) > 0); |
| 238 | |
| 239 | auto& txFrag = txSeqIt->second; |
| 240 | txFrag.rtoTimer.cancel(); |
| 241 | auto netPkt = txFrag.netPkt; |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 242 | |
| 243 | // Check if maximum number of retransmissions exceeded |
| 244 | if (txFrag.retxCount >= m_options.maxRetx) { |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 245 | // Delete all LpPackets of NetPkt from m_unackedFrags (except this one) |
| 246 | for (size_t i = 0; i < netPkt->unackedFrags.size(); i++) { |
| 247 | if (netPkt->unackedFrags[i] != txSeqIt) { |
| 248 | deleteUnackedFrag(netPkt->unackedFrags[i]); |
| 249 | } |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 250 | } |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 251 | |
| 252 | ++m_linkService->nRetxExhausted; |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 253 | deleteUnackedFrag(txSeqIt); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 254 | } |
| 255 | else { |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 256 | // Assign new TxSequence |
| 257 | lp::Sequence newTxSeq = assignTxSequence(txFrag.pkt); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 258 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 259 | // Move fragment to new TxSequence mapping |
| 260 | auto newTxFragIt = m_unackedFrags.emplace_hint( |
| 261 | m_firstUnackedFrag != m_unackedFrags.end() && m_firstUnackedFrag->first > newTxSeq |
| 262 | ? m_firstUnackedFrag |
| 263 | : m_unackedFrags.end(), |
| 264 | std::piecewise_construct, |
| 265 | std::forward_as_tuple(newTxSeq), |
| 266 | std::forward_as_tuple(txFrag.pkt)); |
| 267 | auto& newTxFrag = newTxFragIt->second; |
| 268 | newTxFrag.retxCount = txFrag.retxCount + 1; |
| 269 | newTxFrag.netPkt = netPkt; |
| 270 | |
| 271 | // Update associated NetPkt |
| 272 | auto fragInNetPkt = std::find(netPkt->unackedFrags.begin(), netPkt->unackedFrags.end(), txSeqIt); |
| 273 | BOOST_ASSERT(fragInNetPkt != netPkt->unackedFrags.end()); |
| 274 | *fragInNetPkt = newTxFragIt; |
| 275 | |
| 276 | deleteUnackedFrag(txSeqIt); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 277 | |
| 278 | // Retransmit fragment |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 279 | m_linkService->sendLpPacket(lp::Packet(newTxFrag.pkt)); |
| 280 | |
| 281 | // Start RTO timer for this sequence |
| 282 | newTxFrag.rtoTimer = scheduler::schedule(m_rto.computeRto(), |
| 283 | bind(&LpReliability::onLpPacketLost, this, newTxFragIt)); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 284 | } |
| 285 | } |
| 286 | |
| 287 | void |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 288 | LpReliability::onLpPacketAcknowledged(UnackedFrags::iterator fragIt) |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 289 | { |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 290 | auto netPkt = fragIt->second.netPkt; |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 291 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 292 | // Remove from NetPkt unacked fragment list |
| 293 | auto fragInNetPkt = std::find(netPkt->unackedFrags.begin(), netPkt->unackedFrags.end(), fragIt); |
| 294 | BOOST_ASSERT(fragInNetPkt != netPkt->unackedFrags.end()); |
| 295 | *fragInNetPkt = netPkt->unackedFrags.back(); |
| 296 | netPkt->unackedFrags.pop_back(); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 297 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 298 | // Check if network-layer packet completely received. If so, increment counters |
| 299 | if (netPkt->unackedFrags.empty()) { |
| 300 | if (netPkt->didRetx) { |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 301 | ++m_linkService->nRetransmitted; |
| 302 | } |
| 303 | else { |
| 304 | ++m_linkService->nAcknowledged; |
| 305 | } |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 306 | } |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 307 | |
| 308 | deleteUnackedFrag(fragIt); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 309 | } |
| 310 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 311 | void |
| 312 | LpReliability::deleteUnackedFrag(UnackedFrags::iterator fragIt) |
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 | lp::Sequence firstUnackedTxSeq = m_firstUnackedFrag->first; |
| 315 | lp::Sequence currentTxSeq = fragIt->first; |
| 316 | auto nextFragIt = m_unackedFrags.erase(fragIt); |
| 317 | |
| 318 | if (!m_unackedFrags.empty() && firstUnackedTxSeq == currentTxSeq) { |
| 319 | // If "first" fragment in send window (allowing for wraparound), increment window begin |
| 320 | if (nextFragIt == m_unackedFrags.end()) { |
| 321 | m_firstUnackedFrag = m_unackedFrags.begin(); |
| 322 | } |
| 323 | else { |
| 324 | m_firstUnackedFrag = nextFragIt; |
| 325 | } |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 326 | } |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 327 | else if (m_unackedFrags.empty()) { |
| 328 | m_firstUnackedFrag = m_unackedFrags.end(); |
| 329 | } |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | LpReliability::UnackedFrag::UnackedFrag(lp::Packet pkt) |
| 333 | : pkt(std::move(pkt)) |
| 334 | , sendTime(time::steady_clock::now()) |
| 335 | , retxCount(0) |
| 336 | , nGreaterSeqAcks(0) |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 337 | { |
| 338 | } |
| 339 | |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 340 | } // namespace face |
| 341 | } // namespace nfd |