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

Unified Diff: net/quic/congestion_control/tcp_cubic_sender_packets_test.cc

Issue 1811043002: Landing Recent QUIC changes until 2016-03-15 16:26 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add an export clause. Created 4 years, 9 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/congestion_control/tcp_cubic_sender_packets.cc ('k') | net/quic/crypto/aead_base_decrypter_nss.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/congestion_control/tcp_cubic_sender_packets_test.cc
diff --git a/net/quic/congestion_control/tcp_cubic_sender_packets_test.cc b/net/quic/congestion_control/tcp_cubic_sender_packets_test.cc
index 0d04e6e0fe6982fd2bf550431afdd750cd2016b7..f4a4227eabef8e2d87507d12e3d490c8a2352a8c 100644
--- a/net/quic/congestion_control/tcp_cubic_sender_packets_test.cc
+++ b/net/quic/congestion_control/tcp_cubic_sender_packets_test.cc
@@ -69,21 +69,21 @@ class TcpCubicSenderPacketsTest : public ::testing::Test {
bytes_in_flight_(0) {}
int SendAvailableSendWindow() {
+ return SendAvailableSendWindow(kDefaultTCPMSS);
+ }
+
+ int SendAvailableSendWindow(QuicPacketLength packet_length) {
// Send as long as TimeUntilSend returns Zero.
int packets_sent = 0;
- bool can_send = sender_
- ->TimeUntilSend(clock_.Now(), bytes_in_flight_,
- HAS_RETRANSMITTABLE_DATA)
- .IsZero();
+ bool can_send =
+ sender_->TimeUntilSend(clock_.Now(), bytes_in_flight_).IsZero();
while (can_send) {
sender_->OnPacketSent(clock_.Now(), bytes_in_flight_, packet_number_++,
kDefaultTCPMSS, HAS_RETRANSMITTABLE_DATA);
++packets_sent;
bytes_in_flight_ += kDefaultTCPMSS;
- can_send = sender_
- ->TimeUntilSend(clock_.Now(), bytes_in_flight_,
- HAS_RETRANSMITTABLE_DATA)
- .IsZero();
+ can_send =
+ sender_->TimeUntilSend(clock_.Now(), bytes_in_flight_).IsZero();
}
return packets_sent;
}
@@ -105,17 +105,19 @@ class TcpCubicSenderPacketsTest : public ::testing::Test {
clock_.AdvanceTime(one_ms_);
}
- void LoseNPackets(int n) {
+ void LoseNPackets(int n) { LoseNPackets(n, kDefaultTCPMSS); }
+
+ void LoseNPackets(int n, QuicPacketLength packet_length) {
SendAlgorithmInterface::CongestionVector acked_packets;
SendAlgorithmInterface::CongestionVector lost_packets;
for (int i = 0; i < n; ++i) {
++acked_packet_number_;
lost_packets.push_back(
- std::make_pair(acked_packet_number_, kDefaultTCPMSS));
+ std::make_pair(acked_packet_number_, packet_length));
}
sender_->OnCongestionEvent(false, bytes_in_flight_, acked_packets,
lost_packets);
- bytes_in_flight_ -= n * kDefaultTCPMSS;
+ bytes_in_flight_ -= n * packet_length;
}
// Does not increment acked_packet_number_.
@@ -140,31 +142,26 @@ TEST_F(TcpCubicSenderPacketsTest, SimpleSender) {
// At startup make sure we are at the default.
EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow());
// At startup make sure we can send.
- EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA)
- .IsZero());
+ EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0).IsZero());
// Make sure we can send.
- EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA)
- .IsZero());
+ EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0).IsZero());
// And that window is un-affected.
EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow());
// Fill the send window with data, then verify that we can't send.
SendAvailableSendWindow();
- EXPECT_FALSE(sender_
- ->TimeUntilSend(clock_.Now(), sender_->GetCongestionWindow(),
- HAS_RETRANSMITTABLE_DATA)
- .IsZero());
+ EXPECT_FALSE(
+ sender_->TimeUntilSend(clock_.Now(), sender_->GetCongestionWindow())
+ .IsZero());
}
TEST_F(TcpCubicSenderPacketsTest, ApplicationLimitedSlowStart) {
// Send exactly 10 packets and ensure the CWND ends at 14 packets.
const int kNumberOfAcks = 5;
// At startup make sure we can send.
- EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA)
- .IsZero());
+ EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0).IsZero());
// Make sure we can send.
- EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA)
- .IsZero());
+ EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0).IsZero());
SendAvailableSendWindow();
for (int i = 0; i < kNumberOfAcks; ++i) {
@@ -179,12 +176,10 @@ TEST_F(TcpCubicSenderPacketsTest, ApplicationLimitedSlowStart) {
TEST_F(TcpCubicSenderPacketsTest, ExponentialSlowStart) {
const int kNumberOfAcks = 20;
// At startup make sure we can send.
- EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA)
- .IsZero());
+ EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0).IsZero());
EXPECT_EQ(QuicBandwidth::Zero(), sender_->BandwidthEstimate());
// Make sure we can send.
- EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA)
- .IsZero());
+ EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0).IsZero());
for (int i = 0; i < kNumberOfAcks; ++i) {
// Send our full send window.
@@ -300,6 +295,39 @@ TEST_F(TcpCubicSenderPacketsTest, SlowStartPacketLossWithLargeReduction) {
EXPECT_FALSE(sender_->hybrid_slow_start().started());
}
+TEST_F(TcpCubicSenderPacketsTest, SlowStartHalfPacketLossWithLargeReduction) {
+ FLAGS_quic_sslr_byte_conservation = true;
+ QuicConfig config;
+ QuicTagVector options;
+ options.push_back(kSSLR);
+ QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
+ sender_->SetFromConfig(config, Perspective::IS_SERVER);
+
+ sender_->SetNumEmulatedConnections(1);
+ const int kNumberOfAcks = 10;
+ for (int i = 0; i < kNumberOfAcks; ++i) {
+ // Send our full send window in half sized packets.
+ SendAvailableSendWindow(kDefaultTCPMSS / 2);
+ AckNPackets(2);
+ }
+ SendAvailableSendWindow(kDefaultTCPMSS / 2);
+ QuicByteCount expected_send_window =
+ kDefaultWindowTCP + (kDefaultTCPMSS * 2 * kNumberOfAcks);
+ EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
+
+ // Lose a packet to exit slow start. We should now have fallen out of
+ // slow start with a window reduced by 1.
+ LoseNPackets(1);
+ expected_send_window -= kDefaultTCPMSS;
+ EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
+
+ // Lose 10 packets in recovery and verify that congestion window is reduced
+ // by 5 packets.
+ LoseNPackets(10, kDefaultTCPMSS / 2);
+ expected_send_window -= 5 * kDefaultTCPMSS;
+ EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
+}
+
TEST_F(TcpCubicSenderPacketsTest, NoPRRWhenLessThanOnePacketInFlight) {
SendAvailableSendWindow();
LoseNPackets(kInitialCongestionWindowPackets - 1);
@@ -309,8 +337,7 @@ TEST_F(TcpCubicSenderPacketsTest, NoPRRWhenLessThanOnePacketInFlight) {
// Simulate abandoning all packets by supplying a bytes_in_flight of 0.
// PRR should now allow a packet to be sent, even though prr's state
// variables believe it has sent enough packets.
- EXPECT_EQ(QuicTime::Delta::Zero(),
- sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA));
+ EXPECT_EQ(QuicTime::Delta::Zero(), sender_->TimeUntilSend(clock_.Now(), 0));
}
TEST_F(TcpCubicSenderPacketsTest, SlowStartPacketLossPRR) {
@@ -387,10 +414,7 @@ TEST_F(TcpCubicSenderPacketsTest, SlowStartBurstPacketLossPRR) {
LoseNPackets(num_packets_to_lose);
// Immediately after the loss, ensure at least one packet can be sent.
// Losses without subsequent acks can occur with timer based loss detection.
- EXPECT_TRUE(sender_
- ->TimeUntilSend(clock_.Now(), bytes_in_flight_,
- HAS_RETRANSMITTABLE_DATA)
- .IsZero());
+ EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), bytes_in_flight_).IsZero());
AckNPackets(1);
// We should now have fallen out of slow start with a reduced window.
@@ -844,22 +868,14 @@ TEST_F(TcpCubicSenderPacketsTest, PaceBelowCWND) {
sender_->SetFromConfig(config, Perspective::IS_SERVER);
sender_->OnRetransmissionTimeout(true);
EXPECT_EQ(1u, sender_->congestion_window());
- EXPECT_TRUE(sender_
- ->TimeUntilSend(QuicTime::Zero(), kDefaultTCPMSS,
- HAS_RETRANSMITTABLE_DATA)
- .IsZero());
- EXPECT_TRUE(sender_
- ->TimeUntilSend(QuicTime::Zero(), 2 * kDefaultTCPMSS,
- HAS_RETRANSMITTABLE_DATA)
- .IsZero());
- EXPECT_TRUE(sender_
- ->TimeUntilSend(QuicTime::Zero(), 3 * kDefaultTCPMSS,
- HAS_RETRANSMITTABLE_DATA)
- .IsZero());
- EXPECT_FALSE(sender_
- ->TimeUntilSend(QuicTime::Zero(), 4 * kDefaultTCPMSS,
- HAS_RETRANSMITTABLE_DATA)
- .IsZero());
+ EXPECT_TRUE(
+ sender_->TimeUntilSend(QuicTime::Zero(), kDefaultTCPMSS).IsZero());
+ EXPECT_TRUE(
+ sender_->TimeUntilSend(QuicTime::Zero(), 2 * kDefaultTCPMSS).IsZero());
+ EXPECT_TRUE(
+ sender_->TimeUntilSend(QuicTime::Zero(), 3 * kDefaultTCPMSS).IsZero());
+ EXPECT_FALSE(
+ sender_->TimeUntilSend(QuicTime::Zero(), 4 * kDefaultTCPMSS).IsZero());
}
TEST_F(TcpCubicSenderPacketsTest, ResetAfterConnectionMigration) {
« no previous file with comments | « net/quic/congestion_control/tcp_cubic_sender_packets.cc ('k') | net/quic/crypto/aead_base_decrypter_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698