| 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 QuicByteCount TcpCubicSender::SendWindow() const { | 189 QuicByteCount TcpCubicSender::SendWindow() const { |
| 190 // What's the current send window in bytes. | 190 // What's the current send window in bytes. |
| 191 return min(receive_window_, GetCongestionWindow()); | 191 return min(receive_window_, GetCongestionWindow()); |
| 192 } | 192 } |
| 193 | 193 |
| 194 QuicBandwidth TcpCubicSender::BandwidthEstimate() const { | 194 QuicBandwidth TcpCubicSender::BandwidthEstimate() const { |
| 195 return QuicBandwidth::FromBytesAndTimeDelta(GetCongestionWindow(), | 195 return QuicBandwidth::FromBytesAndTimeDelta(GetCongestionWindow(), |
| 196 rtt_stats_->SmoothedRtt()); | 196 rtt_stats_->SmoothedRtt()); |
| 197 } | 197 } |
| 198 | 198 |
| 199 bool TcpCubicSender::HasReliableBandwidthEstimate() const { |
| 200 return !InSlowStart() && !InRecovery(); |
| 201 } |
| 202 |
| 199 QuicTime::Delta TcpCubicSender::RetransmissionDelay() const { | 203 QuicTime::Delta TcpCubicSender::RetransmissionDelay() const { |
| 200 if (!rtt_stats_->HasUpdates()) { | 204 if (!rtt_stats_->HasUpdates()) { |
| 201 return QuicTime::Delta::Zero(); | 205 return QuicTime::Delta::Zero(); |
| 202 } | 206 } |
| 203 return QuicTime::Delta::FromMicroseconds( | 207 return QuicTime::Delta::FromMicroseconds( |
| 204 rtt_stats_->SmoothedRtt().ToMicroseconds() + | 208 rtt_stats_->SmoothedRtt().ToMicroseconds() + |
| 205 4 * rtt_stats_->mean_deviation().ToMicroseconds()); | 209 4 * rtt_stats_->mean_deviation().ToMicroseconds()); |
| 206 } | 210 } |
| 207 | 211 |
| 208 QuicByteCount TcpCubicSender::GetCongestionWindow() const { | 212 QuicByteCount TcpCubicSender::GetCongestionWindow() const { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 // AvailableSendWindow = | 335 // AvailableSendWindow = |
| 332 // CEIL(prr_delivered * ssthresh / BytesInFlightAtLoss) - prr_sent | 336 // CEIL(prr_delivered * ssthresh / BytesInFlightAtLoss) - prr_sent |
| 333 if (prr_delivered_ * slowstart_threshold_ * kMaxSegmentSize > | 337 if (prr_delivered_ * slowstart_threshold_ * kMaxSegmentSize > |
| 334 prr_out_ * bytes_in_flight_before_loss_) { | 338 prr_out_ * bytes_in_flight_before_loss_) { |
| 335 return QuicTime::Delta::Zero(); | 339 return QuicTime::Delta::Zero(); |
| 336 } | 340 } |
| 337 return QuicTime::Delta::Infinite(); | 341 return QuicTime::Delta::Infinite(); |
| 338 } | 342 } |
| 339 | 343 |
| 340 } // namespace net | 344 } // namespace net |
| OLD | NEW |