Add test flag --quic_use_lower_server_response_mtu_for_test that cap server side response packet size.
PiperOrigin-RevId: 395525045
diff --git a/quic/core/quic_connection.cc b/quic/core/quic_connection.cc
index 9e0c95e..57d16ec 100644
--- a/quic/core/quic_connection.cc
+++ b/quic/core/quic_connection.cc
@@ -3122,7 +3122,11 @@
if (perspective_ == Perspective::IS_SERVER &&
encryption_level_ == ENCRYPTION_INITIAL &&
last_size_ > packet_creator_.max_packet_length()) {
- SetMaxPacketLength(last_size_);
+ if (GetQuicFlag(FLAGS_quic_use_lower_server_response_mtu_for_test)) {
+ SetMaxPacketLength(std::min(last_size_, QuicByteCount(1250)));
+ } else {
+ SetMaxPacketLength(last_size_);
+ }
}
return true;
}
diff --git a/quic/core/quic_connection_test.cc b/quic/core/quic_connection_test.cc
index b7fba67..68ee43b 100644
--- a/quic/core/quic_connection_test.cc
+++ b/quic/core/quic_connection_test.cc
@@ -2832,6 +2832,18 @@
EXPECT_EQ(1000u, connection.max_packet_length());
}
+TEST_P(QuicConnectionTest, LowerServerResponseMtuTest) {
+ set_perspective(Perspective::IS_SERVER);
+ connection_.SetMaxPacketLength(1000);
+ EXPECT_EQ(1000u, connection_.max_packet_length());
+
+ SetQuicFlag(FLAGS_quic_use_lower_server_response_mtu_for_test, true);
+ EXPECT_CALL(visitor_, OnCryptoFrame(_)).Times(::testing::AtMost(1));
+ EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(::testing::AtMost(1));
+ ProcessCryptoPacketAtLevel(1, ENCRYPTION_INITIAL);
+ EXPECT_EQ(1250u, connection_.max_packet_length());
+}
+
TEST_P(QuicConnectionTest, IncreaseServerMaxPacketSize) {
set_perspective(Perspective::IS_SERVER);
connection_.SetMaxPacketLength(1000);
diff --git a/quic/core/quic_protocol_flags_list.h b/quic/core/quic_protocol_flags_list.h
index 8f6b7e5..02f107b 100644
--- a/quic/core/quic_protocol_flags_list.h
+++ b/quic/core/quic_protocol_flags_list.h
@@ -281,4 +281,6 @@
false,
"If true, always reject retry_token received in INITIAL packets")
+QUIC_PROTOCOL_FLAG(bool, quic_use_lower_server_response_mtu_for_test, false,
+ "If true, cap server response packet size at 1250.")
#endif