OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_cubic_sender.h" | 5 #include "net/quic/congestion_control/tcp_cubic_sender.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "net/quic/congestion_control/prr_sender.h" | 10 #include "net/quic/congestion_control/prr_sender.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 largest_sent_packet_number_(0), | 43 largest_sent_packet_number_(0), |
44 largest_acked_packet_number_(0), | 44 largest_acked_packet_number_(0), |
45 largest_sent_at_last_cutback_(0), | 45 largest_sent_at_last_cutback_(0), |
46 congestion_window_(initial_tcp_congestion_window), | 46 congestion_window_(initial_tcp_congestion_window), |
47 min_congestion_window_(kDefaultMinimumCongestionWindow), | 47 min_congestion_window_(kDefaultMinimumCongestionWindow), |
48 min4_mode_(false), | 48 min4_mode_(false), |
49 slowstart_threshold_(max_tcp_congestion_window), | 49 slowstart_threshold_(max_tcp_congestion_window), |
50 last_cutback_exited_slowstart_(false), | 50 last_cutback_exited_slowstart_(false), |
51 max_tcp_congestion_window_(max_tcp_congestion_window), | 51 max_tcp_congestion_window_(max_tcp_congestion_window), |
52 initial_tcp_congestion_window_(initial_tcp_congestion_window), | 52 initial_tcp_congestion_window_(initial_tcp_congestion_window), |
53 initial_max_tcp_congestion_window_(max_tcp_congestion_window) {} | 53 initial_max_tcp_congestion_window_(max_tcp_congestion_window), |
| 54 slow_start_large_reduction_(false) {} |
54 | 55 |
55 TcpCubicSender::~TcpCubicSender() { | 56 TcpCubicSender::~TcpCubicSender() { |
56 UMA_HISTOGRAM_COUNTS("Net.QuicSession.FinalTcpCwnd", congestion_window_); | 57 UMA_HISTOGRAM_COUNTS("Net.QuicSession.FinalTcpCwnd", congestion_window_); |
57 } | 58 } |
58 | 59 |
59 void TcpCubicSender::SetFromConfig(const QuicConfig& config, | 60 void TcpCubicSender::SetFromConfig(const QuicConfig& config, |
60 Perspective perspective) { | 61 Perspective perspective) { |
61 if (perspective == Perspective::IS_SERVER) { | 62 if (perspective == Perspective::IS_SERVER) { |
62 if (config.HasReceivedConnectionOptions() && | 63 if (config.HasReceivedConnectionOptions() && |
63 ContainsQuicTag(config.ReceivedConnectionOptions(), kIW03)) { | 64 ContainsQuicTag(config.ReceivedConnectionOptions(), kIW03)) { |
(...skipping 19 matching lines...) Expand all Loading... |
83 ContainsQuicTag(config.ReceivedConnectionOptions(), kMIN1)) { | 84 ContainsQuicTag(config.ReceivedConnectionOptions(), kMIN1)) { |
84 // Min CWND experiment. | 85 // Min CWND experiment. |
85 min_congestion_window_ = 1; | 86 min_congestion_window_ = 1; |
86 } | 87 } |
87 if (config.HasReceivedConnectionOptions() && | 88 if (config.HasReceivedConnectionOptions() && |
88 ContainsQuicTag(config.ReceivedConnectionOptions(), kMIN4)) { | 89 ContainsQuicTag(config.ReceivedConnectionOptions(), kMIN4)) { |
89 // Min CWND of 4 experiment. | 90 // Min CWND of 4 experiment. |
90 min4_mode_ = true; | 91 min4_mode_ = true; |
91 min_congestion_window_ = 1; | 92 min_congestion_window_ = 1; |
92 } | 93 } |
| 94 if (config.HasReceivedConnectionOptions() && |
| 95 ContainsQuicTag(config.ReceivedConnectionOptions(), kSSLR)) { |
| 96 // Slow Start Fast Exit experiment. |
| 97 slow_start_large_reduction_ = true; |
| 98 } |
93 } | 99 } |
94 } | 100 } |
95 | 101 |
96 void TcpCubicSender::ResumeConnectionState( | 102 void TcpCubicSender::ResumeConnectionState( |
97 const CachedNetworkParameters& cached_network_params, | 103 const CachedNetworkParameters& cached_network_params, |
98 bool max_bandwidth_resumption) { | 104 bool max_bandwidth_resumption) { |
99 QuicBandwidth bandwidth = QuicBandwidth::FromBytesPerSecond( | 105 QuicBandwidth bandwidth = QuicBandwidth::FromBytesPerSecond( |
100 max_bandwidth_resumption | 106 max_bandwidth_resumption |
101 ? cached_network_params.max_bandwidth_estimate_bytes_per_second() | 107 ? cached_network_params.max_bandwidth_estimate_bytes_per_second() |
102 : cached_network_params.bandwidth_estimate_bytes_per_second()); | 108 : cached_network_params.bandwidth_estimate_bytes_per_second()); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 hybrid_slow_start_.OnPacketAcked(acked_packet_number, InSlowStart()); | 169 hybrid_slow_start_.OnPacketAcked(acked_packet_number, InSlowStart()); |
164 } | 170 } |
165 | 171 |
166 void TcpCubicSender::OnPacketLost(QuicPacketNumber packet_number, | 172 void TcpCubicSender::OnPacketLost(QuicPacketNumber packet_number, |
167 QuicByteCount bytes_in_flight) { | 173 QuicByteCount bytes_in_flight) { |
168 // TCP NewReno (RFC6582) says that once a loss occurs, any losses in packets | 174 // TCP NewReno (RFC6582) says that once a loss occurs, any losses in packets |
169 // already sent should be treated as a single loss event, since it's expected. | 175 // already sent should be treated as a single loss event, since it's expected. |
170 if (packet_number <= largest_sent_at_last_cutback_) { | 176 if (packet_number <= largest_sent_at_last_cutback_) { |
171 if (last_cutback_exited_slowstart_) { | 177 if (last_cutback_exited_slowstart_) { |
172 ++stats_->slowstart_packets_lost; | 178 ++stats_->slowstart_packets_lost; |
| 179 if (slow_start_large_reduction_) { |
| 180 // Reduce congestion window by 1 for every loss. |
| 181 congestion_window_ = |
| 182 max(congestion_window_ - 1, min_congestion_window_); |
| 183 slowstart_threshold_ = congestion_window_; |
| 184 } |
173 } | 185 } |
174 DVLOG(1) << "Ignoring loss for largest_missing:" << packet_number | 186 DVLOG(1) << "Ignoring loss for largest_missing:" << packet_number |
175 << " because it was sent prior to the last CWND cutback."; | 187 << " because it was sent prior to the last CWND cutback."; |
176 return; | 188 return; |
177 } | 189 } |
178 ++stats_->tcp_loss_events; | 190 ++stats_->tcp_loss_events; |
179 last_cutback_exited_slowstart_ = InSlowStart(); | 191 last_cutback_exited_slowstart_ = InSlowStart(); |
180 if (InSlowStart()) { | 192 if (InSlowStart()) { |
181 ++stats_->slowstart_packets_lost; | 193 ++stats_->slowstart_packets_lost; |
182 } | 194 } |
183 | 195 |
184 prr_.OnPacketLost(bytes_in_flight); | 196 prr_.OnPacketLost(bytes_in_flight); |
185 | 197 |
186 if (reno_) { | 198 // TODO(jri): Separate out all of slow start into a separate class. |
| 199 if (slow_start_large_reduction_) { |
| 200 DCHECK_LT(1u, congestion_window_); |
| 201 congestion_window_ = congestion_window_ - 1; |
| 202 } else if (reno_) { |
187 congestion_window_ = congestion_window_ * RenoBeta(); | 203 congestion_window_ = congestion_window_ * RenoBeta(); |
188 } else { | 204 } else { |
189 congestion_window_ = | 205 congestion_window_ = |
190 cubic_.CongestionWindowAfterPacketLoss(congestion_window_); | 206 cubic_.CongestionWindowAfterPacketLoss(congestion_window_); |
191 } | 207 } |
192 slowstart_threshold_ = congestion_window_; | |
193 // Enforce a minimum congestion window. | 208 // Enforce a minimum congestion window. |
194 if (congestion_window_ < min_congestion_window_) { | 209 if (congestion_window_ < min_congestion_window_) { |
195 congestion_window_ = min_congestion_window_; | 210 congestion_window_ = min_congestion_window_; |
196 } | 211 } |
| 212 slowstart_threshold_ = congestion_window_; |
197 largest_sent_at_last_cutback_ = largest_sent_packet_number_; | 213 largest_sent_at_last_cutback_ = largest_sent_packet_number_; |
198 // reset packet count from congestion avoidance mode. We start | 214 // reset packet count from congestion avoidance mode. We start |
199 // counting again when we're out of recovery. | 215 // counting again when we're out of recovery. |
200 congestion_window_count_ = 0; | 216 congestion_window_count_ = 0; |
201 DVLOG(1) << "Incoming loss; congestion window: " << congestion_window_ | 217 DVLOG(1) << "Incoming loss; congestion window: " << congestion_window_ |
202 << " slowstart threshold: " << slowstart_threshold_; | 218 << " slowstart threshold: " << slowstart_threshold_; |
203 } | 219 } |
204 | 220 |
205 bool TcpCubicSender::OnPacketSent(QuicTime /*sent_time*/, | 221 bool TcpCubicSender::OnPacketSent(QuicTime /*sent_time*/, |
206 QuicByteCount /*bytes_in_flight*/, | 222 QuicByteCount /*bytes_in_flight*/, |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 slowstart_threshold_ = initial_max_tcp_congestion_window_; | 390 slowstart_threshold_ = initial_max_tcp_congestion_window_; |
375 last_cutback_exited_slowstart_ = false; | 391 last_cutback_exited_slowstart_ = false; |
376 max_tcp_congestion_window_ = initial_max_tcp_congestion_window_; | 392 max_tcp_congestion_window_ = initial_max_tcp_congestion_window_; |
377 } | 393 } |
378 | 394 |
379 CongestionControlType TcpCubicSender::GetCongestionControlType() const { | 395 CongestionControlType TcpCubicSender::GetCongestionControlType() const { |
380 return reno_ ? kReno : kCubic; | 396 return reno_ ? kReno : kCubic; |
381 } | 397 } |
382 | 398 |
383 } // namespace net | 399 } // namespace net |
OLD | NEW |