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 #ifndef QUICHE_QUIC_CORE_CONGESTION_CONTROL_BBR2_STARTUP_H_ 6 #define QUICHE_QUIC_CORE_CONGESTION_CONTROL_BBR2_STARTUP_H_ 7 8 #include "quiche/quic/core/congestion_control/bbr2_misc.h" 9 #include "quiche/quic/core/quic_bandwidth.h" 10 #include "quiche/quic/core/quic_time.h" 11 #include "quiche/quic/core/quic_types.h" 12 #include "quiche/quic/platform/api/quic_export.h" 13 14 namespace quic { 15 16 class Bbr2Sender; 17 class QUICHE_EXPORT Bbr2StartupMode final : public Bbr2ModeBase { 18 public: 19 Bbr2StartupMode(const Bbr2Sender* sender, Bbr2NetworkModel* model, 20 QuicTime now); 21 22 void Enter(QuicTime now, 23 const Bbr2CongestionEvent* congestion_event) override; 24 void Leave(QuicTime now, 25 const Bbr2CongestionEvent* congestion_event) override; 26 27 Bbr2Mode OnCongestionEvent( 28 QuicByteCount prior_in_flight, QuicTime event_time, 29 const AckedPacketVector& acked_packets, 30 const LostPacketVector& lost_packets, 31 const Bbr2CongestionEvent& congestion_event) override; 32 GetCwndLimits()33 Limits<QuicByteCount> GetCwndLimits() const override { 34 // Inflight_lo is never set in STARTUP. 35 QUICHE_DCHECK_EQ(Bbr2NetworkModel::inflight_lo_default(), 36 model_->inflight_lo()); 37 return NoGreaterThan(model_->inflight_lo()); 38 } 39 IsProbingForBandwidth()40 bool IsProbingForBandwidth() const override { return true; } 41 OnExitQuiescence(QuicTime,QuicTime)42 Bbr2Mode OnExitQuiescence(QuicTime /*now*/, 43 QuicTime /*quiescence_start_time*/) override { 44 return Bbr2Mode::STARTUP; 45 } 46 47 struct QUICHE_EXPORT DebugState { 48 bool full_bandwidth_reached; 49 QuicBandwidth full_bandwidth_baseline = QuicBandwidth::Zero(); 50 QuicRoundTripCount round_trips_without_bandwidth_growth; 51 }; 52 53 DebugState ExportDebugState() const; 54 55 private: 56 const Bbr2Params& Params() const; 57 58 void CheckExcessiveLosses(const Bbr2CongestionEvent& congestion_event); 59 // Used when the pacing gain can decrease in STARTUP. 60 QuicBandwidth max_bw_at_round_beginning_ = QuicBandwidth::Zero(); 61 }; 62 63 QUICHE_EXPORT std::ostream& operator<<( 64 std::ostream& os, const Bbr2StartupMode::DebugState& state); 65 66 } // namespace quic 67 68 #endif // QUICHE_QUIC_CORE_CONGESTION_CONTROL_BBR2_STARTUP_H_ 69