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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 bool TcpCubicSender::InRecovery() const { | 303 bool TcpCubicSender::InRecovery() const { |
304 return largest_acked_packet_number_ <= largest_sent_at_last_cutback_ && | 304 return largest_acked_packet_number_ <= largest_sent_at_last_cutback_ && |
305 largest_acked_packet_number_ != 0; | 305 largest_acked_packet_number_ != 0; |
306 } | 306 } |
307 | 307 |
308 // Called when we receive an ack. Normal TCP tracks how many packets one ack | 308 // Called when we receive an ack. Normal TCP tracks how many packets one ack |
309 // represents, but quic has a separate ack for each packet. | 309 // represents, but quic has a separate ack for each packet. |
310 void TcpCubicSender::MaybeIncreaseCwnd(QuicPacketNumber acked_packet_number, | 310 void TcpCubicSender::MaybeIncreaseCwnd(QuicPacketNumber acked_packet_number, |
311 QuicByteCount bytes_in_flight) { | 311 QuicByteCount bytes_in_flight) { |
312 LOG_IF(DFATAL, InRecovery()) << "Never increase the CWND during recovery."; | 312 LOG_IF(DFATAL, InRecovery()) << "Never increase the CWND during recovery."; |
| 313 // Do not increase the congestion window unless the sender is close to using |
| 314 // the current window. |
313 if (!IsCwndLimited(bytes_in_flight)) { | 315 if (!IsCwndLimited(bytes_in_flight)) { |
314 // Do not increase the congestion window unless the sender is close to using | 316 cubic_.OnApplicationLimited(); |
315 // the current window. | |
316 if (FLAGS_reset_cubic_epoch_when_app_limited || | |
317 FLAGS_shift_quic_cubic_epoch_when_app_limited) { | |
318 cubic_.OnApplicationLimited(); | |
319 } | |
320 return; | 317 return; |
321 } | 318 } |
322 if (congestion_window_ >= max_tcp_congestion_window_) { | 319 if (congestion_window_ >= max_tcp_congestion_window_) { |
323 return; | 320 return; |
324 } | 321 } |
325 if (InSlowStart()) { | 322 if (InSlowStart()) { |
326 // TCP slow start, exponential growth, increase by one for each ACK. | 323 // TCP slow start, exponential growth, increase by one for each ACK. |
327 ++congestion_window_; | 324 ++congestion_window_; |
328 DVLOG(1) << "Slow start; congestion window: " << congestion_window_ | 325 DVLOG(1) << "Slow start; congestion window: " << congestion_window_ |
329 << " slowstart threshold: " << slowstart_threshold_; | 326 << " slowstart threshold: " << slowstart_threshold_; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 hybrid_slow_start_.Restart(); | 358 hybrid_slow_start_.Restart(); |
362 slowstart_threshold_ = congestion_window_ / 2; | 359 slowstart_threshold_ = congestion_window_ / 2; |
363 congestion_window_ = min_congestion_window_; | 360 congestion_window_ = min_congestion_window_; |
364 } | 361 } |
365 | 362 |
366 CongestionControlType TcpCubicSender::GetCongestionControlType() const { | 363 CongestionControlType TcpCubicSender::GetCongestionControlType() const { |
367 return reno_ ? kReno : kCubic; | 364 return reno_ ? kReno : kCubic; |
368 } | 365 } |
369 | 366 |
370 } // namespace net | 367 } // namespace net |
OLD | NEW |