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 #include "net/quic/quic_flags.h" |
| 8 |
| 9 using std::min; |
| 10 |
7 namespace net { | 11 namespace net { |
8 | 12 |
9 PacingSender::PacingSender(SendAlgorithmInterface* sender, | 13 PacingSender::PacingSender(SendAlgorithmInterface* sender, |
10 QuicTime::Delta alarm_granularity, | 14 QuicTime::Delta alarm_granularity, |
11 uint32 initial_packet_burst) | 15 uint32 initial_packet_burst) |
12 : sender_(sender), | 16 : sender_(sender), |
13 alarm_granularity_(alarm_granularity), | 17 alarm_granularity_(alarm_granularity), |
14 initial_packet_burst_(initial_packet_burst), | 18 initial_packet_burst_(initial_packet_burst), |
15 burst_tokens_(initial_packet_burst), | 19 burst_tokens_(initial_packet_burst), |
16 last_delayed_packet_sent_time_(QuicTime::Zero()), | 20 last_delayed_packet_sent_time_(QuicTime::Zero()), |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 QuicPacketSequenceNumber sequence_number, | 58 QuicPacketSequenceNumber sequence_number, |
55 QuicByteCount bytes, | 59 QuicByteCount bytes, |
56 HasRetransmittableData has_retransmittable_data) { | 60 HasRetransmittableData has_retransmittable_data) { |
57 const bool in_flight = | 61 const bool in_flight = |
58 sender_->OnPacketSent(sent_time, bytes_in_flight, sequence_number, | 62 sender_->OnPacketSent(sent_time, bytes_in_flight, sequence_number, |
59 bytes, has_retransmittable_data); | 63 bytes, has_retransmittable_data); |
60 if (has_retransmittable_data != HAS_RETRANSMITTABLE_DATA) { | 64 if (has_retransmittable_data != HAS_RETRANSMITTABLE_DATA) { |
61 return in_flight; | 65 return in_flight; |
62 } | 66 } |
63 if (bytes_in_flight == 0) { | 67 if (bytes_in_flight == 0) { |
64 // Add more burst tokens anytime the connection is leaving quiescence. | 68 // Add more burst tokens anytime the connection is leaving quiescence, but |
65 burst_tokens_ = initial_packet_burst_; | 69 // limit it to the equivalent of a single bulk write, not exceeding the |
| 70 // current CWND in packets. |
| 71 if (FLAGS_quic_limit_pacing_burst) { |
| 72 burst_tokens_ = min( |
| 73 initial_packet_burst_, |
| 74 static_cast<uint32>(sender_->GetCongestionWindow() / kDefaultTCPMSS)); |
| 75 } else { |
| 76 burst_tokens_ = initial_packet_burst_; |
| 77 } |
66 } | 78 } |
67 if (burst_tokens_ > 0) { | 79 if (burst_tokens_ > 0) { |
68 --burst_tokens_; | 80 --burst_tokens_; |
69 was_last_send_delayed_ = false; | 81 was_last_send_delayed_ = false; |
70 last_delayed_packet_sent_time_ = QuicTime::Zero(); | 82 last_delayed_packet_sent_time_ = QuicTime::Zero(); |
71 ideal_next_packet_send_time_ = QuicTime::Zero(); | 83 ideal_next_packet_send_time_ = QuicTime::Zero(); |
72 return in_flight; | 84 return in_flight; |
73 } | 85 } |
74 // The next packet should be sent as soon as the current packets has been | 86 // The next packet should be sent as soon as the current packets has been |
75 // transferred. | 87 // transferred. |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 178 |
167 QuicByteCount PacingSender::GetSlowStartThreshold() const { | 179 QuicByteCount PacingSender::GetSlowStartThreshold() const { |
168 return sender_->GetSlowStartThreshold(); | 180 return sender_->GetSlowStartThreshold(); |
169 } | 181 } |
170 | 182 |
171 CongestionControlType PacingSender::GetCongestionControlType() const { | 183 CongestionControlType PacingSender::GetCongestionControlType() const { |
172 return sender_->GetCongestionControlType(); | 184 return sender_->GetCongestionControlType(); |
173 } | 185 } |
174 | 186 |
175 } // namespace net | 187 } // namespace net |
OLD | NEW |