Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(517)

Unified Diff: net/quic/core/quic_sent_packet_manager_test.cc

Issue 2391103003: Landing Recent QUIC changes until 3:24 PM, Oct 01, 2016 UTC-4 (Closed)
Patch Set: Add new error code to quic_error_mapping.cc Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/core/quic_sent_packet_manager.cc ('k') | net/quic/core/quic_spdy_stream.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8f531c32fed80217368602d722f760647958ff37..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);
@@ -1165,6 +1160,48 @@ TEST_P(QuicSentPacketManagerTest, GetTransmissionTimeCryptoHandshake) {
EXPECT_EQ(expected_time, manager_.GetRetransmissionTime());
}
+TEST_P(QuicSentPacketManagerTest,
+ GetConservativeTransmissionTimeCryptoHandshake) {
+ FLAGS_quic_conservative_handshake_retransmits = true;
+ QuicConfig config;
+ QuicTagVector options;
+ options.push_back(kCONH);
+ QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
+ EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
+ EXPECT_CALL(*network_change_visitor_, OnCongestionChange());
+ manager_.SetFromConfig(config);
+ // Calling SetFromConfig requires mocking out some send algorithm methods.
+ EXPECT_CALL(*send_algorithm_, PacingRate(_))
+ .WillRepeatedly(Return(QuicBandwidth::Zero()));
+ EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
+ .WillRepeatedly(Return(10 * kDefaultTCPMSS));
+
+ SendCryptoPacket(1);
+
+ // Check the min.
+ RttStats* rtt_stats = const_cast<RttStats*>(manager_.GetRttStats());
+ rtt_stats->set_initial_rtt_us(1 * kNumMicrosPerMilli);
+ EXPECT_EQ(clock_.Now() + QuicTime::Delta::FromMilliseconds(25),
+ manager_.GetRetransmissionTime());
+
+ // Test with a standard smoothed RTT.
+ rtt_stats->set_initial_rtt_us(100 * kNumMicrosPerMilli);
+
+ QuicTime::Delta srtt =
+ QuicTime::Delta::FromMicroseconds(rtt_stats->initial_rtt_us());
+ QuicTime expected_time = clock_.Now() + 2 * srtt;
+ EXPECT_EQ(expected_time, manager_.GetRetransmissionTime());
+
+ // Retransmit the packet by invoking the retransmission timeout.
+ clock_.AdvanceTime(2 * srtt);
+ manager_.OnRetransmissionTimeout();
+ RetransmitNextPacket(2);
+
+ // The retransmission time should now be twice as far in the future.
+ expected_time = clock_.Now() + srtt * 2 * 2;
+ EXPECT_EQ(expected_time, manager_.GetRetransmissionTime());
+}
+
TEST_P(QuicSentPacketManagerTest, GetTransmissionTimeTailLossProbe) {
QuicSentPacketManagerPeer::SetMaxTailLossProbes(&manager_, 2);
SendDataPacket(1);
@@ -1205,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());
@@ -1260,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
@@ -1277,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());
@@ -1301,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());
« no previous file with comments | « net/quic/core/quic_sent_packet_manager.cc ('k') | net/quic/core/quic_spdy_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698