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

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

Issue 1037623002: QUIC - small formatting changes to keep code in sync with internal source. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Low_impact_Dispatcher_88758328
Patch Set: Created 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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_bytes_sender.h" 5 #include "net/quic/congestion_control/tcp_cubic_bytes_sender.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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 QuicPacketSequenceNumber sequence_number_; 120 QuicPacketSequenceNumber sequence_number_;
121 QuicPacketSequenceNumber acked_sequence_number_; 121 QuicPacketSequenceNumber acked_sequence_number_;
122 QuicByteCount bytes_in_flight_; 122 QuicByteCount bytes_in_flight_;
123 TransmissionInfo standard_packet_; 123 TransmissionInfo standard_packet_;
124 }; 124 };
125 125
126 TEST_F(TcpCubicBytesSenderTest, SimpleSender) { 126 TEST_F(TcpCubicBytesSenderTest, SimpleSender) {
127 // At startup make sure we are at the default. 127 // At startup make sure we are at the default.
128 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); 128 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow());
129 // At startup make sure we can send. 129 // At startup make sure we can send.
130 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) 130 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0,
131 .IsZero()); 131 HAS_RETRANSMITTABLE_DATA).IsZero());
132 // Make sure we can send. 132 // Make sure we can send.
133 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) 133 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0,
134 .IsZero()); 134 HAS_RETRANSMITTABLE_DATA).IsZero());
135 // And that window is un-affected. 135 // And that window is un-affected.
136 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); 136 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow());
137 137
138 // Fill the send window with data, then verify that we can't send. 138 // Fill the send window with data, then verify that we can't send.
139 SendAvailableSendWindow(); 139 SendAvailableSendWindow();
140 EXPECT_FALSE(sender_->TimeUntilSend(clock_.Now(), 140 EXPECT_FALSE(sender_->TimeUntilSend(clock_.Now(),
141 sender_->GetCongestionWindow(), 141 sender_->GetCongestionWindow(),
142 HAS_RETRANSMITTABLE_DATA).IsZero()); 142 HAS_RETRANSMITTABLE_DATA).IsZero());
143 } 143 }
144 144
145 TEST_F(TcpCubicBytesSenderTest, ApplicationLimitedSlowStart) { 145 TEST_F(TcpCubicBytesSenderTest, ApplicationLimitedSlowStart) {
146 // Send exactly 10 packets and ensure the CWND ends at 14 packets. 146 // Send exactly 10 packets and ensure the CWND ends at 14 packets.
147 const int kNumberOfAcks = 5; 147 const int kNumberOfAcks = 5;
148 // At startup make sure we can send. 148 // At startup make sure we can send.
149 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) 149 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0,
150 .IsZero()); 150 HAS_RETRANSMITTABLE_DATA).IsZero());
151 // Make sure we can send. 151 // Make sure we can send.
152 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) 152 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0,
153 .IsZero()); 153 HAS_RETRANSMITTABLE_DATA).IsZero());
154 154
155 SendAvailableSendWindow(); 155 SendAvailableSendWindow();
156 for (int i = 0; i < kNumberOfAcks; ++i) { 156 for (int i = 0; i < kNumberOfAcks; ++i) {
157 AckNPackets(2); 157 AckNPackets(2);
158 } 158 }
159 QuicByteCount bytes_to_send = sender_->GetCongestionWindow(); 159 QuicByteCount bytes_to_send = sender_->GetCongestionWindow();
160 // It's expected 2 acks will arrive when the bytes_in_flight are greater than 160 // It's expected 2 acks will arrive when the bytes_in_flight are greater than
161 // half the CWND. 161 // half the CWND.
162 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * 2, bytes_to_send); 162 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * 2, bytes_to_send);
163 } 163 }
164 164
165 TEST_F(TcpCubicBytesSenderTest, ExponentialSlowStart) { 165 TEST_F(TcpCubicBytesSenderTest, ExponentialSlowStart) {
166 const int kNumberOfAcks = 20; 166 const int kNumberOfAcks = 20;
167 // At startup make sure we can send. 167 // At startup make sure we can send.
168 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) 168 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0,
169 .IsZero()); 169 HAS_RETRANSMITTABLE_DATA).IsZero());
170 EXPECT_FALSE(sender_->HasReliableBandwidthEstimate()); 170 EXPECT_FALSE(sender_->HasReliableBandwidthEstimate());
171 EXPECT_EQ(QuicBandwidth::Zero(), sender_->BandwidthEstimate()); 171 EXPECT_EQ(QuicBandwidth::Zero(), sender_->BandwidthEstimate());
172 // Make sure we can send. 172 // Make sure we can send.
173 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0, HAS_RETRANSMITTABLE_DATA) 173 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 0,
174 .IsZero()); 174 HAS_RETRANSMITTABLE_DATA).IsZero());
175 175
176 for (int i = 0; i < kNumberOfAcks; ++i) { 176 for (int i = 0; i < kNumberOfAcks; ++i) {
177 // Send our full send window. 177 // Send our full send window.
178 SendAvailableSendWindow(); 178 SendAvailableSendWindow();
179 AckNPackets(2); 179 AckNPackets(2);
180 } 180 }
181 const QuicByteCount cwnd = sender_->GetCongestionWindow(); 181 const QuicByteCount cwnd = sender_->GetCongestionWindow();
182 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * kNumberOfAcks, cwnd); 182 EXPECT_EQ(kDefaultWindowTCP + kDefaultTCPMSS * 2 * kNumberOfAcks, cwnd);
183 EXPECT_FALSE(sender_->HasReliableBandwidthEstimate()); 183 EXPECT_FALSE(sender_->HasReliableBandwidthEstimate());
184 EXPECT_EQ(QuicBandwidth::FromBytesAndTimeDelta( 184 EXPECT_EQ(QuicBandwidth::FromBytesAndTimeDelta(
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 HAS_RETRANSMITTABLE_DATA)); 473 HAS_RETRANSMITTABLE_DATA));
474 } 474 }
475 475
476 TEST_F(TcpCubicBytesSenderTest, ConfigureMaxInitialWindow) { 476 TEST_F(TcpCubicBytesSenderTest, ConfigureMaxInitialWindow) {
477 QuicConfig config; 477 QuicConfig config;
478 478
479 // Verify that kCOPT: kIW10 forces the congestion window to the default of 10. 479 // Verify that kCOPT: kIW10 forces the congestion window to the default of 10.
480 QuicTagVector options; 480 QuicTagVector options;
481 options.push_back(kIW10); 481 options.push_back(kIW10);
482 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); 482 QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
483 sender_->SetFromConfig(config, 483 sender_->SetFromConfig(config, Perspective::IS_SERVER,
484 /* is_server= */ Perspective::IS_SERVER,
485 /* using_pacing= */ false); 484 /* using_pacing= */ false);
486 EXPECT_EQ(10u * kDefaultTCPMSS, sender_->GetCongestionWindow()); 485 EXPECT_EQ(10u * kDefaultTCPMSS, sender_->GetCongestionWindow());
487 } 486 }
488 487
489 TEST_F(TcpCubicBytesSenderTest, DisableAckTrainDetectionWithPacing) { 488 TEST_F(TcpCubicBytesSenderTest, DisableAckTrainDetectionWithPacing) {
490 EXPECT_TRUE(sender_->hybrid_slow_start().ack_train_detection()); 489 EXPECT_TRUE(sender_->hybrid_slow_start().ack_train_detection());
491 490
492 QuicConfig config; 491 QuicConfig config;
493 sender_->SetFromConfig(config, 492 sender_->SetFromConfig(config, Perspective::IS_SERVER,
494 /* is_server= */ Perspective::IS_SERVER,
495 /* using_pacing= */ true); 493 /* using_pacing= */ true);
496 EXPECT_FALSE(sender_->hybrid_slow_start().ack_train_detection()); 494 EXPECT_FALSE(sender_->hybrid_slow_start().ack_train_detection());
497 } 495 }
498 496
499 TEST_F(TcpCubicBytesSenderTest, 2ConnectionCongestionAvoidanceAtEndOfRecovery) { 497 TEST_F(TcpCubicBytesSenderTest, 2ConnectionCongestionAvoidanceAtEndOfRecovery) {
500 sender_->SetNumEmulatedConnections(2); 498 sender_->SetNumEmulatedConnections(2);
501 // Ack 10 packets in 5 acks to raise the CWND to 20. 499 // Ack 10 packets in 5 acks to raise the CWND to 20.
502 const int kNumberOfAcks = 5; 500 const int kNumberOfAcks = 5;
503 for (int i = 0; i < kNumberOfAcks; ++i) { 501 for (int i = 0; i < kNumberOfAcks; ++i) {
504 // Send our full send window. 502 // Send our full send window.
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 631
634 cached_network_params.set_bandwidth_estimate_bytes_per_second( 632 cached_network_params.set_bandwidth_estimate_bytes_per_second(
635 (kMinCongestionWindowForBandwidthResumption - 1) * kDefaultTCPMSS); 633 (kMinCongestionWindowForBandwidthResumption - 1) * kDefaultTCPMSS);
636 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params)); 634 EXPECT_TRUE(sender_->ResumeConnectionState(cached_network_params));
637 EXPECT_EQ(kMinCongestionWindowForBandwidthResumption * kDefaultTCPMSS, 635 EXPECT_EQ(kMinCongestionWindowForBandwidthResumption * kDefaultTCPMSS,
638 sender_->GetCongestionWindow()); 636 sender_->GetCongestionWindow());
639 } 637 }
640 638
641 } // namespace test 639 } // namespace test
642 } // namespace net 640 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698