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 "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 #include "net/quic/congestion_control/receive_algorithm_interface.h" | 10 #include "net/quic/congestion_control/receive_algorithm_interface.h" |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 scoped_ptr<QuicPacket> packet(ConstructDataPacket(number, fec_group, | 494 scoped_ptr<QuicPacket> packet(ConstructDataPacket(number, fec_group, |
495 entropy_flag)); | 495 entropy_flag)); |
496 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket( | 496 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket( |
497 ENCRYPTION_NONE, number, *packet)); | 497 ENCRYPTION_NONE, number, *packet)); |
498 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); | 498 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); |
499 return encrypted->length(); | 499 return encrypted->length(); |
500 } | 500 } |
501 | 501 |
502 void ProcessClosePacket(QuicPacketSequenceNumber number, | 502 void ProcessClosePacket(QuicPacketSequenceNumber number, |
503 QuicFecGroupNumber fec_group) { | 503 QuicFecGroupNumber fec_group) { |
504 EXPECT_CALL(visitor_, OnCanWrite()).Times(1).WillOnce(Return(true)); | |
505 scoped_ptr<QuicPacket> packet(ConstructClosePacket(number, fec_group)); | 504 scoped_ptr<QuicPacket> packet(ConstructClosePacket(number, fec_group)); |
506 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket( | 505 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket( |
507 ENCRYPTION_NONE, number, *packet)); | 506 ENCRYPTION_NONE, number, *packet)); |
508 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); | 507 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); |
509 } | 508 } |
510 | 509 |
511 size_t ProcessFecProtectedPacket(QuicPacketSequenceNumber number, | 510 size_t ProcessFecProtectedPacket(QuicPacketSequenceNumber number, |
512 bool expect_revival, bool entropy_flag) { | 511 bool expect_revival, bool entropy_flag) { |
513 if (expect_revival) { | 512 if (expect_revival) { |
514 EXPECT_CALL(visitor_, OnPacket(_, _, _, _)).WillOnce(DoAll( | 513 EXPECT_CALL(visitor_, OnPacket(_, _, _, _)).WillOnce(DoAll( |
(...skipping 28 matching lines...) Expand all Loading... |
543 header_.is_in_fec_group = IN_FEC_GROUP; | 542 header_.is_in_fec_group = IN_FEC_GROUP; |
544 header_.fec_group = min_protected_packet; | 543 header_.fec_group = min_protected_packet; |
545 QuicFecData fec_data; | 544 QuicFecData fec_data; |
546 fec_data.fec_group = header_.fec_group; | 545 fec_data.fec_group = header_.fec_group; |
547 // Since all data packets in this test have the same payload, the | 546 // Since all data packets in this test have the same payload, the |
548 // redundancy is either equal to that payload or the xor of that payload | 547 // redundancy is either equal to that payload or the xor of that payload |
549 // with itself, depending on the number of packets. | 548 // with itself, depending on the number of packets. |
550 if (((number - min_protected_packet) % 2) == 0) { | 549 if (((number - min_protected_packet) % 2) == 0) { |
551 for (size_t i = GetStartOfFecProtectedData( | 550 for (size_t i = GetStartOfFecProtectedData( |
552 header_.public_header.guid_length, | 551 header_.public_header.guid_length, |
553 header_.public_header.version_flag, | 552 header_.public_header.version_flag); |
554 header_.public_header.sequence_number_length); | |
555 i < data_packet->length(); ++i) { | 553 i < data_packet->length(); ++i) { |
556 data_packet->mutable_data()[i] ^= data_packet->data()[i]; | 554 data_packet->mutable_data()[i] ^= data_packet->data()[i]; |
557 } | 555 } |
558 } | 556 } |
559 fec_data.redundancy = data_packet->FecProtectedData(); | 557 fec_data.redundancy = data_packet->FecProtectedData(); |
560 scoped_ptr<QuicPacket> fec_packet( | 558 scoped_ptr<QuicPacket> fec_packet( |
561 framer_.ConstructFecPacket(header_, fec_data).packet); | 559 framer_.ConstructFecPacket(header_, fec_data).packet); |
562 scoped_ptr<QuicEncryptedPacket> encrypted( | 560 scoped_ptr<QuicEncryptedPacket> encrypted( |
563 framer_.EncryptPacket(ENCRYPTION_NONE, number, *fec_packet)); | 561 framer_.EncryptPacket(ENCRYPTION_NONE, number, *fec_packet)); |
564 | 562 |
(...skipping 15 matching lines...) Expand all Loading... |
580 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(AnyNumber()); | 578 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(AnyNumber()); |
581 return packet_size; | 579 return packet_size; |
582 } | 580 } |
583 | 581 |
584 void SendAckPacketToPeer() { | 582 void SendAckPacketToPeer() { |
585 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(1); | 583 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(1); |
586 connection_.SendAck(); | 584 connection_.SendAck(); |
587 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(AnyNumber()); | 585 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(AnyNumber()); |
588 } | 586 } |
589 | 587 |
590 QuicPacketEntropyHash ProcessAckPacket(QuicAckFrame* frame, | 588 QuicPacketEntropyHash ProcessAckPacket(QuicAckFrame* frame) { |
591 bool expect_writes) { | |
592 if (expect_writes) { | |
593 EXPECT_CALL(visitor_, OnCanWrite()).Times(1).WillOnce(Return(true)); | |
594 } | |
595 return ProcessFramePacket(QuicFrame(frame)); | 589 return ProcessFramePacket(QuicFrame(frame)); |
596 } | 590 } |
597 | 591 |
598 QuicPacketEntropyHash ProcessGoAwayPacket(QuicGoAwayFrame* frame) { | 592 QuicPacketEntropyHash ProcessGoAwayPacket(QuicGoAwayFrame* frame) { |
599 return ProcessFramePacket(QuicFrame(frame)); | 593 return ProcessFramePacket(QuicFrame(frame)); |
600 } | 594 } |
601 | 595 |
602 bool IsMissing(QuicPacketSequenceNumber number) { | 596 bool IsMissing(QuicPacketSequenceNumber number) { |
603 return IsAwaitingPacket(outgoing_ack()->received_info, number); | 597 return IsAwaitingPacket(outgoing_ack()->received_info, number); |
604 } | 598 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 EXPECT_EQ(5u, outgoing_ack()->received_info.largest_observed); | 740 EXPECT_EQ(5u, outgoing_ack()->received_info.largest_observed); |
747 EXPECT_TRUE(IsMissing(1)); | 741 EXPECT_TRUE(IsMissing(1)); |
748 EXPECT_TRUE(IsMissing(4)); | 742 EXPECT_TRUE(IsMissing(4)); |
749 | 743 |
750 // Pretend at this point the client has gotten acks for 2 and 3 and 1 is a | 744 // Pretend at this point the client has gotten acks for 2 and 3 and 1 is a |
751 // packet the peer will not retransmit. It indicates this by sending 'least | 745 // packet the peer will not retransmit. It indicates this by sending 'least |
752 // awaiting' is 4. The connection should then realize 1 will not be | 746 // awaiting' is 4. The connection should then realize 1 will not be |
753 // retransmitted, and will remove it from the missing list. | 747 // retransmitted, and will remove it from the missing list. |
754 creator_.set_sequence_number(5); | 748 creator_.set_sequence_number(5); |
755 QuicAckFrame frame(0, QuicTime::Zero(), 4); | 749 QuicAckFrame frame(0, QuicTime::Zero(), 4); |
756 ProcessAckPacket(&frame, true); | 750 ProcessAckPacket(&frame); |
757 | 751 |
758 // Force an ack to be sent. | 752 // Force an ack to be sent. |
759 SendAckPacketToPeer(); | 753 SendAckPacketToPeer(); |
760 EXPECT_TRUE(IsMissing(4)); | 754 EXPECT_TRUE(IsMissing(4)); |
761 } | 755 } |
762 | 756 |
763 TEST_F(QuicConnectionTest, RejectPacketTooFarOut) { | 757 TEST_F(QuicConnectionTest, RejectPacketTooFarOut) { |
764 // Call ProcessDataPacket rather than ProcessPacket, as we should not get a | 758 // Call ProcessDataPacket rather than ProcessPacket, as we should not get a |
765 // packet call to the visitor. | 759 // packet call to the visitor. |
766 EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_PACKET_HEADER, false)); | 760 EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_PACKET_HEADER, false)); |
767 ProcessDataPacket(6000, 0, !kEntropyFlag); | 761 ProcessDataPacket(6000, 0, !kEntropyFlag); |
768 } | 762 } |
769 | 763 |
770 TEST_F(QuicConnectionTest, TruncatedAck) { | 764 TEST_F(QuicConnectionTest, TruncatedAck) { |
771 EXPECT_CALL(visitor_, OnAck(_)).Times(testing::AnyNumber()); | 765 EXPECT_CALL(visitor_, OnAck(_)).Times(testing::AnyNumber()); |
772 EXPECT_CALL(*send_algorithm_, OnIncomingAck(_, _, _)).Times(2); | 766 EXPECT_CALL(*send_algorithm_, OnIncomingAck(_, _, _)).Times(2); |
773 EXPECT_CALL(*send_algorithm_, OnIncomingLoss(_)).Times(1); | 767 EXPECT_CALL(*send_algorithm_, OnIncomingLoss(_)).Times(1); |
774 for (int i = 0; i < 200; ++i) { | 768 for (int i = 0; i < 200; ++i) { |
775 SendStreamDataToPeer(1, "foo", i * 3, !kFin, NULL); | 769 SendStreamDataToPeer(1, "foo", i * 3, !kFin, NULL); |
776 } | 770 } |
777 | 771 |
778 QuicAckFrame frame(0, QuicTime::Zero(), 1); | 772 QuicAckFrame frame(0, QuicTime::Zero(), 1); |
779 frame.received_info.largest_observed = 192; | 773 frame.received_info.largest_observed = 192; |
780 InsertMissingPacketsBetween(&frame.received_info, 1, 192); | 774 InsertMissingPacketsBetween(&frame.received_info, 1, 192); |
781 frame.received_info.entropy_hash = | 775 frame.received_info.entropy_hash = |
782 QuicConnectionPeer::GetSentEntropyHash(&connection_, 192) ^ | 776 QuicConnectionPeer::GetSentEntropyHash(&connection_, 192) ^ |
783 QuicConnectionPeer::GetSentEntropyHash(&connection_, 191); | 777 QuicConnectionPeer::GetSentEntropyHash(&connection_, 191); |
784 | 778 |
785 ProcessAckPacket(&frame, true); | 779 ProcessAckPacket(&frame); |
786 | 780 |
787 EXPECT_TRUE(QuicConnectionPeer::GetReceivedTruncatedAck(&connection_)); | 781 EXPECT_TRUE(QuicConnectionPeer::GetReceivedTruncatedAck(&connection_)); |
788 | 782 |
789 frame.received_info.missing_packets.erase(191); | 783 frame.received_info.missing_packets.erase(191); |
790 frame.received_info.entropy_hash = | 784 frame.received_info.entropy_hash = |
791 QuicConnectionPeer::GetSentEntropyHash(&connection_, 192) ^ | 785 QuicConnectionPeer::GetSentEntropyHash(&connection_, 192) ^ |
792 QuicConnectionPeer::GetSentEntropyHash(&connection_, 190); | 786 QuicConnectionPeer::GetSentEntropyHash(&connection_, 190); |
793 | 787 |
794 ProcessAckPacket(&frame, true); | 788 ProcessAckPacket(&frame); |
795 EXPECT_FALSE(QuicConnectionPeer::GetReceivedTruncatedAck(&connection_)); | 789 EXPECT_FALSE(QuicConnectionPeer::GetReceivedTruncatedAck(&connection_)); |
796 } | 790 } |
797 | 791 |
798 TEST_F(QuicConnectionTest, LeastUnackedLower) { | 792 TEST_F(QuicConnectionTest, LeastUnackedLower) { |
799 SendStreamDataToPeer(1, "foo", 0, !kFin, NULL); | 793 SendStreamDataToPeer(1, "foo", 0, !kFin, NULL); |
800 SendStreamDataToPeer(1, "bar", 3, !kFin, NULL); | 794 SendStreamDataToPeer(1, "bar", 3, !kFin, NULL); |
801 SendStreamDataToPeer(1, "eep", 6, !kFin, NULL); | 795 SendStreamDataToPeer(1, "eep", 6, !kFin, NULL); |
802 | 796 |
803 // Start out saying the least unacked is 2 | 797 // Start out saying the least unacked is 2 |
804 creator_.set_sequence_number(5); | 798 creator_.set_sequence_number(5); |
805 QuicAckFrame frame(0, QuicTime::Zero(), 2); | 799 QuicAckFrame frame(0, QuicTime::Zero(), 2); |
806 ProcessAckPacket(&frame, true); | 800 ProcessAckPacket(&frame); |
807 | 801 |
808 // Change it to 1, but lower the sequence number to fake out-of-order packets. | 802 // Change it to 1, but lower the sequence number to fake out-of-order packets. |
809 // This should be fine. | 803 // This should be fine. |
810 creator_.set_sequence_number(1); | 804 creator_.set_sequence_number(1); |
811 QuicAckFrame frame2(0, QuicTime::Zero(), 1); | 805 QuicAckFrame frame2(0, QuicTime::Zero(), 1); |
812 // The scheduler will not process out of order acks. | 806 // The scheduler will not process out of order acks. |
813 ProcessAckPacket(&frame2, false); | 807 ProcessAckPacket(&frame2); |
814 | 808 |
815 // Now claim it's one, but set the ordering so it was sent "after" the first | 809 // Now claim it's one, but set the ordering so it was sent "after" the first |
816 // one. This should cause a connection error. | 810 // one. This should cause a connection error. |
817 EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_ACK_DATA, false)); | 811 EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_ACK_DATA, false)); |
818 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)); | 812 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)); |
819 creator_.set_sequence_number(7); | 813 creator_.set_sequence_number(7); |
820 ProcessAckPacket(&frame2, false); | 814 ProcessAckPacket(&frame2); |
821 } | 815 } |
822 | 816 |
823 TEST_F(QuicConnectionTest, LargestObservedLower) { | 817 TEST_F(QuicConnectionTest, LargestObservedLower) { |
824 SendStreamDataToPeer(1, "foo", 0, !kFin, NULL); | 818 SendStreamDataToPeer(1, "foo", 0, !kFin, NULL); |
825 SendStreamDataToPeer(1, "bar", 3, !kFin, NULL); | 819 SendStreamDataToPeer(1, "bar", 3, !kFin, NULL); |
826 SendStreamDataToPeer(1, "eep", 6, !kFin, NULL); | 820 SendStreamDataToPeer(1, "eep", 6, !kFin, NULL); |
827 EXPECT_CALL(*send_algorithm_, OnIncomingAck(_, _, _)).Times(2); | 821 EXPECT_CALL(*send_algorithm_, OnIncomingAck(_, _, _)).Times(2); |
828 | 822 |
829 // Start out saying the largest observed is 2. | 823 // Start out saying the largest observed is 2. |
830 QuicAckFrame frame(2, QuicTime::Zero(), 0); | 824 QuicAckFrame frame(2, QuicTime::Zero(), 0); |
831 frame.received_info.entropy_hash = QuicConnectionPeer::GetSentEntropyHash( | 825 frame.received_info.entropy_hash = QuicConnectionPeer::GetSentEntropyHash( |
832 &connection_, 2); | 826 &connection_, 2); |
833 EXPECT_CALL(visitor_, OnAck(_)); | 827 EXPECT_CALL(visitor_, OnAck(_)); |
834 ProcessAckPacket(&frame, true); | 828 ProcessAckPacket(&frame); |
835 | 829 |
836 // Now change it to 1, and it should cause a connection error. | 830 // Now change it to 1, and it should cause a connection error. |
837 QuicAckFrame frame2(1, QuicTime::Zero(), 0); | 831 QuicAckFrame frame2(1, QuicTime::Zero(), 0); |
838 EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_ACK_DATA, false)); | 832 EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_ACK_DATA, false)); |
839 ProcessAckPacket(&frame2, false); | 833 ProcessAckPacket(&frame2); |
840 } | 834 } |
841 | 835 |
842 TEST_F(QuicConnectionTest, LeastUnackedGreaterThanPacketSequenceNumber) { | 836 TEST_F(QuicConnectionTest, LeastUnackedGreaterThanPacketSequenceNumber) { |
843 EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_ACK_DATA, false)); | 837 EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_ACK_DATA, false)); |
844 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)); | 838 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)); |
845 // Create an ack with least_unacked is 2 in packet number 1. | 839 // Create an ack with least_unacked is 2 in packet number 1. |
846 creator_.set_sequence_number(0); | 840 creator_.set_sequence_number(0); |
847 QuicAckFrame frame(0, QuicTime::Zero(), 2); | 841 QuicAckFrame frame(0, QuicTime::Zero(), 2); |
848 ProcessAckPacket(&frame, false); | 842 ProcessAckPacket(&frame); |
849 } | 843 } |
850 | 844 |
851 TEST_F(QuicConnectionTest, | 845 TEST_F(QuicConnectionTest, |
852 NackSequenceNumberGreaterThanLargestReceived) { | 846 NackSequenceNumberGreaterThanLargestReceived) { |
853 SendStreamDataToPeer(1, "foo", 0, !kFin, NULL); | 847 SendStreamDataToPeer(1, "foo", 0, !kFin, NULL); |
854 SendStreamDataToPeer(1, "bar", 3, !kFin, NULL); | 848 SendStreamDataToPeer(1, "bar", 3, !kFin, NULL); |
855 SendStreamDataToPeer(1, "eep", 6, !kFin, NULL); | 849 SendStreamDataToPeer(1, "eep", 6, !kFin, NULL); |
856 | 850 |
857 EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_ACK_DATA, false)); | 851 EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_ACK_DATA, false)); |
858 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)); | 852 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)); |
859 QuicAckFrame frame(0, QuicTime::Zero(), 1); | 853 QuicAckFrame frame(0, QuicTime::Zero(), 1); |
860 frame.received_info.missing_packets.insert(3); | 854 frame.received_info.missing_packets.insert(3); |
861 ProcessAckPacket(&frame, false); | 855 ProcessAckPacket(&frame); |
862 } | 856 } |
863 | 857 |
864 TEST_F(QuicConnectionTest, AckUnsentData) { | 858 TEST_F(QuicConnectionTest, AckUnsentData) { |
865 // Ack a packet which has not been sent. | 859 // Ack a packet which has not been sent. |
866 EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_ACK_DATA, false)); | 860 EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_ACK_DATA, false)); |
867 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)); | 861 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)); |
868 QuicAckFrame frame(1, QuicTime::Zero(), 0); | 862 QuicAckFrame frame(1, QuicTime::Zero(), 0); |
869 ProcessAckPacket(&frame, false); | 863 ProcessAckPacket(&frame); |
870 } | 864 } |
871 | 865 |
872 TEST_F(QuicConnectionTest, AckAll) { | 866 TEST_F(QuicConnectionTest, AckAll) { |
873 ProcessPacket(1); | 867 ProcessPacket(1); |
874 | 868 |
875 creator_.set_sequence_number(1); | 869 creator_.set_sequence_number(1); |
876 QuicAckFrame frame1(0, QuicTime::Zero(), 1); | 870 QuicAckFrame frame1(0, QuicTime::Zero(), 1); |
877 ProcessAckPacket(&frame1, true); | 871 ProcessAckPacket(&frame1); |
878 } | 872 } |
879 | 873 |
880 TEST_F(QuicConnectionTest, DontWaitForPacketsBefore) { | 874 TEST_F(QuicConnectionTest, DontWaitForPacketsBefore) { |
881 ProcessPacket(2); | 875 ProcessPacket(2); |
882 ProcessPacket(7); | 876 ProcessPacket(7); |
883 EXPECT_TRUE(connection_.DontWaitForPacketsBefore(4)); | 877 EXPECT_TRUE(connection_.DontWaitForPacketsBefore(4)); |
884 EXPECT_EQ(3u, outgoing_ack()->received_info.missing_packets.size()); | 878 EXPECT_EQ(3u, outgoing_ack()->received_info.missing_packets.size()); |
885 } | 879 } |
886 | 880 |
887 TEST_F(QuicConnectionTest, BasicSending) { | 881 TEST_F(QuicConnectionTest, BasicSending) { |
(...skipping 14 matching lines...) Expand all Loading... |
902 EXPECT_EQ(1u, last_ack()->sent_info.least_unacked); | 896 EXPECT_EQ(1u, last_ack()->sent_info.least_unacked); |
903 | 897 |
904 SequenceNumberSet expected_acks; | 898 SequenceNumberSet expected_acks; |
905 expected_acks.insert(1); | 899 expected_acks.insert(1); |
906 | 900 |
907 // Client acks up to packet 3 | 901 // Client acks up to packet 3 |
908 EXPECT_CALL(visitor_, OnAck(ContainerEq(expected_acks))); | 902 EXPECT_CALL(visitor_, OnAck(ContainerEq(expected_acks))); |
909 QuicAckFrame frame(3, QuicTime::Zero(), 0); | 903 QuicAckFrame frame(3, QuicTime::Zero(), 0); |
910 frame.received_info.entropy_hash = | 904 frame.received_info.entropy_hash = |
911 QuicConnectionPeer::GetSentEntropyHash(&connection_, 3); | 905 QuicConnectionPeer::GetSentEntropyHash(&connection_, 3); |
912 ProcessAckPacket(&frame, true); | 906 ProcessAckPacket(&frame); |
913 SendAckPacketToPeer(); // Packet 6 | 907 SendAckPacketToPeer(); // Packet 6 |
914 | 908 |
915 // As soon as we've acked one, we skip ack packets 2 and 3 and note lack of | 909 // As soon as we've acked one, we skip ack packets 2 and 3 and note lack of |
916 // ack for 4. | 910 // ack for 4. |
917 EXPECT_EQ(4u, last_ack()->sent_info.least_unacked); | 911 EXPECT_EQ(4u, last_ack()->sent_info.least_unacked); |
918 | 912 |
919 expected_acks.clear(); | 913 expected_acks.clear(); |
920 expected_acks.insert(4); | 914 expected_acks.insert(4); |
921 | 915 |
922 // Client acks up to packet 4, the last packet | 916 // Client acks up to packet 4, the last packet |
923 EXPECT_CALL(visitor_, OnAck(ContainerEq(expected_acks))); | 917 EXPECT_CALL(visitor_, OnAck(ContainerEq(expected_acks))); |
924 QuicAckFrame frame2(6, QuicTime::Zero(), 0); | 918 QuicAckFrame frame2(6, QuicTime::Zero(), 0); |
925 frame2.received_info.entropy_hash = | 919 frame2.received_info.entropy_hash = |
926 QuicConnectionPeer::GetSentEntropyHash(&connection_, 6); | 920 QuicConnectionPeer::GetSentEntropyHash(&connection_, 6); |
927 ProcessAckPacket(&frame2, true); // Even parity triggers ack packet 7 | 921 ProcessAckPacket(&frame2); // Even parity triggers ack packet 7 |
928 | 922 |
929 // The least packet awaiting ack should now be 7 | 923 // The least packet awaiting ack should now be 7 |
930 EXPECT_EQ(7u, last_ack()->sent_info.least_unacked); | 924 EXPECT_EQ(7u, last_ack()->sent_info.least_unacked); |
931 | 925 |
932 // If we force an ack, we shouldn't change our retransmit state. | 926 // If we force an ack, we shouldn't change our retransmit state. |
933 SendAckPacketToPeer(); // Packet 8 | 927 SendAckPacketToPeer(); // Packet 8 |
934 EXPECT_EQ(8u, last_ack()->sent_info.least_unacked); | 928 EXPECT_EQ(8u, last_ack()->sent_info.least_unacked); |
935 | 929 |
936 // But if we send more data it should. | 930 // But if we send more data it should. |
937 SendStreamDataToPeer(1, "eep", 6, !kFin, &last_packet); // Packet 9 | 931 SendStreamDataToPeer(1, "eep", 6, !kFin, &last_packet); // Packet 9 |
(...skipping 26 matching lines...) Expand all Loading... |
964 connection_.options()->max_packets_per_fec_group = 2; | 958 connection_.options()->max_packets_per_fec_group = 2; |
965 | 959 |
966 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 960 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
967 helper_->set_blocked(true); | 961 helper_->set_blocked(true); |
968 connection_.SendStreamData(1, "food", 0, !kFin); | 962 connection_.SendStreamData(1, "food", 0, !kFin); |
969 EXPECT_FALSE(creator_.ShouldSendFec(true)); | 963 EXPECT_FALSE(creator_.ShouldSendFec(true)); |
970 // Expect the first data packet and the fec packet to be queued. | 964 // Expect the first data packet and the fec packet to be queued. |
971 EXPECT_EQ(2u, connection_.NumQueuedPackets()); | 965 EXPECT_EQ(2u, connection_.NumQueuedPackets()); |
972 } | 966 } |
973 | 967 |
974 TEST_F(QuicConnectionTest, AbandonFECFromCongestionWindow) { | |
975 connection_.options()->max_packets_per_fec_group = 1; | |
976 // 1 Data and 1 FEC packet. | |
977 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(2); | |
978 connection_.SendStreamData(1, "foo", 0, !kFin); | |
979 | |
980 // Larger timeout for FEC bytes to expire. | |
981 const QuicTime::Delta retransmission_time = | |
982 QuicTime::Delta::FromMilliseconds(5000); | |
983 clock_.AdvanceTime(retransmission_time); | |
984 | |
985 // Send only data packet. | |
986 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(1); | |
987 // Abandon both FEC and data packet. | |
988 EXPECT_CALL(*send_algorithm_, AbandoningPacket(_, _)).Times(2); | |
989 | |
990 connection_.OnRetransmissionTimeout(); | |
991 } | |
992 | |
993 TEST_F(QuicConnectionTest, DontAbandonAckedFEC) { | |
994 connection_.options()->max_packets_per_fec_group = 1; | |
995 const QuicPacketSequenceNumber sequence_number = | |
996 QuicConnectionPeer::GetPacketCreator(&connection_)->sequence_number() + 1; | |
997 | |
998 // 1 Data and 1 FEC packet. | |
999 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(2); | |
1000 connection_.SendStreamData(1, "foo", 0, !kFin); | |
1001 | |
1002 QuicAckFrame ack_fec(2, QuicTime::Zero(), 1); | |
1003 // Data packet missing. | |
1004 ack_fec.received_info.missing_packets.insert(1); | |
1005 ack_fec.received_info.entropy_hash = | |
1006 QuicConnectionPeer::GetSentEntropyHash(&connection_, 2) ^ | |
1007 QuicConnectionPeer::GetSentEntropyHash(&connection_, 1); | |
1008 | |
1009 EXPECT_CALL(visitor_, OnAck(_)).Times(1); | |
1010 EXPECT_CALL(*send_algorithm_, OnIncomingAck(_, _, _)).Times(1); | |
1011 EXPECT_CALL(*send_algorithm_, OnIncomingLoss(_)).Times(1); | |
1012 | |
1013 ProcessAckPacket(&ack_fec, true); | |
1014 | |
1015 const QuicTime::Delta kDefaultRetransmissionTime = | |
1016 QuicTime::Delta::FromMilliseconds(5000); | |
1017 clock_.AdvanceTime(kDefaultRetransmissionTime); | |
1018 | |
1019 // Abandon only data packet, FEC has been acked. | |
1020 EXPECT_CALL(*send_algorithm_, AbandoningPacket(sequence_number, _)).Times(1); | |
1021 // Send only data packet. | |
1022 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(1); | |
1023 connection_.OnRetransmissionTimeout(); | |
1024 } | |
1025 | |
1026 TEST_F(QuicConnectionTest, FramePacking) { | 968 TEST_F(QuicConnectionTest, FramePacking) { |
1027 // Block the connection. | 969 // Block the connection. |
1028 helper_->SetSendAlarm( | 970 helper_->SetSendAlarm( |
1029 clock_.ApproximateNow().Add(QuicTime::Delta::FromSeconds(1))); | 971 clock_.ApproximateNow().Add(QuicTime::Delta::FromSeconds(1))); |
1030 | 972 |
1031 // Send an ack and two stream frames in 1 packet by queueing them. | 973 // Send an ack and two stream frames in 1 packet by queueing them. |
1032 connection_.SendAck(); | 974 connection_.SendAck(); |
1033 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll( | 975 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll( |
1034 IgnoreResult(InvokeWithoutArgs(&connection_, | 976 IgnoreResult(InvokeWithoutArgs(&connection_, |
1035 &TestConnection::SendStreamData1)), | 977 &TestConnection::SendStreamData1)), |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1120 | 1062 |
1121 SequenceNumberSet expected_acks; | 1063 SequenceNumberSet expected_acks; |
1122 expected_acks.insert(1); | 1064 expected_acks.insert(1); |
1123 EXPECT_CALL(visitor_, OnAck(ContainerEq(expected_acks))); | 1065 EXPECT_CALL(visitor_, OnAck(ContainerEq(expected_acks))); |
1124 | 1066 |
1125 // Client acks one but not two or three. Right now we only retransmit on | 1067 // Client acks one but not two or three. Right now we only retransmit on |
1126 // explicit nack, so it should not trigger a retransimission. | 1068 // explicit nack, so it should not trigger a retransimission. |
1127 QuicAckFrame ack_one(1, QuicTime::Zero(), 0); | 1069 QuicAckFrame ack_one(1, QuicTime::Zero(), 0); |
1128 ack_one.received_info.entropy_hash = | 1070 ack_one.received_info.entropy_hash = |
1129 QuicConnectionPeer::GetSentEntropyHash(&connection_, 1); | 1071 QuicConnectionPeer::GetSentEntropyHash(&connection_, 1); |
1130 ProcessAckPacket(&ack_one, true); | 1072 ProcessAckPacket(&ack_one); |
1131 ProcessAckPacket(&ack_one, true); | 1073 ProcessAckPacket(&ack_one); |
1132 ProcessAckPacket(&ack_one, true); | 1074 ProcessAckPacket(&ack_one); |
1133 | 1075 |
1134 expected_acks.clear(); | 1076 expected_acks.clear(); |
1135 expected_acks.insert(3); | 1077 expected_acks.insert(3); |
1136 EXPECT_CALL(visitor_, OnAck(ContainerEq(expected_acks))); | 1078 EXPECT_CALL(visitor_, OnAck(ContainerEq(expected_acks))); |
1137 | 1079 |
1138 // Client acks up to 3 with two explicitly missing. Two nacks should cause no | 1080 // Client acks up to 3 with two explicitly missing. Two nacks should cause no |
1139 // change. | 1081 // change. |
1140 QuicAckFrame nack_two(3, QuicTime::Zero(), 0); | 1082 QuicAckFrame nack_two(3, QuicTime::Zero(), 0); |
1141 nack_two.received_info.missing_packets.insert(2); | 1083 nack_two.received_info.missing_packets.insert(2); |
1142 nack_two.received_info.entropy_hash = | 1084 nack_two.received_info.entropy_hash = |
1143 QuicConnectionPeer::GetSentEntropyHash(&connection_, 3) ^ | 1085 QuicConnectionPeer::GetSentEntropyHash(&connection_, 3) ^ |
1144 QuicConnectionPeer::GetSentEntropyHash(&connection_, 2) ^ | 1086 QuicConnectionPeer::GetSentEntropyHash(&connection_, 2) ^ |
1145 QuicConnectionPeer::GetSentEntropyHash(&connection_, 1); | 1087 QuicConnectionPeer::GetSentEntropyHash(&connection_, 1); |
1146 ProcessAckPacket(&nack_two, true); | 1088 ProcessAckPacket(&nack_two); |
1147 ProcessAckPacket(&nack_two, true); | 1089 ProcessAckPacket(&nack_two); |
1148 | 1090 |
1149 // The third nack should trigger a retransimission. | 1091 // The third nack should trigger a retransimission. |
1150 EXPECT_CALL(*send_algorithm_, | 1092 EXPECT_CALL(*send_algorithm_, |
1151 SentPacket(_, _, second_packet_size - kQuicVersionSize, | 1093 SentPacket(_, _, second_packet_size - kQuicVersionSize, |
1152 IS_RETRANSMISSION)).Times(1); | 1094 IS_RETRANSMISSION)).Times(1); |
1153 ProcessAckPacket(&nack_two, true); | 1095 ProcessAckPacket(&nack_two); |
1154 } | 1096 } |
1155 | 1097 |
1156 TEST_F(QuicConnectionTest, RetransmitNackedLargestObserved) { | 1098 TEST_F(QuicConnectionTest, RetransmitNackedLargestObserved) { |
1157 EXPECT_CALL(*send_algorithm_, OnIncomingLoss(_)).Times(1); | 1099 EXPECT_CALL(*send_algorithm_, OnIncomingLoss(_)).Times(1); |
1158 QuicPacketSequenceNumber largest_observed; | 1100 QuicPacketSequenceNumber largest_observed; |
1159 QuicByteCount packet_size; | 1101 QuicByteCount packet_size; |
1160 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, NOT_RETRANSMISSION)) | 1102 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, NOT_RETRANSMISSION)) |
1161 .WillOnce(DoAll(SaveArg<1>(&largest_observed), SaveArg<2>(&packet_size))); | 1103 .WillOnce(DoAll(SaveArg<1>(&largest_observed), SaveArg<2>(&packet_size))); |
1162 EXPECT_CALL(*send_algorithm_, AbandoningPacket(1, _)).Times(1); | 1104 EXPECT_CALL(*send_algorithm_, AbandoningPacket(1, _)).Times(1); |
1163 connection_.SendStreamData(1, "foo", 0, !kFin); | 1105 connection_.SendStreamData(1, "foo", 0, !kFin); |
1164 QuicAckFrame frame(1, QuicTime::Zero(), largest_observed); | 1106 QuicAckFrame frame(1, QuicTime::Zero(), largest_observed); |
1165 frame.received_info.missing_packets.insert(largest_observed); | 1107 frame.received_info.missing_packets.insert(largest_observed); |
1166 frame.received_info.entropy_hash = QuicConnectionPeer::GetSentEntropyHash( | 1108 frame.received_info.entropy_hash = QuicConnectionPeer::GetSentEntropyHash( |
1167 &connection_, largest_observed - 1); | 1109 &connection_, largest_observed - 1); |
1168 ProcessAckPacket(&frame, true); | 1110 ProcessAckPacket(&frame); |
1169 // Second udp packet will force an ack frame. | 1111 // Second udp packet will force an ack frame. |
1170 EXPECT_CALL(*send_algorithm_, | 1112 EXPECT_CALL(*send_algorithm_, |
1171 SentPacket(_, _, _, NOT_RETRANSMISSION)); | 1113 SentPacket(_, _, _, NOT_RETRANSMISSION)); |
1172 ProcessAckPacket(&frame, true); | 1114 ProcessAckPacket(&frame); |
1173 // Third nack should retransmit the largest observed packet. | 1115 // Third nack should retransmit the largest observed packet. |
1174 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, packet_size - kQuicVersionSize, | 1116 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, packet_size - kQuicVersionSize, |
1175 IS_RETRANSMISSION)); | 1117 IS_RETRANSMISSION)); |
1176 ProcessAckPacket(&frame, true); | 1118 ProcessAckPacket(&frame); |
1177 } | 1119 } |
1178 | 1120 |
1179 TEST_F(QuicConnectionTest, RetransmitNackedPacketsOnTruncatedAck) { | 1121 TEST_F(QuicConnectionTest, RetransmitNackedPacketsOnTruncatedAck) { |
1180 for (int i = 0; i < 200; ++i) { | 1122 for (int i = 0; i < 200; ++i) { |
1181 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(1); | 1123 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(1); |
1182 connection_.SendStreamData(1, "foo", i * 3, !kFin); | 1124 connection_.SendStreamData(1, "foo", i * 3, !kFin); |
1183 } | 1125 } |
1184 | 1126 |
1185 // Make a truncated ack frame. | 1127 // Make a truncated ack frame. |
1186 QuicAckFrame frame(0, QuicTime::Zero(), 1); | 1128 QuicAckFrame frame(0, QuicTime::Zero(), 1); |
1187 frame.received_info.largest_observed = 192; | 1129 frame.received_info.largest_observed = 192; |
1188 InsertMissingPacketsBetween(&frame.received_info, 1, 192); | 1130 InsertMissingPacketsBetween(&frame.received_info, 1, 192); |
1189 frame.received_info.entropy_hash = | 1131 frame.received_info.entropy_hash = |
1190 QuicConnectionPeer::GetSentEntropyHash(&connection_, 192) ^ | 1132 QuicConnectionPeer::GetSentEntropyHash(&connection_, 192) ^ |
1191 QuicConnectionPeer::GetSentEntropyHash(&connection_, 191); | 1133 QuicConnectionPeer::GetSentEntropyHash(&connection_, 191); |
1192 | 1134 |
1193 | 1135 |
1194 EXPECT_CALL(*send_algorithm_, OnIncomingAck(_, _, _)).Times(1); | 1136 EXPECT_CALL(*send_algorithm_, OnIncomingAck(_, _, _)).Times(1); |
1195 EXPECT_CALL(*send_algorithm_, OnIncomingLoss(_)).Times(1); | 1137 EXPECT_CALL(*send_algorithm_, OnIncomingLoss(_)).Times(1); |
1196 EXPECT_CALL(visitor_, OnAck(_)).Times(1); | 1138 EXPECT_CALL(visitor_, OnAck(_)).Times(1); |
1197 ProcessAckPacket(&frame, true); | 1139 ProcessAckPacket(&frame); |
1198 EXPECT_TRUE(QuicConnectionPeer::GetReceivedTruncatedAck(&connection_)); | 1140 EXPECT_TRUE(QuicConnectionPeer::GetReceivedTruncatedAck(&connection_)); |
1199 | 1141 |
1200 QuicConnectionPeer::SetMaxPacketsPerRetransmissionAlarm(&connection_, 200); | 1142 QuicConnectionPeer::SetMaxPacketsPerRetransmissionAlarm(&connection_, 200); |
1201 const QuicTime::Delta kDefaultRetransmissionTime = | 1143 const QuicTime::Delta kDefaultRetransmissionTime = |
1202 QuicTime::Delta::FromMilliseconds(500); | 1144 QuicTime::Delta::FromMilliseconds(500); |
1203 clock_.AdvanceTime(kDefaultRetransmissionTime); | 1145 clock_.AdvanceTime(kDefaultRetransmissionTime); |
1204 // Only packets that are less than largest observed should be retransmitted. | 1146 // Only packets that are less than largest observed should be retransmitted. |
1205 EXPECT_CALL(*send_algorithm_, AbandoningPacket(_, _)).Times(191); | 1147 EXPECT_CALL(*send_algorithm_, AbandoningPacket(_, _)).Times(191); |
1206 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(191); | 1148 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(191); |
1207 connection_.OnRetransmissionTimeout(); | 1149 connection_.OnRetransmissionTimeout(); |
(...skipping 25 matching lines...) Expand all Loading... |
1233 } | 1175 } |
1234 | 1176 |
1235 nack.received_info.entropy_hash = | 1177 nack.received_info.entropy_hash = |
1236 QuicConnectionPeer::GetSentEntropyHash(&connection_, 12) ^ | 1178 QuicConnectionPeer::GetSentEntropyHash(&connection_, 12) ^ |
1237 QuicConnectionPeer::GetSentEntropyHash(&connection_, 11); | 1179 QuicConnectionPeer::GetSentEntropyHash(&connection_, 11); |
1238 SequenceNumberSet expected_acks; | 1180 SequenceNumberSet expected_acks; |
1239 expected_acks.insert(12); | 1181 expected_acks.insert(12); |
1240 EXPECT_CALL(visitor_, OnAck(ContainerEq(expected_acks))); | 1182 EXPECT_CALL(visitor_, OnAck(ContainerEq(expected_acks))); |
1241 | 1183 |
1242 // Nack three times. | 1184 // Nack three times. |
1243 ProcessAckPacket(&nack, true); | 1185 ProcessAckPacket(&nack); |
1244 // The second call will trigger an ack. | 1186 // The second call will trigger an ack. |
1245 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(1); | 1187 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(1); |
1246 ProcessAckPacket(&nack, true); | 1188 ProcessAckPacket(&nack); |
1247 // The third call should trigger retransmitting 10 packets. | 1189 // The third call should trigger retransmitting 10 packets. |
1248 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(10); | 1190 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(10); |
1249 ProcessAckPacket(&nack, true); | 1191 ProcessAckPacket(&nack); |
1250 | 1192 |
1251 // The fourth call should trigger retransmitting the 11th packet and an ack. | 1193 // The fourth call should trigger retransmitting the 11th packet and an ack. |
1252 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(2); | 1194 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(2); |
1253 ProcessAckPacket(&nack, true); | 1195 ProcessAckPacket(&nack); |
1254 } | 1196 } |
1255 | 1197 |
1256 // Test sending multiple acks from the connection to the session. | 1198 // Test sending multiple acks from the connection to the session. |
1257 TEST_F(QuicConnectionTest, MultipleAcks) { | 1199 TEST_F(QuicConnectionTest, MultipleAcks) { |
1258 EXPECT_CALL(*send_algorithm_, OnIncomingAck(_, _, _)).Times(6); | 1200 EXPECT_CALL(*send_algorithm_, OnIncomingAck(_, _, _)).Times(6); |
1259 EXPECT_CALL(*send_algorithm_, OnIncomingLoss(_)).Times(1); | 1201 EXPECT_CALL(*send_algorithm_, OnIncomingLoss(_)).Times(1); |
1260 QuicPacketSequenceNumber last_packet; | 1202 QuicPacketSequenceNumber last_packet; |
1261 SendStreamDataToPeer(1u, "foo", 0, !kFin, &last_packet); // Packet 1 | 1203 SendStreamDataToPeer(1u, "foo", 0, !kFin, &last_packet); // Packet 1 |
1262 EXPECT_EQ(1u, last_packet); | 1204 EXPECT_EQ(1u, last_packet); |
1263 SendStreamDataToPeer(3u, "foo", 0, !kFin, &last_packet); // Packet 2 | 1205 SendStreamDataToPeer(3u, "foo", 0, !kFin, &last_packet); // Packet 2 |
(...skipping 15 matching lines...) Expand all Loading... |
1279 QuicConnectionPeer::GetSentEntropyHash(&connection_, 1); | 1221 QuicConnectionPeer::GetSentEntropyHash(&connection_, 1); |
1280 | 1222 |
1281 // The connection should pass up acks for 1, 4, 5. 2 is not acked, and 3 was | 1223 // The connection should pass up acks for 1, 4, 5. 2 is not acked, and 3 was |
1282 // an ackframe so should not be passed up. | 1224 // an ackframe so should not be passed up. |
1283 SequenceNumberSet expected_acks; | 1225 SequenceNumberSet expected_acks; |
1284 expected_acks.insert(1); | 1226 expected_acks.insert(1); |
1285 expected_acks.insert(4); | 1227 expected_acks.insert(4); |
1286 expected_acks.insert(5); | 1228 expected_acks.insert(5); |
1287 | 1229 |
1288 EXPECT_CALL(visitor_, OnAck(ContainerEq(expected_acks))); | 1230 EXPECT_CALL(visitor_, OnAck(ContainerEq(expected_acks))); |
1289 ProcessAckPacket(&frame1, true); | 1231 ProcessAckPacket(&frame1); |
1290 | 1232 |
1291 // Now the client implicitly acks 2, and explicitly acks 6 | 1233 // Now the client implicitly acks 2, and explicitly acks 6 |
1292 QuicAckFrame frame2(6, QuicTime::Zero(), 0); | 1234 QuicAckFrame frame2(6, QuicTime::Zero(), 0); |
1293 frame2.received_info.entropy_hash = | 1235 frame2.received_info.entropy_hash = |
1294 QuicConnectionPeer::GetSentEntropyHash(&connection_, 6); | 1236 QuicConnectionPeer::GetSentEntropyHash(&connection_, 6); |
1295 expected_acks.clear(); | 1237 expected_acks.clear(); |
1296 // Both acks should be passed up. | 1238 // Both acks should be passed up. |
1297 expected_acks.insert(2); | 1239 expected_acks.insert(2); |
1298 expected_acks.insert(6); | 1240 expected_acks.insert(6); |
1299 | 1241 |
1300 EXPECT_CALL(visitor_, OnAck(ContainerEq(expected_acks))); | 1242 EXPECT_CALL(visitor_, OnAck(ContainerEq(expected_acks))); |
1301 ProcessAckPacket(&frame2, true); | 1243 ProcessAckPacket(&frame2); |
1302 } | 1244 } |
1303 | 1245 |
1304 TEST_F(QuicConnectionTest, DontLatchUnackedPacket) { | 1246 TEST_F(QuicConnectionTest, DontLatchUnackedPacket) { |
1305 EXPECT_CALL(*send_algorithm_, OnIncomingAck(_, _, _)).Times(1); | 1247 EXPECT_CALL(*send_algorithm_, OnIncomingAck(_, _, _)).Times(1); |
1306 SendStreamDataToPeer(1, "foo", 0, !kFin, NULL); // Packet 1; | 1248 SendStreamDataToPeer(1, "foo", 0, !kFin, NULL); // Packet 1; |
1307 SendAckPacketToPeer(); // Packet 2 | 1249 SendAckPacketToPeer(); // Packet 2 |
1308 | 1250 |
1309 // This sets least unacked to 3 (unsent packet), since we don't need | 1251 // This sets least unacked to 3 (unsent packet), since we don't need |
1310 // an ack for Packet 2 (ack packet). | 1252 // an ack for Packet 2 (ack packet). |
1311 SequenceNumberSet expected_acks; | 1253 SequenceNumberSet expected_acks; |
1312 expected_acks.insert(1); | 1254 expected_acks.insert(1); |
1313 // Client acks packet 1 | 1255 // Client acks packet 1 |
1314 EXPECT_CALL(visitor_, OnAck(ContainerEq(expected_acks))); | 1256 EXPECT_CALL(visitor_, OnAck(ContainerEq(expected_acks))); |
1315 QuicAckFrame frame(1, QuicTime::Zero(), 0); | 1257 QuicAckFrame frame(1, QuicTime::Zero(), 0); |
1316 frame.received_info.entropy_hash = QuicConnectionPeer::GetSentEntropyHash( | 1258 frame.received_info.entropy_hash = QuicConnectionPeer::GetSentEntropyHash( |
1317 &connection_, 1); | 1259 &connection_, 1); |
1318 ProcessAckPacket(&frame, true); | 1260 ProcessAckPacket(&frame); |
1319 | 1261 |
1320 // Verify that our internal state has least-unacked as 3. | 1262 // Verify that our internal state has least-unacked as 3. |
1321 EXPECT_EQ(3u, outgoing_ack()->sent_info.least_unacked); | 1263 EXPECT_EQ(3u, outgoing_ack()->sent_info.least_unacked); |
1322 | 1264 |
1323 // When we send an ack, we make sure our least-unacked makes sense. In this | 1265 // When we send an ack, we make sure our least-unacked makes sense. In this |
1324 // case since we're not waiting on an ack for 2 and all packets are acked, we | 1266 // case since we're not waiting on an ack for 2 and all packets are acked, we |
1325 // set it to 3. | 1267 // set it to 3. |
1326 SendAckPacketToPeer(); // Packet 3 | 1268 SendAckPacketToPeer(); // Packet 3 |
1327 // Since this was an ack packet, we set least_unacked to 4. | 1269 // Since this was an ack packet, we set least_unacked to 4. |
1328 EXPECT_EQ(4u, outgoing_ack()->sent_info.least_unacked); | 1270 EXPECT_EQ(4u, outgoing_ack()->sent_info.least_unacked); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1528 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, NOT_RETRANSMISSION)) | 1470 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, NOT_RETRANSMISSION)) |
1529 .Times(AnyNumber()); | 1471 .Times(AnyNumber()); |
1530 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, IS_RETRANSMISSION)) | 1472 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, IS_RETRANSMISSION)) |
1531 .WillOnce(SaveArg<1>(&nack_sequence_number)); | 1473 .WillOnce(SaveArg<1>(&nack_sequence_number)); |
1532 QuicAckFrame ack(rto_sequence_number, QuicTime::Zero(), 0); | 1474 QuicAckFrame ack(rto_sequence_number, QuicTime::Zero(), 0); |
1533 // Ack the retransmitted packet. | 1475 // Ack the retransmitted packet. |
1534 ack.received_info.missing_packets.insert(rto_sequence_number); | 1476 ack.received_info.missing_packets.insert(rto_sequence_number); |
1535 ack.received_info.entropy_hash = QuicConnectionPeer::GetSentEntropyHash( | 1477 ack.received_info.entropy_hash = QuicConnectionPeer::GetSentEntropyHash( |
1536 &connection_, rto_sequence_number - 1); | 1478 &connection_, rto_sequence_number - 1); |
1537 for (int i = 0; i < 3; i++) { | 1479 for (int i = 0; i < 3; i++) { |
1538 ProcessAckPacket(&ack, true); | 1480 ProcessAckPacket(&ack); |
1539 } | 1481 } |
1540 EXPECT_FALSE(QuicConnectionPeer::IsSavedForRetransmission( | 1482 EXPECT_FALSE(QuicConnectionPeer::IsSavedForRetransmission( |
1541 &connection_, rto_sequence_number)); | 1483 &connection_, rto_sequence_number)); |
1542 EXPECT_TRUE(QuicConnectionPeer::IsSavedForRetransmission( | 1484 EXPECT_TRUE(QuicConnectionPeer::IsSavedForRetransmission( |
1543 &connection_, nack_sequence_number)); | 1485 &connection_, nack_sequence_number)); |
1544 EXPECT_EQ(2u, QuicConnectionPeer::GetRetransmissionCount( | 1486 EXPECT_EQ(2u, QuicConnectionPeer::GetRetransmissionCount( |
1545 &connection_, nack_sequence_number)); | 1487 &connection_, nack_sequence_number)); |
1546 } | 1488 } |
1547 | 1489 |
1548 TEST_F(QuicConnectionTest, SetRTOAfterWritingToSocket) { | 1490 TEST_F(QuicConnectionTest, SetRTOAfterWritingToSocket) { |
(...skipping 30 matching lines...) Expand all Loading... |
1579 TEST_F(QuicConnectionTest, CloseFecGroup) { | 1521 TEST_F(QuicConnectionTest, CloseFecGroup) { |
1580 // Don't send missing packet 1 | 1522 // Don't send missing packet 1 |
1581 // Don't send missing packet 2 | 1523 // Don't send missing packet 2 |
1582 ProcessFecProtectedPacket(3, false, !kEntropyFlag); | 1524 ProcessFecProtectedPacket(3, false, !kEntropyFlag); |
1583 // Don't send missing FEC packet 3 | 1525 // Don't send missing FEC packet 3 |
1584 ASSERT_EQ(1u, connection_.NumFecGroups()); | 1526 ASSERT_EQ(1u, connection_.NumFecGroups()); |
1585 | 1527 |
1586 // Now send non-fec protected ack packet and close the group | 1528 // Now send non-fec protected ack packet and close the group |
1587 QuicAckFrame frame(0, QuicTime::Zero(), 5); | 1529 QuicAckFrame frame(0, QuicTime::Zero(), 5); |
1588 creator_.set_sequence_number(4); | 1530 creator_.set_sequence_number(4); |
1589 ProcessAckPacket(&frame, true); | 1531 ProcessAckPacket(&frame); |
1590 ASSERT_EQ(0u, connection_.NumFecGroups()); | 1532 ASSERT_EQ(0u, connection_.NumFecGroups()); |
1591 } | 1533 } |
1592 | 1534 |
1593 TEST_F(QuicConnectionTest, NoQuicCongestionFeedbackFrame) { | 1535 TEST_F(QuicConnectionTest, NoQuicCongestionFeedbackFrame) { |
1594 SendAckPacketToPeer(); | 1536 SendAckPacketToPeer(); |
1595 EXPECT_TRUE(last_feedback() == NULL); | 1537 EXPECT_TRUE(last_feedback() == NULL); |
1596 } | 1538 } |
1597 | 1539 |
1598 TEST_F(QuicConnectionTest, WithQuicCongestionFeedbackFrame) { | 1540 TEST_F(QuicConnectionTest, WithQuicCongestionFeedbackFrame) { |
1599 QuicCongestionFeedbackFrame info; | 1541 QuicCongestionFeedbackFrame info; |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1801 EXPECT_EQ(1u, connection_.NumQueuedPackets()); | 1743 EXPECT_EQ(1u, connection_.NumQueuedPackets()); |
1802 | 1744 |
1803 // Now send non-retransmitting information, that we're not going to | 1745 // Now send non-retransmitting information, that we're not going to |
1804 // retransmit 3. The far end should stop waiting for it. | 1746 // retransmit 3. The far end should stop waiting for it. |
1805 QuicAckFrame frame(0, QuicTime::Zero(), 1); | 1747 QuicAckFrame frame(0, QuicTime::Zero(), 1); |
1806 EXPECT_CALL(*send_algorithm_, | 1748 EXPECT_CALL(*send_algorithm_, |
1807 TimeUntilSend(_, NOT_RETRANSMISSION, _)).WillRepeatedly( | 1749 TimeUntilSend(_, NOT_RETRANSMISSION, _)).WillRepeatedly( |
1808 testing::Return(QuicTime::Delta::Zero())); | 1750 testing::Return(QuicTime::Delta::Zero())); |
1809 EXPECT_CALL(*send_algorithm_, | 1751 EXPECT_CALL(*send_algorithm_, |
1810 SentPacket(_, _, _, _)); | 1752 SentPacket(_, _, _, _)); |
1811 ProcessAckPacket(&frame, true); | 1753 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(Return(true)); |
| 1754 ProcessAckPacket(&frame); |
1812 | 1755 |
1813 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 1756 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
1814 // Ensure alarm is not set | 1757 // Ensure alarm is not set |
1815 EXPECT_FALSE(helper_->IsSendAlarmSet()); | 1758 EXPECT_FALSE(helper_->IsSendAlarmSet()); |
1816 } | 1759 } |
1817 | 1760 |
1818 TEST_F(QuicConnectionTest, SendSchedulerDelayThenAckAndHold) { | 1761 TEST_F(QuicConnectionTest, SendSchedulerDelayThenAckAndHold) { |
1819 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag); | 1762 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag); |
1820 EXPECT_CALL(*send_algorithm_, | 1763 EXPECT_CALL(*send_algorithm_, |
1821 TimeUntilSend(_, NOT_RETRANSMISSION, _)).WillOnce( | 1764 TimeUntilSend(_, NOT_RETRANSMISSION, _)).WillOnce( |
1822 testing::Return(QuicTime::Delta::FromMicroseconds(10))); | 1765 testing::Return(QuicTime::Delta::FromMicroseconds(10))); |
1823 connection_.SendOrQueuePacket( | 1766 connection_.SendOrQueuePacket( |
1824 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA); | 1767 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA); |
1825 EXPECT_EQ(1u, connection_.NumQueuedPackets()); | 1768 EXPECT_EQ(1u, connection_.NumQueuedPackets()); |
1826 | 1769 |
1827 // Now send non-retransmitting information, that we're not going to | 1770 // Now send non-retransmitting information, that we're not going to |
1828 // retransmit 3. The far end should stop waiting for it. | 1771 // retransmit 3. The far end should stop waiting for it. |
1829 QuicAckFrame frame(0, QuicTime::Zero(), 1); | 1772 QuicAckFrame frame(0, QuicTime::Zero(), 1); |
1830 EXPECT_CALL(*send_algorithm_, | 1773 EXPECT_CALL(*send_algorithm_, |
1831 TimeUntilSend(_, NOT_RETRANSMISSION, _)).WillOnce( | 1774 TimeUntilSend(_, NOT_RETRANSMISSION, _)).WillOnce( |
1832 testing::Return(QuicTime::Delta::FromMicroseconds(1))); | 1775 testing::Return(QuicTime::Delta::FromMicroseconds(1))); |
1833 ProcessAckPacket(&frame, false); | 1776 ProcessAckPacket(&frame); |
1834 | 1777 |
1835 EXPECT_EQ(1u, connection_.NumQueuedPackets()); | 1778 EXPECT_EQ(1u, connection_.NumQueuedPackets()); |
1836 } | 1779 } |
1837 | 1780 |
1838 TEST_F(QuicConnectionTest, SendSchedulerDelayThenOnCanWrite) { | 1781 TEST_F(QuicConnectionTest, SendSchedulerDelayThenOnCanWrite) { |
1839 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag); | 1782 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag); |
1840 EXPECT_CALL(*send_algorithm_, | 1783 EXPECT_CALL(*send_algorithm_, |
1841 TimeUntilSend(_, NOT_RETRANSMISSION, _)).WillOnce( | 1784 TimeUntilSend(_, NOT_RETRANSMISSION, _)).WillOnce( |
1842 testing::Return(QuicTime::Delta::FromMicroseconds(10))); | 1785 testing::Return(QuicTime::Delta::FromMicroseconds(10))); |
1843 connection_.SendOrQueuePacket( | 1786 connection_.SendOrQueuePacket( |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1914 goaway.error_code = QUIC_PEER_GOING_AWAY; | 1857 goaway.error_code = QUIC_PEER_GOING_AWAY; |
1915 goaway.reason_phrase = "Going away."; | 1858 goaway.reason_phrase = "Going away."; |
1916 EXPECT_CALL(visitor_, OnGoAway(_)); | 1859 EXPECT_CALL(visitor_, OnGoAway(_)); |
1917 ProcessGoAwayPacket(&goaway); | 1860 ProcessGoAwayPacket(&goaway); |
1918 } | 1861 } |
1919 | 1862 |
1920 TEST_F(QuicConnectionTest, MissingPacketsBeforeLeastUnacked) { | 1863 TEST_F(QuicConnectionTest, MissingPacketsBeforeLeastUnacked) { |
1921 QuicAckFrame ack(0, QuicTime::Zero(), 4); | 1864 QuicAckFrame ack(0, QuicTime::Zero(), 4); |
1922 // Set the sequence number of the ack packet to be least unacked (4) | 1865 // Set the sequence number of the ack packet to be least unacked (4) |
1923 creator_.set_sequence_number(3); | 1866 creator_.set_sequence_number(3); |
1924 ProcessAckPacket(&ack, true); | 1867 ProcessAckPacket(&ack); |
1925 EXPECT_TRUE(outgoing_ack()->received_info.missing_packets.empty()); | 1868 EXPECT_TRUE(outgoing_ack()->received_info.missing_packets.empty()); |
1926 } | 1869 } |
1927 | 1870 |
1928 TEST_F(QuicConnectionTest, ReceivedEntropyHashCalculation) { | 1871 TEST_F(QuicConnectionTest, ReceivedEntropyHashCalculation) { |
1929 EXPECT_CALL(visitor_, OnPacket(_, _, _, _)).WillRepeatedly(Return(true)); | 1872 EXPECT_CALL(visitor_, OnPacket(_, _, _, _)).WillRepeatedly(Return(true)); |
1930 ProcessDataPacket(1, 1, kEntropyFlag); | 1873 ProcessDataPacket(1, 1, kEntropyFlag); |
1931 ProcessDataPacket(4, 1, kEntropyFlag); | 1874 ProcessDataPacket(4, 1, kEntropyFlag); |
1932 ProcessDataPacket(3, 1, !kEntropyFlag); | 1875 ProcessDataPacket(3, 1, !kEntropyFlag); |
1933 ProcessDataPacket(7, 1, kEntropyFlag); | 1876 ProcessDataPacket(7, 1, kEntropyFlag); |
1934 EXPECT_EQ(146u, outgoing_ack()->received_info.entropy_hash); | 1877 EXPECT_EQ(146u, outgoing_ack()->received_info.entropy_hash); |
1935 } | 1878 } |
1936 | 1879 |
1937 TEST_F(QuicConnectionTest, UpdateEntropyForReceivedPackets) { | 1880 TEST_F(QuicConnectionTest, UpdateEntropyForReceivedPackets) { |
1938 EXPECT_CALL(visitor_, OnPacket(_, _, _, _)).WillRepeatedly(Return(true)); | 1881 EXPECT_CALL(visitor_, OnPacket(_, _, _, _)).WillRepeatedly(Return(true)); |
1939 ProcessDataPacket(1, 1, kEntropyFlag); | 1882 ProcessDataPacket(1, 1, kEntropyFlag); |
1940 ProcessDataPacket(5, 1, kEntropyFlag); | 1883 ProcessDataPacket(5, 1, kEntropyFlag); |
1941 ProcessDataPacket(4, 1, !kEntropyFlag); | 1884 ProcessDataPacket(4, 1, !kEntropyFlag); |
1942 EXPECT_EQ(34u, outgoing_ack()->received_info.entropy_hash); | 1885 EXPECT_EQ(34u, outgoing_ack()->received_info.entropy_hash); |
1943 // Make 4th packet my least unacked, and update entropy for 2, 3 packets. | 1886 // Make 4th packet my least unacked, and update entropy for 2, 3 packets. |
1944 QuicAckFrame ack(0, QuicTime::Zero(), 4); | 1887 QuicAckFrame ack(0, QuicTime::Zero(), 4); |
1945 QuicPacketEntropyHash kRandomEntropyHash = 129u; | 1888 QuicPacketEntropyHash kRandomEntropyHash = 129u; |
1946 ack.sent_info.entropy_hash = kRandomEntropyHash; | 1889 ack.sent_info.entropy_hash = kRandomEntropyHash; |
1947 creator_.set_sequence_number(5); | 1890 creator_.set_sequence_number(5); |
1948 QuicPacketEntropyHash six_packet_entropy_hash = 0; | 1891 QuicPacketEntropyHash six_packet_entropy_hash = 0; |
1949 if (ProcessAckPacket(&ack, true)) { | 1892 if (ProcessAckPacket(&ack)) { |
1950 six_packet_entropy_hash = 1 << 6; | 1893 six_packet_entropy_hash = 1 << 6; |
1951 }; | 1894 }; |
1952 | 1895 |
1953 EXPECT_EQ((kRandomEntropyHash + (1 << 5) + six_packet_entropy_hash), | 1896 EXPECT_EQ((kRandomEntropyHash + (1 << 5) + six_packet_entropy_hash), |
1954 outgoing_ack()->received_info.entropy_hash); | 1897 outgoing_ack()->received_info.entropy_hash); |
1955 } | 1898 } |
1956 | 1899 |
1957 TEST_F(QuicConnectionTest, UpdateEntropyHashUptoCurrentPacket) { | 1900 TEST_F(QuicConnectionTest, UpdateEntropyHashUptoCurrentPacket) { |
1958 EXPECT_CALL(visitor_, OnPacket(_, _, _, _)).WillRepeatedly(Return(true)); | 1901 EXPECT_CALL(visitor_, OnPacket(_, _, _, _)).WillRepeatedly(Return(true)); |
1959 ProcessDataPacket(1, 1, kEntropyFlag); | 1902 ProcessDataPacket(1, 1, kEntropyFlag); |
1960 ProcessDataPacket(5, 1, !kEntropyFlag); | 1903 ProcessDataPacket(5, 1, !kEntropyFlag); |
1961 ProcessDataPacket(22, 1, kEntropyFlag); | 1904 ProcessDataPacket(22, 1, kEntropyFlag); |
1962 EXPECT_EQ(66u, outgoing_ack()->received_info.entropy_hash); | 1905 EXPECT_EQ(66u, outgoing_ack()->received_info.entropy_hash); |
1963 creator_.set_sequence_number(22); | 1906 creator_.set_sequence_number(22); |
1964 QuicPacketEntropyHash kRandomEntropyHash = 85u; | 1907 QuicPacketEntropyHash kRandomEntropyHash = 85u; |
1965 // Current packet is the least unacked packet. | 1908 // Current packet is the least unacked packet. |
1966 QuicAckFrame ack(0, QuicTime::Zero(), 23); | 1909 QuicAckFrame ack(0, QuicTime::Zero(), 23); |
1967 ack.sent_info.entropy_hash = kRandomEntropyHash; | 1910 ack.sent_info.entropy_hash = kRandomEntropyHash; |
1968 QuicPacketEntropyHash ack_entropy_hash = ProcessAckPacket(&ack, true); | 1911 QuicPacketEntropyHash ack_entropy_hash = ProcessAckPacket(&ack); |
1969 EXPECT_EQ((kRandomEntropyHash + ack_entropy_hash), | 1912 EXPECT_EQ((kRandomEntropyHash + ack_entropy_hash), |
1970 outgoing_ack()->received_info.entropy_hash); | 1913 outgoing_ack()->received_info.entropy_hash); |
1971 ProcessDataPacket(25, 1, kEntropyFlag); | 1914 ProcessDataPacket(25, 1, kEntropyFlag); |
1972 EXPECT_EQ((kRandomEntropyHash + ack_entropy_hash + (1 << (25 % 8))), | 1915 EXPECT_EQ((kRandomEntropyHash + ack_entropy_hash + (1 << (25 % 8))), |
1973 outgoing_ack()->received_info.entropy_hash); | 1916 outgoing_ack()->received_info.entropy_hash); |
1974 } | 1917 } |
1975 | 1918 |
1976 TEST_F(QuicConnectionTest, EntropyCalculationForTruncatedAck) { | 1919 TEST_F(QuicConnectionTest, EntropyCalculationForTruncatedAck) { |
1977 EXPECT_CALL(visitor_, OnPacket(_, _, _, _)).WillRepeatedly(Return(true)); | 1920 EXPECT_CALL(visitor_, OnPacket(_, _, _, _)).WillRepeatedly(Return(true)); |
1978 QuicPacketEntropyHash entropy[51]; | 1921 QuicPacketEntropyHash entropy[51]; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2083 QuicAckFrame nack_three(4, QuicTime::Zero(), 0); | 2026 QuicAckFrame nack_three(4, QuicTime::Zero(), 0); |
2084 nack_three.received_info.missing_packets.insert(3); | 2027 nack_three.received_info.missing_packets.insert(3); |
2085 nack_three.received_info.entropy_hash = | 2028 nack_three.received_info.entropy_hash = |
2086 QuicConnectionPeer::GetSentEntropyHash(&connection_, 4) ^ | 2029 QuicConnectionPeer::GetSentEntropyHash(&connection_, 4) ^ |
2087 QuicConnectionPeer::GetSentEntropyHash(&connection_, 3) ^ | 2030 QuicConnectionPeer::GetSentEntropyHash(&connection_, 3) ^ |
2088 QuicConnectionPeer::GetSentEntropyHash(&connection_, 2); | 2031 QuicConnectionPeer::GetSentEntropyHash(&connection_, 2); |
2089 QuicFrame frame(&nack_three); | 2032 QuicFrame frame(&nack_three); |
2090 EXPECT_CALL(visitor_, OnAck(_)); | 2033 EXPECT_CALL(visitor_, OnAck(_)); |
2091 EXPECT_CALL(*send_algorithm_, OnIncomingAck(_, _, _)).Times(1); | 2034 EXPECT_CALL(*send_algorithm_, OnIncomingAck(_, _, _)).Times(1); |
2092 EXPECT_CALL(*send_algorithm_, OnIncomingLoss(_)).Times(1); | 2035 EXPECT_CALL(*send_algorithm_, OnIncomingLoss(_)).Times(1); |
2093 EXPECT_CALL(visitor_, OnCanWrite()).Times(3).WillRepeatedly(Return(true)); | |
2094 | 2036 |
2095 ProcessFramePacket(frame); | 2037 ProcessFramePacket(frame); |
2096 ProcessFramePacket(frame); | 2038 ProcessFramePacket(frame); |
2097 size_t ack_packet_size = last_sent_packet_size(); | 2039 size_t ack_packet_size = last_sent_packet_size(); |
2098 ProcessFramePacket(frame); | 2040 ProcessFramePacket(frame); |
2099 | 2041 |
2100 EXPECT_CALL(*send_algorithm_, SmoothedRtt()).WillOnce( | 2042 EXPECT_CALL(*send_algorithm_, SmoothedRtt()).WillOnce( |
2101 Return(QuicTime::Delta::Zero())); | 2043 Return(QuicTime::Delta::Zero())); |
2102 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillOnce( | 2044 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillOnce( |
2103 Return(QuicBandwidth::Zero())); | 2045 Return(QuicBandwidth::Zero())); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2173 | 2115 |
2174 QuicFrames frames; | 2116 QuicFrames frames; |
2175 frames.push_back(stream_frame); | 2117 frames.push_back(stream_frame); |
2176 frames.push_back(close_frame); | 2118 frames.push_back(close_frame); |
2177 scoped_ptr<QuicPacket> packet( | 2119 scoped_ptr<QuicPacket> packet( |
2178 framer_.ConstructFrameDataPacket(header_, frames).packet); | 2120 framer_.ConstructFrameDataPacket(header_, frames).packet); |
2179 EXPECT_TRUE(NULL != packet.get()); | 2121 EXPECT_TRUE(NULL != packet.get()); |
2180 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket( | 2122 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket( |
2181 ENCRYPTION_NONE, 1, *packet)); | 2123 ENCRYPTION_NONE, 1, *packet)); |
2182 | 2124 |
2183 EXPECT_CALL(visitor_, OnCanWrite()).Times(1).WillOnce(Return(true)); | |
2184 EXPECT_CALL(visitor_, ConnectionClose(QUIC_PEER_GOING_AWAY, true)); | 2125 EXPECT_CALL(visitor_, ConnectionClose(QUIC_PEER_GOING_AWAY, true)); |
2185 EXPECT_CALL(visitor_, OnPacket(_, _, _, _)).Times(0); | 2126 EXPECT_CALL(visitor_, OnPacket(_, _, _, _)).Times(0); |
2186 | 2127 |
2187 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); | 2128 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); |
2188 } | 2129 } |
2189 | 2130 |
2190 } // namespace | 2131 } // namespace |
2191 } // namespace test | 2132 } // namespace test |
2192 } // namespace net | 2133 } // namespace net |
OLD | NEW |