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.h" | 9 #include "base/metrics/histogram.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 | 13 |
14 using std::max; | 14 using std::max; |
15 using std::min; | 15 using std::min; |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 | 18 |
19 namespace { | 19 namespace { |
20 // Constants based on TCP defaults. | 20 // Constants based on TCP defaults. |
21 // The minimum cwnd based on RFC 3782 (TCP NewReno) for cwnd reductions on a | 21 // The minimum cwnd based on RFC 3782 (TCP NewReno) for cwnd reductions on a |
22 // fast retransmission. The cwnd after a timeout is still 1. | 22 // fast retransmission. The cwnd after a timeout is still 1. |
23 const QuicPacketCount kMinimumCongestionWindow = 2; | 23 const QuicPacketCount kMinimumCongestionWindow = 2; |
24 const QuicByteCount kMaxSegmentSize = kDefaultTCPMSS; | 24 const QuicByteCount kMaxSegmentSize = kDefaultTCPMSS; |
25 const int64 kInitialCongestionWindow = 10; | 25 const int64 kInitialCongestionWindow = 10; |
26 const int kMaxBurstLength = 3; | 26 const int kMaxBurstLength = 3; |
| 27 const float kRenoBeta = 0.7f; // Reno backoff factor. |
27 } // namespace | 28 } // namespace |
28 | 29 |
29 TcpCubicSender::TcpCubicSender( | 30 TcpCubicSender::TcpCubicSender( |
30 const QuicClock* clock, | 31 const QuicClock* clock, |
31 const RttStats* rtt_stats, | 32 const RttStats* rtt_stats, |
32 bool reno, | 33 bool reno, |
33 QuicPacketCount max_tcp_congestion_window, | 34 QuicPacketCount max_tcp_congestion_window, |
34 QuicConnectionStats* stats) | 35 QuicConnectionStats* stats) |
35 : hybrid_slow_start_(clock), | 36 : hybrid_slow_start_(clock), |
36 cubic_(clock, stats), | 37 cubic_(clock, stats), |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 } | 127 } |
127 ++stats_->tcp_loss_events; | 128 ++stats_->tcp_loss_events; |
128 last_cutback_exited_slowstart_ = InSlowStart(); | 129 last_cutback_exited_slowstart_ = InSlowStart(); |
129 if (InSlowStart()) { | 130 if (InSlowStart()) { |
130 ++stats_->slowstart_packets_lost; | 131 ++stats_->slowstart_packets_lost; |
131 } | 132 } |
132 | 133 |
133 prr_.OnPacketLost(bytes_in_flight); | 134 prr_.OnPacketLost(bytes_in_flight); |
134 | 135 |
135 if (reno_) { | 136 if (reno_) { |
136 congestion_window_ = congestion_window_ >> 1; | 137 congestion_window_ = congestion_window_ * kRenoBeta; |
137 } else { | 138 } else { |
138 congestion_window_ = | 139 congestion_window_ = |
139 cubic_.CongestionWindowAfterPacketLoss(congestion_window_); | 140 cubic_.CongestionWindowAfterPacketLoss(congestion_window_); |
140 } | 141 } |
141 slowstart_threshold_ = congestion_window_; | 142 slowstart_threshold_ = congestion_window_; |
142 // Enforce TCP's minimum congestion window of 2*MSS. | 143 // Enforce TCP's minimum congestion window of 2*MSS. |
143 if (congestion_window_ < kMinimumCongestionWindow) { | 144 if (congestion_window_ < kMinimumCongestionWindow) { |
144 congestion_window_ = kMinimumCongestionWindow; | 145 congestion_window_ = kMinimumCongestionWindow; |
145 } | 146 } |
146 largest_sent_at_last_cutback_ = largest_sent_sequence_number_; | 147 largest_sent_at_last_cutback_ = largest_sent_sequence_number_; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 congestion_window_ = previous_congestion_window_; | 317 congestion_window_ = previous_congestion_window_; |
317 slowstart_threshold_ = previous_slowstart_threshold_; | 318 slowstart_threshold_ = previous_slowstart_threshold_; |
318 previous_congestion_window_ = 0; | 319 previous_congestion_window_ = 0; |
319 } | 320 } |
320 | 321 |
321 CongestionControlType TcpCubicSender::GetCongestionControlType() const { | 322 CongestionControlType TcpCubicSender::GetCongestionControlType() const { |
322 return reno_ ? kReno : kCubic; | 323 return reno_ ? kReno : kCubic; |
323 } | 324 } |
324 | 325 |
325 } // namespace net | 326 } // namespace net |
OLD | NEW |