OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/quic/quic_connection.h" | 5 #include "net/quic/quic_connection.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 | 819 |
820 QuicPacketEntropyHash ProcessStopWaitingPacket(QuicStopWaitingFrame* frame) { | 820 QuicPacketEntropyHash ProcessStopWaitingPacket(QuicStopWaitingFrame* frame) { |
821 return ProcessFramePacket(QuicFrame(frame)); | 821 return ProcessFramePacket(QuicFrame(frame)); |
822 } | 822 } |
823 | 823 |
824 QuicPacketEntropyHash ProcessGoAwayPacket(QuicGoAwayFrame* frame) { | 824 QuicPacketEntropyHash ProcessGoAwayPacket(QuicGoAwayFrame* frame) { |
825 return ProcessFramePacket(QuicFrame(frame)); | 825 return ProcessFramePacket(QuicFrame(frame)); |
826 } | 826 } |
827 | 827 |
828 bool IsMissing(QuicPacketSequenceNumber number) { | 828 bool IsMissing(QuicPacketSequenceNumber number) { |
829 return IsAwaitingPacket(outgoing_ack()->received_info, number); | 829 return IsAwaitingPacket(*outgoing_ack(), number); |
830 } | 830 } |
831 | 831 |
832 QuicPacket* ConstructDataPacket(QuicPacketSequenceNumber number, | 832 QuicPacket* ConstructDataPacket(QuicPacketSequenceNumber number, |
833 QuicFecGroupNumber fec_group, | 833 QuicFecGroupNumber fec_group, |
834 bool entropy_flag) { | 834 bool entropy_flag) { |
835 header_.public_header.connection_id = connection_id_; | 835 header_.public_header.connection_id = connection_id_; |
836 header_.public_header.reset_flag = false; | 836 header_.public_header.reset_flag = false; |
837 header_.public_header.version_flag = false; | 837 header_.public_header.version_flag = false; |
838 header_.public_header.sequence_number_length = sequence_number_length_; | 838 header_.public_header.sequence_number_length = sequence_number_length_; |
839 header_.public_header.connection_id_length = connection_id_length_; | 839 header_.public_header.connection_id_length = connection_id_length_; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 } | 885 } |
886 | 886 |
887 QuicTime::Delta DefaultDelayedAckTime() { | 887 QuicTime::Delta DefaultDelayedAckTime() { |
888 return QuicTime::Delta::FromMilliseconds(kMinRetransmissionTimeMs/2); | 888 return QuicTime::Delta::FromMilliseconds(kMinRetransmissionTimeMs/2); |
889 } | 889 } |
890 | 890 |
891 // Initialize a frame acknowledging all packets up to largest_observed. | 891 // Initialize a frame acknowledging all packets up to largest_observed. |
892 const QuicAckFrame InitAckFrame(QuicPacketSequenceNumber largest_observed) { | 892 const QuicAckFrame InitAckFrame(QuicPacketSequenceNumber largest_observed) { |
893 QuicAckFrame frame(MakeAckFrame(largest_observed)); | 893 QuicAckFrame frame(MakeAckFrame(largest_observed)); |
894 if (largest_observed > 0) { | 894 if (largest_observed > 0) { |
895 frame.received_info.entropy_hash = | 895 frame.entropy_hash = |
896 QuicConnectionPeer::GetSentEntropyHash(&connection_, largest_observed); | 896 QuicConnectionPeer::GetSentEntropyHash(&connection_, |
| 897 largest_observed); |
897 } | 898 } |
898 return frame; | 899 return frame; |
899 } | 900 } |
900 | 901 |
901 const QuicStopWaitingFrame InitStopWaitingFrame( | 902 const QuicStopWaitingFrame InitStopWaitingFrame( |
902 QuicPacketSequenceNumber least_unacked) { | 903 QuicPacketSequenceNumber least_unacked) { |
903 QuicStopWaitingFrame frame; | 904 QuicStopWaitingFrame frame; |
904 frame.least_unacked = least_unacked; | 905 frame.least_unacked = least_unacked; |
905 return frame; | 906 return frame; |
906 } | 907 } |
907 // Explicitly nack a packet. | 908 // Explicitly nack a packet. |
908 void NackPacket(QuicPacketSequenceNumber missing, QuicAckFrame* frame) { | 909 void NackPacket(QuicPacketSequenceNumber missing, QuicAckFrame* frame) { |
909 frame->received_info.missing_packets.insert(missing); | 910 frame->missing_packets.insert(missing); |
910 frame->received_info.entropy_hash ^= | 911 frame->entropy_hash ^= |
911 QuicConnectionPeer::GetSentEntropyHash(&connection_, missing); | 912 QuicConnectionPeer::GetSentEntropyHash(&connection_, missing); |
912 if (missing > 1) { | 913 if (missing > 1) { |
913 frame->received_info.entropy_hash ^= | 914 frame->entropy_hash ^= |
914 QuicConnectionPeer::GetSentEntropyHash(&connection_, missing - 1); | 915 QuicConnectionPeer::GetSentEntropyHash(&connection_, missing - 1); |
915 } | 916 } |
916 } | 917 } |
917 | 918 |
918 // Undo nacking a packet within the frame. | 919 // Undo nacking a packet within the frame. |
919 void AckPacket(QuicPacketSequenceNumber arrived, QuicAckFrame* frame) { | 920 void AckPacket(QuicPacketSequenceNumber arrived, QuicAckFrame* frame) { |
920 EXPECT_THAT(frame->received_info.missing_packets, Contains(arrived)); | 921 EXPECT_THAT(frame->missing_packets, Contains(arrived)); |
921 frame->received_info.missing_packets.erase(arrived); | 922 frame->missing_packets.erase(arrived); |
922 frame->received_info.entropy_hash ^= | 923 frame->entropy_hash ^= |
923 QuicConnectionPeer::GetSentEntropyHash(&connection_, arrived); | 924 QuicConnectionPeer::GetSentEntropyHash(&connection_, arrived); |
924 if (arrived > 1) { | 925 if (arrived > 1) { |
925 frame->received_info.entropy_hash ^= | 926 frame->entropy_hash ^= |
926 QuicConnectionPeer::GetSentEntropyHash(&connection_, arrived - 1); | 927 QuicConnectionPeer::GetSentEntropyHash(&connection_, arrived - 1); |
927 } | 928 } |
928 } | 929 } |
929 | 930 |
930 void TriggerConnectionClose() { | 931 void TriggerConnectionClose() { |
931 // Send an erroneous packet to close the connection. | 932 // Send an erroneous packet to close the connection. |
932 EXPECT_CALL(visitor_, | 933 EXPECT_CALL(visitor_, |
933 OnConnectionClosed(QUIC_INVALID_PACKET_HEADER, false)); | 934 OnConnectionClosed(QUIC_INVALID_PACKET_HEADER, false)); |
934 // Call ProcessDataPacket rather than ProcessPacket, as we should not get a | 935 // Call ProcessDataPacket rather than ProcessPacket, as we should not get a |
935 // packet call to the visitor. | 936 // packet call to the visitor. |
936 ProcessDataPacket(6000, 0, !kEntropyFlag); | 937 ProcessDataPacket(6000, 0, !kEntropyFlag); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
984 | 985 |
985 // Run all end to end tests with all supported versions. | 986 // Run all end to end tests with all supported versions. |
986 INSTANTIATE_TEST_CASE_P(SupportedVersion, | 987 INSTANTIATE_TEST_CASE_P(SupportedVersion, |
987 QuicConnectionTest, | 988 QuicConnectionTest, |
988 ::testing::ValuesIn(QuicSupportedVersions())); | 989 ::testing::ValuesIn(QuicSupportedVersions())); |
989 | 990 |
990 TEST_P(QuicConnectionTest, PacketsInOrder) { | 991 TEST_P(QuicConnectionTest, PacketsInOrder) { |
991 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 992 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
992 | 993 |
993 ProcessPacket(1); | 994 ProcessPacket(1); |
994 EXPECT_EQ(1u, outgoing_ack()->received_info.largest_observed); | 995 EXPECT_EQ(1u, outgoing_ack()->largest_observed); |
995 EXPECT_EQ(0u, outgoing_ack()->received_info.missing_packets.size()); | 996 EXPECT_EQ(0u, outgoing_ack()->missing_packets.size()); |
996 | 997 |
997 ProcessPacket(2); | 998 ProcessPacket(2); |
998 EXPECT_EQ(2u, outgoing_ack()->received_info.largest_observed); | 999 EXPECT_EQ(2u, outgoing_ack()->largest_observed); |
999 EXPECT_EQ(0u, outgoing_ack()->received_info.missing_packets.size()); | 1000 EXPECT_EQ(0u, outgoing_ack()->missing_packets.size()); |
1000 | 1001 |
1001 ProcessPacket(3); | 1002 ProcessPacket(3); |
1002 EXPECT_EQ(3u, outgoing_ack()->received_info.largest_observed); | 1003 EXPECT_EQ(3u, outgoing_ack()->largest_observed); |
1003 EXPECT_EQ(0u, outgoing_ack()->received_info.missing_packets.size()); | 1004 EXPECT_EQ(0u, outgoing_ack()->missing_packets.size()); |
1004 } | 1005 } |
1005 | 1006 |
1006 TEST_P(QuicConnectionTest, PacketsOutOfOrder) { | 1007 TEST_P(QuicConnectionTest, PacketsOutOfOrder) { |
1007 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1008 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1008 | 1009 |
1009 ProcessPacket(3); | 1010 ProcessPacket(3); |
1010 EXPECT_EQ(3u, outgoing_ack()->received_info.largest_observed); | 1011 EXPECT_EQ(3u, outgoing_ack()->largest_observed); |
1011 EXPECT_TRUE(IsMissing(2)); | 1012 EXPECT_TRUE(IsMissing(2)); |
1012 EXPECT_TRUE(IsMissing(1)); | 1013 EXPECT_TRUE(IsMissing(1)); |
1013 | 1014 |
1014 ProcessPacket(2); | 1015 ProcessPacket(2); |
1015 EXPECT_EQ(3u, outgoing_ack()->received_info.largest_observed); | 1016 EXPECT_EQ(3u, outgoing_ack()->largest_observed); |
1016 EXPECT_FALSE(IsMissing(2)); | 1017 EXPECT_FALSE(IsMissing(2)); |
1017 EXPECT_TRUE(IsMissing(1)); | 1018 EXPECT_TRUE(IsMissing(1)); |
1018 | 1019 |
1019 ProcessPacket(1); | 1020 ProcessPacket(1); |
1020 EXPECT_EQ(3u, outgoing_ack()->received_info.largest_observed); | 1021 EXPECT_EQ(3u, outgoing_ack()->largest_observed); |
1021 EXPECT_FALSE(IsMissing(2)); | 1022 EXPECT_FALSE(IsMissing(2)); |
1022 EXPECT_FALSE(IsMissing(1)); | 1023 EXPECT_FALSE(IsMissing(1)); |
1023 } | 1024 } |
1024 | 1025 |
1025 TEST_P(QuicConnectionTest, DuplicatePacket) { | 1026 TEST_P(QuicConnectionTest, DuplicatePacket) { |
1026 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1027 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1027 | 1028 |
1028 ProcessPacket(3); | 1029 ProcessPacket(3); |
1029 EXPECT_EQ(3u, outgoing_ack()->received_info.largest_observed); | 1030 EXPECT_EQ(3u, outgoing_ack()->largest_observed); |
1030 EXPECT_TRUE(IsMissing(2)); | 1031 EXPECT_TRUE(IsMissing(2)); |
1031 EXPECT_TRUE(IsMissing(1)); | 1032 EXPECT_TRUE(IsMissing(1)); |
1032 | 1033 |
1033 // Send packet 3 again, but do not set the expectation that | 1034 // Send packet 3 again, but do not set the expectation that |
1034 // the visitor OnStreamFrames() will be called. | 1035 // the visitor OnStreamFrames() will be called. |
1035 ProcessDataPacket(3, 0, !kEntropyFlag); | 1036 ProcessDataPacket(3, 0, !kEntropyFlag); |
1036 EXPECT_EQ(3u, outgoing_ack()->received_info.largest_observed); | 1037 EXPECT_EQ(3u, outgoing_ack()->largest_observed); |
1037 EXPECT_TRUE(IsMissing(2)); | 1038 EXPECT_TRUE(IsMissing(2)); |
1038 EXPECT_TRUE(IsMissing(1)); | 1039 EXPECT_TRUE(IsMissing(1)); |
1039 } | 1040 } |
1040 | 1041 |
1041 TEST_P(QuicConnectionTest, PacketsOutOfOrderWithAdditionsAndLeastAwaiting) { | 1042 TEST_P(QuicConnectionTest, PacketsOutOfOrderWithAdditionsAndLeastAwaiting) { |
1042 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1043 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1043 | 1044 |
1044 ProcessPacket(3); | 1045 ProcessPacket(3); |
1045 EXPECT_EQ(3u, outgoing_ack()->received_info.largest_observed); | 1046 EXPECT_EQ(3u, outgoing_ack()->largest_observed); |
1046 EXPECT_TRUE(IsMissing(2)); | 1047 EXPECT_TRUE(IsMissing(2)); |
1047 EXPECT_TRUE(IsMissing(1)); | 1048 EXPECT_TRUE(IsMissing(1)); |
1048 | 1049 |
1049 ProcessPacket(2); | 1050 ProcessPacket(2); |
1050 EXPECT_EQ(3u, outgoing_ack()->received_info.largest_observed); | 1051 EXPECT_EQ(3u, outgoing_ack()->largest_observed); |
1051 EXPECT_TRUE(IsMissing(1)); | 1052 EXPECT_TRUE(IsMissing(1)); |
1052 | 1053 |
1053 ProcessPacket(5); | 1054 ProcessPacket(5); |
1054 EXPECT_EQ(5u, outgoing_ack()->received_info.largest_observed); | 1055 EXPECT_EQ(5u, outgoing_ack()->largest_observed); |
1055 EXPECT_TRUE(IsMissing(1)); | 1056 EXPECT_TRUE(IsMissing(1)); |
1056 EXPECT_TRUE(IsMissing(4)); | 1057 EXPECT_TRUE(IsMissing(4)); |
1057 | 1058 |
1058 // Pretend at this point the client has gotten acks for 2 and 3 and 1 is a | 1059 // Pretend at this point the client has gotten acks for 2 and 3 and 1 is a |
1059 // packet the peer will not retransmit. It indicates this by sending 'least | 1060 // packet the peer will not retransmit. It indicates this by sending 'least |
1060 // awaiting' is 4. The connection should then realize 1 will not be | 1061 // awaiting' is 4. The connection should then realize 1 will not be |
1061 // retransmitted, and will remove it from the missing list. | 1062 // retransmitted, and will remove it from the missing list. |
1062 peer_creator_.set_sequence_number(5); | 1063 peer_creator_.set_sequence_number(5); |
1063 QuicAckFrame frame = InitAckFrame(1); | 1064 QuicAckFrame frame = InitAckFrame(1); |
1064 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(_, _, _, _)); | 1065 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(_, _, _, _)); |
(...skipping 2083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3148 EXPECT_EQ("Unable to read public flags.", | 3149 EXPECT_EQ("Unable to read public flags.", |
3149 writer_->connection_close_frames()[0].error_details); | 3150 writer_->connection_close_frames()[0].error_details); |
3150 } | 3151 } |
3151 | 3152 |
3152 TEST_P(QuicConnectionTest, MissingPacketsBeforeLeastUnacked) { | 3153 TEST_P(QuicConnectionTest, MissingPacketsBeforeLeastUnacked) { |
3153 // Set the sequence number of the ack packet to be least unacked (4). | 3154 // Set the sequence number of the ack packet to be least unacked (4). |
3154 peer_creator_.set_sequence_number(3); | 3155 peer_creator_.set_sequence_number(3); |
3155 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3156 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3156 QuicStopWaitingFrame frame = InitStopWaitingFrame(4); | 3157 QuicStopWaitingFrame frame = InitStopWaitingFrame(4); |
3157 ProcessStopWaitingPacket(&frame); | 3158 ProcessStopWaitingPacket(&frame); |
3158 EXPECT_TRUE(outgoing_ack()->received_info.missing_packets.empty()); | 3159 EXPECT_TRUE(outgoing_ack()->missing_packets.empty()); |
3159 } | 3160 } |
3160 | 3161 |
3161 TEST_P(QuicConnectionTest, ReceivedEntropyHashCalculation) { | 3162 TEST_P(QuicConnectionTest, ReceivedEntropyHashCalculation) { |
3162 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(AtLeast(1)); | 3163 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(AtLeast(1)); |
3163 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3164 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3164 ProcessDataPacket(1, 1, kEntropyFlag); | 3165 ProcessDataPacket(1, 1, kEntropyFlag); |
3165 ProcessDataPacket(4, 1, kEntropyFlag); | 3166 ProcessDataPacket(4, 1, kEntropyFlag); |
3166 ProcessDataPacket(3, 1, !kEntropyFlag); | 3167 ProcessDataPacket(3, 1, !kEntropyFlag); |
3167 ProcessDataPacket(7, 1, kEntropyFlag); | 3168 ProcessDataPacket(7, 1, kEntropyFlag); |
3168 EXPECT_EQ(146u, outgoing_ack()->received_info.entropy_hash); | 3169 EXPECT_EQ(146u, outgoing_ack()->entropy_hash); |
3169 } | 3170 } |
3170 | 3171 |
3171 TEST_P(QuicConnectionTest, ReceivedEntropyHashCalculationHalfFEC) { | 3172 TEST_P(QuicConnectionTest, ReceivedEntropyHashCalculationHalfFEC) { |
3172 // FEC packets should not change the entropy hash calculation. | 3173 // FEC packets should not change the entropy hash calculation. |
3173 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(AtLeast(1)); | 3174 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(AtLeast(1)); |
3174 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3175 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3175 ProcessDataPacket(1, 1, kEntropyFlag); | 3176 ProcessDataPacket(1, 1, kEntropyFlag); |
3176 ProcessFecPacket(4, 1, false, kEntropyFlag, NULL); | 3177 ProcessFecPacket(4, 1, false, kEntropyFlag, NULL); |
3177 ProcessDataPacket(3, 3, !kEntropyFlag); | 3178 ProcessDataPacket(3, 3, !kEntropyFlag); |
3178 ProcessFecPacket(7, 3, false, kEntropyFlag, NULL); | 3179 ProcessFecPacket(7, 3, false, kEntropyFlag, NULL); |
3179 EXPECT_EQ(146u, outgoing_ack()->received_info.entropy_hash); | 3180 EXPECT_EQ(146u, outgoing_ack()->entropy_hash); |
3180 } | 3181 } |
3181 | 3182 |
3182 TEST_P(QuicConnectionTest, UpdateEntropyForReceivedPackets) { | 3183 TEST_P(QuicConnectionTest, UpdateEntropyForReceivedPackets) { |
3183 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(AtLeast(1)); | 3184 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(AtLeast(1)); |
3184 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3185 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3185 ProcessDataPacket(1, 1, kEntropyFlag); | 3186 ProcessDataPacket(1, 1, kEntropyFlag); |
3186 ProcessDataPacket(5, 1, kEntropyFlag); | 3187 ProcessDataPacket(5, 1, kEntropyFlag); |
3187 ProcessDataPacket(4, 1, !kEntropyFlag); | 3188 ProcessDataPacket(4, 1, !kEntropyFlag); |
3188 EXPECT_EQ(34u, outgoing_ack()->received_info.entropy_hash); | 3189 EXPECT_EQ(34u, outgoing_ack()->entropy_hash); |
3189 // Make 4th packet my least unacked, and update entropy for 2, 3 packets. | 3190 // Make 4th packet my least unacked, and update entropy for 2, 3 packets. |
3190 peer_creator_.set_sequence_number(5); | 3191 peer_creator_.set_sequence_number(5); |
3191 QuicPacketEntropyHash six_packet_entropy_hash = 0; | 3192 QuicPacketEntropyHash six_packet_entropy_hash = 0; |
3192 QuicPacketEntropyHash kRandomEntropyHash = 129u; | 3193 QuicPacketEntropyHash kRandomEntropyHash = 129u; |
3193 QuicStopWaitingFrame frame = InitStopWaitingFrame(4); | 3194 QuicStopWaitingFrame frame = InitStopWaitingFrame(4); |
3194 frame.entropy_hash = kRandomEntropyHash; | 3195 frame.entropy_hash = kRandomEntropyHash; |
3195 if (ProcessStopWaitingPacket(&frame)) { | 3196 if (ProcessStopWaitingPacket(&frame)) { |
3196 six_packet_entropy_hash = 1 << 6; | 3197 six_packet_entropy_hash = 1 << 6; |
3197 } | 3198 } |
3198 | 3199 |
3199 EXPECT_EQ((kRandomEntropyHash + (1 << 5) + six_packet_entropy_hash), | 3200 EXPECT_EQ((kRandomEntropyHash + (1 << 5) + six_packet_entropy_hash), |
3200 outgoing_ack()->received_info.entropy_hash); | 3201 outgoing_ack()->entropy_hash); |
3201 } | 3202 } |
3202 | 3203 |
3203 TEST_P(QuicConnectionTest, UpdateEntropyHashUptoCurrentPacket) { | 3204 TEST_P(QuicConnectionTest, UpdateEntropyHashUptoCurrentPacket) { |
3204 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(AtLeast(1)); | 3205 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(AtLeast(1)); |
3205 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3206 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3206 ProcessDataPacket(1, 1, kEntropyFlag); | 3207 ProcessDataPacket(1, 1, kEntropyFlag); |
3207 ProcessDataPacket(5, 1, !kEntropyFlag); | 3208 ProcessDataPacket(5, 1, !kEntropyFlag); |
3208 ProcessDataPacket(22, 1, kEntropyFlag); | 3209 ProcessDataPacket(22, 1, kEntropyFlag); |
3209 EXPECT_EQ(66u, outgoing_ack()->received_info.entropy_hash); | 3210 EXPECT_EQ(66u, outgoing_ack()->entropy_hash); |
3210 peer_creator_.set_sequence_number(22); | 3211 peer_creator_.set_sequence_number(22); |
3211 QuicPacketEntropyHash kRandomEntropyHash = 85u; | 3212 QuicPacketEntropyHash kRandomEntropyHash = 85u; |
3212 // Current packet is the least unacked packet. | 3213 // Current packet is the least unacked packet. |
3213 QuicPacketEntropyHash ack_entropy_hash; | 3214 QuicPacketEntropyHash ack_entropy_hash; |
3214 QuicStopWaitingFrame frame = InitStopWaitingFrame(23); | 3215 QuicStopWaitingFrame frame = InitStopWaitingFrame(23); |
3215 frame.entropy_hash = kRandomEntropyHash; | 3216 frame.entropy_hash = kRandomEntropyHash; |
3216 ack_entropy_hash = ProcessStopWaitingPacket(&frame); | 3217 ack_entropy_hash = ProcessStopWaitingPacket(&frame); |
3217 EXPECT_EQ((kRandomEntropyHash + ack_entropy_hash), | 3218 EXPECT_EQ((kRandomEntropyHash + ack_entropy_hash), |
3218 outgoing_ack()->received_info.entropy_hash); | 3219 outgoing_ack()->entropy_hash); |
3219 ProcessDataPacket(25, 1, kEntropyFlag); | 3220 ProcessDataPacket(25, 1, kEntropyFlag); |
3220 EXPECT_EQ((kRandomEntropyHash + ack_entropy_hash + (1 << (25 % 8))), | 3221 EXPECT_EQ((kRandomEntropyHash + ack_entropy_hash + (1 << (25 % 8))), |
3221 outgoing_ack()->received_info.entropy_hash); | 3222 outgoing_ack()->entropy_hash); |
3222 } | 3223 } |
3223 | 3224 |
3224 TEST_P(QuicConnectionTest, EntropyCalculationForTruncatedAck) { | 3225 TEST_P(QuicConnectionTest, EntropyCalculationForTruncatedAck) { |
3225 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(AtLeast(1)); | 3226 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(AtLeast(1)); |
3226 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3227 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3227 QuicPacketEntropyHash entropy[51]; | 3228 QuicPacketEntropyHash entropy[51]; |
3228 entropy[0] = 0; | 3229 entropy[0] = 0; |
3229 for (int i = 1; i < 51; ++i) { | 3230 for (int i = 1; i < 51; ++i) { |
3230 bool should_send = i % 10 != 1; | 3231 bool should_send = i % 10 != 1; |
3231 bool entropy_flag = (i & (i - 1)) != 0; | 3232 bool entropy_flag = (i & (i - 1)) != 0; |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3818 | 3819 |
3819 // Send some data, which will register the delegate to be notified. | 3820 // Send some data, which will register the delegate to be notified. |
3820 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get()); | 3821 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get()); |
3821 connection_.SendStreamDataWithString(2, "bar", 0, !kFin, NULL); | 3822 connection_.SendStreamDataWithString(2, "bar", 0, !kFin, NULL); |
3822 | 3823 |
3823 // Process an ACK from the server with a revived packet, which should trigger | 3824 // Process an ACK from the server with a revived packet, which should trigger |
3824 // the callback. | 3825 // the callback. |
3825 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 3826 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
3826 QuicAckFrame frame = InitAckFrame(2); | 3827 QuicAckFrame frame = InitAckFrame(2); |
3827 NackPacket(1, &frame); | 3828 NackPacket(1, &frame); |
3828 frame.received_info.revived_packets.insert(1); | 3829 frame.revived_packets.insert(1); |
3829 ProcessAckPacket(&frame); | 3830 ProcessAckPacket(&frame); |
3830 // If the ack is processed again, the notifier should not be called again. | 3831 // If the ack is processed again, the notifier should not be called again. |
3831 ProcessAckPacket(&frame); | 3832 ProcessAckPacket(&frame); |
3832 } | 3833 } |
3833 | 3834 |
3834 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterFECRecovery) { | 3835 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterFECRecovery) { |
3835 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3836 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3836 EXPECT_CALL(visitor_, OnCanWrite()); | 3837 EXPECT_CALL(visitor_, OnCanWrite()); |
3837 | 3838 |
3838 // Create a delegate which we expect to be called. | 3839 // Create a delegate which we expect to be called. |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3984 QuicBlockedFrame blocked; | 3985 QuicBlockedFrame blocked; |
3985 blocked.stream_id = 3; | 3986 blocked.stream_id = 3; |
3986 EXPECT_CALL(visitor_, OnBlockedFrames(_)); | 3987 EXPECT_CALL(visitor_, OnBlockedFrames(_)); |
3987 ProcessFramePacket(QuicFrame(&blocked)); | 3988 ProcessFramePacket(QuicFrame(&blocked)); |
3988 EXPECT_TRUE(ack_alarm->IsSet()); | 3989 EXPECT_TRUE(ack_alarm->IsSet()); |
3989 } | 3990 } |
3990 | 3991 |
3991 } // namespace | 3992 } // namespace |
3992 } // namespace test | 3993 } // namespace test |
3993 } // namespace net | 3994 } // namespace net |
OLD | NEW |