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/core/congestion_control/cubic.h" | 5 #include "net/quic/core/congestion_control/cubic.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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 ((current_time + delay_min - epoch_).ToMicroseconds() << 10) / | 143 ((current_time + delay_min - epoch_).ToMicroseconds() << 10) / |
144 kNumMicrosPerSecond; | 144 kNumMicrosPerSecond; |
145 | 145 |
146 int64_t offset = time_to_origin_point_ - elapsed_time; | 146 int64_t offset = time_to_origin_point_ - elapsed_time; |
147 QuicPacketCount delta_congestion_window = | 147 QuicPacketCount delta_congestion_window = |
148 (kCubeCongestionWindowScale * offset * offset * offset) >> kCubeScale; | 148 (kCubeCongestionWindowScale * offset * offset * offset) >> kCubeScale; |
149 | 149 |
150 QuicPacketCount target_congestion_window = | 150 QuicPacketCount target_congestion_window = |
151 origin_point_congestion_window_ - delta_congestion_window; | 151 origin_point_congestion_window_ - delta_congestion_window; |
152 | 152 |
153 if (FLAGS_quic_limit_cubic_cwnd_increase) { | 153 // Limit the CWND increase to half the acked packets rounded up to the |
154 // Limit the CWND increase to half the acked packets rounded up to the | 154 // nearest packet. |
155 // nearest packet. | 155 target_congestion_window = |
156 target_congestion_window = | 156 min(target_congestion_window, |
157 min(target_congestion_window, | 157 current_congestion_window + (epoch_packets_count_ + 1) / 2); |
158 current_congestion_window + (epoch_packets_count_ + 1) / 2); | |
159 } | |
160 | 158 |
161 DCHECK_LT(0u, estimated_tcp_congestion_window_); | 159 DCHECK_LT(0u, estimated_tcp_congestion_window_); |
162 // With dynamic beta/alpha based on number of active streams, it is possible | 160 // With dynamic beta/alpha based on number of active streams, it is possible |
163 // for the required_ack_count to become much lower than acked_packets_count_ | 161 // for the required_ack_count to become much lower than acked_packets_count_ |
164 // suddenly, leading to more than one iteration through the following loop. | 162 // suddenly, leading to more than one iteration through the following loop. |
165 while (true) { | 163 while (true) { |
166 // Update estimated TCP congestion_window. | 164 // Update estimated TCP congestion_window. |
167 QuicPacketCount required_ack_count = static_cast<QuicPacketCount>( | 165 QuicPacketCount required_ack_count = static_cast<QuicPacketCount>( |
168 estimated_tcp_congestion_window_ / Alpha()); | 166 estimated_tcp_congestion_window_ / Alpha()); |
169 if (acked_packets_count_ < required_ack_count) { | 167 if (acked_packets_count_ < required_ack_count) { |
(...skipping 11 matching lines...) Expand all Loading... |
181 // congestion_window, use highest (fastest). | 179 // congestion_window, use highest (fastest). |
182 if (target_congestion_window < estimated_tcp_congestion_window_) { | 180 if (target_congestion_window < estimated_tcp_congestion_window_) { |
183 target_congestion_window = estimated_tcp_congestion_window_; | 181 target_congestion_window = estimated_tcp_congestion_window_; |
184 } | 182 } |
185 | 183 |
186 DVLOG(1) << "Final target congestion_window: " << target_congestion_window; | 184 DVLOG(1) << "Final target congestion_window: " << target_congestion_window; |
187 return target_congestion_window; | 185 return target_congestion_window; |
188 } | 186 } |
189 | 187 |
190 } // namespace net | 188 } // namespace net |
OLD | NEW |