OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "net/quic/congestion_control/tcp_loss_algorithm.h" |
| 6 |
| 7 #include "net/quic/quic_protocol.h" |
| 8 |
| 9 namespace net { |
| 10 |
| 11 namespace { |
| 12 // TCP retransmits after 3 nacks. |
| 13 static const size_t kNumberOfNacksBeforeRetransmission = 3; |
| 14 } |
| 15 |
| 16 TCPLossAlgorithm::TCPLossAlgorithm() { } |
| 17 |
| 18 // Uses nack counts to decide when packets are lost. |
| 19 SequenceNumberSet TCPLossAlgorithm::DetectLostPackets( |
| 20 const QuicUnackedPacketMap& unacked_packets, |
| 21 const QuicTime& time, |
| 22 QuicPacketSequenceNumber largest_observed, |
| 23 QuicTime::Delta srtt) { |
| 24 SequenceNumberSet lost_packets; |
| 25 |
| 26 for (QuicUnackedPacketMap::const_iterator it = unacked_packets.begin(); |
| 27 it != unacked_packets.end() && it->first <= largest_observed; ++it) { |
| 28 if (!it->second.pending) { |
| 29 continue; |
| 30 } |
| 31 size_t num_nacks_needed = kNumberOfNacksBeforeRetransmission; |
| 32 // Check for early retransmit(RFC5827) when the last packet gets acked and |
| 33 // the there are fewer than 4 pending packets. |
| 34 // TODO(ianswett): Set a retransmission timer instead of losing the packet |
| 35 // and retransmitting immediately. |
| 36 if (it->second.retransmittable_frames && |
| 37 unacked_packets.largest_sent_packet() == largest_observed) { |
| 38 num_nacks_needed = largest_observed - it->first; |
| 39 } |
| 40 |
| 41 if (it->second.nack_count < num_nacks_needed) { |
| 42 continue; |
| 43 } |
| 44 |
| 45 lost_packets.insert(it->first); |
| 46 } |
| 47 |
| 48 return lost_packets; |
| 49 } |
| 50 |
| 51 } // namespace net |
OLD | NEW |