| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 slowstart_threshold_(max_tcp_congestion_window), | 50 slowstart_threshold_(max_tcp_congestion_window), |
| 51 previous_slowstart_threshold_(0), | 51 previous_slowstart_threshold_(0), |
| 52 last_cutback_exited_slowstart_(false), | 52 last_cutback_exited_slowstart_(false), |
| 53 max_tcp_congestion_window_(max_tcp_congestion_window) { | 53 max_tcp_congestion_window_(max_tcp_congestion_window) { |
| 54 } | 54 } |
| 55 | 55 |
| 56 TcpCubicSender::~TcpCubicSender() { | 56 TcpCubicSender::~TcpCubicSender() { |
| 57 UMA_HISTOGRAM_COUNTS("Net.QuicSession.FinalTcpCwnd", congestion_window_); | 57 UMA_HISTOGRAM_COUNTS("Net.QuicSession.FinalTcpCwnd", congestion_window_); |
| 58 } | 58 } |
| 59 | 59 |
| 60 bool TcpCubicSender::InSlowStart() const { | |
| 61 return congestion_window_ < slowstart_threshold_; | |
| 62 } | |
| 63 | |
| 64 void TcpCubicSender::SetFromConfig(const QuicConfig& config, bool is_server) { | 60 void TcpCubicSender::SetFromConfig(const QuicConfig& config, bool is_server) { |
| 65 if (is_server && config.HasReceivedInitialCongestionWindow()) { | 61 if (is_server && config.HasReceivedInitialCongestionWindow()) { |
| 66 // Set the initial window size. | 62 // Set the initial window size. |
| 67 congestion_window_ = min(kMaxInitialWindow, | 63 congestion_window_ = min(kMaxInitialWindow, |
| 68 config.ReceivedInitialCongestionWindow()); | 64 config.ReceivedInitialCongestionWindow()); |
| 69 } | 65 } |
| 70 } | 66 } |
| 71 | 67 |
| 72 void TcpCubicSender::OnIncomingQuicCongestionFeedbackFrame( | 68 void TcpCubicSender::OnIncomingQuicCongestionFeedbackFrame( |
| 73 const QuicCongestionFeedbackFrame& feedback, | 69 const QuicCongestionFeedbackFrame& feedback, |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 } | 202 } |
| 207 return QuicTime::Delta::FromMicroseconds( | 203 return QuicTime::Delta::FromMicroseconds( |
| 208 rtt_stats_->SmoothedRtt().ToMicroseconds() + | 204 rtt_stats_->SmoothedRtt().ToMicroseconds() + |
| 209 4 * rtt_stats_->mean_deviation().ToMicroseconds()); | 205 4 * rtt_stats_->mean_deviation().ToMicroseconds()); |
| 210 } | 206 } |
| 211 | 207 |
| 212 QuicByteCount TcpCubicSender::GetCongestionWindow() const { | 208 QuicByteCount TcpCubicSender::GetCongestionWindow() const { |
| 213 return congestion_window_ * kMaxSegmentSize; | 209 return congestion_window_ * kMaxSegmentSize; |
| 214 } | 210 } |
| 215 | 211 |
| 212 bool TcpCubicSender::InSlowStart() const { |
| 213 return congestion_window_ < slowstart_threshold_; |
| 214 } |
| 215 |
| 216 QuicByteCount TcpCubicSender::GetSlowStartThreshold() const { | 216 QuicByteCount TcpCubicSender::GetSlowStartThreshold() const { |
| 217 return slowstart_threshold_ * kMaxSegmentSize; | 217 return slowstart_threshold_ * kMaxSegmentSize; |
| 218 } | 218 } |
| 219 | 219 |
| 220 bool TcpCubicSender::IsCwndLimited(QuicByteCount bytes_in_flight) const { | 220 bool TcpCubicSender::IsCwndLimited(QuicByteCount bytes_in_flight) const { |
| 221 const QuicByteCount congestion_window_bytes = congestion_window_ * | 221 const QuicByteCount congestion_window_bytes = congestion_window_ * |
| 222 kMaxSegmentSize; | 222 kMaxSegmentSize; |
| 223 if (bytes_in_flight >= congestion_window_bytes) { | 223 if (bytes_in_flight >= congestion_window_bytes) { |
| 224 return true; | 224 return true; |
| 225 } | 225 } |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 // AvailableSendWindow = | 339 // AvailableSendWindow = |
| 340 // CEIL(prr_delivered * ssthresh / BytesInFlightAtLoss) - prr_sent | 340 // CEIL(prr_delivered * ssthresh / BytesInFlightAtLoss) - prr_sent |
| 341 if (prr_delivered_ * slowstart_threshold_ * kMaxSegmentSize > | 341 if (prr_delivered_ * slowstart_threshold_ * kMaxSegmentSize > |
| 342 prr_out_ * bytes_in_flight_before_loss_) { | 342 prr_out_ * bytes_in_flight_before_loss_) { |
| 343 return QuicTime::Delta::Zero(); | 343 return QuicTime::Delta::Zero(); |
| 344 } | 344 } |
| 345 return QuicTime::Delta::Infinite(); | 345 return QuicTime::Delta::Infinite(); |
| 346 } | 346 } |
| 347 | 347 |
| 348 } // namespace net | 348 } // namespace net |
| OLD | NEW |