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 "net/quic/core/quic_connection.h" | 5 #include "net/quic/core/quic_connection.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <memory> | 8 #include <memory> |
9 #include <ostream> | 9 #include <ostream> |
10 #include <utility> | 10 #include <utility> |
(...skipping 3480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3491 EXPECT_EQ(4u, connection_.sent_packet_manager().GetConsecutiveRtoCount()); | 3491 EXPECT_EQ(4u, connection_.sent_packet_manager().GetConsecutiveRtoCount()); |
3492 // This time, we should time out. | 3492 // This time, we should time out. |
3493 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_TOO_MANY_RTOS, _, | 3493 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_TOO_MANY_RTOS, _, |
3494 ConnectionCloseSource::FROM_SELF)); | 3494 ConnectionCloseSource::FROM_SELF)); |
3495 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 3495 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
3496 connection_.GetRetransmissionAlarm()->Fire(); | 3496 connection_.GetRetransmissionAlarm()->Fire(); |
3497 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); | 3497 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); |
3498 EXPECT_FALSE(connection_.connected()); | 3498 EXPECT_FALSE(connection_.connected()); |
3499 } | 3499 } |
3500 | 3500 |
3501 TEST_P(QuicConnectionTest, TimeoutAfter5ServerRTOs) { | |
3502 FLAGS_quic_reloadable_flag_quic_only_5rto_client_side = true; | |
3503 connection_.SetMaxTailLossProbes(2); | |
3504 set_perspective(Perspective::IS_SERVER); | |
3505 QuicFramerPeer::SetPerspective(QuicConnectionPeer::GetFramer(&connection_), | |
3506 Perspective::IS_SERVER); | |
3507 creator_->StopSendingVersion(); | |
3508 EXPECT_TRUE(connection_.connected()); | |
3509 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); | |
3510 QuicConfig config; | |
3511 QuicTagVector connection_options; | |
3512 connection_options.push_back(k5RTO); | |
3513 config.SetConnectionOptionsToSend(connection_options); | |
3514 connection_.SetFromConfig(config); | |
3515 | |
3516 // Send stream data. | |
3517 SendStreamDataToPeer(kClientDataStreamId1, "foo", 0, kFin, nullptr); | |
3518 | |
3519 EXPECT_CALL(visitor_, OnPathDegrading()); | |
3520 // Fire the retransmission alarm 6 times, twice for TLP and 4 times for RTO. | |
3521 for (int i = 0; i < 6; ++i) { | |
3522 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | |
3523 connection_.GetRetransmissionAlarm()->Fire(); | |
3524 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); | |
3525 EXPECT_TRUE(connection_.connected()); | |
3526 } | |
3527 | |
3528 EXPECT_EQ(2u, connection_.sent_packet_manager().GetConsecutiveTlpCount()); | |
3529 EXPECT_EQ(4u, connection_.sent_packet_manager().GetConsecutiveRtoCount()); | |
3530 // The 5th RTO should not time out server side. | |
3531 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | |
3532 connection_.GetRetransmissionAlarm()->Fire(); | |
3533 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); | |
3534 EXPECT_TRUE(connection_.connected()); | |
3535 } | |
3536 | |
3537 TEST_P(QuicConnectionTest, SendScheduler) { | 3501 TEST_P(QuicConnectionTest, SendScheduler) { |
3538 // Test that if we send a packet without delay, it is not queued. | 3502 // Test that if we send a packet without delay, it is not queued. |
3539 QuicPacket* packet = ConstructDataPacket(kDefaultPathId, 1, !kHasStopWaiting); | 3503 QuicPacket* packet = ConstructDataPacket(kDefaultPathId, 1, !kHasStopWaiting); |
3540 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 3504 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
3541 connection_.SendPacket(ENCRYPTION_NONE, kDefaultPathId, 1, packet, | 3505 connection_.SendPacket(ENCRYPTION_NONE, kDefaultPathId, 1, packet, |
3542 HAS_RETRANSMITTABLE_DATA, false, false); | 3506 HAS_RETRANSMITTABLE_DATA, false, false); |
3543 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 3507 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
3544 } | 3508 } |
3545 | 3509 |
3546 TEST_P(QuicConnectionTest, FailToSendFirstPacket) { | 3510 TEST_P(QuicConnectionTest, FailToSendFirstPacket) { |
(...skipping 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5112 error_details, ConnectionCloseSource::FROM_PEER)); | 5076 error_details, ConnectionCloseSource::FROM_PEER)); |
5113 connection_.set_perspective(Perspective::IS_CLIENT); | 5077 connection_.set_perspective(Perspective::IS_CLIENT); |
5114 connection_.CloseConnection(QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT, | 5078 connection_.CloseConnection(QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT, |
5115 error_details, | 5079 error_details, |
5116 ConnectionCloseBehavior::SILENT_CLOSE); | 5080 ConnectionCloseBehavior::SILENT_CLOSE); |
5117 } | 5081 } |
5118 | 5082 |
5119 } // namespace | 5083 } // namespace |
5120 } // namespace test | 5084 } // namespace test |
5121 } // namespace net | 5085 } // namespace net |
OLD | NEW |