| OLD | NEW |
| 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 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 EXPECT_TRUE( | 922 EXPECT_TRUE( |
| 923 sender_->TimeUntilSend(QuicTime::Zero(), kDefaultTCPMSS).IsZero()); | 923 sender_->TimeUntilSend(QuicTime::Zero(), kDefaultTCPMSS).IsZero()); |
| 924 EXPECT_TRUE( | 924 EXPECT_TRUE( |
| 925 sender_->TimeUntilSend(QuicTime::Zero(), 2 * kDefaultTCPMSS).IsZero()); | 925 sender_->TimeUntilSend(QuicTime::Zero(), 2 * kDefaultTCPMSS).IsZero()); |
| 926 EXPECT_TRUE( | 926 EXPECT_TRUE( |
| 927 sender_->TimeUntilSend(QuicTime::Zero(), 3 * kDefaultTCPMSS).IsZero()); | 927 sender_->TimeUntilSend(QuicTime::Zero(), 3 * kDefaultTCPMSS).IsZero()); |
| 928 EXPECT_FALSE( | 928 EXPECT_FALSE( |
| 929 sender_->TimeUntilSend(QuicTime::Zero(), 4 * kDefaultTCPMSS).IsZero()); | 929 sender_->TimeUntilSend(QuicTime::Zero(), 4 * kDefaultTCPMSS).IsZero()); |
| 930 } | 930 } |
| 931 | 931 |
| 932 TEST_F(TcpCubicSenderPacketsTest, NoPRR) { |
| 933 ValueRestore<bool> old_flag(&FLAGS_quic_allow_noprr, true); |
| 934 QuicTime::Delta rtt = QuicTime::Delta::FromMilliseconds(100); |
| 935 sender_->rtt_stats_.UpdateRtt(rtt, QuicTime::Delta::Zero(), QuicTime::Zero()); |
| 936 |
| 937 sender_->SetNumEmulatedConnections(1); |
| 938 // Verify that kCOPT: kNPRR allows all packets to be sent, even if only one |
| 939 // ack has been received. |
| 940 QuicTagVector options; |
| 941 options.push_back(kNPRR); |
| 942 QuicConfig config; |
| 943 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); |
| 944 sender_->SetFromConfig(config, Perspective::IS_SERVER); |
| 945 SendAvailableSendWindow(); |
| 946 LoseNPackets(9); |
| 947 AckNPackets(1); |
| 948 |
| 949 // We should now have fallen out of slow start with a reduced window. |
| 950 EXPECT_EQ(kRenoBeta * kDefaultWindowTCP, sender_->GetCongestionWindow()); |
| 951 const QuicPacketCount window_in_packets = |
| 952 kRenoBeta * kDefaultWindowTCP / kDefaultTCPMSS; |
| 953 const QuicBandwidth expected_pacing_rate = |
| 954 QuicBandwidth::FromBytesAndTimeDelta(kRenoBeta * kDefaultWindowTCP, |
| 955 sender_->rtt_stats_.smoothed_rtt()); |
| 956 EXPECT_EQ(expected_pacing_rate, sender_->PacingRate()); |
| 957 EXPECT_EQ(window_in_packets, |
| 958 static_cast<uint64_t>(SendAvailableSendWindow())); |
| 959 EXPECT_EQ(expected_pacing_rate, sender_->PacingRate()); |
| 960 } |
| 961 |
| 932 TEST_F(TcpCubicSenderPacketsTest, ResetAfterConnectionMigration) { | 962 TEST_F(TcpCubicSenderPacketsTest, ResetAfterConnectionMigration) { |
| 933 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); | 963 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); |
| 934 EXPECT_EQ(kMaxCongestionWindowPackets, sender_->slowstart_threshold()); | 964 EXPECT_EQ(kMaxCongestionWindowPackets, sender_->slowstart_threshold()); |
| 935 | 965 |
| 936 // Starts with slow start. | 966 // Starts with slow start. |
| 937 sender_->SetNumEmulatedConnections(1); | 967 sender_->SetNumEmulatedConnections(1); |
| 938 const int kNumberOfAcks = 10; | 968 const int kNumberOfAcks = 10; |
| 939 for (int i = 0; i < kNumberOfAcks; ++i) { | 969 for (int i = 0; i < kNumberOfAcks; ++i) { |
| 940 // Send our full send window. | 970 // Send our full send window. |
| 941 SendAvailableSendWindow(); | 971 SendAvailableSendWindow(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 acked_packets.push_back(std::make_pair(i, 1350)); | 1007 acked_packets.push_back(std::make_pair(i, 1350)); |
| 978 sender->OnCongestionEvent(true, sender->GetCongestionWindow(), | 1008 sender->OnCongestionEvent(true, sender->GetCongestionWindow(), |
| 979 acked_packets, missing_packets); | 1009 acked_packets, missing_packets); |
| 980 } | 1010 } |
| 981 EXPECT_EQ(kDefaultMaxCongestionWindowPackets, | 1011 EXPECT_EQ(kDefaultMaxCongestionWindowPackets, |
| 982 sender->GetCongestionWindow() / kDefaultTCPMSS); | 1012 sender->GetCongestionWindow() / kDefaultTCPMSS); |
| 983 } | 1013 } |
| 984 | 1014 |
| 985 } // namespace test | 1015 } // namespace test |
| 986 } // namespace net | 1016 } // namespace net |
| OLD | NEW |