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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 random_(random), | 82 random_(random), |
83 mode_(STARTUP), | 83 mode_(STARTUP), |
84 sampler_(), | 84 sampler_(), |
85 round_trip_count_(0), | 85 round_trip_count_(0), |
86 last_sent_packet_(0), | 86 last_sent_packet_(0), |
87 current_round_trip_end_(0), | 87 current_round_trip_end_(0), |
88 max_bandwidth_(kBandwidthWindowSize, QuicBandwidth::Zero(), 0), | 88 max_bandwidth_(kBandwidthWindowSize, QuicBandwidth::Zero(), 0), |
89 max_ack_height_(kBandwidthWindowSize, 0, 0), | 89 max_ack_height_(kBandwidthWindowSize, 0, 0), |
90 aggregation_epoch_start_time_(QuicTime::Zero()), | 90 aggregation_epoch_start_time_(QuicTime::Zero()), |
91 aggregation_epoch_bytes_(0), | 91 aggregation_epoch_bytes_(0), |
| 92 bytes_acked_since_queue_drained_(0), |
92 min_rtt_(QuicTime::Delta::Zero()), | 93 min_rtt_(QuicTime::Delta::Zero()), |
93 min_rtt_timestamp_(QuicTime::Zero()), | 94 min_rtt_timestamp_(QuicTime::Zero()), |
94 congestion_window_(initial_tcp_congestion_window * kDefaultTCPMSS), | 95 congestion_window_(initial_tcp_congestion_window * kDefaultTCPMSS), |
95 initial_congestion_window_(initial_tcp_congestion_window * | 96 initial_congestion_window_(initial_tcp_congestion_window * |
96 kDefaultTCPMSS), | 97 kDefaultTCPMSS), |
97 max_congestion_window_(max_tcp_congestion_window * kDefaultTCPMSS), | 98 max_congestion_window_(max_tcp_congestion_window * kDefaultTCPMSS), |
98 pacing_rate_(QuicBandwidth::Zero()), | 99 pacing_rate_(QuicBandwidth::Zero()), |
99 pacing_gain_(1), | 100 pacing_gain_(1), |
100 congestion_window_gain_(1), | 101 congestion_window_gain_(1), |
101 congestion_window_gain_constant_( | 102 congestion_window_gain_constant_( |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 DiscardLostPackets(lost_packets); | 270 DiscardLostPackets(lost_packets); |
270 | 271 |
271 // Input the new data into the BBR model of the connection. | 272 // Input the new data into the BBR model of the connection. |
272 if (!acked_packets.empty()) { | 273 if (!acked_packets.empty()) { |
273 QuicPacketNumber last_acked_packet = acked_packets.rbegin()->first; | 274 QuicPacketNumber last_acked_packet = acked_packets.rbegin()->first; |
274 is_round_start = UpdateRoundTripCounter(last_acked_packet); | 275 is_round_start = UpdateRoundTripCounter(last_acked_packet); |
275 min_rtt_expired = UpdateBandwidthAndMinRtt(event_time, acked_packets); | 276 min_rtt_expired = UpdateBandwidthAndMinRtt(event_time, acked_packets); |
276 UpdateRecoveryState(last_acked_packet, !lost_packets.empty(), | 277 UpdateRecoveryState(last_acked_packet, !lost_packets.empty(), |
277 is_round_start); | 278 is_round_start); |
278 | 279 |
| 280 const QuicByteCount bytes_acked = |
| 281 sampler_.total_bytes_acked() - total_bytes_acked_before; |
279 if (FLAGS_quic_reloadable_flag_quic_bbr_slow_recent_delivery) { | 282 if (FLAGS_quic_reloadable_flag_quic_bbr_slow_recent_delivery) { |
280 QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_bbr_slow_recent_delivery, 1, | 283 QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_bbr_slow_recent_delivery, 1, |
281 2); | 284 2); |
282 UpdateRecentlyAcked( | 285 UpdateRecentlyAcked(event_time, bytes_acked); |
283 event_time, sampler_.total_bytes_acked() - total_bytes_acked_before); | |
284 } | 286 } |
285 | 287 |
286 if (FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes) { | 288 if (FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes) { |
287 QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_bbr_ack_aggregation_bytes, 1, | 289 QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_bbr_ack_aggregation_bytes, 1, |
288 2); | 290 2); |
289 UpdateAckAggregationBytes( | 291 UpdateAckAggregationBytes(event_time, bytes_acked); |
290 event_time, sampler_.total_bytes_acked() - total_bytes_acked_before); | 292 } |
| 293 if (FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes2) { |
| 294 QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_bbr_ack_aggregation_bytes2, 1, |
| 295 2); |
| 296 UpdateAckAggregationBytes(event_time, bytes_acked); |
| 297 if (unacked_packets_->bytes_in_flight() <= |
| 298 1.25 * GetTargetCongestionWindow(pacing_gain_)) { |
| 299 bytes_acked_since_queue_drained_ = 0; |
| 300 } else { |
| 301 bytes_acked_since_queue_drained_ += bytes_acked; |
| 302 } |
291 } | 303 } |
292 } | 304 } |
293 | 305 |
294 // Handle logic specific to PROBE_BW mode. | 306 // Handle logic specific to PROBE_BW mode. |
295 if (mode_ == PROBE_BW) { | 307 if (mode_ == PROBE_BW) { |
296 UpdateGainCyclePhase(event_time, prior_in_flight, !lost_packets.empty()); | 308 UpdateGainCyclePhase(event_time, prior_in_flight, !lost_packets.empty()); |
297 } | 309 } |
298 | 310 |
299 // Handle logic specific to STARTUP and DRAIN modes. | 311 // Handle logic specific to STARTUP and DRAIN modes. |
300 if (is_round_start && !is_at_full_bandwidth_) { | 312 if (is_round_start && !is_at_full_bandwidth_) { |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 GetTargetCongestionWindow(congestion_window_gain_); | 657 GetTargetCongestionWindow(congestion_window_gain_); |
646 | 658 |
647 if (rtt_variance_weight_ > 0.f && !BandwidthEstimate().IsZero()) { | 659 if (rtt_variance_weight_ > 0.f && !BandwidthEstimate().IsZero()) { |
648 target_window += rtt_variance_weight_ * rtt_stats_->mean_deviation() * | 660 target_window += rtt_variance_weight_ * rtt_stats_->mean_deviation() * |
649 BandwidthEstimate(); | 661 BandwidthEstimate(); |
650 } else if (FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes && | 662 } else if (FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes && |
651 is_at_full_bandwidth_) { | 663 is_at_full_bandwidth_) { |
652 QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_bbr_ack_aggregation_bytes, 2, | 664 QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_bbr_ack_aggregation_bytes, 2, |
653 2); | 665 2); |
654 target_window += max_ack_height_.GetBest(); | 666 target_window += max_ack_height_.GetBest(); |
| 667 } else if (FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes2 && |
| 668 is_at_full_bandwidth_) { |
| 669 QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_bbr_ack_aggregation_bytes2, 2, |
| 670 2); |
| 671 if (2 * max_ack_height_.GetBest() > bytes_acked_since_queue_drained_) { |
| 672 target_window += |
| 673 2 * max_ack_height_.GetBest() - bytes_acked_since_queue_drained_; |
| 674 } |
655 } | 675 } |
656 if (FLAGS_quic_reloadable_flag_quic_bbr_add_tso_cwnd) { | 676 if (FLAGS_quic_reloadable_flag_quic_bbr_add_tso_cwnd) { |
657 // QUIC doesn't have TSO, but it does have similarly quantized pacing, so | 677 // QUIC doesn't have TSO, but it does have similarly quantized pacing, so |
658 // allow extra CWND to make QUIC's BBR CWND identical to TCP's. | 678 // allow extra CWND to make QUIC's BBR CWND identical to TCP's. |
659 QuicByteCount tso_segs_goal = 0; | 679 QuicByteCount tso_segs_goal = 0; |
660 if (pacing_rate_ < QuicBandwidth::FromKBitsPerSecond(1200)) { | 680 if (pacing_rate_ < QuicBandwidth::FromKBitsPerSecond(1200)) { |
661 tso_segs_goal = kDefaultTCPMSS; | 681 tso_segs_goal = kDefaultTCPMSS; |
662 } else if (pacing_rate_ < QuicBandwidth::FromKBitsPerSecond(24000)) { | 682 } else if (pacing_rate_ < QuicBandwidth::FromKBitsPerSecond(24000)) { |
663 tso_segs_goal = 2 * kDefaultTCPMSS; | 683 tso_segs_goal = 2 * kDefaultTCPMSS; |
664 } else { | 684 } else { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 os << "Minimum RTT timestamp: " << state.min_rtt_timestamp.ToDebuggingValue() | 819 os << "Minimum RTT timestamp: " << state.min_rtt_timestamp.ToDebuggingValue() |
800 << std::endl; | 820 << std::endl; |
801 | 821 |
802 os << "Last sample is app-limited: " | 822 os << "Last sample is app-limited: " |
803 << (state.last_sample_is_app_limited ? "yes" : "no"); | 823 << (state.last_sample_is_app_limited ? "yes" : "no"); |
804 | 824 |
805 return os; | 825 return os; |
806 } | 826 } |
807 | 827 |
808 } // namespace net | 828 } // namespace net |
OLD | NEW |