| 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/tcp_cubic_sender.h" | 5 #include "net/quic/congestion_control/tcp_cubic_sender.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 | 10 |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 delay_min_ = rtt; | 333 delay_min_ = rtt; |
| 334 } | 334 } |
| 335 // First time call. | 335 // First time call. |
| 336 if (smoothed_rtt_.IsZero()) { | 336 if (smoothed_rtt_.IsZero()) { |
| 337 smoothed_rtt_ = rtt; | 337 smoothed_rtt_ = rtt; |
| 338 mean_deviation_ = QuicTime::Delta::FromMicroseconds( | 338 mean_deviation_ = QuicTime::Delta::FromMicroseconds( |
| 339 rtt.ToMicroseconds() / 2); | 339 rtt.ToMicroseconds() / 2); |
| 340 } else { | 340 } else { |
| 341 mean_deviation_ = QuicTime::Delta::FromMicroseconds( | 341 mean_deviation_ = QuicTime::Delta::FromMicroseconds( |
| 342 kOneMinusBeta * mean_deviation_.ToMicroseconds() + | 342 kOneMinusBeta * mean_deviation_.ToMicroseconds() + |
| 343 kBeta * abs(smoothed_rtt_.ToMicroseconds() - rtt.ToMicroseconds())); | 343 kBeta * |
| 344 std::abs(smoothed_rtt_.ToMicroseconds() - rtt.ToMicroseconds())); |
| 344 smoothed_rtt_ = QuicTime::Delta::FromMicroseconds( | 345 smoothed_rtt_ = QuicTime::Delta::FromMicroseconds( |
| 345 kOneMinusAlpha * smoothed_rtt_.ToMicroseconds() + | 346 kOneMinusAlpha * smoothed_rtt_.ToMicroseconds() + |
| 346 kAlpha * rtt.ToMicroseconds()); | 347 kAlpha * rtt.ToMicroseconds()); |
| 347 DVLOG(1) << "Cubic; smoothed_rtt_:" << smoothed_rtt_.ToMicroseconds() | 348 DVLOG(1) << "Cubic; smoothed_rtt_:" << smoothed_rtt_.ToMicroseconds() |
| 348 << " mean_deviation_:" << mean_deviation_.ToMicroseconds(); | 349 << " mean_deviation_:" << mean_deviation_.ToMicroseconds(); |
| 349 } | 350 } |
| 350 | 351 |
| 351 // Hybrid start triggers when cwnd is larger than some threshold. | 352 // Hybrid start triggers when cwnd is larger than some threshold. |
| 352 if (congestion_window_ <= slowstart_threshold_ && | 353 if (congestion_window_ <= slowstart_threshold_ && |
| 353 congestion_window_ >= kHybridStartLowWindow) { | 354 congestion_window_ >= kHybridStartLowWindow) { |
| 354 if (!hybrid_slow_start_.started()) { | 355 if (!hybrid_slow_start_.started()) { |
| 355 // Time to start the hybrid slow start. | 356 // Time to start the hybrid slow start. |
| 356 hybrid_slow_start_.Reset(end_sequence_number_); | 357 hybrid_slow_start_.Reset(end_sequence_number_); |
| 357 } | 358 } |
| 358 hybrid_slow_start_.Update(rtt, delay_min_); | 359 hybrid_slow_start_.Update(rtt, delay_min_); |
| 359 if (hybrid_slow_start_.Exit()) { | 360 if (hybrid_slow_start_.Exit()) { |
| 360 slowstart_threshold_ = congestion_window_; | 361 slowstart_threshold_ = congestion_window_; |
| 361 } | 362 } |
| 362 } | 363 } |
| 363 } | 364 } |
| 364 | 365 |
| 365 } // namespace net | 366 } // namespace net |
| OLD | NEW |