gfe-relnote: (n/a) Remove unused QUIC connection option "BBQ4". Not protected.

Also changed kDerivedHighCWNDGain to 2.0f and fixed test 'DerivedCWNDGainStartup'.

PiperOrigin-RevId: 247060931
Change-Id: Ie1253736d8bc4dd81ba700ef0ee7826bba5eeb69
diff --git a/quic/core/congestion_control/bbr_sender.cc b/quic/core/congestion_control/bbr_sender.cc
index 3ca2063..2c0ad34 100644
--- a/quic/core/congestion_control/bbr_sender.cc
+++ b/quic/core/congestion_control/bbr_sender.cc
@@ -30,7 +30,7 @@
 // The newly derived gain for STARTUP, equal to 4 * ln(2)
 const float kDerivedHighGain = 2.773f;
 // The newly derived CWND gain for STARTUP, 2.
-const float kDerivedHighCWNDGain = 2.773f;
+const float kDerivedHighCWNDGain = 2.0f;
 // The gain used in STARTUP after loss has been detected.
 // 1.5 is enough to allow for 25% exogenous loss and still observe a 25% growth
 // in measured bandwidth.
@@ -329,11 +329,6 @@
     QUIC_RELOADABLE_FLAG_COUNT_N(quic_bbr_slower_startup3, 3, 4);
     enable_ack_aggregation_during_startup_ = true;
   }
-  if (GetQuicReloadableFlag(quic_bbr_slower_startup3) &&
-      config.HasClientRequestedIndependentOption(kBBQ4, perspective)) {
-    QUIC_RELOADABLE_FLAG_COUNT_N(quic_bbr_slower_startup3, 4, 4);
-    set_drain_gain(kModerateProbeRttMultiplier);
-  }
   if (GetQuicReloadableFlag(quic_bbr_slower_startup4) &&
       config.HasClientRequestedIndependentOption(kBBQ5, perspective)) {
     QUIC_RELOADABLE_FLAG_COUNT(quic_bbr_slower_startup4);
diff --git a/quic/core/congestion_control/bbr_sender.h b/quic/core/congestion_control/bbr_sender.h
index d01dbfe..843764b 100644
--- a/quic/core/congestion_control/bbr_sender.h
+++ b/quic/core/congestion_control/bbr_sender.h
@@ -164,6 +164,10 @@
     drain_gain_ = drain_gain;
   }
 
+  // Returns the current estimate of the RTT of the connection.  Outside of the
+  // edge cases, this is minimum RTT.
+  QuicTime::Delta GetMinRtt() const;
+
   DebugState ExportDebugState() const;
 
  private:
@@ -179,9 +183,6 @@
                          QuicRoundTripCount>
       MaxAckHeightFilter;
 
-  // Returns the current estimate of the RTT of the connection.  Outside of the
-  // edge cases, this is minimum RTT.
-  QuicTime::Delta GetMinRtt() const;
   // Returns whether the connection has achieved full bandwidth required to exit
   // the slow start.
   bool IsAtFullBandwidth() const;
diff --git a/quic/core/congestion_control/bbr_sender_test.cc b/quic/core/congestion_control/bbr_sender_test.cc
index 21675e6..1f4c082 100644
--- a/quic/core/congestion_control/bbr_sender_test.cc
+++ b/quic/core/congestion_control/bbr_sender_test.cc
@@ -11,6 +11,7 @@
 #include "net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.h"
 #include "net/third_party/quiche/src/quic/core/quic_packets.h"
 #include "net/third_party/quiche/src/quic/core/quic_utils.h"
+#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
@@ -304,7 +305,7 @@
 
   // The margin here is quite high, since there exists a possibility that the
   // connection just exited high gain cycle.
-  EXPECT_APPROX_EQ(kTestRtt, rtt_stats_->smoothed_rtt(), 0.2f);
+  EXPECT_APPROX_EQ(kTestRtt, sender_->GetMinRtt(), 0.2f);
 }
 
 TEST_F(BbrSenderTest, SimpleTransferEarlyPacketLoss) {
@@ -471,6 +472,20 @@
   EXPECT_LE(loss_rate, 0.31);
 }
 
+// Test the number of losses incurred by the startup phase in a situation when
+// the buffer is less than BDP, with a STARTUP CWND gain of 2.
+TEST_F(BbrSenderTest, PacketLossOnSmallBufferStartupDerivedCWNDGain) {
+  SetQuicReloadableFlag(quic_bbr_slower_startup3, true);
+  CreateSmallBufferSetup();
+
+  SetConnectionOption(kBBQ2);
+  DriveOutOfStartup();
+  float loss_rate =
+      static_cast<float>(bbr_sender_.connection()->GetStats().packets_lost) /
+      bbr_sender_.connection()->GetStats().packets_sent;
+  EXPECT_LE(loss_rate, 0.1);
+}
+
 // Ensures the code transitions loss recovery states correctly (NOT_IN_RECOVERY
 // -> CONSERVATION -> GROWTH -> NOT_IN_RECOVERY).
 TEST_F(BbrSenderTest, RecoveryStates) {
@@ -602,15 +617,14 @@
   EXPECT_APPROX_EQ(kTestRtt, rtt_stats_->smoothed_rtt(), 0.1f);
 }
 
+// TODO(wub): Re-enable this test once default drain_gain changed to 0.75.
 // Verify that the DRAIN phase works correctly.
-TEST_F(BbrSenderTest, ShallowDrain) {
+TEST_F(BbrSenderTest, DISABLED_ShallowDrain) {
   SetQuicReloadableFlag(quic_bbr_slower_startup3, true);
   // Disable Ack Decimation on the receiver, because it can increase srtt.
   QuicConnectionPeer::SetAckMode(receiver_.connection(), AckMode::TCP_ACKING);
 
   CreateDefaultSetup();
-  // BBQ4 increases the pacing gain in DRAIN to 0.75
-  SetConnectionOption(kBBQ4);
   const QuicTime::Delta timeout = QuicTime::Delta::FromSeconds(10);
   // Get the queue at the bottleneck, which is the outgoing queue at the port to
   // which the receiver is connected.
@@ -1186,7 +1200,7 @@
 
 TEST_F(BbrSenderTest, DerivedCWNDGainStartup) {
   SetQuicReloadableFlag(quic_bbr_slower_startup3, true);
-  CreateDefaultSetup();
+  CreateSmallBufferSetup();
 
   SetConnectionOption(kBBQ2);
   EXPECT_EQ(3u, sender_->num_startup_rtts());
@@ -1208,7 +1222,10 @@
   EXPECT_EQ(3u, sender_->ExportDebugState().rounds_without_bandwidth_gain);
   EXPECT_APPROX_EQ(kTestLinkBandwidth,
                    sender_->ExportDebugState().max_bandwidth, 0.01f);
-  EXPECT_EQ(0u, bbr_sender_.connection()->GetStats().packets_lost);
+  float loss_rate =
+      static_cast<float>(bbr_sender_.connection()->GetStats().packets_lost) /
+      bbr_sender_.connection()->GetStats().packets_sent;
+  EXPECT_LT(loss_rate, 0.15f);
   EXPECT_FALSE(sender_->ExportDebugState().last_sample_is_app_limited);
   // Expect an SRTT less than 2.7 * Min RTT on exit from STARTUP.
   EXPECT_GT(kTestRtt * 2.7, rtt_stats_->smoothed_rtt());
diff --git a/quic/core/crypto/crypto_protocol.h b/quic/core/crypto/crypto_protocol.h
index 5b65267..6873e0f 100644
--- a/quic/core/crypto/crypto_protocol.h
+++ b/quic/core/crypto/crypto_protocol.h
@@ -26,6 +26,9 @@
 
 typedef std::string ServerConfigID;
 
+// The following tags have been deprecated and should not be reused:
+// "BBQ4"
+
 // clang-format off
 const QuicTag kCHLO = TAG('C', 'H', 'L', 'O');   // Client hello
 const QuicTag kSHLO = TAG('S', 'H', 'L', 'O');   // Server hello
@@ -112,7 +115,6 @@
                                                  // CWND gain.
 const QuicTag kBBQ3 = TAG('B', 'B', 'Q', '3');   // BBR with ack aggregation
                                                  // compensation in STARTUP.
-const QuicTag kBBQ4 = TAG('B', 'B', 'Q', '4');   // Drain gain of 0.75.
 const QuicTag kBBQ5 = TAG('B', 'B', 'Q', '5');   // Expire ack aggregation upon
                                                  // bandwidth increase in
                                                  // STARTUP.