OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/quic/congestion_control/tcp_loss_algorithm.h" | 5 #include "net/quic/congestion_control/tcp_loss_algorithm.h" |
6 | 6 |
| 7 #include "net/quic/congestion_control/rtt_stats.h" |
7 #include "net/quic/quic_protocol.h" | 8 #include "net/quic/quic_protocol.h" |
8 | 9 |
9 namespace net { | 10 namespace net { |
10 | 11 |
11 namespace { | 12 namespace { |
12 | 13 |
13 // TCP retransmits after 3 nacks. | 14 // TCP retransmits after 3 nacks. |
14 static const size_t kNumberOfNacksBeforeRetransmission = 3; | 15 static const size_t kNumberOfNacksBeforeRetransmission = 3; |
15 | 16 |
16 // How many RTTs the algorithm waits before determining a packet is lost due | 17 // How many RTTs the algorithm waits before determining a packet is lost due |
17 // to early retransmission. | 18 // to early retransmission. |
18 static const double kEarlyRetransmitLossDelayMultiplier = 1.25; | 19 static const double kEarlyRetransmitLossDelayMultiplier = 1.25; |
19 | 20 |
20 } | 21 } |
21 | 22 |
22 TCPLossAlgorithm::TCPLossAlgorithm() | 23 TCPLossAlgorithm::TCPLossAlgorithm() |
23 : loss_detection_timeout_(QuicTime::Zero()) { } | 24 : loss_detection_timeout_(QuicTime::Zero()) { } |
24 | 25 |
25 // Uses nack counts to decide when packets are lost. | 26 // Uses nack counts to decide when packets are lost. |
26 SequenceNumberSet TCPLossAlgorithm::DetectLostPackets( | 27 SequenceNumberSet TCPLossAlgorithm::DetectLostPackets( |
27 const QuicUnackedPacketMap& unacked_packets, | 28 const QuicUnackedPacketMap& unacked_packets, |
28 const QuicTime& time, | 29 const QuicTime& time, |
29 QuicPacketSequenceNumber largest_observed, | 30 QuicPacketSequenceNumber largest_observed, |
30 QuicTime::Delta srtt, | 31 const RttStats& rtt_stats) { |
31 QuicTime::Delta latest_rtt) { | |
32 SequenceNumberSet lost_packets; | 32 SequenceNumberSet lost_packets; |
33 loss_detection_timeout_ = QuicTime::Zero(); | 33 loss_detection_timeout_ = QuicTime::Zero(); |
34 QuicTime::Delta loss_delay = | 34 QuicTime::Delta loss_delay = |
35 srtt.Multiply(kEarlyRetransmitLossDelayMultiplier); | 35 rtt_stats.SmoothedRtt().Multiply(kEarlyRetransmitLossDelayMultiplier); |
36 | 36 |
37 for (QuicUnackedPacketMap::const_iterator it = unacked_packets.begin(); | 37 for (QuicUnackedPacketMap::const_iterator it = unacked_packets.begin(); |
38 it != unacked_packets.end() && it->first <= largest_observed; ++it) { | 38 it != unacked_packets.end() && it->first <= largest_observed; ++it) { |
39 if (!it->second.pending) { | 39 if (!it->second.pending) { |
40 continue; | 40 continue; |
41 } | 41 } |
42 | 42 |
43 LOG_IF(DFATAL, it->second.nack_count == 0) | 43 LOG_IF(DFATAL, it->second.nack_count == 0) |
44 << "All packets less than largest observed should have been nacked."; | 44 << "All packets less than largest observed should have been nacked."; |
45 if (it->second.nack_count >= kNumberOfNacksBeforeRetransmission) { | 45 if (it->second.nack_count >= kNumberOfNacksBeforeRetransmission) { |
(...skipping 20 matching lines...) Expand all Loading... |
66 } | 66 } |
67 | 67 |
68 return lost_packets; | 68 return lost_packets; |
69 } | 69 } |
70 | 70 |
71 QuicTime TCPLossAlgorithm::GetLossTimeout() const { | 71 QuicTime TCPLossAlgorithm::GetLossTimeout() const { |
72 return loss_detection_timeout_; | 72 return loss_detection_timeout_; |
73 } | 73 } |
74 | 74 |
75 } // namespace net | 75 } // namespace net |
OLD | NEW |