| 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/prr_sender.h" | 10 #include "net/quic/congestion_control/prr_sender.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 71 } |
| 72 if (using_pacing) { | 72 if (using_pacing) { |
| 73 // Disable the ack train mode in hystart when pacing is enabled, since it | 73 // Disable the ack train mode in hystart when pacing is enabled, since it |
| 74 // may be falsely triggered. | 74 // may be falsely triggered. |
| 75 hybrid_slow_start_.set_ack_train_detection(false); | 75 hybrid_slow_start_.set_ack_train_detection(false); |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool TcpCubicSender::ResumeConnectionState( | 80 bool TcpCubicSender::ResumeConnectionState( |
| 81 const CachedNetworkParameters& cached_network_params) { | 81 const CachedNetworkParameters& cached_network_params, |
| 82 bool max_bandwidth_resumption) { |
| 82 // If the previous bandwidth estimate is less than an hour old, store in | 83 // If the previous bandwidth estimate is less than an hour old, store in |
| 83 // preparation for doing bandwidth resumption. | 84 // preparation for doing bandwidth resumption. |
| 84 int64 seconds_since_estimate = | 85 int64 seconds_since_estimate = |
| 85 clock_->WallNow().ToUNIXSeconds() - cached_network_params.timestamp(); | 86 clock_->WallNow().ToUNIXSeconds() - cached_network_params.timestamp(); |
| 86 if (seconds_since_estimate > kNumSecondsPerHour) { | 87 if (seconds_since_estimate > kNumSecondsPerHour) { |
| 87 return false; | 88 return false; |
| 88 } | 89 } |
| 89 | 90 |
| 90 QuicBandwidth bandwidth = QuicBandwidth::FromBytesPerSecond( | 91 QuicBandwidth bandwidth = QuicBandwidth::FromBytesPerSecond( |
| 91 cached_network_params.bandwidth_estimate_bytes_per_second()); | 92 max_bandwidth_resumption |
| 93 ? cached_network_params.max_bandwidth_estimate_bytes_per_second() |
| 94 : cached_network_params.bandwidth_estimate_bytes_per_second()); |
| 92 QuicTime::Delta rtt_ms = | 95 QuicTime::Delta rtt_ms = |
| 93 QuicTime::Delta::FromMilliseconds(cached_network_params.min_rtt_ms()); | 96 QuicTime::Delta::FromMilliseconds(cached_network_params.min_rtt_ms()); |
| 94 | 97 |
| 95 // Make sure CWND is in appropriate range (in case of bad data). | 98 // Make sure CWND is in appropriate range (in case of bad data). |
| 96 QuicPacketCount new_congestion_window = | 99 QuicPacketCount new_congestion_window = |
| 97 bandwidth.ToBytesPerPeriod(rtt_ms) / kMaxPacketSize; | 100 bandwidth.ToBytesPerPeriod(rtt_ms) / kMaxPacketSize; |
| 98 congestion_window_ = max(min(new_congestion_window, kMaxTcpCongestionWindow), | 101 congestion_window_ = max(min(new_congestion_window, kMaxTcpCongestionWindow), |
| 99 kMinCongestionWindowForBandwidthResumption); | 102 kMinCongestionWindowForBandwidthResumption); |
| 100 | 103 |
| 101 // TODO(rjshade): Set appropriate CWND when previous connection was in slow | 104 // TODO(rjshade): Set appropriate CWND when previous connection was in slow |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 hybrid_slow_start_.Restart(); | 360 hybrid_slow_start_.Restart(); |
| 358 slowstart_threshold_ = congestion_window_ / 2; | 361 slowstart_threshold_ = congestion_window_ / 2; |
| 359 congestion_window_ = min_congestion_window_; | 362 congestion_window_ = min_congestion_window_; |
| 360 } | 363 } |
| 361 | 364 |
| 362 CongestionControlType TcpCubicSender::GetCongestionControlType() const { | 365 CongestionControlType TcpCubicSender::GetCongestionControlType() const { |
| 363 return reno_ ? kReno : kCubic; | 366 return reno_ ? kReno : kCubic; |
| 364 } | 367 } |
| 365 | 368 |
| 366 } // namespace net | 369 } // namespace net |
| OLD | NEW |