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 <sys/epoll.h> | 6 #include <sys/epoll.h> |
7 | 7 |
8 #include <cstdint> | 8 #include <cstdint> |
9 #include <list> | 9 #include <list> |
10 #include <memory> | 10 #include <memory> |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 std::vector<TestParams> GetTestParams() { | 132 std::vector<TestParams> GetTestParams() { |
133 // Divide the versions into buckets in which the intra-frame format | 133 // Divide the versions into buckets in which the intra-frame format |
134 // is compatible. When clients encounter QUIC version negotiation | 134 // is compatible. When clients encounter QUIC version negotiation |
135 // they simply retransmit all packets using the new version's | 135 // they simply retransmit all packets using the new version's |
136 // QUIC framing. However, they are unable to change the intra-frame | 136 // QUIC framing. However, they are unable to change the intra-frame |
137 // layout (for example to change HTTP/2 headers to SPDY/3). So | 137 // layout (for example to change HTTP/2 headers to SPDY/3). So |
138 // these tests need to ensure that clients are never attempting | 138 // these tests need to ensure that clients are never attempting |
139 // to do 0-RTT across incompatible versions. Chromium only supports | 139 // to do 0-RTT across incompatible versions. Chromium only supports |
140 // a single version at a time anyway. :) | 140 // a single version at a time anyway. :) |
141 QuicVersionVector all_supported_versions = AllSupportedVersions(); | 141 QuicVersionVector all_supported_versions = AllSupportedVersions(); |
142 QuicVersionVector version_buckets[3]; | 142 // Even though this currently has one element, it may well get another |
| 143 // with future versions of QUIC, so don't remove it. |
| 144 QuicVersionVector version_buckets[1]; |
143 | 145 |
144 for (const QuicVersion version : all_supported_versions) { | 146 for (const QuicVersion version : all_supported_versions) { |
145 if (version <= QUIC_VERSION_32) { | 147 // Versions: 34+ |
146 // Versions: 31-32 | 148 // QUIC_VERSION_34 deprecates entropy and uses new ack and stop waiting |
147 // v31 adds a hash of the CHLO into the proof signature. | 149 // wire formats. |
148 version_buckets[0].push_back(version); | 150 version_buckets[0].push_back(version); |
149 } else if (version <= QUIC_VERSION_33) { | |
150 // Versions: 33 | |
151 // v33 adds a diversification nonce into the hkdf. | |
152 version_buckets[1].push_back(version); | |
153 } else { | |
154 // Versions: 34+ | |
155 // QUIC_VERSION_34 deprecates entropy and uses new ack and stop waiting | |
156 // wire formats. | |
157 version_buckets[2].push_back(version); | |
158 } | |
159 } | 151 } |
160 | 152 |
161 // This must be kept in sync with the number of nested for-loops below as it | 153 // This must be kept in sync with the number of nested for-loops below as it |
162 // is used to prune the number of tests that are run. | 154 // is used to prune the number of tests that are run. |
163 const int kMaxEnabledOptions = 5; | 155 const int kMaxEnabledOptions = 5; |
164 int max_enabled_options = 0; | 156 int max_enabled_options = 0; |
165 std::vector<TestParams> params; | 157 std::vector<TestParams> params; |
166 for (bool server_uses_stateless_rejects_if_peer_supported : {true, false}) { | 158 for (bool server_uses_stateless_rejects_if_peer_supported : {true, false}) { |
167 for (bool client_supports_stateless_rejects : {true, false}) { | 159 for (bool client_supports_stateless_rejects : {true, false}) { |
168 for (const QuicTag congestion_control_tag : {kRENO, kTBBR, kQBIC}) { | 160 for (const QuicTag congestion_control_tag : {kRENO, kTBBR, kQBIC}) { |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 | 880 |
889 client_->Disconnect(); | 881 client_->Disconnect(); |
890 | 882 |
891 // The 0-RTT handshake should succeed. | 883 // The 0-RTT handshake should succeed. |
892 client_->Connect(); | 884 client_->Connect(); |
893 client_->WaitForInitialResponse(); | 885 client_->WaitForInitialResponse(); |
894 ASSERT_TRUE(client_->client()->connected()); | 886 ASSERT_TRUE(client_->client()->connected()); |
895 EXPECT_EQ(kFooResponseBody, | 887 EXPECT_EQ(kFooResponseBody, |
896 client_->SendCustomSynchronousRequest(headers, body)); | 888 client_->SendCustomSynchronousRequest(headers, body)); |
897 | 889 |
898 if (negotiated_version_ <= QUIC_VERSION_32) { | 890 EXPECT_EQ(1, client_->client()->session()->GetNumSentClientHellos()); |
899 EXPECT_EQ(expected_num_hellos_latest_session, | 891 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); |
900 client_->client()->session()->GetNumSentClientHellos()); | |
901 EXPECT_EQ(2, client_->client()->GetNumSentClientHellos()); | |
902 } else { | |
903 EXPECT_EQ(1, client_->client()->session()->GetNumSentClientHellos()); | |
904 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); | |
905 } | |
906 | 892 |
907 client_->Disconnect(); | 893 client_->Disconnect(); |
908 | 894 |
909 // Restart the server so that the 0-RTT handshake will take 1 RTT. | 895 // Restart the server so that the 0-RTT handshake will take 1 RTT. |
910 StopServer(); | 896 StopServer(); |
911 server_writer_ = new PacketDroppingTestWriter(); | 897 server_writer_ = new PacketDroppingTestWriter(); |
912 StartServer(); | 898 StartServer(); |
913 | 899 |
914 client_->Connect(); | 900 client_->Connect(); |
915 ASSERT_TRUE(client_->client()->connected()); | 901 ASSERT_TRUE(client_->client()->connected()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 EXPECT_EQ(2, client_->client()->GetNumSentClientHellos()); | 934 EXPECT_EQ(2, client_->client()->GetNumSentClientHellos()); |
949 | 935 |
950 client_->Disconnect(); | 936 client_->Disconnect(); |
951 | 937 |
952 // The 0-RTT handshake should succeed. | 938 // The 0-RTT handshake should succeed. |
953 client_->Connect(); | 939 client_->Connect(); |
954 client_->WaitForInitialResponse(); | 940 client_->WaitForInitialResponse(); |
955 ASSERT_TRUE(client_->client()->connected()); | 941 ASSERT_TRUE(client_->client()->connected()); |
956 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 942 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
957 | 943 |
958 if (negotiated_version_ <= QUIC_VERSION_32) { | 944 EXPECT_EQ(1, client_->client()->session()->GetNumSentClientHellos()); |
959 EXPECT_EQ(expected_num_hellos_latest_session, | 945 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); |
960 client_->client()->session()->GetNumSentClientHellos()); | |
961 EXPECT_EQ(2, client_->client()->GetNumSentClientHellos()); | |
962 } else { | |
963 EXPECT_EQ(1, client_->client()->session()->GetNumSentClientHellos()); | |
964 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); | |
965 } | |
966 | 946 |
967 client_->Disconnect(); | 947 client_->Disconnect(); |
968 | 948 |
969 // Restart the server so that the 0-RTT handshake will take 1 RTT. | 949 // Restart the server so that the 0-RTT handshake will take 1 RTT. |
970 StopServer(); | 950 StopServer(); |
971 server_writer_ = new PacketDroppingTestWriter(); | 951 server_writer_ = new PacketDroppingTestWriter(); |
972 StartServer(); | 952 StartServer(); |
973 | 953 |
974 client_->Connect(); | 954 client_->Connect(); |
975 ASSERT_TRUE(client_->client()->connected()); | 955 ASSERT_TRUE(client_->client()->connected()); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 | 997 |
1018 client_->Disconnect(); | 998 client_->Disconnect(); |
1019 | 999 |
1020 // The 0-RTT handshake should succeed. | 1000 // The 0-RTT handshake should succeed. |
1021 client_->Connect(); | 1001 client_->Connect(); |
1022 client_->WaitForInitialResponse(); | 1002 client_->WaitForInitialResponse(); |
1023 ASSERT_TRUE(client_->client()->connected()); | 1003 ASSERT_TRUE(client_->client()->connected()); |
1024 EXPECT_EQ(kFooResponseBody, | 1004 EXPECT_EQ(kFooResponseBody, |
1025 client_->SendCustomSynchronousRequest(headers, body)); | 1005 client_->SendCustomSynchronousRequest(headers, body)); |
1026 | 1006 |
1027 if (negotiated_version_ <= QUIC_VERSION_32) { | 1007 EXPECT_EQ(1, client_->client()->session()->GetNumSentClientHellos()); |
1028 EXPECT_EQ(expected_num_hellos_latest_session, | 1008 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); |
1029 client_->client()->session()->GetNumSentClientHellos()); | |
1030 EXPECT_EQ(2, client_->client()->GetNumSentClientHellos()); | |
1031 } else { | |
1032 EXPECT_EQ(1, client_->client()->session()->GetNumSentClientHellos()); | |
1033 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); | |
1034 } | |
1035 | 1009 |
1036 client_->Disconnect(); | 1010 client_->Disconnect(); |
1037 | 1011 |
1038 // Restart the server so that the 0-RTT handshake will take 1 RTT. | 1012 // Restart the server so that the 0-RTT handshake will take 1 RTT. |
1039 StopServer(); | 1013 StopServer(); |
1040 server_writer_ = new PacketDroppingTestWriter(); | 1014 server_writer_ = new PacketDroppingTestWriter(); |
1041 StartServer(); | 1015 StartServer(); |
1042 | 1016 |
1043 client_->Connect(); | 1017 client_->Connect(); |
1044 ASSERT_TRUE(client_->client()->connected()); | 1018 ASSERT_TRUE(client_->client()->connected()); |
(...skipping 1909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2954 protected: | 2928 protected: |
2955 PacketReorderingWriter* reorder_writer_; | 2929 PacketReorderingWriter* reorder_writer_; |
2956 }; | 2930 }; |
2957 | 2931 |
2958 INSTANTIATE_TEST_CASE_P(EndToEndBufferedPacketsTests, | 2932 INSTANTIATE_TEST_CASE_P(EndToEndBufferedPacketsTests, |
2959 EndToEndBufferedPacketsTest, | 2933 EndToEndBufferedPacketsTest, |
2960 testing::ValuesIn(GetTestParams())); | 2934 testing::ValuesIn(GetTestParams())); |
2961 | 2935 |
2962 TEST_P(EndToEndBufferedPacketsTest, Buffer0RttRequest) { | 2936 TEST_P(EndToEndBufferedPacketsTest, Buffer0RttRequest) { |
2963 ASSERT_TRUE(Initialize()); | 2937 ASSERT_TRUE(Initialize()); |
2964 if (negotiated_version_ <= QUIC_VERSION_32) { | |
2965 // Since no 0-rtt for v32 and under, and this test relies on 0-rtt, skip | |
2966 // this test if QUIC doesn't do 0-rtt. | |
2967 return; | |
2968 } | |
2969 // Finish one request to make sure handshake established. | 2938 // Finish one request to make sure handshake established. |
2970 client_->SendSynchronousRequest("/foo"); | 2939 client_->SendSynchronousRequest("/foo"); |
2971 // Disconnect for next 0-rtt request. | 2940 // Disconnect for next 0-rtt request. |
2972 client_->Disconnect(); | 2941 client_->Disconnect(); |
2973 | 2942 |
2974 // Client get valid STK now. Do a 0-rtt request. | 2943 // Client get valid STK now. Do a 0-rtt request. |
2975 // Buffer a CHLO till another packets sent out. | 2944 // Buffer a CHLO till another packets sent out. |
2976 reorder_writer_->SetDelay(1); | 2945 reorder_writer_->SetDelay(1); |
2977 // Only send out a CHLO. | 2946 // Only send out a CHLO. |
2978 client_->client()->Initialize(); | 2947 client_->client()->Initialize(); |
(...skipping 11 matching lines...) Expand all Loading... |
2990 client_->WaitForResponse(); | 2959 client_->WaitForResponse(); |
2991 EXPECT_EQ(kBarResponseBody, client_->response_body()); | 2960 EXPECT_EQ(kBarResponseBody, client_->response_body()); |
2992 QuicConnectionStats client_stats = | 2961 QuicConnectionStats client_stats = |
2993 client_->client()->session()->connection()->GetStats(); | 2962 client_->client()->session()->connection()->GetStats(); |
2994 EXPECT_EQ(0u, client_stats.packets_lost); | 2963 EXPECT_EQ(0u, client_stats.packets_lost); |
2995 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); | 2964 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); |
2996 } | 2965 } |
2997 } // namespace | 2966 } // namespace |
2998 } // namespace test | 2967 } // namespace test |
2999 } // namespace net | 2968 } // namespace net |
OLD | NEW |