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 // BBR (Bottleneck Bandwidth and RTT) congestion control algorithm. | 5 // BBR (Bottleneck Bandwidth and RTT) congestion control algorithm. |
6 | 6 |
7 #ifndef NET_QUIC_CORE_CONGESTION_CONTROL_BBR_SENDER_H_ | 7 #ifndef NET_QUIC_CORE_CONGESTION_CONTROL_BBR_SENDER_H_ |
8 #define NET_QUIC_CORE_CONGESTION_CONTROL_BBR_SENDER_H_ | 8 #define NET_QUIC_CORE_CONGESTION_CONTROL_BBR_SENDER_H_ |
9 | 9 |
10 #include <cstdint> | 10 #include <cstdint> |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 const CongestionVector& acked_packets, | 112 const CongestionVector& acked_packets, |
113 const CongestionVector& lost_packets) override; | 113 const CongestionVector& lost_packets) override; |
114 bool OnPacketSent(QuicTime sent_time, | 114 bool OnPacketSent(QuicTime sent_time, |
115 QuicByteCount bytes_in_flight, | 115 QuicByteCount bytes_in_flight, |
116 QuicPacketNumber packet_number, | 116 QuicPacketNumber packet_number, |
117 QuicByteCount bytes, | 117 QuicByteCount bytes, |
118 HasRetransmittableData is_retransmittable) override; | 118 HasRetransmittableData is_retransmittable) override; |
119 void OnRetransmissionTimeout(bool packets_retransmitted) override {} | 119 void OnRetransmissionTimeout(bool packets_retransmitted) override {} |
120 void OnConnectionMigration() override {} | 120 void OnConnectionMigration() override {} |
121 QuicTime::Delta TimeUntilSend(QuicTime now, | 121 QuicTime::Delta TimeUntilSend(QuicTime now, |
122 QuicByteCount bytes_in_flight) const override; | 122 QuicByteCount bytes_in_flight) override; |
123 QuicBandwidth PacingRate(QuicByteCount bytes_in_flight) const override; | 123 QuicBandwidth PacingRate(QuicByteCount bytes_in_flight) const override; |
124 QuicBandwidth BandwidthEstimate() const override; | 124 QuicBandwidth BandwidthEstimate() const override; |
125 QuicByteCount GetCongestionWindow() const override; | 125 QuicByteCount GetCongestionWindow() const override; |
126 QuicByteCount GetSlowStartThreshold() const override; | 126 QuicByteCount GetSlowStartThreshold() const override; |
127 CongestionControlType GetCongestionControlType() const override; | 127 CongestionControlType GetCongestionControlType() const override; |
128 std::string GetDebugState() const override; | 128 std::string GetDebugState() const override; |
129 void OnApplicationLimited(QuicByteCount bytes_in_flight) override; | 129 void OnApplicationLimited(QuicByteCount bytes_in_flight) override; |
130 // End implementation of SendAlgorithmInterface. | 130 // End implementation of SendAlgorithmInterface. |
131 | 131 |
132 // Gets the number of RTTs BBR remains in STARTUP phase. | 132 // Gets the number of RTTs BBR remains in STARTUP phase. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // Decides whether to enter or exit PROBE_RTT. | 189 // Decides whether to enter or exit PROBE_RTT. |
190 void MaybeEnterOrExitProbeRtt(QuicTime now, | 190 void MaybeEnterOrExitProbeRtt(QuicTime now, |
191 bool is_round_start, | 191 bool is_round_start, |
192 bool min_rtt_expired); | 192 bool min_rtt_expired); |
193 // Determines whether BBR needs to enter, exit or advance state of the | 193 // Determines whether BBR needs to enter, exit or advance state of the |
194 // recovery. | 194 // recovery. |
195 void UpdateRecoveryState(QuicPacketNumber last_acked_packet, | 195 void UpdateRecoveryState(QuicPacketNumber last_acked_packet, |
196 bool has_losses, | 196 bool has_losses, |
197 bool is_round_start); | 197 bool is_round_start); |
198 | 198 |
| 199 // Returns true if recent ack rate has decreased substantially and if sender |
| 200 // is allowed to continue sending when congestion window limited. |
| 201 bool SlowDeliveryAllowsSending(QuicTime now, QuicByteCount bytes_in_flight); |
| 202 |
| 203 // Updates history of recently received acks. Acks are considered recent |
| 204 // if received within kRecentlyAckedRttFraction x smoothed RTT in the past. |
| 205 // Adds new ack to recently_acked_ if |newly_acked_bytes| is non-zero. |
| 206 void UpdateRecentlyAcked(QuicTime new_ack_time, |
| 207 QuicByteCount newly_acked_bytes); |
| 208 |
199 // Updates the ack aggregation max filter in bytes. | 209 // Updates the ack aggregation max filter in bytes. |
200 void UpdateAckAggregationBytes(QuicTime ack_time, | 210 void UpdateAckAggregationBytes(QuicTime ack_time, |
201 QuicByteCount newly_acked_bytes); | 211 QuicByteCount newly_acked_bytes); |
202 | 212 |
203 // Determines the appropriate pacing rate for the connection. | 213 // Determines the appropriate pacing rate for the connection. |
204 void CalculatePacingRate(); | 214 void CalculatePacingRate(); |
205 // Determines the appropriate congestion window for the connection. | 215 // Determines the appropriate congestion window for the connection. |
206 void CalculateCongestionWindow(QuicByteCount bytes_acked); | 216 void CalculateCongestionWindow(QuicByteCount bytes_acked); |
207 // Determines the approriate window that constrains the in-flight during | 217 // Determines the approriate window that constrains the in-flight during |
208 // recovery. | 218 // recovery. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 273 |
264 // The gain used for the congestion window during PROBE_BW. Latched from | 274 // The gain used for the congestion window during PROBE_BW. Latched from |
265 // quic_bbr_cwnd_gain flag. | 275 // quic_bbr_cwnd_gain flag. |
266 const float congestion_window_gain_constant_; | 276 const float congestion_window_gain_constant_; |
267 // The coefficient by which mean RTT variance is added to the congestion | 277 // The coefficient by which mean RTT variance is added to the congestion |
268 // window. Latched from quic_bbr_rtt_variation_weight flag. | 278 // window. Latched from quic_bbr_rtt_variation_weight flag. |
269 const float rtt_variance_weight_; | 279 const float rtt_variance_weight_; |
270 // The number of RTTs to stay in STARTUP mode. Defaults to 3. | 280 // The number of RTTs to stay in STARTUP mode. Defaults to 3. |
271 QuicRoundTripCount num_startup_rtts_; | 281 QuicRoundTripCount num_startup_rtts_; |
272 | 282 |
| 283 // Gain to use when delivery rate is slow. |
| 284 // TODO(jri): Make this a constant if we decide to use this code for BBR. |
| 285 const float congestion_window_gain_for_slow_delivery_; |
| 286 // Threshold multiplier below which delivery is considered slow. |
| 287 // TODO(jri): Make this a constant if we decide to use this code for BBR. |
| 288 const float threshold_multiplier_for_slow_delivery_; |
| 289 |
273 // Number of round-trips in PROBE_BW mode, used for determining the current | 290 // Number of round-trips in PROBE_BW mode, used for determining the current |
274 // pacing gain cycle. | 291 // pacing gain cycle. |
275 int cycle_current_offset_; | 292 int cycle_current_offset_; |
276 // The time at which the last pacing gain cycle was started. | 293 // The time at which the last pacing gain cycle was started. |
277 QuicTime last_cycle_start_; | 294 QuicTime last_cycle_start_; |
278 | 295 |
279 // Indicates whether the connection has reached the full bandwidth mode. | 296 // Indicates whether the connection has reached the full bandwidth mode. |
280 bool is_at_full_bandwidth_; | 297 bool is_at_full_bandwidth_; |
281 // Number of rounds during which there was no significant bandwidth increase. | 298 // Number of rounds during which there was no significant bandwidth increase. |
282 QuicRoundTripCount rounds_without_bandwidth_gain_; | 299 QuicRoundTripCount rounds_without_bandwidth_gain_; |
(...skipping 15 matching lines...) Expand all Loading... |
298 bool last_sample_is_app_limited_; | 315 bool last_sample_is_app_limited_; |
299 | 316 |
300 // Current state of recovery. | 317 // Current state of recovery. |
301 RecoveryState recovery_state_; | 318 RecoveryState recovery_state_; |
302 // Receiving acknowledgement of a packet after |end_recovery_at_| will cause | 319 // Receiving acknowledgement of a packet after |end_recovery_at_| will cause |
303 // BBR to exit the recovery mode. | 320 // BBR to exit the recovery mode. |
304 QuicPacketNumber end_recovery_at_; | 321 QuicPacketNumber end_recovery_at_; |
305 // A window used to limit the number of bytes in flight during loss recovery. | 322 // A window used to limit the number of bytes in flight during loss recovery. |
306 QuicByteCount recovery_window_; | 323 QuicByteCount recovery_window_; |
307 | 324 |
| 325 // Records information about a received ack |
| 326 struct DataDelivered { |
| 327 QuicTime ack_time; |
| 328 QuicByteCount acked_bytes; |
| 329 }; |
| 330 |
| 331 // Data structure to record recently received acks. Used for determining |
| 332 // recently seen ack rate over a short period in the past. |
| 333 std::deque<DataDelivered> recently_acked_; |
| 334 QuicByteCount bytes_recently_acked_; |
| 335 |
308 DISALLOW_COPY_AND_ASSIGN(BbrSender); | 336 DISALLOW_COPY_AND_ASSIGN(BbrSender); |
309 }; | 337 }; |
310 | 338 |
311 QUIC_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, | 339 QUIC_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, |
312 const BbrSender::Mode& mode); | 340 const BbrSender::Mode& mode); |
313 QUIC_EXPORT_PRIVATE std::ostream& operator<<( | 341 QUIC_EXPORT_PRIVATE std::ostream& operator<<( |
314 std::ostream& os, | 342 std::ostream& os, |
315 const BbrSender::DebugState& state); | 343 const BbrSender::DebugState& state); |
316 | 344 |
317 } // namespace net | 345 } // namespace net |
318 | 346 |
319 #endif // NET_QUIC_CORE_CONGESTION_CONTROL_BBR_SENDER_H_ | 347 #endif // NET_QUIC_CORE_CONGESTION_CONTROL_BBR_SENDER_H_ |
OLD | NEW |