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

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

Issue 2183493002: Add a merely pass-through QuicMultipathSentPacketManager. Protected behind blocked flag FLAGS_quic_… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
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 <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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 alarm_factory, 457 alarm_factory,
458 writer, 458 writer,
459 /* owns_writer= */ false, 459 /* owns_writer= */ false,
460 perspective, 460 perspective,
461 SupportedVersions(version)) { 461 SupportedVersions(version)) {
462 writer->set_perspective(perspective); 462 writer->set_perspective(perspective);
463 } 463 }
464 464
465 void SendAck() { QuicConnectionPeer::SendAck(this); } 465 void SendAck() { QuicConnectionPeer::SendAck(this); }
466 466
467 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) { 467 void SetSendAlgorithm(QuicPathId path_id,
468 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm); 468 SendAlgorithmInterface* send_algorithm) {
469 QuicConnectionPeer::SetSendAlgorithm(this, path_id, send_algorithm);
469 } 470 }
470 471
471 void SetLossAlgorithm(LossDetectionInterface* loss_algorithm) { 472 void SetLossAlgorithm(QuicPathId path_id,
472 // TODO(fayang): connection tests should use MockSentPacketManager. 473 LossDetectionInterface* loss_algorithm) {
473 QuicSentPacketManagerPeer::SetLossAlgorithm( 474 QuicConnectionPeer::SetLossAlgorithm(this, path_id, loss_algorithm);
474 static_cast<QuicSentPacketManager*>(
475 QuicConnectionPeer::GetSentPacketManager(this)),
476 loss_algorithm);
477 } 475 }
478 476
479 void SendPacket(EncryptionLevel level, 477 void SendPacket(EncryptionLevel level,
480 QuicPathId path_id, 478 QuicPathId path_id,
481 QuicPacketNumber packet_number, 479 QuicPacketNumber packet_number,
482 QuicPacket* packet, 480 QuicPacket* packet,
483 QuicPacketEntropyHash entropy_hash, 481 QuicPacketEntropyHash entropy_hash,
484 HasRetransmittableData retransmittable, 482 HasRetransmittableData retransmittable,
485 bool has_ack, 483 bool has_ack,
486 bool has_pending_frames) { 484 bool has_pending_frames) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 TestAlarmFactory::TestAlarm* GetTimeoutAlarm() { 595 TestAlarmFactory::TestAlarm* GetTimeoutAlarm() {
598 return reinterpret_cast<TestAlarmFactory::TestAlarm*>( 596 return reinterpret_cast<TestAlarmFactory::TestAlarm*>(
599 QuicConnectionPeer::GetTimeoutAlarm(this)); 597 QuicConnectionPeer::GetTimeoutAlarm(this));
600 } 598 }
601 599
602 TestAlarmFactory::TestAlarm* GetMtuDiscoveryAlarm() { 600 TestAlarmFactory::TestAlarm* GetMtuDiscoveryAlarm() {
603 return reinterpret_cast<TestAlarmFactory::TestAlarm*>( 601 return reinterpret_cast<TestAlarmFactory::TestAlarm*>(
604 QuicConnectionPeer::GetMtuDiscoveryAlarm(this)); 602 QuicConnectionPeer::GetMtuDiscoveryAlarm(this));
605 } 603 }
606 604
607 void DisableTailLossProbe() { 605 void SetMaxTailLossProbes(QuicPathId path_id, size_t max_tail_loss_probes) {
608 QuicSentPacketManagerPeer::SetMaxTailLossProbes( 606 QuicSentPacketManagerPeer::SetMaxTailLossProbes(
609 QuicConnectionPeer::GetSentPacketManager(this), 0); 607 QuicConnectionPeer::GetSentPacketManager(this, path_id),
608 max_tail_loss_probes);
609 }
610
611 QuicByteCount GetBytesInFlight(QuicPathId path_id) {
612 return QuicSentPacketManagerPeer::GetBytesInFlight(
613 QuicConnectionPeer::GetSentPacketManager(this, path_id));
610 } 614 }
611 615
612 using QuicConnection::SelectMutualVersion; 616 using QuicConnection::SelectMutualVersion;
613 using QuicConnection::set_defer_send_in_response_to_packets; 617 using QuicConnection::set_defer_send_in_response_to_packets;
614 618
615 private: 619 private:
616 TestPacketWriter* writer() { 620 TestPacketWriter* writer() {
617 return static_cast<TestPacketWriter*>(QuicConnection::writer()); 621 return static_cast<TestPacketWriter*>(QuicConnection::writer());
618 } 622 }
619 623
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 writer_(new TestPacketWriter(version(), &clock_)), 678 writer_(new TestPacketWriter(version(), &clock_)),
675 connection_(connection_id_, 679 connection_(connection_id_,
676 kPeerAddress, 680 kPeerAddress,
677 helper_.get(), 681 helper_.get(),
678 alarm_factory_.get(), 682 alarm_factory_.get(),
679 writer_.get(), 683 writer_.get(),
680 Perspective::IS_CLIENT, 684 Perspective::IS_CLIENT,
681 version()), 685 version()),
682 creator_(QuicConnectionPeer::GetPacketCreator(&connection_)), 686 creator_(QuicConnectionPeer::GetPacketCreator(&connection_)),
683 generator_(QuicConnectionPeer::GetPacketGenerator(&connection_)), 687 generator_(QuicConnectionPeer::GetPacketGenerator(&connection_)),
684 manager_(QuicConnectionPeer::GetSentPacketManager(&connection_)), 688 manager_(QuicConnectionPeer::GetSentPacketManager(&connection_,
689 kDefaultPathId)),
685 frame1_(1, false, 0, StringPiece(data1)), 690 frame1_(1, false, 0, StringPiece(data1)),
686 frame2_(1, false, 3, StringPiece(data2)), 691 frame2_(1, false, 3, StringPiece(data2)),
687 packet_number_length_(PACKET_6BYTE_PACKET_NUMBER), 692 packet_number_length_(PACKET_6BYTE_PACKET_NUMBER),
688 connection_id_length_(PACKET_8BYTE_CONNECTION_ID) { 693 connection_id_length_(PACKET_8BYTE_CONNECTION_ID) {
689 connection_.set_defer_send_in_response_to_packets(GetParam().ack_response == 694 connection_.set_defer_send_in_response_to_packets(GetParam().ack_response ==
690 AckResponse::kDefer); 695 AckResponse::kDefer);
691 FLAGS_quic_always_log_bugs_for_tests = true; 696 FLAGS_quic_always_log_bugs_for_tests = true;
692 connection_.set_visitor(&visitor_); 697 connection_.set_visitor(&visitor_);
693 connection_.SetSendAlgorithm(send_algorithm_); 698 connection_.SetSendAlgorithm(kDefaultPathId, send_algorithm_);
694 connection_.SetLossAlgorithm(loss_algorithm_); 699 connection_.SetLossAlgorithm(kDefaultPathId, loss_algorithm_);
695 framer_.set_received_entropy_calculator(&entropy_calculator_); 700 framer_.set_received_entropy_calculator(&entropy_calculator_);
696 peer_framer_.set_received_entropy_calculator(&peer_entropy_calculator_); 701 peer_framer_.set_received_entropy_calculator(&peer_entropy_calculator_);
697 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _)) 702 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
698 .WillRepeatedly(Return(QuicTime::Delta::Zero())); 703 .WillRepeatedly(Return(QuicTime::Delta::Zero()));
699 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 704 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
700 .Times(AnyNumber()); 705 .Times(AnyNumber());
701 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()) 706 EXPECT_CALL(*send_algorithm_, RetransmissionDelay())
702 .WillRepeatedly(Return(QuicTime::Delta::Zero())); 707 .WillRepeatedly(Return(QuicTime::Delta::Zero()));
703 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) 708 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
704 .WillRepeatedly(Return(kDefaultTCPMSS)); 709 .WillRepeatedly(Return(kDefaultTCPMSS));
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 MockRandom random_generator_; 1053 MockRandom random_generator_;
1049 SimpleBufferAllocator buffer_allocator_; 1054 SimpleBufferAllocator buffer_allocator_;
1050 std::unique_ptr<TestConnectionHelper> helper_; 1055 std::unique_ptr<TestConnectionHelper> helper_;
1051 std::unique_ptr<TestAlarmFactory> alarm_factory_; 1056 std::unique_ptr<TestAlarmFactory> alarm_factory_;
1052 QuicFramer peer_framer_; 1057 QuicFramer peer_framer_;
1053 QuicPacketCreator peer_creator_; 1058 QuicPacketCreator peer_creator_;
1054 std::unique_ptr<TestPacketWriter> writer_; 1059 std::unique_ptr<TestPacketWriter> writer_;
1055 TestConnection connection_; 1060 TestConnection connection_;
1056 QuicPacketCreator* creator_; 1061 QuicPacketCreator* creator_;
1057 QuicPacketGenerator* generator_; 1062 QuicPacketGenerator* generator_;
1058 QuicSentPacketManager* manager_; 1063 QuicSentPacketManagerInterface* manager_;
1059 StrictMock<MockQuicConnectionVisitor> visitor_; 1064 StrictMock<MockQuicConnectionVisitor> visitor_;
1060 1065
1061 QuicStreamFrame frame1_; 1066 QuicStreamFrame frame1_;
1062 QuicStreamFrame frame2_; 1067 QuicStreamFrame frame2_;
1063 QuicAckFrame ack_; 1068 QuicAckFrame ack_;
1064 QuicStopWaitingFrame stop_waiting_; 1069 QuicStopWaitingFrame stop_waiting_;
1065 QuicPacketNumberLength packet_number_length_; 1070 QuicPacketNumberLength packet_number_length_;
1066 QuicConnectionIdLength connection_id_length_; 1071 QuicConnectionIdLength connection_id_length_;
1067 1072
1068 private: 1073 private:
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after
2069 // Fire the RTO and verify that the RST_STREAM is resent, not stream data. 2074 // Fire the RTO and verify that the RST_STREAM is resent, not stream data.
2070 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); 2075 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
2071 clock_.AdvanceTime(DefaultRetransmissionTime()); 2076 clock_.AdvanceTime(DefaultRetransmissionTime());
2072 connection_.GetRetransmissionAlarm()->Fire(); 2077 connection_.GetRetransmissionAlarm()->Fire();
2073 EXPECT_EQ(1u, writer_->frame_count()); 2078 EXPECT_EQ(1u, writer_->frame_count());
2074 EXPECT_EQ(1u, writer_->rst_stream_frames().size()); 2079 EXPECT_EQ(1u, writer_->rst_stream_frames().size());
2075 EXPECT_EQ(stream_id, writer_->rst_stream_frames().front().stream_id); 2080 EXPECT_EQ(stream_id, writer_->rst_stream_frames().front().stream_id);
2076 } 2081 }
2077 2082
2078 TEST_P(QuicConnectionTest, RetransmitForQuicRstStreamNoErrorOnRTO) { 2083 TEST_P(QuicConnectionTest, RetransmitForQuicRstStreamNoErrorOnRTO) {
2079 connection_.DisableTailLossProbe(); 2084 connection_.SetMaxTailLossProbes(kDefaultPathId, 0);
2080 2085
2081 QuicStreamId stream_id = 2; 2086 QuicStreamId stream_id = 2;
2082 QuicPacketNumber last_packet; 2087 QuicPacketNumber last_packet;
2083 SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet); 2088 SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet);
2084 2089
2085 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); 2090 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
2086 connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14); 2091 connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14);
2087 2092
2088 // Fire the RTO and verify that the RST_STREAM is resent, the stream data 2093 // Fire the RTO and verify that the RST_STREAM is resent, the stream data
2089 // is only sent on QUIC_VERSION_29 or later versions. 2094 // is only sent on QUIC_VERSION_29 or later versions.
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
2269 lost_packets.push_back(std::make_pair(1, kMaxPacketSize)); 2274 lost_packets.push_back(std::make_pair(1, kMaxPacketSize));
2270 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _, _)) 2275 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _, _))
2271 .WillOnce(SetArgPointee<4>(lost_packets)); 2276 .WillOnce(SetArgPointee<4>(lost_packets));
2272 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); 2277 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
2273 EXPECT_CALL(*send_algorithm_, 2278 EXPECT_CALL(*send_algorithm_,
2274 OnPacketSent(_, _, _, packet_size - kQuicVersionSize, _)); 2279 OnPacketSent(_, _, _, packet_size - kQuicVersionSize, _));
2275 ProcessAckPacket(&frame); 2280 ProcessAckPacket(&frame);
2276 } 2281 }
2277 2282
2278 TEST_P(QuicConnectionTest, QueueAfterTwoRTOs) { 2283 TEST_P(QuicConnectionTest, QueueAfterTwoRTOs) {
2279 connection_.DisableTailLossProbe(); 2284 connection_.SetMaxTailLossProbes(kDefaultPathId, 0);
2280 2285
2281 for (int i = 0; i < 10; ++i) { 2286 for (int i = 0; i < 10; ++i) {
2282 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); 2287 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
2283 connection_.SendStreamDataWithString(3, "foo", i * 3, !kFin, nullptr); 2288 connection_.SendStreamDataWithString(3, "foo", i * 3, !kFin, nullptr);
2284 } 2289 }
2285 2290
2286 // Block the writer and ensure they're queued. 2291 // Block the writer and ensure they're queued.
2287 BlockOnNextWrite(); 2292 BlockOnNextWrite();
2288 clock_.AdvanceTime(DefaultRetransmissionTime()); 2293 clock_.AdvanceTime(DefaultRetransmissionTime());
2289 // Only one packet should be retransmitted. 2294 // Only one packet should be retransmitted.
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
2485 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); 2490 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
2486 frame = InitAckFrame(7); 2491 frame = InitAckFrame(7);
2487 NackPacket(5, &frame); 2492 NackPacket(5, &frame);
2488 NackPacket(6, &frame); 2493 NackPacket(6, &frame);
2489 ProcessAckPacket(&frame); 2494 ProcessAckPacket(&frame);
2490 2495
2491 EXPECT_EQ(6u, stop_waiting()->least_unacked); 2496 EXPECT_EQ(6u, stop_waiting()->least_unacked);
2492 } 2497 }
2493 2498
2494 TEST_P(QuicConnectionTest, TLP) { 2499 TEST_P(QuicConnectionTest, TLP) {
2495 QuicSentPacketManagerPeer::SetMaxTailLossProbes(manager_, 1); 2500 connection_.SetMaxTailLossProbes(kDefaultPathId, 1);
2496 2501
2497 SendStreamDataToPeer(3, "foo", 0, !kFin, nullptr); 2502 SendStreamDataToPeer(3, "foo", 0, !kFin, nullptr);
2498 EXPECT_EQ(1u, stop_waiting()->least_unacked); 2503 EXPECT_EQ(1u, stop_waiting()->least_unacked);
2499 QuicTime retransmission_time = 2504 QuicTime retransmission_time =
2500 connection_.GetRetransmissionAlarm()->deadline(); 2505 connection_.GetRetransmissionAlarm()->deadline();
2501 EXPECT_NE(QuicTime::Zero(), retransmission_time); 2506 EXPECT_NE(QuicTime::Zero(), retransmission_time);
2502 2507
2503 EXPECT_EQ(1u, writer_->header().packet_number); 2508 EXPECT_EQ(1u, writer_->header().packet_number);
2504 // Simulate the retransmission alarm firing and sending a tlp, 2509 // Simulate the retransmission alarm firing and sending a tlp,
2505 // so send algorithm's OnRetransmissionTimeout is not called. 2510 // so send algorithm's OnRetransmissionTimeout is not called.
2506 clock_.AdvanceTime(retransmission_time - clock_.Now()); 2511 clock_.AdvanceTime(retransmission_time - clock_.Now());
2507 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 2u, _, _)); 2512 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 2u, _, _));
2508 connection_.GetRetransmissionAlarm()->Fire(); 2513 connection_.GetRetransmissionAlarm()->Fire();
2509 EXPECT_EQ(2u, writer_->header().packet_number); 2514 EXPECT_EQ(2u, writer_->header().packet_number);
2510 // We do not raise the high water mark yet. 2515 // We do not raise the high water mark yet.
2511 EXPECT_EQ(1u, stop_waiting()->least_unacked); 2516 EXPECT_EQ(1u, stop_waiting()->least_unacked);
2512 } 2517 }
2513 2518
2514 TEST_P(QuicConnectionTest, RTO) { 2519 TEST_P(QuicConnectionTest, RTO) {
2515 connection_.DisableTailLossProbe(); 2520 connection_.SetMaxTailLossProbes(kDefaultPathId, 0);
2516 2521
2517 QuicTime default_retransmission_time = 2522 QuicTime default_retransmission_time =
2518 clock_.ApproximateNow() + DefaultRetransmissionTime(); 2523 clock_.ApproximateNow() + DefaultRetransmissionTime();
2519 SendStreamDataToPeer(3, "foo", 0, !kFin, nullptr); 2524 SendStreamDataToPeer(3, "foo", 0, !kFin, nullptr);
2520 EXPECT_EQ(1u, stop_waiting()->least_unacked); 2525 EXPECT_EQ(1u, stop_waiting()->least_unacked);
2521 2526
2522 EXPECT_EQ(1u, writer_->header().packet_number); 2527 EXPECT_EQ(1u, writer_->header().packet_number);
2523 EXPECT_EQ(default_retransmission_time, 2528 EXPECT_EQ(default_retransmission_time,
2524 connection_.GetRetransmissionAlarm()->deadline()); 2529 connection_.GetRetransmissionAlarm()->deadline());
2525 // Simulate the retransmission alarm firing. 2530 // Simulate the retransmission alarm firing.
2526 clock_.AdvanceTime(DefaultRetransmissionTime()); 2531 clock_.AdvanceTime(DefaultRetransmissionTime());
2527 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 2u, _, _)); 2532 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 2u, _, _));
2528 connection_.GetRetransmissionAlarm()->Fire(); 2533 connection_.GetRetransmissionAlarm()->Fire();
2529 EXPECT_EQ(2u, writer_->header().packet_number); 2534 EXPECT_EQ(2u, writer_->header().packet_number);
2530 // We do not raise the high water mark yet. 2535 // We do not raise the high water mark yet.
2531 EXPECT_EQ(1u, stop_waiting()->least_unacked); 2536 EXPECT_EQ(1u, stop_waiting()->least_unacked);
2532 } 2537 }
2533 2538
2534 TEST_P(QuicConnectionTest, RTOWithSameEncryptionLevel) { 2539 TEST_P(QuicConnectionTest, RTOWithSameEncryptionLevel) {
2535 connection_.DisableTailLossProbe(); 2540 connection_.SetMaxTailLossProbes(kDefaultPathId, 0);
2536 2541
2537 QuicTime default_retransmission_time = 2542 QuicTime default_retransmission_time =
2538 clock_.ApproximateNow() + DefaultRetransmissionTime(); 2543 clock_.ApproximateNow() + DefaultRetransmissionTime();
2539 use_tagging_decrypter(); 2544 use_tagging_decrypter();
2540 2545
2541 // A TaggingEncrypter puts kTagSize copies of the given byte (0x01 here) at 2546 // A TaggingEncrypter puts kTagSize copies of the given byte (0x01 here) at
2542 // the end of the packet. We can test this to check which encrypter was used. 2547 // the end of the packet. We can test this to check which encrypter was used.
2543 connection_.SetEncrypter(ENCRYPTION_NONE, new TaggingEncrypter(0x01)); 2548 connection_.SetEncrypter(ENCRYPTION_NONE, new TaggingEncrypter(0x01));
2544 SendStreamDataToPeer(3, "foo", 0, !kFin, nullptr); 2549 SendStreamDataToPeer(3, "foo", 0, !kFin, nullptr);
2545 EXPECT_EQ(0x01010101u, writer_->final_bytes_of_last_packet()); 2550 EXPECT_EQ(0x01010101u, writer_->final_bytes_of_last_packet());
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
2751 ENCRYPTION_INITIAL); 2756 ENCRYPTION_INITIAL);
2752 2757
2753 // Finally, process a third packet and note that we do not reprocess the 2758 // Finally, process a third packet and note that we do not reprocess the
2754 // buffered packet. 2759 // buffered packet.
2755 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1); 2760 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
2756 ProcessDataPacketAtLevel(kDefaultPathId, 102, kEntropyFlag, !kHasStopWaiting, 2761 ProcessDataPacketAtLevel(kDefaultPathId, 102, kEntropyFlag, !kHasStopWaiting,
2757 ENCRYPTION_INITIAL); 2762 ENCRYPTION_INITIAL);
2758 } 2763 }
2759 2764
2760 TEST_P(QuicConnectionTest, TestRetransmitOrder) { 2765 TEST_P(QuicConnectionTest, TestRetransmitOrder) {
2761 connection_.DisableTailLossProbe(); 2766 connection_.SetMaxTailLossProbes(kDefaultPathId, 0);
2762 2767
2763 QuicByteCount first_packet_size; 2768 QuicByteCount first_packet_size;
2764 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 2769 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
2765 .WillOnce(DoAll(SaveArg<3>(&first_packet_size), Return(true))); 2770 .WillOnce(DoAll(SaveArg<3>(&first_packet_size), Return(true)));
2766 2771
2767 connection_.SendStreamDataWithString(3, "first_packet", 0, !kFin, nullptr); 2772 connection_.SendStreamDataWithString(3, "first_packet", 0, !kFin, nullptr);
2768 QuicByteCount second_packet_size; 2773 QuicByteCount second_packet_size;
2769 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 2774 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
2770 .WillOnce(DoAll(SaveArg<3>(&second_packet_size), Return(true))); 2775 .WillOnce(DoAll(SaveArg<3>(&second_packet_size), Return(true)));
2771 connection_.SendStreamDataWithString(3, "second_packet", 12, !kFin, nullptr); 2776 connection_.SendStreamDataWithString(3, "second_packet", 12, !kFin, nullptr);
(...skipping 24 matching lines...) Expand all
2796 // Make sure that RTO is not started when the packet is queued. 2801 // Make sure that RTO is not started when the packet is queued.
2797 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); 2802 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet());
2798 2803
2799 // Test that RTO is started once we write to the socket. 2804 // Test that RTO is started once we write to the socket.
2800 writer_->SetWritable(); 2805 writer_->SetWritable();
2801 connection_.OnCanWrite(); 2806 connection_.OnCanWrite();
2802 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); 2807 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet());
2803 } 2808 }
2804 2809
2805 TEST_P(QuicConnectionTest, DelayRTOWithAckReceipt) { 2810 TEST_P(QuicConnectionTest, DelayRTOWithAckReceipt) {
2806 connection_.DisableTailLossProbe(); 2811 connection_.SetMaxTailLossProbes(kDefaultPathId, 0);
2807 2812
2808 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 2813 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2809 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2); 2814 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2);
2810 connection_.SendStreamDataWithString(2, "foo", 0, !kFin, nullptr); 2815 connection_.SendStreamDataWithString(2, "foo", 0, !kFin, nullptr);
2811 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, nullptr); 2816 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, nullptr);
2812 QuicAlarm* retransmission_alarm = connection_.GetRetransmissionAlarm(); 2817 QuicAlarm* retransmission_alarm = connection_.GetRetransmissionAlarm();
2813 EXPECT_TRUE(retransmission_alarm->IsSet()); 2818 EXPECT_TRUE(retransmission_alarm->IsSet());
2814 EXPECT_EQ(clock_.Now() + DefaultRetransmissionTime(), 2819 EXPECT_EQ(clock_.Now() + DefaultRetransmissionTime(),
2815 retransmission_alarm->deadline()); 2820 retransmission_alarm->deadline());
2816 2821
(...skipping 19 matching lines...) Expand all
2836 // The new retransmitted packet number should set the RTO to a larger value 2841 // The new retransmitted packet number should set the RTO to a larger value
2837 // than previously. 2842 // than previously.
2838 EXPECT_TRUE(retransmission_alarm->IsSet()); 2843 EXPECT_TRUE(retransmission_alarm->IsSet());
2839 QuicTime next_rto_time = retransmission_alarm->deadline(); 2844 QuicTime next_rto_time = retransmission_alarm->deadline();
2840 QuicTime expected_rto_time = 2845 QuicTime expected_rto_time =
2841 connection_.sent_packet_manager().GetRetransmissionTime(); 2846 connection_.sent_packet_manager().GetRetransmissionTime();
2842 EXPECT_EQ(next_rto_time, expected_rto_time); 2847 EXPECT_EQ(next_rto_time, expected_rto_time);
2843 } 2848 }
2844 2849
2845 TEST_P(QuicConnectionTest, TestQueued) { 2850 TEST_P(QuicConnectionTest, TestQueued) {
2846 connection_.DisableTailLossProbe(); 2851 connection_.SetMaxTailLossProbes(kDefaultPathId, 0);
2847 2852
2848 EXPECT_EQ(0u, connection_.NumQueuedPackets()); 2853 EXPECT_EQ(0u, connection_.NumQueuedPackets());
2849 BlockOnNextWrite(); 2854 BlockOnNextWrite();
2850 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, nullptr); 2855 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, nullptr);
2851 EXPECT_EQ(1u, connection_.NumQueuedPackets()); 2856 EXPECT_EQ(1u, connection_.NumQueuedPackets());
2852 2857
2853 // Unblock the writes and actually send. 2858 // Unblock the writes and actually send.
2854 writer_->SetWritable(); 2859 writer_->SetWritable();
2855 connection_.OnCanWrite(); 2860 connection_.OnCanWrite();
2856 EXPECT_EQ(0u, connection_.NumQueuedPackets()); 2861 EXPECT_EQ(0u, connection_.NumQueuedPackets());
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
3048 3053
3049 const QuicPacketCount probe_packet_number = kPacketsBetweenMtuProbesBase + 1; 3054 const QuicPacketCount probe_packet_number = kPacketsBetweenMtuProbesBase + 1;
3050 ASSERT_EQ(probe_packet_number, creator_->packet_number()); 3055 ASSERT_EQ(probe_packet_number, creator_->packet_number());
3051 3056
3052 // Acknowledge all packets sent so far. 3057 // Acknowledge all packets sent so far.
3053 QuicAckFrame probe_ack = InitAckFrame(probe_packet_number); 3058 QuicAckFrame probe_ack = InitAckFrame(probe_packet_number);
3054 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 3059 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3055 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); 3060 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
3056 ProcessAckPacket(&probe_ack); 3061 ProcessAckPacket(&probe_ack);
3057 EXPECT_EQ(kMtuDiscoveryTargetPacketSizeHigh, connection_.max_packet_length()); 3062 EXPECT_EQ(kMtuDiscoveryTargetPacketSizeHigh, connection_.max_packet_length());
3058 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); 3063 EXPECT_EQ(0u, connection_.GetBytesInFlight(kDefaultPathId));
3059 3064
3060 // Send more packets, and ensure that none of them sets the alarm. 3065 // Send more packets, and ensure that none of them sets the alarm.
3061 for (QuicPacketCount i = 0; i < 4 * kPacketsBetweenMtuProbesBase; i++) { 3066 for (QuicPacketCount i = 0; i < 4 * kPacketsBetweenMtuProbesBase; i++) {
3062 SendStreamDataToPeer(3, ".", i, /*fin=*/false, nullptr); 3067 SendStreamDataToPeer(3, ".", i, /*fin=*/false, nullptr);
3063 ASSERT_FALSE(connection_.GetMtuDiscoveryAlarm()->IsSet()); 3068 ASSERT_FALSE(connection_.GetMtuDiscoveryAlarm()->IsSet());
3064 } 3069 }
3065 3070
3066 EXPECT_EQ(1u, connection_.mtu_probe_count()); 3071 EXPECT_EQ(1u, connection_.mtu_probe_count());
3067 } 3072 }
3068 3073
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
3165 const QuicPacketCount probe_sequence_number = 3170 const QuicPacketCount probe_sequence_number =
3166 kPacketsBetweenMtuProbesBase + 1; 3171 kPacketsBetweenMtuProbesBase + 1;
3167 ASSERT_EQ(probe_sequence_number, creator_->packet_number()); 3172 ASSERT_EQ(probe_sequence_number, creator_->packet_number());
3168 3173
3169 // Acknowledge all packets sent so far. 3174 // Acknowledge all packets sent so far.
3170 QuicAckFrame probe_ack = InitAckFrame(probe_sequence_number); 3175 QuicAckFrame probe_ack = InitAckFrame(probe_sequence_number);
3171 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 3176 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3172 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); 3177 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
3173 ProcessAckPacket(&probe_ack); 3178 ProcessAckPacket(&probe_ack);
3174 EXPECT_EQ(mtu_limit, connection_.max_packet_length()); 3179 EXPECT_EQ(mtu_limit, connection_.max_packet_length());
3175 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(manager_)); 3180 EXPECT_EQ(0u, connection_.GetBytesInFlight(kDefaultPathId));
3176 3181
3177 // Send more packets, and ensure that none of them sets the alarm. 3182 // Send more packets, and ensure that none of them sets the alarm.
3178 for (QuicPacketCount i = 0; i < 4 * kPacketsBetweenMtuProbesBase; i++) { 3183 for (QuicPacketCount i = 0; i < 4 * kPacketsBetweenMtuProbesBase; i++) {
3179 SendStreamDataToPeer(3, ".", i, /*fin=*/false, nullptr); 3184 SendStreamDataToPeer(3, ".", i, /*fin=*/false, nullptr);
3180 ASSERT_FALSE(connection_.GetMtuDiscoveryAlarm()->IsSet()); 3185 ASSERT_FALSE(connection_.GetMtuDiscoveryAlarm()->IsSet());
3181 } 3186 }
3182 3187
3183 EXPECT_EQ(1u, connection_.mtu_probe_count()); 3188 EXPECT_EQ(1u, connection_.mtu_probe_count());
3184 } 3189 }
3185 3190
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
3413 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 0, !kFin, 3418 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 0, !kFin,
3414 nullptr); 3419 nullptr);
3415 connection_.GetTimeoutAlarm()->Fire(); 3420 connection_.GetTimeoutAlarm()->Fire();
3416 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1)); 3421 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1));
3417 } 3422 }
3418 EXPECT_FALSE(connection_.connected()); 3423 EXPECT_FALSE(connection_.connected());
3419 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); 3424 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet());
3420 } 3425 }
3421 3426
3422 TEST_P(QuicConnectionTest, TimeoutAfter5RTOs) { 3427 TEST_P(QuicConnectionTest, TimeoutAfter5RTOs) {
3423 QuicSentPacketManagerPeer::SetMaxTailLossProbes(manager_, 2); 3428 connection_.SetMaxTailLossProbes(kDefaultPathId, 2);
3424 EXPECT_TRUE(connection_.connected()); 3429 EXPECT_TRUE(connection_.connected());
3425 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); 3430 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
3426 QuicConfig config; 3431 QuicConfig config;
3427 QuicTagVector connection_options; 3432 QuicTagVector connection_options;
3428 connection_options.push_back(k5RTO); 3433 connection_options.push_back(k5RTO);
3429 config.SetConnectionOptionsToSend(connection_options); 3434 config.SetConnectionOptionsToSend(connection_options);
3430 connection_.SetFromConfig(config); 3435 connection_.SetFromConfig(config);
3431 3436
3432 // Send stream data. 3437 // Send stream data.
3433 SendStreamDataToPeer(kClientDataStreamId1, "foo", 0, kFin, nullptr); 3438 SendStreamDataToPeer(kClientDataStreamId1, "foo", 0, kFin, nullptr);
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
4462 ConnectionCloseSource::FROM_SELF)); 4467 ConnectionCloseSource::FROM_SELF));
4463 std::unique_ptr<QuicEncryptedPacket> encrypted( 4468 std::unique_ptr<QuicEncryptedPacket> encrypted(
4464 framer_.BuildVersionNegotiationPacket(connection_id_, 4469 framer_.BuildVersionNegotiationPacket(connection_id_,
4465 QuicSupportedVersions())); 4470 QuicSupportedVersions()));
4466 std::unique_ptr<QuicReceivedPacket> received( 4471 std::unique_ptr<QuicReceivedPacket> received(
4467 ConstructReceivedPacket(*encrypted, QuicTime::Zero())); 4472 ConstructReceivedPacket(*encrypted, QuicTime::Zero()));
4468 connection_.ProcessUdpPacket(kSelfAddress, kPeerAddress, *received); 4473 connection_.ProcessUdpPacket(kSelfAddress, kPeerAddress, *received);
4469 } 4474 }
4470 4475
4471 TEST_P(QuicConnectionTest, CheckSendStats) { 4476 TEST_P(QuicConnectionTest, CheckSendStats) {
4472 connection_.DisableTailLossProbe(); 4477 connection_.SetMaxTailLossProbes(kDefaultPathId, 0);
4473 4478
4474 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); 4479 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
4475 connection_.SendStreamDataWithString(3, "first", 0, !kFin, nullptr); 4480 connection_.SendStreamDataWithString(3, "first", 0, !kFin, nullptr);
4476 size_t first_packet_size = writer_->last_packet_size(); 4481 size_t first_packet_size = writer_->last_packet_size();
4477 4482
4478 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); 4483 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
4479 connection_.SendStreamDataWithString(5, "second", 0, !kFin, nullptr); 4484 connection_.SendStreamDataWithString(5, "second", 0, !kFin, nullptr);
4480 size_t second_packet_size = writer_->last_packet_size(); 4485 size_t second_packet_size = writer_->last_packet_size();
4481 4486
4482 // 2 retransmissions due to rto, 1 due to explicit nack. 4487 // 2 retransmissions due to rto, 1 due to explicit nack.
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
4676 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _, _)); 4681 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _, _));
4677 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); 4682 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
4678 QuicAckFrame second_ack_frame = InitAckFrame(5); 4683 QuicAckFrame second_ack_frame = InitAckFrame(5);
4679 ProcessAckPacket(&second_ack_frame); 4684 ProcessAckPacket(&second_ack_frame);
4680 } 4685 }
4681 4686
4682 // AckNotifierCallback is triggered by the ack of a packet that timed 4687 // AckNotifierCallback is triggered by the ack of a packet that timed
4683 // out and was retransmitted, even though the retransmission has a 4688 // out and was retransmitted, even though the retransmission has a
4684 // different packet number. 4689 // different packet number.
4685 TEST_P(QuicConnectionTest, AckNotifierCallbackForAckAfterRTO) { 4690 TEST_P(QuicConnectionTest, AckNotifierCallbackForAckAfterRTO) {
4686 connection_.DisableTailLossProbe(); 4691 connection_.SetMaxTailLossProbes(kDefaultPathId, 0);
4687 4692
4688 // Create a listener which we expect to be called. 4693 // Create a listener which we expect to be called.
4689 scoped_refptr<MockAckListener> listener(new StrictMock<MockAckListener>); 4694 scoped_refptr<MockAckListener> listener(new StrictMock<MockAckListener>);
4690 4695
4691 QuicTime default_retransmission_time = 4696 QuicTime default_retransmission_time =
4692 clock_.ApproximateNow() + DefaultRetransmissionTime(); 4697 clock_.ApproximateNow() + DefaultRetransmissionTime();
4693 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, listener.get()); 4698 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, listener.get());
4694 EXPECT_EQ(1u, stop_waiting()->least_unacked); 4699 EXPECT_EQ(1u, stop_waiting()->least_unacked);
4695 4700
4696 EXPECT_EQ(1u, writer_->header().packet_number); 4701 EXPECT_EQ(1u, writer_->header().packet_number);
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
4933 EXPECT_FALSE(connection_.connected()); 4938 EXPECT_FALSE(connection_.connected());
4934 } 4939 }
4935 4940
4936 TEST_P(QuicConnectionTest, OnPathDegrading) { 4941 TEST_P(QuicConnectionTest, OnPathDegrading) {
4937 QuicByteCount packet_size; 4942 QuicByteCount packet_size;
4938 const size_t kMinTimeoutsBeforePathDegrading = 2; 4943 const size_t kMinTimeoutsBeforePathDegrading = 2;
4939 4944
4940 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 4945 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
4941 .WillOnce(DoAll(SaveArg<3>(&packet_size), Return(true))); 4946 .WillOnce(DoAll(SaveArg<3>(&packet_size), Return(true)));
4942 connection_.SendStreamDataWithString(3, "packet", 0, !kFin, nullptr); 4947 connection_.SendStreamDataWithString(3, "packet", 0, !kFin, nullptr);
4943 size_t num_timeouts = 4948 size_t num_timeouts = kMinTimeoutsBeforePathDegrading +
4944 kMinTimeoutsBeforePathDegrading + 4949 QuicSentPacketManagerPeer::GetMaxTailLossProbes(
4945 QuicSentPacketManagerPeer::GetMaxTailLossProbes( 4950 QuicConnectionPeer::GetSentPacketManager(
4946 QuicConnectionPeer::GetSentPacketManager(&connection_)); 4951 &connection_, kDefaultPathId));
4947 for (size_t i = 1; i < num_timeouts; ++i) { 4952 for (size_t i = 1; i < num_timeouts; ++i) {
4948 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10 * i)); 4953 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10 * i));
4949 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, packet_size, _)); 4954 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, packet_size, _));
4950 connection_.GetRetransmissionAlarm()->Fire(); 4955 connection_.GetRetransmissionAlarm()->Fire();
4951 } 4956 }
4952 // Next RTO should cause OnPathDegrading to be called before the 4957 // Next RTO should cause OnPathDegrading to be called before the
4953 // retransmission is sent out. 4958 // retransmission is sent out.
4954 clock_.AdvanceTime( 4959 clock_.AdvanceTime(
4955 QuicTime::Delta::FromSeconds(kMinTimeoutsBeforePathDegrading * 10)); 4960 QuicTime::Delta::FromSeconds(kMinTimeoutsBeforePathDegrading * 10));
4956 { 4961 {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
5003 frame1_.data_length = data->length(); 5008 frame1_.data_length = data->length();
5004 5009
5005 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _, 5010 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _,
5006 ConnectionCloseSource::FROM_SELF)); 5011 ConnectionCloseSource::FROM_SELF));
5007 ProcessFramePacket(QuicFrame(&frame1_)); 5012 ProcessFramePacket(QuicFrame(&frame1_));
5008 } 5013 }
5009 5014
5010 } // namespace 5015 } // namespace
5011 } // namespace test 5016 } // namespace test
5012 } // namespace net 5017 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698