OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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_bytes.h" | 5 #include "net/quic/congestion_control/tcp_cubic_sender_bytes.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "net/quic/congestion_control/prr_sender.h" | 9 #include "net/quic/congestion_control/prr_sender.h" |
10 #include "net/quic/congestion_control/rtt_stats.h" | 10 #include "net/quic/congestion_control/rtt_stats.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 void TcpCubicSenderBytes::SetMaxCongestionWindow( | 74 void TcpCubicSenderBytes::SetMaxCongestionWindow( |
75 QuicByteCount max_congestion_window) { | 75 QuicByteCount max_congestion_window) { |
76 max_congestion_window_ = max_congestion_window; | 76 max_congestion_window_ = max_congestion_window; |
77 } | 77 } |
78 | 78 |
79 void TcpCubicSenderBytes::ExitSlowstart() { | 79 void TcpCubicSenderBytes::ExitSlowstart() { |
80 slowstart_threshold_ = congestion_window_; | 80 slowstart_threshold_ = congestion_window_; |
81 } | 81 } |
82 | 82 |
83 void TcpCubicSenderBytes::OnPacketLost(QuicPacketNumber packet_number, | 83 void TcpCubicSenderBytes::OnPacketLost(QuicPacketNumber packet_number, |
| 84 QuicByteCount lost_bytes, |
84 QuicByteCount bytes_in_flight) { | 85 QuicByteCount bytes_in_flight) { |
85 // TCP NewReno (RFC6582) says that once a loss occurs, any losses in packets | 86 // TCP NewReno (RFC6582) says that once a loss occurs, any losses in packets |
86 // already sent should be treated as a single loss event, since it's expected. | 87 // already sent should be treated as a single loss event, since it's expected. |
87 if (packet_number <= largest_sent_at_last_cutback_) { | 88 if (packet_number <= largest_sent_at_last_cutback_) { |
88 if (last_cutback_exited_slowstart_) { | 89 if (last_cutback_exited_slowstart_) { |
89 ++stats_->slowstart_packets_lost; | 90 ++stats_->slowstart_packets_lost; |
| 91 stats_->slowstart_bytes_lost += lost_bytes; |
90 if (slow_start_large_reduction_) { | 92 if (slow_start_large_reduction_) { |
91 // Reduce congestion window by 1 MSS for every loss. | 93 // Reduce congestion window by lost_bytes for every loss. |
92 congestion_window_ = | 94 congestion_window_ = |
93 max(congestion_window_ - kDefaultTCPMSS, min_congestion_window_); | 95 max(congestion_window_ - lost_bytes, min_congestion_window_); |
94 slowstart_threshold_ = congestion_window_; | 96 slowstart_threshold_ = congestion_window_; |
95 } | 97 } |
96 } | 98 } |
97 DVLOG(1) << "Ignoring loss for largest_missing:" << packet_number | 99 DVLOG(1) << "Ignoring loss for largest_missing:" << packet_number |
98 << " because it was sent prior to the last CWND cutback."; | 100 << " because it was sent prior to the last CWND cutback."; |
99 return; | 101 return; |
100 } | 102 } |
101 ++stats_->tcp_loss_events; | 103 ++stats_->tcp_loss_events; |
102 last_cutback_exited_slowstart_ = InSlowStart(); | 104 last_cutback_exited_slowstart_ = InSlowStart(); |
103 if (InSlowStart()) { | 105 if (InSlowStart()) { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 congestion_window_ = initial_tcp_congestion_window_; | 200 congestion_window_ = initial_tcp_congestion_window_; |
199 max_congestion_window_ = initial_max_tcp_congestion_window_; | 201 max_congestion_window_ = initial_max_tcp_congestion_window_; |
200 slowstart_threshold_ = initial_max_tcp_congestion_window_; | 202 slowstart_threshold_ = initial_max_tcp_congestion_window_; |
201 } | 203 } |
202 | 204 |
203 CongestionControlType TcpCubicSenderBytes::GetCongestionControlType() const { | 205 CongestionControlType TcpCubicSenderBytes::GetCongestionControlType() const { |
204 return reno_ ? kRenoBytes : kCubicBytes; | 206 return reno_ ? kRenoBytes : kCubicBytes; |
205 } | 207 } |
206 | 208 |
207 } // namespace net | 209 } // namespace net |
OLD | NEW |