No public description

PiperOrigin-RevId: 676051976
diff --git a/quiche/quic/core/congestion_control/pacing_sender.cc b/quiche/quic/core/congestion_control/pacing_sender.cc
index 687bf47..a705591 100644
--- a/quiche/quic/core/congestion_control/pacing_sender.cc
+++ b/quiche/quic/core/congestion_control/pacing_sender.cc
@@ -23,6 +23,7 @@
 PacingSender::PacingSender()
     : sender_(nullptr),
       max_pacing_rate_(QuicBandwidth::Zero()),
+      application_driven_pacing_rate_(QuicBandwidth::Infinite()),
       burst_tokens_(kInitialUnpacedBurst),
       ideal_next_packet_send_time_(QuicTime::Zero()),
       initial_burst_size_(kInitialUnpacedBurst),
diff --git a/quiche/quic/core/congestion_control/pacing_sender.h b/quiche/quic/core/congestion_control/pacing_sender.h
index 214b2670..3461a39 100644
--- a/quiche/quic/core/congestion_control/pacing_sender.h
+++ b/quiche/quic/core/congestion_control/pacing_sender.h
@@ -44,6 +44,19 @@
     max_pacing_rate_ = max_pacing_rate;
   }
 
+  void set_application_driven_pacing_rate(
+      QuicBandwidth application_driven_pacing_rate) {
+    // Soft pacing suggestion from application layer. Experimental, see
+    // b/364614652 for more context.
+
+    application_driven_pacing_rate_ = application_driven_pacing_rate;
+    sender_->SetApplicationDrivenPacingRate(application_driven_pacing_rate_);
+  }
+
+  QuicBandwidth application_driven_pacing_rate() const {
+    return application_driven_pacing_rate_;
+  }
+
   void set_remove_non_initial_burst() { remove_non_initial_burst_ = true; }
 
   QuicBandwidth max_pacing_rate() const { return max_pacing_rate_; }
@@ -88,6 +101,12 @@
   // If not QuicBandidth::Zero, the maximum rate the PacingSender will use.
   QuicBandwidth max_pacing_rate_;
 
+  // Keep track of the application driven pacing rate used by sender_.
+  // Experimental, see b/364614652 for more context. This signals application
+  // bandwidth needs to the underlying BBR sender, so that we can back off
+  // accordingly when congestion is detected.
+  QuicBandwidth application_driven_pacing_rate_;
+
   // Number of unpaced packets to be sent before packets are delayed.
   uint32_t burst_tokens_;
   QuicTime ideal_next_packet_send_time_;  // When can the next packet be sent.
diff --git a/quiche/quic/core/quic_connection.cc b/quiche/quic/core/quic_connection.cc
index d569048..e705044 100644
--- a/quiche/quic/core/quic_connection.cc
+++ b/quiche/quic/core/quic_connection.cc
@@ -663,6 +663,12 @@
   sent_packet_manager_.SetMaxPacingRate(max_pacing_rate);
 }
 
+void QuicConnection::SetApplicationDrivenPacingRate(
+    QuicBandwidth application_driven_pacing_rate) {
+  sent_packet_manager_.SetApplicationDrivenPacingRate(
+      application_driven_pacing_rate);
+}
+
 void QuicConnection::AdjustNetworkParameters(
     const SendAlgorithmInterface::NetworkParams& params) {
   sent_packet_manager_.AdjustNetworkParameters(params);
@@ -687,6 +693,10 @@
   return sent_packet_manager_.MaxPacingRate();
 }
 
+QuicBandwidth QuicConnection::ApplicationDrivenPacingRate() const {
+  return sent_packet_manager_.ApplicationDrivenPacingRate();
+}
+
 bool QuicConnection::SelectMutualVersion(
     const ParsedQuicVersionVector& available_versions) {
   // Try to find the highest mutual version by iterating over supported
diff --git a/quiche/quic/core/quic_connection.h b/quiche/quic/core/quic_connection.h
index 81a742d..3a7e534 100644
--- a/quiche/quic/core/quic_connection.h
+++ b/quiche/quic/core/quic_connection.h
@@ -561,6 +561,15 @@
   // Called by the Session when a max pacing rate for the connection is needed.
   virtual void SetMaxPacingRate(QuicBandwidth max_pacing_rate);
 
+  // Called by the Session when an application driven pacing rate for the
+  // connection is needed.  Experimental, see b/364614652 for more context.
+  // This is only used by an experimental feature for bbr2_sender to support
+  // soft pacing based on application layer hints when there are signs of
+  // congestion.  application_driven_pacing_rat| is the bandwidth that is
+  // considered sufficient for the application's need.
+  virtual void SetApplicationDrivenPacingRate(
+      QuicBandwidth application_driven_pacing_rate);
+
   // Allows the client to adjust network parameters based on external
   // information.
   void AdjustNetworkParameters(
@@ -577,6 +586,9 @@
   // Returns the max pacing rate for the connection.
   virtual QuicBandwidth MaxPacingRate() const;
 
+  // Returns the application driven pacing rate for the connection.
+  virtual QuicBandwidth ApplicationDrivenPacingRate() const;
+
   // Sends crypto handshake messages of length |write_length| to the peer in as
   // few packets as possible. Returns the number of bytes consumed from the
   // data.
diff --git a/quiche/quic/core/quic_sent_packet_manager.h b/quiche/quic/core/quic_sent_packet_manager.h
index ce95b4d..faebd06 100644
--- a/quiche/quic/core/quic_sent_packet_manager.h
+++ b/quiche/quic/core/quic_sent_packet_manager.h
@@ -151,6 +151,20 @@
     pacing_sender_.set_max_pacing_rate(max_pacing_rate);
   }
 
+  // Experimental, see b/364614652 for more context.
+  // This is only used by an experimental feature for bbr2_sender to support
+  // soft pacing based on application layer hints when there are signs of
+  // congestion.
+  void SetApplicationDrivenPacingRate(
+      QuicBandwidth application_driven_pacing_rate) {
+    pacing_sender_.set_application_driven_pacing_rate(
+        application_driven_pacing_rate);
+  }
+
+  QuicBandwidth ApplicationDrivenPacingRate() const {
+    return pacing_sender_.application_driven_pacing_rate();
+  }
+
   // The delay to use for the send alarm. If zero, it essentially means
   // to queue the send call immediately.
   // WARNING: This is currently an experimental API.
diff --git a/quiche/quic/test_tools/quic_test_utils.h b/quiche/quic/test_tools/quic_test_utils.h
index df9fd66..0e9f020 100644
--- a/quiche/quic/test_tools/quic_test_utils.h
+++ b/quiche/quic/test_tools/quic_test_utils.h
@@ -655,6 +655,11 @@
               (const CachedNetworkParameters&, bool), (override));
   MOCK_METHOD(void, SetMaxPacingRate, (QuicBandwidth), (override));
 
+  MOCK_METHOD(void, SetApplicationDrivenPacingRate, (quic::QuicBandwidth),
+              (override));
+  MOCK_METHOD(quic::QuicBandwidth, ApplicationDrivenPacingRate, (),
+              (const, override));
+
   MOCK_METHOD(void, OnStreamReset, (QuicStreamId, QuicRstStreamErrorCode),
               (override));
   MOCK_METHOD(bool, SendControlFrame, (const QuicFrame& frame), (override));