| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/bbr_sender.h" | 5 #include "net/quic/core/congestion_control/bbr_sender.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| 11 #include "net/quic/core/congestion_control/rtt_stats.h" | 11 #include "net/quic/core/congestion_control/rtt_stats.h" |
| 12 #include "net/quic/core/quic_flags.h" | 12 #include "net/quic/core/quic_flags.h" |
| 13 #include "net/quic/platform/api/quic_bug_tracker.h" | 13 #include "net/quic/platform/api/quic_bug_tracker.h" |
| 14 #include "net/quic/platform/api/quic_logging.h" |
| 14 | 15 |
| 15 namespace net { | 16 namespace net { |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 // Constants based on TCP defaults. | 19 // Constants based on TCP defaults. |
| 19 const QuicByteCount kMaxSegmentSize = kDefaultTCPMSS; | 20 const QuicByteCount kMaxSegmentSize = kDefaultTCPMSS; |
| 20 // The minimum CWND to ensure delayed acks don't reduce bandwidth measurements. | 21 // The minimum CWND to ensure delayed acks don't reduce bandwidth measurements. |
| 21 // Does not inflate the pacing rate. | 22 // Does not inflate the pacing rate. |
| 22 const QuicByteCount kMinimumCongestionWindow = 4 * kMaxSegmentSize; | 23 const QuicByteCount kMinimumCongestionWindow = 4 * kMaxSegmentSize; |
| 23 | 24 |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 // If none of the RTT samples are valid, return immediately. | 296 // If none of the RTT samples are valid, return immediately. |
| 296 if (sample_min_rtt.IsInfinite()) { | 297 if (sample_min_rtt.IsInfinite()) { |
| 297 return false; | 298 return false; |
| 298 } | 299 } |
| 299 | 300 |
| 300 // Do not expire min_rtt if none was ever available. | 301 // Do not expire min_rtt if none was ever available. |
| 301 bool min_rtt_expired = | 302 bool min_rtt_expired = |
| 302 !min_rtt_.IsZero() && (now > (min_rtt_timestamp_ + kMinRttExpiry)); | 303 !min_rtt_.IsZero() && (now > (min_rtt_timestamp_ + kMinRttExpiry)); |
| 303 | 304 |
| 304 if (min_rtt_expired || sample_min_rtt < min_rtt_ || min_rtt_.IsZero()) { | 305 if (min_rtt_expired || sample_min_rtt < min_rtt_ || min_rtt_.IsZero()) { |
| 305 DVLOG(2) << "Min RTT updated, old value: " << min_rtt_ | 306 QUIC_DVLOG(2) << "Min RTT updated, old value: " << min_rtt_ |
| 306 << ", new value: " << sample_min_rtt | 307 << ", new value: " << sample_min_rtt |
| 307 << ", current time: " << now.ToDebuggingValue(); | 308 << ", current time: " << now.ToDebuggingValue(); |
| 308 | 309 |
| 309 min_rtt_ = sample_min_rtt; | 310 min_rtt_ = sample_min_rtt; |
| 310 min_rtt_timestamp_ = now; | 311 min_rtt_timestamp_ = now; |
| 311 } | 312 } |
| 312 | 313 |
| 313 return min_rtt_expired; | 314 return min_rtt_expired; |
| 314 } | 315 } |
| 315 | 316 |
| 316 void BbrSender::UpdateGainCyclePhase(QuicTime now, | 317 void BbrSender::UpdateGainCyclePhase(QuicTime now, |
| 317 QuicByteCount prior_in_flight, | 318 QuicByteCount prior_in_flight, |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 stream << ExportDebugState(); | 521 stream << ExportDebugState(); |
| 521 return stream.str(); | 522 return stream.str(); |
| 522 } | 523 } |
| 523 | 524 |
| 524 void BbrSender::OnApplicationLimited(QuicByteCount bytes_in_flight) { | 525 void BbrSender::OnApplicationLimited(QuicByteCount bytes_in_flight) { |
| 525 if (bytes_in_flight >= GetCongestionWindow()) { | 526 if (bytes_in_flight >= GetCongestionWindow()) { |
| 526 return; | 527 return; |
| 527 } | 528 } |
| 528 | 529 |
| 529 sampler_.OnAppLimited(); | 530 sampler_.OnAppLimited(); |
| 530 DVLOG(2) << "Becoming application limited. Last sent packet: " | 531 QUIC_DVLOG(2) << "Becoming application limited. Last sent packet: " |
| 531 << last_sent_packet_ << ", CWND: " << GetCongestionWindow(); | 532 << last_sent_packet_ << ", CWND: " << GetCongestionWindow(); |
| 532 } | 533 } |
| 533 | 534 |
| 534 BbrSender::DebugState BbrSender::ExportDebugState() const { | 535 BbrSender::DebugState BbrSender::ExportDebugState() const { |
| 535 return DebugState(*this); | 536 return DebugState(*this); |
| 536 } | 537 } |
| 537 | 538 |
| 538 static std::string ModeToString(BbrSender::Mode mode) { | 539 static std::string ModeToString(BbrSender::Mode mode) { |
| 539 switch (mode) { | 540 switch (mode) { |
| 540 case BbrSender::STARTUP: | 541 case BbrSender::STARTUP: |
| 541 return "STARTUP"; | 542 return "STARTUP"; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 os << "Minimum RTT timestamp: " << state.min_rtt_timestamp.ToDebuggingValue() | 575 os << "Minimum RTT timestamp: " << state.min_rtt_timestamp.ToDebuggingValue() |
| 575 << std::endl; | 576 << std::endl; |
| 576 | 577 |
| 577 os << "Last sample is app-limited: " | 578 os << "Last sample is app-limited: " |
| 578 << (state.last_sample_is_app_limited ? "yes" : "no"); | 579 << (state.last_sample_is_app_limited ? "yes" : "no"); |
| 579 | 580 |
| 580 return os; | 581 return os; |
| 581 } | 582 } |
| 582 | 583 |
| 583 } // namespace net | 584 } // namespace net |
| OLD | NEW |