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/quic_connection.h" | 5 #include "net/quic/quic_connection.h" |
6 | 6 |
7 #include <ostream> | 7 #include <ostream> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 3313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3324 VLOG(1) << "sending data packet"; | 3324 VLOG(1) << "sending data packet"; |
3325 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 0, !kFin, | 3325 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 0, !kFin, |
3326 nullptr); | 3326 nullptr); |
3327 connection_.GetTimeoutAlarm()->Fire(); | 3327 connection_.GetTimeoutAlarm()->Fire(); |
3328 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1)); | 3328 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1)); |
3329 } | 3329 } |
3330 EXPECT_FALSE(connection_.connected()); | 3330 EXPECT_FALSE(connection_.connected()); |
3331 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); | 3331 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); |
3332 } | 3332 } |
3333 | 3333 |
| 3334 TEST_P(QuicConnectionTest, TimeoutAfter5RTOs) { |
| 3335 FLAGS_quic_enable_rto_timeout = true; |
| 3336 QuicSentPacketManagerPeer::SetMaxTailLossProbes(manager_, 2); |
| 3337 EXPECT_TRUE(connection_.connected()); |
| 3338 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); |
| 3339 QuicConfig config; |
| 3340 QuicTagVector connection_options; |
| 3341 connection_options.push_back(k5RTO); |
| 3342 config.SetConnectionOptionsToSend(connection_options); |
| 3343 connection_.SetFromConfig(config); |
| 3344 |
| 3345 // Send stream data. |
| 3346 SendStreamDataToPeer(kClientDataStreamId1, "foo", 0, kFin, nullptr); |
| 3347 |
| 3348 EXPECT_CALL(visitor_, OnPathDegrading()); |
| 3349 // Fire the retransmission alarm 6 times, twice for TLP and 4 times for RTO. |
| 3350 for (int i = 0; i < 6; ++i) { |
| 3351 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
| 3352 connection_.GetRetransmissionAlarm()->Fire(); |
| 3353 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); |
| 3354 EXPECT_TRUE(connection_.connected()); |
| 3355 } |
| 3356 |
| 3357 EXPECT_EQ(2u, connection_.sent_packet_manager().consecutive_tlp_count()); |
| 3358 EXPECT_EQ(4u, connection_.sent_packet_manager().consecutive_rto_count()); |
| 3359 // This time, we should time out. |
| 3360 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_TOO_MANY_RTOS, |
| 3361 ConnectionCloseSource::FROM_SELF)); |
| 3362 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
| 3363 connection_.GetRetransmissionAlarm()->Fire(); |
| 3364 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); |
| 3365 EXPECT_FALSE(connection_.connected()); |
| 3366 } |
| 3367 |
3334 TEST_P(QuicConnectionTest, SendScheduler) { | 3368 TEST_P(QuicConnectionTest, SendScheduler) { |
3335 // Test that if we send a packet without delay, it is not queued. | 3369 // Test that if we send a packet without delay, it is not queued. |
3336 QuicPacket* packet = | 3370 QuicPacket* packet = |
3337 ConstructDataPacket(kDefaultPathId, 1, !kEntropyFlag, !kHasStopWaiting); | 3371 ConstructDataPacket(kDefaultPathId, 1, !kEntropyFlag, !kHasStopWaiting); |
3338 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 3372 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
3339 connection_.SendPacket(ENCRYPTION_NONE, kDefaultPathId, 1, packet, | 3373 connection_.SendPacket(ENCRYPTION_NONE, kDefaultPathId, 1, packet, |
3340 kTestEntropyHash, HAS_RETRANSMITTABLE_DATA, false, | 3374 kTestEntropyHash, HAS_RETRANSMITTABLE_DATA, false, |
3341 false); | 3375 false); |
3342 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 3376 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
3343 } | 3377 } |
(...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4639 // result in multiple attempts to close the connection - it will be marked as | 4673 // result in multiple attempts to close the connection - it will be marked as |
4640 // disconnected after the first call. | 4674 // disconnected after the first call. |
4641 EXPECT_CALL(visitor_, OnConnectionClosed(_, _)).Times(1); | 4675 EXPECT_CALL(visitor_, OnConnectionClosed(_, _)).Times(1); |
4642 connection_.SendConnectionCloseWithDetails(QUIC_NO_ERROR, "no reason"); | 4676 connection_.SendConnectionCloseWithDetails(QUIC_NO_ERROR, "no reason"); |
4643 connection_.SendConnectionCloseWithDetails(QUIC_NO_ERROR, "no reason"); | 4677 connection_.SendConnectionCloseWithDetails(QUIC_NO_ERROR, "no reason"); |
4644 } | 4678 } |
4645 | 4679 |
4646 } // namespace | 4680 } // namespace |
4647 } // namespace test | 4681 } // namespace test |
4648 } // namespace net | 4682 } // namespace net |
OLD | NEW |