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_sender_bytes.h" | 5 #include "net/quic/congestion_control/tcp_cubic_sender_bytes.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 24 matching lines...) Expand all Loading... |
35 : TcpCubicSenderBase(clock, rtt_stats, reno, stats), | 35 : TcpCubicSenderBase(clock, rtt_stats, reno, stats), |
36 cubic_(clock), | 36 cubic_(clock), |
37 num_acked_packets_(0), | 37 num_acked_packets_(0), |
38 congestion_window_(initial_tcp_congestion_window * kDefaultTCPMSS), | 38 congestion_window_(initial_tcp_congestion_window * kDefaultTCPMSS), |
39 min_congestion_window_(kDefaultMinimumCongestionWindow), | 39 min_congestion_window_(kDefaultMinimumCongestionWindow), |
40 max_congestion_window_(max_congestion_window * kDefaultTCPMSS), | 40 max_congestion_window_(max_congestion_window * kDefaultTCPMSS), |
41 slowstart_threshold_(max_congestion_window * kDefaultTCPMSS), | 41 slowstart_threshold_(max_congestion_window * kDefaultTCPMSS), |
42 initial_tcp_congestion_window_(initial_tcp_congestion_window * | 42 initial_tcp_congestion_window_(initial_tcp_congestion_window * |
43 kDefaultTCPMSS), | 43 kDefaultTCPMSS), |
44 initial_max_tcp_congestion_window_(max_congestion_window * | 44 initial_max_tcp_congestion_window_(max_congestion_window * |
45 kDefaultTCPMSS) {} | 45 kDefaultTCPMSS), |
| 46 min_slow_start_exit_window_(min_congestion_window_) {} |
46 | 47 |
47 TcpCubicSenderBytes::~TcpCubicSenderBytes() {} | 48 TcpCubicSenderBytes::~TcpCubicSenderBytes() {} |
48 | 49 |
49 void TcpCubicSenderBytes::SetCongestionWindowFromBandwidthAndRtt( | 50 void TcpCubicSenderBytes::SetCongestionWindowFromBandwidthAndRtt( |
50 QuicBandwidth bandwidth, | 51 QuicBandwidth bandwidth, |
51 QuicTime::Delta rtt) { | 52 QuicTime::Delta rtt) { |
52 // Make sure CWND is in appropriate range (in case of bad data). | |
53 QuicByteCount new_congestion_window = bandwidth.ToBytesPerPeriod(rtt); | 53 QuicByteCount new_congestion_window = bandwidth.ToBytesPerPeriod(rtt); |
54 congestion_window_ = | 54 if (FLAGS_quic_no_lower_bw_resumption_limit) { |
55 max(min(new_congestion_window, kMaxCongestionWindow * kDefaultTCPMSS), | 55 // Limit new CWND if needed. |
56 kMinCongestionWindowForBandwidthResumption * kDefaultTCPMSS); | 56 congestion_window_ = |
| 57 max(min_congestion_window_, |
| 58 min(new_congestion_window, kMaxCongestionWindow * kDefaultTCPMSS)); |
| 59 } else { |
| 60 congestion_window_ = |
| 61 max(min(new_congestion_window, kMaxCongestionWindow * kDefaultTCPMSS), |
| 62 kMinCongestionWindowForBandwidthResumption * kDefaultTCPMSS); |
| 63 } |
57 } | 64 } |
58 | 65 |
59 void TcpCubicSenderBytes::SetCongestionWindowInPackets( | 66 void TcpCubicSenderBytes::SetCongestionWindowInPackets( |
60 QuicPacketCount congestion_window) { | 67 QuicPacketCount congestion_window) { |
61 congestion_window_ = congestion_window * kDefaultTCPMSS; | 68 congestion_window_ = congestion_window * kDefaultTCPMSS; |
62 } | 69 } |
63 | 70 |
64 void TcpCubicSenderBytes::SetMinCongestionWindowInPackets( | 71 void TcpCubicSenderBytes::SetMinCongestionWindowInPackets( |
65 QuicPacketCount congestion_window) { | 72 QuicPacketCount congestion_window) { |
66 min_congestion_window_ = congestion_window * kDefaultTCPMSS; | 73 min_congestion_window_ = congestion_window * kDefaultTCPMSS; |
(...skipping 18 matching lines...) Expand all Loading... |
85 QuicByteCount bytes_in_flight) { | 92 QuicByteCount bytes_in_flight) { |
86 // TCP NewReno (RFC6582) says that once a loss occurs, any losses in packets | 93 // TCP NewReno (RFC6582) says that once a loss occurs, any losses in packets |
87 // already sent should be treated as a single loss event, since it's expected. | 94 // already sent should be treated as a single loss event, since it's expected. |
88 if (packet_number <= largest_sent_at_last_cutback_) { | 95 if (packet_number <= largest_sent_at_last_cutback_) { |
89 if (last_cutback_exited_slowstart_) { | 96 if (last_cutback_exited_slowstart_) { |
90 ++stats_->slowstart_packets_lost; | 97 ++stats_->slowstart_packets_lost; |
91 stats_->slowstart_bytes_lost += lost_bytes; | 98 stats_->slowstart_bytes_lost += lost_bytes; |
92 if (slow_start_large_reduction_) { | 99 if (slow_start_large_reduction_) { |
93 // Reduce congestion window by lost_bytes for every loss. | 100 // Reduce congestion window by lost_bytes for every loss. |
94 congestion_window_ = | 101 congestion_window_ = |
95 max(congestion_window_ - lost_bytes, min_congestion_window_); | 102 max(congestion_window_ - lost_bytes, min_slow_start_exit_window_); |
96 slowstart_threshold_ = congestion_window_; | 103 slowstart_threshold_ = congestion_window_; |
97 } | 104 } |
98 } | 105 } |
99 DVLOG(1) << "Ignoring loss for largest_missing:" << packet_number | 106 DVLOG(1) << "Ignoring loss for largest_missing:" << packet_number |
100 << " because it was sent prior to the last CWND cutback."; | 107 << " because it was sent prior to the last CWND cutback."; |
101 return; | 108 return; |
102 } | 109 } |
103 ++stats_->tcp_loss_events; | 110 ++stats_->tcp_loss_events; |
104 last_cutback_exited_slowstart_ = InSlowStart(); | 111 last_cutback_exited_slowstart_ = InSlowStart(); |
105 if (InSlowStart()) { | 112 if (InSlowStart()) { |
106 ++stats_->slowstart_packets_lost; | 113 ++stats_->slowstart_packets_lost; |
107 } | 114 } |
108 | 115 |
109 prr_.OnPacketLost(bytes_in_flight); | 116 prr_.OnPacketLost(bytes_in_flight); |
110 | 117 |
111 // TODO(jri): Separate out all of slow start into a separate class. | 118 // TODO(jri): Separate out all of slow start into a separate class. |
112 if (slow_start_large_reduction_ && InSlowStart()) { | 119 if (slow_start_large_reduction_ && InSlowStart()) { |
113 DCHECK_LT(kDefaultTCPMSS, congestion_window_); | 120 DCHECK_LT(kDefaultTCPMSS, congestion_window_); |
| 121 if (FLAGS_quic_sslr_limit_reduction && |
| 122 congestion_window_ >= 2 * initial_tcp_congestion_window_) { |
| 123 min_slow_start_exit_window_ = congestion_window_ / 2; |
| 124 } |
114 congestion_window_ = congestion_window_ - kDefaultTCPMSS; | 125 congestion_window_ = congestion_window_ - kDefaultTCPMSS; |
115 } else if (reno_) { | 126 } else if (reno_) { |
116 congestion_window_ = congestion_window_ * RenoBeta(); | 127 congestion_window_ = congestion_window_ * RenoBeta(); |
117 } else { | 128 } else { |
118 congestion_window_ = | 129 congestion_window_ = |
119 cubic_.CongestionWindowAfterPacketLoss(congestion_window_); | 130 cubic_.CongestionWindowAfterPacketLoss(congestion_window_); |
120 } | 131 } |
121 // Enforce TCP's minimum congestion window of 2*MSS. | |
122 if (congestion_window_ < min_congestion_window_) { | 132 if (congestion_window_ < min_congestion_window_) { |
123 congestion_window_ = min_congestion_window_; | 133 congestion_window_ = min_congestion_window_; |
124 } | 134 } |
125 slowstart_threshold_ = congestion_window_; | 135 slowstart_threshold_ = congestion_window_; |
126 largest_sent_at_last_cutback_ = largest_sent_packet_number_; | 136 largest_sent_at_last_cutback_ = largest_sent_packet_number_; |
127 // Reset packet count from congestion avoidance mode. We start counting again | 137 // Reset packet count from congestion avoidance mode. We start counting again |
128 // when we're out of recovery. | 138 // when we're out of recovery. |
129 num_acked_packets_ = 0; | 139 num_acked_packets_ = 0; |
130 DVLOG(1) << "Incoming loss; congestion window: " << congestion_window_ | 140 DVLOG(1) << "Incoming loss; congestion window: " << congestion_window_ |
131 << " slowstart threshold: " << slowstart_threshold_; | 141 << " slowstart threshold: " << slowstart_threshold_; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 congestion_window_ = initial_tcp_congestion_window_; | 210 congestion_window_ = initial_tcp_congestion_window_; |
201 max_congestion_window_ = initial_max_tcp_congestion_window_; | 211 max_congestion_window_ = initial_max_tcp_congestion_window_; |
202 slowstart_threshold_ = initial_max_tcp_congestion_window_; | 212 slowstart_threshold_ = initial_max_tcp_congestion_window_; |
203 } | 213 } |
204 | 214 |
205 CongestionControlType TcpCubicSenderBytes::GetCongestionControlType() const { | 215 CongestionControlType TcpCubicSenderBytes::GetCongestionControlType() const { |
206 return reno_ ? kRenoBytes : kCubicBytes; | 216 return reno_ ? kRenoBytes : kCubicBytes; |
207 } | 217 } |
208 | 218 |
209 } // namespace net | 219 } // namespace net |
OLD | NEW |