OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "net/quic/quic_sent_packet_manager.h" | 5 #include "net/quic/quic_sent_packet_manager.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "net/quic/quic_flags.h" | 8 #include "net/quic/quic_flags.h" |
9 #include "net/quic/test_tools/quic_config_peer.h" | 9 #include "net/quic/test_tools/quic_config_peer.h" |
10 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" | 10 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" |
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1309 | 1309 |
1310 TEST_F(QuicSentPacketManagerTest, NegotiateCongestionControlFromOptions) { | 1310 TEST_F(QuicSentPacketManagerTest, NegotiateCongestionControlFromOptions) { |
1311 ValueRestore<bool> old_flag(&FLAGS_quic_allow_bbr, true); | 1311 ValueRestore<bool> old_flag(&FLAGS_quic_allow_bbr, true); |
1312 QuicConfig config; | 1312 QuicConfig config; |
1313 QuicTagVector options; | 1313 QuicTagVector options; |
1314 | 1314 |
1315 options.push_back(kRENO); | 1315 options.push_back(kRENO); |
1316 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); | 1316 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); |
1317 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); | 1317 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); |
1318 manager_.SetFromConfig(config); | 1318 manager_.SetFromConfig(config); |
1319 EXPECT_EQ(kReno, QuicSentPacketManagerPeer::GetCongestionControlAlgorithm( | 1319 EXPECT_EQ(kReno, QuicSentPacketManagerPeer::GetSendAlgorithm( |
1320 manager_)->GetCongestionControlType()); | 1320 manager_)->GetCongestionControlType()); |
1321 | 1321 |
1322 // TODO(rtenneti): Enable the following code after BBR code is checked in. | 1322 // TODO(rtenneti): Enable the following code after BBR code is checked in. |
1323 #if 0 | 1323 #if 0 |
1324 options.clear(); | 1324 options.clear(); |
1325 options.push_back(kTBBR); | 1325 options.push_back(kTBBR); |
1326 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); | 1326 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); |
1327 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); | 1327 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); |
1328 manager_.SetFromConfig(config); | 1328 manager_.SetFromConfig(config); |
1329 EXPECT_EQ(kBBR, QuicSentPacketManagerPeer::GetCongestionControlAlgorithm( | 1329 EXPECT_EQ(kBBR, QuicSentPacketManagerPeer::GetSendAlgorithm( |
1330 manager_)->GetCongestionControlType()); | 1330 manager_)->GetCongestionControlType()); |
1331 #endif | 1331 #endif |
1332 } | 1332 } |
1333 | 1333 |
1334 TEST_F(QuicSentPacketManagerTest, NegotiateNumConnectionsFromOptions) { | 1334 TEST_F(QuicSentPacketManagerTest, NegotiateNumConnectionsFromOptions) { |
1335 QuicConfig config; | 1335 QuicConfig config; |
1336 QuicTagVector options; | 1336 QuicTagVector options; |
1337 | 1337 |
1338 options.push_back(k1CON); | 1338 options.push_back(k1CON); |
1339 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); | 1339 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1393 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); | 1393 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); |
1394 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); | 1394 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); |
1395 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) | 1395 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) |
1396 .WillOnce(Return(100 * kDefaultTCPMSS)); | 1396 .WillOnce(Return(100 * kDefaultTCPMSS)); |
1397 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); | 1397 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); |
1398 manager_.SetFromConfig(config); | 1398 manager_.SetFromConfig(config); |
1399 | 1399 |
1400 EXPECT_TRUE(manager_.using_pacing()); | 1400 EXPECT_TRUE(manager_.using_pacing()); |
1401 } | 1401 } |
1402 | 1402 |
| 1403 TEST_F(QuicSentPacketManagerTest, NegotiateReceiveWindowFromOptions) { |
| 1404 EXPECT_EQ(kDefaultSocketReceiveBuffer, |
| 1405 QuicSentPacketManagerPeer::GetReceiveWindow(&manager_)); |
| 1406 |
| 1407 // Try to set a size below the minimum and ensure it gets set to the min. |
| 1408 QuicConfig client_config; |
| 1409 QuicConfigPeer::SetReceivedSocketReceiveBuffer(&client_config, 1024); |
| 1410 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); |
| 1411 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); |
| 1412 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) |
| 1413 .WillOnce(Return(100 * kDefaultTCPMSS)); |
| 1414 manager_.SetFromConfig(client_config); |
| 1415 |
| 1416 EXPECT_EQ(kMinSocketReceiveBuffer, |
| 1417 QuicSentPacketManagerPeer::GetReceiveWindow(&manager_)); |
| 1418 |
| 1419 // Ensure the smaller send window only allows 16 packets to be sent. |
| 1420 for (QuicPacketSequenceNumber i = 1; i <= 16; ++i) { |
| 1421 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)).WillOnce(Return( |
| 1422 QuicTime::Delta::Zero())); |
| 1423 EXPECT_EQ(QuicTime::Delta::Zero(), |
| 1424 manager_.TimeUntilSend(clock_.Now(), HAS_RETRANSMITTABLE_DATA)); |
| 1425 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, BytesInFlight(), i, |
| 1426 1024, HAS_RETRANSMITTABLE_DATA)) |
| 1427 .WillOnce(Return(true)); |
| 1428 SerializedPacket packet(CreatePacket(i, true)); |
| 1429 manager_.OnPacketSent(&packet, 0, clock_.Now(), 1024, |
| 1430 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA); |
| 1431 } |
| 1432 EXPECT_EQ(QuicTime::Delta::Infinite(), |
| 1433 manager_.TimeUntilSend(clock_.Now(), HAS_RETRANSMITTABLE_DATA)); |
| 1434 } |
| 1435 |
1403 TEST_F(QuicSentPacketManagerTest, UseInitialRoundTripTimeToSend) { | 1436 TEST_F(QuicSentPacketManagerTest, UseInitialRoundTripTimeToSend) { |
1404 uint32 initial_rtt_us = 325000; | 1437 uint32 initial_rtt_us = 325000; |
1405 EXPECT_NE(initial_rtt_us, | 1438 EXPECT_NE(initial_rtt_us, |
1406 manager_.GetRttStats()->SmoothedRtt().ToMicroseconds()); | 1439 manager_.GetRttStats()->SmoothedRtt().ToMicroseconds()); |
1407 | 1440 |
1408 QuicConfig config; | 1441 QuicConfig config; |
1409 config.SetInitialRoundTripTimeUsToSend(initial_rtt_us); | 1442 config.SetInitialRoundTripTimeUsToSend(initial_rtt_us); |
1410 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); | 1443 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); |
1411 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); | 1444 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)); |
1412 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) | 1445 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) |
1413 .WillOnce(Return(100 * kDefaultTCPMSS)); | 1446 .WillOnce(Return(100 * kDefaultTCPMSS)); |
1414 manager_.SetFromConfig(config); | 1447 manager_.SetFromConfig(config); |
1415 | 1448 |
1416 EXPECT_EQ(initial_rtt_us, | 1449 EXPECT_EQ(initial_rtt_us, |
1417 manager_.GetRttStats()->SmoothedRtt().ToMicroseconds()); | 1450 manager_.GetRttStats()->SmoothedRtt().ToMicroseconds()); |
1418 } | 1451 } |
1419 | 1452 |
1420 } // namespace | 1453 } // namespace |
1421 } // namespace test | 1454 } // namespace test |
1422 } // namespace net | 1455 } // namespace net |
OLD | NEW |