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