| 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/cubic.h" | 5 #include "net/quic/congestion_control/cubic.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "net/quic/congestion_control/cube_root.h" | |
| 14 #include "net/quic/quic_flags.h" | 13 #include "net/quic/quic_flags.h" |
| 15 #include "net/quic/quic_protocol.h" | 14 #include "net/quic/quic_protocol.h" |
| 16 | 15 |
| 17 using std::max; | 16 using std::max; |
| 18 | 17 |
| 19 namespace net { | 18 namespace net { |
| 20 | 19 |
| 21 namespace { | 20 namespace { |
| 22 | 21 |
| 23 // Constants based on TCP defaults. | 22 // Constants based on TCP defaults. |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 // First ACK after a loss event. | 128 // First ACK after a loss event. |
| 130 DVLOG(1) << "Start of epoch"; | 129 DVLOG(1) << "Start of epoch"; |
| 131 epoch_ = current_time; // Start of epoch. | 130 epoch_ = current_time; // Start of epoch. |
| 132 acked_packets_count_ = 1; // Reset count. | 131 acked_packets_count_ = 1; // Reset count. |
| 133 // Reset estimated_tcp_congestion_window_ to be in sync with cubic. | 132 // Reset estimated_tcp_congestion_window_ to be in sync with cubic. |
| 134 estimated_tcp_congestion_window_ = current_congestion_window; | 133 estimated_tcp_congestion_window_ = current_congestion_window; |
| 135 if (last_max_congestion_window_ <= current_congestion_window) { | 134 if (last_max_congestion_window_ <= current_congestion_window) { |
| 136 time_to_origin_point_ = 0; | 135 time_to_origin_point_ = 0; |
| 137 origin_point_congestion_window_ = current_congestion_window; | 136 origin_point_congestion_window_ = current_congestion_window; |
| 138 } else { | 137 } else { |
| 139 if (FLAGS_quic_use_std_cbrt) { | 138 time_to_origin_point_ = |
| 140 time_to_origin_point_ = static_cast<uint32>( | 139 static_cast<uint32>(cbrt(kCubeFactor * (last_max_congestion_window_ - |
| 141 cbrt(kCubeFactor * | 140 current_congestion_window))); |
| 142 (last_max_congestion_window_ - current_congestion_window))); | |
| 143 } else { | |
| 144 // TODO(rjshade): Remove CubeRoot source when removing | |
| 145 // FLAGS_quic_use_std_cbrt. | |
| 146 time_to_origin_point_ = | |
| 147 CubeRoot::Root(kCubeFactor * (last_max_congestion_window_ - | |
| 148 current_congestion_window)); | |
| 149 } | |
| 150 origin_point_congestion_window_ = | 141 origin_point_congestion_window_ = |
| 151 last_max_congestion_window_; | 142 last_max_congestion_window_; |
| 152 } | 143 } |
| 153 } | 144 } |
| 154 // Change the time unit from microseconds to 2^10 fractions per second. Take | 145 // Change the time unit from microseconds to 2^10 fractions per second. Take |
| 155 // the round trip time in account. This is done to allow us to use shift as a | 146 // the round trip time in account. This is done to allow us to use shift as a |
| 156 // divide operator. | 147 // divide operator. |
| 157 int64 elapsed_time = | 148 int64 elapsed_time = |
| 158 (current_time.Add(delay_min).Subtract(epoch_).ToMicroseconds() << 10) / | 149 (current_time.Add(delay_min).Subtract(epoch_).ToMicroseconds() << 10) / |
| 159 base::Time::kMicrosecondsPerSecond; | 150 base::Time::kMicrosecondsPerSecond; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 // congestion_window, use highest (fastest). | 182 // congestion_window, use highest (fastest). |
| 192 if (target_congestion_window < estimated_tcp_congestion_window_) { | 183 if (target_congestion_window < estimated_tcp_congestion_window_) { |
| 193 target_congestion_window = estimated_tcp_congestion_window_; | 184 target_congestion_window = estimated_tcp_congestion_window_; |
| 194 } | 185 } |
| 195 | 186 |
| 196 DVLOG(1) << "Target congestion_window: " << target_congestion_window; | 187 DVLOG(1) << "Target congestion_window: " << target_congestion_window; |
| 197 return target_congestion_window; | 188 return target_congestion_window; |
| 198 } | 189 } |
| 199 | 190 |
| 200 } // namespace net | 191 } // namespace net |
| OLD | NEW |