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/paced_sender.h" | 5 #include "net/quic/congestion_control/paced_sender.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "net/quic/quic_protocol.h" | 9 #include "net/quic/quic_protocol.h" |
10 | 10 |
| 11 using std::max; |
| 12 |
11 namespace net { | 13 namespace net { |
12 | 14 |
13 // To prevent too aggressive pacing we allow the following packet burst size. | 15 // To prevent too aggressive pacing we allow the following packet burst size. |
14 const int64 kMinPacketBurstSize = 2; | 16 const int64 kMinPacketBurstSize = 2; |
15 // Max estimated time between calls to TimeUntilSend and | 17 // Max estimated time between calls to TimeUntilSend and |
16 // AvailableCongestionWindow. | 18 // AvailableCongestionWindow. |
17 const int64 kMaxSchedulingDelayUs = 2000; | 19 const int64 kMaxSchedulingDelayUs = 2000; |
18 | 20 |
19 PacedSender::PacedSender(QuicBandwidth estimate, QuicByteCount max_segment_size) | 21 PacedSender::PacedSender(QuicBandwidth estimate, QuicByteCount max_segment_size) |
20 : leaky_bucket_(estimate), | 22 : leaky_bucket_(estimate), |
(...skipping 13 matching lines...) Expand all Loading... |
34 | 36 |
35 QuicTime::Delta PacedSender::TimeUntilSend(QuicTime now, | 37 QuicTime::Delta PacedSender::TimeUntilSend(QuicTime now, |
36 QuicTime::Delta time_until_send) { | 38 QuicTime::Delta time_until_send) { |
37 if (time_until_send.ToMicroseconds() >= kMaxSchedulingDelayUs) { | 39 if (time_until_send.ToMicroseconds() >= kMaxSchedulingDelayUs) { |
38 return time_until_send; | 40 return time_until_send; |
39 } | 41 } |
40 // Pace the data. | 42 // Pace the data. |
41 QuicByteCount pacing_window = pace_.ToBytesPerPeriod( | 43 QuicByteCount pacing_window = pace_.ToBytesPerPeriod( |
42 QuicTime::Delta::FromMicroseconds(kMaxSchedulingDelayUs)); | 44 QuicTime::Delta::FromMicroseconds(kMaxSchedulingDelayUs)); |
43 QuicByteCount min_window_size = kMinPacketBurstSize * max_segment_size_; | 45 QuicByteCount min_window_size = kMinPacketBurstSize * max_segment_size_; |
44 pacing_window = std::max(pacing_window, min_window_size); | 46 pacing_window = max(pacing_window, min_window_size); |
45 | 47 |
46 if (pacing_window > leaky_bucket_.BytesPending(now)) { | 48 if (pacing_window > leaky_bucket_.BytesPending(now)) { |
47 // We have not filled our pacing window yet. | 49 // We have not filled our pacing window yet. |
48 return time_until_send; | 50 return time_until_send; |
49 } | 51 } |
50 return leaky_bucket_.TimeRemaining(now); | 52 return leaky_bucket_.TimeRemaining(now); |
51 } | 53 } |
52 | 54 |
53 } // namespace net | 55 } // namespace net |
OLD | NEW |