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 <stdint.h> | 7 #include <stdint.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <cmath> | 9 #include <cmath> |
10 | 10 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 last_update_time_ = QuicTime::Zero(); // Reset time. | 72 last_update_time_ = QuicTime::Zero(); // Reset time. |
73 last_congestion_window_ = 0; | 73 last_congestion_window_ = 0; |
74 last_max_congestion_window_ = 0; | 74 last_max_congestion_window_ = 0; |
75 acked_packets_count_ = 0; | 75 acked_packets_count_ = 0; |
76 estimated_tcp_congestion_window_ = 0; | 76 estimated_tcp_congestion_window_ = 0; |
77 origin_point_congestion_window_ = 0; | 77 origin_point_congestion_window_ = 0; |
78 time_to_origin_point_ = 0; | 78 time_to_origin_point_ = 0; |
79 last_target_congestion_window_ = 0; | 79 last_target_congestion_window_ = 0; |
80 } | 80 } |
81 | 81 |
| 82 void Cubic::OnApplicationLimited() { |
| 83 // When sender is not using the available congestion window, the window does |
| 84 // not grow. But to be RTT-independent, Cubic assumes that the sender has been |
| 85 // using the entire window during the time since the beginning of the current |
| 86 // "epoch" (the end of the last loss recovery period). Since |
| 87 // application-limited periods break this assumption, we reset the epoch when |
| 88 // in such a period. This reset effectively freezes congestion window growth |
| 89 // through application-limited periods and allows Cubic growth to continue |
| 90 // when the entire window is being used. |
| 91 epoch_ = QuicTime::Zero(); |
| 92 } |
| 93 |
82 QuicPacketCount Cubic::CongestionWindowAfterPacketLoss( | 94 QuicPacketCount Cubic::CongestionWindowAfterPacketLoss( |
83 QuicPacketCount current_congestion_window) { | 95 QuicPacketCount current_congestion_window) { |
84 if (current_congestion_window < last_max_congestion_window_) { | 96 if (current_congestion_window < last_max_congestion_window_) { |
85 // We never reached the old max, so assume we are competing with another | 97 // We never reached the old max, so assume we are competing with another |
86 // flow. Use our extra back off factor to allow the other flow to go up. | 98 // flow. Use our extra back off factor to allow the other flow to go up. |
87 last_max_congestion_window_ = | 99 last_max_congestion_window_ = |
88 static_cast<int>(kBetaLastMax * current_congestion_window); | 100 static_cast<int>(kBetaLastMax * current_congestion_window); |
89 } else { | 101 } else { |
90 last_max_congestion_window_ = current_congestion_window; | 102 last_max_congestion_window_ = current_congestion_window; |
91 } | 103 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 168 |
157 // We have a new cubic congestion window. | 169 // We have a new cubic congestion window. |
158 last_target_congestion_window_ = target_congestion_window; | 170 last_target_congestion_window_ = target_congestion_window; |
159 | 171 |
160 // Compute target congestion_window based on cubic target and estimated TCP | 172 // Compute target congestion_window based on cubic target and estimated TCP |
161 // congestion_window, use highest (fastest). | 173 // congestion_window, use highest (fastest). |
162 if (target_congestion_window < estimated_tcp_congestion_window_) { | 174 if (target_congestion_window < estimated_tcp_congestion_window_) { |
163 target_congestion_window = estimated_tcp_congestion_window_; | 175 target_congestion_window = estimated_tcp_congestion_window_; |
164 } | 176 } |
165 | 177 |
166 DVLOG(1) << "Target congestion_window: " << target_congestion_window; | 178 DVLOG(1) << "Final target congestion_window: " << target_congestion_window; |
167 return target_congestion_window; | 179 return target_congestion_window; |
168 } | 180 } |
169 | 181 |
170 } // namespace net | 182 } // namespace net |
OLD | NEW |