Index: net/quic/congestion_control/tcp_cubic_bytes_sender_test.cc |
diff --git a/net/quic/congestion_control/tcp_cubic_sender_test.cc b/net/quic/congestion_control/tcp_cubic_bytes_sender_test.cc |
similarity index 78% |
copy from net/quic/congestion_control/tcp_cubic_sender_test.cc |
copy to net/quic/congestion_control/tcp_cubic_bytes_sender_test.cc |
index 1baffb0bcdbd0333f843795656c71325a626ffc8..3f442ce9009f98a3cd1ed693e26d8292fec3390b 100644 |
--- a/net/quic/congestion_control/tcp_cubic_sender_test.cc |
+++ b/net/quic/congestion_control/tcp_cubic_bytes_sender_test.cc |
@@ -1,13 +1,14 @@ |
-// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2015 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+#include "net/quic/congestion_control/tcp_cubic_bytes_sender.h" |
+ |
#include <algorithm> |
#include "base/logging.h" |
#include "base/memory/scoped_ptr.h" |
#include "net/quic/congestion_control/rtt_stats.h" |
-#include "net/quic/congestion_control/tcp_cubic_sender.h" |
#include "net/quic/crypto/crypto_protocol.h" |
#include "net/quic/quic_protocol.h" |
#include "net/quic/quic_utils.h" |
@@ -15,8 +16,6 @@ |
#include "net/quic/test_tools/quic_config_peer.h" |
#include "testing/gtest/include/gtest/gtest.h" |
-using std::min; |
- |
namespace net { |
namespace test { |
@@ -28,40 +27,30 @@ const uint32 kDefaultWindowTCP = |
kInitialCongestionWindowPackets * kDefaultTCPMSS; |
const float kRenoBeta = 0.7f; // Reno backoff factor. |
-class TcpCubicSenderPeer : public TcpCubicSender { |
+class TcpCubicBytesSenderPeer : public TcpCubicBytesSender { |
public: |
- TcpCubicSenderPeer(const QuicClock* clock, bool reno) |
- : TcpCubicSender(clock, |
- &rtt_stats_, |
- reno, |
- kInitialCongestionWindowPackets, |
- &stats_) {} |
- |
- QuicPacketCount congestion_window() { |
- return congestion_window_; |
- } |
- |
- QuicPacketCount slowstart_threshold() { |
- return slowstart_threshold_; |
- } |
+ TcpCubicBytesSenderPeer(const QuicClock* clock, bool reno) |
+ : TcpCubicBytesSender(clock, |
+ &rtt_stats_, |
+ reno, |
+ kInitialCongestionWindowPackets, |
+ &stats_) {} |
const HybridSlowStart& hybrid_slow_start() const { |
return hybrid_slow_start_; |
} |
- float GetRenoBeta() const { |
- return RenoBeta(); |
- } |
+ float GetRenoBeta() const { return RenoBeta(); } |
RttStats rtt_stats_; |
QuicConnectionStats stats_; |
}; |
-class TcpCubicSenderTest : public ::testing::Test { |
+class TcpCubicBytesSenderTest : public ::testing::Test { |
protected: |
- TcpCubicSenderTest() |
+ TcpCubicBytesSenderTest() |
: one_ms_(QuicTime::Delta::FromMilliseconds(1)), |
- sender_(new TcpCubicSenderPeer(&clock_, true)), |
+ sender_(new TcpCubicBytesSenderPeer(&clock_, true)), |
sequence_number_(1), |
acked_sequence_number_(0), |
bytes_in_flight_(0) { |
@@ -71,15 +60,15 @@ class TcpCubicSenderTest : public ::testing::Test { |
int SendAvailableSendWindow() { |
// 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_, |
+ HAS_RETRANSMITTABLE_DATA).IsZero(); |
while (can_send) { |
sender_->OnPacketSent(clock_.Now(), bytes_in_flight_, sequence_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_, |
+ HAS_RETRANSMITTABLE_DATA).IsZero(); |
} |
return packets_sent; |
} |
@@ -87,8 +76,7 @@ class TcpCubicSenderTest : public ::testing::Test { |
// Normal is that TCP acks every other segment. |
void AckNPackets(int n) { |
sender_->rtt_stats_.UpdateRtt(QuicTime::Delta::FromMilliseconds(60), |
- QuicTime::Delta::Zero(), |
- clock_.Now()); |
+ QuicTime::Delta::Zero(), clock_.Now()); |
SendAlgorithmInterface::CongestionVector acked_packets; |
SendAlgorithmInterface::CongestionVector lost_packets; |
for (int i = 0; i < n; ++i) { |
@@ -96,8 +84,8 @@ class TcpCubicSenderTest : public ::testing::Test { |
acked_packets.push_back( |
std::make_pair(acked_sequence_number_, standard_packet_)); |
} |
- sender_->OnCongestionEvent( |
- true, bytes_in_flight_, acked_packets, lost_packets); |
+ sender_->OnCongestionEvent(true, bytes_in_flight_, acked_packets, |
+ lost_packets); |
bytes_in_flight_ -= n * kDefaultTCPMSS; |
clock_.AdvanceTime(one_ms_); |
} |
@@ -110,8 +98,8 @@ class TcpCubicSenderTest : public ::testing::Test { |
lost_packets.push_back( |
std::make_pair(acked_sequence_number_, standard_packet_)); |
} |
- sender_->OnCongestionEvent( |
- false, bytes_in_flight_, acked_packets, lost_packets); |
+ sender_->OnCongestionEvent(false, bytes_in_flight_, acked_packets, |
+ lost_packets); |
bytes_in_flight_ -= n * kDefaultTCPMSS; |
} |
@@ -120,31 +108,29 @@ class TcpCubicSenderTest : public ::testing::Test { |
SendAlgorithmInterface::CongestionVector acked_packets; |
SendAlgorithmInterface::CongestionVector lost_packets; |
lost_packets.push_back(std::make_pair(sequence_number, standard_packet_)); |
- sender_->OnCongestionEvent( |
- false, bytes_in_flight_, acked_packets, lost_packets); |
+ sender_->OnCongestionEvent(false, bytes_in_flight_, acked_packets, |
+ lost_packets); |
bytes_in_flight_ -= kDefaultTCPMSS; |
} |
const QuicTime::Delta one_ms_; |
MockClock clock_; |
- scoped_ptr<TcpCubicSenderPeer> sender_; |
+ scoped_ptr<TcpCubicBytesSenderPeer> sender_; |
QuicPacketSequenceNumber sequence_number_; |
QuicPacketSequenceNumber acked_sequence_number_; |
QuicByteCount bytes_in_flight_; |
TransmissionInfo standard_packet_; |
}; |
-TEST_F(TcpCubicSenderTest, SimpleSender) { |
+TEST_F(TcpCubicBytesSenderTest, 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, HAS_RETRANSMITTABLE_DATA) |
+ .IsZero()); |
// Make sure we can send. |
- EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), |
- 0, |
- HAS_RETRANSMITTABLE_DATA).IsZero()); |
+ EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) |
+ .IsZero()); |
// And that window is un-affected. |
EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); |
@@ -155,17 +141,15 @@ TEST_F(TcpCubicSenderTest, SimpleSender) { |
HAS_RETRANSMITTABLE_DATA).IsZero()); |
} |
-TEST_F(TcpCubicSenderTest, ApplicationLimitedSlowStart) { |
+TEST_F(TcpCubicBytesSenderTest, 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, HAS_RETRANSMITTABLE_DATA) |
+ .IsZero()); |
// Make sure we can send. |
- EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), |
- 0, |
- HAS_RETRANSMITTABLE_DATA).IsZero()); |
+ EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) |
+ .IsZero()); |
SendAvailableSendWindow(); |
for (int i = 0; i < kNumberOfAcks; ++i) { |
@@ -174,22 +158,19 @@ TEST_F(TcpCubicSenderTest, ApplicationLimitedSlowStart) { |
QuicByteCount bytes_to_send = sender_->GetCongestionWindow(); |
// It's expected 2 acks will arrive when the bytes_in_flight are greater than |
// half the CWND. |
- EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * 2, |
- bytes_to_send); |
+ EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * 2, bytes_to_send); |
} |
-TEST_F(TcpCubicSenderTest, ExponentialSlowStart) { |
+TEST_F(TcpCubicBytesSenderTest, 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, HAS_RETRANSMITTABLE_DATA) |
+ .IsZero()); |
EXPECT_FALSE(sender_->HasReliableBandwidthEstimate()); |
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, HAS_RETRANSMITTABLE_DATA) |
+ .IsZero()); |
for (int i = 0; i < kNumberOfAcks; ++i) { |
// Send our full send window. |
@@ -204,14 +185,14 @@ TEST_F(TcpCubicSenderTest, ExponentialSlowStart) { |
sender_->BandwidthEstimate()); |
} |
-TEST_F(TcpCubicSenderTest, SlowStartAckTrain) { |
+TEST_F(TcpCubicBytesSenderTest, SlowStartAckTrain) { |
sender_->SetNumEmulatedConnections(1); |
// Make sure that we fall out of slow start when we send ACK train longer |
// than half the RTT, in this test case 30ms, which is more than 30 calls to |
// Ack2Packets in one round. |
// Since we start at 10 packet first round will be 5 second round 10 etc |
- // Hence we should pass 30 at 65 = 5 + 10 + 20 + 30 |
+ // Hence we should pass 30 at 65 = 5 + 10 + 20 + 30. |
const int kNumberOfAcks = 65; |
for (int i = 0; i < kNumberOfAcks; ++i) { |
// Send our full send window. |
@@ -237,18 +218,16 @@ TEST_F(TcpCubicSenderTest, SlowStartAckTrain) { |
expected_send_window += kDefaultTCPMSS; |
EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
EXPECT_EQ(expected_ss_tresh, sender_->GetSlowStartThreshold()); |
- EXPECT_EQ(140u, sender_->slowstart_threshold()); |
// Now RTO and ensure slow start gets reset. |
EXPECT_TRUE(sender_->hybrid_slow_start().started()); |
sender_->OnRetransmissionTimeout(true); |
EXPECT_FALSE(sender_->hybrid_slow_start().started()); |
EXPECT_EQ(2 * kDefaultTCPMSS, sender_->GetCongestionWindow()); |
- EXPECT_EQ(expected_send_window / 2 / kDefaultTCPMSS, |
- sender_->slowstart_threshold()); |
+ EXPECT_EQ(expected_send_window / 2, sender_->GetSlowStartThreshold()); |
} |
-TEST_F(TcpCubicSenderTest, SlowStartPacketLoss) { |
+TEST_F(TcpCubicBytesSenderTest, SlowStartPacketLoss) { |
sender_->SetNumEmulatedConnections(1); |
const int kNumberOfAcks = 10; |
for (int i = 0; i < kNumberOfAcks; ++i) { |
@@ -257,8 +236,8 @@ TEST_F(TcpCubicSenderTest, SlowStartPacketLoss) { |
AckNPackets(2); |
} |
SendAvailableSendWindow(); |
- QuicByteCount expected_send_window = kDefaultWindowTCP + |
- (kDefaultTCPMSS * 2 * kNumberOfAcks); |
+ QuicByteCount expected_send_window = |
+ kDefaultWindowTCP + (kDefaultTCPMSS * 2 * kNumberOfAcks); |
EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
// Lose a packet to exit slow start. |
@@ -293,20 +272,20 @@ TEST_F(TcpCubicSenderTest, SlowStartPacketLoss) { |
EXPECT_FALSE(sender_->hybrid_slow_start().started()); |
} |
-TEST_F(TcpCubicSenderTest, NoPRRWhenLessThanOnePacketInFlight) { |
+TEST_F(TcpCubicBytesSenderTest, NoPRRWhenLessThanOnePacketInFlight) { |
SendAvailableSendWindow(); |
LoseNPackets(kInitialCongestionWindowPackets - 1); |
AckNPackets(1); |
// PRR will allow 2 packets for every ack during recovery. |
EXPECT_EQ(2, SendAvailableSendWindow()); |
// 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. |
+ // 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)); |
} |
-TEST_F(TcpCubicSenderTest, SlowStartPacketLossPRR) { |
+TEST_F(TcpCubicBytesSenderTest, SlowStartPacketLossPRR) { |
sender_->SetNumEmulatedConnections(1); |
// Test based on the first example in RFC6937. |
// Ack 10 packets in 5 acks to raise the CWND to 20, as in the example. |
@@ -317,8 +296,8 @@ TEST_F(TcpCubicSenderTest, SlowStartPacketLossPRR) { |
AckNPackets(2); |
} |
SendAvailableSendWindow(); |
- QuicByteCount expected_send_window = kDefaultWindowTCP + |
- (kDefaultTCPMSS * 2 * kNumberOfAcks); |
+ QuicByteCount expected_send_window = |
+ kDefaultWindowTCP + (kDefaultTCPMSS * 2 * kNumberOfAcks); |
EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
LoseNPackets(1); |
@@ -355,7 +334,7 @@ TEST_F(TcpCubicSenderTest, SlowStartPacketLossPRR) { |
EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
} |
-TEST_F(TcpCubicSenderTest, SlowStartBurstPacketLossPRR) { |
+TEST_F(TcpCubicBytesSenderTest, SlowStartBurstPacketLossPRR) { |
sender_->SetNumEmulatedConnections(1); |
// Test based on the second example in RFC6937, though we also implement |
// forward acknowledgements, so the first two incoming acks will trigger |
@@ -368,8 +347,8 @@ TEST_F(TcpCubicSenderTest, SlowStartBurstPacketLossPRR) { |
AckNPackets(2); |
} |
SendAvailableSendWindow(); |
- QuicByteCount expected_send_window = kDefaultWindowTCP + |
- (kDefaultTCPMSS * 2 * kNumberOfAcks); |
+ QuicByteCount expected_send_window = |
+ kDefaultWindowTCP + (kDefaultTCPMSS * 2 * kNumberOfAcks); |
EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
// Lose one more than the congestion window reduction, so that after loss, |
@@ -380,15 +359,15 @@ TEST_F(TcpCubicSenderTest, 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_, |
+ HAS_RETRANSMITTABLE_DATA).IsZero()); |
AckNPackets(1); |
// We should now have fallen out of slow start with a reduced window. |
expected_send_window *= kRenoBeta; |
EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
- // Only 2 packets should be allowed to be sent, per PRR-SSRB |
+ // Only 2 packets should be allowed to be sent, per PRR-SSRB. |
EXPECT_EQ(2, SendAvailableSendWindow()); |
// Ack the next packet, which triggers another loss. |
@@ -412,25 +391,25 @@ TEST_F(TcpCubicSenderTest, SlowStartBurstPacketLossPRR) { |
} |
} |
-TEST_F(TcpCubicSenderTest, RTOCongestionWindow) { |
+TEST_F(TcpCubicBytesSenderTest, RTOCongestionWindow) { |
EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); |
- // Expect the window to decrease to the minimum once the RTO fires |
- // and slow start threshold to be set to 1/2 of the CWND. |
+ // Expect the window to decrease to the minimum once the RTO fires and slow |
+ // start threshold to be set to 1/2 of the CWND. |
sender_->OnRetransmissionTimeout(true); |
EXPECT_EQ(2 * kDefaultTCPMSS, sender_->GetCongestionWindow()); |
- EXPECT_EQ(5u, sender_->slowstart_threshold()); |
+ EXPECT_EQ(5u * kDefaultTCPMSS, sender_->GetSlowStartThreshold()); |
} |
-TEST_F(TcpCubicSenderTest, RTOCongestionWindowNoRetransmission) { |
+TEST_F(TcpCubicBytesSenderTest, RTOCongestionWindowNoRetransmission) { |
EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); |
- // Expect the window to remain unchanged if the RTO fires but no |
- // packets are retransmitted. |
+ // Expect the window to remain unchanged if the RTO fires but no packets are |
+ // retransmitted. |
sender_->OnRetransmissionTimeout(false); |
EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); |
} |
-TEST_F(TcpCubicSenderTest, RetransmissionDelay) { |
+TEST_F(TcpCubicBytesSenderTest, RetransmissionDelay) { |
const int64 kRttMs = 10; |
const int64 kDeviationMs = 3; |
EXPECT_EQ(QuicTime::Delta::Zero(), sender_->RetransmissionDelay()); |
@@ -438,9 +417,9 @@ TEST_F(TcpCubicSenderTest, RetransmissionDelay) { |
sender_->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. |
+ // 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, sender_->RetransmissionDelay()); |
@@ -458,15 +437,14 @@ TEST_F(TcpCubicSenderTest, RetransmissionDelay) { |
EXPECT_NEAR(kRttMs, sender_->rtt_stats_.smoothed_rtt().ToMilliseconds(), 1); |
EXPECT_NEAR(expected_delay.ToMilliseconds(), |
- sender_->RetransmissionDelay().ToMilliseconds(), |
- 1); |
- EXPECT_EQ(static_cast<int64>( |
- sender_->GetCongestionWindow() * kNumMicrosPerSecond / |
- sender_->rtt_stats_.smoothed_rtt().ToMicroseconds()), |
- sender_->BandwidthEstimate().ToBytesPerSecond()); |
+ sender_->RetransmissionDelay().ToMilliseconds(), 1); |
+ EXPECT_EQ( |
+ static_cast<int64>(sender_->GetCongestionWindow() * kNumMicrosPerSecond / |
+ sender_->rtt_stats_.smoothed_rtt().ToMicroseconds()), |
+ sender_->BandwidthEstimate().ToBytesPerSecond()); |
} |
-TEST_F(TcpCubicSenderTest, MultipleLossesInOneWindow) { |
+TEST_F(TcpCubicBytesSenderTest, MultipleLossesInOneWindow) { |
SendAvailableSendWindow(); |
const QuicByteCount initial_window = sender_->GetCongestionWindow(); |
LosePacket(acked_sequence_number_ + 1); |
@@ -482,7 +460,7 @@ TEST_F(TcpCubicSenderTest, MultipleLossesInOneWindow) { |
EXPECT_GT(post_loss_window, sender_->GetCongestionWindow()); |
} |
-TEST_F(TcpCubicSenderTest, DontTrackAckPackets) { |
+TEST_F(TcpCubicBytesSenderTest, DontTrackAckPackets) { |
// Send a packet with no retransmittable data, and ensure it's not tracked. |
EXPECT_FALSE(sender_->OnPacketSent(clock_.Now(), bytes_in_flight_, |
sequence_number_++, kDefaultTCPMSS, |
@@ -494,28 +472,30 @@ TEST_F(TcpCubicSenderTest, DontTrackAckPackets) { |
HAS_RETRANSMITTABLE_DATA)); |
} |
-TEST_F(TcpCubicSenderTest, ConfigureMaxInitialWindow) { |
+TEST_F(TcpCubicBytesSenderTest, ConfigureMaxInitialWindow) { |
QuicConfig config; |
// Verify that kCOPT: kIW10 forces the congestion window to the default of 10. |
QuicTagVector options; |
options.push_back(kIW10); |
QuicConfigPeer::SetReceivedConnectionOptions(&config, options); |
- sender_->SetFromConfig(config, Perspective::IS_SERVER, |
+ sender_->SetFromConfig(config, |
+ /* is_server= */ Perspective::IS_SERVER, |
/* using_pacing= */ false); |
- EXPECT_EQ(10u, sender_->congestion_window()); |
+ EXPECT_EQ(10u * kDefaultTCPMSS, sender_->GetCongestionWindow()); |
} |
-TEST_F(TcpCubicSenderTest, DisableAckTrainDetectionWithPacing) { |
+TEST_F(TcpCubicBytesSenderTest, DisableAckTrainDetectionWithPacing) { |
EXPECT_TRUE(sender_->hybrid_slow_start().ack_train_detection()); |
QuicConfig config; |
- sender_->SetFromConfig(config, Perspective::IS_SERVER, |
+ sender_->SetFromConfig(config, |
+ /* is_server= */ Perspective::IS_SERVER, |
/* using_pacing= */ true); |
EXPECT_FALSE(sender_->hybrid_slow_start().ack_train_detection()); |
} |
-TEST_F(TcpCubicSenderTest, 2ConnectionCongestionAvoidanceAtEndOfRecovery) { |
+TEST_F(TcpCubicBytesSenderTest, 2ConnectionCongestionAvoidanceAtEndOfRecovery) { |
sender_->SetNumEmulatedConnections(2); |
// Ack 10 packets in 5 acks to raise the CWND to 20. |
const int kNumberOfAcks = 5; |
@@ -525,8 +505,8 @@ TEST_F(TcpCubicSenderTest, 2ConnectionCongestionAvoidanceAtEndOfRecovery) { |
AckNPackets(2); |
} |
SendAvailableSendWindow(); |
- QuicByteCount expected_send_window = kDefaultWindowTCP + |
- (kDefaultTCPMSS * 2 * kNumberOfAcks); |
+ QuicByteCount expected_send_window = |
+ kDefaultWindowTCP + (kDefaultTCPMSS * 2 * kNumberOfAcks); |
EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
LoseNPackets(1); |
@@ -571,7 +551,7 @@ TEST_F(TcpCubicSenderTest, 2ConnectionCongestionAvoidanceAtEndOfRecovery) { |
EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
} |
-TEST_F(TcpCubicSenderTest, 1ConnectionCongestionAvoidanceAtEndOfRecovery) { |
+TEST_F(TcpCubicBytesSenderTest, 1ConnectionCongestionAvoidanceAtEndOfRecovery) { |
sender_->SetNumEmulatedConnections(1); |
// Ack 10 packets in 5 acks to raise the CWND to 20. |
const int kNumberOfAcks = 5; |
@@ -581,8 +561,8 @@ TEST_F(TcpCubicSenderTest, 1ConnectionCongestionAvoidanceAtEndOfRecovery) { |
AckNPackets(2); |
} |
SendAvailableSendWindow(); |
- QuicByteCount expected_send_window = kDefaultWindowTCP + |
- (kDefaultTCPMSS * 2 * kNumberOfAcks); |
+ QuicByteCount expected_send_window = |
+ kDefaultWindowTCP + (kDefaultTCPMSS * 2 * kNumberOfAcks); |
EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
LoseNPackets(1); |
@@ -617,7 +597,7 @@ TEST_F(TcpCubicSenderTest, 1ConnectionCongestionAvoidanceAtEndOfRecovery) { |
EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
} |
-TEST_F(TcpCubicSenderTest, BandwidthResumption) { |
+TEST_F(TcpCubicBytesSenderTest, BandwidthResumption) { |
// Test that when provided with CachedNetworkParameters and opted in to the |
// bandwidth resumption experiment, that the TcpCubicSender sets initial CWND |
// appropriately. |
@@ -626,7 +606,7 @@ TEST_F(TcpCubicSenderTest, BandwidthResumption) { |
CachedNetworkParameters cached_network_params; |
const QuicPacketCount kNumberOfPackets = 123; |
const int kBandwidthEstimateBytesPerSecond = |
- kNumberOfPackets * kMaxPacketSize; |
+ kNumberOfPackets * kDefaultTCPMSS; |
cached_network_params.set_bandwidth_estimate_bytes_per_second( |
kBandwidthEstimateBytesPerSecond); |
cached_network_params.set_min_rtt_ms(1000); |
@@ -635,26 +615,26 @@ TEST_F(TcpCubicSenderTest, BandwidthResumption) { |
cached_network_params.set_timestamp(clock_.WallNow().ToUNIXSeconds() - |
(kNumSecondsPerHour + 1)); |
EXPECT_FALSE(sender_->ResumeConnectionState(cached_network_params)); |
- EXPECT_EQ(10u, sender_->congestion_window()); |
+ EXPECT_EQ(10u * kDefaultTCPMSS, sender_->GetCongestionWindow()); |
// If the estimate is new enough, make sure it is used. |
cached_network_params.set_timestamp(clock_.WallNow().ToUNIXSeconds() - |
(kNumSecondsPerHour - 1)); |
EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params)); |
- EXPECT_EQ(kNumberOfPackets, sender_->congestion_window()); |
+ EXPECT_EQ(kNumberOfPackets * kDefaultTCPMSS, sender_->GetCongestionWindow()); |
// Resumed CWND is limited to be in a sensible range. |
cached_network_params.set_bandwidth_estimate_bytes_per_second( |
- (kMaxCongestionWindowForBandwidthResumption + 1) * kMaxPacketSize); |
+ (kMaxCongestionWindowForBandwidthResumption + 1) * kDefaultTCPMSS); |
EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params)); |
- EXPECT_EQ(kMaxCongestionWindowForBandwidthResumption, |
- sender_->congestion_window()); |
+ EXPECT_EQ(kMaxCongestionWindowForBandwidthResumption * kDefaultTCPMSS, |
+ sender_->GetCongestionWindow()); |
cached_network_params.set_bandwidth_estimate_bytes_per_second( |
- (kMinCongestionWindowForBandwidthResumption - 1) * kMaxPacketSize); |
+ (kMinCongestionWindowForBandwidthResumption - 1) * kDefaultTCPMSS); |
EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params)); |
- EXPECT_EQ(kMinCongestionWindowForBandwidthResumption, |
- sender_->congestion_window()); |
+ EXPECT_EQ(kMinCongestionWindowForBandwidthResumption * kDefaultTCPMSS, |
+ sender_->GetCongestionWindow()); |
} |
} // namespace test |