| 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/rtt_stats.h" | 10 #include "net/quic/congestion_control/rtt_stats.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 | 93 |
| 94 void TcpCubicSender::OnCongestionEvent( | 94 void TcpCubicSender::OnCongestionEvent( |
| 95 bool rtt_updated, | 95 bool rtt_updated, |
| 96 QuicByteCount bytes_in_flight, | 96 QuicByteCount bytes_in_flight, |
| 97 const CongestionVector& acked_packets, | 97 const CongestionVector& acked_packets, |
| 98 const CongestionVector& lost_packets) { | 98 const CongestionVector& lost_packets) { |
| 99 if (rtt_updated && InSlowStart() && | 99 if (rtt_updated && InSlowStart() && |
| 100 hybrid_slow_start_.ShouldExitSlowStart(rtt_stats_->latest_rtt(), | 100 hybrid_slow_start_.ShouldExitSlowStart(rtt_stats_->latest_rtt(), |
| 101 rtt_stats_->min_rtt(), | 101 rtt_stats_->MinRtt(), |
| 102 congestion_window_)) { | 102 congestion_window_)) { |
| 103 slowstart_threshold_ = congestion_window_; | 103 slowstart_threshold_ = congestion_window_; |
| 104 } | 104 } |
| 105 for (CongestionVector::const_iterator it = lost_packets.begin(); | 105 for (CongestionVector::const_iterator it = lost_packets.begin(); |
| 106 it != lost_packets.end(); ++it) { | 106 it != lost_packets.end(); ++it) { |
| 107 OnPacketLost(it->first, bytes_in_flight); | 107 OnPacketLost(it->first, bytes_in_flight); |
| 108 } | 108 } |
| 109 for (CongestionVector::const_iterator it = acked_packets.begin(); | 109 for (CongestionVector::const_iterator it = acked_packets.begin(); |
| 110 it != acked_packets.end(); ++it) { | 110 it != acked_packets.end(); ++it) { |
| 111 OnPacketAcked(it->first, it->second.bytes_sent, bytes_in_flight); | 111 OnPacketAcked(it->first, it->second.bytes_sent, bytes_in_flight); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 } | 205 } |
| 206 | 206 |
| 207 QuicBandwidth TcpCubicSender::PacingRate() const { | 207 QuicBandwidth TcpCubicSender::PacingRate() const { |
| 208 // We pace at twice the rate of the underlying sender's bandwidth estimate | 208 // We pace at twice the rate of the underlying sender's bandwidth estimate |
| 209 // during slow start and 1.25x during congestion avoidance to ensure pacing | 209 // during slow start and 1.25x during congestion avoidance to ensure pacing |
| 210 // doesn't prevent us from filling the window. | 210 // doesn't prevent us from filling the window. |
| 211 return BandwidthEstimate().Scale(InSlowStart() ? 2 : 1.25); | 211 return BandwidthEstimate().Scale(InSlowStart() ? 2 : 1.25); |
| 212 } | 212 } |
| 213 | 213 |
| 214 QuicBandwidth TcpCubicSender::BandwidthEstimate() const { | 214 QuicBandwidth TcpCubicSender::BandwidthEstimate() const { |
| 215 if (rtt_stats_->SmoothedRtt().IsZero()) { |
| 216 LOG(DFATAL) << "In BandwidthEstimate(), smoothed RTT is zero!"; |
| 217 return QuicBandwidth::Zero(); |
| 218 } |
| 215 return QuicBandwidth::FromBytesAndTimeDelta(GetCongestionWindow(), | 219 return QuicBandwidth::FromBytesAndTimeDelta(GetCongestionWindow(), |
| 216 rtt_stats_->SmoothedRtt()); | 220 rtt_stats_->SmoothedRtt()); |
| 217 } | 221 } |
| 218 | 222 |
| 219 bool TcpCubicSender::HasReliableBandwidthEstimate() const { | 223 bool TcpCubicSender::HasReliableBandwidthEstimate() const { |
| 220 return !InSlowStart() && !InRecovery(); | 224 return !InSlowStart() && !InRecovery(); |
| 221 } | 225 } |
| 222 | 226 |
| 223 QuicTime::Delta TcpCubicSender::RetransmissionDelay() const { | 227 QuicTime::Delta TcpCubicSender::RetransmissionDelay() const { |
| 224 if (!rtt_stats_->HasUpdates()) { | 228 if (!rtt_stats_->HasUpdates()) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 ++congestion_window_; | 297 ++congestion_window_; |
| 294 congestion_window_count_ = 0; | 298 congestion_window_count_ = 0; |
| 295 } | 299 } |
| 296 | 300 |
| 297 DVLOG(1) << "Reno; congestion window: " << congestion_window_ | 301 DVLOG(1) << "Reno; congestion window: " << congestion_window_ |
| 298 << " slowstart threshold: " << slowstart_threshold_ | 302 << " slowstart threshold: " << slowstart_threshold_ |
| 299 << " congestion window count: " << congestion_window_count_; | 303 << " congestion window count: " << congestion_window_count_; |
| 300 } else { | 304 } else { |
| 301 congestion_window_ = min(max_tcp_congestion_window_, | 305 congestion_window_ = min(max_tcp_congestion_window_, |
| 302 cubic_.CongestionWindowAfterAck( | 306 cubic_.CongestionWindowAfterAck( |
| 303 congestion_window_, rtt_stats_->min_rtt())); | 307 congestion_window_, rtt_stats_->MinRtt())); |
| 304 DVLOG(1) << "Cubic; congestion window: " << congestion_window_ | 308 DVLOG(1) << "Cubic; congestion window: " << congestion_window_ |
| 305 << " slowstart threshold: " << slowstart_threshold_; | 309 << " slowstart threshold: " << slowstart_threshold_; |
| 306 } | 310 } |
| 307 } | 311 } |
| 308 | 312 |
| 309 void TcpCubicSender::OnRetransmissionTimeout(bool packets_retransmitted) { | 313 void TcpCubicSender::OnRetransmissionTimeout(bool packets_retransmitted) { |
| 310 largest_sent_at_last_cutback_ = 0; | 314 largest_sent_at_last_cutback_ = 0; |
| 311 if (!packets_retransmitted) { | 315 if (!packets_retransmitted) { |
| 312 return; | 316 return; |
| 313 } | 317 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 return QuicTime::Delta::Zero(); | 371 return QuicTime::Delta::Zero(); |
| 368 } | 372 } |
| 369 return QuicTime::Delta::Infinite(); | 373 return QuicTime::Delta::Infinite(); |
| 370 } | 374 } |
| 371 | 375 |
| 372 CongestionControlType TcpCubicSender::GetCongestionControlType() const { | 376 CongestionControlType TcpCubicSender::GetCongestionControlType() const { |
| 373 return reno_ ? kReno : kCubic; | 377 return reno_ ? kReno : kCubic; |
| 374 } | 378 } |
| 375 | 379 |
| 376 } // namespace net | 380 } // namespace net |
| OLD | NEW |