OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/pacing_sender.h" | 5 #include "net/quic/congestion_control/pacing_sender.h" |
6 | 6 |
7 namespace net { | 7 namespace net { |
8 | 8 |
9 PacingSender::PacingSender(SendAlgorithmInterface* sender, | 9 PacingSender::PacingSender(SendAlgorithmInterface* sender, |
10 QuicTime::Delta alarm_granularity, | 10 QuicTime::Delta alarm_granularity, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 } | 60 } |
61 if (burst_tokens_ > 0) { | 61 if (burst_tokens_ > 0) { |
62 --burst_tokens_; | 62 --burst_tokens_; |
63 was_last_send_delayed_ = false; | 63 was_last_send_delayed_ = false; |
64 last_delayed_packet_sent_time_ = QuicTime::Zero(); | 64 last_delayed_packet_sent_time_ = QuicTime::Zero(); |
65 next_packet_send_time_ = QuicTime::Zero(); | 65 next_packet_send_time_ = QuicTime::Zero(); |
66 return in_flight; | 66 return in_flight; |
67 } | 67 } |
68 // The next packet should be sent as soon as the current packets has | 68 // The next packet should be sent as soon as the current packets has |
69 // been transferred. We pace at twice the rate of the underlying | 69 // been transferred. We pace at twice the rate of the underlying |
70 // sender's bandwidth estimate to help ensure that pacing doesn't become | 70 // sender's bandwidth estimate during slow start and 1.25x during congestion |
71 // a bottleneck. | 71 // avoidance to ensure pacing doesn't prevent us from filling the window. |
72 const float kPacingAggression = 2; | 72 const float kPacingAggression = sender_->InSlowStart() ? 2 : 1.25; |
73 QuicTime::Delta delay = | 73 QuicTime::Delta delay = |
74 BandwidthEstimate().Scale(kPacingAggression).TransferTime(bytes); | 74 BandwidthEstimate().Scale(kPacingAggression).TransferTime(bytes); |
75 // If the last send was delayed, and the alarm took a long time to get | 75 // If the last send was delayed, and the alarm took a long time to get |
76 // invoked, allow the connection to make up for lost time. | 76 // invoked, allow the connection to make up for lost time. |
77 if (was_last_send_delayed_) { | 77 if (was_last_send_delayed_) { |
78 next_packet_send_time_ = next_packet_send_time_.Add(delay); | 78 next_packet_send_time_ = next_packet_send_time_.Add(delay); |
79 // The send was application limited if it takes longer than the | 79 // The send was application limited if it takes longer than the |
80 // pacing delay between sent packets. | 80 // pacing delay between sent packets. |
81 const bool application_limited = | 81 const bool application_limited = |
82 last_delayed_packet_sent_time_.IsInitialized() && | 82 last_delayed_packet_sent_time_.IsInitialized() && |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 } | 159 } |
160 | 160 |
161 QuicTime::Delta PacingSender::RetransmissionDelay() const { | 161 QuicTime::Delta PacingSender::RetransmissionDelay() const { |
162 return sender_->RetransmissionDelay(); | 162 return sender_->RetransmissionDelay(); |
163 } | 163 } |
164 | 164 |
165 QuicByteCount PacingSender::GetCongestionWindow() const { | 165 QuicByteCount PacingSender::GetCongestionWindow() const { |
166 return sender_->GetCongestionWindow(); | 166 return sender_->GetCongestionWindow(); |
167 } | 167 } |
168 | 168 |
| 169 bool PacingSender::InSlowStart() const { |
| 170 return sender_->InSlowStart(); |
| 171 } |
| 172 |
169 QuicByteCount PacingSender::GetSlowStartThreshold() const { | 173 QuicByteCount PacingSender::GetSlowStartThreshold() const { |
170 return sender_->GetSlowStartThreshold(); | 174 return sender_->GetSlowStartThreshold(); |
171 } | 175 } |
172 | 176 |
173 } // namespace net | 177 } // namespace net |
OLD | NEW |