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 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 ((current_time + delay_min - epoch_).ToMicroseconds() << 10) / | 145 ((current_time + delay_min - epoch_).ToMicroseconds() << 10) / |
146 kNumMicrosPerSecond; | 146 kNumMicrosPerSecond; |
147 | 147 |
148 int64_t offset = time_to_origin_point_ - elapsed_time; | 148 int64_t offset = time_to_origin_point_ - elapsed_time; |
149 QuicByteCount delta_congestion_window = | 149 QuicByteCount delta_congestion_window = |
150 ((kCubeCongestionWindowScale * offset * offset * offset) >> kCubeScale) * | 150 ((kCubeCongestionWindowScale * offset * offset * offset) >> kCubeScale) * |
151 kDefaultTCPMSS; | 151 kDefaultTCPMSS; |
152 | 152 |
153 QuicByteCount target_congestion_window = | 153 QuicByteCount target_congestion_window = |
154 origin_point_congestion_window_ - delta_congestion_window; | 154 origin_point_congestion_window_ - delta_congestion_window; |
155 if (FLAGS_quic_limit_cubic_cwnd_increase) { | 155 // Limit the CWND increase to half the acked bytes. |
156 // Limit the CWND increase to half the acked bytes. | 156 target_congestion_window = |
157 target_congestion_window = | 157 min(target_congestion_window, |
158 min(target_congestion_window, | 158 current_congestion_window + acked_bytes_count_ / 2); |
159 current_congestion_window + acked_bytes_count_ / 2); | |
160 } | |
161 | 159 |
162 DCHECK_LT(0u, estimated_tcp_congestion_window_); | 160 DCHECK_LT(0u, estimated_tcp_congestion_window_); |
163 // Increase the window by Alpha * 1 MSS of bytes every time we ack an | 161 // Increase the window by Alpha * 1 MSS of bytes every time we ack an |
164 // estimated tcp window of bytes. | 162 // estimated tcp window of bytes. |
165 estimated_tcp_congestion_window_ += acked_bytes_count_ * | 163 estimated_tcp_congestion_window_ += acked_bytes_count_ * |
166 (Alpha() * kDefaultTCPMSS) / | 164 (Alpha() * kDefaultTCPMSS) / |
167 estimated_tcp_congestion_window_; | 165 estimated_tcp_congestion_window_; |
168 acked_bytes_count_ = 0; | 166 acked_bytes_count_ = 0; |
169 | 167 |
170 // We have a new cubic congestion window. | 168 // We have a new cubic congestion window. |
171 last_target_congestion_window_ = target_congestion_window; | 169 last_target_congestion_window_ = target_congestion_window; |
172 | 170 |
173 // Compute target congestion_window based on cubic target and estimated TCP | 171 // Compute target congestion_window based on cubic target and estimated TCP |
174 // congestion_window, use highest (fastest). | 172 // congestion_window, use highest (fastest). |
175 if (target_congestion_window < estimated_tcp_congestion_window_) { | 173 if (target_congestion_window < estimated_tcp_congestion_window_) { |
176 target_congestion_window = estimated_tcp_congestion_window_; | 174 target_congestion_window = estimated_tcp_congestion_window_; |
177 } | 175 } |
178 | 176 |
179 DVLOG(1) << "Final target congestion_window: " << target_congestion_window; | 177 DVLOG(1) << "Final target congestion_window: " << target_congestion_window; |
180 return target_congestion_window; | 178 return target_congestion_window; |
181 } | 179 } |
182 | 180 |
183 } // namespace net | 181 } // namespace net |
OLD | NEW |