| 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_packets.h" | 5 #include "net/quic/congestion_control/tcp_cubic_sender_packets.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "net/quic/congestion_control/prr_sender.h" | 10 #include "net/quic/congestion_control/prr_sender.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 void TcpCubicSenderPackets::SetMaxCongestionWindow( | 73 void TcpCubicSenderPackets::SetMaxCongestionWindow( |
| 74 QuicByteCount max_congestion_window) { | 74 QuicByteCount max_congestion_window) { |
| 75 max_tcp_congestion_window_ = max_congestion_window / kDefaultTCPMSS; | 75 max_tcp_congestion_window_ = max_congestion_window / kDefaultTCPMSS; |
| 76 } | 76 } |
| 77 | 77 |
| 78 void TcpCubicSenderPackets::ExitSlowstart() { | 78 void TcpCubicSenderPackets::ExitSlowstart() { |
| 79 slowstart_threshold_ = congestion_window_; | 79 slowstart_threshold_ = congestion_window_; |
| 80 } | 80 } |
| 81 | 81 |
| 82 void TcpCubicSenderPackets::OnPacketLost(QuicPacketNumber packet_number, | 82 void TcpCubicSenderPackets::OnPacketLost(QuicPacketNumber packet_number, |
| 83 QuicByteCount lost_bytes, |
| 83 QuicByteCount bytes_in_flight) { | 84 QuicByteCount bytes_in_flight) { |
| 84 // TCP NewReno (RFC6582) says that once a loss occurs, any losses in packets | 85 // TCP NewReno (RFC6582) says that once a loss occurs, any losses in packets |
| 85 // already sent should be treated as a single loss event, since it's expected. | 86 // already sent should be treated as a single loss event, since it's expected. |
| 86 if (packet_number <= largest_sent_at_last_cutback_) { | 87 if (packet_number <= largest_sent_at_last_cutback_) { |
| 87 if (last_cutback_exited_slowstart_) { | 88 if (last_cutback_exited_slowstart_) { |
| 88 ++stats_->slowstart_packets_lost; | 89 ++stats_->slowstart_packets_lost; |
| 90 stats_->slowstart_bytes_lost += lost_bytes; |
| 89 if (slow_start_large_reduction_) { | 91 if (slow_start_large_reduction_) { |
| 90 // Reduce congestion window by 1 for every loss. | 92 if (FLAGS_quic_sslr_byte_conservation) { |
| 91 congestion_window_ = | 93 if (stats_->slowstart_packets_lost == 1 || |
| 92 max(congestion_window_ - 1, min_congestion_window_); | 94 (stats_->slowstart_bytes_lost / kDefaultTCPMSS) > |
| 95 (stats_->slowstart_bytes_lost - lost_bytes) / |
| 96 kDefaultTCPMSS) { |
| 97 // Reduce congestion window by 1 for every mss of bytes lost. |
| 98 congestion_window_ = |
| 99 max(congestion_window_ - 1, min_congestion_window_); |
| 100 } |
| 101 } else { |
| 102 // Reduce congestion window by 1 for every loss. |
| 103 congestion_window_ = |
| 104 max(congestion_window_ - 1, min_congestion_window_); |
| 105 } |
| 93 slowstart_threshold_ = congestion_window_; | 106 slowstart_threshold_ = congestion_window_; |
| 94 } | 107 } |
| 95 } | 108 } |
| 96 DVLOG(1) << "Ignoring loss for largest_missing:" << packet_number | 109 DVLOG(1) << "Ignoring loss for largest_missing:" << packet_number |
| 97 << " because it was sent prior to the last CWND cutback."; | 110 << " because it was sent prior to the last CWND cutback."; |
| 98 return; | 111 return; |
| 99 } | 112 } |
| 100 ++stats_->tcp_loss_events; | 113 ++stats_->tcp_loss_events; |
| 101 last_cutback_exited_slowstart_ = InSlowStart(); | 114 last_cutback_exited_slowstart_ = InSlowStart(); |
| 102 if (InSlowStart()) { | 115 if (InSlowStart()) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 congestion_window_ = initial_tcp_congestion_window_; | 208 congestion_window_ = initial_tcp_congestion_window_; |
| 196 slowstart_threshold_ = initial_max_tcp_congestion_window_; | 209 slowstart_threshold_ = initial_max_tcp_congestion_window_; |
| 197 max_tcp_congestion_window_ = initial_max_tcp_congestion_window_; | 210 max_tcp_congestion_window_ = initial_max_tcp_congestion_window_; |
| 198 } | 211 } |
| 199 | 212 |
| 200 CongestionControlType TcpCubicSenderPackets::GetCongestionControlType() const { | 213 CongestionControlType TcpCubicSenderPackets::GetCongestionControlType() const { |
| 201 return reno_ ? kReno : kCubic; | 214 return reno_ ? kReno : kCubic; |
| 202 } | 215 } |
| 203 | 216 |
| 204 } // namespace net | 217 } // namespace net |
| OLD | NEW |