In quic, adjust blackhole detection configs based on connection options. protected by existing gfe2_reloadable_flag_quic_default_enable_5rto_blackhole_detection.
Connection options include 2RTO, 3RTO, 4RTO, 6RTO and client only blackhole detection.
PiperOrigin-RevId: 315280821
Change-Id: I21a8f6fc101412a83794821a265c9e312a89b6d8
diff --git a/quic/core/quic_connection_test.cc b/quic/core/quic_connection_test.cc
index f6e463f..8d096eb 100644
--- a/quic/core/quic_connection_test.cc
+++ b/quic/core/quic_connection_test.cc
@@ -6117,6 +6117,10 @@
connection_options.push_back(k5RTO);
config.SetConnectionOptionsToSend(connection_options);
QuicConfigPeer::SetNegotiated(&config, true);
+ if (GetQuicReloadableFlag(quic_default_enable_5rto_blackhole_detection)) {
+ EXPECT_CALL(visitor_, GetHandshakeState())
+ .WillRepeatedly(Return(HANDSHAKE_COMPLETE));
+ }
if (connection_.version().AuthenticatesHandshakeConnectionIds()) {
QuicConfigPeer::SetReceivedOriginalConnectionId(
&config, connection_.connection_id());
@@ -10957,6 +10961,161 @@
}
}
+TEST_P(QuicConnectionTest, ClientOnlyBlackholeDetectionClient) {
+ if (!GetQuicReloadableFlag(quic_default_enable_5rto_blackhole_detection)) {
+ return;
+ }
+ QuicConfig config;
+ QuicTagVector connection_options;
+ connection_options.push_back(kCBHD);
+ config.SetConnectionOptionsToSend(connection_options);
+ EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
+ connection_.SetFromConfig(config);
+ EXPECT_CALL(visitor_, GetHandshakeState())
+ .WillRepeatedly(Return(HANDSHAKE_COMPLETE));
+ EXPECT_FALSE(connection_.GetBlackholeDetectorAlarm()->IsSet());
+ // Send stream data.
+ SendStreamDataToPeer(
+ GetNthClientInitiatedStreamId(1, connection_.transport_version()), "foo",
+ 0, FIN, nullptr);
+ // Verify blackhole detection is in progress.
+ EXPECT_TRUE(connection_.GetBlackholeDetectorAlarm()->IsSet());
+}
+
+TEST_P(QuicConnectionTest, ClientOnlyBlackholeDetectionServer) {
+ if (!GetQuicReloadableFlag(quic_default_enable_5rto_blackhole_detection)) {
+ return;
+ }
+ set_perspective(Perspective::IS_SERVER);
+ QuicPacketCreatorPeer::SetSendVersionInPacket(creator_, false);
+ if (version().SupportsAntiAmplificationLimit()) {
+ QuicConnectionPeer::SetAddressValidated(&connection_);
+ }
+ QuicConfig config;
+ QuicTagVector connection_options;
+ connection_options.push_back(kCBHD);
+ config.SetInitialReceivedConnectionOptions(connection_options);
+ EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
+ connection_.SetFromConfig(config);
+ EXPECT_CALL(visitor_, GetHandshakeState())
+ .WillRepeatedly(Return(HANDSHAKE_COMPLETE));
+ EXPECT_FALSE(connection_.GetBlackholeDetectorAlarm()->IsSet());
+ // Send stream data.
+ SendStreamDataToPeer(
+ GetNthClientInitiatedStreamId(1, connection_.transport_version()), "foo",
+ 0, FIN, nullptr);
+ // Verify blackhole detection is disabled.
+ EXPECT_FALSE(connection_.GetBlackholeDetectorAlarm()->IsSet());
+}
+
+TEST_P(QuicConnectionTest, 2RtoBlackholeDetection) {
+ if (!GetQuicReloadableFlag(quic_default_enable_5rto_blackhole_detection)) {
+ return;
+ }
+ QuicConfig config;
+ QuicTagVector connection_options;
+ connection_options.push_back(k2RTO);
+ config.SetConnectionOptionsToSend(connection_options);
+ EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
+ connection_.SetFromConfig(config);
+ const size_t kMinRttMs = 40;
+ RttStats* rtt_stats = const_cast<RttStats*>(manager_->GetRttStats());
+ rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs),
+ QuicTime::Delta::Zero(), QuicTime::Zero());
+ EXPECT_CALL(visitor_, GetHandshakeState())
+ .WillRepeatedly(Return(HANDSHAKE_COMPLETE));
+ EXPECT_FALSE(connection_.GetBlackholeDetectorAlarm()->IsSet());
+ // Send stream data.
+ SendStreamDataToPeer(
+ GetNthClientInitiatedStreamId(1, connection_.transport_version()), "foo",
+ 0, FIN, nullptr);
+ // Verify blackhole delay is expected.
+ EXPECT_EQ(clock_.Now() +
+ connection_.sent_packet_manager().GetNetworkBlackholeDelay(2),
+ QuicConnectionPeer::GetBlackholeDetectionDeadline(&connection_));
+}
+
+TEST_P(QuicConnectionTest, 3RtoBlackholeDetection) {
+ if (!GetQuicReloadableFlag(quic_default_enable_5rto_blackhole_detection)) {
+ return;
+ }
+ QuicConfig config;
+ QuicTagVector connection_options;
+ connection_options.push_back(k3RTO);
+ config.SetConnectionOptionsToSend(connection_options);
+ EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
+ connection_.SetFromConfig(config);
+ const size_t kMinRttMs = 40;
+ RttStats* rtt_stats = const_cast<RttStats*>(manager_->GetRttStats());
+ rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs),
+ QuicTime::Delta::Zero(), QuicTime::Zero());
+ EXPECT_CALL(visitor_, GetHandshakeState())
+ .WillRepeatedly(Return(HANDSHAKE_COMPLETE));
+ EXPECT_FALSE(connection_.GetBlackholeDetectorAlarm()->IsSet());
+ // Send stream data.
+ SendStreamDataToPeer(
+ GetNthClientInitiatedStreamId(1, connection_.transport_version()), "foo",
+ 0, FIN, nullptr);
+ // Verify blackhole delay is expected.
+ EXPECT_EQ(clock_.Now() +
+ connection_.sent_packet_manager().GetNetworkBlackholeDelay(3),
+ QuicConnectionPeer::GetBlackholeDetectionDeadline(&connection_));
+}
+
+TEST_P(QuicConnectionTest, 4RtoBlackholeDetection) {
+ if (!GetQuicReloadableFlag(quic_default_enable_5rto_blackhole_detection)) {
+ return;
+ }
+ QuicConfig config;
+ QuicTagVector connection_options;
+ connection_options.push_back(k4RTO);
+ config.SetConnectionOptionsToSend(connection_options);
+ EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
+ connection_.SetFromConfig(config);
+ const size_t kMinRttMs = 40;
+ RttStats* rtt_stats = const_cast<RttStats*>(manager_->GetRttStats());
+ rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs),
+ QuicTime::Delta::Zero(), QuicTime::Zero());
+ EXPECT_CALL(visitor_, GetHandshakeState())
+ .WillRepeatedly(Return(HANDSHAKE_COMPLETE));
+ EXPECT_FALSE(connection_.GetBlackholeDetectorAlarm()->IsSet());
+ // Send stream data.
+ SendStreamDataToPeer(
+ GetNthClientInitiatedStreamId(1, connection_.transport_version()), "foo",
+ 0, FIN, nullptr);
+ // Verify blackhole delay is expected.
+ EXPECT_EQ(clock_.Now() +
+ connection_.sent_packet_manager().GetNetworkBlackholeDelay(4),
+ QuicConnectionPeer::GetBlackholeDetectionDeadline(&connection_));
+}
+
+TEST_P(QuicConnectionTest, 6RtoBlackholeDetection) {
+ if (!GetQuicReloadableFlag(quic_default_enable_5rto_blackhole_detection)) {
+ return;
+ }
+ QuicConfig config;
+ QuicTagVector connection_options;
+ connection_options.push_back(k6RTO);
+ config.SetConnectionOptionsToSend(connection_options);
+ EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
+ connection_.SetFromConfig(config);
+ const size_t kMinRttMs = 40;
+ RttStats* rtt_stats = const_cast<RttStats*>(manager_->GetRttStats());
+ rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs),
+ QuicTime::Delta::Zero(), QuicTime::Zero());
+ EXPECT_CALL(visitor_, GetHandshakeState())
+ .WillRepeatedly(Return(HANDSHAKE_COMPLETE));
+ EXPECT_FALSE(connection_.GetBlackholeDetectorAlarm()->IsSet());
+ // Send stream data.
+ SendStreamDataToPeer(
+ GetNthClientInitiatedStreamId(1, connection_.transport_version()), "foo",
+ 0, FIN, nullptr);
+ // Verify blackhole delay is expected.
+ EXPECT_EQ(clock_.Now() +
+ connection_.sent_packet_manager().GetNetworkBlackholeDelay(6),
+ QuicConnectionPeer::GetBlackholeDetectionDeadline(&connection_));
+}
+
} // namespace
} // namespace test
} // namespace quic