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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| 11 #include "net/quic/congestion_control/loss_detection_interface.h" |
11 #include "net/quic/congestion_control/receive_algorithm_interface.h" | 12 #include "net/quic/congestion_control/receive_algorithm_interface.h" |
12 #include "net/quic/congestion_control/send_algorithm_interface.h" | 13 #include "net/quic/congestion_control/send_algorithm_interface.h" |
13 #include "net/quic/crypto/null_encrypter.h" | 14 #include "net/quic/crypto/null_encrypter.h" |
14 #include "net/quic/crypto/quic_decrypter.h" | 15 #include "net/quic/crypto/quic_decrypter.h" |
15 #include "net/quic/crypto/quic_encrypter.h" | 16 #include "net/quic/crypto/quic_encrypter.h" |
16 #include "net/quic/quic_protocol.h" | 17 #include "net/quic/quic_protocol.h" |
17 #include "net/quic/quic_sent_packet_manager.h" | 18 #include "net/quic/quic_sent_packet_manager.h" |
18 #include "net/quic/quic_utils.h" | 19 #include "net/quic/quic_utils.h" |
19 #include "net/quic/test_tools/mock_clock.h" | 20 #include "net/quic/test_tools/mock_clock.h" |
20 #include "net/quic/test_tools/mock_random.h" | 21 #include "net/quic/test_tools/mock_random.h" |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 uint32 final_bytes_of_last_packet_; | 392 uint32 final_bytes_of_last_packet_; |
392 uint32 final_bytes_of_previous_packet_; | 393 uint32 final_bytes_of_previous_packet_; |
393 bool use_tagging_decrypter_; | 394 bool use_tagging_decrypter_; |
394 uint32 packets_write_attempts_; | 395 uint32 packets_write_attempts_; |
395 | 396 |
396 DISALLOW_COPY_AND_ASSIGN(TestPacketWriter); | 397 DISALLOW_COPY_AND_ASSIGN(TestPacketWriter); |
397 }; | 398 }; |
398 | 399 |
399 class TestConnection : public QuicConnection { | 400 class TestConnection : public QuicConnection { |
400 public: | 401 public: |
401 TestConnection(QuicGuid guid, | 402 TestConnection(QuicConnectionId connection_id, |
402 IPEndPoint address, | 403 IPEndPoint address, |
403 TestConnectionHelper* helper, | 404 TestConnectionHelper* helper, |
404 TestPacketWriter* writer, | 405 TestPacketWriter* writer, |
405 bool is_server, | 406 bool is_server, |
406 QuicVersion version) | 407 QuicVersion version) |
407 : QuicConnection(guid, address, helper, writer, is_server, | 408 : QuicConnection(connection_id, address, helper, writer, is_server, |
408 SupportedVersions(version)), | 409 SupportedVersions(version)), |
409 helper_(helper), | 410 helper_(helper), |
410 writer_(writer) { | 411 writer_(writer) { |
411 // Disable tail loss probes for most tests. | 412 // Disable tail loss probes for most tests. |
412 QuicSentPacketManagerPeer::SetMaxTailLossProbes( | 413 QuicSentPacketManagerPeer::SetMaxTailLossProbes( |
413 QuicConnectionPeer::GetSentPacketManager(this), 0); | 414 QuicConnectionPeer::GetSentPacketManager(this), 0); |
414 writer_->set_is_server(is_server); | 415 writer_->set_is_server(is_server); |
415 } | 416 } |
416 | 417 |
417 void SendAck() { | 418 void SendAck() { |
418 QuicConnectionPeer::SendAck(this); | 419 QuicConnectionPeer::SendAck(this); |
419 } | 420 } |
420 | 421 |
421 void SetReceiveAlgorithm(TestReceiveAlgorithm* receive_algorithm) { | 422 void SetReceiveAlgorithm(TestReceiveAlgorithm* receive_algorithm) { |
422 QuicConnectionPeer::SetReceiveAlgorithm(this, receive_algorithm); | 423 QuicConnectionPeer::SetReceiveAlgorithm(this, receive_algorithm); |
423 } | 424 } |
424 | 425 |
425 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) { | 426 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) { |
426 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm); | 427 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm); |
427 } | 428 } |
428 | 429 |
| 430 void SetLossAlgorithm(LossDetectionInterface* loss_algorithm) { |
| 431 QuicSentPacketManagerPeer::SetLossAlgorithm( |
| 432 QuicConnectionPeer::GetSentPacketManager(this), loss_algorithm); |
| 433 } |
| 434 |
429 void SendPacket(EncryptionLevel level, | 435 void SendPacket(EncryptionLevel level, |
430 QuicPacketSequenceNumber sequence_number, | 436 QuicPacketSequenceNumber sequence_number, |
431 QuicPacket* packet, | 437 QuicPacket* packet, |
432 QuicPacketEntropyHash entropy_hash, | 438 QuicPacketEntropyHash entropy_hash, |
433 HasRetransmittableData retransmittable) { | 439 HasRetransmittableData retransmittable) { |
434 RetransmittableFrames* retransmittable_frames = | 440 RetransmittableFrames* retransmittable_frames = |
435 retransmittable == HAS_RETRANSMITTABLE_DATA ? | 441 retransmittable == HAS_RETRANSMITTABLE_DATA ? |
436 new RetransmittableFrames() : NULL; | 442 new RetransmittableFrames() : NULL; |
437 OnSerializedPacket( | 443 OnSerializedPacket( |
438 SerializedPacket(sequence_number, PACKET_6BYTE_SEQUENCE_NUMBER, | 444 SerializedPacket(sequence_number, PACKET_6BYTE_SEQUENCE_NUMBER, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 private: | 534 private: |
529 TestConnectionHelper* helper_; | 535 TestConnectionHelper* helper_; |
530 TestPacketWriter* writer_; | 536 TestPacketWriter* writer_; |
531 | 537 |
532 DISALLOW_COPY_AND_ASSIGN(TestConnection); | 538 DISALLOW_COPY_AND_ASSIGN(TestConnection); |
533 }; | 539 }; |
534 | 540 |
535 class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> { | 541 class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> { |
536 protected: | 542 protected: |
537 QuicConnectionTest() | 543 QuicConnectionTest() |
538 : guid_(42), | 544 : connection_id_(42), |
539 framer_(SupportedVersions(version()), QuicTime::Zero(), false), | 545 framer_(SupportedVersions(version()), QuicTime::Zero(), false), |
540 creator_(guid_, &framer_, &random_generator_, false), | 546 creator_(connection_id_, &framer_, &random_generator_, false), |
541 send_algorithm_(new StrictMock<MockSendAlgorithm>), | 547 send_algorithm_(new StrictMock<MockSendAlgorithm>), |
| 548 loss_algorithm_(new MockLossAlgorithm()), |
542 helper_(new TestConnectionHelper(&clock_, &random_generator_)), | 549 helper_(new TestConnectionHelper(&clock_, &random_generator_)), |
543 writer_(new TestPacketWriter(version())), | 550 writer_(new TestPacketWriter(version())), |
544 connection_(guid_, IPEndPoint(), helper_.get(), writer_.get(), | 551 connection_(connection_id_, IPEndPoint(), helper_.get(), |
545 false, version()), | 552 writer_.get(), false, version()), |
546 frame1_(1, false, 0, MakeIOVector(data1)), | 553 frame1_(1, false, 0, MakeIOVector(data1)), |
547 frame2_(1, false, 3, MakeIOVector(data2)), | 554 frame2_(1, false, 3, MakeIOVector(data2)), |
548 accept_packet_(true) { | 555 accept_packet_(true) { |
549 connection_.set_visitor(&visitor_); | 556 connection_.set_visitor(&visitor_); |
550 connection_.SetSendAlgorithm(send_algorithm_); | 557 connection_.SetSendAlgorithm(send_algorithm_); |
| 558 connection_.SetLossAlgorithm(loss_algorithm_); |
551 framer_.set_received_entropy_calculator(&entropy_calculator_); | 559 framer_.set_received_entropy_calculator(&entropy_calculator_); |
552 // Simplify tests by not sending feedback unless specifically configured. | 560 // Simplify tests by not sending feedback unless specifically configured. |
553 SetFeedback(NULL); | 561 SetFeedback(NULL); |
554 EXPECT_CALL( | 562 EXPECT_CALL( |
555 *send_algorithm_, TimeUntilSend(_, _, _, _)).WillRepeatedly(Return( | 563 *send_algorithm_, TimeUntilSend(_, _, _, _)).WillRepeatedly(Return( |
556 QuicTime::Delta::Zero())); | 564 QuicTime::Delta::Zero())); |
557 EXPECT_CALL(*receive_algorithm_, | 565 EXPECT_CALL(*receive_algorithm_, |
558 RecordIncomingPacket(_, _, _)).Times(AnyNumber()); | 566 RecordIncomingPacket(_, _, _)).Times(AnyNumber()); |
559 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 567 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
560 .Times(AnyNumber()); | 568 .Times(AnyNumber()); |
561 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()).WillRepeatedly( | 569 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()).WillRepeatedly( |
562 Return(QuicTime::Delta::Zero())); | 570 Return(QuicTime::Delta::Zero())); |
563 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillRepeatedly(Return( | 571 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillRepeatedly(Return( |
564 QuicBandwidth::FromKBitsPerSecond(100))); | 572 QuicBandwidth::FromKBitsPerSecond(100))); |
565 EXPECT_CALL(*send_algorithm_, SmoothedRtt()).WillRepeatedly(Return( | 573 EXPECT_CALL(*send_algorithm_, SmoothedRtt()).WillRepeatedly(Return( |
566 QuicTime::Delta::FromMilliseconds(100))); | 574 QuicTime::Delta::FromMilliseconds(100))); |
567 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 575 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
568 .WillByDefault(Return(true)); | 576 .WillByDefault(Return(true)); |
569 EXPECT_CALL(visitor_, HasPendingWrites()).Times(AnyNumber()); | 577 EXPECT_CALL(visitor_, HasPendingWrites()).Times(AnyNumber()); |
570 EXPECT_CALL(visitor_, HasPendingHandshake()).Times(AnyNumber()); | 578 EXPECT_CALL(visitor_, HasPendingHandshake()).Times(AnyNumber()); |
571 EXPECT_CALL(visitor_, OnCanWrite()).Times(AnyNumber()); | 579 EXPECT_CALL(visitor_, OnCanWrite()).Times(AnyNumber()); |
| 580 |
| 581 EXPECT_CALL(*loss_algorithm_, GetLossTimeout()) |
| 582 .WillRepeatedly(Return(QuicTime::Zero())); |
| 583 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) |
| 584 .WillRepeatedly(Return(SequenceNumberSet())); |
572 } | 585 } |
573 | 586 |
574 QuicVersion version() { | 587 QuicVersion version() { |
575 return GetParam(); | 588 return GetParam(); |
576 } | 589 } |
577 | 590 |
578 QuicAckFrame* outgoing_ack() { | 591 QuicAckFrame* outgoing_ack() { |
579 outgoing_ack_.reset(QuicConnectionPeer::CreateAckFrame(&connection_)); | 592 outgoing_ack_.reset(QuicConnectionPeer::CreateAckFrame(&connection_)); |
580 return outgoing_ack_.get(); | 593 return outgoing_ack_.get(); |
581 } | 594 } |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 // Construct the decrypted data packet so we can compute the correct | 714 // Construct the decrypted data packet so we can compute the correct |
702 // redundancy. If |packet| has been provided then use that, otherwise | 715 // redundancy. If |packet| has been provided then use that, otherwise |
703 // construct a default data packet. | 716 // construct a default data packet. |
704 scoped_ptr<QuicPacket> data_packet; | 717 scoped_ptr<QuicPacket> data_packet; |
705 if (packet) { | 718 if (packet) { |
706 data_packet.reset(packet); | 719 data_packet.reset(packet); |
707 } else { | 720 } else { |
708 data_packet.reset(ConstructDataPacket(number, 1, !kEntropyFlag)); | 721 data_packet.reset(ConstructDataPacket(number, 1, !kEntropyFlag)); |
709 } | 722 } |
710 | 723 |
711 header_.public_header.guid = guid_; | 724 header_.public_header.connection_id = connection_id_; |
712 header_.public_header.reset_flag = false; | 725 header_.public_header.reset_flag = false; |
713 header_.public_header.version_flag = false; | 726 header_.public_header.version_flag = false; |
714 header_.entropy_flag = entropy_flag; | 727 header_.entropy_flag = entropy_flag; |
715 header_.fec_flag = true; | 728 header_.fec_flag = true; |
716 header_.packet_sequence_number = number; | 729 header_.packet_sequence_number = number; |
717 header_.is_in_fec_group = IN_FEC_GROUP; | 730 header_.is_in_fec_group = IN_FEC_GROUP; |
718 header_.fec_group = min_protected_packet; | 731 header_.fec_group = min_protected_packet; |
719 QuicFecData fec_data; | 732 QuicFecData fec_data; |
720 fec_data.fec_group = header_.fec_group; | 733 fec_data.fec_group = header_.fec_group; |
721 | 734 |
722 // Since all data packets in this test have the same payload, the | 735 // Since all data packets in this test have the same payload, the |
723 // redundancy is either equal to that payload or the xor of that payload | 736 // redundancy is either equal to that payload or the xor of that payload |
724 // with itself, depending on the number of packets. | 737 // with itself, depending on the number of packets. |
725 if (((number - min_protected_packet) % 2) == 0) { | 738 if (((number - min_protected_packet) % 2) == 0) { |
726 for (size_t i = GetStartOfFecProtectedData( | 739 for (size_t i = GetStartOfFecProtectedData( |
727 header_.public_header.guid_length, | 740 header_.public_header.connection_id_length, |
728 header_.public_header.version_flag, | 741 header_.public_header.version_flag, |
729 header_.public_header.sequence_number_length); | 742 header_.public_header.sequence_number_length); |
730 i < data_packet->length(); ++i) { | 743 i < data_packet->length(); ++i) { |
731 data_packet->mutable_data()[i] ^= data_packet->data()[i]; | 744 data_packet->mutable_data()[i] ^= data_packet->data()[i]; |
732 } | 745 } |
733 } | 746 } |
734 fec_data.redundancy = data_packet->FecProtectedData(); | 747 fec_data.redundancy = data_packet->FecProtectedData(); |
735 | 748 |
736 scoped_ptr<QuicPacket> fec_packet( | 749 scoped_ptr<QuicPacket> fec_packet( |
737 framer_.BuildFecPacket(header_, fec_data).packet); | 750 framer_.BuildFecPacket(header_, fec_data).packet); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 return ProcessFramePacket(QuicFrame(frame)); | 792 return ProcessFramePacket(QuicFrame(frame)); |
780 } | 793 } |
781 | 794 |
782 bool IsMissing(QuicPacketSequenceNumber number) { | 795 bool IsMissing(QuicPacketSequenceNumber number) { |
783 return IsAwaitingPacket(outgoing_ack()->received_info, number); | 796 return IsAwaitingPacket(outgoing_ack()->received_info, number); |
784 } | 797 } |
785 | 798 |
786 QuicPacket* ConstructDataPacket(QuicPacketSequenceNumber number, | 799 QuicPacket* ConstructDataPacket(QuicPacketSequenceNumber number, |
787 QuicFecGroupNumber fec_group, | 800 QuicFecGroupNumber fec_group, |
788 bool entropy_flag) { | 801 bool entropy_flag) { |
789 header_.public_header.guid = guid_; | 802 header_.public_header.connection_id = connection_id_; |
790 header_.public_header.reset_flag = false; | 803 header_.public_header.reset_flag = false; |
791 header_.public_header.version_flag = false; | 804 header_.public_header.version_flag = false; |
792 header_.entropy_flag = entropy_flag; | 805 header_.entropy_flag = entropy_flag; |
793 header_.fec_flag = false; | 806 header_.fec_flag = false; |
794 header_.packet_sequence_number = number; | 807 header_.packet_sequence_number = number; |
795 header_.is_in_fec_group = fec_group == 0u ? NOT_IN_FEC_GROUP : IN_FEC_GROUP; | 808 header_.is_in_fec_group = fec_group == 0u ? NOT_IN_FEC_GROUP : IN_FEC_GROUP; |
796 header_.fec_group = fec_group; | 809 header_.fec_group = fec_group; |
797 | 810 |
798 QuicFrames frames; | 811 QuicFrames frames; |
799 QuicFrame frame(&frame1_); | 812 QuicFrame frame(&frame1_); |
800 frames.push_back(frame); | 813 frames.push_back(frame); |
801 QuicPacket* packet = | 814 QuicPacket* packet = |
802 framer_.BuildUnsizedDataPacket(header_, frames).packet; | 815 framer_.BuildUnsizedDataPacket(header_, frames).packet; |
803 EXPECT_TRUE(packet != NULL); | 816 EXPECT_TRUE(packet != NULL); |
804 return packet; | 817 return packet; |
805 } | 818 } |
806 | 819 |
807 QuicPacket* ConstructClosePacket(QuicPacketSequenceNumber number, | 820 QuicPacket* ConstructClosePacket(QuicPacketSequenceNumber number, |
808 QuicFecGroupNumber fec_group) { | 821 QuicFecGroupNumber fec_group) { |
809 header_.public_header.guid = guid_; | 822 header_.public_header.connection_id = connection_id_; |
810 header_.packet_sequence_number = number; | 823 header_.packet_sequence_number = number; |
811 header_.public_header.reset_flag = false; | 824 header_.public_header.reset_flag = false; |
812 header_.public_header.version_flag = false; | 825 header_.public_header.version_flag = false; |
813 header_.entropy_flag = false; | 826 header_.entropy_flag = false; |
814 header_.fec_flag = false; | 827 header_.fec_flag = false; |
815 header_.is_in_fec_group = fec_group == 0u ? NOT_IN_FEC_GROUP : IN_FEC_GROUP; | 828 header_.is_in_fec_group = fec_group == 0u ? NOT_IN_FEC_GROUP : IN_FEC_GROUP; |
816 header_.fec_group = fec_group; | 829 header_.fec_group = fec_group; |
817 | 830 |
818 QuicConnectionCloseFrame qccf; | 831 QuicConnectionCloseFrame qccf; |
819 qccf.error_code = QUIC_PEER_GOING_AWAY; | 832 qccf.error_code = QUIC_PEER_GOING_AWAY; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 ProcessDataPacket(6000, 0, !kEntropyFlag); | 902 ProcessDataPacket(6000, 0, !kEntropyFlag); |
890 EXPECT_FALSE( | 903 EXPECT_FALSE( |
891 QuicConnectionPeer::GetConnectionClosePacket(&connection_) == NULL); | 904 QuicConnectionPeer::GetConnectionClosePacket(&connection_) == NULL); |
892 } | 905 } |
893 | 906 |
894 void BlockOnNextWrite() { | 907 void BlockOnNextWrite() { |
895 writer_->BlockOnNextWrite(); | 908 writer_->BlockOnNextWrite(); |
896 EXPECT_CALL(visitor_, OnWriteBlocked()).Times(AtLeast(1)); | 909 EXPECT_CALL(visitor_, OnWriteBlocked()).Times(AtLeast(1)); |
897 } | 910 } |
898 | 911 |
899 QuicGuid guid_; | 912 QuicConnectionId connection_id_; |
900 QuicFramer framer_; | 913 QuicFramer framer_; |
901 QuicPacketCreator creator_; | 914 QuicPacketCreator creator_; |
902 MockEntropyCalculator entropy_calculator_; | 915 MockEntropyCalculator entropy_calculator_; |
903 | 916 |
904 MockSendAlgorithm* send_algorithm_; | 917 MockSendAlgorithm* send_algorithm_; |
| 918 MockLossAlgorithm* loss_algorithm_; |
905 TestReceiveAlgorithm* receive_algorithm_; | 919 TestReceiveAlgorithm* receive_algorithm_; |
906 MockClock clock_; | 920 MockClock clock_; |
907 MockRandom random_generator_; | 921 MockRandom random_generator_; |
908 scoped_ptr<TestConnectionHelper> helper_; | 922 scoped_ptr<TestConnectionHelper> helper_; |
909 scoped_ptr<TestPacketWriter> writer_; | 923 scoped_ptr<TestPacketWriter> writer_; |
910 TestConnection connection_; | 924 TestConnection connection_; |
911 StrictMock<MockConnectionVisitor> visitor_; | 925 StrictMock<MockConnectionVisitor> visitor_; |
912 | 926 |
913 QuicPacketHeader header_; | 927 QuicPacketHeader header_; |
914 QuicStreamFrame frame1_; | 928 QuicStreamFrame frame1_; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 } | 1045 } |
1032 | 1046 |
1033 TEST_P(QuicConnectionTest, TruncatedAck) { | 1047 TEST_P(QuicConnectionTest, TruncatedAck) { |
1034 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1048 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1035 QuicPacketSequenceNumber num_packets = 256 * 2 + 1; | 1049 QuicPacketSequenceNumber num_packets = 256 * 2 + 1; |
1036 for (QuicPacketSequenceNumber i = 0; i < num_packets; ++i) { | 1050 for (QuicPacketSequenceNumber i = 0; i < num_packets; ++i) { |
1037 SendStreamDataToPeer(3, "foo", i * 3, !kFin, NULL); | 1051 SendStreamDataToPeer(3, "foo", i * 3, !kFin, NULL); |
1038 } | 1052 } |
1039 | 1053 |
1040 QuicAckFrame frame = InitAckFrame(num_packets, 1); | 1054 QuicAckFrame frame = InitAckFrame(num_packets, 1); |
| 1055 SequenceNumberSet lost_packets; |
1041 // Create an ack with 256 nacks, none adjacent to one another. | 1056 // Create an ack with 256 nacks, none adjacent to one another. |
1042 for (QuicPacketSequenceNumber i = 1; i <= 256; ++i) { | 1057 for (QuicPacketSequenceNumber i = 1; i <= 256; ++i) { |
1043 NackPacket(i * 2, &frame); | 1058 NackPacket(i * 2, &frame); |
| 1059 if (i < 256) { // Last packet is nacked, but not lost. |
| 1060 lost_packets.insert(i * 2); |
| 1061 } |
1044 } | 1062 } |
| 1063 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) |
| 1064 .WillOnce(Return(lost_packets)); |
1045 EXPECT_CALL(entropy_calculator_, | 1065 EXPECT_CALL(entropy_calculator_, |
1046 EntropyHash(511)).WillOnce(testing::Return(0)); | 1066 EntropyHash(511)).WillOnce(testing::Return(0)); |
1047 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 1067 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
1048 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(256); | 1068 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(256); |
1049 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(255); | 1069 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(255); |
1050 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(255); | 1070 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(255); |
1051 ProcessAckPacket(&frame); | 1071 ProcessAckPacket(&frame); |
1052 | 1072 |
1053 QuicReceivedPacketManager* received_packet_manager = | 1073 QuicReceivedPacketManager* received_packet_manager = |
1054 QuicConnectionPeer::GetReceivedPacketManager(&connection_); | 1074 QuicConnectionPeer::GetReceivedPacketManager(&connection_); |
1055 // A truncated ack will not have the true largest observed. | 1075 // A truncated ack will not have the true largest observed. |
1056 EXPECT_GT(num_packets, | 1076 EXPECT_GT(num_packets, |
1057 received_packet_manager->peer_largest_observed_packet()); | 1077 received_packet_manager->peer_largest_observed_packet()); |
1058 | 1078 |
1059 AckPacket(192, &frame); | 1079 AckPacket(192, &frame); |
1060 | 1080 |
1061 // Removing one missing packet allows us to ack 192 and one more range, but | 1081 // Removing one missing packet allows us to ack 192 and one more range, but |
1062 // 192 has already been declared lost, so it doesn't register as an ack. | 1082 // 192 has already been declared lost, so it doesn't register as an ack. |
| 1083 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) |
| 1084 .WillOnce(Return(SequenceNumberSet())); |
1063 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 1085 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
1064 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1); | 1086 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1); |
1065 ProcessAckPacket(&frame); | 1087 ProcessAckPacket(&frame); |
1066 EXPECT_EQ(num_packets, | 1088 EXPECT_EQ(num_packets, |
1067 received_packet_manager->peer_largest_observed_packet()); | 1089 received_packet_manager->peer_largest_observed_packet()); |
1068 } | 1090 } |
1069 | 1091 |
1070 TEST_P(QuicConnectionTest, AckReceiptCausesAckSendBadEntropy) { | 1092 TEST_P(QuicConnectionTest, AckReceiptCausesAckSendBadEntropy) { |
1071 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1093 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1072 | 1094 |
(...skipping 30 matching lines...) Expand all Loading... |
1103 // Should ack immediately, since this fills the last hole. | 1125 // Should ack immediately, since this fills the last hole. |
1104 EXPECT_EQ(3u, writer_->packets_write_attempts()); | 1126 EXPECT_EQ(3u, writer_->packets_write_attempts()); |
1105 | 1127 |
1106 ProcessPacket(4); | 1128 ProcessPacket(4); |
1107 // Should not cause an ack. | 1129 // Should not cause an ack. |
1108 EXPECT_EQ(3u, writer_->packets_write_attempts()); | 1130 EXPECT_EQ(3u, writer_->packets_write_attempts()); |
1109 } | 1131 } |
1110 | 1132 |
1111 TEST_P(QuicConnectionTest, AckReceiptCausesAckSend) { | 1133 TEST_P(QuicConnectionTest, AckReceiptCausesAckSend) { |
1112 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1134 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1113 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(1); | 1135 |
1114 QuicPacketSequenceNumber original; | 1136 QuicPacketSequenceNumber original; |
1115 QuicByteCount packet_size; | 1137 QuicByteCount packet_size; |
1116 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, _)) | 1138 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, _)) |
1117 .WillOnce(DoAll(SaveArg<1>(&original), SaveArg<2>(&packet_size), | 1139 .WillOnce(DoAll(SaveArg<1>(&original), SaveArg<2>(&packet_size), |
1118 Return(true))); | 1140 Return(true))); |
1119 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1); | |
1120 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); | 1141 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); |
1121 QuicAckFrame frame = InitAckFrame(original, 1); | 1142 QuicAckFrame frame = InitAckFrame(original, 1); |
1122 NackPacket(original, &frame); | 1143 NackPacket(original, &frame); |
1123 // First nack triggers early retransmit. | 1144 // First nack triggers early retransmit. |
| 1145 SequenceNumberSet lost_packets; |
| 1146 lost_packets.insert(1); |
| 1147 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) |
| 1148 .WillOnce(Return(lost_packets)); |
1124 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 1149 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
| 1150 EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)).Times(1); |
| 1151 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1); |
1125 QuicPacketSequenceNumber retransmission; | 1152 QuicPacketSequenceNumber retransmission; |
1126 EXPECT_CALL(*send_algorithm_, | 1153 EXPECT_CALL(*send_algorithm_, |
1127 OnPacketSent(_, _, packet_size - kQuicVersionSize, | 1154 OnPacketSent(_, _, packet_size - kQuicVersionSize, |
1128 NACK_RETRANSMISSION, _)) | 1155 NACK_RETRANSMISSION, _)) |
1129 .WillOnce(DoAll(SaveArg<1>(&retransmission), Return(true))); | 1156 .WillOnce(DoAll(SaveArg<1>(&retransmission), Return(true))); |
1130 | 1157 |
1131 ProcessAckPacket(&frame); | 1158 ProcessAckPacket(&frame); |
1132 | 1159 |
1133 QuicAckFrame frame2 = InitAckFrame(retransmission, 1); | 1160 QuicAckFrame frame2 = InitAckFrame(retransmission, 1); |
1134 NackPacket(original, &frame2); | 1161 NackPacket(original, &frame2); |
1135 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 1162 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
1136 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)); | 1163 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)); |
| 1164 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) |
| 1165 .WillOnce(Return(SequenceNumberSet())); |
1137 ProcessAckPacket(&frame2); | 1166 ProcessAckPacket(&frame2); |
1138 | 1167 |
1139 // Now if the peer sends an ack which still reports the retransmitted packet | 1168 // Now if the peer sends an ack which still reports the retransmitted packet |
1140 // as missing, that will bundle an ack with data after two acks in a row | 1169 // as missing, that will bundle an ack with data after two acks in a row |
1141 // indicate the high water mark needs to be raised. | 1170 // indicate the high water mark needs to be raised. |
1142 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, | 1171 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, |
1143 HAS_RETRANSMITTABLE_DATA)); | 1172 HAS_RETRANSMITTABLE_DATA)); |
1144 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, NULL); | 1173 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, NULL); |
1145 // No ack sent. | 1174 // No ack sent. |
1146 EXPECT_EQ(1u, writer_->frame_count()); | 1175 EXPECT_EQ(1u, writer_->frame_count()); |
1147 EXPECT_EQ(1u, writer_->stream_frames()->size()); | 1176 EXPECT_EQ(1u, writer_->stream_frames()->size()); |
1148 writer_->Reset(); | 1177 writer_->Reset(); |
1149 | 1178 |
| 1179 // No more packet loss for the rest of the test. |
| 1180 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) |
| 1181 .WillRepeatedly(Return(SequenceNumberSet())); |
1150 ProcessAckPacket(&frame2); | 1182 ProcessAckPacket(&frame2); |
1151 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, | 1183 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, |
1152 HAS_RETRANSMITTABLE_DATA)); | 1184 HAS_RETRANSMITTABLE_DATA)); |
1153 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, NULL); | 1185 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, NULL); |
1154 // Ack bundled. | 1186 // Ack bundled. |
1155 if (version() > QUIC_VERSION_15) { | 1187 if (version() > QUIC_VERSION_15) { |
1156 EXPECT_EQ(3u, writer_->frame_count()); | 1188 EXPECT_EQ(3u, writer_->frame_count()); |
1157 } else { | 1189 } else { |
1158 EXPECT_EQ(2u, writer_->frame_count()); | 1190 EXPECT_EQ(2u, writer_->frame_count()); |
1159 } | 1191 } |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1516 // Advance the time so not all the FEC packets are abandoned. | 1548 // Advance the time so not all the FEC packets are abandoned. |
1517 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); | 1549 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); |
1518 connection_.SendStreamDataWithString(3, "foo", 6, !kFin, NULL); | 1550 connection_.SendStreamDataWithString(3, "foo", 6, !kFin, NULL); |
1519 | 1551 |
1520 QuicAckFrame ack_fec = InitAckFrame(5, 1); | 1552 QuicAckFrame ack_fec = InitAckFrame(5, 1); |
1521 // Ack all data packets, but no fec packets. | 1553 // Ack all data packets, but no fec packets. |
1522 NackPacket(2, &ack_fec); | 1554 NackPacket(2, &ack_fec); |
1523 NackPacket(4, &ack_fec); | 1555 NackPacket(4, &ack_fec); |
1524 | 1556 |
1525 // Lose the first FEC packet and ack the three data packets. | 1557 // Lose the first FEC packet and ack the three data packets. |
| 1558 SequenceNumberSet lost_packets; |
| 1559 lost_packets.insert(2); |
| 1560 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) |
| 1561 .WillOnce(Return(lost_packets)); |
1526 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 1562 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
1527 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(3); | 1563 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(3); |
1528 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)); | 1564 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)); |
1529 EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _)); | 1565 EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _)); |
1530 ProcessAckPacket(&ack_fec); | 1566 ProcessAckPacket(&ack_fec); |
1531 | 1567 |
1532 clock_.AdvanceTime(DefaultRetransmissionTime().Subtract( | 1568 clock_.AdvanceTime(DefaultRetransmissionTime().Subtract( |
1533 QuicTime::Delta::FromMilliseconds(1))); | 1569 QuicTime::Delta::FromMilliseconds(1))); |
1534 | 1570 |
1535 // Abandon all packets | 1571 // Abandon all packets |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1781 | 1817 |
1782 // Parse the last packet and ensure it's the two stream frames from | 1818 // Parse the last packet and ensure it's the two stream frames from |
1783 // two different streams. | 1819 // two different streams. |
1784 EXPECT_EQ(2u, writer_->frame_count()); | 1820 EXPECT_EQ(2u, writer_->frame_count()); |
1785 EXPECT_EQ(2u, writer_->stream_frames()->size()); | 1821 EXPECT_EQ(2u, writer_->stream_frames()->size()); |
1786 EXPECT_EQ(kStreamId3, (*writer_->stream_frames())[0].stream_id); | 1822 EXPECT_EQ(kStreamId3, (*writer_->stream_frames())[0].stream_id); |
1787 EXPECT_EQ(kStreamId5, (*writer_->stream_frames())[1].stream_id); | 1823 EXPECT_EQ(kStreamId5, (*writer_->stream_frames())[1].stream_id); |
1788 } | 1824 } |
1789 | 1825 |
1790 TEST_P(QuicConnectionTest, RetransmitOnNack) { | 1826 TEST_P(QuicConnectionTest, RetransmitOnNack) { |
1791 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | |
1792 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)); | |
1793 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(1); | |
1794 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)).Times(1); | |
1795 QuicPacketSequenceNumber last_packet; | 1827 QuicPacketSequenceNumber last_packet; |
1796 QuicByteCount second_packet_size; | 1828 QuicByteCount second_packet_size; |
1797 SendStreamDataToPeer(3, "foo", 0, !kFin, &last_packet); // Packet 1 | 1829 SendStreamDataToPeer(3, "foo", 0, !kFin, &last_packet); // Packet 1 |
1798 second_packet_size = | 1830 second_packet_size = |
1799 SendStreamDataToPeer(3, "foos", 3, !kFin, &last_packet); // Packet 2 | 1831 SendStreamDataToPeer(3, "foos", 3, !kFin, &last_packet); // Packet 2 |
1800 SendStreamDataToPeer(3, "fooos", 7, !kFin, &last_packet); // Packet 3 | 1832 SendStreamDataToPeer(3, "fooos", 7, !kFin, &last_packet); // Packet 3 |
1801 | 1833 |
1802 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1834 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1803 | 1835 |
1804 // Peer acks one but not two or three. Right now we only retransmit on | 1836 // Don't lose a packet on an ack, and nothing is retransmitted. |
1805 // explicit nack, so it should not trigger a retransmission. | 1837 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
| 1838 EXPECT_CALL(*send_algorithm_, OnPacketAcked(1, _)); |
1806 QuicAckFrame ack_one = InitAckFrame(1, 0); | 1839 QuicAckFrame ack_one = InitAckFrame(1, 0); |
1807 ProcessAckPacket(&ack_one); | 1840 ProcessAckPacket(&ack_one); |
1808 ProcessAckPacket(&ack_one); | |
1809 ProcessAckPacket(&ack_one); | |
1810 | 1841 |
1811 // Peer acks up to 3 with two explicitly missing. | 1842 // Lose a packet and ensure it triggers retransmission. |
1812 // Early retransmit causes 2 to be retransmitted on the first ack. | |
1813 QuicAckFrame nack_two = InitAckFrame(3, 0); | 1843 QuicAckFrame nack_two = InitAckFrame(3, 0); |
1814 NackPacket(2, &nack_two); | 1844 NackPacket(2, &nack_two); |
1815 // The third nack should trigger a retransmission. | 1845 SequenceNumberSet lost_packets; |
| 1846 lost_packets.insert(2); |
| 1847 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) |
| 1848 .WillOnce(Return(lost_packets)); |
1816 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 1849 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
1817 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)); | 1850 EXPECT_CALL(*send_algorithm_, OnPacketAcked(3, _)); |
| 1851 EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _)).Times(1); |
| 1852 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)).Times(1); |
1818 EXPECT_CALL(*send_algorithm_, | 1853 EXPECT_CALL(*send_algorithm_, |
1819 OnPacketSent(_, _, second_packet_size - kQuicVersionSize, | 1854 OnPacketSent(_, _, second_packet_size - kQuicVersionSize, |
1820 NACK_RETRANSMISSION, _)).Times(1); | 1855 NACK_RETRANSMISSION, _)).Times(1); |
1821 ProcessAckPacket(&nack_two); | 1856 ProcessAckPacket(&nack_two); |
1822 } | 1857 } |
1823 | 1858 |
1824 TEST_P(QuicConnectionTest, DiscardRetransmit) { | 1859 TEST_P(QuicConnectionTest, DiscardRetransmit) { |
1825 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | |
1826 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)); | |
1827 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(1); | |
1828 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)).Times(1); | |
1829 QuicPacketSequenceNumber last_packet; | 1860 QuicPacketSequenceNumber last_packet; |
1830 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1 | 1861 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1 |
1831 SendStreamDataToPeer(1, "foos", 3, !kFin, &last_packet); // Packet 2 | 1862 SendStreamDataToPeer(1, "foos", 3, !kFin, &last_packet); // Packet 2 |
1832 SendStreamDataToPeer(1, "fooos", 7, !kFin, &last_packet); // Packet 3 | 1863 SendStreamDataToPeer(1, "fooos", 7, !kFin, &last_packet); // Packet 3 |
1833 | 1864 |
1834 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1865 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1835 | 1866 |
1836 // Peer acks one but not two or three. Right now we only retransmit on | 1867 // Instigate a loss with an ack. |
1837 // explicit nack, so it should not trigger a retransmission. | |
1838 QuicAckFrame ack_one = InitAckFrame(1, 0); | |
1839 ProcessAckPacket(&ack_one); | |
1840 ProcessAckPacket(&ack_one); | |
1841 ProcessAckPacket(&ack_one); | |
1842 | |
1843 // Peer acks up to 3 with two explicitly missing. Two nacks should cause no | |
1844 // change. | |
1845 QuicAckFrame nack_two = InitAckFrame(3, 0); | 1868 QuicAckFrame nack_two = InitAckFrame(3, 0); |
1846 NackPacket(2, &nack_two); | 1869 NackPacket(2, &nack_two); |
1847 // The first nack should trigger a fast retransmission, but we'll be | 1870 // The first nack should trigger a fast retransmission, but we'll be |
1848 // write blocked, so the packet will be queued. | 1871 // write blocked, so the packet will be queued. |
1849 BlockOnNextWrite(); | 1872 BlockOnNextWrite(); |
| 1873 SequenceNumberSet lost_packets; |
| 1874 lost_packets.insert(2); |
| 1875 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) |
| 1876 .WillOnce(Return(lost_packets)); |
1850 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 1877 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
1851 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)); | 1878 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(2); |
| 1879 EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _)); |
| 1880 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)); |
1852 ProcessAckPacket(&nack_two); | 1881 ProcessAckPacket(&nack_two); |
1853 EXPECT_EQ(1u, connection_.NumQueuedPackets()); | 1882 EXPECT_EQ(1u, connection_.NumQueuedPackets()); |
1854 | 1883 |
1855 // Now, ack the previous transmission. | 1884 // Now, ack the previous transmission. |
| 1885 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) |
| 1886 .WillOnce(Return(SequenceNumberSet())); |
1856 QuicAckFrame ack_all = InitAckFrame(3, 0); | 1887 QuicAckFrame ack_all = InitAckFrame(3, 0); |
1857 ProcessAckPacket(&ack_all); | 1888 ProcessAckPacket(&ack_all); |
1858 | 1889 |
1859 // Unblock the socket and attempt to send the queued packets. However, | 1890 // Unblock the socket and attempt to send the queued packets. However, |
1860 // since the previous transmission has been acked, we will not | 1891 // since the previous transmission has been acked, we will not |
1861 // send the retransmission. | 1892 // send the retransmission. |
1862 EXPECT_CALL(*send_algorithm_, | 1893 EXPECT_CALL(*send_algorithm_, |
1863 OnPacketSent(_, _, _, _, _)).Times(0); | 1894 OnPacketSent(_, _, _, _, _)).Times(0); |
1864 | 1895 |
1865 writer_->SetWritable(); | 1896 writer_->SetWritable(); |
1866 connection_.OnCanWrite(); | 1897 connection_.OnCanWrite(); |
1867 | 1898 |
1868 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 1899 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
1869 } | 1900 } |
1870 | 1901 |
1871 TEST_P(QuicConnectionTest, RetransmitNackedLargestObserved) { | 1902 TEST_P(QuicConnectionTest, RetransmitNackedLargestObserved) { |
1872 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1903 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1873 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(1); | |
1874 QuicPacketSequenceNumber largest_observed; | 1904 QuicPacketSequenceNumber largest_observed; |
1875 QuicByteCount packet_size; | 1905 QuicByteCount packet_size; |
1876 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, _)) | 1906 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, _)) |
1877 .WillOnce(DoAll(SaveArg<1>(&largest_observed), SaveArg<2>(&packet_size), | 1907 .WillOnce(DoAll(SaveArg<1>(&largest_observed), SaveArg<2>(&packet_size), |
1878 Return(true))); | 1908 Return(true))); |
1879 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1); | |
1880 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); | 1909 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); |
| 1910 |
1881 QuicAckFrame frame = InitAckFrame(1, largest_observed); | 1911 QuicAckFrame frame = InitAckFrame(1, largest_observed); |
1882 NackPacket(largest_observed, &frame); | 1912 NackPacket(largest_observed, &frame); |
1883 // The first nack should retransmit the largest observed packet. | 1913 // The first nack should retransmit the largest observed packet. |
| 1914 SequenceNumberSet lost_packets; |
| 1915 lost_packets.insert(1); |
| 1916 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) |
| 1917 .WillOnce(Return(lost_packets)); |
1884 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 1918 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
| 1919 EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)).Times(1); |
| 1920 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1); |
1885 EXPECT_CALL(*send_algorithm_, | 1921 EXPECT_CALL(*send_algorithm_, |
1886 OnPacketSent(_, _, packet_size - kQuicVersionSize, | 1922 OnPacketSent(_, _, packet_size - kQuicVersionSize, |
1887 NACK_RETRANSMISSION, _)); | 1923 NACK_RETRANSMISSION, _)); |
1888 ProcessAckPacket(&frame); | 1924 ProcessAckPacket(&frame); |
1889 } | 1925 } |
1890 | 1926 |
1891 TEST_P(QuicConnectionTest, QueueAfterTwoRTOs) { | 1927 TEST_P(QuicConnectionTest, QueueAfterTwoRTOs) { |
1892 for (int i = 0; i < 10; ++i) { | 1928 for (int i = 0; i < 10; ++i) { |
1893 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); | 1929 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); |
1894 connection_.SendStreamDataWithString(3, "foo", i * 3, !kFin, NULL); | 1930 connection_.SendStreamDataWithString(3, "foo", i * 3, !kFin, NULL); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1985 TEST_P(QuicConnectionTest, NoLimitPacketsPerNack) { | 2021 TEST_P(QuicConnectionTest, NoLimitPacketsPerNack) { |
1986 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2022 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1987 int offset = 0; | 2023 int offset = 0; |
1988 // Send packets 1 to 15. | 2024 // Send packets 1 to 15. |
1989 for (int i = 0; i < 15; ++i) { | 2025 for (int i = 0; i < 15; ++i) { |
1990 SendStreamDataToPeer(1, "foo", offset, !kFin, NULL); | 2026 SendStreamDataToPeer(1, "foo", offset, !kFin, NULL); |
1991 offset += 3; | 2027 offset += 3; |
1992 } | 2028 } |
1993 | 2029 |
1994 // Ack 15, nack 1-14. | 2030 // Ack 15, nack 1-14. |
| 2031 SequenceNumberSet lost_packets; |
1995 QuicAckFrame nack = InitAckFrame(15, 0); | 2032 QuicAckFrame nack = InitAckFrame(15, 0); |
1996 for (int i = 1; i < 15; ++i) { | 2033 for (int i = 1; i < 15; ++i) { |
1997 NackPacket(i, &nack); | 2034 NackPacket(i, &nack); |
| 2035 lost_packets.insert(i); |
1998 } | 2036 } |
1999 | 2037 |
2000 // 14 packets have been NACK'd and lost. In TCP cubic, PRR limits | 2038 // 14 packets have been NACK'd and lost. In TCP cubic, PRR limits |
2001 // the retransmission rate in the case of burst losses. | 2039 // the retransmission rate in the case of burst losses. |
| 2040 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) |
| 2041 .WillOnce(Return(lost_packets)); |
2002 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 2042 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
2003 EXPECT_CALL(*send_algorithm_, OnPacketAcked(15, _)).Times(1); | 2043 EXPECT_CALL(*send_algorithm_, OnPacketAcked(15, _)).Times(1); |
2004 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(14); | 2044 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(14); |
2005 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(14); | 2045 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(14); |
2006 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(14); | 2046 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(14); |
2007 ProcessAckPacket(&nack); | 2047 ProcessAckPacket(&nack); |
2008 } | 2048 } |
2009 | 2049 |
2010 // Test sending multiple acks from the connection to the session. | 2050 // Test sending multiple acks from the connection to the session. |
2011 TEST_P(QuicConnectionTest, MultipleAcks) { | 2051 TEST_P(QuicConnectionTest, MultipleAcks) { |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2352 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, RTO_RETRANSMISSION, _)) | 2392 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, RTO_RETRANSMISSION, _)) |
2353 .WillOnce(DoAll(SaveArg<1>(&rto_sequence_number), Return(true))); | 2393 .WillOnce(DoAll(SaveArg<1>(&rto_sequence_number), Return(true))); |
2354 connection_.GetRetransmissionAlarm()->Fire(); | 2394 connection_.GetRetransmissionAlarm()->Fire(); |
2355 EXPECT_FALSE(QuicConnectionPeer::IsSavedForRetransmission( | 2395 EXPECT_FALSE(QuicConnectionPeer::IsSavedForRetransmission( |
2356 &connection_, original_sequence_number)); | 2396 &connection_, original_sequence_number)); |
2357 ASSERT_TRUE(QuicConnectionPeer::IsSavedForRetransmission( | 2397 ASSERT_TRUE(QuicConnectionPeer::IsSavedForRetransmission( |
2358 &connection_, rto_sequence_number)); | 2398 &connection_, rto_sequence_number)); |
2359 EXPECT_TRUE(QuicConnectionPeer::IsRetransmission( | 2399 EXPECT_TRUE(QuicConnectionPeer::IsRetransmission( |
2360 &connection_, rto_sequence_number)); | 2400 &connection_, rto_sequence_number)); |
2361 // Once by explicit nack. | 2401 // Once by explicit nack. |
2362 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)).Times(3); | 2402 SequenceNumberSet lost_packets; |
2363 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(1); | 2403 lost_packets.insert(rto_sequence_number); |
| 2404 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) |
| 2405 .WillOnce(Return(lost_packets)); |
| 2406 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)).Times(1); |
| 2407 EXPECT_CALL(*send_algorithm_, OnPacketLost(rto_sequence_number, _)).Times(1); |
2364 EXPECT_CALL(*send_algorithm_, | 2408 EXPECT_CALL(*send_algorithm_, |
2365 OnPacketAbandoned(rto_sequence_number, _)).Times(1); | 2409 OnPacketAbandoned(rto_sequence_number, _)).Times(1); |
2366 QuicPacketSequenceNumber nack_sequence_number = 0; | 2410 QuicPacketSequenceNumber nack_sequence_number = 0; |
2367 // Ack packets might generate some other packets, which are not | 2411 // Ack packets might generate some other packets, which are not |
2368 // retransmissions. (More ack packets). | 2412 // retransmissions. (More ack packets). |
2369 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, _)) | 2413 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, _)) |
2370 .Times(AnyNumber()); | 2414 .Times(AnyNumber()); |
2371 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NACK_RETRANSMISSION, _)) | 2415 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NACK_RETRANSMISSION, _)) |
2372 .WillOnce(DoAll(SaveArg<1>(&nack_sequence_number), Return(true))); | 2416 .WillOnce(DoAll(SaveArg<1>(&nack_sequence_number), Return(true))); |
2373 QuicAckFrame ack = InitAckFrame(rto_sequence_number, 0); | 2417 QuicAckFrame ack = InitAckFrame(rto_sequence_number, 0); |
2374 // Ack the retransmitted packet. | 2418 // Nack the retransmitted packet. |
2375 NackPacket(original_sequence_number, &ack); | 2419 NackPacket(original_sequence_number, &ack); |
2376 NackPacket(rto_sequence_number, &ack); | 2420 NackPacket(rto_sequence_number, &ack); |
2377 for (int i = 0; i < 3; i++) { | 2421 ProcessAckPacket(&ack); |
2378 ProcessAckPacket(&ack); | 2422 |
2379 } | |
2380 ASSERT_NE(0u, nack_sequence_number); | 2423 ASSERT_NE(0u, nack_sequence_number); |
2381 EXPECT_FALSE(QuicConnectionPeer::IsSavedForRetransmission( | 2424 EXPECT_FALSE(QuicConnectionPeer::IsSavedForRetransmission( |
2382 &connection_, rto_sequence_number)); | 2425 &connection_, rto_sequence_number)); |
2383 ASSERT_TRUE(QuicConnectionPeer::IsSavedForRetransmission( | 2426 ASSERT_TRUE(QuicConnectionPeer::IsSavedForRetransmission( |
2384 &connection_, nack_sequence_number)); | 2427 &connection_, nack_sequence_number)); |
2385 EXPECT_TRUE(QuicConnectionPeer::IsRetransmission( | 2428 EXPECT_TRUE(QuicConnectionPeer::IsRetransmission( |
2386 &connection_, nack_sequence_number)); | 2429 &connection_, nack_sequence_number)); |
2387 } | 2430 } |
2388 | 2431 |
2389 TEST_P(QuicConnectionTest, SetRTOAfterWritingToSocket) { | 2432 TEST_P(QuicConnectionTest, SetRTOAfterWritingToSocket) { |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2866 EXPECT_TRUE(connection_.GetAckAlarm()->IsSet()); | 2909 EXPECT_TRUE(connection_.GetAckAlarm()->IsSet()); |
2867 } | 2910 } |
2868 | 2911 |
2869 TEST_P(QuicConnectionTest, BundleAckWithDataOnIncomingAck) { | 2912 TEST_P(QuicConnectionTest, BundleAckWithDataOnIncomingAck) { |
2870 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2913 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
2871 connection_.SendStreamDataWithString(kStreamId3, "foo", 0, !kFin, NULL); | 2914 connection_.SendStreamDataWithString(kStreamId3, "foo", 0, !kFin, NULL); |
2872 connection_.SendStreamDataWithString(kStreamId3, "foo", 3, !kFin, NULL); | 2915 connection_.SendStreamDataWithString(kStreamId3, "foo", 3, !kFin, NULL); |
2873 // Ack the second packet, which will retransmit the first packet. | 2916 // Ack the second packet, which will retransmit the first packet. |
2874 QuicAckFrame ack = InitAckFrame(2, 0); | 2917 QuicAckFrame ack = InitAckFrame(2, 0); |
2875 NackPacket(1, &ack); | 2918 NackPacket(1, &ack); |
| 2919 SequenceNumberSet lost_packets; |
| 2920 lost_packets.insert(1); |
| 2921 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) |
| 2922 .WillOnce(Return(lost_packets)); |
2876 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 2923 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
2877 EXPECT_CALL(*send_algorithm_, OnPacketAcked(2, _)).Times(1); | 2924 EXPECT_CALL(*send_algorithm_, OnPacketAcked(2, _)).Times(1); |
2878 EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)).Times(1); | 2925 EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)).Times(1); |
2879 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1); | 2926 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1); |
2880 ProcessAckPacket(&ack); | 2927 ProcessAckPacket(&ack); |
2881 EXPECT_EQ(1u, writer_->frame_count()); | 2928 EXPECT_EQ(1u, writer_->frame_count()); |
2882 EXPECT_EQ(1u, writer_->stream_frames()->size()); | 2929 EXPECT_EQ(1u, writer_->stream_frames()->size()); |
2883 writer_->Reset(); | 2930 writer_->Reset(); |
2884 | 2931 |
2885 // Now ack the retransmission, which will both raise the high water mark | 2932 // Now ack the retransmission, which will both raise the high water mark |
2886 // and see if there is more data to send. | 2933 // and see if there is more data to send. |
2887 ack = InitAckFrame(3, 0); | 2934 ack = InitAckFrame(3, 0); |
2888 NackPacket(1, &ack); | 2935 NackPacket(1, &ack); |
| 2936 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) |
| 2937 .WillOnce(Return(SequenceNumberSet())); |
2889 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 2938 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
2890 EXPECT_CALL(*send_algorithm_, OnPacketAcked(3, _)).Times(1); | 2939 EXPECT_CALL(*send_algorithm_, OnPacketAcked(3, _)).Times(1); |
2891 ProcessAckPacket(&ack); | 2940 ProcessAckPacket(&ack); |
2892 | 2941 |
2893 // Check that no packet is sent and the ack alarm isn't set. | 2942 // Check that no packet is sent and the ack alarm isn't set. |
2894 EXPECT_EQ(0u, writer_->frame_count()); | 2943 EXPECT_EQ(0u, writer_->frame_count()); |
2895 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 2944 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
2896 writer_->Reset(); | 2945 writer_->Reset(); |
2897 | 2946 |
2898 // Send the same ack, but send both data and an ack together. | 2947 // Send the same ack, but send both data and an ack together. |
2899 ack = InitAckFrame(3, 0); | 2948 ack = InitAckFrame(3, 0); |
2900 NackPacket(1, &ack); | 2949 NackPacket(1, &ack); |
| 2950 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) |
| 2951 .WillOnce(Return(SequenceNumberSet())); |
2901 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce( | 2952 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce( |
2902 IgnoreResult(InvokeWithoutArgs( | 2953 IgnoreResult(InvokeWithoutArgs( |
2903 &connection_, | 2954 &connection_, |
2904 &TestConnection::EnsureWritableAndSendStreamData5))); | 2955 &TestConnection::EnsureWritableAndSendStreamData5))); |
2905 ProcessAckPacket(&ack); | 2956 ProcessAckPacket(&ack); |
2906 | 2957 |
2907 // Check that ack is bundled with outgoing data and the delayed ack | 2958 // Check that ack is bundled with outgoing data and the delayed ack |
2908 // alarm is reset. | 2959 // alarm is reset. |
2909 if (version() > QUIC_VERSION_15) { | 2960 if (version() > QUIC_VERSION_15) { |
2910 EXPECT_EQ(3u, writer_->frame_count()); | 2961 EXPECT_EQ(3u, writer_->frame_count()); |
(...skipping 21 matching lines...) Expand all Loading... |
2932 connection_.CloseConnection(QUIC_PEER_GOING_AWAY, false); | 2983 connection_.CloseConnection(QUIC_PEER_GOING_AWAY, false); |
2933 EXPECT_FALSE(connection_.connected()); | 2984 EXPECT_FALSE(connection_.connected()); |
2934 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag); | 2985 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag); |
2935 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, 1, _, _, _)).Times(0); | 2986 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, 1, _, _, _)).Times(0); |
2936 connection_.SendPacket( | 2987 connection_.SendPacket( |
2937 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA); | 2988 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA); |
2938 } | 2989 } |
2939 | 2990 |
2940 TEST_P(QuicConnectionTest, PublicReset) { | 2991 TEST_P(QuicConnectionTest, PublicReset) { |
2941 QuicPublicResetPacket header; | 2992 QuicPublicResetPacket header; |
2942 header.public_header.guid = guid_; | 2993 header.public_header.connection_id = connection_id_; |
2943 header.public_header.reset_flag = true; | 2994 header.public_header.reset_flag = true; |
2944 header.public_header.version_flag = false; | 2995 header.public_header.version_flag = false; |
2945 header.rejected_sequence_number = 10101; | 2996 header.rejected_sequence_number = 10101; |
2946 scoped_ptr<QuicEncryptedPacket> packet( | 2997 scoped_ptr<QuicEncryptedPacket> packet( |
2947 framer_.BuildPublicResetPacket(header)); | 2998 framer_.BuildPublicResetPacket(header)); |
2948 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PUBLIC_RESET, true)); | 2999 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PUBLIC_RESET, true)); |
2949 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *packet); | 3000 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *packet); |
2950 } | 3001 } |
2951 | 3002 |
2952 TEST_P(QuicConnectionTest, GoAway) { | 3003 TEST_P(QuicConnectionTest, GoAway) { |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3142 EXPECT_TRUE(QuicConnectionPeer::IsValidEntropy( | 3193 EXPECT_TRUE(QuicConnectionPeer::IsValidEntropy( |
3143 &connection_, max_sequence_number, missing_packets, entropy_hash)) | 3194 &connection_, max_sequence_number, missing_packets, entropy_hash)) |
3144 << ""; | 3195 << ""; |
3145 } | 3196 } |
3146 | 3197 |
3147 TEST_P(QuicConnectionTest, ServerSendsVersionNegotiationPacket) { | 3198 TEST_P(QuicConnectionTest, ServerSendsVersionNegotiationPacket) { |
3148 connection_.SetSupportedVersions(QuicSupportedVersions()); | 3199 connection_.SetSupportedVersions(QuicSupportedVersions()); |
3149 framer_.set_version_for_tests(QUIC_VERSION_UNSUPPORTED); | 3200 framer_.set_version_for_tests(QUIC_VERSION_UNSUPPORTED); |
3150 | 3201 |
3151 QuicPacketHeader header; | 3202 QuicPacketHeader header; |
3152 header.public_header.guid = guid_; | 3203 header.public_header.connection_id = connection_id_; |
3153 header.public_header.reset_flag = false; | 3204 header.public_header.reset_flag = false; |
3154 header.public_header.version_flag = true; | 3205 header.public_header.version_flag = true; |
3155 header.entropy_flag = false; | 3206 header.entropy_flag = false; |
3156 header.fec_flag = false; | 3207 header.fec_flag = false; |
3157 header.packet_sequence_number = 12; | 3208 header.packet_sequence_number = 12; |
3158 header.fec_group = 0; | 3209 header.fec_group = 0; |
3159 | 3210 |
3160 QuicFrames frames; | 3211 QuicFrames frames; |
3161 QuicFrame frame(&frame1_); | 3212 QuicFrame frame(&frame1_); |
3162 frames.push_back(frame); | 3213 frames.push_back(frame); |
(...skipping 17 matching lines...) Expand all Loading... |
3180 EXPECT_EQ(kSupportedQuicVersions[i], | 3231 EXPECT_EQ(kSupportedQuicVersions[i], |
3181 writer_->version_negotiation_packet()->versions[i]); | 3232 writer_->version_negotiation_packet()->versions[i]); |
3182 } | 3233 } |
3183 } | 3234 } |
3184 | 3235 |
3185 TEST_P(QuicConnectionTest, ServerSendsVersionNegotiationPacketSocketBlocked) { | 3236 TEST_P(QuicConnectionTest, ServerSendsVersionNegotiationPacketSocketBlocked) { |
3186 connection_.SetSupportedVersions(QuicSupportedVersions()); | 3237 connection_.SetSupportedVersions(QuicSupportedVersions()); |
3187 framer_.set_version_for_tests(QUIC_VERSION_UNSUPPORTED); | 3238 framer_.set_version_for_tests(QUIC_VERSION_UNSUPPORTED); |
3188 | 3239 |
3189 QuicPacketHeader header; | 3240 QuicPacketHeader header; |
3190 header.public_header.guid = guid_; | 3241 header.public_header.connection_id = connection_id_; |
3191 header.public_header.reset_flag = false; | 3242 header.public_header.reset_flag = false; |
3192 header.public_header.version_flag = true; | 3243 header.public_header.version_flag = true; |
3193 header.entropy_flag = false; | 3244 header.entropy_flag = false; |
3194 header.fec_flag = false; | 3245 header.fec_flag = false; |
3195 header.packet_sequence_number = 12; | 3246 header.packet_sequence_number = 12; |
3196 header.fec_group = 0; | 3247 header.fec_group = 0; |
3197 | 3248 |
3198 QuicFrames frames; | 3249 QuicFrames frames; |
3199 QuicFrame frame(&frame1_); | 3250 QuicFrame frame(&frame1_); |
3200 frames.push_back(frame); | 3251 frames.push_back(frame); |
(...skipping 24 matching lines...) Expand all Loading... |
3225 writer_->version_negotiation_packet()->versions[i]); | 3276 writer_->version_negotiation_packet()->versions[i]); |
3226 } | 3277 } |
3227 } | 3278 } |
3228 | 3279 |
3229 TEST_P(QuicConnectionTest, | 3280 TEST_P(QuicConnectionTest, |
3230 ServerSendsVersionNegotiationPacketSocketBlockedDataBuffered) { | 3281 ServerSendsVersionNegotiationPacketSocketBlockedDataBuffered) { |
3231 connection_.SetSupportedVersions(QuicSupportedVersions()); | 3282 connection_.SetSupportedVersions(QuicSupportedVersions()); |
3232 framer_.set_version_for_tests(QUIC_VERSION_UNSUPPORTED); | 3283 framer_.set_version_for_tests(QUIC_VERSION_UNSUPPORTED); |
3233 | 3284 |
3234 QuicPacketHeader header; | 3285 QuicPacketHeader header; |
3235 header.public_header.guid = guid_; | 3286 header.public_header.connection_id = connection_id_; |
3236 header.public_header.reset_flag = false; | 3287 header.public_header.reset_flag = false; |
3237 header.public_header.version_flag = true; | 3288 header.public_header.version_flag = true; |
3238 header.entropy_flag = false; | 3289 header.entropy_flag = false; |
3239 header.fec_flag = false; | 3290 header.fec_flag = false; |
3240 header.packet_sequence_number = 12; | 3291 header.packet_sequence_number = 12; |
3241 header.fec_group = 0; | 3292 header.fec_group = 0; |
3242 | 3293 |
3243 QuicFrames frames; | 3294 QuicFrames frames; |
3244 QuicFrame frame(&frame1_); | 3295 QuicFrame frame(&frame1_); |
3245 frames.push_back(frame); | 3296 frames.push_back(frame); |
(...skipping 10 matching lines...) Expand all Loading... |
3256 EXPECT_EQ(0u, writer_->last_packet_size()); | 3307 EXPECT_EQ(0u, writer_->last_packet_size()); |
3257 EXPECT_FALSE(connection_.HasQueuedData()); | 3308 EXPECT_FALSE(connection_.HasQueuedData()); |
3258 } | 3309 } |
3259 | 3310 |
3260 TEST_P(QuicConnectionTest, ClientHandlesVersionNegotiation) { | 3311 TEST_P(QuicConnectionTest, ClientHandlesVersionNegotiation) { |
3261 // Start out with some unsupported version. | 3312 // Start out with some unsupported version. |
3262 QuicConnectionPeer::GetFramer(&connection_)->set_version_for_tests( | 3313 QuicConnectionPeer::GetFramer(&connection_)->set_version_for_tests( |
3263 QUIC_VERSION_UNSUPPORTED); | 3314 QUIC_VERSION_UNSUPPORTED); |
3264 | 3315 |
3265 QuicPacketHeader header; | 3316 QuicPacketHeader header; |
3266 header.public_header.guid = guid_; | 3317 header.public_header.connection_id = connection_id_; |
3267 header.public_header.reset_flag = false; | 3318 header.public_header.reset_flag = false; |
3268 header.public_header.version_flag = true; | 3319 header.public_header.version_flag = true; |
3269 header.entropy_flag = false; | 3320 header.entropy_flag = false; |
3270 header.fec_flag = false; | 3321 header.fec_flag = false; |
3271 header.packet_sequence_number = 12; | 3322 header.packet_sequence_number = 12; |
3272 header.fec_group = 0; | 3323 header.fec_group = 0; |
3273 | 3324 |
3274 QuicVersionVector supported_versions; | 3325 QuicVersionVector supported_versions; |
3275 for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) { | 3326 for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) { |
3276 supported_versions.push_back(kSupportedQuicVersions[i]); | 3327 supported_versions.push_back(kSupportedQuicVersions[i]); |
(...skipping 17 matching lines...) Expand all Loading... |
3294 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(1); | 3345 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(1); |
3295 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3346 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3296 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); | 3347 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); |
3297 | 3348 |
3298 ASSERT_FALSE(QuicPacketCreatorPeer::SendVersionInPacket( | 3349 ASSERT_FALSE(QuicPacketCreatorPeer::SendVersionInPacket( |
3299 QuicConnectionPeer::GetPacketCreator(&connection_))); | 3350 QuicConnectionPeer::GetPacketCreator(&connection_))); |
3300 } | 3351 } |
3301 | 3352 |
3302 TEST_P(QuicConnectionTest, BadVersionNegotiation) { | 3353 TEST_P(QuicConnectionTest, BadVersionNegotiation) { |
3303 QuicPacketHeader header; | 3354 QuicPacketHeader header; |
3304 header.public_header.guid = guid_; | 3355 header.public_header.connection_id = connection_id_; |
3305 header.public_header.reset_flag = false; | 3356 header.public_header.reset_flag = false; |
3306 header.public_header.version_flag = true; | 3357 header.public_header.version_flag = true; |
3307 header.entropy_flag = false; | 3358 header.entropy_flag = false; |
3308 header.fec_flag = false; | 3359 header.fec_flag = false; |
3309 header.packet_sequence_number = 12; | 3360 header.packet_sequence_number = 12; |
3310 header.fec_group = 0; | 3361 header.fec_group = 0; |
3311 | 3362 |
3312 QuicVersionVector supported_versions; | 3363 QuicVersionVector supported_versions; |
3313 for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) { | 3364 for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) { |
3314 supported_versions.push_back(kSupportedQuicVersions[i]); | 3365 supported_versions.push_back(kSupportedQuicVersions[i]); |
(...skipping 30 matching lines...) Expand all Loading... |
3345 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(1); | 3396 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(1); |
3346 | 3397 |
3347 // Retransmit due to RTO. | 3398 // Retransmit due to RTO. |
3348 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10)); | 3399 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10)); |
3349 connection_.GetRetransmissionAlarm()->Fire(); | 3400 connection_.GetRetransmissionAlarm()->Fire(); |
3350 | 3401 |
3351 // Retransmit due to explicit nacks. | 3402 // Retransmit due to explicit nacks. |
3352 QuicAckFrame nack_three = InitAckFrame(4, 0); | 3403 QuicAckFrame nack_three = InitAckFrame(4, 0); |
3353 NackPacket(3, &nack_three); | 3404 NackPacket(3, &nack_three); |
3354 NackPacket(1, &nack_three); | 3405 NackPacket(1, &nack_three); |
3355 QuicFrame frame(&nack_three); | 3406 SequenceNumberSet lost_packets; |
| 3407 lost_packets.insert(1); |
| 3408 lost_packets.insert(3); |
| 3409 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) |
| 3410 .WillOnce(Return(lost_packets)); |
3356 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 3411 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
3357 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1); | 3412 EXPECT_CALL(*send_algorithm_, OnPacketAcked(4, _)).Times(1); |
3358 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(1); | 3413 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(2); |
3359 EXPECT_CALL(visitor_, OnCanWrite()).Times(4); | 3414 EXPECT_CALL(visitor_, OnCanWrite()).Times(2); |
3360 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3415 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3361 | 3416 ProcessAckPacket(&nack_three); |
3362 ProcessFramePacket(frame); | |
3363 ProcessFramePacket(frame); | |
3364 ProcessFramePacket(frame); | |
3365 | 3417 |
3366 EXPECT_CALL(*send_algorithm_, SmoothedRtt()).WillOnce( | 3418 EXPECT_CALL(*send_algorithm_, SmoothedRtt()).WillOnce( |
3367 Return(QuicTime::Delta::Zero())); | 3419 Return(QuicTime::Delta::Zero())); |
3368 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillOnce( | 3420 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillOnce( |
3369 Return(QuicBandwidth::Zero())); | 3421 Return(QuicBandwidth::Zero())); |
3370 | 3422 |
3371 const QuicConnectionStats& stats = connection_.GetStats(); | 3423 const QuicConnectionStats& stats = connection_.GetStats(); |
3372 EXPECT_EQ(3 * first_packet_size + 2 * second_packet_size - kQuicVersionSize, | 3424 EXPECT_EQ(3 * first_packet_size + 2 * second_packet_size - kQuicVersionSize, |
3373 stats.bytes_sent); | 3425 stats.bytes_sent); |
3374 EXPECT_EQ(5u, stats.packets_sent); | 3426 EXPECT_EQ(5u, stats.packets_sent); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3421 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 2) == NULL); | 3473 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 2) == NULL); |
3422 | 3474 |
3423 // Verify that adding 5 kills off 3, despite 4 being created before 3. | 3475 // Verify that adding 5 kills off 3, despite 4 being created before 3. |
3424 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 5) != NULL); | 3476 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 5) != NULL); |
3425 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 4) != NULL); | 3477 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 4) != NULL); |
3426 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 3) == NULL); | 3478 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 3) == NULL); |
3427 } | 3479 } |
3428 | 3480 |
3429 TEST_P(QuicConnectionTest, ProcessFramesIfPacketClosedConnection) { | 3481 TEST_P(QuicConnectionTest, ProcessFramesIfPacketClosedConnection) { |
3430 // Construct a packet with stream frame and connection close frame. | 3482 // Construct a packet with stream frame and connection close frame. |
3431 header_.public_header.guid = guid_; | 3483 header_.public_header.connection_id = connection_id_; |
3432 header_.packet_sequence_number = 1; | 3484 header_.packet_sequence_number = 1; |
3433 header_.public_header.reset_flag = false; | 3485 header_.public_header.reset_flag = false; |
3434 header_.public_header.version_flag = false; | 3486 header_.public_header.version_flag = false; |
3435 header_.entropy_flag = false; | 3487 header_.entropy_flag = false; |
3436 header_.fec_flag = false; | 3488 header_.fec_flag = false; |
3437 header_.fec_group = 0; | 3489 header_.fec_group = 0; |
3438 | 3490 |
3439 QuicConnectionCloseFrame qccf; | 3491 QuicConnectionCloseFrame qccf; |
3440 qccf.error_code = QUIC_PEER_GOING_AWAY; | 3492 qccf.error_code = QUIC_PEER_GOING_AWAY; |
3441 QuicFrame close_frame(&qccf); | 3493 QuicFrame close_frame(&qccf); |
(...skipping 11 matching lines...) Expand all Loading... |
3453 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PEER_GOING_AWAY, true)); | 3505 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PEER_GOING_AWAY, true)); |
3454 EXPECT_CALL(visitor_, OnStreamFrames(_)).WillOnce(Return(true)); | 3506 EXPECT_CALL(visitor_, OnStreamFrames(_)).WillOnce(Return(true)); |
3455 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3507 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3456 | 3508 |
3457 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); | 3509 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); |
3458 } | 3510 } |
3459 | 3511 |
3460 TEST_P(QuicConnectionTest, DontProcessStreamFrameAndIgnoreCloseFrame) { | 3512 TEST_P(QuicConnectionTest, DontProcessStreamFrameAndIgnoreCloseFrame) { |
3461 // Construct a packet with stream frame, ack frame, | 3513 // Construct a packet with stream frame, ack frame, |
3462 // and connection close frame. | 3514 // and connection close frame. |
3463 header_.public_header.guid = guid_; | 3515 header_.public_header.connection_id = connection_id_; |
3464 header_.packet_sequence_number = 1; | 3516 header_.packet_sequence_number = 1; |
3465 header_.public_header.reset_flag = false; | 3517 header_.public_header.reset_flag = false; |
3466 header_.public_header.version_flag = false; | 3518 header_.public_header.version_flag = false; |
3467 header_.entropy_flag = false; | 3519 header_.entropy_flag = false; |
3468 header_.fec_flag = false; | 3520 header_.fec_flag = false; |
3469 header_.fec_group = 0; | 3521 header_.fec_group = 0; |
3470 | 3522 |
3471 QuicConnectionCloseFrame qccf; | 3523 QuicConnectionCloseFrame qccf; |
3472 qccf.error_code = QUIC_PEER_GOING_AWAY; | 3524 qccf.error_code = QUIC_PEER_GOING_AWAY; |
3473 QuicFrame close_frame(&qccf); | 3525 QuicFrame close_frame(&qccf); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3579 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get()); | 3631 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get()); |
3580 | 3632 |
3581 // Send some other data which we will ACK. | 3633 // Send some other data which we will ACK. |
3582 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); | 3634 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); |
3583 connection_.SendStreamDataWithString(1, "bar", 0, !kFin, NULL); | 3635 connection_.SendStreamDataWithString(1, "bar", 0, !kFin, NULL); |
3584 | 3636 |
3585 // Now we receive ACK for packets 2 and 3, but importantly missing packet 1 | 3637 // Now we receive ACK for packets 2 and 3, but importantly missing packet 1 |
3586 // which we registered to be notified about. | 3638 // which we registered to be notified about. |
3587 QuicAckFrame frame = InitAckFrame(3, 0); | 3639 QuicAckFrame frame = InitAckFrame(3, 0); |
3588 NackPacket(1, &frame); | 3640 NackPacket(1, &frame); |
3589 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)); | 3641 SequenceNumberSet lost_packets; |
3590 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)); | 3642 lost_packets.insert(1); |
| 3643 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) |
| 3644 .WillOnce(Return(lost_packets)); |
| 3645 EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)); |
| 3646 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)); |
3591 ProcessAckPacket(&frame); | 3647 ProcessAckPacket(&frame); |
3592 } | 3648 } |
3593 | 3649 |
3594 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterRetransmission) { | 3650 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterRetransmission) { |
3595 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3651 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3596 | 3652 |
3597 // Create a delegate which we expect to be called. | 3653 // Create a delegate which we expect to be called. |
3598 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); | 3654 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); |
3599 EXPECT_CALL(*delegate, OnAckNotification()).Times(1); | 3655 EXPECT_CALL(*delegate, OnAckNotification()).Times(1); |
3600 | 3656 |
3601 // In total expect ACKs for all 4 packets. | |
3602 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)).Times(2); | |
3603 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(4); | |
3604 | |
3605 // Send four packets, and register to be notified on ACK of packet 2. | 3657 // Send four packets, and register to be notified on ACK of packet 2. |
3606 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); | 3658 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); |
3607 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, delegate.get()); | 3659 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, delegate.get()); |
3608 connection_.SendStreamDataWithString(3, "baz", 0, !kFin, NULL); | 3660 connection_.SendStreamDataWithString(3, "baz", 0, !kFin, NULL); |
3609 connection_.SendStreamDataWithString(3, "qux", 0, !kFin, NULL); | 3661 connection_.SendStreamDataWithString(3, "qux", 0, !kFin, NULL); |
3610 | 3662 |
3611 // Now we receive ACK for packets 1, 3, and 4, which invokes fast retransmit. | 3663 // Now we receive ACK for packets 1, 3, and 4 and lose 2. |
3612 QuicAckFrame frame = InitAckFrame(4, 0); | 3664 QuicAckFrame frame = InitAckFrame(4, 0); |
3613 NackPacket(2, &frame); | 3665 NackPacket(2, &frame); |
| 3666 SequenceNumberSet lost_packets; |
| 3667 lost_packets.insert(2); |
| 3668 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) |
| 3669 .WillOnce(Return(lost_packets)); |
| 3670 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
| 3671 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(3); |
3614 EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _)); | 3672 EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _)); |
3615 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)); | 3673 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)); |
3616 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 3674 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
3617 ProcessAckPacket(&frame); | 3675 ProcessAckPacket(&frame); |
3618 | 3676 |
3619 // Now we get an ACK for packet 5 (retransmitted packet 2), which should | 3677 // Now we get an ACK for packet 5 (retransmitted packet 2), which should |
3620 // trigger the callback. | 3678 // trigger the callback. |
| 3679 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) |
| 3680 .WillRepeatedly(Return(SequenceNumberSet())); |
| 3681 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
| 3682 EXPECT_CALL(*send_algorithm_, OnPacketAcked(5, _)); |
3621 QuicAckFrame second_ack_frame = InitAckFrame(5, 0); | 3683 QuicAckFrame second_ack_frame = InitAckFrame(5, 0); |
3622 ProcessAckPacket(&second_ack_frame); | 3684 ProcessAckPacket(&second_ack_frame); |
3623 } | 3685 } |
3624 | 3686 |
3625 // TODO(rjshade): Add a similar test that FEC recovery on peer (and resulting | 3687 // TODO(rjshade): Add a similar test that FEC recovery on peer (and resulting |
3626 // ACK) triggers notification on our end. | 3688 // ACK) triggers notification on our end. |
3627 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterFECRecovery) { | 3689 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterFECRecovery) { |
3628 if (version() < QUIC_VERSION_15) { | 3690 if (version() < QUIC_VERSION_15) { |
3629 return; | 3691 return; |
3630 } | 3692 } |
(...skipping 15 matching lines...) Expand all Loading... |
3646 // Should recover the Ack packet and trigger the notification callback. | 3708 // Should recover the Ack packet and trigger the notification callback. |
3647 QuicFrames frames; | 3709 QuicFrames frames; |
3648 | 3710 |
3649 QuicAckFrame ack_frame = InitAckFrame(1, 0); | 3711 QuicAckFrame ack_frame = InitAckFrame(1, 0); |
3650 frames.push_back(QuicFrame(&ack_frame)); | 3712 frames.push_back(QuicFrame(&ack_frame)); |
3651 | 3713 |
3652 // Dummy stream frame to satisfy expectations set elsewhere. | 3714 // Dummy stream frame to satisfy expectations set elsewhere. |
3653 frames.push_back(QuicFrame(&frame1_)); | 3715 frames.push_back(QuicFrame(&frame1_)); |
3654 | 3716 |
3655 QuicPacketHeader ack_header; | 3717 QuicPacketHeader ack_header; |
3656 ack_header.public_header.guid = guid_; | 3718 ack_header.public_header.connection_id = connection_id_; |
3657 ack_header.public_header.reset_flag = false; | 3719 ack_header.public_header.reset_flag = false; |
3658 ack_header.public_header.version_flag = false; | 3720 ack_header.public_header.version_flag = false; |
3659 ack_header.entropy_flag = !kEntropyFlag; | 3721 ack_header.entropy_flag = !kEntropyFlag; |
3660 ack_header.fec_flag = true; | 3722 ack_header.fec_flag = true; |
3661 ack_header.packet_sequence_number = 1; | 3723 ack_header.packet_sequence_number = 1; |
3662 ack_header.is_in_fec_group = IN_FEC_GROUP; | 3724 ack_header.is_in_fec_group = IN_FEC_GROUP; |
3663 ack_header.fec_group = 1; | 3725 ack_header.fec_group = 1; |
3664 | 3726 |
3665 QuicPacket* packet = | 3727 QuicPacket* packet = |
3666 framer_.BuildUnsizedDataPacket(ack_header, frames).packet; | 3728 framer_.BuildUnsizedDataPacket(ack_header, frames).packet; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3731 scoped_ptr<MockQuicConnectionDebugVisitor> | 3793 scoped_ptr<MockQuicConnectionDebugVisitor> |
3732 debug_visitor(new StrictMock<MockQuicConnectionDebugVisitor>); | 3794 debug_visitor(new StrictMock<MockQuicConnectionDebugVisitor>); |
3733 connection_.set_debug_visitor(debug_visitor.get()); | 3795 connection_.set_debug_visitor(debug_visitor.get()); |
3734 EXPECT_CALL(*debug_visitor, OnPacketHeader(Ref(header))).Times(1); | 3796 EXPECT_CALL(*debug_visitor, OnPacketHeader(Ref(header))).Times(1); |
3735 connection_.OnPacketHeader(header); | 3797 connection_.OnPacketHeader(header); |
3736 } | 3798 } |
3737 | 3799 |
3738 TEST_P(QuicConnectionTest, Pacing) { | 3800 TEST_P(QuicConnectionTest, Pacing) { |
3739 ValueRestore<bool> old_flag(&FLAGS_enable_quic_pacing, true); | 3801 ValueRestore<bool> old_flag(&FLAGS_enable_quic_pacing, true); |
3740 | 3802 |
3741 TestConnection server(guid_, IPEndPoint(), helper_.get(), writer_.get(), | 3803 TestConnection server(connection_id_, IPEndPoint(), helper_.get(), |
3742 true, version()); | 3804 writer_.get(), true, version()); |
3743 TestConnection client(guid_, IPEndPoint(), helper_.get(), writer_.get(), | 3805 TestConnection client(connection_id_, IPEndPoint(), helper_.get(), |
3744 false, version()); | 3806 writer_.get(), false, version()); |
3745 EXPECT_TRUE(client.sent_packet_manager().using_pacing()); | 3807 EXPECT_TRUE(client.sent_packet_manager().using_pacing()); |
3746 EXPECT_FALSE(server.sent_packet_manager().using_pacing()); | 3808 EXPECT_FALSE(server.sent_packet_manager().using_pacing()); |
3747 } | 3809 } |
3748 | 3810 |
3749 TEST_P(QuicConnectionTest, ControlFramesInstigateAcks) { | 3811 TEST_P(QuicConnectionTest, ControlFramesInstigateAcks) { |
3750 if (version() < QUIC_VERSION_14) { | 3812 if (version() < QUIC_VERSION_14) { |
3751 return; | 3813 return; |
3752 } | 3814 } |
3753 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3815 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3754 | 3816 |
(...skipping 13 matching lines...) Expand all Loading... |
3768 QuicBlockedFrame blocked; | 3830 QuicBlockedFrame blocked; |
3769 blocked.stream_id = 3; | 3831 blocked.stream_id = 3; |
3770 EXPECT_CALL(visitor_, OnBlockedFrames(_)); | 3832 EXPECT_CALL(visitor_, OnBlockedFrames(_)); |
3771 ProcessFramePacket(QuicFrame(&blocked)); | 3833 ProcessFramePacket(QuicFrame(&blocked)); |
3772 EXPECT_TRUE(ack_alarm->IsSet()); | 3834 EXPECT_TRUE(ack_alarm->IsSet()); |
3773 } | 3835 } |
3774 | 3836 |
3775 } // namespace | 3837 } // namespace |
3776 } // namespace test | 3838 } // namespace test |
3777 } // namespace net | 3839 } // namespace net |
OLD | NEW |