| 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 | 10 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 feedback.tcp.accumulated_number_of_lost_packets; | 82 feedback.tcp.accumulated_number_of_lost_packets; |
| 83 if (recovered_lost_packets > 0) { | 83 if (recovered_lost_packets > 0) { |
| 84 // Assume the loss could be as late as the last acked packet. | 84 // Assume the loss could be as late as the last acked packet. |
| 85 OnPacketLost(largest_acked_sequence_number_, feedback_receive_time); | 85 OnPacketLost(largest_acked_sequence_number_, feedback_receive_time); |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 receive_window_ = feedback.tcp.receive_window; | 88 receive_window_ = feedback.tcp.receive_window; |
| 89 } | 89 } |
| 90 | 90 |
| 91 void TcpCubicSender::OnPacketAcked( | 91 void TcpCubicSender::OnPacketAcked( |
| 92 QuicPacketSequenceNumber acked_sequence_number, | 92 QuicPacketSequenceNumber acked_sequence_number, QuicByteCount acked_bytes) { |
| 93 QuicByteCount acked_bytes, | |
| 94 QuicTime::Delta rtt) { | |
| 95 DCHECK_GE(bytes_in_flight_, acked_bytes); | 93 DCHECK_GE(bytes_in_flight_, acked_bytes); |
| 96 bytes_in_flight_ -= acked_bytes; | 94 bytes_in_flight_ -= acked_bytes; |
| 97 largest_acked_sequence_number_ = max(acked_sequence_number, | 95 largest_acked_sequence_number_ = max(acked_sequence_number, |
| 98 largest_acked_sequence_number_); | 96 largest_acked_sequence_number_); |
| 99 CongestionAvoidance(acked_sequence_number); | 97 CongestionAvoidance(acked_sequence_number); |
| 100 AckAccounting(rtt); | |
| 101 if (end_sequence_number_ == acked_sequence_number) { | 98 if (end_sequence_number_ == acked_sequence_number) { |
| 102 DVLOG(1) << "Start update end sequence number @" << acked_sequence_number; | 99 DVLOG(1) << "Start update end sequence number @" << acked_sequence_number; |
| 103 update_end_sequence_number_ = true; | 100 update_end_sequence_number_ = true; |
| 104 } | 101 } |
| 105 } | 102 } |
| 106 | 103 |
| 107 void TcpCubicSender::OnPacketLost(QuicPacketSequenceNumber sequence_number, | 104 void TcpCubicSender::OnPacketLost(QuicPacketSequenceNumber sequence_number, |
| 108 QuicTime /*ack_receive_time*/) { | 105 QuicTime /*ack_receive_time*/) { |
| 109 // TCP NewReno (RFC6582) says that once a loss occurs, any losses in packets | 106 // TCP NewReno (RFC6582) says that once a loss occurs, any losses in packets |
| 110 // already sent should be treated as a single loss event, since it's expected. | 107 // already sent should be treated as a single loss event, since it's expected. |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 } | 276 } |
| 280 | 277 |
| 281 void TcpCubicSender::OnRetransmissionTimeout(bool packets_retransmitted) { | 278 void TcpCubicSender::OnRetransmissionTimeout(bool packets_retransmitted) { |
| 282 bytes_in_flight_ = 0; | 279 bytes_in_flight_ = 0; |
| 283 if (packets_retransmitted) { | 280 if (packets_retransmitted) { |
| 284 cubic_.Reset(); | 281 cubic_.Reset(); |
| 285 congestion_window_ = kMinimumCongestionWindow; | 282 congestion_window_ = kMinimumCongestionWindow; |
| 286 } | 283 } |
| 287 } | 284 } |
| 288 | 285 |
| 289 void TcpCubicSender::AckAccounting(QuicTime::Delta rtt) { | 286 void TcpCubicSender::UpdateRtt(QuicTime::Delta rtt) { |
| 290 if (rtt.IsInfinite() || rtt.IsZero()) { | 287 if (rtt.IsInfinite() || rtt.IsZero()) { |
| 291 DVLOG(1) << "Ignoring rtt, because it's " | 288 DVLOG(1) << "Ignoring rtt, because it's " |
| 292 << (rtt.IsZero() ? "Zero" : "Infinite"); | 289 << (rtt.IsZero() ? "Zero" : "Infinite"); |
| 293 return; | 290 return; |
| 294 } | 291 } |
| 295 // RTT can't be negative. | 292 // RTT can't be negative. |
| 296 DCHECK_LT(0, rtt.ToMicroseconds()); | 293 DCHECK_LT(0, rtt.ToMicroseconds()); |
| 297 | 294 |
| 298 // TODO(pwestin): Discard delay samples right after fast recovery, | 295 // TODO(pwestin): Discard delay samples right after fast recovery, |
| 299 // during 1 second?. | 296 // during 1 second?. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 326 hybrid_slow_start_.Reset(end_sequence_number_); | 323 hybrid_slow_start_.Reset(end_sequence_number_); |
| 327 } | 324 } |
| 328 hybrid_slow_start_.Update(rtt, delay_min_); | 325 hybrid_slow_start_.Update(rtt, delay_min_); |
| 329 if (hybrid_slow_start_.Exit()) { | 326 if (hybrid_slow_start_.Exit()) { |
| 330 slowstart_threshold_ = congestion_window_; | 327 slowstart_threshold_ = congestion_window_; |
| 331 } | 328 } |
| 332 } | 329 } |
| 333 } | 330 } |
| 334 | 331 |
| 335 } // namespace net | 332 } // namespace net |
| OLD | NEW |