| 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 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 85 |
| 86 const char kFooResponseBody[] = "Artichoke hearts make me happy."; | 86 const char kFooResponseBody[] = "Artichoke hearts make me happy."; |
| 87 const char kBarResponseBody[] = "Palm hearts are pretty delicious, also."; | 87 const char kBarResponseBody[] = "Palm hearts are pretty delicious, also."; |
| 88 const float kSessionToStreamRatio = 1.5; | 88 const float kSessionToStreamRatio = 1.5; |
| 89 | 89 |
| 90 // Run all tests with the cross products of all versions. | 90 // Run all tests with the cross products of all versions. |
| 91 struct TestParams { | 91 struct TestParams { |
| 92 TestParams(const QuicVersionVector& client_supported_versions, | 92 TestParams(const QuicVersionVector& client_supported_versions, |
| 93 const QuicVersionVector& server_supported_versions, | 93 const QuicVersionVector& server_supported_versions, |
| 94 QuicVersion negotiated_version, | 94 QuicVersion negotiated_version, |
| 95 bool use_fec, | |
| 96 bool client_supports_stateless_rejects, | 95 bool client_supports_stateless_rejects, |
| 97 bool server_uses_stateless_rejects_if_peer_supported, | 96 bool server_uses_stateless_rejects_if_peer_supported, |
| 98 QuicTag congestion_control_tag, | 97 QuicTag congestion_control_tag, |
| 99 bool auto_tune_flow_control_window) | 98 bool auto_tune_flow_control_window) |
| 100 : client_supported_versions(client_supported_versions), | 99 : client_supported_versions(client_supported_versions), |
| 101 server_supported_versions(server_supported_versions), | 100 server_supported_versions(server_supported_versions), |
| 102 negotiated_version(negotiated_version), | 101 negotiated_version(negotiated_version), |
| 103 use_fec(use_fec), | |
| 104 client_supports_stateless_rejects(client_supports_stateless_rejects), | 102 client_supports_stateless_rejects(client_supports_stateless_rejects), |
| 105 server_uses_stateless_rejects_if_peer_supported( | 103 server_uses_stateless_rejects_if_peer_supported( |
| 106 server_uses_stateless_rejects_if_peer_supported), | 104 server_uses_stateless_rejects_if_peer_supported), |
| 107 congestion_control_tag(congestion_control_tag), | 105 congestion_control_tag(congestion_control_tag), |
| 108 auto_tune_flow_control_window(auto_tune_flow_control_window) {} | 106 auto_tune_flow_control_window(auto_tune_flow_control_window) {} |
| 109 | 107 |
| 110 friend ostream& operator<<(ostream& os, const TestParams& p) { | 108 friend ostream& operator<<(ostream& os, const TestParams& p) { |
| 111 os << "{ server_supported_versions: " | 109 os << "{ server_supported_versions: " |
| 112 << QuicVersionVectorToString(p.server_supported_versions); | 110 << QuicVersionVectorToString(p.server_supported_versions); |
| 113 os << " client_supported_versions: " | 111 os << " client_supported_versions: " |
| 114 << QuicVersionVectorToString(p.client_supported_versions); | 112 << QuicVersionVectorToString(p.client_supported_versions); |
| 115 os << " negotiated_version: " << QuicVersionToString(p.negotiated_version); | 113 os << " negotiated_version: " << QuicVersionToString(p.negotiated_version); |
| 116 os << " client_supports_stateless_rejects: " | 114 os << " client_supports_stateless_rejects: " |
| 117 << p.client_supports_stateless_rejects; | 115 << p.client_supports_stateless_rejects; |
| 118 os << " server_uses_stateless_rejects_if_peer_supported: " | 116 os << " server_uses_stateless_rejects_if_peer_supported: " |
| 119 << p.server_uses_stateless_rejects_if_peer_supported; | 117 << p.server_uses_stateless_rejects_if_peer_supported; |
| 120 os << " use_fec: " << p.use_fec; | |
| 121 os << " congestion_control_tag: " | 118 os << " congestion_control_tag: " |
| 122 << QuicUtils::TagToString(p.congestion_control_tag); | 119 << QuicUtils::TagToString(p.congestion_control_tag); |
| 123 os << " auto_tune_flow_control_window: " << p.auto_tune_flow_control_window | 120 os << " auto_tune_flow_control_window: " << p.auto_tune_flow_control_window |
| 124 << " }"; | 121 << " }"; |
| 125 return os; | 122 return os; |
| 126 } | 123 } |
| 127 | 124 |
| 128 QuicVersionVector client_supported_versions; | 125 QuicVersionVector client_supported_versions; |
| 129 QuicVersionVector server_supported_versions; | 126 QuicVersionVector server_supported_versions; |
| 130 QuicVersion negotiated_version; | 127 QuicVersion negotiated_version; |
| 131 bool use_fec; | |
| 132 bool client_supports_stateless_rejects; | 128 bool client_supports_stateless_rejects; |
| 133 bool server_uses_stateless_rejects_if_peer_supported; | 129 bool server_uses_stateless_rejects_if_peer_supported; |
| 134 QuicTag congestion_control_tag; | 130 QuicTag congestion_control_tag; |
| 135 bool auto_tune_flow_control_window; | 131 bool auto_tune_flow_control_window; |
| 136 }; | 132 }; |
| 137 | 133 |
| 138 // Constructs various test permutations. | 134 // Constructs various test permutations. |
| 139 vector<TestParams> GetTestParams() { | 135 vector<TestParams> GetTestParams() { |
| 140 // Divide the versions into buckets in which the intra-frame format | 136 // Divide the versions into buckets in which the intra-frame format |
| 141 // is compatible. When clients encounter QUIC version negotiation | 137 // is compatible. When clients encounter QUIC version negotiation |
| (...skipping 15 matching lines...) Expand all Loading... |
| 157 version_buckets[1].push_back(version); | 153 version_buckets[1].push_back(version); |
| 158 } | 154 } |
| 159 } | 155 } |
| 160 | 156 |
| 161 vector<TestParams> params; | 157 vector<TestParams> params; |
| 162 for (bool server_uses_stateless_rejects_if_peer_supported : {true, false}) { | 158 for (bool server_uses_stateless_rejects_if_peer_supported : {true, false}) { |
| 163 for (bool client_supports_stateless_rejects : {true, false}) { | 159 for (bool client_supports_stateless_rejects : {true, false}) { |
| 164 // TODO(rtenneti): Add kTBBR after BBR code is checked in. | 160 // TODO(rtenneti): Add kTBBR after BBR code is checked in. |
| 165 for (const QuicTag congestion_control_tag : {kRENO, kQBIC}) { | 161 for (const QuicTag congestion_control_tag : {kRENO, kQBIC}) { |
| 166 for (bool auto_tune_flow_control_window : {true, false}) { | 162 for (bool auto_tune_flow_control_window : {true, false}) { |
| 167 for (const bool use_fec : {false, true}) { | 163 const int kMaxEnabledOptions = 5; |
| 168 const int kMaxEnabledOptions = 5; | 164 int enabled_options = 0; |
| 169 int enabled_options = 0; | 165 if (congestion_control_tag != kQBIC) { |
| 170 if (congestion_control_tag != kQBIC) { | 166 ++enabled_options; |
| 171 ++enabled_options; | 167 } |
| 172 } | 168 if (auto_tune_flow_control_window) { |
| 173 if (use_fec) { | 169 ++enabled_options; |
| 174 ++enabled_options; | 170 } |
| 175 } | 171 if (client_supports_stateless_rejects) { |
| 176 if (auto_tune_flow_control_window) { | 172 ++enabled_options; |
| 177 ++enabled_options; | 173 } |
| 178 } | 174 if (server_uses_stateless_rejects_if_peer_supported) { |
| 179 if (client_supports_stateless_rejects) { | 175 ++enabled_options; |
| 180 ++enabled_options; | 176 } |
| 181 } | 177 CHECK_GE(kMaxEnabledOptions, enabled_options); |
| 182 if (server_uses_stateless_rejects_if_peer_supported) { | |
| 183 ++enabled_options; | |
| 184 } | |
| 185 CHECK_GE(kMaxEnabledOptions, enabled_options); | |
| 186 | 178 |
| 187 // Run tests with no options, a single option, or all the options | 179 // Run tests with no options, a single option, or all the options |
| 188 // enabled to avoid a combinatorial explosion. | 180 // enabled to avoid a combinatorial explosion. |
| 189 if (enabled_options > 1 && enabled_options < kMaxEnabledOptions) { | 181 if (enabled_options > 1 && enabled_options < kMaxEnabledOptions) { |
| 182 continue; |
| 183 } |
| 184 |
| 185 for (const QuicVersionVector& client_versions : version_buckets) { |
| 186 CHECK(!client_versions.empty()); |
| 187 // Add an entry for server and client supporting all versions. |
| 188 params.push_back(TestParams( |
| 189 client_versions, all_supported_versions, |
| 190 client_versions.front(), client_supports_stateless_rejects, |
| 191 server_uses_stateless_rejects_if_peer_supported, |
| 192 congestion_control_tag, auto_tune_flow_control_window)); |
| 193 |
| 194 // Run version negotiation tests tests with no options, or all |
| 195 // the options enabled to avoid a combinatorial explosion. |
| 196 if (enabled_options > 0 && enabled_options < kMaxEnabledOptions) { |
| 190 continue; | 197 continue; |
| 191 } | 198 } |
| 192 | 199 |
| 193 for (const QuicVersionVector& client_versions : version_buckets) { | 200 // Test client supporting all versions and server supporting 1 |
| 194 CHECK(!client_versions.empty()); | 201 // version. Simulate an old server and exercise version downgrade |
| 195 // Add an entry for server and client supporting all versions. | 202 // in the client. Protocol negotiation should occur. Skip the i = |
| 203 // 0 case because it is essentially the same as the default case. |
| 204 for (size_t i = 1; i < client_versions.size(); ++i) { |
| 205 QuicVersionVector server_supported_versions; |
| 206 server_supported_versions.push_back(client_versions[i]); |
| 196 params.push_back(TestParams( | 207 params.push_back(TestParams( |
| 197 client_versions, all_supported_versions, | 208 client_versions, server_supported_versions, |
| 198 client_versions.front(), use_fec, | 209 server_supported_versions.front(), |
| 199 client_supports_stateless_rejects, | 210 client_supports_stateless_rejects, |
| 200 server_uses_stateless_rejects_if_peer_supported, | 211 server_uses_stateless_rejects_if_peer_supported, |
| 201 congestion_control_tag, auto_tune_flow_control_window)); | 212 congestion_control_tag, auto_tune_flow_control_window)); |
| 202 | |
| 203 // Run version negotiation tests tests with no options, or all | |
| 204 // the options enabled to avoid a combinatorial explosion. | |
| 205 if (enabled_options > 0 && enabled_options < kMaxEnabledOptions) { | |
| 206 continue; | |
| 207 } | |
| 208 | |
| 209 // Test client supporting all versions and server supporting 1 | |
| 210 // version. Simulate an old server and exercise version downgrade | |
| 211 // in the client. Protocol negotiation should occur. Skip the i = | |
| 212 // 0 case because it is essentially the same as the default case. | |
| 213 for (size_t i = 1; i < client_versions.size(); ++i) { | |
| 214 QuicVersionVector server_supported_versions; | |
| 215 server_supported_versions.push_back(client_versions[i]); | |
| 216 params.push_back(TestParams( | |
| 217 client_versions, server_supported_versions, | |
| 218 server_supported_versions.front(), use_fec, | |
| 219 client_supports_stateless_rejects, | |
| 220 server_uses_stateless_rejects_if_peer_supported, | |
| 221 congestion_control_tag, auto_tune_flow_control_window)); | |
| 222 } | |
| 223 } | 213 } |
| 224 } | 214 } |
| 225 } | 215 } |
| 226 } | 216 } |
| 227 } | 217 } |
| 228 } | 218 } |
| 229 return params; | 219 return params; |
| 230 } | 220 } |
| 231 | 221 |
| 232 class ServerDelegate : public PacketDroppingTestWriter::Delegate { | 222 class ServerDelegate : public PacketDroppingTestWriter::Delegate { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 } | 335 } |
| 346 | 336 |
| 347 bool Initialize() { | 337 bool Initialize() { |
| 348 QuicTagVector copt; | 338 QuicTagVector copt; |
| 349 server_config_.SetConnectionOptionsToSend(copt); | 339 server_config_.SetConnectionOptionsToSend(copt); |
| 350 | 340 |
| 351 // TODO(nimia): Consider setting the congestion control algorithm for the | 341 // TODO(nimia): Consider setting the congestion control algorithm for the |
| 352 // client as well according to the test parameter. | 342 // client as well according to the test parameter. |
| 353 copt.push_back(GetParam().congestion_control_tag); | 343 copt.push_back(GetParam().congestion_control_tag); |
| 354 | 344 |
| 355 if (GetParam().use_fec) { | |
| 356 // Set FEC config in client's connection options and in client session. | |
| 357 copt.push_back(kFHDR); | |
| 358 } | |
| 359 if (GetParam().client_supports_stateless_rejects) { | 345 if (GetParam().client_supports_stateless_rejects) { |
| 360 copt.push_back(kSREJ); | 346 copt.push_back(kSREJ); |
| 361 } | 347 } |
| 362 if (GetParam().auto_tune_flow_control_window) { | 348 if (GetParam().auto_tune_flow_control_window) { |
| 363 copt.push_back(kAFCW); | 349 copt.push_back(kAFCW); |
| 364 copt.push_back(kIFW5); | 350 copt.push_back(kIFW5); |
| 365 } | 351 } |
| 366 client_config_.SetConnectionOptionsToSend(copt); | 352 client_config_.SetConnectionOptionsToSend(copt); |
| 367 | 353 |
| 368 // Start the server first, because CreateQuicClient() attempts | 354 // Start the server first, because CreateQuicClient() attempts |
| (...skipping 2011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2380 // sending requests for them. | 2366 // sending requests for them. |
| 2381 EXPECT_EQ(1u, client_->num_requests()); | 2367 EXPECT_EQ(1u, client_->num_requests()); |
| 2382 // Including response to original request, 12 responses in total were | 2368 // Including response to original request, 12 responses in total were |
| 2383 // recieved. | 2369 // recieved. |
| 2384 EXPECT_EQ(12u, client_->num_responses()); | 2370 EXPECT_EQ(12u, client_->num_responses()); |
| 2385 } | 2371 } |
| 2386 | 2372 |
| 2387 } // namespace | 2373 } // namespace |
| 2388 } // namespace test | 2374 } // namespace test |
| 2389 } // namespace net | 2375 } // namespace net |
| OLD | NEW |