| 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 3536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3547 VLOG(1) << "sending data packet"; | 3547 VLOG(1) << "sending data packet"; |
| 3548 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 0, !kFin, | 3548 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 0, !kFin, |
| 3549 nullptr); | 3549 nullptr); |
| 3550 connection_.GetTimeoutAlarm()->Fire(); | 3550 connection_.GetTimeoutAlarm()->Fire(); |
| 3551 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1)); | 3551 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1)); |
| 3552 } | 3552 } |
| 3553 EXPECT_FALSE(connection_.connected()); | 3553 EXPECT_FALSE(connection_.connected()); |
| 3554 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); | 3554 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); |
| 3555 } | 3555 } |
| 3556 | 3556 |
| 3557 TEST_P(QuicConnectionTest, TimeoutAfter5RTOs) { | 3557 TEST_P(QuicConnectionTest, TimeoutAfter5ClientRTOs) { |
| 3558 connection_.SetMaxTailLossProbes(kDefaultPathId, 2); | 3558 connection_.SetMaxTailLossProbes(kDefaultPathId, 2); |
| 3559 EXPECT_TRUE(connection_.connected()); | 3559 EXPECT_TRUE(connection_.connected()); |
| 3560 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); | 3560 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); |
| 3561 QuicConfig config; | 3561 QuicConfig config; |
| 3562 QuicTagVector connection_options; | 3562 QuicTagVector connection_options; |
| 3563 connection_options.push_back(k5RTO); | 3563 connection_options.push_back(k5RTO); |
| 3564 config.SetConnectionOptionsToSend(connection_options); | 3564 config.SetConnectionOptionsToSend(connection_options); |
| 3565 connection_.SetFromConfig(config); | 3565 connection_.SetFromConfig(config); |
| 3566 | 3566 |
| 3567 // Send stream data. | 3567 // Send stream data. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3580 EXPECT_EQ(4u, connection_.sent_packet_manager().GetConsecutiveRtoCount()); | 3580 EXPECT_EQ(4u, connection_.sent_packet_manager().GetConsecutiveRtoCount()); |
| 3581 // This time, we should time out. | 3581 // This time, we should time out. |
| 3582 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_TOO_MANY_RTOS, _, | 3582 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_TOO_MANY_RTOS, _, |
| 3583 ConnectionCloseSource::FROM_SELF)); | 3583 ConnectionCloseSource::FROM_SELF)); |
| 3584 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 3584 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
| 3585 connection_.GetRetransmissionAlarm()->Fire(); | 3585 connection_.GetRetransmissionAlarm()->Fire(); |
| 3586 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); | 3586 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); |
| 3587 EXPECT_FALSE(connection_.connected()); | 3587 EXPECT_FALSE(connection_.connected()); |
| 3588 } | 3588 } |
| 3589 | 3589 |
| 3590 TEST_P(QuicConnectionTest, TimeoutAfter5ServerRTOs) { |
| 3591 FLAGS_quic_only_5rto_client_side = true; |
| 3592 connection_.SetMaxTailLossProbes(kDefaultPathId, 2); |
| 3593 QuicConnectionPeer::SetPerspective(&connection_, Perspective::IS_SERVER); |
| 3594 QuicFramerPeer::SetPerspective(QuicConnectionPeer::GetFramer(&connection_), |
| 3595 Perspective::IS_SERVER); |
| 3596 creator_->StopSendingVersion(); |
| 3597 EXPECT_TRUE(connection_.connected()); |
| 3598 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); |
| 3599 QuicConfig config; |
| 3600 QuicTagVector connection_options; |
| 3601 connection_options.push_back(k5RTO); |
| 3602 config.SetConnectionOptionsToSend(connection_options); |
| 3603 connection_.SetFromConfig(config); |
| 3604 |
| 3605 // Send stream data. |
| 3606 SendStreamDataToPeer(kClientDataStreamId1, "foo", 0, kFin, nullptr); |
| 3607 |
| 3608 EXPECT_CALL(visitor_, OnPathDegrading()); |
| 3609 // Fire the retransmission alarm 6 times, twice for TLP and 4 times for RTO. |
| 3610 for (int i = 0; i < 6; ++i) { |
| 3611 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
| 3612 connection_.GetRetransmissionAlarm()->Fire(); |
| 3613 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); |
| 3614 EXPECT_TRUE(connection_.connected()); |
| 3615 } |
| 3616 |
| 3617 EXPECT_EQ(2u, connection_.sent_packet_manager().GetConsecutiveTlpCount()); |
| 3618 EXPECT_EQ(4u, connection_.sent_packet_manager().GetConsecutiveRtoCount()); |
| 3619 // The 5th RTO should not time out server side. |
| 3620 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
| 3621 connection_.GetRetransmissionAlarm()->Fire(); |
| 3622 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); |
| 3623 EXPECT_TRUE(connection_.connected()); |
| 3624 } |
| 3625 |
| 3590 TEST_P(QuicConnectionTest, SendScheduler) { | 3626 TEST_P(QuicConnectionTest, SendScheduler) { |
| 3591 // Test that if we send a packet without delay, it is not queued. | 3627 // Test that if we send a packet without delay, it is not queued. |
| 3592 QuicPacket* packet = | 3628 QuicPacket* packet = |
| 3593 ConstructDataPacket(kDefaultPathId, 1, !kEntropyFlag, !kHasStopWaiting); | 3629 ConstructDataPacket(kDefaultPathId, 1, !kEntropyFlag, !kHasStopWaiting); |
| 3594 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 3630 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
| 3595 connection_.SendPacket(ENCRYPTION_NONE, kDefaultPathId, 1, packet, | 3631 connection_.SendPacket(ENCRYPTION_NONE, kDefaultPathId, 1, packet, |
| 3596 kTestEntropyHash, HAS_RETRANSMITTABLE_DATA, false, | 3632 kTestEntropyHash, HAS_RETRANSMITTABLE_DATA, false, |
| 3597 false); | 3633 false); |
| 3598 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 3634 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
| 3599 } | 3635 } |
| (...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5222 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); | 5258 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); |
| 5223 EXPECT_EQ(1u, writer_->frame_count()); | 5259 EXPECT_EQ(1u, writer_->frame_count()); |
| 5224 EXPECT_FALSE(writer_->connection_close_frames().empty()); | 5260 EXPECT_FALSE(writer_->connection_close_frames().empty()); |
| 5225 // Ack frame is not bundled in connection close packet. | 5261 // Ack frame is not bundled in connection close packet. |
| 5226 EXPECT_TRUE(writer_->ack_frames().empty()); | 5262 EXPECT_TRUE(writer_->ack_frames().empty()); |
| 5227 } | 5263 } |
| 5228 | 5264 |
| 5229 } // namespace | 5265 } // namespace |
| 5230 } // namespace test | 5266 } // namespace test |
| 5231 } // namespace net | 5267 } // namespace net |
| OLD | NEW |