summaryrefslogtreecommitdiff
path: root/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr_sender_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr_sender_test.cc')
-rw-r--r--chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr_sender_test.cc106
1 files changed, 95 insertions, 11 deletions
diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr_sender_test.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr_sender_test.cc
index 8ecab8736ae..6acfe80519a 100644
--- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr_sender_test.cc
+++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr_sender_test.cc
@@ -135,8 +135,9 @@ class BbrSenderTest : public QuicTest {
endpoint->connection()->clock()->Now(), rtt_stats,
QuicSentPacketManagerPeer::GetUnackedPacketMap(
QuicConnectionPeer::GetSentPacketManager(endpoint->connection())),
- kInitialCongestionWindowPackets, kDefaultMaxCongestionWindowPackets,
- &random_, QuicConnectionPeer::GetStats(endpoint->connection()));
+ kInitialCongestionWindowPackets,
+ GetQuicFlag(FLAGS_quic_max_congestion_window), &random_,
+ QuicConnectionPeer::GetStats(endpoint->connection()));
QuicConnectionPeer::SetSendAlgorithm(endpoint->connection(), sender);
endpoint->RecordTrace();
return sender;
@@ -379,8 +380,9 @@ TEST_F(BbrSenderTest, SimpleTransferAckDecimation) {
bbr_sender_.connection()->clock()->Now(), rtt_stats_,
QuicSentPacketManagerPeer::GetUnackedPacketMap(
QuicConnectionPeer::GetSentPacketManager(bbr_sender_.connection())),
- kInitialCongestionWindowPackets, kDefaultMaxCongestionWindowPackets,
- &random_, QuicConnectionPeer::GetStats(bbr_sender_.connection()));
+ kInitialCongestionWindowPackets,
+ GetQuicFlag(FLAGS_quic_max_congestion_window), &random_,
+ QuicConnectionPeer::GetStats(bbr_sender_.connection()));
QuicConnectionPeer::SetSendAlgorithm(bbr_sender_.connection(), sender_);
// Enable Ack Decimation on the receiver.
QuicConnectionPeer::SetAckMode(receiver_.connection(),
@@ -1247,10 +1249,18 @@ TEST_F(BbrSenderTest, SimpleCompetition) {
TEST_F(BbrSenderTest, ResumeConnectionState) {
CreateDefaultSetup();
- bbr_sender_.connection()->AdjustNetworkParameters(kTestLinkBandwidth,
- kTestRtt, false);
- EXPECT_EQ(kTestLinkBandwidth, sender_->ExportDebugState().max_bandwidth);
- EXPECT_EQ(kTestLinkBandwidth, sender_->BandwidthEstimate());
+ bbr_sender_.connection()->AdjustNetworkParameters(
+ SendAlgorithmInterface::NetworkParams(kTestLinkBandwidth, kTestRtt,
+ false));
+ if (!GetQuicReloadableFlag(quic_bbr_donot_inject_bandwidth)) {
+ EXPECT_EQ(kTestLinkBandwidth, sender_->ExportDebugState().max_bandwidth);
+ EXPECT_EQ(kTestLinkBandwidth, sender_->BandwidthEstimate());
+ }
+ EXPECT_EQ(kTestLinkBandwidth * kTestRtt,
+ sender_->ExportDebugState().congestion_window);
+ if (GetQuicReloadableFlag(quic_bbr_fix_pacing_rate)) {
+ EXPECT_EQ(kTestLinkBandwidth, sender_->PacingRate(/*bytes_in_flight=*/0));
+ }
EXPECT_APPROX_EQ(kTestRtt, sender_->ExportDebugState().min_rtt, 0.01f);
DriveOutOfStartup();
@@ -1299,14 +1309,88 @@ TEST_F(BbrSenderTest, StartupStats) {
EXPECT_THAT(stats.slowstart_bytes_sent, AllOf(Ge(100000u), Le(1000000u)));
EXPECT_LE(stats.slowstart_packets_lost, 10u);
EXPECT_LE(stats.slowstart_bytes_lost, 10000u);
- EXPECT_THAT(stats.slowstart_duration,
+ EXPECT_FALSE(stats.slowstart_duration.IsRunning());
+ EXPECT_THAT(stats.slowstart_duration.GetTotalElapsedTime(),
AllOf(Ge(QuicTime::Delta::FromMilliseconds(500)),
Le(QuicTime::Delta::FromMilliseconds(1500))));
- EXPECT_EQ(QuicTime::Zero(), stats.slowstart_start_time);
- EXPECT_EQ(stats.slowstart_duration,
+ EXPECT_EQ(stats.slowstart_duration.GetTotalElapsedTime(),
QuicConnectionPeer::GetSentPacketManager(bbr_sender_.connection())
->GetSlowStartDuration());
}
+// Regression test for b/143540157.
+TEST_F(BbrSenderTest, RecalculatePacingRateOnCwndChange1RTT) {
+ CreateDefaultSetup();
+
+ bbr_sender_.AddBytesToTransfer(1 * 1024 * 1024);
+ // Wait until an ACK comes back.
+ const QuicTime::Delta timeout = QuicTime::Delta::FromSeconds(5);
+ bool simulator_result = simulator_.RunUntilOrTimeout(
+ [this]() { return !sender_->ExportDebugState().min_rtt.IsZero(); },
+ timeout);
+ ASSERT_TRUE(simulator_result);
+ const QuicByteCount previous_cwnd =
+ sender_->ExportDebugState().congestion_window;
+
+ // Bootstrap cwnd.
+ bbr_sender_.connection()->AdjustNetworkParameters(
+ SendAlgorithmInterface::NetworkParams(kTestLinkBandwidth,
+ QuicTime::Delta::Zero(), false));
+ if (!GetQuicReloadableFlag(quic_bbr_donot_inject_bandwidth)) {
+ EXPECT_EQ(kTestLinkBandwidth, sender_->ExportDebugState().max_bandwidth);
+ EXPECT_EQ(kTestLinkBandwidth, sender_->BandwidthEstimate());
+ }
+ EXPECT_LT(previous_cwnd, sender_->ExportDebugState().congestion_window);
+
+ if (GetQuicReloadableFlag(quic_bbr_fix_pacing_rate)) {
+ // Verify pacing rate is re-calculated based on the new cwnd and min_rtt.
+ EXPECT_APPROX_EQ(QuicBandwidth::FromBytesAndTimeDelta(
+ sender_->ExportDebugState().congestion_window,
+ sender_->ExportDebugState().min_rtt),
+ sender_->PacingRate(/*bytes_in_flight=*/0), 0.01f);
+ } else {
+ // Pacing rate is still based on initial cwnd.
+ EXPECT_APPROX_EQ(QuicBandwidth::FromBytesAndTimeDelta(
+ kInitialCongestionWindowPackets * kDefaultTCPMSS,
+ sender_->ExportDebugState().min_rtt),
+ sender_->PacingRate(/*bytes_in_flight=*/0), 0.01f);
+ }
+}
+
+TEST_F(BbrSenderTest, RecalculatePacingRateOnCwndChange0RTT) {
+ CreateDefaultSetup();
+ // Initial RTT is available.
+ const_cast<RttStats*>(rtt_stats_)->set_initial_rtt(kTestRtt);
+
+ // Bootstrap cwnd.
+ bbr_sender_.connection()->AdjustNetworkParameters(
+ SendAlgorithmInterface::NetworkParams(kTestLinkBandwidth,
+ QuicTime::Delta::Zero(), false));
+ if (!GetQuicReloadableFlag(quic_bbr_donot_inject_bandwidth)) {
+ EXPECT_EQ(kTestLinkBandwidth, sender_->ExportDebugState().max_bandwidth);
+ EXPECT_EQ(kTestLinkBandwidth, sender_->BandwidthEstimate());
+ }
+ EXPECT_LT(kInitialCongestionWindowPackets * kDefaultTCPMSS,
+ sender_->ExportDebugState().congestion_window);
+ // No Rtt sample is available.
+ EXPECT_TRUE(sender_->ExportDebugState().min_rtt.IsZero());
+
+ if (GetQuicReloadableFlag(quic_bbr_fix_pacing_rate)) {
+ // Verify pacing rate is re-calculated based on the new cwnd and initial
+ // RTT.
+ EXPECT_APPROX_EQ(QuicBandwidth::FromBytesAndTimeDelta(
+ sender_->ExportDebugState().congestion_window,
+ rtt_stats_->initial_rtt()),
+ sender_->PacingRate(/*bytes_in_flight=*/0), 0.01f);
+ } else {
+ // Pacing rate is still based on initial cwnd.
+ EXPECT_APPROX_EQ(
+ 2.885f * QuicBandwidth::FromBytesAndTimeDelta(
+ kInitialCongestionWindowPackets * kDefaultTCPMSS,
+ rtt_stats_->initial_rtt()),
+ sender_->PacingRate(/*bytes_in_flight=*/0), 0.01f);
+ }
+}
+
} // namespace test
} // namespace quic