OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/congestion_control/tcp_cubic_bytes_sender.h" | 5 #include "net/quic/congestion_control/tcp_cubic_bytes_sender.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "net/quic/congestion_control/prr_sender.h" | 9 #include "net/quic/congestion_control/prr_sender.h" |
10 #include "net/quic/congestion_control/rtt_stats.h" | 10 #include "net/quic/congestion_control/rtt_stats.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 largest_sent_at_last_cutback_(0), | 45 largest_sent_at_last_cutback_(0), |
46 congestion_window_(initial_tcp_congestion_window * kDefaultTCPMSS), | 46 congestion_window_(initial_tcp_congestion_window * kDefaultTCPMSS), |
47 min_congestion_window_(kDefaultMinimumCongestionWindow), | 47 min_congestion_window_(kDefaultMinimumCongestionWindow), |
48 min4_mode_(false), | 48 min4_mode_(false), |
49 max_congestion_window_(max_congestion_window * kDefaultTCPMSS), | 49 max_congestion_window_(max_congestion_window * kDefaultTCPMSS), |
50 slowstart_threshold_(max_congestion_window * kDefaultTCPMSS), | 50 slowstart_threshold_(max_congestion_window * kDefaultTCPMSS), |
51 last_cutback_exited_slowstart_(false), | 51 last_cutback_exited_slowstart_(false), |
52 initial_tcp_congestion_window_(initial_tcp_congestion_window * | 52 initial_tcp_congestion_window_(initial_tcp_congestion_window * |
53 kDefaultTCPMSS), | 53 kDefaultTCPMSS), |
54 initial_max_tcp_congestion_window_(max_congestion_window * | 54 initial_max_tcp_congestion_window_(max_congestion_window * |
55 kDefaultTCPMSS) {} | 55 kDefaultTCPMSS), |
| 56 slow_start_large_reduction_(false) {} |
56 | 57 |
57 TcpCubicBytesSender::~TcpCubicBytesSender() {} | 58 TcpCubicBytesSender::~TcpCubicBytesSender() {} |
58 | 59 |
59 void TcpCubicBytesSender::SetFromConfig(const QuicConfig& config, | 60 void TcpCubicBytesSender::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(), kIW10)) { | 64 ContainsQuicTag(config.ReceivedConnectionOptions(), kIW10)) { |
64 // Initial window experiment. | 65 // Initial window experiment. |
65 congestion_window_ = 10 * kDefaultTCPMSS; | 66 congestion_window_ = 10 * kDefaultTCPMSS; |
66 } | 67 } |
67 if (config.HasReceivedConnectionOptions() && | 68 if (config.HasReceivedConnectionOptions() && |
68 ContainsQuicTag(config.ReceivedConnectionOptions(), kMIN1)) { | 69 ContainsQuicTag(config.ReceivedConnectionOptions(), kMIN1)) { |
69 // Min CWND experiment. | 70 // Min CWND experiment. |
70 min_congestion_window_ = kDefaultTCPMSS; | 71 min_congestion_window_ = kDefaultTCPMSS; |
71 } | 72 } |
72 if (config.HasReceivedConnectionOptions() && | 73 if (config.HasReceivedConnectionOptions() && |
73 ContainsQuicTag(config.ReceivedConnectionOptions(), kMIN4)) { | 74 ContainsQuicTag(config.ReceivedConnectionOptions(), kMIN4)) { |
74 // Min CWND of 4 experiment. | 75 // Min CWND of 4 experiment. |
75 min4_mode_ = true; | 76 min4_mode_ = true; |
76 min_congestion_window_ = kDefaultTCPMSS; | 77 min_congestion_window_ = kDefaultTCPMSS; |
77 } | 78 } |
| 79 if (config.HasReceivedConnectionOptions() && |
| 80 ContainsQuicTag(config.ReceivedConnectionOptions(), kSSLR)) { |
| 81 // Slow Start Fast Exit experiment. |
| 82 slow_start_large_reduction_ = true; |
| 83 } |
78 } | 84 } |
79 } | 85 } |
80 | 86 |
81 void TcpCubicBytesSender::ResumeConnectionState( | 87 void TcpCubicBytesSender::ResumeConnectionState( |
82 const CachedNetworkParameters& cached_network_params, | 88 const CachedNetworkParameters& cached_network_params, |
83 bool max_bandwidth_resumption) { | 89 bool max_bandwidth_resumption) { |
84 QuicBandwidth bandwidth = QuicBandwidth::FromBytesPerSecond( | 90 QuicBandwidth bandwidth = QuicBandwidth::FromBytesPerSecond( |
85 max_bandwidth_resumption | 91 max_bandwidth_resumption |
86 ? cached_network_params.max_bandwidth_estimate_bytes_per_second() | 92 ? cached_network_params.max_bandwidth_estimate_bytes_per_second() |
87 : cached_network_params.bandwidth_estimate_bytes_per_second()); | 93 : cached_network_params.bandwidth_estimate_bytes_per_second()); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 hybrid_slow_start_.OnPacketAcked(acked_packet_number, InSlowStart()); | 155 hybrid_slow_start_.OnPacketAcked(acked_packet_number, InSlowStart()); |
150 } | 156 } |
151 | 157 |
152 void TcpCubicBytesSender::OnPacketLost(QuicPacketNumber packet_number, | 158 void TcpCubicBytesSender::OnPacketLost(QuicPacketNumber packet_number, |
153 QuicByteCount bytes_in_flight) { | 159 QuicByteCount bytes_in_flight) { |
154 // TCP NewReno (RFC6582) says that once a loss occurs, any losses in packets | 160 // TCP NewReno (RFC6582) says that once a loss occurs, any losses in packets |
155 // already sent should be treated as a single loss event, since it's expected. | 161 // already sent should be treated as a single loss event, since it's expected. |
156 if (packet_number <= largest_sent_at_last_cutback_) { | 162 if (packet_number <= largest_sent_at_last_cutback_) { |
157 if (last_cutback_exited_slowstart_) { | 163 if (last_cutback_exited_slowstart_) { |
158 ++stats_->slowstart_packets_lost; | 164 ++stats_->slowstart_packets_lost; |
| 165 if (slow_start_large_reduction_) { |
| 166 // Reduce congestion window by 1 MSS for every loss. |
| 167 congestion_window_ = |
| 168 max(congestion_window_ - kDefaultTCPMSS, min_congestion_window_); |
| 169 slowstart_threshold_ = congestion_window_; |
| 170 } |
159 } | 171 } |
160 DVLOG(1) << "Ignoring loss for largest_missing:" << packet_number | 172 DVLOG(1) << "Ignoring loss for largest_missing:" << packet_number |
161 << " because it was sent prior to the last CWND cutback."; | 173 << " because it was sent prior to the last CWND cutback."; |
162 return; | 174 return; |
163 } | 175 } |
164 ++stats_->tcp_loss_events; | 176 ++stats_->tcp_loss_events; |
165 last_cutback_exited_slowstart_ = InSlowStart(); | 177 last_cutback_exited_slowstart_ = InSlowStart(); |
166 if (InSlowStart()) { | 178 if (InSlowStart()) { |
167 ++stats_->slowstart_packets_lost; | 179 ++stats_->slowstart_packets_lost; |
168 } | 180 } |
169 | 181 |
170 prr_.OnPacketLost(bytes_in_flight); | 182 prr_.OnPacketLost(bytes_in_flight); |
171 | 183 |
172 if (reno_) { | 184 // TODO(jri): Separate out all of slow start into a separate class. |
| 185 if (slow_start_large_reduction_) { |
| 186 DCHECK_LT(kDefaultTCPMSS, congestion_window_); |
| 187 congestion_window_ = congestion_window_ - kDefaultTCPMSS; |
| 188 } else if (reno_) { |
173 congestion_window_ = congestion_window_ * RenoBeta(); | 189 congestion_window_ = congestion_window_ * RenoBeta(); |
174 } else { | 190 } else { |
175 congestion_window_ = | 191 congestion_window_ = |
176 cubic_.CongestionWindowAfterPacketLoss(congestion_window_); | 192 cubic_.CongestionWindowAfterPacketLoss(congestion_window_); |
177 } | 193 } |
178 slowstart_threshold_ = congestion_window_; | |
179 // Enforce TCP's minimum congestion window of 2*MSS. | 194 // Enforce TCP's minimum congestion window of 2*MSS. |
180 if (congestion_window_ < min_congestion_window_) { | 195 if (congestion_window_ < min_congestion_window_) { |
181 congestion_window_ = min_congestion_window_; | 196 congestion_window_ = min_congestion_window_; |
182 } | 197 } |
| 198 slowstart_threshold_ = congestion_window_; |
183 largest_sent_at_last_cutback_ = largest_sent_packet_number_; | 199 largest_sent_at_last_cutback_ = largest_sent_packet_number_; |
184 // Reset packet count from congestion avoidance mode. We start counting again | 200 // Reset packet count from congestion avoidance mode. We start counting again |
185 // when we're out of recovery. | 201 // when we're out of recovery. |
186 num_acked_packets_ = 0; | 202 num_acked_packets_ = 0; |
187 DVLOG(1) << "Incoming loss; congestion window: " << congestion_window_ | 203 DVLOG(1) << "Incoming loss; congestion window: " << congestion_window_ |
188 << " slowstart threshold: " << slowstart_threshold_; | 204 << " slowstart threshold: " << slowstart_threshold_; |
189 } | 205 } |
190 | 206 |
191 bool TcpCubicBytesSender::OnPacketSent( | 207 bool TcpCubicBytesSender::OnPacketSent( |
192 QuicTime /*sent_time*/, | 208 QuicTime /*sent_time*/, |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 largest_sent_packet_number_ = 0; | 379 largest_sent_packet_number_ = 0; |
364 largest_acked_packet_number_ = 0; | 380 largest_acked_packet_number_ = 0; |
365 largest_sent_at_last_cutback_ = 0; | 381 largest_sent_at_last_cutback_ = 0; |
366 congestion_window_ = initial_tcp_congestion_window_; | 382 congestion_window_ = initial_tcp_congestion_window_; |
367 max_congestion_window_ = initial_max_tcp_congestion_window_; | 383 max_congestion_window_ = initial_max_tcp_congestion_window_; |
368 slowstart_threshold_ = initial_max_tcp_congestion_window_; | 384 slowstart_threshold_ = initial_max_tcp_congestion_window_; |
369 last_cutback_exited_slowstart_ = false; | 385 last_cutback_exited_slowstart_ = false; |
370 } | 386 } |
371 | 387 |
372 } // namespace net | 388 } // namespace net |
OLD | NEW |