| 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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 server_config_.SetInitialStreamFlowControlWindowToSend(window); | 358 server_config_.SetInitialStreamFlowControlWindowToSend(window); |
| 359 } | 359 } |
| 360 | 360 |
| 361 void set_server_initial_session_flow_control_receive_window(uint32_t window) { | 361 void set_server_initial_session_flow_control_receive_window(uint32_t window) { |
| 362 CHECK(server_thread_.get() == nullptr); | 362 CHECK(server_thread_.get() == nullptr); |
| 363 DVLOG(1) << "Setting server initial session flow control window: " | 363 DVLOG(1) << "Setting server initial session flow control window: " |
| 364 << window; | 364 << window; |
| 365 server_config_.SetInitialSessionFlowControlWindowToSend(window); | 365 server_config_.SetInitialSessionFlowControlWindowToSend(window); |
| 366 } | 366 } |
| 367 | 367 |
| 368 const QuicSentPacketManager* GetSentPacketManagerFromFirstServerSession() | 368 const QuicSentPacketManagerInterface* |
| 369 const { | 369 GetSentPacketManagerFromFirstServerSession() const { |
| 370 QuicDispatcher* dispatcher = | 370 QuicDispatcher* dispatcher = |
| 371 QuicServerPeer::GetDispatcher(server_thread_->server()); | 371 QuicServerPeer::GetDispatcher(server_thread_->server()); |
| 372 QuicSession* session = dispatcher->session_map().begin()->second; | 372 QuicSession* session = dispatcher->session_map().begin()->second; |
| 373 return &session->connection()->sent_packet_manager(); | 373 return &session->connection()->sent_packet_manager(); |
| 374 } | 374 } |
| 375 | 375 |
| 376 bool Initialize() { | 376 bool Initialize() { |
| 377 QuicTagVector copt; | 377 QuicTagVector copt; |
| 378 server_config_.SetConnectionOptionsToSend(copt); | 378 server_config_.SetConnectionOptionsToSend(copt); |
| 379 | 379 |
| (...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 EXPECT_EQ(QUIC_TOO_MANY_OPEN_STREAMS, client_->connection_error()); | 1193 EXPECT_EQ(QUIC_TOO_MANY_OPEN_STREAMS, client_->connection_error()); |
| 1194 } else { | 1194 } else { |
| 1195 EXPECT_TRUE(client_->connected()); | 1195 EXPECT_TRUE(client_->connected()); |
| 1196 EXPECT_EQ(QUIC_REFUSED_STREAM, client_->stream_error()); | 1196 EXPECT_EQ(QUIC_REFUSED_STREAM, client_->stream_error()); |
| 1197 EXPECT_EQ(QUIC_NO_ERROR, client_->connection_error()); | 1197 EXPECT_EQ(QUIC_NO_ERROR, client_->connection_error()); |
| 1198 } | 1198 } |
| 1199 } | 1199 } |
| 1200 | 1200 |
| 1201 TEST_P(EndToEndTest, NegotiateCongestionControl) { | 1201 TEST_P(EndToEndTest, NegotiateCongestionControl) { |
| 1202 ValueRestore<bool> old_flag(&FLAGS_quic_allow_bbr, true); | 1202 ValueRestore<bool> old_flag(&FLAGS_quic_allow_bbr, true); |
| 1203 // Disable this flag because if connection uses multipath sent packet manager, |
| 1204 // static_cast here does not work. |
| 1205 FLAGS_quic_enable_multipath = false; |
| 1203 ASSERT_TRUE(Initialize()); | 1206 ASSERT_TRUE(Initialize()); |
| 1204 client_->client()->WaitForCryptoHandshakeConfirmed(); | 1207 client_->client()->WaitForCryptoHandshakeConfirmed(); |
| 1205 | 1208 |
| 1206 CongestionControlType expected_congestion_control_type = kReno; | 1209 CongestionControlType expected_congestion_control_type = kReno; |
| 1207 switch (GetParam().congestion_control_tag) { | 1210 switch (GetParam().congestion_control_tag) { |
| 1208 case kRENO: | 1211 case kRENO: |
| 1209 expected_congestion_control_type = kReno; | 1212 expected_congestion_control_type = kReno; |
| 1210 break; | 1213 break; |
| 1211 case kTBBR: | 1214 case kTBBR: |
| 1212 expected_congestion_control_type = kBBR; | 1215 expected_congestion_control_type = kBBR; |
| 1213 break; | 1216 break; |
| 1214 case kQBIC: | 1217 case kQBIC: |
| 1215 expected_congestion_control_type = kCubic; | 1218 expected_congestion_control_type = kCubic; |
| 1216 break; | 1219 break; |
| 1217 default: | 1220 default: |
| 1218 DLOG(FATAL) << "Unexpected congestion control tag"; | 1221 DLOG(FATAL) << "Unexpected congestion control tag"; |
| 1219 } | 1222 } |
| 1220 | 1223 |
| 1221 EXPECT_EQ(expected_congestion_control_type, | 1224 EXPECT_EQ(expected_congestion_control_type, |
| 1222 QuicSentPacketManagerPeer::GetSendAlgorithm( | 1225 QuicSentPacketManagerPeer::GetSendAlgorithm( |
| 1223 *GetSentPacketManagerFromFirstServerSession()) | 1226 *static_cast<const QuicSentPacketManager*>( |
| 1227 GetSentPacketManagerFromFirstServerSession())) |
| 1224 ->GetCongestionControlType()); | 1228 ->GetCongestionControlType()); |
| 1225 } | 1229 } |
| 1226 | 1230 |
| 1227 TEST_P(EndToEndTest, LimitMaxOpenStreams) { | 1231 TEST_P(EndToEndTest, LimitMaxOpenStreams) { |
| 1228 // Server limits the number of max streams to 2. | 1232 // Server limits the number of max streams to 2. |
| 1229 server_config_.SetMaxStreamsPerConnection(2, 2); | 1233 server_config_.SetMaxStreamsPerConnection(2, 2); |
| 1230 // Client tries to negotiate for 10. | 1234 // Client tries to negotiate for 10. |
| 1231 client_config_.SetMaxStreamsPerConnection(10, 5); | 1235 client_config_.SetMaxStreamsPerConnection(10, 5); |
| 1232 | 1236 |
| 1233 ASSERT_TRUE(Initialize()); | 1237 ASSERT_TRUE(Initialize()); |
| 1234 client_->client()->WaitForCryptoHandshakeConfirmed(); | 1238 client_->client()->WaitForCryptoHandshakeConfirmed(); |
| 1235 QuicConfig* client_negotiated_config = client_->client()->session()->config(); | 1239 QuicConfig* client_negotiated_config = client_->client()->session()->config(); |
| 1236 EXPECT_EQ(2u, client_negotiated_config->MaxStreamsPerConnection()); | 1240 EXPECT_EQ(2u, client_negotiated_config->MaxStreamsPerConnection()); |
| 1237 } | 1241 } |
| 1238 | 1242 |
| 1239 TEST_P(EndToEndTest, ClientSuggestsRTT) { | 1243 TEST_P(EndToEndTest, ClientSuggestsRTT) { |
| 1240 // Client suggests initial RTT, verify it is used. | 1244 // Client suggests initial RTT, verify it is used. |
| 1241 const uint32_t kInitialRTT = 20000; | 1245 const uint32_t kInitialRTT = 20000; |
| 1242 client_config_.SetInitialRoundTripTimeUsToSend(kInitialRTT); | 1246 client_config_.SetInitialRoundTripTimeUsToSend(kInitialRTT); |
| 1243 | 1247 |
| 1244 ASSERT_TRUE(Initialize()); | 1248 ASSERT_TRUE(Initialize()); |
| 1245 client_->client()->WaitForCryptoHandshakeConfirmed(); | 1249 client_->client()->WaitForCryptoHandshakeConfirmed(); |
| 1246 server_thread_->WaitForCryptoHandshakeConfirmed(); | 1250 server_thread_->WaitForCryptoHandshakeConfirmed(); |
| 1247 | 1251 |
| 1248 // Pause the server so we can access the server's internals without races. | 1252 // Pause the server so we can access the server's internals without races. |
| 1249 server_thread_->Pause(); | 1253 server_thread_->Pause(); |
| 1250 QuicDispatcher* dispatcher = | 1254 QuicDispatcher* dispatcher = |
| 1251 QuicServerPeer::GetDispatcher(server_thread_->server()); | 1255 QuicServerPeer::GetDispatcher(server_thread_->server()); |
| 1252 ASSERT_EQ(1u, dispatcher->session_map().size()); | 1256 ASSERT_EQ(1u, dispatcher->session_map().size()); |
| 1253 const QuicSentPacketManager& client_sent_packet_manager = | 1257 const QuicSentPacketManagerInterface& client_sent_packet_manager = |
| 1254 client_->client()->session()->connection()->sent_packet_manager(); | 1258 client_->client()->session()->connection()->sent_packet_manager(); |
| 1255 const QuicSentPacketManager& server_sent_packet_manager = | 1259 const QuicSentPacketManagerInterface* server_sent_packet_manager = |
| 1256 *GetSentPacketManagerFromFirstServerSession(); | 1260 GetSentPacketManagerFromFirstServerSession(); |
| 1257 | 1261 |
| 1258 EXPECT_EQ(kInitialRTT, | 1262 EXPECT_EQ(kInitialRTT, |
| 1259 client_sent_packet_manager.GetRttStats()->initial_rtt_us()); | 1263 client_sent_packet_manager.GetRttStats()->initial_rtt_us()); |
| 1260 EXPECT_EQ(kInitialRTT, | 1264 EXPECT_EQ(kInitialRTT, |
| 1261 server_sent_packet_manager.GetRttStats()->initial_rtt_us()); | 1265 server_sent_packet_manager->GetRttStats()->initial_rtt_us()); |
| 1262 server_thread_->Resume(); | 1266 server_thread_->Resume(); |
| 1263 } | 1267 } |
| 1264 | 1268 |
| 1265 TEST_P(EndToEndTest, MaxInitialRTT) { | 1269 TEST_P(EndToEndTest, MaxInitialRTT) { |
| 1266 // Client tries to suggest twice the server's max initial rtt and the server | 1270 // Client tries to suggest twice the server's max initial rtt and the server |
| 1267 // uses the max. | 1271 // uses the max. |
| 1268 client_config_.SetInitialRoundTripTimeUsToSend(2 * | 1272 client_config_.SetInitialRoundTripTimeUsToSend(2 * |
| 1269 kMaxInitialRoundTripTimeUs); | 1273 kMaxInitialRoundTripTimeUs); |
| 1270 | 1274 |
| 1271 ASSERT_TRUE(Initialize()); | 1275 ASSERT_TRUE(Initialize()); |
| 1272 client_->client()->WaitForCryptoHandshakeConfirmed(); | 1276 client_->client()->WaitForCryptoHandshakeConfirmed(); |
| 1273 server_thread_->WaitForCryptoHandshakeConfirmed(); | 1277 server_thread_->WaitForCryptoHandshakeConfirmed(); |
| 1274 | 1278 |
| 1275 // Pause the server so we can access the server's internals without races. | 1279 // Pause the server so we can access the server's internals without races. |
| 1276 server_thread_->Pause(); | 1280 server_thread_->Pause(); |
| 1277 QuicDispatcher* dispatcher = | 1281 QuicDispatcher* dispatcher = |
| 1278 QuicServerPeer::GetDispatcher(server_thread_->server()); | 1282 QuicServerPeer::GetDispatcher(server_thread_->server()); |
| 1279 ASSERT_EQ(1u, dispatcher->session_map().size()); | 1283 ASSERT_EQ(1u, dispatcher->session_map().size()); |
| 1280 QuicSession* session = dispatcher->session_map().begin()->second; | 1284 QuicSession* session = dispatcher->session_map().begin()->second; |
| 1281 const QuicSentPacketManager& client_sent_packet_manager = | 1285 const QuicSentPacketManagerInterface& client_sent_packet_manager = |
| 1282 client_->client()->session()->connection()->sent_packet_manager(); | 1286 client_->client()->session()->connection()->sent_packet_manager(); |
| 1283 | 1287 |
| 1284 // Now that acks have been exchanged, the RTT estimate has decreased on the | 1288 // Now that acks have been exchanged, the RTT estimate has decreased on the |
| 1285 // server and is not infinite on the client. | 1289 // server and is not infinite on the client. |
| 1286 EXPECT_FALSE( | 1290 EXPECT_FALSE( |
| 1287 client_sent_packet_manager.GetRttStats()->smoothed_rtt().IsInfinite()); | 1291 client_sent_packet_manager.GetRttStats()->smoothed_rtt().IsInfinite()); |
| 1288 const RttStats& server_rtt_stats = | 1292 const RttStats& server_rtt_stats = |
| 1289 *session->connection()->sent_packet_manager().GetRttStats(); | 1293 *session->connection()->sent_packet_manager().GetRttStats(); |
| 1290 EXPECT_EQ(static_cast<int64_t>(kMaxInitialRoundTripTimeUs), | 1294 EXPECT_EQ(static_cast<int64_t>(kMaxInitialRoundTripTimeUs), |
| 1291 server_rtt_stats.initial_rtt_us()); | 1295 server_rtt_stats.initial_rtt_us()); |
| 1292 EXPECT_GE(static_cast<int64_t>(kMaxInitialRoundTripTimeUs), | 1296 EXPECT_GE(static_cast<int64_t>(kMaxInitialRoundTripTimeUs), |
| 1293 server_rtt_stats.smoothed_rtt().ToMicroseconds()); | 1297 server_rtt_stats.smoothed_rtt().ToMicroseconds()); |
| 1294 server_thread_->Resume(); | 1298 server_thread_->Resume(); |
| 1295 } | 1299 } |
| 1296 | 1300 |
| 1297 TEST_P(EndToEndTest, MinInitialRTT) { | 1301 TEST_P(EndToEndTest, MinInitialRTT) { |
| 1298 // Client tries to suggest 0 and the server uses the default. | 1302 // Client tries to suggest 0 and the server uses the default. |
| 1299 client_config_.SetInitialRoundTripTimeUsToSend(0); | 1303 client_config_.SetInitialRoundTripTimeUsToSend(0); |
| 1300 | 1304 |
| 1301 ASSERT_TRUE(Initialize()); | 1305 ASSERT_TRUE(Initialize()); |
| 1302 client_->client()->WaitForCryptoHandshakeConfirmed(); | 1306 client_->client()->WaitForCryptoHandshakeConfirmed(); |
| 1303 server_thread_->WaitForCryptoHandshakeConfirmed(); | 1307 server_thread_->WaitForCryptoHandshakeConfirmed(); |
| 1304 | 1308 |
| 1305 // Pause the server so we can access the server's internals without races. | 1309 // Pause the server so we can access the server's internals without races. |
| 1306 server_thread_->Pause(); | 1310 server_thread_->Pause(); |
| 1307 QuicDispatcher* dispatcher = | 1311 QuicDispatcher* dispatcher = |
| 1308 QuicServerPeer::GetDispatcher(server_thread_->server()); | 1312 QuicServerPeer::GetDispatcher(server_thread_->server()); |
| 1309 ASSERT_EQ(1u, dispatcher->session_map().size()); | 1313 ASSERT_EQ(1u, dispatcher->session_map().size()); |
| 1310 QuicSession* session = dispatcher->session_map().begin()->second; | 1314 QuicSession* session = dispatcher->session_map().begin()->second; |
| 1311 const QuicSentPacketManager& client_sent_packet_manager = | 1315 const QuicSentPacketManagerInterface& client_sent_packet_manager = |
| 1312 client_->client()->session()->connection()->sent_packet_manager(); | 1316 client_->client()->session()->connection()->sent_packet_manager(); |
| 1313 const QuicSentPacketManager& server_sent_packet_manager = | 1317 const QuicSentPacketManagerInterface& server_sent_packet_manager = |
| 1314 session->connection()->sent_packet_manager(); | 1318 session->connection()->sent_packet_manager(); |
| 1315 | 1319 |
| 1316 // Now that acks have been exchanged, the RTT estimate has decreased on the | 1320 // Now that acks have been exchanged, the RTT estimate has decreased on the |
| 1317 // server and is not infinite on the client. | 1321 // server and is not infinite on the client. |
| 1318 EXPECT_FALSE( | 1322 EXPECT_FALSE( |
| 1319 client_sent_packet_manager.GetRttStats()->smoothed_rtt().IsInfinite()); | 1323 client_sent_packet_manager.GetRttStats()->smoothed_rtt().IsInfinite()); |
| 1320 // Expect the default rtt of 100ms. | 1324 // Expect the default rtt of 100ms. |
| 1321 EXPECT_EQ(static_cast<int64_t>(100 * kNumMicrosPerMilli), | 1325 EXPECT_EQ(static_cast<int64_t>(100 * kNumMicrosPerMilli), |
| 1322 server_sent_packet_manager.GetRttStats()->initial_rtt_us()); | 1326 server_sent_packet_manager.GetRttStats()->initial_rtt_us()); |
| 1323 // Ensure the bandwidth is valid. | 1327 // Ensure the bandwidth is valid. |
| (...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2725 client_->WaitForResponse(); | 2729 client_->WaitForResponse(); |
| 2726 // TODO(fayang): Fix this test to work with stateless rejects. | 2730 // TODO(fayang): Fix this test to work with stateless rejects. |
| 2727 if (!BothSidesSupportStatelessRejects()) { | 2731 if (!BothSidesSupportStatelessRejects()) { |
| 2728 VerifyCleanConnection(false); | 2732 VerifyCleanConnection(false); |
| 2729 } | 2733 } |
| 2730 } | 2734 } |
| 2731 | 2735 |
| 2732 } // namespace | 2736 } // namespace |
| 2733 } // namespace test | 2737 } // namespace test |
| 2734 } // namespace net | 2738 } // namespace net |
| OLD | NEW |