OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/core/congestion_control/general_loss_algorithm.h" | 5 #include "net/quic/core/congestion_control/general_loss_algorithm.h" |
6 | 6 |
7 #include "net/quic/core/congestion_control/rtt_stats.h" | 7 #include "net/quic/core/congestion_control/rtt_stats.h" |
8 #include "net/quic/core/quic_flags.h" | 8 #include "net/quic/core/quic_flags.h" |
9 #include "net/quic/core/quic_packets.h" | 9 #include "net/quic/core/quic_packets.h" |
10 #include "net/quic/platform/api/quic_bug_tracker.h" | 10 #include "net/quic/platform/api/quic_bug_tracker.h" |
| 11 #include "net/quic/platform/api/quic_flag_utils.h" |
11 | 12 |
12 namespace net { | 13 namespace net { |
13 | 14 |
14 namespace { | 15 namespace { |
15 | 16 |
16 // The minimum delay before a packet will be considered lost, | 17 // The minimum delay before a packet will be considered lost, |
17 // regardless of SRTT. Half of the minimum TLP, since the loss algorithm only | 18 // regardless of SRTT. Half of the minimum TLP, since the loss algorithm only |
18 // triggers when a nack has been receieved for the packet. | 19 // triggers when a nack has been receieved for the packet. |
19 static const size_t kMinLossDelayMs = 5; | 20 static const size_t kMinLossDelayMs = 5; |
20 | 21 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 } | 128 } |
128 | 129 |
129 void GeneralLossAlgorithm::SpuriousRetransmitDetected( | 130 void GeneralLossAlgorithm::SpuriousRetransmitDetected( |
130 const QuicUnackedPacketMap& unacked_packets, | 131 const QuicUnackedPacketMap& unacked_packets, |
131 QuicTime time, | 132 QuicTime time, |
132 const RttStats& rtt_stats, | 133 const RttStats& rtt_stats, |
133 QuicPacketNumber spurious_retransmission) { | 134 QuicPacketNumber spurious_retransmission) { |
134 if (loss_type_ != kAdaptiveTime || reordering_shift_ == 0) { | 135 if (loss_type_ != kAdaptiveTime || reordering_shift_ == 0) { |
135 return; | 136 return; |
136 } | 137 } |
137 if (spurious_retransmission <= largest_sent_on_spurious_retransmit_) { | |
138 return; | |
139 } | |
140 largest_sent_on_spurious_retransmit_ = unacked_packets.largest_sent_packet(); | |
141 // Calculate the extra time needed so this wouldn't have been declared lost. | 138 // Calculate the extra time needed so this wouldn't have been declared lost. |
142 // Extra time needed is based on how long it's been since the spurious | 139 // Extra time needed is based on how long it's been since the spurious |
143 // retransmission was sent, because the SRTT and latest RTT may have changed. | 140 // retransmission was sent, because the SRTT and latest RTT may have changed. |
144 QuicTime::Delta extra_time_needed = | 141 QuicTime::Delta extra_time_needed = |
145 time - | 142 time - |
146 unacked_packets.GetTransmissionInfo(spurious_retransmission).sent_time; | 143 unacked_packets.GetTransmissionInfo(spurious_retransmission).sent_time; |
147 // Increase the reordering fraction until enough time would be allowed. | 144 // Increase the reordering fraction until enough time would be allowed. |
148 QuicTime::Delta max_rtt = | 145 QuicTime::Delta max_rtt = |
149 std::max(rtt_stats.previous_srtt(), rtt_stats.latest_rtt()); | 146 std::max(rtt_stats.previous_srtt(), rtt_stats.latest_rtt()); |
| 147 if (FLAGS_quic_reloadable_flag_quic_fix_adaptive_time_loss) { |
| 148 QUIC_FLAG_COUNT(quic_reloadable_flag_quic_fix_adaptive_time_loss); |
| 149 while ((max_rtt >> reordering_shift_) <= extra_time_needed && |
| 150 reordering_shift_ > 0) { |
| 151 --reordering_shift_; |
| 152 } |
| 153 return; |
| 154 } |
| 155 |
| 156 if (spurious_retransmission <= largest_sent_on_spurious_retransmit_) { |
| 157 return; |
| 158 } |
| 159 largest_sent_on_spurious_retransmit_ = unacked_packets.largest_sent_packet(); |
150 QuicTime::Delta proposed_extra_time(QuicTime::Delta::Zero()); | 160 QuicTime::Delta proposed_extra_time(QuicTime::Delta::Zero()); |
151 do { | 161 do { |
152 proposed_extra_time = max_rtt >> reordering_shift_; | 162 proposed_extra_time = max_rtt >> reordering_shift_; |
153 --reordering_shift_; | 163 --reordering_shift_; |
154 } while (proposed_extra_time < extra_time_needed && reordering_shift_ > 0); | 164 } while (proposed_extra_time < extra_time_needed && reordering_shift_ > 0); |
155 } | 165 } |
156 | 166 |
157 } // namespace net | 167 } // namespace net |
OLD | NEW |