| Index: net/quic/core/quic_sent_packet_manager_test.cc
|
| diff --git a/net/quic/core/quic_sent_packet_manager_test.cc b/net/quic/core/quic_sent_packet_manager_test.cc
|
| index a6a54477348d376689e13d85de4e19da8fea7407..f08dfa4df21b4b5f8d3aeac1bbddd8af4f288ae8 100644
|
| --- a/net/quic/core/quic_sent_packet_manager_test.cc
|
| +++ b/net/quic/core/quic_sent_packet_manager_test.cc
|
| @@ -754,9 +754,7 @@ TEST_P(QuicSentPacketManagerTest, TailLossProbeThenRTO) {
|
|
|
| // Ensure the RTO is set based on the correct packet.
|
| rto_packet_time = clock_.Now();
|
| - EXPECT_CALL(*send_algorithm_, RetransmissionDelay())
|
| - .WillOnce(Return(QuicTime::Delta::FromSeconds(1)));
|
| - EXPECT_EQ(rto_packet_time + QuicTime::Delta::FromSeconds(1),
|
| + EXPECT_EQ(rto_packet_time + QuicTime::Delta::FromMilliseconds(500),
|
| manager_.GetRetransmissionTime());
|
|
|
| // Advance the time enough to ensure all packets are RTO'd.
|
| @@ -1121,9 +1119,6 @@ TEST_P(QuicSentPacketManagerTest, TwoRetransmissionTimeoutsAckFirst) {
|
|
|
| TEST_P(QuicSentPacketManagerTest, OnPathDegrading) {
|
| SendDataPacket(1);
|
| - QuicTime::Delta delay = QuicTime::Delta::FromMilliseconds(500);
|
| - EXPECT_CALL(*send_algorithm_, RetransmissionDelay())
|
| - .WillRepeatedly(Return(delay));
|
| for (size_t i = 1; i < kMinTimeoutsBeforePathDegrading; ++i) {
|
| manager_.OnRetransmissionTimeout();
|
| RetransmitNextPacket(i + 2);
|
| @@ -1247,17 +1242,17 @@ TEST_P(QuicSentPacketManagerTest, GetTransmissionTimeTailLossProbe) {
|
| }
|
|
|
| TEST_P(QuicSentPacketManagerTest, GetTransmissionTimeSpuriousRTO) {
|
| - const_cast<RttStats*>(manager_.GetRttStats())
|
| - ->UpdateRtt(QuicTime::Delta::FromMilliseconds(100),
|
| - QuicTime::Delta::Zero(), QuicTime::Zero());
|
| + RttStats* rtt_stats = const_cast<RttStats*>(manager_.GetRttStats());
|
| + rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(100),
|
| + QuicTime::Delta::Zero(), QuicTime::Zero());
|
| +
|
| SendDataPacket(1);
|
| SendDataPacket(2);
|
| SendDataPacket(3);
|
| SendDataPacket(4);
|
|
|
| - QuicTime::Delta expected_rto_delay = QuicTime::Delta::FromMilliseconds(500);
|
| - EXPECT_CALL(*send_algorithm_, RetransmissionDelay())
|
| - .WillRepeatedly(Return(expected_rto_delay));
|
| + QuicTime::Delta expected_rto_delay =
|
| + rtt_stats->smoothed_rtt() + 4 * rtt_stats->mean_deviation();
|
| QuicTime expected_time = clock_.Now() + expected_rto_delay;
|
| EXPECT_EQ(expected_time, manager_.GetRetransmissionTime());
|
|
|
| @@ -1302,8 +1297,10 @@ TEST_P(QuicSentPacketManagerTest, GetTransmissionTimeSpuriousRTO) {
|
|
|
| TEST_P(QuicSentPacketManagerTest, GetTransmissionDelayMin) {
|
| SendDataPacket(1);
|
| - EXPECT_CALL(*send_algorithm_, RetransmissionDelay())
|
| - .WillRepeatedly(Return(QuicTime::Delta::FromMilliseconds(1)));
|
| + // Provide a 1ms RTT sample.
|
| + const_cast<RttStats*>(manager_.GetRttStats())
|
| + ->UpdateRtt(QuicTime::Delta::FromMilliseconds(1), QuicTime::Delta::Zero(),
|
| + QuicTime::Zero());
|
| QuicTime::Delta delay = QuicTime::Delta::FromMilliseconds(200);
|
|
|
| // If the delay is smaller than the min, ensure it exponentially backs off
|
| @@ -1319,18 +1316,19 @@ TEST_P(QuicSentPacketManagerTest, GetTransmissionDelayMin) {
|
| }
|
|
|
| TEST_P(QuicSentPacketManagerTest, GetTransmissionDelayMax) {
|
| - EXPECT_CALL(*send_algorithm_, RetransmissionDelay())
|
| - .WillOnce(Return(QuicTime::Delta::FromSeconds(500)));
|
| + SendDataPacket(1);
|
| + // Provide a 60s RTT sample.
|
| + const_cast<RttStats*>(manager_.GetRttStats())
|
| + ->UpdateRtt(QuicTime::Delta::FromSeconds(60), QuicTime::Delta::Zero(),
|
| + QuicTime::Zero());
|
|
|
| EXPECT_EQ(QuicTime::Delta::FromSeconds(60),
|
| QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_));
|
| }
|
|
|
| -TEST_P(QuicSentPacketManagerTest, GetTransmissionDelay) {
|
| +TEST_P(QuicSentPacketManagerTest, GetTransmissionDelayExponentialBackoff) {
|
| SendDataPacket(1);
|
| QuicTime::Delta delay = QuicTime::Delta::FromMilliseconds(500);
|
| - EXPECT_CALL(*send_algorithm_, RetransmissionDelay())
|
| - .WillRepeatedly(Return(delay));
|
|
|
| // Delay should back off exponentially.
|
| EXPECT_CALL(*network_change_visitor_, OnPathDegrading());
|
| @@ -1343,6 +1341,40 @@ TEST_P(QuicSentPacketManagerTest, GetTransmissionDelay) {
|
| }
|
| }
|
|
|
| +TEST_F(QuicSentPacketManagerTest, RetransmissionDelay) {
|
| + RttStats* rtt_stats = const_cast<RttStats*>(manager_.GetRttStats());
|
| + const int64_t kRttMs = 250;
|
| + const int64_t kDeviationMs = 5;
|
| +
|
| + rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kRttMs),
|
| + QuicTime::Delta::Zero(), clock_.Now());
|
| +
|
| + // Initial value is to set the median deviation to half of the initial rtt,
|
| + // the median in then multiplied by a factor of 4 and finally the smoothed rtt
|
| + // is added which is the initial rtt.
|
| + QuicTime::Delta expected_delay =
|
| + QuicTime::Delta::FromMilliseconds(kRttMs + kRttMs / 2 * 4);
|
| + EXPECT_EQ(expected_delay,
|
| + QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_));
|
| +
|
| + for (int i = 0; i < 100; ++i) {
|
| + // Run to make sure that we converge.
|
| + rtt_stats->UpdateRtt(
|
| + QuicTime::Delta::FromMilliseconds(kRttMs + kDeviationMs),
|
| + QuicTime::Delta::Zero(), clock_.Now());
|
| + rtt_stats->UpdateRtt(
|
| + QuicTime::Delta::FromMilliseconds(kRttMs - kDeviationMs),
|
| + QuicTime::Delta::Zero(), clock_.Now());
|
| + }
|
| + expected_delay = QuicTime::Delta::FromMilliseconds(kRttMs + kDeviationMs * 4);
|
| +
|
| + EXPECT_NEAR(kRttMs, rtt_stats->smoothed_rtt().ToMilliseconds(), 1);
|
| + EXPECT_NEAR(expected_delay.ToMilliseconds(),
|
| + QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_)
|
| + .ToMilliseconds(),
|
| + 1);
|
| +}
|
| +
|
| TEST_P(QuicSentPacketManagerTest, GetLossDelay) {
|
| auto loss_algorithm = base::MakeUnique<MockLossAlgorithm>();
|
| QuicSentPacketManagerPeer::SetLossAlgorithm(&manager_, loss_algorithm.get());
|
|
|