OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/core/congestion_control/bbr_sender.h" | 5 #include "net/quic/core/congestion_control/bbr_sender.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "net/quic/core/congestion_control/rtt_stats.h" | 10 #include "net/quic/core/congestion_control/rtt_stats.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 147 |
148 QuicBandwidth BbrSender::PacingRate(QuicByteCount bytes_in_flight) const { | 148 QuicBandwidth BbrSender::PacingRate(QuicByteCount bytes_in_flight) const { |
149 if (pacing_rate_.IsZero()) { | 149 if (pacing_rate_.IsZero()) { |
150 return kHighGain * QuicBandwidth::FromBytesAndTimeDelta( | 150 return kHighGain * QuicBandwidth::FromBytesAndTimeDelta( |
151 initial_congestion_window_, GetMinRtt()); | 151 initial_congestion_window_, GetMinRtt()); |
152 } | 152 } |
153 if (FLAGS_quic_reloadable_flag_quic_bbr_keep_sending_at_recent_rate && | 153 if (FLAGS_quic_reloadable_flag_quic_bbr_keep_sending_at_recent_rate && |
154 mode_ == PROBE_BW && bytes_in_flight > congestion_window_) { | 154 mode_ == PROBE_BW && bytes_in_flight > congestion_window_) { |
155 QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_bbr_keep_sending_at_recent_rate, | 155 QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_bbr_keep_sending_at_recent_rate, |
156 1, 2); | 156 1, 2); |
157 return max_bandwidth_.GetThirdBest(); | 157 if (pacing_gain_ > 1) { |
| 158 return max_bandwidth_.GetBest(); |
| 159 } else { |
| 160 return max_bandwidth_.GetThirdBest(); |
| 161 } |
158 } | 162 } |
159 return pacing_rate_; | 163 return pacing_rate_; |
160 } | 164 } |
161 | 165 |
162 QuicBandwidth BbrSender::BandwidthEstimate() const { | 166 QuicBandwidth BbrSender::BandwidthEstimate() const { |
163 return max_bandwidth_.GetBest(); | 167 return max_bandwidth_.GetBest(); |
164 } | 168 } |
165 | 169 |
166 QuicByteCount BbrSender::GetCongestionWindow() const { | 170 QuicByteCount BbrSender::GetCongestionWindow() const { |
167 if (mode_ == PROBE_RTT) { | 171 if (mode_ == PROBE_RTT) { |
168 return kMinimumCongestionWindow; | 172 return kMinimumCongestionWindow; |
169 } | 173 } |
170 | 174 |
171 if (InRecovery()) { | 175 if (InRecovery()) { |
172 return std::min(congestion_window_, recovery_window_); | 176 return std::min(congestion_window_, recovery_window_); |
173 } | 177 } |
174 | 178 |
175 if (FLAGS_quic_reloadable_flag_quic_bbr_keep_sending_at_recent_rate && | 179 if (FLAGS_quic_reloadable_flag_quic_bbr_keep_sending_at_recent_rate && |
176 mode_ == PROBE_BW) { | 180 mode_ == PROBE_BW && pacing_gain_ >= 1) { |
177 QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_bbr_keep_sending_at_recent_rate, | 181 QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_bbr_keep_sending_at_recent_rate, |
178 2, 2); | 182 2, 2); |
179 // Send for another SRTT at a more recently measured bandwidth. | 183 // Send for another SRTT at a more recently measured bandwidth. |
180 return congestion_window_ + | 184 return congestion_window_ + |
181 max_bandwidth_.GetThirdBest() * rtt_stats_->smoothed_rtt(); | 185 max_bandwidth_.GetThirdBest() * rtt_stats_->smoothed_rtt(); |
182 } | 186 } |
183 | 187 |
184 return congestion_window_; | 188 return congestion_window_; |
185 } | 189 } |
186 | 190 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 } | 291 } |
288 | 292 |
289 QuicTime::Delta BbrSender::GetMinRtt() const { | 293 QuicTime::Delta BbrSender::GetMinRtt() const { |
290 return !min_rtt_.IsZero() | 294 return !min_rtt_.IsZero() |
291 ? min_rtt_ | 295 ? min_rtt_ |
292 : QuicTime::Delta::FromMicroseconds(rtt_stats_->initial_rtt_us()); | 296 : QuicTime::Delta::FromMicroseconds(rtt_stats_->initial_rtt_us()); |
293 } | 297 } |
294 | 298 |
295 QuicByteCount BbrSender::GetTargetCongestionWindow(float gain) const { | 299 QuicByteCount BbrSender::GetTargetCongestionWindow(float gain) const { |
296 QuicByteCount bdp = GetMinRtt() * BandwidthEstimate(); | 300 QuicByteCount bdp = GetMinRtt() * BandwidthEstimate(); |
| 301 if (FLAGS_quic_reloadable_flag_quic_bbr_base_cwnd_on_srtt && |
| 302 mode_ == PROBE_BW && gain >= 1 && !rtt_stats_->smoothed_rtt().IsZero()) { |
| 303 bdp = rtt_stats_->smoothed_rtt() * BandwidthEstimate(); |
| 304 } |
297 QuicByteCount congestion_window = gain * bdp; | 305 QuicByteCount congestion_window = gain * bdp; |
298 | 306 |
299 // BDP estimate will be zero if no bandwidth samples are available yet. | 307 // BDP estimate will be zero if no bandwidth samples are available yet. |
300 if (congestion_window == 0) { | 308 if (congestion_window == 0) { |
301 congestion_window = gain * initial_congestion_window_; | 309 congestion_window = gain * initial_congestion_window_; |
302 } | 310 } |
303 | 311 |
304 return std::max(congestion_window, kMinimumCongestionWindow); | 312 return std::max(congestion_window, kMinimumCongestionWindow); |
305 } | 313 } |
306 | 314 |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 os << "Minimum RTT timestamp: " << state.min_rtt_timestamp.ToDebuggingValue() | 735 os << "Minimum RTT timestamp: " << state.min_rtt_timestamp.ToDebuggingValue() |
728 << std::endl; | 736 << std::endl; |
729 | 737 |
730 os << "Last sample is app-limited: " | 738 os << "Last sample is app-limited: " |
731 << (state.last_sample_is_app_limited ? "yes" : "no"); | 739 << (state.last_sample_is_app_limited ? "yes" : "no"); |
732 | 740 |
733 return os; | 741 return os; |
734 } | 742 } |
735 | 743 |
736 } // namespace net | 744 } // namespace net |
OLD | NEW |