| 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 16 matching lines...) Expand all Loading... |
| 27 const uint32 kDefaultNumConnections = 2; // N-connection emulation. | 27 const uint32 kDefaultNumConnections = 2; // N-connection emulation. |
| 28 } // namespace | 28 } // namespace |
| 29 | 29 |
| 30 TcpCubicSender::TcpCubicSender(const QuicClock* clock, | 30 TcpCubicSender::TcpCubicSender(const QuicClock* clock, |
| 31 const RttStats* rtt_stats, | 31 const RttStats* rtt_stats, |
| 32 bool reno, | 32 bool reno, |
| 33 QuicPacketCount initial_tcp_congestion_window, | 33 QuicPacketCount initial_tcp_congestion_window, |
| 34 QuicPacketCount max_tcp_congestion_window, | 34 QuicPacketCount max_tcp_congestion_window, |
| 35 QuicConnectionStats* stats) | 35 QuicConnectionStats* stats) |
| 36 : hybrid_slow_start_(clock), | 36 : hybrid_slow_start_(clock), |
| 37 cubic_(clock, stats), | 37 cubic_(clock), |
| 38 rtt_stats_(rtt_stats), | 38 rtt_stats_(rtt_stats), |
| 39 stats_(stats), | 39 stats_(stats), |
| 40 reno_(reno), | 40 reno_(reno), |
| 41 num_connections_(kDefaultNumConnections), | 41 num_connections_(kDefaultNumConnections), |
| 42 congestion_window_count_(0), | 42 congestion_window_count_(0), |
| 43 largest_sent_sequence_number_(0), | 43 largest_sent_sequence_number_(0), |
| 44 largest_acked_sequence_number_(0), | 44 largest_acked_sequence_number_(0), |
| 45 largest_sent_at_last_cutback_(0), | 45 largest_sent_at_last_cutback_(0), |
| 46 congestion_window_(initial_tcp_congestion_window), | 46 congestion_window_(initial_tcp_congestion_window), |
| 47 previous_congestion_window_(0), | |
| 48 slowstart_threshold_(max_tcp_congestion_window), | 47 slowstart_threshold_(max_tcp_congestion_window), |
| 49 previous_slowstart_threshold_(0), | |
| 50 last_cutback_exited_slowstart_(false), | 48 last_cutback_exited_slowstart_(false), |
| 51 max_tcp_congestion_window_(max_tcp_congestion_window), | 49 max_tcp_congestion_window_(max_tcp_congestion_window), |
| 52 clock_(clock) {} | 50 clock_(clock) { |
| 51 } |
| 53 | 52 |
| 54 TcpCubicSender::~TcpCubicSender() { | 53 TcpCubicSender::~TcpCubicSender() { |
| 55 UMA_HISTOGRAM_COUNTS("Net.QuicSession.FinalTcpCwnd", congestion_window_); | 54 UMA_HISTOGRAM_COUNTS("Net.QuicSession.FinalTcpCwnd", congestion_window_); |
| 56 } | 55 } |
| 57 | 56 |
| 58 void TcpCubicSender::SetFromConfig(const QuicConfig& config, | 57 void TcpCubicSender::SetFromConfig(const QuicConfig& config, |
| 59 bool is_server, | 58 bool is_server, |
| 60 bool using_pacing) { | 59 bool using_pacing) { |
| 61 if (is_server) { | 60 if (is_server) { |
| 62 if (config.HasReceivedConnectionOptions() && | 61 if (config.HasReceivedConnectionOptions() && |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 OnPacketAcked(it->first, it->second.bytes_sent, bytes_in_flight); | 130 OnPacketAcked(it->first, it->second.bytes_sent, bytes_in_flight); |
| 132 } | 131 } |
| 133 } | 132 } |
| 134 | 133 |
| 135 void TcpCubicSender::OnPacketAcked( | 134 void TcpCubicSender::OnPacketAcked( |
| 136 QuicPacketSequenceNumber acked_sequence_number, | 135 QuicPacketSequenceNumber acked_sequence_number, |
| 137 QuicByteCount acked_bytes, | 136 QuicByteCount acked_bytes, |
| 138 QuicByteCount bytes_in_flight) { | 137 QuicByteCount bytes_in_flight) { |
| 139 largest_acked_sequence_number_ = max(acked_sequence_number, | 138 largest_acked_sequence_number_ = max(acked_sequence_number, |
| 140 largest_acked_sequence_number_); | 139 largest_acked_sequence_number_); |
| 141 // As soon as a packet is acked, ensure we're no longer in RTO mode. | |
| 142 previous_congestion_window_ = 0; | |
| 143 if (InRecovery()) { | 140 if (InRecovery()) { |
| 144 // PRR is used when in recovery. | 141 // PRR is used when in recovery. |
| 145 prr_.OnPacketAcked(acked_bytes); | 142 prr_.OnPacketAcked(acked_bytes); |
| 146 return; | 143 return; |
| 147 } | 144 } |
| 148 MaybeIncreaseCwnd(acked_sequence_number, bytes_in_flight); | 145 MaybeIncreaseCwnd(acked_sequence_number, bytes_in_flight); |
| 149 // TODO(ianswett): Should this even be called when not in slow start? | 146 // TODO(ianswett): Should this even be called when not in slow start? |
| 150 hybrid_slow_start_.OnPacketAcked(acked_sequence_number, InSlowStart()); | 147 hybrid_slow_start_.OnPacketAcked(acked_sequence_number, InSlowStart()); |
| 151 } | 148 } |
| 152 | 149 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 } | 337 } |
| 341 } | 338 } |
| 342 | 339 |
| 343 void TcpCubicSender::OnRetransmissionTimeout(bool packets_retransmitted) { | 340 void TcpCubicSender::OnRetransmissionTimeout(bool packets_retransmitted) { |
| 344 largest_sent_at_last_cutback_ = 0; | 341 largest_sent_at_last_cutback_ = 0; |
| 345 if (!packets_retransmitted) { | 342 if (!packets_retransmitted) { |
| 346 return; | 343 return; |
| 347 } | 344 } |
| 348 cubic_.Reset(); | 345 cubic_.Reset(); |
| 349 hybrid_slow_start_.Restart(); | 346 hybrid_slow_start_.Restart(); |
| 350 // Only reduce ssthresh once over multiple retransmissions. | |
| 351 if (previous_congestion_window_ != 0) { | |
| 352 return; | |
| 353 } | |
| 354 previous_slowstart_threshold_ = slowstart_threshold_; | |
| 355 slowstart_threshold_ = congestion_window_ / 2; | 347 slowstart_threshold_ = congestion_window_ / 2; |
| 356 previous_congestion_window_ = congestion_window_; | |
| 357 congestion_window_ = kMinimumCongestionWindow; | 348 congestion_window_ = kMinimumCongestionWindow; |
| 358 } | 349 } |
| 359 | 350 |
| 360 void TcpCubicSender::RevertRetransmissionTimeout() { | |
| 361 if (previous_congestion_window_ == 0) { | |
| 362 LOG(DFATAL) << "No previous congestion window to revert to."; | |
| 363 return; | |
| 364 } | |
| 365 congestion_window_ = previous_congestion_window_; | |
| 366 slowstart_threshold_ = previous_slowstart_threshold_; | |
| 367 previous_congestion_window_ = 0; | |
| 368 } | |
| 369 | |
| 370 CongestionControlType TcpCubicSender::GetCongestionControlType() const { | 351 CongestionControlType TcpCubicSender::GetCongestionControlType() const { |
| 371 return reno_ ? kReno : kCubic; | 352 return reno_ ? kReno : kCubic; |
| 372 } | 353 } |
| 373 | 354 |
| 374 } // namespace net | 355 } // namespace net |
| OLD | NEW |