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

Side by Side Diff: net/quic/congestion_control/tcp_cubic_sender_packets_test.cc

Issue 1814843002: Remove the unused has_retransmittable_data argument from QuicSendAlgorithm::TimeUntilSend. No func… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@116887287
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/congestion_control/tcp_cubic_sender_packets.h" 5 #include "net/quic/congestion_control/tcp_cubic_sender_packets.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 : one_ms_(QuicTime::Delta::FromMilliseconds(1)), 64 : one_ms_(QuicTime::Delta::FromMilliseconds(1)),
65 sender_( 65 sender_(
66 new TcpCubicSenderPacketsPeer(&clock_, true, kMaxCongestionWindow)), 66 new TcpCubicSenderPacketsPeer(&clock_, true, kMaxCongestionWindow)),
67 packet_number_(1), 67 packet_number_(1),
68 acked_packet_number_(0), 68 acked_packet_number_(0),
69 bytes_in_flight_(0) {} 69 bytes_in_flight_(0) {}
70 70
71 int SendAvailableSendWindow() { 71 int SendAvailableSendWindow() {
72 // Send as long as TimeUntilSend returns Zero. 72 // Send as long as TimeUntilSend returns Zero.
73 int packets_sent = 0; 73 int packets_sent = 0;
74 bool can_send = sender_ 74 bool can_send =
75 ->TimeUntilSend(clock_.Now(), bytes_in_flight_, 75 sender_->TimeUntilSend(clock_.Now(), bytes_in_flight_).IsZero();
76 HAS_RETRANSMITTABLE_DATA)
77 .IsZero();
78 while (can_send) { 76 while (can_send) {
79 sender_->OnPacketSent(clock_.Now(), bytes_in_flight_, packet_number_++, 77 sender_->OnPacketSent(clock_.Now(), bytes_in_flight_, packet_number_++,
80 kDefaultTCPMSS, HAS_RETRANSMITTABLE_DATA); 78 kDefaultTCPMSS, HAS_RETRANSMITTABLE_DATA);
81 ++packets_sent; 79 ++packets_sent;
82 bytes_in_flight_ += kDefaultTCPMSS; 80 bytes_in_flight_ += kDefaultTCPMSS;
83 can_send = sender_ 81 can_send =
84 ->TimeUntilSend(clock_.Now(), bytes_in_flight_, 82 sender_->TimeUntilSend(clock_.Now(), bytes_in_flight_).IsZero();
85 HAS_RETRANSMITTABLE_DATA)
86 .IsZero();
87 } 83 }
88 return packets_sent; 84 return packets_sent;
89 } 85 }
90 86
91 // Normal is that TCP acks every other segment. 87 // Normal is that TCP acks every other segment.
92 void AckNPackets(int n) { 88 void AckNPackets(int n) {
93 sender_->rtt_stats_.UpdateRtt(QuicTime::Delta::FromMilliseconds(60), 89 sender_->rtt_stats_.UpdateRtt(QuicTime::Delta::FromMilliseconds(60),
94 QuicTime::Delta::Zero(), clock_.Now()); 90 QuicTime::Delta::Zero(), clock_.Now());
95 SendAlgorithmInterface::CongestionVector acked_packets; 91 SendAlgorithmInterface::CongestionVector acked_packets;
96 SendAlgorithmInterface::CongestionVector lost_packets; 92 SendAlgorithmInterface::CongestionVector lost_packets;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 scoped_ptr<TcpCubicSenderPacketsPeer> sender_; 129 scoped_ptr<TcpCubicSenderPacketsPeer> sender_;
134 QuicPacketNumber packet_number_; 130 QuicPacketNumber packet_number_;
135 QuicPacketNumber acked_packet_number_; 131 QuicPacketNumber acked_packet_number_;
136 QuicByteCount bytes_in_flight_; 132 QuicByteCount bytes_in_flight_;
137 }; 133 };
138 134
139 TEST_F(TcpCubicSenderPacketsTest, SimpleSender) { 135 TEST_F(TcpCubicSenderPacketsTest, SimpleSender) {
140 // At startup make sure we are at the default. 136 // At startup make sure we are at the default.
141 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); 137 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow());
142 // At startup make sure we can send. 138 // At startup make sure we can send.
143 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) 139 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0).IsZero());
144 .IsZero());
145 // Make sure we can send. 140 // Make sure we can send.
146 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) 141 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0).IsZero());
147 .IsZero());
148 // And that window is un-affected. 142 // And that window is un-affected.
149 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); 143 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow());
150 144
151 // Fill the send window with data, then verify that we can't send. 145 // Fill the send window with data, then verify that we can't send.
152 SendAvailableSendWindow(); 146 SendAvailableSendWindow();
153 EXPECT_FALSE(sender_ 147 EXPECT_FALSE(
154 ->TimeUntilSend(clock_.Now(), sender_->GetCongestionWindow(), 148 sender_->TimeUntilSend(clock_.Now(), sender_->GetCongestionWindow())
155 HAS_RETRANSMITTABLE_DATA) 149 .IsZero());
156 .IsZero());
157 } 150 }
158 151
159 TEST_F(TcpCubicSenderPacketsTest, ApplicationLimitedSlowStart) { 152 TEST_F(TcpCubicSenderPacketsTest, ApplicationLimitedSlowStart) {
160 // Send exactly 10 packets and ensure the CWND ends at 14 packets. 153 // Send exactly 10 packets and ensure the CWND ends at 14 packets.
161 const int kNumberOfAcks = 5; 154 const int kNumberOfAcks = 5;
162 // At startup make sure we can send. 155 // At startup make sure we can send.
163 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) 156 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0).IsZero());
164 .IsZero());
165 // Make sure we can send. 157 // Make sure we can send.
166 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) 158 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0).IsZero());
167 .IsZero());
168 159
169 SendAvailableSendWindow(); 160 SendAvailableSendWindow();
170 for (int i = 0; i < kNumberOfAcks; ++i) { 161 for (int i = 0; i < kNumberOfAcks; ++i) {
171 AckNPackets(2); 162 AckNPackets(2);
172 } 163 }
173 QuicByteCount bytes_to_send = sender_->GetCongestionWindow(); 164 QuicByteCount bytes_to_send = sender_->GetCongestionWindow();
174 // It's expected 2 acks will arrive when the bytes_in_flight are greater than 165 // It's expected 2 acks will arrive when the bytes_in_flight are greater than
175 // half the CWND. 166 // half the CWND.
176 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * 2, bytes_to_send); 167 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * 2, bytes_to_send);
177 } 168 }
178 169
179 TEST_F(TcpCubicSenderPacketsTest, ExponentialSlowStart) { 170 TEST_F(TcpCubicSenderPacketsTest, ExponentialSlowStart) {
180 const int kNumberOfAcks = 20; 171 const int kNumberOfAcks = 20;
181 // At startup make sure we can send. 172 // At startup make sure we can send.
182 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) 173 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0).IsZero());
183 .IsZero());
184 EXPECT_EQ(QuicBandwidth::Zero(), sender_->BandwidthEstimate()); 174 EXPECT_EQ(QuicBandwidth::Zero(), sender_->BandwidthEstimate());
185 // Make sure we can send. 175 // Make sure we can send.
186 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) 176 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0).IsZero());
187 .IsZero());
188 177
189 for (int i = 0; i < kNumberOfAcks; ++i) { 178 for (int i = 0; i < kNumberOfAcks; ++i) {
190 // Send our full send window. 179 // Send our full send window.
191 SendAvailableSendWindow(); 180 SendAvailableSendWindow();
192 AckNPackets(2); 181 AckNPackets(2);
193 } 182 }
194 const QuicByteCount cwnd = sender_->GetCongestionWindow(); 183 const QuicByteCount cwnd = sender_->GetCongestionWindow();
195 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * kNumberOfAcks, cwnd); 184 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * kNumberOfAcks, cwnd);
196 EXPECT_EQ(QuicBandwidth::FromBytesAndTimeDelta( 185 EXPECT_EQ(QuicBandwidth::FromBytesAndTimeDelta(
197 cwnd, sender_->rtt_stats_.smoothed_rtt()), 186 cwnd, sender_->rtt_stats_.smoothed_rtt()),
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 291
303 TEST_F(TcpCubicSenderPacketsTest, NoPRRWhenLessThanOnePacketInFlight) { 292 TEST_F(TcpCubicSenderPacketsTest, NoPRRWhenLessThanOnePacketInFlight) {
304 SendAvailableSendWindow(); 293 SendAvailableSendWindow();
305 LoseNPackets(kInitialCongestionWindowPackets - 1); 294 LoseNPackets(kInitialCongestionWindowPackets - 1);
306 AckNPackets(1); 295 AckNPackets(1);
307 // PRR will allow 2 packets for every ack during recovery. 296 // PRR will allow 2 packets for every ack during recovery.
308 EXPECT_EQ(2, SendAvailableSendWindow()); 297 EXPECT_EQ(2, SendAvailableSendWindow());
309 // Simulate abandoning all packets by supplying a bytes_in_flight of 0. 298 // Simulate abandoning all packets by supplying a bytes_in_flight of 0.
310 // PRR should now allow a packet to be sent, even though prr's state 299 // PRR should now allow a packet to be sent, even though prr's state
311 // variables believe it has sent enough packets. 300 // variables believe it has sent enough packets.
312 EXPECT_EQ(QuicTime::Delta::Zero(), 301 EXPECT_EQ(QuicTime::Delta::Zero(), sender_->TimeUntilSend(clock_.Now(), 0));
313 sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA));
314 } 302 }
315 303
316 TEST_F(TcpCubicSenderPacketsTest, SlowStartPacketLossPRR) { 304 TEST_F(TcpCubicSenderPacketsTest, SlowStartPacketLossPRR) {
317 sender_->SetNumEmulatedConnections(1); 305 sender_->SetNumEmulatedConnections(1);
318 // Test based on the first example in RFC6937. 306 // Test based on the first example in RFC6937.
319 // Ack 10 packets in 5 acks to raise the CWND to 20, as in the example. 307 // Ack 10 packets in 5 acks to raise the CWND to 20, as in the example.
320 const int kNumberOfAcks = 5; 308 const int kNumberOfAcks = 5;
321 for (int i = 0; i < kNumberOfAcks; ++i) { 309 for (int i = 0; i < kNumberOfAcks; ++i) {
322 // Send our full send window. 310 // Send our full send window.
323 SendAvailableSendWindow(); 311 SendAvailableSendWindow();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); 368 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
381 369
382 // Lose one more than the congestion window reduction, so that after loss, 370 // Lose one more than the congestion window reduction, so that after loss,
383 // bytes_in_flight is lesser than the congestion window. 371 // bytes_in_flight is lesser than the congestion window.
384 size_t send_window_after_loss = kRenoBeta * expected_send_window; 372 size_t send_window_after_loss = kRenoBeta * expected_send_window;
385 size_t num_packets_to_lose = 373 size_t num_packets_to_lose =
386 (expected_send_window - send_window_after_loss) / kDefaultTCPMSS + 1; 374 (expected_send_window - send_window_after_loss) / kDefaultTCPMSS + 1;
387 LoseNPackets(num_packets_to_lose); 375 LoseNPackets(num_packets_to_lose);
388 // Immediately after the loss, ensure at least one packet can be sent. 376 // Immediately after the loss, ensure at least one packet can be sent.
389 // Losses without subsequent acks can occur with timer based loss detection. 377 // Losses without subsequent acks can occur with timer based loss detection.
390 EXPECT_TRUE(sender_ 378 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), bytes_in_flight_).IsZero());
391 ->TimeUntilSend(clock_.Now(), bytes_in_flight_,
392 HAS_RETRANSMITTABLE_DATA)
393 .IsZero());
394 AckNPackets(1); 379 AckNPackets(1);
395 380
396 // We should now have fallen out of slow start with a reduced window. 381 // We should now have fallen out of slow start with a reduced window.
397 expected_send_window *= kRenoBeta; 382 expected_send_window *= kRenoBeta;
398 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); 383 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
399 384
400 // Only 2 packets should be allowed to be sent, per PRR-SSRB 385 // Only 2 packets should be allowed to be sent, per PRR-SSRB
401 EXPECT_EQ(2, SendAvailableSendWindow()); 386 EXPECT_EQ(2, SendAvailableSendWindow());
402 387
403 // Ack the next packet, which triggers another loss. 388 // Ack the next packet, which triggers another loss.
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 QuicConfig config; 822 QuicConfig config;
838 823
839 // Verify that kCOPT: kMIN4 forces the min CWND to 1 packet, but allows up 824 // Verify that kCOPT: kMIN4 forces the min CWND to 1 packet, but allows up
840 // to 4 to be sent. 825 // to 4 to be sent.
841 QuicTagVector options; 826 QuicTagVector options;
842 options.push_back(kMIN4); 827 options.push_back(kMIN4);
843 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); 828 QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
844 sender_->SetFromConfig(config, Perspective::IS_SERVER); 829 sender_->SetFromConfig(config, Perspective::IS_SERVER);
845 sender_->OnRetransmissionTimeout(true); 830 sender_->OnRetransmissionTimeout(true);
846 EXPECT_EQ(1u, sender_->congestion_window()); 831 EXPECT_EQ(1u, sender_->congestion_window());
847 EXPECT_TRUE(sender_ 832 EXPECT_TRUE(
848 ->TimeUntilSend(QuicTime::Zero(), kDefaultTCPMSS, 833 sender_->TimeUntilSend(QuicTime::Zero(), kDefaultTCPMSS).IsZero());
849 HAS_RETRANSMITTABLE_DATA) 834 EXPECT_TRUE(
850 .IsZero()); 835 sender_->TimeUntilSend(QuicTime::Zero(), 2 * kDefaultTCPMSS).IsZero());
851 EXPECT_TRUE(sender_ 836 EXPECT_TRUE(
852 ->TimeUntilSend(QuicTime::Zero(), 2 * kDefaultTCPMSS, 837 sender_->TimeUntilSend(QuicTime::Zero(), 3 * kDefaultTCPMSS).IsZero());
853 HAS_RETRANSMITTABLE_DATA) 838 EXPECT_FALSE(
854 .IsZero()); 839 sender_->TimeUntilSend(QuicTime::Zero(), 4 * kDefaultTCPMSS).IsZero());
855 EXPECT_TRUE(sender_
856 ->TimeUntilSend(QuicTime::Zero(), 3 * kDefaultTCPMSS,
857 HAS_RETRANSMITTABLE_DATA)
858 .IsZero());
859 EXPECT_FALSE(sender_
860 ->TimeUntilSend(QuicTime::Zero(), 4 * kDefaultTCPMSS,
861 HAS_RETRANSMITTABLE_DATA)
862 .IsZero());
863 } 840 }
864 841
865 TEST_F(TcpCubicSenderPacketsTest, ResetAfterConnectionMigration) { 842 TEST_F(TcpCubicSenderPacketsTest, ResetAfterConnectionMigration) {
866 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); 843 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow());
867 EXPECT_EQ(kMaxCongestionWindow, sender_->slowstart_threshold()); 844 EXPECT_EQ(kMaxCongestionWindow, sender_->slowstart_threshold());
868 845
869 // Starts with slow start. 846 // Starts with slow start.
870 sender_->SetNumEmulatedConnections(1); 847 sender_->SetNumEmulatedConnections(1);
871 const int kNumberOfAcks = 10; 848 const int kNumberOfAcks = 10;
872 for (int i = 0; i < kNumberOfAcks; ++i) { 849 for (int i = 0; i < kNumberOfAcks; ++i) {
(...skipping 18 matching lines...) Expand all
891 868
892 // Resets cwnd and slow start threshold on connection migrations. 869 // Resets cwnd and slow start threshold on connection migrations.
893 sender_->OnConnectionMigration(); 870 sender_->OnConnectionMigration();
894 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); 871 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow());
895 EXPECT_EQ(kMaxCongestionWindow, sender_->slowstart_threshold()); 872 EXPECT_EQ(kMaxCongestionWindow, sender_->slowstart_threshold());
896 EXPECT_FALSE(sender_->hybrid_slow_start().started()); 873 EXPECT_FALSE(sender_->hybrid_slow_start().started());
897 } 874 }
898 875
899 } // namespace test 876 } // namespace test
900 } // namespace net 877 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/tcp_cubic_sender_bytes_test.cc ('k') | net/quic/quic_connection_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698