| 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 <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 const char kBarResponseBody[] = "Palm hearts are pretty delicious, also."; | 89 const char kBarResponseBody[] = "Palm hearts are pretty delicious, also."; |
| 90 const float kSessionToStreamRatio = 1.5; | 90 const float kSessionToStreamRatio = 1.5; |
| 91 | 91 |
| 92 // Run all tests with the cross products of all versions. | 92 // Run all tests with the cross products of all versions. |
| 93 struct TestParams { | 93 struct TestParams { |
| 94 TestParams(const QuicVersionVector& client_supported_versions, | 94 TestParams(const QuicVersionVector& client_supported_versions, |
| 95 const QuicVersionVector& server_supported_versions, | 95 const QuicVersionVector& server_supported_versions, |
| 96 QuicVersion negotiated_version, | 96 QuicVersion negotiated_version, |
| 97 bool client_supports_stateless_rejects, | 97 bool client_supports_stateless_rejects, |
| 98 bool server_uses_stateless_rejects_if_peer_supported, | 98 bool server_uses_stateless_rejects_if_peer_supported, |
| 99 QuicTag congestion_control_tag, | 99 QuicTag congestion_control_tag) |
| 100 bool auto_tune_flow_control_window) | |
| 101 : client_supported_versions(client_supported_versions), | 100 : client_supported_versions(client_supported_versions), |
| 102 server_supported_versions(server_supported_versions), | 101 server_supported_versions(server_supported_versions), |
| 103 negotiated_version(negotiated_version), | 102 negotiated_version(negotiated_version), |
| 104 client_supports_stateless_rejects(client_supports_stateless_rejects), | 103 client_supports_stateless_rejects(client_supports_stateless_rejects), |
| 105 server_uses_stateless_rejects_if_peer_supported( | 104 server_uses_stateless_rejects_if_peer_supported( |
| 106 server_uses_stateless_rejects_if_peer_supported), | 105 server_uses_stateless_rejects_if_peer_supported), |
| 107 congestion_control_tag(congestion_control_tag), | 106 congestion_control_tag(congestion_control_tag) {} |
| 108 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 << " congestion_control_tag: " | 118 os << " congestion_control_tag: " |
| 121 << QuicUtils::TagToString(p.congestion_control_tag); | 119 << QuicUtils::TagToString(p.congestion_control_tag) << " }"; |
| 122 os << " auto_tune_flow_control_window: " << p.auto_tune_flow_control_window | |
| 123 << " }"; | |
| 124 return os; | 120 return os; |
| 125 } | 121 } |
| 126 | 122 |
| 127 QuicVersionVector client_supported_versions; | 123 QuicVersionVector client_supported_versions; |
| 128 QuicVersionVector server_supported_versions; | 124 QuicVersionVector server_supported_versions; |
| 129 QuicVersion negotiated_version; | 125 QuicVersion negotiated_version; |
| 130 bool client_supports_stateless_rejects; | 126 bool client_supports_stateless_rejects; |
| 131 bool server_uses_stateless_rejects_if_peer_supported; | 127 bool server_uses_stateless_rejects_if_peer_supported; |
| 132 QuicTag congestion_control_tag; | 128 QuicTag congestion_control_tag; |
| 133 bool auto_tune_flow_control_window; | |
| 134 }; | 129 }; |
| 135 | 130 |
| 136 // Constructs various test permutations. | 131 // Constructs various test permutations. |
| 137 vector<TestParams> GetTestParams() { | 132 vector<TestParams> GetTestParams() { |
| 138 // Divide the versions into buckets in which the intra-frame format | 133 // Divide the versions into buckets in which the intra-frame format |
| 139 // is compatible. When clients encounter QUIC version negotiation | 134 // is compatible. When clients encounter QUIC version negotiation |
| 140 // they simply retransmit all packets using the new version's | 135 // they simply retransmit all packets using the new version's |
| 141 // QUIC framing. However, they are unable to change the intra-frame | 136 // QUIC framing. However, they are unable to change the intra-frame |
| 142 // layout (for example to change SPDY/4 headers to SPDY/3). So | 137 // layout (for example to change SPDY/4 headers to SPDY/3). So |
| 143 // these tests need to ensure that clients are never attempting | 138 // these tests need to ensure that clients are never attempting |
| (...skipping 10 matching lines...) Expand all Loading... |
| 154 // version negotiation across the version 26 boundary. | 149 // version negotiation across the version 26 boundary. |
| 155 version_buckets[1].push_back(version); | 150 version_buckets[1].push_back(version); |
| 156 } | 151 } |
| 157 } | 152 } |
| 158 | 153 |
| 159 vector<TestParams> params; | 154 vector<TestParams> params; |
| 160 for (bool server_uses_stateless_rejects_if_peer_supported : {true, false}) { | 155 for (bool server_uses_stateless_rejects_if_peer_supported : {true, false}) { |
| 161 for (bool client_supports_stateless_rejects : {true, false}) { | 156 for (bool client_supports_stateless_rejects : {true, false}) { |
| 162 // TODO(rtenneti): Add kTBBR after BBR code is checked in. | 157 // TODO(rtenneti): Add kTBBR after BBR code is checked in. |
| 163 for (const QuicTag congestion_control_tag : {kRENO, kQBIC}) { | 158 for (const QuicTag congestion_control_tag : {kRENO, kQBIC}) { |
| 164 for (bool auto_tune_flow_control_window : {true, false}) { | 159 const int kMaxEnabledOptions = 4; |
| 165 const int kMaxEnabledOptions = 5; | 160 int enabled_options = 0; |
| 166 int enabled_options = 0; | 161 if (congestion_control_tag != kQBIC) { |
| 167 if (congestion_control_tag != kQBIC) { | 162 ++enabled_options; |
| 168 ++enabled_options; | 163 } |
| 169 } | 164 if (client_supports_stateless_rejects) { |
| 170 if (auto_tune_flow_control_window) { | 165 ++enabled_options; |
| 171 ++enabled_options; | 166 } |
| 172 } | 167 if (server_uses_stateless_rejects_if_peer_supported) { |
| 173 if (client_supports_stateless_rejects) { | 168 ++enabled_options; |
| 174 ++enabled_options; | 169 } |
| 175 } | 170 CHECK_GE(kMaxEnabledOptions, enabled_options); |
| 176 if (server_uses_stateless_rejects_if_peer_supported) { | |
| 177 ++enabled_options; | |
| 178 } | |
| 179 CHECK_GE(kMaxEnabledOptions, enabled_options); | |
| 180 | 171 |
| 181 // Run tests with no options, a single option, or all the options | 172 // Run tests with no options, a single option, or all the options |
| 182 // enabled to avoid a combinatorial explosion. | 173 // enabled to avoid a combinatorial explosion. |
| 183 if (enabled_options > 1 && enabled_options < kMaxEnabledOptions) { | 174 if (enabled_options > 1 && enabled_options < kMaxEnabledOptions) { |
| 175 continue; |
| 176 } |
| 177 |
| 178 for (const QuicVersionVector& client_versions : version_buckets) { |
| 179 CHECK(!client_versions.empty()); |
| 180 // Add an entry for server and client supporting all versions. |
| 181 params.push_back(TestParams( |
| 182 client_versions, all_supported_versions, client_versions.front(), |
| 183 client_supports_stateless_rejects, |
| 184 server_uses_stateless_rejects_if_peer_supported, |
| 185 congestion_control_tag)); |
| 186 |
| 187 // Run version negotiation tests tests with no options, or all |
| 188 // the options enabled to avoid a combinatorial explosion. |
| 189 if (enabled_options > 0 && enabled_options < kMaxEnabledOptions) { |
| 184 continue; | 190 continue; |
| 185 } | 191 } |
| 186 | 192 |
| 187 for (const QuicVersionVector& client_versions : version_buckets) { | 193 // Test client supporting all versions and server supporting 1 |
| 188 CHECK(!client_versions.empty()); | 194 // version. Simulate an old server and exercise version downgrade |
| 189 // Add an entry for server and client supporting all versions. | 195 // in the client. Protocol negotiation should occur. Skip the i = |
| 190 params.push_back(TestParams( | 196 // 0 case because it is essentially the same as the default case. |
| 191 client_versions, all_supported_versions, | 197 for (size_t i = 1; i < client_versions.size(); ++i) { |
| 192 client_versions.front(), client_supports_stateless_rejects, | 198 QuicVersionVector server_supported_versions; |
| 193 server_uses_stateless_rejects_if_peer_supported, | 199 server_supported_versions.push_back(client_versions[i]); |
| 194 congestion_control_tag, auto_tune_flow_control_window)); | 200 params.push_back( |
| 195 | 201 TestParams(client_versions, server_supported_versions, |
| 196 // Run version negotiation tests tests with no options, or all | 202 server_supported_versions.front(), |
| 197 // the options enabled to avoid a combinatorial explosion. | 203 client_supports_stateless_rejects, |
| 198 if (enabled_options > 0 && enabled_options < kMaxEnabledOptions) { | 204 server_uses_stateless_rejects_if_peer_supported, |
| 199 continue; | 205 congestion_control_tag)); |
| 200 } | |
| 201 | |
| 202 // Test client supporting all versions and server supporting 1 | |
| 203 // version. Simulate an old server and exercise version downgrade | |
| 204 // in the client. Protocol negotiation should occur. Skip the i = | |
| 205 // 0 case because it is essentially the same as the default case. | |
| 206 for (size_t i = 1; i < client_versions.size(); ++i) { | |
| 207 QuicVersionVector server_supported_versions; | |
| 208 server_supported_versions.push_back(client_versions[i]); | |
| 209 params.push_back(TestParams( | |
| 210 client_versions, server_supported_versions, | |
| 211 server_supported_versions.front(), | |
| 212 client_supports_stateless_rejects, | |
| 213 server_uses_stateless_rejects_if_peer_supported, | |
| 214 congestion_control_tag, auto_tune_flow_control_window)); | |
| 215 } | |
| 216 } | 206 } |
| 217 } | 207 } |
| 218 } | 208 } |
| 219 } | 209 } |
| 220 } | 210 } |
| 221 return params; | 211 return params; |
| 222 } | 212 } |
| 223 | 213 |
| 224 class ServerDelegate : public PacketDroppingTestWriter::Delegate { | 214 class ServerDelegate : public PacketDroppingTestWriter::Delegate { |
| 225 public: | 215 public: |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 server_config_.SetConnectionOptionsToSend(copt); | 331 server_config_.SetConnectionOptionsToSend(copt); |
| 342 | 332 |
| 343 // TODO(nimia): Consider setting the congestion control algorithm for the | 333 // TODO(nimia): Consider setting the congestion control algorithm for the |
| 344 // client as well according to the test parameter. | 334 // client as well according to the test parameter. |
| 345 copt.push_back(GetParam().congestion_control_tag); | 335 copt.push_back(GetParam().congestion_control_tag); |
| 346 copt.push_back(kSPSH); | 336 copt.push_back(kSPSH); |
| 347 | 337 |
| 348 if (GetParam().client_supports_stateless_rejects) { | 338 if (GetParam().client_supports_stateless_rejects) { |
| 349 copt.push_back(kSREJ); | 339 copt.push_back(kSREJ); |
| 350 } | 340 } |
| 351 if (GetParam().auto_tune_flow_control_window) { | |
| 352 copt.push_back(kAFCW); | |
| 353 copt.push_back(kIFW5); | |
| 354 } | |
| 355 client_config_.SetConnectionOptionsToSend(copt); | 341 client_config_.SetConnectionOptionsToSend(copt); |
| 356 | 342 |
| 357 // Start the server first, because CreateQuicClient() attempts | 343 // Start the server first, because CreateQuicClient() attempts |
| 358 // to connect to the server. | 344 // to connect to the server. |
| 359 StartServer(); | 345 StartServer(); |
| 360 | 346 |
| 361 client_.reset(CreateQuicClient(client_writer_)); | 347 client_.reset(CreateQuicClient(client_writer_)); |
| 362 static EpollEvent event(EPOLLOUT, false); | 348 static EpollEvent event(EPOLLOUT, false); |
| 363 client_writer_->Initialize( | 349 client_writer_->Initialize( |
| 364 reinterpret_cast<QuicEpollConnectionHelper*>( | 350 reinterpret_cast<QuicEpollConnectionHelper*>( |
| (...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1484 | 1470 |
| 1485 TEST_P(EndToEndTest, DifferentFlowControlWindows) { | 1471 TEST_P(EndToEndTest, DifferentFlowControlWindows) { |
| 1486 // Client and server can set different initial flow control receive windows. | 1472 // Client and server can set different initial flow control receive windows. |
| 1487 // These are sent in CHLO/SHLO. Tests that these values are exchanged properly | 1473 // These are sent in CHLO/SHLO. Tests that these values are exchanged properly |
| 1488 // in the crypto handshake. | 1474 // in the crypto handshake. |
| 1489 const uint32_t kClientStreamIFCW = 123456; | 1475 const uint32_t kClientStreamIFCW = 123456; |
| 1490 const uint32_t kClientSessionIFCW = 234567; | 1476 const uint32_t kClientSessionIFCW = 234567; |
| 1491 set_client_initial_stream_flow_control_receive_window(kClientStreamIFCW); | 1477 set_client_initial_stream_flow_control_receive_window(kClientStreamIFCW); |
| 1492 set_client_initial_session_flow_control_receive_window(kClientSessionIFCW); | 1478 set_client_initial_session_flow_control_receive_window(kClientSessionIFCW); |
| 1493 | 1479 |
| 1494 uint32_t kServerStreamIFCW = | 1480 uint32_t kServerStreamIFCW = 32 * 1024; |
| 1495 GetParam().auto_tune_flow_control_window ? 32 * 1024 : 654321; | 1481 uint32_t kServerSessionIFCW = 48 * 1024; |
| 1496 uint32_t kServerSessionIFCW = | |
| 1497 GetParam().auto_tune_flow_control_window ? 48 * 1024 : 765432; | |
| 1498 set_server_initial_stream_flow_control_receive_window(kServerStreamIFCW); | 1482 set_server_initial_stream_flow_control_receive_window(kServerStreamIFCW); |
| 1499 set_server_initial_session_flow_control_receive_window(kServerSessionIFCW); | 1483 set_server_initial_session_flow_control_receive_window(kServerSessionIFCW); |
| 1500 | 1484 |
| 1501 ASSERT_TRUE(Initialize()); | 1485 ASSERT_TRUE(Initialize()); |
| 1502 | 1486 |
| 1503 // Values are exchanged during crypto handshake, so wait for that to finish. | 1487 // Values are exchanged during crypto handshake, so wait for that to finish. |
| 1504 client_->client()->WaitForCryptoHandshakeConfirmed(); | 1488 client_->client()->WaitForCryptoHandshakeConfirmed(); |
| 1505 server_thread_->WaitForCryptoHandshakeConfirmed(); | 1489 server_thread_->WaitForCryptoHandshakeConfirmed(); |
| 1506 | 1490 |
| 1507 // Open a data stream to make sure the stream level flow control is updated. | 1491 // Open a data stream to make sure the stream level flow control is updated. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1535 EXPECT_EQ(kClientSessionIFCW, | 1519 EXPECT_EQ(kClientSessionIFCW, |
| 1536 session->config()->ReceivedInitialSessionFlowControlWindowBytes()); | 1520 session->config()->ReceivedInitialSessionFlowControlWindowBytes()); |
| 1537 EXPECT_EQ(kClientSessionIFCW, QuicFlowControllerPeer::SendWindowOffset( | 1521 EXPECT_EQ(kClientSessionIFCW, QuicFlowControllerPeer::SendWindowOffset( |
| 1538 session->flow_controller())); | 1522 session->flow_controller())); |
| 1539 server_thread_->Resume(); | 1523 server_thread_->Resume(); |
| 1540 } | 1524 } |
| 1541 | 1525 |
| 1542 TEST_P(EndToEndTest, HeadersAndCryptoStreamsNoConnectionFlowControl) { | 1526 TEST_P(EndToEndTest, HeadersAndCryptoStreamsNoConnectionFlowControl) { |
| 1543 // The special headers and crypto streams should be subject to per-stream flow | 1527 // The special headers and crypto streams should be subject to per-stream flow |
| 1544 // control limits, but should not be subject to connection level flow control. | 1528 // control limits, but should not be subject to connection level flow control. |
| 1545 const uint32_t kStreamIFCW = | 1529 const uint32_t kStreamIFCW = 32 * 1024; |
| 1546 GetParam().auto_tune_flow_control_window ? 32 * 1024 : 123456; | 1530 const uint32_t kSessionIFCW = 48 * 1024; |
| 1547 const uint32_t kSessionIFCW = | |
| 1548 GetParam().auto_tune_flow_control_window ? 48 * 1024 : 234567; | |
| 1549 set_client_initial_stream_flow_control_receive_window(kStreamIFCW); | 1531 set_client_initial_stream_flow_control_receive_window(kStreamIFCW); |
| 1550 set_client_initial_session_flow_control_receive_window(kSessionIFCW); | 1532 set_client_initial_session_flow_control_receive_window(kSessionIFCW); |
| 1551 set_server_initial_stream_flow_control_receive_window(kStreamIFCW); | 1533 set_server_initial_stream_flow_control_receive_window(kStreamIFCW); |
| 1552 set_server_initial_session_flow_control_receive_window(kSessionIFCW); | 1534 set_server_initial_session_flow_control_receive_window(kSessionIFCW); |
| 1553 | 1535 |
| 1554 ASSERT_TRUE(Initialize()); | 1536 ASSERT_TRUE(Initialize()); |
| 1555 | 1537 |
| 1556 // Wait for crypto handshake to finish. This should have contributed to the | 1538 // Wait for crypto handshake to finish. This should have contributed to the |
| 1557 // crypto stream flow control window, but not affected the session flow | 1539 // crypto stream flow control window, but not affected the session flow |
| 1558 // control window. | 1540 // control window. |
| (...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2616 client_->client()->WaitForCryptoHandshakeConfirmed(); | 2598 client_->client()->WaitForCryptoHandshakeConfirmed(); |
| 2617 SetPacketLossPercentage(1); | 2599 SetPacketLossPercentage(1); |
| 2618 client_->SendRequest("/huge_response"); | 2600 client_->SendRequest("/huge_response"); |
| 2619 client_->WaitForResponse(); | 2601 client_->WaitForResponse(); |
| 2620 VerifyCleanConnection(false); | 2602 VerifyCleanConnection(false); |
| 2621 } | 2603 } |
| 2622 | 2604 |
| 2623 } // namespace | 2605 } // namespace |
| 2624 } // namespace test | 2606 } // namespace test |
| 2625 } // namespace net | 2607 } // namespace net |
| OLD | NEW |