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 <list> | 8 #include <list> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // Run all tests with the cross products of all versions. | 95 // Run all tests with the cross products of all versions. |
96 struct TestParams { | 96 struct TestParams { |
97 TestParams(const QuicVersionVector& client_supported_versions, | 97 TestParams(const QuicVersionVector& client_supported_versions, |
98 const QuicVersionVector& server_supported_versions, | 98 const QuicVersionVector& server_supported_versions, |
99 QuicVersion negotiated_version, | 99 QuicVersion negotiated_version, |
100 bool client_supports_stateless_rejects, | 100 bool client_supports_stateless_rejects, |
101 bool server_uses_stateless_rejects_if_peer_supported, | 101 bool server_uses_stateless_rejects_if_peer_supported, |
102 QuicTag congestion_control_tag, | 102 QuicTag congestion_control_tag, |
103 bool disable_hpack_dynamic_table, | 103 bool disable_hpack_dynamic_table, |
104 bool force_hol_blocking, | 104 bool force_hol_blocking, |
105 bool use_cheap_stateless_reject) | 105 bool use_cheap_stateless_reject, |
| 106 bool buffer_packet_till_chlo) |
106 : client_supported_versions(client_supported_versions), | 107 : client_supported_versions(client_supported_versions), |
107 server_supported_versions(server_supported_versions), | 108 server_supported_versions(server_supported_versions), |
108 negotiated_version(negotiated_version), | 109 negotiated_version(negotiated_version), |
109 client_supports_stateless_rejects(client_supports_stateless_rejects), | 110 client_supports_stateless_rejects(client_supports_stateless_rejects), |
110 server_uses_stateless_rejects_if_peer_supported( | 111 server_uses_stateless_rejects_if_peer_supported( |
111 server_uses_stateless_rejects_if_peer_supported), | 112 server_uses_stateless_rejects_if_peer_supported), |
112 congestion_control_tag(congestion_control_tag), | 113 congestion_control_tag(congestion_control_tag), |
113 disable_hpack_dynamic_table(disable_hpack_dynamic_table), | 114 disable_hpack_dynamic_table(disable_hpack_dynamic_table), |
114 force_hol_blocking(force_hol_blocking), | 115 force_hol_blocking(force_hol_blocking), |
115 use_cheap_stateless_reject(use_cheap_stateless_reject) {} | 116 use_cheap_stateless_reject(use_cheap_stateless_reject), |
| 117 buffer_packet_till_chlo(buffer_packet_till_chlo) {} |
116 | 118 |
117 friend ostream& operator<<(ostream& os, const TestParams& p) { | 119 friend ostream& operator<<(ostream& os, const TestParams& p) { |
118 os << "{ server_supported_versions: " | 120 os << "{ server_supported_versions: " |
119 << QuicVersionVectorToString(p.server_supported_versions); | 121 << QuicVersionVectorToString(p.server_supported_versions); |
120 os << " client_supported_versions: " | 122 os << " client_supported_versions: " |
121 << QuicVersionVectorToString(p.client_supported_versions); | 123 << QuicVersionVectorToString(p.client_supported_versions); |
122 os << " negotiated_version: " << QuicVersionToString(p.negotiated_version); | 124 os << " negotiated_version: " << QuicVersionToString(p.negotiated_version); |
123 os << " client_supports_stateless_rejects: " | 125 os << " client_supports_stateless_rejects: " |
124 << p.client_supports_stateless_rejects; | 126 << p.client_supports_stateless_rejects; |
125 os << " server_uses_stateless_rejects_if_peer_supported: " | 127 os << " server_uses_stateless_rejects_if_peer_supported: " |
126 << p.server_uses_stateless_rejects_if_peer_supported; | 128 << p.server_uses_stateless_rejects_if_peer_supported; |
127 os << " congestion_control_tag: " | 129 os << " congestion_control_tag: " |
128 << QuicUtils::TagToString(p.congestion_control_tag); | 130 << QuicUtils::TagToString(p.congestion_control_tag); |
129 os << " disable_hpack_dynamic_table: " << p.disable_hpack_dynamic_table; | 131 os << " disable_hpack_dynamic_table: " << p.disable_hpack_dynamic_table; |
130 os << " force_hol_blocking: " << p.force_hol_blocking; | 132 os << " force_hol_blocking: " << p.force_hol_blocking; |
131 os << " use_cheap_stateless_reject: " << p.use_cheap_stateless_reject | 133 os << " use_cheap_stateless_reject: " << p.use_cheap_stateless_reject; |
132 << " }"; | 134 os << " buffer_packet_till_chlo: " << p.buffer_packet_till_chlo << " }"; |
133 return os; | 135 return os; |
134 } | 136 } |
135 | 137 |
136 QuicVersionVector client_supported_versions; | 138 QuicVersionVector client_supported_versions; |
137 QuicVersionVector server_supported_versions; | 139 QuicVersionVector server_supported_versions; |
138 QuicVersion negotiated_version; | 140 QuicVersion negotiated_version; |
139 bool client_supports_stateless_rejects; | 141 bool client_supports_stateless_rejects; |
140 bool server_uses_stateless_rejects_if_peer_supported; | 142 bool server_uses_stateless_rejects_if_peer_supported; |
141 QuicTag congestion_control_tag; | 143 QuicTag congestion_control_tag; |
142 bool disable_hpack_dynamic_table; | 144 bool disable_hpack_dynamic_table; |
143 bool force_hol_blocking; | 145 bool force_hol_blocking; |
144 bool use_cheap_stateless_reject; | 146 bool use_cheap_stateless_reject; |
| 147 bool buffer_packet_till_chlo; |
145 }; | 148 }; |
146 | 149 |
147 // Constructs various test permutations. | 150 // Constructs various test permutations. |
148 vector<TestParams> GetTestParams() { | 151 vector<TestParams> GetTestParams() { |
149 // Divide the versions into buckets in which the intra-frame format | 152 // Divide the versions into buckets in which the intra-frame format |
150 // is compatible. When clients encounter QUIC version negotiation | 153 // is compatible. When clients encounter QUIC version negotiation |
151 // they simply retransmit all packets using the new version's | 154 // they simply retransmit all packets using the new version's |
152 // QUIC framing. However, they are unable to change the intra-frame | 155 // QUIC framing. However, they are unable to change the intra-frame |
153 // layout (for example to change SPDY/4 headers to SPDY/3). So | 156 // layout (for example to change SPDY/4 headers to SPDY/3). So |
154 // these tests need to ensure that clients are never attempting | 157 // these tests need to ensure that clients are never attempting |
(...skipping 18 matching lines...) Expand all Loading... |
173 } else { | 176 } else { |
174 // Versions: 34+ | 177 // Versions: 34+ |
175 // QUIC_VERSION_34 deprecates entropy and uses new ack and stop waiting | 178 // QUIC_VERSION_34 deprecates entropy and uses new ack and stop waiting |
176 // wire formats. | 179 // wire formats. |
177 version_buckets[3].push_back(version); | 180 version_buckets[3].push_back(version); |
178 } | 181 } |
179 } | 182 } |
180 | 183 |
181 // This must be kept in sync with the number of nested for-loops below as it | 184 // This must be kept in sync with the number of nested for-loops below as it |
182 // is used to prune the number of tests that are run. | 185 // is used to prune the number of tests that are run. |
183 const int kMaxEnabledOptions = 5; | 186 const int kMaxEnabledOptions = 6; |
184 int max_enabled_options = 0; | 187 int max_enabled_options = 0; |
185 vector<TestParams> params; | 188 vector<TestParams> params; |
186 for (bool server_uses_stateless_rejects_if_peer_supported : {true, false}) { | 189 for (bool server_uses_stateless_rejects_if_peer_supported : {true, false}) { |
187 for (bool client_supports_stateless_rejects : {true, false}) { | 190 for (bool client_supports_stateless_rejects : {true, false}) { |
188 for (const QuicTag congestion_control_tag : {kRENO, kQBIC}) { | 191 for (const QuicTag congestion_control_tag : {kRENO, kQBIC}) { |
189 for (bool disable_hpack_dynamic_table : {false}) { | 192 for (bool disable_hpack_dynamic_table : {false}) { |
190 for (bool force_hol_blocking : {true, false}) { | 193 for (bool force_hol_blocking : {true, false}) { |
191 for (bool use_cheap_stateless_reject : {true, false}) { | 194 for (bool use_cheap_stateless_reject : {true, false}) { |
192 int enabled_options = 0; | 195 for (bool buffer_packet_till_chlo : {true, false}) { |
193 if (force_hol_blocking) { | 196 if (!buffer_packet_till_chlo && use_cheap_stateless_reject) { |
194 ++enabled_options; | 197 // Doing stateless reject while not buffering packet |
195 } | 198 // before CHLO is not allowed. |
196 if (congestion_control_tag != kQBIC) { | 199 break; |
197 ++enabled_options; | 200 } |
198 } | 201 int enabled_options = 0; |
199 if (disable_hpack_dynamic_table) { | 202 if (force_hol_blocking) { |
200 ++enabled_options; | 203 ++enabled_options; |
201 } | 204 } |
202 if (client_supports_stateless_rejects) { | 205 if (congestion_control_tag != kQBIC) { |
203 ++enabled_options; | 206 ++enabled_options; |
204 } | 207 } |
205 if (server_uses_stateless_rejects_if_peer_supported) { | 208 if (disable_hpack_dynamic_table) { |
206 ++enabled_options; | 209 ++enabled_options; |
207 } | 210 } |
208 if (use_cheap_stateless_reject) { | 211 if (client_supports_stateless_rejects) { |
209 ++enabled_options; | 212 ++enabled_options; |
210 } | 213 } |
211 CHECK_GE(kMaxEnabledOptions, enabled_options); | 214 if (server_uses_stateless_rejects_if_peer_supported) { |
212 if (enabled_options > max_enabled_options) { | 215 ++enabled_options; |
213 max_enabled_options = enabled_options; | 216 } |
214 } | 217 if (buffer_packet_till_chlo) { |
| 218 ++enabled_options; |
| 219 } |
| 220 if (use_cheap_stateless_reject) { |
| 221 ++enabled_options; |
| 222 } |
| 223 CHECK_GE(kMaxEnabledOptions, enabled_options); |
| 224 if (enabled_options > max_enabled_options) { |
| 225 max_enabled_options = enabled_options; |
| 226 } |
215 | 227 |
216 // Run tests with no options, a single option, or all the | 228 // Run tests with no options, a single option, or all the |
217 // options enabled to avoid a combinatorial explosion. | 229 // options enabled to avoid a combinatorial explosion. |
218 if (enabled_options > 1 && enabled_options < kMaxEnabledOptions) { | 230 if (enabled_options > 1 && |
219 continue; | |
220 } | |
221 | |
222 for (const QuicVersionVector& client_versions : version_buckets) { | |
223 CHECK(!client_versions.empty()); | |
224 // Add an entry for server and client supporting all versions. | |
225 params.push_back(TestParams( | |
226 client_versions, all_supported_versions, | |
227 client_versions.front(), client_supports_stateless_rejects, | |
228 server_uses_stateless_rejects_if_peer_supported, | |
229 congestion_control_tag, disable_hpack_dynamic_table, | |
230 force_hol_blocking, use_cheap_stateless_reject)); | |
231 | |
232 // Run version negotiation tests tests with no options, or all | |
233 // the options enabled to avoid a combinatorial explosion. | |
234 if (enabled_options > 0 && | |
235 enabled_options < kMaxEnabledOptions) { | 231 enabled_options < kMaxEnabledOptions) { |
236 continue; | 232 continue; |
237 } | 233 } |
238 | 234 |
239 // Test client supporting all versions and server supporting 1 | 235 for (const QuicVersionVector& client_versions : |
240 // version. Simulate an old server and exercise version | 236 version_buckets) { |
241 // downgrade in the client. Protocol negotiation should occur. | 237 CHECK(!client_versions.empty()); |
242 // Skip the i = 0 case because it is essentially the same as | 238 // Add an entry for server and client supporting all versions. |
243 // the default case. | |
244 for (size_t i = 1; i < client_versions.size(); ++i) { | |
245 QuicVersionVector server_supported_versions; | |
246 server_supported_versions.push_back(client_versions[i]); | |
247 params.push_back(TestParams( | 239 params.push_back(TestParams( |
248 client_versions, server_supported_versions, | 240 client_versions, all_supported_versions, |
249 server_supported_versions.front(), | 241 client_versions.front(), |
250 client_supports_stateless_rejects, | 242 client_supports_stateless_rejects, |
251 server_uses_stateless_rejects_if_peer_supported, | 243 server_uses_stateless_rejects_if_peer_supported, |
252 congestion_control_tag, disable_hpack_dynamic_table, | 244 congestion_control_tag, disable_hpack_dynamic_table, |
253 force_hol_blocking, use_cheap_stateless_reject)); | 245 force_hol_blocking, use_cheap_stateless_reject, |
254 } // End of version for loop. | 246 buffer_packet_till_chlo)); |
255 } // End of 2nd version for loop. | 247 |
256 } // End of use_cheap_stateless_reject for loop. | 248 // Run version negotiation tests tests with no options, or all |
257 } // End of force_hol_blocking loop. | 249 // the options enabled to avoid a combinatorial explosion. |
258 } // End of disable_hpack_dynamic_table for loop. | 250 if (enabled_options > 0 && |
259 } // End of congestion_control_tag for loop. | 251 enabled_options < kMaxEnabledOptions) { |
260 } // End of client_supports_stateless_rejects for loop. | 252 continue; |
| 253 } |
| 254 |
| 255 // Test client supporting all versions and server supporting 1 |
| 256 // version. Simulate an old server and exercise version |
| 257 // downgrade in the client. Protocol negotiation should occur. |
| 258 // Skip the i = 0 case because it is essentially the same as |
| 259 // the default case. |
| 260 for (size_t i = 1; i < client_versions.size(); ++i) { |
| 261 QuicVersionVector server_supported_versions; |
| 262 server_supported_versions.push_back(client_versions[i]); |
| 263 params.push_back(TestParams( |
| 264 client_versions, server_supported_versions, |
| 265 server_supported_versions.front(), |
| 266 client_supports_stateless_rejects, |
| 267 server_uses_stateless_rejects_if_peer_supported, |
| 268 congestion_control_tag, disable_hpack_dynamic_table, |
| 269 force_hol_blocking, use_cheap_stateless_reject, |
| 270 buffer_packet_till_chlo)); |
| 271 } // End of version for loop. |
| 272 } // End of 2nd version for loop. |
| 273 } // End of buffer_packet_till_chlo loop. |
| 274 } // End of use_cheap_stateless_reject for loop. |
| 275 } // End of force_hol_blocking loop. |
| 276 } // End of disable_hpack_dynamic_table for loop. |
| 277 } // End of congestion_control_tag for loop. |
| 278 } // End of client_supports_stateless_rejects for loop. |
261 CHECK_EQ(kMaxEnabledOptions, max_enabled_options); | 279 CHECK_EQ(kMaxEnabledOptions, max_enabled_options); |
262 } // End of server_uses_stateless_rejects_if_peer_supported for loop. | 280 } // End of server_uses_stateless_rejects_if_peer_supported for loop. |
263 return params; | 281 return params; |
264 } | 282 } |
265 | 283 |
266 class ServerDelegate : public PacketDroppingTestWriter::Delegate { | 284 class ServerDelegate : public PacketDroppingTestWriter::Delegate { |
267 public: | 285 public: |
268 explicit ServerDelegate(QuicDispatcher* dispatcher) | 286 explicit ServerDelegate(QuicDispatcher* dispatcher) |
269 : dispatcher_(dispatcher) {} | 287 : dispatcher_(dispatcher) {} |
270 ~ServerDelegate() override {} | 288 ~ServerDelegate() override {} |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 server_writer_ = new PacketDroppingTestWriter(); | 459 server_writer_ = new PacketDroppingTestWriter(); |
442 } | 460 } |
443 | 461 |
444 void TearDown() override { | 462 void TearDown() override { |
445 ASSERT_TRUE(initialized_) << "You must call Initialize() in every test " | 463 ASSERT_TRUE(initialized_) << "You must call Initialize() in every test " |
446 << "case. Otherwise, your test will leak memory."; | 464 << "case. Otherwise, your test will leak memory."; |
447 StopServer(); | 465 StopServer(); |
448 } | 466 } |
449 | 467 |
450 void StartServer() { | 468 void StartServer() { |
| 469 FLAGS_quic_buffer_packet_till_chlo = GetParam().buffer_packet_till_chlo; |
451 FLAGS_quic_use_cheap_stateless_rejects = | 470 FLAGS_quic_use_cheap_stateless_rejects = |
452 GetParam().use_cheap_stateless_reject; | 471 GetParam().use_cheap_stateless_reject; |
453 server_thread_.reset(new ServerThread( | 472 server_thread_.reset(new ServerThread( |
454 new QuicTestServer(CryptoTestUtils::ProofSourceForTesting(), | 473 new QuicTestServer(CryptoTestUtils::ProofSourceForTesting(), |
455 server_config_, server_supported_versions_), | 474 server_config_, server_supported_versions_), |
456 server_address_, strike_register_no_startup_period_)); | 475 server_address_, strike_register_no_startup_period_)); |
457 if (chlo_multiplier_ != 0) { | 476 if (chlo_multiplier_ != 0) { |
458 server_thread_->server()->SetChloMultiplier(chlo_multiplier_); | 477 server_thread_->server()->SetChloMultiplier(chlo_multiplier_); |
459 } | 478 } |
460 server_thread_->Initialize(); | 479 server_thread_->Initialize(); |
(...skipping 2397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2858 EXPECT_EQ(kBarResponseBody, client_->response_body()); | 2877 EXPECT_EQ(kBarResponseBody, client_->response_body()); |
2859 QuicConnectionStats client_stats = | 2878 QuicConnectionStats client_stats = |
2860 client_->client()->session()->connection()->GetStats(); | 2879 client_->client()->session()->connection()->GetStats(); |
2861 EXPECT_EQ(0u, client_stats.packets_lost); | 2880 EXPECT_EQ(0u, client_stats.packets_lost); |
2862 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); | 2881 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); |
2863 } | 2882 } |
2864 | 2883 |
2865 } // namespace | 2884 } // namespace |
2866 } // namespace test | 2885 } // namespace test |
2867 } // namespace net | 2886 } // namespace net |
OLD | NEW |