gfe-relnote: In QUIC, default enable IETF loss detection with 1/4 RTT time threshold and adaptive packet threshold. Protected by existing gfe2_reloadable_flag_quic_default_on_ietf_loss_detection.

PiperOrigin-RevId: 284345000
Change-Id: I83071dae7ac6c0e2598d23fe555716c26bc9730e
diff --git a/quic/core/congestion_control/general_loss_algorithm.cc b/quic/core/congestion_control/general_loss_algorithm.cc
index 8798322..786f610 100644
--- a/quic/core/congestion_control/general_loss_algorithm.cc
+++ b/quic/core/congestion_control/general_loss_algorithm.cc
@@ -18,15 +18,20 @@
 // regardless of SRTT.  Half of the minimum TLP, since the loss algorithm only
 // triggers when a nack has been receieved for the packet.
 static const size_t kMinLossDelayMs = 5;
-
-// Default fraction (1/8) of an RTT when doing IETF loss detection.
-static const int kDefaultIetfLossDelayShift = 3;
 // Default fraction (1/16) of an RTT when doing adaptive loss detection.
 static const int kDefaultAdaptiveLossDelayShift = 4;
 
 }  // namespace
 
-GeneralLossAlgorithm::GeneralLossAlgorithm() : GeneralLossAlgorithm(kNack) {}
+GeneralLossAlgorithm::GeneralLossAlgorithm()
+    : GeneralLossAlgorithm(GetDefaultLossDetectionType()) {
+  if (GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+    // TODO(fayang): Change defaults in GeneralLossAlgorithm(LossDetectionType
+    // loss_type) when deprecating quic_default_on_ietf_loss_detection.
+    set_reordering_shift(kDefaultLossDelayShift);
+    set_use_adaptive_reordering_threshold(true);
+  }
+}
 
 GeneralLossAlgorithm::GeneralLossAlgorithm(LossDetectionType loss_type)
     : loss_detection_timeout_(QuicTime::Zero()),
@@ -39,12 +44,16 @@
 }
 
 void GeneralLossAlgorithm::SetLossDetectionType(LossDetectionType loss_type) {
+  DCHECK(!GetQuicRestartFlag(quic_default_on_ietf_loss_detection) ||
+         loss_type == kIetfLossDetection);
   loss_detection_timeout_ = QuicTime::Zero();
   loss_type_ = loss_type;
   if (loss_type == kAdaptiveTime) {
     reordering_shift_ = kDefaultAdaptiveLossDelayShift;
   } else if (loss_type == kIetfLossDetection) {
-    reordering_shift_ = kDefaultIetfLossDelayShift;
+    if (!GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+      reordering_shift_ = kDefaultIetfLossDelayShift;
+    }
   } else {
     reordering_shift_ = kDefaultLossDelayShift;
   }
diff --git a/quic/core/congestion_control/general_loss_algorithm.h b/quic/core/congestion_control/general_loss_algorithm.h
index fb85523..fb6af22 100644
--- a/quic/core/congestion_control/general_loss_algorithm.h
+++ b/quic/core/congestion_control/general_loss_algorithm.h
@@ -66,8 +66,8 @@
     return use_adaptive_reordering_threshold_;
   }
 
-  void enable_adaptive_reordering_threshold() {
-    use_adaptive_reordering_threshold_ = true;
+  void set_use_adaptive_reordering_threshold(bool value) {
+    use_adaptive_reordering_threshold_ = value;
   }
 
   bool use_adaptive_time_threshold() const {
@@ -78,6 +78,8 @@
 
  private:
   QuicTime loss_detection_timeout_;
+  // TODO(fayang): remove loss_type_ when deprecating
+  // quic_default_on_ietf_loss_detection.
   LossDetectionType loss_type_;
   // Fraction of a max(SRTT, latest_rtt) to permit reordering before declaring
   // loss.  Fraction calculated by shifting max(SRTT, latest_rtt) to the right
diff --git a/quic/core/congestion_control/general_loss_algorithm_test.cc b/quic/core/congestion_control/general_loss_algorithm_test.cc
index aaf9c7c..435e8ea 100644
--- a/quic/core/congestion_control/general_loss_algorithm_test.cc
+++ b/quic/core/congestion_control/general_loss_algorithm_test.cc
@@ -138,7 +138,12 @@
   packets_acked.push_back(AckedPacket(
       QuicPacketNumber(4), kMaxOutgoingPacketSize, QuicTime::Zero()));
   VerifyLosses(4, packets_acked, {1});
-  EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
+  if (GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+    EXPECT_EQ(clock_.Now() + 1.25 * rtt_stats_.smoothed_rtt(),
+              loss_algorithm_.GetLossTimeout());
+  } else {
+    EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
+  }
 }
 
 TEST_F(GeneralLossAlgorithmTest, EarlyRetransmit1Packet) {
@@ -264,6 +269,9 @@
 
 // NoFack loss detection tests.
 TEST_F(GeneralLossAlgorithmTest, LazyFackNackRetransmit1Packet) {
+  if (GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+    return;
+  }
   loss_algorithm_.SetLossDetectionType(kLazyFack);
   const size_t kNumSentPackets = 5;
   // Transmit 5 packets.
@@ -295,6 +303,9 @@
 // unacknowledged data.
 TEST_F(GeneralLossAlgorithmTest,
        LazyFackNoNackRetransmit1PacketWith1StretchAck) {
+  if (GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+    return;
+  }
   loss_algorithm_.SetLossDetectionType(kLazyFack);
   const size_t kNumSentPackets = 10;
   // Transmit 10 packets.
@@ -326,6 +337,9 @@
 
 // Ack a packet 3 packets ahead does not cause a retransmit.
 TEST_F(GeneralLossAlgorithmTest, LazyFackNackRetransmit1PacketSingleAck) {
+  if (GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+    return;
+  }
   loss_algorithm_.SetLossDetectionType(kLazyFack);
   const size_t kNumSentPackets = 10;
   // Transmit 10 packets.
@@ -351,6 +365,9 @@
 
 // Time-based loss detection tests.
 TEST_F(GeneralLossAlgorithmTest, NoLossFor500Nacks) {
+  if (GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+    return;
+  }
   loss_algorithm_.SetLossDetectionType(kTime);
   const size_t kNumSentPackets = 5;
   // Transmit 5 packets.
@@ -370,6 +387,9 @@
 }
 
 TEST_F(GeneralLossAlgorithmTest, NoLossUntilTimeout) {
+  if (GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+    return;
+  }
   loss_algorithm_.SetLossDetectionType(kTime);
   const size_t kNumSentPackets = 10;
   // Transmit 10 packets at 1/10th an RTT interval.
@@ -396,6 +416,9 @@
 }
 
 TEST_F(GeneralLossAlgorithmTest, NoLossWithoutNack) {
+  if (GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+    return;
+  }
   loss_algorithm_.SetLossDetectionType(kTime);
   const size_t kNumSentPackets = 10;
   // Transmit 10 packets at 1/10th an RTT interval.
@@ -423,6 +446,9 @@
 }
 
 TEST_F(GeneralLossAlgorithmTest, MultipleLossesAtOnce) {
+  if (GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+    return;
+  }
   loss_algorithm_.SetLossDetectionType(kTime);
   const size_t kNumSentPackets = 10;
   // Transmit 10 packets at once and then go forward an RTT.
@@ -448,6 +474,9 @@
 }
 
 TEST_F(GeneralLossAlgorithmTest, NoSpuriousLossesFromLargeReordering) {
+  if (GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+    return;
+  }
   loss_algorithm_.SetLossDetectionType(kTime);
   const size_t kNumSentPackets = 10;
   // Transmit 10 packets at once and then go forward an RTT.
@@ -482,6 +511,9 @@
 }
 
 TEST_F(GeneralLossAlgorithmTest, IncreaseThresholdUponSpuriousLoss) {
+  if (GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+    return;
+  }
   loss_algorithm_.SetLossDetectionType(kAdaptiveTime);
   EXPECT_EQ(4, loss_algorithm_.reordering_shift());
   const size_t kNumSentPackets = 10;
@@ -563,7 +595,7 @@
 }
 
 TEST_F(GeneralLossAlgorithmTest, IncreaseReorderingThresholdUponSpuriousLoss) {
-  loss_algorithm_.enable_adaptive_reordering_threshold();
+  loss_algorithm_.set_use_adaptive_reordering_threshold(true);
   for (size_t i = 1; i <= 4; ++i) {
     SendDataPacket(i);
   }
@@ -627,6 +659,7 @@
 
 TEST_F(GeneralLossAlgorithmTest, DefaultIetfLossDetection) {
   loss_algorithm_.SetLossDetectionType(kIetfLossDetection);
+  loss_algorithm_.set_reordering_shift(kDefaultIetfLossDelayShift);
   for (size_t i = 1; i <= 6; ++i) {
     SendDataPacket(i);
   }
diff --git a/quic/core/congestion_control/uber_loss_algorithm.cc b/quic/core/congestion_control/uber_loss_algorithm.cc
index 4e7f07b..a72ba03 100644
--- a/quic/core/congestion_control/uber_loss_algorithm.cc
+++ b/quic/core/congestion_control/uber_loss_algorithm.cc
@@ -8,7 +8,8 @@
 
 namespace quic {
 
-UberLossAlgorithm::UberLossAlgorithm() : UberLossAlgorithm(kNack) {}
+UberLossAlgorithm::UberLossAlgorithm()
+    : UberLossAlgorithm(GetDefaultLossDetectionType()) {}
 
 UberLossAlgorithm::UberLossAlgorithm(LossDetectionType loss_type)
     : loss_type_(loss_type) {
@@ -89,7 +90,13 @@
 
 void UberLossAlgorithm::EnableAdaptiveReorderingThreshold() {
   for (int8_t i = INITIAL_DATA; i < NUM_PACKET_NUMBER_SPACES; ++i) {
-    general_loss_algorithms_[i].enable_adaptive_reordering_threshold();
+    general_loss_algorithms_[i].set_use_adaptive_reordering_threshold(true);
+  }
+}
+
+void UberLossAlgorithm::DisableAdaptiveReorderingThreshold() {
+  for (int8_t i = INITIAL_DATA; i < NUM_PACKET_NUMBER_SPACES; ++i) {
+    general_loss_algorithms_[i].set_use_adaptive_reordering_threshold(false);
   }
 }
 
diff --git a/quic/core/congestion_control/uber_loss_algorithm.h b/quic/core/congestion_control/uber_loss_algorithm.h
index f922bba..2a530d2 100644
--- a/quic/core/congestion_control/uber_loss_algorithm.h
+++ b/quic/core/congestion_control/uber_loss_algorithm.h
@@ -54,6 +54,9 @@
   // Enable adaptive reordering threshold of all packet number spaces.
   void EnableAdaptiveReorderingThreshold();
 
+  // Disable adaptive reordering threshold of all packet number spaces.
+  void DisableAdaptiveReorderingThreshold();
+
   // Enable adaptive time threshold of all packet number spaces.
   void EnableAdaptiveTimeThreshold();
 
diff --git a/quic/core/congestion_control/uber_loss_algorithm_test.cc b/quic/core/congestion_control/uber_loss_algorithm_test.cc
index 79d0ff7..33e4167 100644
--- a/quic/core/congestion_control/uber_loss_algorithm_test.cc
+++ b/quic/core/congestion_control/uber_loss_algorithm_test.cc
@@ -115,7 +115,12 @@
       APPLICATION_DATA, QuicPacketNumber(4));
   // No packet loss by acking 4.
   VerifyLosses(4, packets_acked_, std::vector<uint64_t>{});
-  EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
+  if (GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+    EXPECT_EQ(clock_.Now() + 1.25 * rtt_stats_.smoothed_rtt(),
+              loss_algorithm_.GetLossTimeout());
+  } else {
+    EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
+  }
 
   // Acking 6 causes 3 to be detected loss.
   AckPackets({6});
diff --git a/quic/core/quic_connection.cc b/quic/core/quic_connection.cc
index 55f53eb..6ff097e 100644
--- a/quic/core/quic_connection.cc
+++ b/quic/core/quic_connection.cc
@@ -303,7 +303,7 @@
                            random_generator_,
                            &stats_,
                            GetDefaultCongestionControlType(),
-                           kNack),
+                           GetDefaultLossDetectionType()),
       version_negotiated_(false),
       perspective_(perspective),
       connected_(true),
diff --git a/quic/core/quic_constants.h b/quic/core/quic_constants.h
index 3264c15..0c6c4ff 100644
--- a/quic/core/quic_constants.h
+++ b/quic/core/quic_constants.h
@@ -248,6 +248,9 @@
 // packet is lost due to early retransmission by time based loss detection.
 static const int kDefaultLossDelayShift = 2;
 
+// Default fraction (1/8) of an RTT when doing IETF loss detection.
+static const int kDefaultIetfLossDelayShift = 3;
+
 // Maximum number of retransmittable packets received before sending an ack.
 const QuicPacketCount kDefaultRetransmittablePacketsBeforeAck = 2;
 // Wait for up to 10 retransmittable packets before sending an ack.
diff --git a/quic/core/quic_sent_packet_manager.cc b/quic/core/quic_sent_packet_manager.cc
index bd0343b..f4d3579 100644
--- a/quic/core/quic_sent_packet_manager.cc
+++ b/quic/core/quic_sent_packet_manager.cc
@@ -250,29 +250,41 @@
     use_new_rto_ = true;
   }
   // Configure loss detection.
-  if (config.HasClientRequestedIndependentOption(kTIME, perspective)) {
-    uber_loss_algorithm_.SetLossDetectionType(kTime);
-  }
-  if (config.HasClientRequestedIndependentOption(kATIM, perspective)) {
-    uber_loss_algorithm_.SetLossDetectionType(kAdaptiveTime);
-  }
-  if (config.HasClientRequestedIndependentOption(kLFAK, perspective)) {
-    uber_loss_algorithm_.SetLossDetectionType(kLazyFack);
+  if (!GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+    if (config.HasClientRequestedIndependentOption(kTIME, perspective)) {
+      uber_loss_algorithm_.SetLossDetectionType(kTime);
+    }
+    if (config.HasClientRequestedIndependentOption(kATIM, perspective)) {
+      uber_loss_algorithm_.SetLossDetectionType(kAdaptiveTime);
+    }
+    if (config.HasClientRequestedIndependentOption(kLFAK, perspective)) {
+      uber_loss_algorithm_.SetLossDetectionType(kLazyFack);
+    }
   }
   if (GetQuicReloadableFlag(quic_enable_ietf_loss_detection)) {
     if (config.HasClientRequestedIndependentOption(kILD0, perspective)) {
       QUIC_RELOADABLE_FLAG_COUNT_N(quic_enable_ietf_loss_detection, 1, 5);
       uber_loss_algorithm_.SetLossDetectionType(kIetfLossDetection);
+      if (GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+        uber_loss_algorithm_.SetReorderingShift(kDefaultIetfLossDelayShift);
+        uber_loss_algorithm_.DisableAdaptiveReorderingThreshold();
+      }
     }
     if (config.HasClientRequestedIndependentOption(kILD1, perspective)) {
       QUIC_RELOADABLE_FLAG_COUNT_N(quic_enable_ietf_loss_detection, 2, 5);
       uber_loss_algorithm_.SetLossDetectionType(kIetfLossDetection);
       uber_loss_algorithm_.SetReorderingShift(kDefaultLossDelayShift);
+      if (GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+        uber_loss_algorithm_.DisableAdaptiveReorderingThreshold();
+      }
     }
     if (config.HasClientRequestedIndependentOption(kILD2, perspective)) {
       QUIC_RELOADABLE_FLAG_COUNT_N(quic_enable_ietf_loss_detection, 3, 5);
       uber_loss_algorithm_.SetLossDetectionType(kIetfLossDetection);
       uber_loss_algorithm_.EnableAdaptiveReorderingThreshold();
+      if (GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+        uber_loss_algorithm_.SetReorderingShift(kDefaultIetfLossDelayShift);
+      }
     }
     if (config.HasClientRequestedIndependentOption(kILD3, perspective)) {
       QUIC_RELOADABLE_FLAG_COUNT_N(quic_enable_ietf_loss_detection, 4, 5);
diff --git a/quic/core/quic_sent_packet_manager_test.cc b/quic/core/quic_sent_packet_manager_test.cc
index 8dd0c30..fe7a81f 100644
--- a/quic/core/quic_sent_packet_manager_test.cc
+++ b/quic/core/quic_sent_packet_manager_test.cc
@@ -91,7 +91,7 @@
                  QuicRandom::GetInstance(),
                  &stats_,
                  kCubicBytes,
-                 kNack),
+                 GetDefaultLossDetectionType()),
         send_algorithm_(new StrictMock<MockSendAlgorithm>),
         network_change_visitor_(new StrictMock<MockNetworkChangeVisitor>) {
     QuicSentPacketManagerPeer::SetSendAlgorithm(&manager_, send_algorithm_);
@@ -470,7 +470,13 @@
   clock_.AdvanceTime(rtt);
 
   // Next, NACK packet 2 three times.
-  ExpectAck(3);
+  if (GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+    EXPECT_CALL(notifier_, IsFrameOutstanding(_)).WillRepeatedly(Return(false));
+    EXPECT_CALL(notifier_, OnFrameLost(_)).Times(1);
+    ExpectAckAndLoss(true, 3, 2);
+  } else {
+    ExpectAck(3);
+  }
   manager_.OnAckFrameStart(QuicPacketNumber(3), QuicTime::Delta::Infinite(),
                            clock_.Now());
   manager_.OnAckRange(QuicPacketNumber(3), QuicPacketNumber(4));
@@ -488,12 +494,16 @@
             manager_.OnAckFrameEnd(clock_.Now(), QuicPacketNumber(3),
                                    ENCRYPTION_INITIAL));
 
-  ExpectAckAndLoss(true, 5, 2);
-  // Frames in all packets are acked.
-  EXPECT_CALL(notifier_, IsFrameOutstanding(_)).WillRepeatedly(Return(false));
-  // Notify session that stream frame in packet 2 gets lost although it is
-  // not outstanding.
-  EXPECT_CALL(notifier_, OnFrameLost(_)).Times(1);
+  if (GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+    ExpectAck(5);
+  } else {
+    // Frames in all packets are acked.
+    EXPECT_CALL(notifier_, IsFrameOutstanding(_)).WillRepeatedly(Return(false));
+    // Notify session that stream frame in packet 2 gets lost although it is
+    // not outstanding.
+    EXPECT_CALL(notifier_, OnFrameLost(_)).Times(1);
+    ExpectAckAndLoss(true, 5, 2);
+  }
   manager_.OnAckFrameStart(QuicPacketNumber(5), QuicTime::Delta::Infinite(),
                            clock_.Now());
   manager_.OnAckRange(QuicPacketNumber(3), QuicPacketNumber(6));
@@ -1598,14 +1608,15 @@
 
   // Ack a packet before the first RTO and ensure the RTO timeout returns to the
   // original value and OnRetransmissionTimeout is not called or reverted.
-  ExpectAck(2);
+  uint64_t acked[] = {1, 2};
+  ExpectAcksAndLosses(true, acked, QUIC_ARRAYSIZE(acked), nullptr, 0);
   manager_.OnAckFrameStart(QuicPacketNumber(2), QuicTime::Delta::Infinite(),
                            clock_.Now());
-  manager_.OnAckRange(QuicPacketNumber(2), QuicPacketNumber(3));
+  manager_.OnAckRange(QuicPacketNumber(1), QuicPacketNumber(3));
   EXPECT_EQ(PACKETS_NEWLY_ACKED,
             manager_.OnAckFrameEnd(clock_.Now(), QuicPacketNumber(1),
                                    ENCRYPTION_INITIAL));
-  EXPECT_EQ(5 * kDefaultLength, manager_.GetBytesInFlight());
+  EXPECT_EQ(4 * kDefaultLength, manager_.GetBytesInFlight());
 
   // Wait 2RTTs from now for the RTO, since it's the max of the RTO time
   // and the TLP time.  In production, there would always be two TLP's first.
@@ -1743,6 +1754,9 @@
 }
 
 TEST_F(QuicSentPacketManagerTest, NegotiateTimeLossDetectionFromOptions) {
+  if (GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+    return;
+  }
   EXPECT_EQ(kNack, QuicSentPacketManagerPeer::GetLossAlgorithm(&manager_)
                        ->GetLossDetectionType());
 
@@ -1760,8 +1774,20 @@
 
 TEST_F(QuicSentPacketManagerTest, NegotiateIetfLossDetectionFromOptions) {
   SetQuicReloadableFlag(quic_enable_ietf_loss_detection, true);
-  EXPECT_EQ(kNack, QuicSentPacketManagerPeer::GetLossAlgorithm(&manager_)
-                       ->GetLossDetectionType());
+  if (GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+    EXPECT_EQ(kIetfLossDetection,
+              QuicSentPacketManagerPeer::GetLossAlgorithm(&manager_)
+                  ->GetLossDetectionType());
+    EXPECT_TRUE(QuicSentPacketManagerPeer::AdaptiveReorderingThresholdEnabled(
+        &manager_));
+    EXPECT_FALSE(
+        QuicSentPacketManagerPeer::AdaptiveTimeThresholdEnabled(&manager_));
+    EXPECT_EQ(kDefaultLossDelayShift,
+              QuicSentPacketManagerPeer::GetReorderingShift(&manager_));
+  } else {
+    EXPECT_EQ(kNack, QuicSentPacketManagerPeer::GetLossAlgorithm(&manager_)
+                         ->GetLossDetectionType());
+  }
 
   QuicConfig config;
   QuicTagVector options;
@@ -1782,8 +1808,20 @@
 TEST_F(QuicSentPacketManagerTest,
        NegotiateIetfLossDetectionOneFourthRttFromOptions) {
   SetQuicReloadableFlag(quic_enable_ietf_loss_detection, true);
-  EXPECT_EQ(kNack, QuicSentPacketManagerPeer::GetLossAlgorithm(&manager_)
-                       ->GetLossDetectionType());
+  if (GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+    EXPECT_EQ(kIetfLossDetection,
+              QuicSentPacketManagerPeer::GetLossAlgorithm(&manager_)
+                  ->GetLossDetectionType());
+    EXPECT_TRUE(QuicSentPacketManagerPeer::AdaptiveReorderingThresholdEnabled(
+        &manager_));
+    EXPECT_FALSE(
+        QuicSentPacketManagerPeer::AdaptiveTimeThresholdEnabled(&manager_));
+    EXPECT_EQ(kDefaultLossDelayShift,
+              QuicSentPacketManagerPeer::GetReorderingShift(&manager_));
+  } else {
+    EXPECT_EQ(kNack, QuicSentPacketManagerPeer::GetLossAlgorithm(&manager_)
+                         ->GetLossDetectionType());
+  }
 
   QuicConfig config;
   QuicTagVector options;
@@ -1805,10 +1843,22 @@
 TEST_F(QuicSentPacketManagerTest,
        NegotiateIetfLossDetectionAdaptiveReorderingThreshold) {
   SetQuicReloadableFlag(quic_enable_ietf_loss_detection, true);
-  EXPECT_EQ(kNack, QuicSentPacketManagerPeer::GetLossAlgorithm(&manager_)
-                       ->GetLossDetectionType());
-  EXPECT_FALSE(
-      QuicSentPacketManagerPeer::AdaptiveReorderingThresholdEnabled(&manager_));
+  if (GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+    EXPECT_EQ(kIetfLossDetection,
+              QuicSentPacketManagerPeer::GetLossAlgorithm(&manager_)
+                  ->GetLossDetectionType());
+    EXPECT_TRUE(QuicSentPacketManagerPeer::AdaptiveReorderingThresholdEnabled(
+        &manager_));
+    EXPECT_FALSE(
+        QuicSentPacketManagerPeer::AdaptiveTimeThresholdEnabled(&manager_));
+    EXPECT_EQ(kDefaultLossDelayShift,
+              QuicSentPacketManagerPeer::GetReorderingShift(&manager_));
+  } else {
+    EXPECT_EQ(kNack, QuicSentPacketManagerPeer::GetLossAlgorithm(&manager_)
+                         ->GetLossDetectionType());
+    EXPECT_FALSE(QuicSentPacketManagerPeer::AdaptiveReorderingThresholdEnabled(
+        &manager_));
+  }
 
   QuicConfig config;
   QuicTagVector options;
@@ -1829,10 +1879,22 @@
 TEST_F(QuicSentPacketManagerTest,
        NegotiateIetfLossDetectionAdaptiveReorderingThreshold2) {
   SetQuicReloadableFlag(quic_enable_ietf_loss_detection, true);
-  EXPECT_EQ(kNack, QuicSentPacketManagerPeer::GetLossAlgorithm(&manager_)
-                       ->GetLossDetectionType());
-  EXPECT_FALSE(
-      QuicSentPacketManagerPeer::AdaptiveReorderingThresholdEnabled(&manager_));
+  if (GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+    EXPECT_EQ(kIetfLossDetection,
+              QuicSentPacketManagerPeer::GetLossAlgorithm(&manager_)
+                  ->GetLossDetectionType());
+    EXPECT_TRUE(QuicSentPacketManagerPeer::AdaptiveReorderingThresholdEnabled(
+        &manager_));
+    EXPECT_FALSE(
+        QuicSentPacketManagerPeer::AdaptiveTimeThresholdEnabled(&manager_));
+    EXPECT_EQ(kDefaultLossDelayShift,
+              QuicSentPacketManagerPeer::GetReorderingShift(&manager_));
+  } else {
+    EXPECT_EQ(kNack, QuicSentPacketManagerPeer::GetLossAlgorithm(&manager_)
+                         ->GetLossDetectionType());
+    EXPECT_FALSE(QuicSentPacketManagerPeer::AdaptiveReorderingThresholdEnabled(
+        &manager_));
+  }
 
   QuicConfig config;
   QuicTagVector options;
@@ -1841,7 +1903,6 @@
   EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
   EXPECT_CALL(*network_change_visitor_, OnCongestionChange());
   manager_.SetFromConfig(config);
-
   EXPECT_EQ(kIetfLossDetection,
             QuicSentPacketManagerPeer::GetLossAlgorithm(&manager_)
                 ->GetLossDetectionType());
@@ -1854,12 +1915,24 @@
 TEST_F(QuicSentPacketManagerTest,
        NegotiateIetfLossDetectionAdaptiveReorderingAndTimeThreshold) {
   SetQuicReloadableFlag(quic_enable_ietf_loss_detection, true);
-  EXPECT_EQ(kNack, QuicSentPacketManagerPeer::GetLossAlgorithm(&manager_)
-                       ->GetLossDetectionType());
-  EXPECT_FALSE(
-      QuicSentPacketManagerPeer::AdaptiveReorderingThresholdEnabled(&manager_));
-  EXPECT_FALSE(
-      QuicSentPacketManagerPeer::AdaptiveTimeThresholdEnabled(&manager_));
+  if (GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+    EXPECT_EQ(kIetfLossDetection,
+              QuicSentPacketManagerPeer::GetLossAlgorithm(&manager_)
+                  ->GetLossDetectionType());
+    EXPECT_TRUE(QuicSentPacketManagerPeer::AdaptiveReorderingThresholdEnabled(
+        &manager_));
+    EXPECT_FALSE(
+        QuicSentPacketManagerPeer::AdaptiveTimeThresholdEnabled(&manager_));
+    EXPECT_EQ(kDefaultLossDelayShift,
+              QuicSentPacketManagerPeer::GetReorderingShift(&manager_));
+  } else {
+    EXPECT_EQ(kNack, QuicSentPacketManagerPeer::GetLossAlgorithm(&manager_)
+                         ->GetLossDetectionType());
+    EXPECT_FALSE(QuicSentPacketManagerPeer::AdaptiveReorderingThresholdEnabled(
+        &manager_));
+    EXPECT_FALSE(
+        QuicSentPacketManagerPeer::AdaptiveTimeThresholdEnabled(&manager_));
+  }
 
   QuicConfig config;
   QuicTagVector options;
diff --git a/quic/core/quic_types.h b/quic/core/quic_types.h
index 23cbe7a..b14e513 100644
--- a/quic/core/quic_types.h
+++ b/quic/core/quic_types.h
@@ -404,6 +404,16 @@
   kIetfLossDetection,  // IETF style loss detection.
 };
 
+// TODO(fayang): Remove this when deprecating
+// quic_default_on_ietf_loss_detection.
+inline LossDetectionType GetDefaultLossDetectionType() {
+  if (GetQuicRestartFlag(quic_default_on_ietf_loss_detection)) {
+    QUIC_RESTART_FLAG_COUNT(quic_default_on_ietf_loss_detection);
+    return kIetfLossDetection;
+  }
+  return kNack;
+}
+
 // EncryptionLevel enumerates the stages of encryption that a QUIC connection
 // progresses through. When retransmitting a packet, the encryption level needs
 // to be specified so that it is retransmitted at a level which the peer can