OLD | NEW |
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_sender_bytes.h" | 5 #include "net/quic/congestion_control/tcp_cubic_sender_bytes.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cstdint> | 8 #include <cstdint> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 expected_send_window += kDefaultTCPMSS; | 225 expected_send_window += kDefaultTCPMSS; |
226 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 226 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
227 | 227 |
228 // Now RTO and ensure slow start gets reset. | 228 // Now RTO and ensure slow start gets reset. |
229 EXPECT_TRUE(sender_->hybrid_slow_start().started()); | 229 EXPECT_TRUE(sender_->hybrid_slow_start().started()); |
230 sender_->OnRetransmissionTimeout(true); | 230 sender_->OnRetransmissionTimeout(true); |
231 EXPECT_FALSE(sender_->hybrid_slow_start().started()); | 231 EXPECT_FALSE(sender_->hybrid_slow_start().started()); |
232 } | 232 } |
233 | 233 |
234 TEST_F(TcpCubicSenderBytesTest, SlowStartPacketLossWithLargeReduction) { | 234 TEST_F(TcpCubicSenderBytesTest, SlowStartPacketLossWithLargeReduction) { |
235 FLAGS_quic_sslr_limit_reduction = true; | |
236 QuicConfig config; | 235 QuicConfig config; |
237 QuicTagVector options; | 236 QuicTagVector options; |
238 options.push_back(kSSLR); | 237 options.push_back(kSSLR); |
239 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); | 238 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); |
240 sender_->SetFromConfig(config, Perspective::IS_SERVER); | 239 sender_->SetFromConfig(config, Perspective::IS_SERVER); |
241 | 240 |
242 sender_->SetNumEmulatedConnections(1); | 241 sender_->SetNumEmulatedConnections(1); |
243 const int kNumberOfAcks = (kDefaultWindowTCP / (2 * kDefaultTCPMSS)) - 1; | 242 const int kNumberOfAcks = (kDefaultWindowTCP / (2 * kDefaultTCPMSS)) - 1; |
244 for (int i = 0; i < kNumberOfAcks; ++i) { | 243 for (int i = 0; i < kNumberOfAcks; ++i) { |
245 // Send our full send window. | 244 // Send our full send window. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 319 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
321 | 320 |
322 // Lose 10 packets in recovery and verify that congestion window is reduced | 321 // Lose 10 packets in recovery and verify that congestion window is reduced |
323 // by 5 packets. | 322 // by 5 packets. |
324 LoseNPackets(10, kDefaultTCPMSS / 2); | 323 LoseNPackets(10, kDefaultTCPMSS / 2); |
325 expected_send_window -= 5 * kDefaultTCPMSS; | 324 expected_send_window -= 5 * kDefaultTCPMSS; |
326 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 325 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
327 } | 326 } |
328 | 327 |
329 TEST_F(TcpCubicSenderBytesTest, SlowStartPacketLossWithMaxHalfReduction) { | 328 TEST_F(TcpCubicSenderBytesTest, SlowStartPacketLossWithMaxHalfReduction) { |
330 FLAGS_quic_sslr_limit_reduction = true; | |
331 QuicConfig config; | 329 QuicConfig config; |
332 QuicTagVector options; | 330 QuicTagVector options; |
333 options.push_back(kSSLR); | 331 options.push_back(kSSLR); |
334 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); | 332 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); |
335 sender_->SetFromConfig(config, Perspective::IS_SERVER); | 333 sender_->SetFromConfig(config, Perspective::IS_SERVER); |
336 | 334 |
337 sender_->SetNumEmulatedConnections(1); | 335 sender_->SetNumEmulatedConnections(1); |
338 const int kNumberOfAcks = kInitialCongestionWindowPackets / 2; | 336 const int kNumberOfAcks = kInitialCongestionWindowPackets / 2; |
339 for (int i = 0; i < kNumberOfAcks; ++i) { | 337 for (int i = 0; i < kNumberOfAcks; ++i) { |
340 // Send our full send window. | 338 // Send our full send window. |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 | 867 |
870 // Resets cwnd and slow start threshold on connection migrations. | 868 // Resets cwnd and slow start threshold on connection migrations. |
871 sender_->OnConnectionMigration(); | 869 sender_->OnConnectionMigration(); |
872 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); | 870 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); |
873 EXPECT_EQ(kMaxCongestionWindowPackets * kDefaultTCPMSS, | 871 EXPECT_EQ(kMaxCongestionWindowPackets * kDefaultTCPMSS, |
874 sender_->GetSlowStartThreshold()); | 872 sender_->GetSlowStartThreshold()); |
875 EXPECT_FALSE(sender_->hybrid_slow_start().started()); | 873 EXPECT_FALSE(sender_->hybrid_slow_start().started()); |
876 } | 874 } |
877 | 875 |
878 TEST_F(TcpCubicSenderBytesTest, DefaultMaxCwnd) { | 876 TEST_F(TcpCubicSenderBytesTest, DefaultMaxCwnd) { |
879 ValueRestore<bool> old_flag(&FLAGS_quic_ignore_srbf, true); | |
880 RttStats rtt_stats; | 877 RttStats rtt_stats; |
881 QuicConnectionStats stats; | 878 QuicConnectionStats stats; |
882 std::unique_ptr<SendAlgorithmInterface> sender(SendAlgorithmInterface::Create( | 879 std::unique_ptr<SendAlgorithmInterface> sender(SendAlgorithmInterface::Create( |
883 &clock_, &rtt_stats, kCubicBytes, &stats, kInitialCongestionWindow)); | 880 &clock_, &rtt_stats, kCubicBytes, &stats, kInitialCongestionWindow)); |
884 | 881 |
885 SendAlgorithmInterface::CongestionVector acked_packets; | 882 SendAlgorithmInterface::CongestionVector acked_packets; |
886 SendAlgorithmInterface::CongestionVector missing_packets; | 883 SendAlgorithmInterface::CongestionVector missing_packets; |
887 for (uint64_t i = 1; i < kDefaultMaxCongestionWindowPackets; ++i) { | 884 for (uint64_t i = 1; i < kDefaultMaxCongestionWindowPackets; ++i) { |
888 acked_packets.clear(); | 885 acked_packets.clear(); |
889 acked_packets.push_back(std::make_pair(i, 1350)); | 886 acked_packets.push_back(std::make_pair(i, 1350)); |
890 sender->OnCongestionEvent(true, sender->GetCongestionWindow(), | 887 sender->OnCongestionEvent(true, sender->GetCongestionWindow(), |
891 acked_packets, missing_packets); | 888 acked_packets, missing_packets); |
892 } | 889 } |
893 EXPECT_EQ(kDefaultMaxCongestionWindowPackets, | 890 EXPECT_EQ(kDefaultMaxCongestionWindowPackets, |
894 sender->GetCongestionWindow() / kDefaultTCPMSS); | 891 sender->GetCongestionWindow() / kDefaultTCPMSS); |
895 } | 892 } |
896 | 893 |
897 } // namespace test | 894 } // namespace test |
898 } // namespace net | 895 } // namespace net |
OLD | NEW |