| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 OnPacketAcked(it->first, it->second.bytes_sent, bytes_in_flight); | 131 OnPacketAcked(it->first, it->second.bytes_sent, bytes_in_flight); |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 | 134 |
| 135 void TcpCubicSender::OnPacketAcked( | 135 void TcpCubicSender::OnPacketAcked( |
| 136 QuicPacketSequenceNumber acked_sequence_number, | 136 QuicPacketSequenceNumber acked_sequence_number, |
| 137 QuicByteCount acked_bytes, | 137 QuicByteCount acked_bytes, |
| 138 QuicByteCount bytes_in_flight) { | 138 QuicByteCount bytes_in_flight) { |
| 139 largest_acked_sequence_number_ = max(acked_sequence_number, | 139 largest_acked_sequence_number_ = max(acked_sequence_number, |
| 140 largest_acked_sequence_number_); | 140 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; |
| 141 if (InRecovery()) { | 143 if (InRecovery()) { |
| 142 // PRR is used when in recovery. | 144 // PRR is used when in recovery. |
| 143 prr_.OnPacketAcked(acked_bytes); | 145 prr_.OnPacketAcked(acked_bytes); |
| 144 return; | 146 return; |
| 145 } | 147 } |
| 146 MaybeIncreaseCwnd(acked_sequence_number, bytes_in_flight); | 148 MaybeIncreaseCwnd(acked_sequence_number, bytes_in_flight); |
| 147 // TODO(ianswett): Should this even be called when not in slow start? | 149 // TODO(ianswett): Should this even be called when not in slow start? |
| 148 hybrid_slow_start_.OnPacketAcked(acked_sequence_number, InSlowStart()); | 150 hybrid_slow_start_.OnPacketAcked(acked_sequence_number, InSlowStart()); |
| 149 } | 151 } |
| 150 | 152 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 } | 340 } |
| 339 } | 341 } |
| 340 | 342 |
| 341 void TcpCubicSender::OnRetransmissionTimeout(bool packets_retransmitted) { | 343 void TcpCubicSender::OnRetransmissionTimeout(bool packets_retransmitted) { |
| 342 largest_sent_at_last_cutback_ = 0; | 344 largest_sent_at_last_cutback_ = 0; |
| 343 if (!packets_retransmitted) { | 345 if (!packets_retransmitted) { |
| 344 return; | 346 return; |
| 345 } | 347 } |
| 346 cubic_.Reset(); | 348 cubic_.Reset(); |
| 347 hybrid_slow_start_.Restart(); | 349 hybrid_slow_start_.Restart(); |
| 350 // Only reduce ssthresh once over multiple retransmissions. |
| 351 if (previous_congestion_window_ != 0) { |
| 352 return; |
| 353 } |
| 348 previous_slowstart_threshold_ = slowstart_threshold_; | 354 previous_slowstart_threshold_ = slowstart_threshold_; |
| 349 slowstart_threshold_ = congestion_window_ / 2; | 355 slowstart_threshold_ = congestion_window_ / 2; |
| 350 previous_congestion_window_ = congestion_window_; | 356 previous_congestion_window_ = congestion_window_; |
| 351 congestion_window_ = kMinimumCongestionWindow; | 357 congestion_window_ = kMinimumCongestionWindow; |
| 352 } | 358 } |
| 353 | 359 |
| 354 void TcpCubicSender::RevertRetransmissionTimeout() { | 360 void TcpCubicSender::RevertRetransmissionTimeout() { |
| 355 if (previous_congestion_window_ == 0) { | 361 if (previous_congestion_window_ == 0) { |
| 356 LOG(DFATAL) << "No previous congestion window to revert to."; | 362 LOG(DFATAL) << "No previous congestion window to revert to."; |
| 357 return; | 363 return; |
| 358 } | 364 } |
| 359 congestion_window_ = previous_congestion_window_; | 365 congestion_window_ = previous_congestion_window_; |
| 360 slowstart_threshold_ = previous_slowstart_threshold_; | 366 slowstart_threshold_ = previous_slowstart_threshold_; |
| 361 previous_congestion_window_ = 0; | 367 previous_congestion_window_ = 0; |
| 362 } | 368 } |
| 363 | 369 |
| 364 CongestionControlType TcpCubicSender::GetCongestionControlType() const { | 370 CongestionControlType TcpCubicSender::GetCongestionControlType() const { |
| 365 return reno_ ? kReno : kCubic; | 371 return reno_ ? kReno : kCubic; |
| 366 } | 372 } |
| 367 | 373 |
| 368 } // namespace net | 374 } // namespace net |
| OLD | NEW |