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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 last_congestion_window_ = 0; | 74 last_congestion_window_ = 0; |
75 last_max_congestion_window_ = 0; | 75 last_max_congestion_window_ = 0; |
76 acked_packets_count_ = 0; | 76 acked_packets_count_ = 0; |
77 estimated_tcp_congestion_window_ = 0; | 77 estimated_tcp_congestion_window_ = 0; |
78 origin_point_congestion_window_ = 0; | 78 origin_point_congestion_window_ = 0; |
79 time_to_origin_point_ = 0; | 79 time_to_origin_point_ = 0; |
80 last_target_congestion_window_ = 0; | 80 last_target_congestion_window_ = 0; |
81 } | 81 } |
82 | 82 |
83 void Cubic::OnApplicationLimited() { | 83 void Cubic::OnApplicationLimited() { |
84 if (FLAGS_shift_quic_cubic_epoch_when_app_limited) { | 84 // When sender is not using the available congestion window, Cubic's epoch |
85 // When sender is not using the available congestion window, Cubic's epoch | 85 // should not continue growing. Reset the epoch when in such a period. |
86 // should not continue growing. Record the time when sender goes into an | 86 epoch_ = QuicTime::Zero(); |
87 // app-limited period here, to compensate later when cwnd growth happens. | |
88 if (app_limited_start_time_ == QuicTime::Zero()) { | |
89 app_limited_start_time_ = clock_->ApproximateNow(); | |
90 } | |
91 } else { | |
92 // When sender is not using the available congestion window, Cubic's epoch | |
93 // should not continue growing. Reset the epoch when in such a period. | |
94 epoch_ = QuicTime::Zero(); | |
95 } | |
96 } | 87 } |
97 | 88 |
98 QuicPacketCount Cubic::CongestionWindowAfterPacketLoss( | 89 QuicPacketCount Cubic::CongestionWindowAfterPacketLoss( |
99 QuicPacketCount current_congestion_window) { | 90 QuicPacketCount current_congestion_window) { |
100 if (current_congestion_window < last_max_congestion_window_) { | 91 if (current_congestion_window < last_max_congestion_window_) { |
101 // We never reached the old max, so assume we are competing with another | 92 // We never reached the old max, so assume we are competing with another |
102 // flow. Use our extra back off factor to allow the other flow to go up. | 93 // flow. Use our extra back off factor to allow the other flow to go up. |
103 last_max_congestion_window_ = | 94 last_max_congestion_window_ = |
104 static_cast<int>(kBetaLastMax * current_congestion_window); | 95 static_cast<int>(kBetaLastMax * current_congestion_window); |
105 } else { | 96 } else { |
(...skipping 26 matching lines...) Expand all Loading... |
132 estimated_tcp_congestion_window_ = current_congestion_window; | 123 estimated_tcp_congestion_window_ = current_congestion_window; |
133 if (last_max_congestion_window_ <= current_congestion_window) { | 124 if (last_max_congestion_window_ <= current_congestion_window) { |
134 time_to_origin_point_ = 0; | 125 time_to_origin_point_ = 0; |
135 origin_point_congestion_window_ = current_congestion_window; | 126 origin_point_congestion_window_ = current_congestion_window; |
136 } else { | 127 } else { |
137 time_to_origin_point_ = static_cast<uint32_t>( | 128 time_to_origin_point_ = static_cast<uint32_t>( |
138 cbrt(kCubeFactor * | 129 cbrt(kCubeFactor * |
139 (last_max_congestion_window_ - current_congestion_window))); | 130 (last_max_congestion_window_ - current_congestion_window))); |
140 origin_point_congestion_window_ = last_max_congestion_window_; | 131 origin_point_congestion_window_ = last_max_congestion_window_; |
141 } | 132 } |
142 } else { | |
143 // If sender was app-limited, then freeze congestion window growth during | |
144 // app-limited period. Continue growth now by shifting the epoch-start | |
145 // through the app-limited period. | |
146 if (FLAGS_shift_quic_cubic_epoch_when_app_limited && | |
147 app_limited_start_time_ != QuicTime::Zero()) { | |
148 QuicTime::Delta shift = current_time - app_limited_start_time_; | |
149 DVLOG(1) << "Shifting epoch for quiescence by " << shift.ToMicroseconds(); | |
150 epoch_ = epoch_ + shift; | |
151 app_limited_start_time_ = QuicTime::Zero(); | |
152 } | |
153 } | 133 } |
154 | 134 |
155 // Change the time unit from microseconds to 2^10 fractions per second. Take | 135 // Change the time unit from microseconds to 2^10 fractions per second. Take |
156 // the round trip time in account. This is done to allow us to use shift as a | 136 // the round trip time in account. This is done to allow us to use shift as a |
157 // divide operator. | 137 // divide operator. |
158 int64_t elapsed_time = | 138 int64_t elapsed_time = |
159 ((current_time + delay_min - epoch_).ToMicroseconds() << 10) / | 139 ((current_time + delay_min - epoch_).ToMicroseconds() << 10) / |
160 kNumMicrosPerSecond; | 140 kNumMicrosPerSecond; |
161 | 141 |
162 int64_t offset = time_to_origin_point_ - elapsed_time; | 142 int64_t offset = time_to_origin_point_ - elapsed_time; |
(...skipping 25 matching lines...) Expand all Loading... |
188 // congestion_window, use highest (fastest). | 168 // congestion_window, use highest (fastest). |
189 if (target_congestion_window < estimated_tcp_congestion_window_) { | 169 if (target_congestion_window < estimated_tcp_congestion_window_) { |
190 target_congestion_window = estimated_tcp_congestion_window_; | 170 target_congestion_window = estimated_tcp_congestion_window_; |
191 } | 171 } |
192 | 172 |
193 DVLOG(1) << "Final target congestion_window: " << target_congestion_window; | 173 DVLOG(1) << "Final target congestion_window: " << target_congestion_window; |
194 return target_congestion_window; | 174 return target_congestion_window; |
195 } | 175 } |
196 | 176 |
197 } // namespace net | 177 } // namespace net |
OLD | NEW |