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/core/congestion_control/cubic_bytes.h" | 5 #include "net/quic/core/congestion_control/cubic_bytes.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <cmath> | 9 #include <cmath> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "net/quic/core/quic_flags.h" |
12 #include "net/quic/core/quic_protocol.h" | 13 #include "net/quic/core/quic_protocol.h" |
13 | 14 |
14 using std::max; | 15 using std::max; |
| 16 using std::min; |
15 | 17 |
16 namespace net { | 18 namespace net { |
17 | 19 |
18 namespace { | 20 namespace { |
19 | 21 |
20 // Constants based on TCP defaults. | 22 // Constants based on TCP defaults. |
21 // The following constants are in 2^10 fractions of a second instead of ms to | 23 // The following constants are in 2^10 fractions of a second instead of ms to |
22 // allow a 10 shift right to divide. | 24 // allow a 10 shift right to divide. |
23 const int kCubeScale = 40; // 1024*1024^3 (first 1024 is from 0.100^3) | 25 const int kCubeScale = 40; // 1024*1024^3 (first 1024 is from 0.100^3) |
24 // where 0.100 is 100 ms which is the scaling | 26 // where 0.100 is 100 ms which is the scaling |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 ((current_time + delay_min - epoch_).ToMicroseconds() << 10) / | 145 ((current_time + delay_min - epoch_).ToMicroseconds() << 10) / |
144 kNumMicrosPerSecond; | 146 kNumMicrosPerSecond; |
145 | 147 |
146 int64_t offset = time_to_origin_point_ - elapsed_time; | 148 int64_t offset = time_to_origin_point_ - elapsed_time; |
147 QuicByteCount delta_congestion_window = | 149 QuicByteCount delta_congestion_window = |
148 ((kCubeCongestionWindowScale * offset * offset * offset) >> kCubeScale) * | 150 ((kCubeCongestionWindowScale * offset * offset * offset) >> kCubeScale) * |
149 kDefaultTCPMSS; | 151 kDefaultTCPMSS; |
150 | 152 |
151 QuicByteCount target_congestion_window = | 153 QuicByteCount target_congestion_window = |
152 origin_point_congestion_window_ - delta_congestion_window; | 154 origin_point_congestion_window_ - delta_congestion_window; |
| 155 if (FLAGS_quic_limit_cubic_cwnd_increase) { |
| 156 // Limit the CWND increase to half the acked bytes. |
| 157 target_congestion_window = |
| 158 min(target_congestion_window, |
| 159 current_congestion_window + acked_bytes_count_ / 2); |
| 160 } |
153 | 161 |
154 DCHECK_LT(0u, estimated_tcp_congestion_window_); | 162 DCHECK_LT(0u, estimated_tcp_congestion_window_); |
155 // Increase the window by Alpha * 1 MSS of bytes every time we ack an | 163 // Increase the window by Alpha * 1 MSS of bytes every time we ack an |
156 // estimated tcp window of bytes. | 164 // estimated tcp window of bytes. |
157 estimated_tcp_congestion_window_ += acked_bytes_count_ * | 165 estimated_tcp_congestion_window_ += acked_bytes_count_ * |
158 (Alpha() * kDefaultTCPMSS) / | 166 (Alpha() * kDefaultTCPMSS) / |
159 estimated_tcp_congestion_window_; | 167 estimated_tcp_congestion_window_; |
160 acked_bytes_count_ = 0; | 168 acked_bytes_count_ = 0; |
161 | 169 |
162 // We have a new cubic congestion window. | 170 // We have a new cubic congestion window. |
163 last_target_congestion_window_ = target_congestion_window; | 171 last_target_congestion_window_ = target_congestion_window; |
164 | 172 |
165 // Compute target congestion_window based on cubic target and estimated TCP | 173 // Compute target congestion_window based on cubic target and estimated TCP |
166 // congestion_window, use highest (fastest). | 174 // congestion_window, use highest (fastest). |
167 if (target_congestion_window < estimated_tcp_congestion_window_) { | 175 if (target_congestion_window < estimated_tcp_congestion_window_) { |
168 target_congestion_window = estimated_tcp_congestion_window_; | 176 target_congestion_window = estimated_tcp_congestion_window_; |
169 } | 177 } |
170 | 178 |
171 DVLOG(1) << "Final target congestion_window: " << target_congestion_window; | 179 DVLOG(1) << "Final target congestion_window: " << target_congestion_window; |
172 return target_congestion_window; | 180 return target_congestion_window; |
173 } | 181 } |
174 | 182 |
175 } // namespace net | 183 } // namespace net |
OLD | NEW |