| 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 26 matching lines...) Expand all Loading... |
| 37 cubic_(clock), | 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) { |
| 53 } | 51 } |
| 54 | 52 |
| 55 TcpCubicSender::~TcpCubicSender() { | 53 TcpCubicSender::~TcpCubicSender() { |
| 56 UMA_HISTOGRAM_COUNTS("Net.QuicSession.FinalTcpCwnd", congestion_window_); | 54 UMA_HISTOGRAM_COUNTS("Net.QuicSession.FinalTcpCwnd", congestion_window_); |
| 57 } | 55 } |
| 58 | 56 |
| 59 void TcpCubicSender::SetFromConfig(const QuicConfig& config, | 57 void TcpCubicSender::SetFromConfig(const QuicConfig& config, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 OnPacketAcked(it->first, it->second.bytes_sent, bytes_in_flight); | 130 OnPacketAcked(it->first, it->second.bytes_sent, bytes_in_flight); |
| 133 } | 131 } |
| 134 } | 132 } |
| 135 | 133 |
| 136 void TcpCubicSender::OnPacketAcked( | 134 void TcpCubicSender::OnPacketAcked( |
| 137 QuicPacketSequenceNumber acked_sequence_number, | 135 QuicPacketSequenceNumber acked_sequence_number, |
| 138 QuicByteCount acked_bytes, | 136 QuicByteCount acked_bytes, |
| 139 QuicByteCount bytes_in_flight) { | 137 QuicByteCount bytes_in_flight) { |
| 140 largest_acked_sequence_number_ = max(acked_sequence_number, | 138 largest_acked_sequence_number_ = max(acked_sequence_number, |
| 141 largest_acked_sequence_number_); | 139 largest_acked_sequence_number_); |
| 142 // As soon as a packet is acked, ensure we're no longer in RTO mode. | |
| 143 previous_congestion_window_ = 0; | |
| 144 if (InRecovery()) { | 140 if (InRecovery()) { |
| 145 // PRR is used when in recovery. | 141 // PRR is used when in recovery. |
| 146 prr_.OnPacketAcked(acked_bytes); | 142 prr_.OnPacketAcked(acked_bytes); |
| 147 return; | 143 return; |
| 148 } | 144 } |
| 149 MaybeIncreaseCwnd(acked_sequence_number, bytes_in_flight); | 145 MaybeIncreaseCwnd(acked_sequence_number, bytes_in_flight); |
| 150 // 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? |
| 151 hybrid_slow_start_.OnPacketAcked(acked_sequence_number, InSlowStart()); | 147 hybrid_slow_start_.OnPacketAcked(acked_sequence_number, InSlowStart()); |
| 152 } | 148 } |
| 153 | 149 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 } | 337 } |
| 342 } | 338 } |
| 343 | 339 |
| 344 void TcpCubicSender::OnRetransmissionTimeout(bool packets_retransmitted) { | 340 void TcpCubicSender::OnRetransmissionTimeout(bool packets_retransmitted) { |
| 345 largest_sent_at_last_cutback_ = 0; | 341 largest_sent_at_last_cutback_ = 0; |
| 346 if (!packets_retransmitted) { | 342 if (!packets_retransmitted) { |
| 347 return; | 343 return; |
| 348 } | 344 } |
| 349 cubic_.Reset(); | 345 cubic_.Reset(); |
| 350 hybrid_slow_start_.Restart(); | 346 hybrid_slow_start_.Restart(); |
| 351 // Only reduce ssthresh once over multiple retransmissions. | |
| 352 if (previous_congestion_window_ != 0) { | |
| 353 return; | |
| 354 } | |
| 355 previous_slowstart_threshold_ = slowstart_threshold_; | |
| 356 slowstart_threshold_ = congestion_window_ / 2; | 347 slowstart_threshold_ = congestion_window_ / 2; |
| 357 previous_congestion_window_ = congestion_window_; | |
| 358 congestion_window_ = kMinimumCongestionWindow; | 348 congestion_window_ = kMinimumCongestionWindow; |
| 359 } | 349 } |
| 360 | 350 |
| 361 void TcpCubicSender::RevertRetransmissionTimeout() { | |
| 362 if (previous_congestion_window_ == 0) { | |
| 363 LOG(DFATAL) << "No previous congestion window to revert to."; | |
| 364 return; | |
| 365 } | |
| 366 congestion_window_ = previous_congestion_window_; | |
| 367 slowstart_threshold_ = previous_slowstart_threshold_; | |
| 368 previous_congestion_window_ = 0; | |
| 369 } | |
| 370 | |
| 371 CongestionControlType TcpCubicSender::GetCongestionControlType() const { | 351 CongestionControlType TcpCubicSender::GetCongestionControlType() const { |
| 372 return reno_ ? kReno : kCubic; | 352 return reno_ ? kReno : kCubic; |
| 373 } | 353 } |
| 374 | 354 |
| 375 } // namespace net | 355 } // namespace net |
| OLD | NEW |