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

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

Issue 2064543002: Add a new rate based sending connection option which uses the pacing rate to keep the bytes_in_flig… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@124273380
Patch Set: Rebase. Created 4 years, 6 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 #include <memory> 8 #include <memory>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 LoseNPackets(9); 946 LoseNPackets(9);
947 AckNPackets(1); 947 AckNPackets(1);
948 948
949 // We should now have fallen out of slow start with a reduced window. 949 // We should now have fallen out of slow start with a reduced window.
950 EXPECT_EQ(kRenoBeta * kDefaultWindowTCP, sender_->GetCongestionWindow()); 950 EXPECT_EQ(kRenoBeta * kDefaultWindowTCP, sender_->GetCongestionWindow());
951 const QuicPacketCount window_in_packets = 951 const QuicPacketCount window_in_packets =
952 kRenoBeta * kDefaultWindowTCP / kDefaultTCPMSS; 952 kRenoBeta * kDefaultWindowTCP / kDefaultTCPMSS;
953 const QuicBandwidth expected_pacing_rate = 953 const QuicBandwidth expected_pacing_rate =
954 QuicBandwidth::FromBytesAndTimeDelta(kRenoBeta * kDefaultWindowTCP, 954 QuicBandwidth::FromBytesAndTimeDelta(kRenoBeta * kDefaultWindowTCP,
955 sender_->rtt_stats_.smoothed_rtt()); 955 sender_->rtt_stats_.smoothed_rtt());
956 EXPECT_EQ(expected_pacing_rate, sender_->PacingRate()); 956 EXPECT_EQ(expected_pacing_rate, sender_->PacingRate(0));
957 EXPECT_EQ(window_in_packets, 957 EXPECT_EQ(window_in_packets,
958 static_cast<uint64_t>(SendAvailableSendWindow())); 958 static_cast<uint64_t>(SendAvailableSendWindow()));
959 EXPECT_EQ(expected_pacing_rate, sender_->PacingRate()); 959 EXPECT_EQ(expected_pacing_rate,
960 sender_->PacingRate(kRenoBeta * kDefaultWindowTCP));
961 }
962
963 TEST_F(TcpCubicSenderPacketsTest, PaceSlowerAboveCwnd) {
964 ValueRestore<bool> old_flag(&FLAGS_quic_rate_based_sending, true);
965 QuicTime::Delta rtt(QuicTime::Delta::FromMilliseconds(60));
966 sender_->rtt_stats_.UpdateRtt(rtt, QuicTime::Delta::Zero(), clock_.Now());
967
968 QuicConfig config;
969 QuicTagVector options;
970 options.push_back(kRATE);
971 QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
972 sender_->SetFromConfig(config, Perspective::IS_SERVER);
973 EXPECT_EQ(10u, sender_->congestion_window());
974 sender_->SetNumEmulatedConnections(1);
975 // Lose a packet to exit slow start.
976 LoseNPackets(1);
977 const QuicPacketCount cwnd = 7;
978 EXPECT_EQ(cwnd * kDefaultTCPMSS, sender_->GetCongestionWindow());
979
980 EXPECT_TRUE(
981 sender_->TimeUntilSend(QuicTime::Zero(), kDefaultTCPMSS).IsZero());
982 EXPECT_EQ(sender_->PacingRate(kDefaultTCPMSS),
983 QuicBandwidth::FromBytesAndTimeDelta(7 * kDefaultTCPMSS, rtt)
984 .Scale(1.25));
985 for (QuicPacketCount i = cwnd + 1; i < 1.5 * cwnd; ++i) {
986 EXPECT_TRUE(
987 sender_->TimeUntilSend(QuicTime::Zero(), i * kDefaultTCPMSS).IsZero());
988 EXPECT_EQ(sender_->PacingRate(i * kDefaultTCPMSS),
989 QuicBandwidth::FromBytesAndTimeDelta(cwnd * kDefaultTCPMSS, rtt)
990 .Scale(0.75));
991 }
992 EXPECT_FALSE(
993 sender_->TimeUntilSend(QuicTime::Zero(), 11 * kDefaultTCPMSS).IsZero());
960 } 994 }
961 995
962 TEST_F(TcpCubicSenderPacketsTest, ResetAfterConnectionMigration) { 996 TEST_F(TcpCubicSenderPacketsTest, ResetAfterConnectionMigration) {
963 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow()); 997 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow());
964 EXPECT_EQ(kMaxCongestionWindowPackets, sender_->slowstart_threshold()); 998 EXPECT_EQ(kMaxCongestionWindowPackets, sender_->slowstart_threshold());
965 999
966 // Starts with slow start. 1000 // Starts with slow start.
967 sender_->SetNumEmulatedConnections(1); 1001 sender_->SetNumEmulatedConnections(1);
968 const int kNumberOfAcks = 10; 1002 const int kNumberOfAcks = 10;
969 for (int i = 0; i < kNumberOfAcks; ++i) { 1003 for (int i = 0; i < kNumberOfAcks; ++i) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 acked_packets.push_back(std::make_pair(i, 1350)); 1041 acked_packets.push_back(std::make_pair(i, 1350));
1008 sender->OnCongestionEvent(true, sender->GetCongestionWindow(), 1042 sender->OnCongestionEvent(true, sender->GetCongestionWindow(),
1009 acked_packets, missing_packets); 1043 acked_packets, missing_packets);
1010 } 1044 }
1011 EXPECT_EQ(kDefaultMaxCongestionWindowPackets, 1045 EXPECT_EQ(kDefaultMaxCongestionWindowPackets,
1012 sender->GetCongestionWindow() / kDefaultTCPMSS); 1046 sender->GetCongestionWindow() / kDefaultTCPMSS);
1013 } 1047 }
1014 1048
1015 } // namespace test 1049 } // namespace test
1016 } // namespace net 1050 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/tcp_cubic_sender_bytes_test.cc ('k') | net/quic/crypto/crypto_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698