Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Side by Side Diff: net/quic/quic_connection_test.cc

Issue 1808863002: Do not disable TLP by default in QuicConnection tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@116687954
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 TestPacketWriter* writer, 428 TestPacketWriter* writer,
429 Perspective perspective, 429 Perspective perspective,
430 QuicVersion version) 430 QuicVersion version)
431 : QuicConnection(connection_id, 431 : QuicConnection(connection_id,
432 address, 432 address,
433 helper, 433 helper,
434 writer, 434 writer,
435 /* owns_writer= */ false, 435 /* owns_writer= */ false,
436 perspective, 436 perspective,
437 SupportedVersions(version)) { 437 SupportedVersions(version)) {
438 // Disable tail loss probes for most tests.
439 QuicSentPacketManagerPeer::SetMaxTailLossProbes(
440 QuicConnectionPeer::GetSentPacketManager(this), 0);
441 writer->set_perspective(perspective); 438 writer->set_perspective(perspective);
442 } 439 }
443 440
444 void SendAck() { QuicConnectionPeer::SendAck(this); } 441 void SendAck() { QuicConnectionPeer::SendAck(this); }
445 442
446 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) { 443 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) {
447 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm); 444 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm);
448 } 445 }
449 446
450 void SetLossAlgorithm(LossDetectionInterface* loss_algorithm) { 447 void SetLossAlgorithm(LossDetectionInterface* loss_algorithm) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 TestConnectionHelper::TestAlarm* GetTimeoutAlarm() { 570 TestConnectionHelper::TestAlarm* GetTimeoutAlarm() {
574 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( 571 return reinterpret_cast<TestConnectionHelper::TestAlarm*>(
575 QuicConnectionPeer::GetTimeoutAlarm(this)); 572 QuicConnectionPeer::GetTimeoutAlarm(this));
576 } 573 }
577 574
578 TestConnectionHelper::TestAlarm* GetMtuDiscoveryAlarm() { 575 TestConnectionHelper::TestAlarm* GetMtuDiscoveryAlarm() {
579 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( 576 return reinterpret_cast<TestConnectionHelper::TestAlarm*>(
580 QuicConnectionPeer::GetMtuDiscoveryAlarm(this)); 577 QuicConnectionPeer::GetMtuDiscoveryAlarm(this));
581 } 578 }
582 579
580 void DisableTailLossProbe() {
581 QuicSentPacketManagerPeer::SetMaxTailLossProbes(
582 QuicConnectionPeer::GetSentPacketManager(this), 0);
583 }
584
583 using QuicConnection::SelectMutualVersion; 585 using QuicConnection::SelectMutualVersion;
584 using QuicConnection::set_defer_send_in_response_to_packets; 586 using QuicConnection::set_defer_send_in_response_to_packets;
585 587
586 private: 588 private:
587 TestPacketWriter* writer() { 589 TestPacketWriter* writer() {
588 return static_cast<TestPacketWriter*>(QuicConnection::writer()); 590 return static_cast<TestPacketWriter*>(QuicConnection::writer());
589 } 591 }
590 592
591 DISALLOW_COPY_AND_ASSIGN(TestConnection); 593 DISALLOW_COPY_AND_ASSIGN(TestConnection);
592 }; 594 };
(...skipping 1444 matching lines...) Expand 10 before | Expand all | Expand 10 after
2037 // Fire the RTO and verify that the RST_STREAM is resent, not stream data. 2039 // Fire the RTO and verify that the RST_STREAM is resent, not stream data.
2038 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); 2040 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
2039 clock_.AdvanceTime(DefaultRetransmissionTime()); 2041 clock_.AdvanceTime(DefaultRetransmissionTime());
2040 connection_.GetRetransmissionAlarm()->Fire(); 2042 connection_.GetRetransmissionAlarm()->Fire();
2041 EXPECT_EQ(1u, writer_->frame_count()); 2043 EXPECT_EQ(1u, writer_->frame_count());
2042 EXPECT_EQ(1u, writer_->rst_stream_frames().size()); 2044 EXPECT_EQ(1u, writer_->rst_stream_frames().size());
2043 EXPECT_EQ(stream_id, writer_->rst_stream_frames().front().stream_id); 2045 EXPECT_EQ(stream_id, writer_->rst_stream_frames().front().stream_id);
2044 } 2046 }
2045 2047
2046 TEST_P(QuicConnectionTest, RetransmitForQuicRstStreamNoErrorOnRTO) { 2048 TEST_P(QuicConnectionTest, RetransmitForQuicRstStreamNoErrorOnRTO) {
2049 connection_.DisableTailLossProbe();
2050
2047 QuicStreamId stream_id = 2; 2051 QuicStreamId stream_id = 2;
2048 QuicPacketNumber last_packet; 2052 QuicPacketNumber last_packet;
2049 SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet); 2053 SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet);
2050 2054
2051 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); 2055 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
2052 connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14); 2056 connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14);
2053 2057
2054 // Fire the RTO and verify that the RST_STREAM is resent, the stream data 2058 // Fire the RTO and verify that the RST_STREAM is resent, the stream data
2055 // is only sent on QUIC_VERSION_29 or later versions. 2059 // is only sent on QUIC_VERSION_29 or later versions.
2056 if (version() > QUIC_VERSION_28) { 2060 if (version() > QUIC_VERSION_28) {
2057 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 2061 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
2058 .Times(AtLeast(2)); 2062 .Times(AtLeast(2));
2059 } else { 2063 } else {
2060 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); 2064 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
2061 } 2065 }
2062 clock_.AdvanceTime(DefaultRetransmissionTime()); 2066 clock_.AdvanceTime(DefaultRetransmissionTime());
2063 connection_.GetRetransmissionAlarm()->Fire(); 2067 connection_.GetRetransmissionAlarm()->Fire();
2064 EXPECT_EQ(1u, writer_->frame_count()); 2068 EXPECT_EQ(1u, writer_->frame_count());
2065 EXPECT_EQ(1u, writer_->rst_stream_frames().size()); 2069 ASSERT_EQ(1u, writer_->rst_stream_frames().size());
2066 EXPECT_EQ(stream_id, writer_->rst_stream_frames().front().stream_id); 2070 EXPECT_EQ(stream_id, writer_->rst_stream_frames().front().stream_id);
2067 } 2071 }
2068 2072
2069 TEST_P(QuicConnectionTest, DoNotSendPendingRetransmissionForResetStream) { 2073 TEST_P(QuicConnectionTest, DoNotSendPendingRetransmissionForResetStream) {
2070 QuicStreamId stream_id = 2; 2074 QuicStreamId stream_id = 2;
2071 QuicPacketNumber last_packet; 2075 QuicPacketNumber last_packet;
2072 SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet); 2076 SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet);
2073 SendStreamDataToPeer(stream_id, "foos", 3, !kFin, &last_packet); 2077 SendStreamDataToPeer(stream_id, "foos", 3, !kFin, &last_packet);
2074 BlockOnNextWrite(); 2078 BlockOnNextWrite();
2075 connection_.SendStreamDataWithString(stream_id, "fooos", 7, !kFin, nullptr); 2079 connection_.SendStreamDataWithString(stream_id, "fooos", 7, !kFin, nullptr);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2194 lost_packets.push_back(std::make_pair(1, kMaxPacketSize)); 2198 lost_packets.push_back(std::make_pair(1, kMaxPacketSize));
2195 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) 2199 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _))
2196 .WillOnce(SetArgPointee<3>(lost_packets)); 2200 .WillOnce(SetArgPointee<3>(lost_packets));
2197 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); 2201 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
2198 EXPECT_CALL(*send_algorithm_, 2202 EXPECT_CALL(*send_algorithm_,
2199 OnPacketSent(_, _, _, packet_size - kQuicVersionSize, _)); 2203 OnPacketSent(_, _, _, packet_size - kQuicVersionSize, _));
2200 ProcessAckPacket(&frame); 2204 ProcessAckPacket(&frame);
2201 } 2205 }
2202 2206
2203 TEST_P(QuicConnectionTest, QueueAfterTwoRTOs) { 2207 TEST_P(QuicConnectionTest, QueueAfterTwoRTOs) {
2208 connection_.DisableTailLossProbe();
2209
2204 for (int i = 0; i < 10; ++i) { 2210 for (int i = 0; i < 10; ++i) {
2205 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); 2211 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
2206 connection_.SendStreamDataWithString(3, "foo", i * 3, !kFin, nullptr); 2212 connection_.SendStreamDataWithString(3, "foo", i * 3, !kFin, nullptr);
2207 } 2213 }
2208 2214
2209 // Block the writer and ensure they're queued. 2215 // Block the writer and ensure they're queued.
2210 BlockOnNextWrite(); 2216 BlockOnNextWrite();
2211 clock_.AdvanceTime(DefaultRetransmissionTime()); 2217 clock_.AdvanceTime(DefaultRetransmissionTime());
2212 // Only one packet should be retransmitted. 2218 // Only one packet should be retransmitted.
2213 connection_.GetRetransmissionAlarm()->Fire(); 2219 connection_.GetRetransmissionAlarm()->Fire();
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
2427 // so send algorithm's OnRetransmissionTimeout is not called. 2433 // so send algorithm's OnRetransmissionTimeout is not called.
2428 clock_.AdvanceTime(retransmission_time.Subtract(clock_.Now())); 2434 clock_.AdvanceTime(retransmission_time.Subtract(clock_.Now()));
2429 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 2u, _, _)); 2435 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 2u, _, _));
2430 connection_.GetRetransmissionAlarm()->Fire(); 2436 connection_.GetRetransmissionAlarm()->Fire();
2431 EXPECT_EQ(2u, writer_->header().packet_number); 2437 EXPECT_EQ(2u, writer_->header().packet_number);
2432 // We do not raise the high water mark yet. 2438 // We do not raise the high water mark yet.
2433 EXPECT_EQ(1u, stop_waiting()->least_unacked); 2439 EXPECT_EQ(1u, stop_waiting()->least_unacked);
2434 } 2440 }
2435 2441
2436 TEST_P(QuicConnectionTest, RTO) { 2442 TEST_P(QuicConnectionTest, RTO) {
2443 connection_.DisableTailLossProbe();
2444
2437 QuicTime default_retransmission_time = 2445 QuicTime default_retransmission_time =
2438 clock_.ApproximateNow().Add(DefaultRetransmissionTime()); 2446 clock_.ApproximateNow().Add(DefaultRetransmissionTime());
2439 SendStreamDataToPeer(3, "foo", 0, !kFin, nullptr); 2447 SendStreamDataToPeer(3, "foo", 0, !kFin, nullptr);
2440 EXPECT_EQ(1u, stop_waiting()->least_unacked); 2448 EXPECT_EQ(1u, stop_waiting()->least_unacked);
2441 2449
2442 EXPECT_EQ(1u, writer_->header().packet_number); 2450 EXPECT_EQ(1u, writer_->header().packet_number);
2443 EXPECT_EQ(default_retransmission_time, 2451 EXPECT_EQ(default_retransmission_time,
2444 connection_.GetRetransmissionAlarm()->deadline()); 2452 connection_.GetRetransmissionAlarm()->deadline());
2445 // Simulate the retransmission alarm firing. 2453 // Simulate the retransmission alarm firing.
2446 clock_.AdvanceTime(DefaultRetransmissionTime()); 2454 clock_.AdvanceTime(DefaultRetransmissionTime());
2447 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 2u, _, _)); 2455 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 2u, _, _));
2448 connection_.GetRetransmissionAlarm()->Fire(); 2456 connection_.GetRetransmissionAlarm()->Fire();
2449 EXPECT_EQ(2u, writer_->header().packet_number); 2457 EXPECT_EQ(2u, writer_->header().packet_number);
2450 // We do not raise the high water mark yet. 2458 // We do not raise the high water mark yet.
2451 EXPECT_EQ(1u, stop_waiting()->least_unacked); 2459 EXPECT_EQ(1u, stop_waiting()->least_unacked);
2452 } 2460 }
2453 2461
2454 TEST_P(QuicConnectionTest, RTOWithSameEncryptionLevel) { 2462 TEST_P(QuicConnectionTest, RTOWithSameEncryptionLevel) {
2463 connection_.DisableTailLossProbe();
2464
2455 QuicTime default_retransmission_time = 2465 QuicTime default_retransmission_time =
2456 clock_.ApproximateNow().Add(DefaultRetransmissionTime()); 2466 clock_.ApproximateNow().Add(DefaultRetransmissionTime());
2457 use_tagging_decrypter(); 2467 use_tagging_decrypter();
2458 2468
2459 // A TaggingEncrypter puts kTagSize copies of the given byte (0x01 here) at 2469 // A TaggingEncrypter puts kTagSize copies of the given byte (0x01 here) at
2460 // the end of the packet. We can test this to check which encrypter was used. 2470 // the end of the packet. We can test this to check which encrypter was used.
2461 connection_.SetEncrypter(ENCRYPTION_NONE, new TaggingEncrypter(0x01)); 2471 connection_.SetEncrypter(ENCRYPTION_NONE, new TaggingEncrypter(0x01));
2462 SendStreamDataToPeer(3, "foo", 0, !kFin, nullptr); 2472 SendStreamDataToPeer(3, "foo", 0, !kFin, nullptr);
2463 EXPECT_EQ(0x01010101u, writer_->final_bytes_of_last_packet()); 2473 EXPECT_EQ(0x01010101u, writer_->final_bytes_of_last_packet());
2464 2474
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
2669 ENCRYPTION_INITIAL); 2679 ENCRYPTION_INITIAL);
2670 2680
2671 // Finally, process a third packet and note that we do not reprocess the 2681 // Finally, process a third packet and note that we do not reprocess the
2672 // buffered packet. 2682 // buffered packet.
2673 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1); 2683 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
2674 ProcessDataPacketAtLevel(kDefaultPathId, 102, kEntropyFlag, !kHasStopWaiting, 2684 ProcessDataPacketAtLevel(kDefaultPathId, 102, kEntropyFlag, !kHasStopWaiting,
2675 ENCRYPTION_INITIAL); 2685 ENCRYPTION_INITIAL);
2676 } 2686 }
2677 2687
2678 TEST_P(QuicConnectionTest, TestRetransmitOrder) { 2688 TEST_P(QuicConnectionTest, TestRetransmitOrder) {
2689 connection_.DisableTailLossProbe();
2690
2679 QuicByteCount first_packet_size; 2691 QuicByteCount first_packet_size;
2680 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 2692 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
2681 .WillOnce(DoAll(SaveArg<3>(&first_packet_size), Return(true))); 2693 .WillOnce(DoAll(SaveArg<3>(&first_packet_size), Return(true)));
2682 2694
2683 connection_.SendStreamDataWithString(3, "first_packet", 0, !kFin, nullptr); 2695 connection_.SendStreamDataWithString(3, "first_packet", 0, !kFin, nullptr);
2684 QuicByteCount second_packet_size; 2696 QuicByteCount second_packet_size;
2685 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 2697 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
2686 .WillOnce(DoAll(SaveArg<3>(&second_packet_size), Return(true))); 2698 .WillOnce(DoAll(SaveArg<3>(&second_packet_size), Return(true)));
2687 connection_.SendStreamDataWithString(3, "second_packet", 12, !kFin, nullptr); 2699 connection_.SendStreamDataWithString(3, "second_packet", 12, !kFin, nullptr);
2688 EXPECT_NE(first_packet_size, second_packet_size); 2700 EXPECT_NE(first_packet_size, second_packet_size);
(...skipping 23 matching lines...) Expand all
2712 // Make sure that RTO is not started when the packet is queued. 2724 // Make sure that RTO is not started when the packet is queued.
2713 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); 2725 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet());
2714 2726
2715 // Test that RTO is started once we write to the socket. 2727 // Test that RTO is started once we write to the socket.
2716 writer_->SetWritable(); 2728 writer_->SetWritable();
2717 connection_.OnCanWrite(); 2729 connection_.OnCanWrite();
2718 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); 2730 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet());
2719 } 2731 }
2720 2732
2721 TEST_P(QuicConnectionTest, DelayRTOWithAckReceipt) { 2733 TEST_P(QuicConnectionTest, DelayRTOWithAckReceipt) {
2734 connection_.DisableTailLossProbe();
2735
2722 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 2736 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2723 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2); 2737 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2);
2724 connection_.SendStreamDataWithString(2, "foo", 0, !kFin, nullptr); 2738 connection_.SendStreamDataWithString(2, "foo", 0, !kFin, nullptr);
2725 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, nullptr); 2739 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, nullptr);
2726 QuicAlarm* retransmission_alarm = connection_.GetRetransmissionAlarm(); 2740 QuicAlarm* retransmission_alarm = connection_.GetRetransmissionAlarm();
2727 EXPECT_TRUE(retransmission_alarm->IsSet()); 2741 EXPECT_TRUE(retransmission_alarm->IsSet());
2728 EXPECT_EQ(clock_.Now().Add(DefaultRetransmissionTime()), 2742 EXPECT_EQ(clock_.Now().Add(DefaultRetransmissionTime()),
2729 retransmission_alarm->deadline()); 2743 retransmission_alarm->deadline());
2730 2744
2731 // Advance the time right before the RTO, then receive an ack for the first 2745 // Advance the time right before the RTO, then receive an ack for the first
(...skipping 18 matching lines...) Expand all
2750 // The new retransmitted packet number should set the RTO to a larger value 2764 // The new retransmitted packet number should set the RTO to a larger value
2751 // than previously. 2765 // than previously.
2752 EXPECT_TRUE(retransmission_alarm->IsSet()); 2766 EXPECT_TRUE(retransmission_alarm->IsSet());
2753 QuicTime next_rto_time = retransmission_alarm->deadline(); 2767 QuicTime next_rto_time = retransmission_alarm->deadline();
2754 QuicTime expected_rto_time = 2768 QuicTime expected_rto_time =
2755 connection_.sent_packet_manager().GetRetransmissionTime(); 2769 connection_.sent_packet_manager().GetRetransmissionTime();
2756 EXPECT_EQ(next_rto_time, expected_rto_time); 2770 EXPECT_EQ(next_rto_time, expected_rto_time);
2757 } 2771 }
2758 2772
2759 TEST_P(QuicConnectionTest, TestQueued) { 2773 TEST_P(QuicConnectionTest, TestQueued) {
2774 connection_.DisableTailLossProbe();
2775
2760 EXPECT_EQ(0u, connection_.NumQueuedPackets()); 2776 EXPECT_EQ(0u, connection_.NumQueuedPackets());
2761 BlockOnNextWrite(); 2777 BlockOnNextWrite();
2762 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, nullptr); 2778 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, nullptr);
2763 EXPECT_EQ(1u, connection_.NumQueuedPackets()); 2779 EXPECT_EQ(1u, connection_.NumQueuedPackets());
2764 2780
2765 // Unblock the writes and actually send. 2781 // Unblock the writes and actually send.
2766 writer_->SetWritable(); 2782 writer_->SetWritable();
2767 connection_.OnCanWrite(); 2783 connection_.OnCanWrite();
2768 EXPECT_EQ(0u, connection_.NumQueuedPackets()); 2784 EXPECT_EQ(0u, connection_.NumQueuedPackets());
2769 } 2785 }
(...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after
4184 EXPECT_CALL(visitor_, 4200 EXPECT_CALL(visitor_,
4185 OnConnectionClosed(QUIC_INVALID_VERSION_NEGOTIATION_PACKET, 4201 OnConnectionClosed(QUIC_INVALID_VERSION_NEGOTIATION_PACKET,
4186 ConnectionCloseSource::FROM_SELF)); 4202 ConnectionCloseSource::FROM_SELF));
4187 scoped_ptr<QuicEncryptedPacket> encrypted( 4203 scoped_ptr<QuicEncryptedPacket> encrypted(
4188 framer_.BuildVersionNegotiationPacket(connection_id_, 4204 framer_.BuildVersionNegotiationPacket(connection_id_,
4189 QuicSupportedVersions())); 4205 QuicSupportedVersions()));
4190 connection_.ProcessUdpPacket(kSelfAddress, kPeerAddress, *encrypted); 4206 connection_.ProcessUdpPacket(kSelfAddress, kPeerAddress, *encrypted);
4191 } 4207 }
4192 4208
4193 TEST_P(QuicConnectionTest, CheckSendStats) { 4209 TEST_P(QuicConnectionTest, CheckSendStats) {
4210 connection_.DisableTailLossProbe();
4211
4194 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); 4212 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
4195 connection_.SendStreamDataWithString(3, "first", 0, !kFin, nullptr); 4213 connection_.SendStreamDataWithString(3, "first", 0, !kFin, nullptr);
4196 size_t first_packet_size = writer_->last_packet_size(); 4214 size_t first_packet_size = writer_->last_packet_size();
4197 4215
4198 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); 4216 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
4199 connection_.SendStreamDataWithString(5, "second", 0, !kFin, nullptr); 4217 connection_.SendStreamDataWithString(5, "second", 0, !kFin, nullptr);
4200 size_t second_packet_size = writer_->last_packet_size(); 4218 size_t second_packet_size = writer_->last_packet_size();
4201 4219
4202 // 2 retransmissions due to rto, 1 due to explicit nack. 4220 // 2 retransmissions due to rto, 1 due to explicit nack.
4203 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); 4221 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
4396 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); 4414 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _));
4397 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); 4415 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
4398 QuicAckFrame second_ack_frame = InitAckFrame(5); 4416 QuicAckFrame second_ack_frame = InitAckFrame(5);
4399 ProcessAckPacket(&second_ack_frame); 4417 ProcessAckPacket(&second_ack_frame);
4400 } 4418 }
4401 4419
4402 // AckNotifierCallback is triggered by the ack of a packet that timed 4420 // AckNotifierCallback is triggered by the ack of a packet that timed
4403 // out and was retransmitted, even though the retransmission has a 4421 // out and was retransmitted, even though the retransmission has a
4404 // different packet number. 4422 // different packet number.
4405 TEST_P(QuicConnectionTest, AckNotifierCallbackForAckAfterRTO) { 4423 TEST_P(QuicConnectionTest, AckNotifierCallbackForAckAfterRTO) {
4424 connection_.DisableTailLossProbe();
4425
4406 // Create a listener which we expect to be called. 4426 // Create a listener which we expect to be called.
4407 scoped_refptr<MockAckListener> listener(new StrictMock<MockAckListener>); 4427 scoped_refptr<MockAckListener> listener(new StrictMock<MockAckListener>);
4408 4428
4409 QuicTime default_retransmission_time = 4429 QuicTime default_retransmission_time =
4410 clock_.ApproximateNow().Add(DefaultRetransmissionTime()); 4430 clock_.ApproximateNow().Add(DefaultRetransmissionTime());
4411 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, listener.get()); 4431 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, listener.get());
4412 EXPECT_EQ(1u, stop_waiting()->least_unacked); 4432 EXPECT_EQ(1u, stop_waiting()->least_unacked);
4413 4433
4414 EXPECT_EQ(1u, writer_->header().packet_number); 4434 EXPECT_EQ(1u, writer_->header().packet_number);
4415 EXPECT_EQ(default_retransmission_time, 4435 EXPECT_EQ(default_retransmission_time,
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
4644 EXPECT_FALSE(connection_.connected()); 4664 EXPECT_FALSE(connection_.connected());
4645 } 4665 }
4646 4666
4647 TEST_P(QuicConnectionTest, OnPathDegrading) { 4667 TEST_P(QuicConnectionTest, OnPathDegrading) {
4648 QuicByteCount packet_size; 4668 QuicByteCount packet_size;
4649 const size_t kMinTimeoutsBeforePathDegrading = 2; 4669 const size_t kMinTimeoutsBeforePathDegrading = 2;
4650 4670
4651 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 4671 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
4652 .WillOnce(DoAll(SaveArg<3>(&packet_size), Return(true))); 4672 .WillOnce(DoAll(SaveArg<3>(&packet_size), Return(true)));
4653 connection_.SendStreamDataWithString(3, "packet", 0, !kFin, nullptr); 4673 connection_.SendStreamDataWithString(3, "packet", 0, !kFin, nullptr);
4654 for (size_t i = 1; i < kMinTimeoutsBeforePathDegrading; ++i) { 4674 size_t num_timeouts =
4675 kMinTimeoutsBeforePathDegrading +
4676 QuicSentPacketManagerPeer::GetMaxTailLossProbes(
4677 QuicConnectionPeer::GetSentPacketManager(&connection_));
4678 for (size_t i = 1; i < num_timeouts; ++i) {
4655 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10 * i)); 4679 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10 * i));
4656 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, packet_size, _)); 4680 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, packet_size, _));
4657 connection_.GetRetransmissionAlarm()->Fire(); 4681 connection_.GetRetransmissionAlarm()->Fire();
4658 } 4682 }
4659 // Next RTO should cause OnPathDegrading to be called before the 4683 // Next RTO should cause OnPathDegrading to be called before the
4660 // retransmission is sent out. 4684 // retransmission is sent out.
4661 clock_.AdvanceTime( 4685 clock_.AdvanceTime(
4662 QuicTime::Delta::FromSeconds(kMinTimeoutsBeforePathDegrading * 10)); 4686 QuicTime::Delta::FromSeconds(kMinTimeoutsBeforePathDegrading * 10));
4663 { 4687 {
4664 InSequence s; 4688 InSequence s;
4665 EXPECT_CALL(visitor_, OnPathDegrading()); 4689 EXPECT_CALL(visitor_, OnPathDegrading());
4666 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, packet_size, _)); 4690 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, packet_size, _));
4667 } 4691 }
4668 connection_.GetRetransmissionAlarm()->Fire(); 4692 connection_.GetRetransmissionAlarm()->Fire();
4669 } 4693 }
4670 4694
4671 TEST_P(QuicConnectionTest, MultipleCallsToSendConnectionCloseWithDetails) { 4695 TEST_P(QuicConnectionTest, MultipleCallsToSendConnectionCloseWithDetails) {
4672 // Verifies that multiple calls to SendConnectionCloseWithDetails do not 4696 // Verifies that multiple calls to SendConnectionCloseWithDetails do not
4673 // result in multiple attempts to close the connection - it will be marked as 4697 // result in multiple attempts to close the connection - it will be marked as
4674 // disconnected after the first call. 4698 // disconnected after the first call.
4675 EXPECT_CALL(visitor_, OnConnectionClosed(_, _)).Times(1); 4699 EXPECT_CALL(visitor_, OnConnectionClosed(_, _)).Times(1);
4676 connection_.SendConnectionCloseWithDetails(QUIC_NO_ERROR, "no reason"); 4700 connection_.SendConnectionCloseWithDetails(QUIC_NO_ERROR, "no reason");
4677 connection_.SendConnectionCloseWithDetails(QUIC_NO_ERROR, "no reason"); 4701 connection_.SendConnectionCloseWithDetails(QUIC_NO_ERROR, "no reason");
4678 } 4702 }
4679 4703
4680 } // namespace 4704 } // namespace
4681 } // namespace test 4705 } // namespace test
4682 } // namespace net 4706 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698