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 <stddef.h> | 5 #include <stddef.h> |
6 #include <string> | 6 #include <string> |
7 #include <sys/epoll.h> | 7 #include <sys/epoll.h> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 server_config_.SetMaxStreamsPerConnection(2, 2); | 913 server_config_.SetMaxStreamsPerConnection(2, 2); |
914 // Client tries to negotiate for 10. | 914 // Client tries to negotiate for 10. |
915 client_config_.SetMaxStreamsPerConnection(10, 5); | 915 client_config_.SetMaxStreamsPerConnection(10, 5); |
916 | 916 |
917 ASSERT_TRUE(Initialize()); | 917 ASSERT_TRUE(Initialize()); |
918 client_->client()->WaitForCryptoHandshakeConfirmed(); | 918 client_->client()->WaitForCryptoHandshakeConfirmed(); |
919 QuicConfig* client_negotiated_config = client_->client()->session()->config(); | 919 QuicConfig* client_negotiated_config = client_->client()->session()->config(); |
920 EXPECT_EQ(2u, client_negotiated_config->MaxStreamsPerConnection()); | 920 EXPECT_EQ(2u, client_negotiated_config->MaxStreamsPerConnection()); |
921 } | 921 } |
922 | 922 |
923 TEST_P(EndToEndTest, LimitCongestionWindowAndRTT) { | 923 TEST_P(EndToEndTest, ClientSuggestsRTT) { |
924 // Client tries to request twice the server's max initial window, and the | 924 // Client suggests initial RTT, verify it is used. |
925 // server limits it to the max. | 925 const uint32 kInitialRTT = 20000; |
926 client_config_.SetInitialCongestionWindowToSend(2 * kMaxInitialWindow); | 926 client_config_.SetInitialRoundTripTimeUsToSend(kInitialRTT); |
927 client_config_.SetInitialRoundTripTimeUsToSend(20000); | |
928 | 927 |
929 ASSERT_TRUE(Initialize()); | 928 ASSERT_TRUE(Initialize()); |
930 client_->client()->WaitForCryptoHandshakeConfirmed(); | 929 client_->client()->WaitForCryptoHandshakeConfirmed(); |
931 server_thread_->WaitForCryptoHandshakeConfirmed(); | 930 server_thread_->WaitForCryptoHandshakeConfirmed(); |
932 | 931 |
933 // Pause the server so we can access the server's internals without races. | 932 // Pause the server so we can access the server's internals without races. |
934 server_thread_->Pause(); | 933 server_thread_->Pause(); |
935 QuicDispatcher* dispatcher = | 934 QuicDispatcher* dispatcher = |
936 QuicServerPeer::GetDispatcher(server_thread_->server()); | 935 QuicServerPeer::GetDispatcher(server_thread_->server()); |
937 ASSERT_EQ(1u, dispatcher->session_map().size()); | 936 ASSERT_EQ(1u, dispatcher->session_map().size()); |
938 const QuicSentPacketManager& client_sent_packet_manager = | 937 const QuicSentPacketManager& client_sent_packet_manager = |
939 client_->client()->session()->connection()->sent_packet_manager(); | 938 client_->client()->session()->connection()->sent_packet_manager(); |
940 const QuicSentPacketManager& server_sent_packet_manager = | 939 const QuicSentPacketManager& server_sent_packet_manager = |
941 *GetSentPacketManagerFromFirstServerSession(); | 940 *GetSentPacketManagerFromFirstServerSession(); |
942 | 941 |
943 // The client shouldn't set its initial window based on the negotiated value. | 942 // BBR automatically enables pacing. |
944 EXPECT_EQ(kDefaultInitialWindow, | 943 EXPECT_EQ(GetParam().use_pacing || |
945 client_sent_packet_manager.GetCongestionWindowInTcpMss()); | 944 (FLAGS_quic_allow_bbr && |
946 EXPECT_EQ(kMaxInitialWindow, | 945 GetParam().congestion_control_tag == kTBBR), |
947 server_sent_packet_manager.GetCongestionWindowInTcpMss()); | 946 server_sent_packet_manager.using_pacing()); |
| 947 EXPECT_EQ(GetParam().use_pacing || |
| 948 (FLAGS_quic_allow_bbr && |
| 949 GetParam().congestion_control_tag == kTBBR), |
| 950 client_sent_packet_manager.using_pacing()); |
948 | 951 |
949 EXPECT_EQ(GetParam().use_pacing, server_sent_packet_manager.using_pacing()); | 952 EXPECT_EQ(kInitialRTT, |
950 EXPECT_EQ(GetParam().use_pacing, client_sent_packet_manager.using_pacing()); | 953 client_sent_packet_manager.GetRttStats()->initial_rtt_us()); |
951 | 954 EXPECT_EQ(kInitialRTT, |
952 // The client *should* set the intitial RTT, but it's increased to 10ms. | 955 server_sent_packet_manager.GetRttStats()->initial_rtt_us()); |
953 EXPECT_EQ(20000u, client_sent_packet_manager.GetRttStats()->initial_rtt_us()); | |
954 EXPECT_EQ(20000u, server_sent_packet_manager.GetRttStats()->initial_rtt_us()); | |
955 | |
956 // Now use the negotiated limits with packet loss. | |
957 SetPacketLossPercentage(30); | |
958 | |
959 // 10 KB body. | |
960 string body; | |
961 GenerateBody(&body, 1024 * 10); | |
962 | |
963 HTTPMessage request(HttpConstants::HTTP_1_1, | |
964 HttpConstants::POST, "/foo"); | |
965 request.AddBody(body, true); | |
966 | |
967 server_thread_->Resume(); | 956 server_thread_->Resume(); |
968 | |
969 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); | |
970 } | 957 } |
971 | 958 |
972 TEST_P(EndToEndTest, MaxInitialRTT) { | 959 TEST_P(EndToEndTest, MaxInitialRTT) { |
973 // Client tries to suggest twice the server's max initial rtt and the server | 960 // Client tries to suggest twice the server's max initial rtt and the server |
974 // uses the max. | 961 // uses the max. |
975 client_config_.SetInitialRoundTripTimeUsToSend( | 962 client_config_.SetInitialRoundTripTimeUsToSend( |
976 2 * kMaxInitialRoundTripTimeUs); | 963 2 * kMaxInitialRoundTripTimeUs); |
977 | 964 |
978 ASSERT_TRUE(Initialize()); | 965 ASSERT_TRUE(Initialize()); |
979 client_->client()->WaitForCryptoHandshakeConfirmed(); | 966 client_->client()->WaitForCryptoHandshakeConfirmed(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 const QuicSentPacketManager& client_sent_packet_manager = | 1005 const QuicSentPacketManager& client_sent_packet_manager = |
1019 client_->client()->session()->connection()->sent_packet_manager(); | 1006 client_->client()->session()->connection()->sent_packet_manager(); |
1020 const QuicSentPacketManager& server_sent_packet_manager = | 1007 const QuicSentPacketManager& server_sent_packet_manager = |
1021 session->connection()->sent_packet_manager(); | 1008 session->connection()->sent_packet_manager(); |
1022 | 1009 |
1023 // Now that acks have been exchanged, the RTT estimate has decreased on the | 1010 // Now that acks have been exchanged, the RTT estimate has decreased on the |
1024 // server and is not infinite on the client. | 1011 // server and is not infinite on the client. |
1025 EXPECT_FALSE( | 1012 EXPECT_FALSE( |
1026 client_sent_packet_manager.GetRttStats()->smoothed_rtt().IsInfinite()); | 1013 client_sent_packet_manager.GetRttStats()->smoothed_rtt().IsInfinite()); |
1027 // Expect the default rtt of 100ms. | 1014 // Expect the default rtt of 100ms. |
1028 EXPECT_EQ(static_cast<int64>(100 * base::Time::kMicrosecondsPerMillisecond), | 1015 EXPECT_EQ(static_cast<int64>(100 * kNumMicrosPerMilli), |
1029 server_sent_packet_manager.GetRttStats()->initial_rtt_us()); | 1016 server_sent_packet_manager.GetRttStats()->initial_rtt_us()); |
1030 // Ensure the bandwidth is valid. | 1017 // Ensure the bandwidth is valid. |
1031 client_sent_packet_manager.BandwidthEstimate(); | 1018 client_sent_packet_manager.BandwidthEstimate(); |
1032 server_sent_packet_manager.BandwidthEstimate(); | 1019 server_sent_packet_manager.BandwidthEstimate(); |
1033 server_thread_->Resume(); | 1020 server_thread_->Resume(); |
1034 } | 1021 } |
1035 | 1022 |
1036 TEST_P(EndToEndTest, ResetConnection) { | 1023 TEST_P(EndToEndTest, ResetConnection) { |
1037 ASSERT_TRUE(Initialize()); | 1024 ASSERT_TRUE(Initialize()); |
1038 client_->client()->WaitForCryptoHandshakeConfirmed(); | 1025 client_->client()->WaitForCryptoHandshakeConfirmed(); |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1359 QuicSession* session = dispatcher->session_map().begin()->second; | 1346 QuicSession* session = dispatcher->session_map().begin()->second; |
1360 EXPECT_EQ(0u, QuicSessionPeer::GetLocallyClosedStreamsHighestOffset( | 1347 EXPECT_EQ(0u, QuicSessionPeer::GetLocallyClosedStreamsHighestOffset( |
1361 session).size()); | 1348 session).size()); |
1362 server_thread_->Resume(); | 1349 server_thread_->Resume(); |
1363 } | 1350 } |
1364 | 1351 |
1365 } // namespace | 1352 } // namespace |
1366 } // namespace test | 1353 } // namespace test |
1367 } // namespace tools | 1354 } // namespace tools |
1368 } // namespace net | 1355 } // namespace net |
OLD | NEW |