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