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" |
11 #include "net/quic/congestion_control/rtt_stats.h" | 11 #include "net/quic/congestion_control/rtt_stats.h" |
12 #include "net/quic/crypto/crypto_protocol.h" | 12 #include "net/quic/crypto/crypto_protocol.h" |
13 #include "net/quic/proto/cached_network_parameters.pb.h" | 13 #include "net/quic/proto/cached_network_parameters.pb.h" |
| 14 #include "net/quic/quic_flags.h" |
14 | 15 |
15 using std::max; | 16 using std::max; |
16 using std::min; | 17 using std::min; |
17 | 18 |
18 namespace net { | 19 namespace net { |
19 | 20 |
20 namespace { | 21 namespace { |
21 // Constants based on TCP defaults. | 22 // Constants based on TCP defaults. |
22 // The minimum cwnd based on RFC 3782 (TCP NewReno) for cwnd reductions on a | 23 // The minimum cwnd based on RFC 3782 (TCP NewReno) for cwnd reductions on a |
23 // fast retransmission. The cwnd after a timeout is still 1. | 24 // fast retransmission. The cwnd after a timeout is still 1. |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 return largest_acked_packet_number_ <= largest_sent_at_last_cutback_ && | 306 return largest_acked_packet_number_ <= largest_sent_at_last_cutback_ && |
306 largest_acked_packet_number_ != 0; | 307 largest_acked_packet_number_ != 0; |
307 } | 308 } |
308 | 309 |
309 // Called when we receive an ack. Normal TCP tracks how many packets one ack | 310 // Called when we receive an ack. Normal TCP tracks how many packets one ack |
310 // represents, but quic has a separate ack for each packet. | 311 // represents, but quic has a separate ack for each packet. |
311 void TcpCubicSender::MaybeIncreaseCwnd(QuicPacketNumber acked_packet_number, | 312 void TcpCubicSender::MaybeIncreaseCwnd(QuicPacketNumber acked_packet_number, |
312 QuicByteCount bytes_in_flight) { | 313 QuicByteCount bytes_in_flight) { |
313 LOG_IF(DFATAL, InRecovery()) << "Never increase the CWND during recovery."; | 314 LOG_IF(DFATAL, InRecovery()) << "Never increase the CWND during recovery."; |
314 if (!IsCwndLimited(bytes_in_flight)) { | 315 if (!IsCwndLimited(bytes_in_flight)) { |
315 // We don't update the congestion window unless we are close to using the | 316 // Do not increase the congestion window unless the sender is close to using |
316 // window we have available. | 317 // the current window. |
| 318 if (FLAGS_reset_cubic_epoch_when_app_limited) { |
| 319 cubic_.OnApplicationLimited(); |
| 320 } |
317 return; | 321 return; |
318 } | 322 } |
319 if (congestion_window_ >= max_tcp_congestion_window_) { | 323 if (congestion_window_ >= max_tcp_congestion_window_) { |
320 return; | 324 return; |
321 } | 325 } |
322 if (InSlowStart()) { | 326 if (InSlowStart()) { |
323 // TCP slow start, exponential growth, increase by one for each ACK. | 327 // TCP slow start, exponential growth, increase by one for each ACK. |
324 ++congestion_window_; | 328 ++congestion_window_; |
325 DVLOG(1) << "Slow start; congestion window: " << congestion_window_ | 329 DVLOG(1) << "Slow start; congestion window: " << congestion_window_ |
326 << " slowstart threshold: " << slowstart_threshold_; | 330 << " slowstart threshold: " << slowstart_threshold_; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 hybrid_slow_start_.Restart(); | 362 hybrid_slow_start_.Restart(); |
359 slowstart_threshold_ = congestion_window_ / 2; | 363 slowstart_threshold_ = congestion_window_ / 2; |
360 congestion_window_ = min_congestion_window_; | 364 congestion_window_ = min_congestion_window_; |
361 } | 365 } |
362 | 366 |
363 CongestionControlType TcpCubicSender::GetCongestionControlType() const { | 367 CongestionControlType TcpCubicSender::GetCongestionControlType() const { |
364 return reno_ ? kReno : kCubic; | 368 return reno_ ? kReno : kCubic; |
365 } | 369 } |
366 | 370 |
367 } // namespace net | 371 } // namespace net |
OLD | NEW |