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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 return QuicTime::Delta::Zero(); | 197 return QuicTime::Delta::Zero(); |
198 } | 198 } |
199 return QuicTime::Delta::Infinite(); | 199 return QuicTime::Delta::Infinite(); |
200 } | 200 } |
201 | 201 |
202 QuicByteCount TcpCubicSender::SendWindow() const { | 202 QuicByteCount TcpCubicSender::SendWindow() const { |
203 // What's the current send window in bytes. | 203 // What's the current send window in bytes. |
204 return min(receive_window_, GetCongestionWindow()); | 204 return min(receive_window_, GetCongestionWindow()); |
205 } | 205 } |
206 | 206 |
| 207 QuicBandwidth TcpCubicSender::PacingRate() const { |
| 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 |
| 210 // doesn't prevent us from filling the window. |
| 211 return BandwidthEstimate().Scale(InSlowStart() ? 2 : 1.25); |
| 212 } |
| 213 |
207 QuicBandwidth TcpCubicSender::BandwidthEstimate() const { | 214 QuicBandwidth TcpCubicSender::BandwidthEstimate() const { |
208 return QuicBandwidth::FromBytesAndTimeDelta(GetCongestionWindow(), | 215 return QuicBandwidth::FromBytesAndTimeDelta(GetCongestionWindow(), |
209 rtt_stats_->SmoothedRtt()); | 216 rtt_stats_->SmoothedRtt()); |
210 } | 217 } |
211 | 218 |
212 bool TcpCubicSender::HasReliableBandwidthEstimate() const { | 219 bool TcpCubicSender::HasReliableBandwidthEstimate() const { |
213 return !InSlowStart() && !InRecovery(); | 220 return !InSlowStart() && !InRecovery(); |
214 } | 221 } |
215 | 222 |
216 QuicTime::Delta TcpCubicSender::RetransmissionDelay() const { | 223 QuicTime::Delta TcpCubicSender::RetransmissionDelay() const { |
217 if (!rtt_stats_->HasUpdates()) { | 224 if (!rtt_stats_->HasUpdates()) { |
218 return QuicTime::Delta::Zero(); | 225 return QuicTime::Delta::Zero(); |
219 } | 226 } |
220 return QuicTime::Delta::FromMicroseconds( | 227 return rtt_stats_->SmoothedRtt().Add( |
221 rtt_stats_->SmoothedRtt().ToMicroseconds() + | 228 rtt_stats_->mean_deviation().Multiply(4)); |
222 4 * rtt_stats_->mean_deviation().ToMicroseconds()); | |
223 } | 229 } |
224 | 230 |
225 QuicByteCount TcpCubicSender::GetCongestionWindow() const { | 231 QuicByteCount TcpCubicSender::GetCongestionWindow() const { |
226 return congestion_window_ * kMaxSegmentSize; | 232 return congestion_window_ * kMaxSegmentSize; |
227 } | 233 } |
228 | 234 |
229 bool TcpCubicSender::InSlowStart() const { | 235 bool TcpCubicSender::InSlowStart() const { |
230 return congestion_window_ < slowstart_threshold_; | 236 return congestion_window_ < slowstart_threshold_; |
231 } | 237 } |
232 | 238 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 return QuicTime::Delta::Zero(); | 367 return QuicTime::Delta::Zero(); |
362 } | 368 } |
363 return QuicTime::Delta::Infinite(); | 369 return QuicTime::Delta::Infinite(); |
364 } | 370 } |
365 | 371 |
366 CongestionControlType TcpCubicSender::GetCongestionControlType() const { | 372 CongestionControlType TcpCubicSender::GetCongestionControlType() const { |
367 return reno_ ? kReno : kCubic; | 373 return reno_ ? kReno : kCubic; |
368 } | 374 } |
369 | 375 |
370 } // namespace net | 376 } // namespace net |
OLD | NEW |