| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <cstdint> | 9 #include <cstdint> |
| 10 | 10 |
| 11 #include "base/logging.h" | |
| 12 #include "net/quic/core/quic_flags.h" | 11 #include "net/quic/core/quic_flags.h" |
| 13 #include "net/quic/core/quic_packets.h" | 12 #include "net/quic/core/quic_packets.h" |
| 13 #include "net/quic/platform/api/quic_logging.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 // Constants based on TCP defaults. | 19 // Constants based on TCP defaults. |
| 20 // The following constants are in 2^10 fractions of a second instead of ms to | 20 // The following constants are in 2^10 fractions of a second instead of ms to |
| 21 // allow a 10 shift right to divide. | 21 // allow a 10 shift right to divide. |
| 22 const int kCubeScale = 40; // 1024*1024^3 (first 1024 is from 0.100^3) | 22 const int kCubeScale = 40; // 1024*1024^3 (first 1024 is from 0.100^3) |
| 23 // where 0.100 is 100 ms which is the scaling | 23 // where 0.100 is 100 ms which is the scaling |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 if (last_congestion_window_ == current_congestion_window && | 149 if (last_congestion_window_ == current_congestion_window && |
| 150 (current_time - last_update_time_ <= MaxCubicTimeInterval())) { | 150 (current_time - last_update_time_ <= MaxCubicTimeInterval())) { |
| 151 return std::max(last_target_congestion_window_, | 151 return std::max(last_target_congestion_window_, |
| 152 estimated_tcp_congestion_window_); | 152 estimated_tcp_congestion_window_); |
| 153 } | 153 } |
| 154 last_congestion_window_ = current_congestion_window; | 154 last_congestion_window_ = current_congestion_window; |
| 155 last_update_time_ = current_time; | 155 last_update_time_ = current_time; |
| 156 | 156 |
| 157 if (!epoch_.IsInitialized()) { | 157 if (!epoch_.IsInitialized()) { |
| 158 // First ACK after a loss event. | 158 // First ACK after a loss event. |
| 159 DVLOG(1) << "Start of epoch"; | 159 QUIC_DVLOG(1) << "Start of epoch"; |
| 160 epoch_ = current_time; // Start of epoch. | 160 epoch_ = current_time; // Start of epoch. |
| 161 acked_bytes_count_ = acked_bytes; // Reset count. | 161 acked_bytes_count_ = acked_bytes; // Reset count. |
| 162 // Reset estimated_tcp_congestion_window_ to be in sync with cubic. | 162 // Reset estimated_tcp_congestion_window_ to be in sync with cubic. |
| 163 estimated_tcp_congestion_window_ = current_congestion_window; | 163 estimated_tcp_congestion_window_ = current_congestion_window; |
| 164 if (last_max_congestion_window_ <= current_congestion_window) { | 164 if (last_max_congestion_window_ <= current_congestion_window) { |
| 165 time_to_origin_point_ = 0; | 165 time_to_origin_point_ = 0; |
| 166 origin_point_congestion_window_ = current_congestion_window; | 166 origin_point_congestion_window_ = current_congestion_window; |
| 167 } else { | 167 } else { |
| 168 time_to_origin_point_ = static_cast<uint32_t>( | 168 time_to_origin_point_ = static_cast<uint32_t>( |
| 169 cbrt(kCubeFactor * | 169 cbrt(kCubeFactor * |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 221 |
| 222 // We have a new cubic congestion window. | 222 // We have a new cubic congestion window. |
| 223 last_target_congestion_window_ = target_congestion_window; | 223 last_target_congestion_window_ = target_congestion_window; |
| 224 | 224 |
| 225 // Compute target congestion_window based on cubic target and estimated TCP | 225 // Compute target congestion_window based on cubic target and estimated TCP |
| 226 // congestion_window, use highest (fastest). | 226 // congestion_window, use highest (fastest). |
| 227 if (target_congestion_window < estimated_tcp_congestion_window_) { | 227 if (target_congestion_window < estimated_tcp_congestion_window_) { |
| 228 target_congestion_window = estimated_tcp_congestion_window_; | 228 target_congestion_window = estimated_tcp_congestion_window_; |
| 229 } | 229 } |
| 230 | 230 |
| 231 DVLOG(1) << "Final target congestion_window: " << target_congestion_window; | 231 QUIC_DVLOG(1) << "Final target congestion_window: " |
| 232 << target_congestion_window; |
| 232 return target_congestion_window; | 233 return target_congestion_window; |
| 233 } | 234 } |
| 234 | 235 |
| 235 } // namespace net | 236 } // namespace net |
| OLD | NEW |