QUICHE team | 7872c77 | 2019-07-23 10:19:37 -0400 | [diff] [blame] | 1 | // Copyright 2019 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_probe_rtt.h" |
| 6 | |
| 7 | #include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_sender.h" |
| 8 | #include "net/third_party/quiche/src/quic/core/quic_time.h" |
| 9 | |
| 10 | namespace quic { |
| 11 | |
| 12 | void Bbr2ProbeRttMode::Enter(const Bbr2CongestionEvent& /*congestion_event*/) { |
| 13 | model_->set_pacing_gain(1.0); |
| 14 | model_->set_cwnd_gain(1.0); |
| 15 | exit_time_ = QuicTime::Zero(); |
| 16 | } |
| 17 | |
| 18 | Bbr2Mode Bbr2ProbeRttMode::OnCongestionEvent( |
| 19 | QuicByteCount /*prior_in_flight*/, |
| 20 | QuicTime /*event_time*/, |
| 21 | const AckedPacketVector& /*acked_packets*/, |
| 22 | const LostPacketVector& /*lost_packets*/, |
| 23 | const Bbr2CongestionEvent& congestion_event) { |
| 24 | if (exit_time_ == QuicTime::Zero()) { |
| 25 | if (congestion_event.bytes_in_flight <= InflightTarget() || |
| 26 | congestion_event.bytes_in_flight <= |
| 27 | sender_->GetMinimumCongestionWindow()) { |
| 28 | exit_time_ = congestion_event.event_time + Params().probe_rtt_duration; |
wub | 0276ecf | 2019-11-11 08:52:41 -0800 | [diff] [blame] | 29 | QUIC_DVLOG(2) << sender_ << " PROBE_RTT exit time set to " << exit_time_ |
| 30 | << ". bytes_inflight:" << congestion_event.bytes_in_flight |
| 31 | << ", inflight_target:" << InflightTarget() |
| 32 | << ", min_congestion_window:" |
| 33 | << sender_->GetMinimumCongestionWindow() << " @ " |
| 34 | << congestion_event.event_time; |
QUICHE team | 7872c77 | 2019-07-23 10:19:37 -0400 | [diff] [blame] | 35 | } |
| 36 | return Bbr2Mode::PROBE_RTT; |
| 37 | } |
| 38 | |
| 39 | return congestion_event.event_time > exit_time_ ? Bbr2Mode::PROBE_BW |
| 40 | : Bbr2Mode::PROBE_RTT; |
| 41 | } |
| 42 | |
| 43 | QuicByteCount Bbr2ProbeRttMode::InflightTarget() const { |
| 44 | return model_->BDP(model_->MaxBandwidth(), |
| 45 | Params().probe_rtt_inflight_target_bdp_fraction); |
| 46 | } |
| 47 | |
| 48 | Limits<QuicByteCount> Bbr2ProbeRttMode::GetCwndLimits() const { |
| 49 | QuicByteCount inflight_upper_bound = |
| 50 | std::min(model_->inflight_lo(), model_->inflight_hi_with_headroom()); |
| 51 | return NoGreaterThan(std::min(inflight_upper_bound, InflightTarget())); |
| 52 | } |
| 53 | |
| 54 | Bbr2ProbeRttMode::DebugState Bbr2ProbeRttMode::ExportDebugState() const { |
| 55 | DebugState s; |
| 56 | s.inflight_target = InflightTarget(); |
| 57 | s.exit_time = exit_time_; |
| 58 | return s; |
| 59 | } |
| 60 | |
| 61 | std::ostream& operator<<(std::ostream& os, |
| 62 | const Bbr2ProbeRttMode::DebugState& state) { |
| 63 | os << "[PROBE_RTT] inflight_target: " << state.inflight_target << "\n"; |
| 64 | os << "[PROBE_RTT] exit_time: " << state.exit_time << "\n"; |
| 65 | return os; |
| 66 | } |
| 67 | |
| 68 | const Bbr2Params& Bbr2ProbeRttMode::Params() const { |
| 69 | return sender_->Params(); |
| 70 | } |
| 71 | |
| 72 | } // namespace quic |