| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 const int kDefaultRetransmissionTimeMs = 500; | 60 const int kDefaultRetransmissionTimeMs = 500; |
| 61 | 61 |
| 62 class TestReceiveAlgorithm : public ReceiveAlgorithmInterface { | 62 class TestReceiveAlgorithm : public ReceiveAlgorithmInterface { |
| 63 public: | 63 public: |
| 64 explicit TestReceiveAlgorithm(QuicCongestionFeedbackFrame* feedback) | 64 explicit TestReceiveAlgorithm(QuicCongestionFeedbackFrame* feedback) |
| 65 : feedback_(feedback) { | 65 : feedback_(feedback) { |
| 66 } | 66 } |
| 67 | 67 |
| 68 bool GenerateCongestionFeedback( | 68 bool GenerateCongestionFeedback( |
| 69 QuicCongestionFeedbackFrame* congestion_feedback) { | 69 QuicCongestionFeedbackFrame* congestion_feedback) { |
| 70 if (feedback_ == NULL) { | 70 if (feedback_ == nullptr) { |
| 71 return false; | 71 return false; |
| 72 } | 72 } |
| 73 *congestion_feedback = *feedback_; | 73 *congestion_feedback = *feedback_; |
| 74 return true; | 74 return true; |
| 75 } | 75 } |
| 76 | 76 |
| 77 MOCK_METHOD3(RecordIncomingPacket, | 77 MOCK_METHOD3(RecordIncomingPacket, |
| 78 void(QuicByteCount, QuicPacketSequenceNumber, QuicTime)); | 78 void(QuicByteCount, QuicPacketSequenceNumber, QuicTime)); |
| 79 | 79 |
| 80 private: | 80 private: |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 } | 171 } |
| 172 *output_length = ciphertext.size() - kTagSize; | 172 *output_length = ciphertext.size() - kTagSize; |
| 173 memcpy(output, ciphertext.data(), *output_length); | 173 memcpy(output, ciphertext.data(), *output_length); |
| 174 return true; | 174 return true; |
| 175 } | 175 } |
| 176 | 176 |
| 177 virtual QuicData* DecryptPacket(QuicPacketSequenceNumber sequence_number, | 177 virtual QuicData* DecryptPacket(QuicPacketSequenceNumber sequence_number, |
| 178 StringPiece associated_data, | 178 StringPiece associated_data, |
| 179 StringPiece ciphertext) OVERRIDE { | 179 StringPiece ciphertext) OVERRIDE { |
| 180 if (ciphertext.size() < kTagSize) { | 180 if (ciphertext.size() < kTagSize) { |
| 181 return NULL; | 181 return nullptr; |
| 182 } | 182 } |
| 183 if (!CheckTag(ciphertext, GetTag(ciphertext))) { | 183 if (!CheckTag(ciphertext, GetTag(ciphertext))) { |
| 184 return NULL; | 184 return nullptr; |
| 185 } | 185 } |
| 186 const size_t len = ciphertext.size() - kTagSize; | 186 const size_t len = ciphertext.size() - kTagSize; |
| 187 uint8* buf = new uint8[len]; | 187 uint8* buf = new uint8[len]; |
| 188 memcpy(buf, ciphertext.data(), len); | 188 memcpy(buf, ciphertext.data(), len); |
| 189 return new QuicData(reinterpret_cast<char*>(buf), len, | 189 return new QuicData(reinterpret_cast<char*>(buf), len, |
| 190 true /* owns buffer */); | 190 true /* owns buffer */); |
| 191 } | 191 } |
| 192 | 192 |
| 193 virtual StringPiece GetKey() const OVERRIDE { return StringPiece(); } | 193 virtual StringPiece GetKey() const OVERRIDE { return StringPiece(); } |
| 194 virtual StringPiece GetNoncePrefix() const OVERRIDE { return StringPiece(); } | 194 virtual StringPiece GetNoncePrefix() const OVERRIDE { return StringPiece(); } |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 QuicSentPacketManagerPeer::SetLossAlgorithm( | 444 QuicSentPacketManagerPeer::SetLossAlgorithm( |
| 445 QuicConnectionPeer::GetSentPacketManager(this), loss_algorithm); | 445 QuicConnectionPeer::GetSentPacketManager(this), loss_algorithm); |
| 446 } | 446 } |
| 447 | 447 |
| 448 void SendPacket(EncryptionLevel level, | 448 void SendPacket(EncryptionLevel level, |
| 449 QuicPacketSequenceNumber sequence_number, | 449 QuicPacketSequenceNumber sequence_number, |
| 450 QuicPacket* packet, | 450 QuicPacket* packet, |
| 451 QuicPacketEntropyHash entropy_hash, | 451 QuicPacketEntropyHash entropy_hash, |
| 452 HasRetransmittableData retransmittable) { | 452 HasRetransmittableData retransmittable) { |
| 453 RetransmittableFrames* retransmittable_frames = | 453 RetransmittableFrames* retransmittable_frames = |
| 454 retransmittable == HAS_RETRANSMITTABLE_DATA ? | 454 retransmittable == HAS_RETRANSMITTABLE_DATA |
| 455 new RetransmittableFrames() : NULL; | 455 ? new RetransmittableFrames() |
| 456 : nullptr; |
| 456 OnSerializedPacket( | 457 OnSerializedPacket( |
| 457 SerializedPacket(sequence_number, PACKET_6BYTE_SEQUENCE_NUMBER, | 458 SerializedPacket(sequence_number, PACKET_6BYTE_SEQUENCE_NUMBER, |
| 458 packet, entropy_hash, retransmittable_frames)); | 459 packet, entropy_hash, retransmittable_frames)); |
| 459 } | 460 } |
| 460 | 461 |
| 461 QuicConsumedData SendStreamDataWithString( | 462 QuicConsumedData SendStreamDataWithString( |
| 462 QuicStreamId id, | 463 QuicStreamId id, |
| 463 StringPiece data, | 464 StringPiece data, |
| 464 QuicStreamOffset offset, | 465 QuicStreamOffset offset, |
| 465 bool fin, | 466 bool fin, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 488 IOVector data_iov; | 489 IOVector data_iov; |
| 489 if (!data.empty()) { | 490 if (!data.empty()) { |
| 490 data_iov.Append(const_cast<char*>(data.data()), data.size()); | 491 data_iov.Append(const_cast<char*>(data.data()), data.size()); |
| 491 } | 492 } |
| 492 return QuicConnection::SendStreamData(id, data_iov, offset, fin, | 493 return QuicConnection::SendStreamData(id, data_iov, offset, fin, |
| 493 fec_protection, delegate); | 494 fec_protection, delegate); |
| 494 } | 495 } |
| 495 | 496 |
| 496 QuicConsumedData SendStreamData3() { | 497 QuicConsumedData SendStreamData3() { |
| 497 return SendStreamDataWithString(kClientDataStreamId1, "food", 0, !kFin, | 498 return SendStreamDataWithString(kClientDataStreamId1, "food", 0, !kFin, |
| 498 NULL); | 499 nullptr); |
| 499 } | 500 } |
| 500 | 501 |
| 501 QuicConsumedData SendStreamData3WithFec() { | 502 QuicConsumedData SendStreamData3WithFec() { |
| 502 return SendStreamDataWithStringWithFec(kClientDataStreamId1, "food", 0, | 503 return SendStreamDataWithStringWithFec(kClientDataStreamId1, "food", 0, |
| 503 !kFin, NULL); | 504 !kFin, nullptr); |
| 504 } | 505 } |
| 505 | 506 |
| 506 QuicConsumedData SendStreamData5() { | 507 QuicConsumedData SendStreamData5() { |
| 507 return SendStreamDataWithString(kClientDataStreamId2, "food2", 0, | 508 return SendStreamDataWithString(kClientDataStreamId2, "food2", 0, !kFin, |
| 508 !kFin, NULL); | 509 nullptr); |
| 509 } | 510 } |
| 510 | 511 |
| 511 QuicConsumedData SendStreamData5WithFec() { | 512 QuicConsumedData SendStreamData5WithFec() { |
| 512 return SendStreamDataWithStringWithFec(kClientDataStreamId2, "food2", 0, | 513 return SendStreamDataWithStringWithFec(kClientDataStreamId2, "food2", 0, |
| 513 !kFin, NULL); | 514 !kFin, nullptr); |
| 514 } | 515 } |
| 515 // Ensures the connection can write stream data before writing. | 516 // Ensures the connection can write stream data before writing. |
| 516 QuicConsumedData EnsureWritableAndSendStreamData5() { | 517 QuicConsumedData EnsureWritableAndSendStreamData5() { |
| 517 EXPECT_TRUE(CanWriteStreamData()); | 518 EXPECT_TRUE(CanWriteStreamData()); |
| 518 return SendStreamData5(); | 519 return SendStreamData5(); |
| 519 } | 520 } |
| 520 | 521 |
| 521 // The crypto stream has special semantics so that it is not blocked by a | 522 // The crypto stream has special semantics so that it is not blocked by a |
| 522 // congestion window limitation, and also so that it gets put into a separate | 523 // congestion window limitation, and also so that it gets put into a separate |
| 523 // packet (so that it is easier to reason about a crypto frame not being | 524 // packet (so that it is easier to reason about a crypto frame not being |
| 524 // split needlessly across packet boundaries). As a result, we have separate | 525 // split needlessly across packet boundaries). As a result, we have separate |
| 525 // tests for some cases for this stream. | 526 // tests for some cases for this stream. |
| 526 QuicConsumedData SendCryptoStreamData() { | 527 QuicConsumedData SendCryptoStreamData() { |
| 527 return SendStreamDataWithString(kCryptoStreamId, "chlo", 0, !kFin, NULL); | 528 return SendStreamDataWithString(kCryptoStreamId, "chlo", 0, !kFin, nullptr); |
| 528 } | 529 } |
| 529 | 530 |
| 530 bool is_server() { | 531 bool is_server() { |
| 531 return QuicConnectionPeer::IsServer(this); | 532 return QuicConnectionPeer::IsServer(this); |
| 532 } | 533 } |
| 533 | 534 |
| 534 void set_version(QuicVersion version) { | 535 void set_version(QuicVersion version) { |
| 535 QuicConnectionPeer::GetFramer(this)->set_version(version); | 536 QuicConnectionPeer::GetFramer(this)->set_version(version); |
| 536 } | 537 } |
| 537 | 538 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 factory_, false, version()), | 629 factory_, false, version()), |
| 629 frame1_(1, false, 0, MakeIOVector(data1)), | 630 frame1_(1, false, 0, MakeIOVector(data1)), |
| 630 frame2_(1, false, 3, MakeIOVector(data2)), | 631 frame2_(1, false, 3, MakeIOVector(data2)), |
| 631 sequence_number_length_(PACKET_6BYTE_SEQUENCE_NUMBER), | 632 sequence_number_length_(PACKET_6BYTE_SEQUENCE_NUMBER), |
| 632 connection_id_length_(PACKET_8BYTE_CONNECTION_ID) { | 633 connection_id_length_(PACKET_8BYTE_CONNECTION_ID) { |
| 633 connection_.set_visitor(&visitor_); | 634 connection_.set_visitor(&visitor_); |
| 634 connection_.SetSendAlgorithm(send_algorithm_); | 635 connection_.SetSendAlgorithm(send_algorithm_); |
| 635 connection_.SetLossAlgorithm(loss_algorithm_); | 636 connection_.SetLossAlgorithm(loss_algorithm_); |
| 636 framer_.set_received_entropy_calculator(&entropy_calculator_); | 637 framer_.set_received_entropy_calculator(&entropy_calculator_); |
| 637 // Simplify tests by not sending feedback unless specifically configured. | 638 // Simplify tests by not sending feedback unless specifically configured. |
| 638 SetFeedback(NULL); | 639 SetFeedback(nullptr); |
| 639 EXPECT_CALL( | 640 EXPECT_CALL( |
| 640 *send_algorithm_, TimeUntilSend(_, _, _)).WillRepeatedly(Return( | 641 *send_algorithm_, TimeUntilSend(_, _, _)).WillRepeatedly(Return( |
| 641 QuicTime::Delta::Zero())); | 642 QuicTime::Delta::Zero())); |
| 642 EXPECT_CALL(*receive_algorithm_, | 643 EXPECT_CALL(*receive_algorithm_, |
| 643 RecordIncomingPacket(_, _, _)).Times(AnyNumber()); | 644 RecordIncomingPacket(_, _, _)).Times(AnyNumber()); |
| 644 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 645 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
| 645 .Times(AnyNumber()); | 646 .Times(AnyNumber()); |
| 646 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()).WillRepeatedly( | 647 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()).WillRepeatedly( |
| 647 Return(QuicTime::Delta::Zero())); | 648 Return(QuicTime::Delta::Zero())); |
| 648 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly( | 649 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly( |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 } | 817 } |
| 817 | 818 |
| 818 QuicByteCount SendStreamDataToPeer(QuicStreamId id, | 819 QuicByteCount SendStreamDataToPeer(QuicStreamId id, |
| 819 StringPiece data, | 820 StringPiece data, |
| 820 QuicStreamOffset offset, | 821 QuicStreamOffset offset, |
| 821 bool fin, | 822 bool fin, |
| 822 QuicPacketSequenceNumber* last_packet) { | 823 QuicPacketSequenceNumber* last_packet) { |
| 823 QuicByteCount packet_size; | 824 QuicByteCount packet_size; |
| 824 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 825 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
| 825 .WillOnce(DoAll(SaveArg<3>(&packet_size), Return(true))); | 826 .WillOnce(DoAll(SaveArg<3>(&packet_size), Return(true))); |
| 826 connection_.SendStreamDataWithString(id, data, offset, fin, NULL); | 827 connection_.SendStreamDataWithString(id, data, offset, fin, nullptr); |
| 827 if (last_packet != NULL) { | 828 if (last_packet != nullptr) { |
| 828 *last_packet = | 829 *last_packet = |
| 829 QuicConnectionPeer::GetPacketCreator(&connection_)->sequence_number(); | 830 QuicConnectionPeer::GetPacketCreator(&connection_)->sequence_number(); |
| 830 } | 831 } |
| 831 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 832 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
| 832 .Times(AnyNumber()); | 833 .Times(AnyNumber()); |
| 833 return packet_size; | 834 return packet_size; |
| 834 } | 835 } |
| 835 | 836 |
| 836 void SendAckPacketToPeer() { | 837 void SendAckPacketToPeer() { |
| 837 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); | 838 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 868 header_.fec_flag = false; | 869 header_.fec_flag = false; |
| 869 header_.packet_sequence_number = number; | 870 header_.packet_sequence_number = number; |
| 870 header_.is_in_fec_group = fec_group == 0u ? NOT_IN_FEC_GROUP : IN_FEC_GROUP; | 871 header_.is_in_fec_group = fec_group == 0u ? NOT_IN_FEC_GROUP : IN_FEC_GROUP; |
| 871 header_.fec_group = fec_group; | 872 header_.fec_group = fec_group; |
| 872 | 873 |
| 873 QuicFrames frames; | 874 QuicFrames frames; |
| 874 QuicFrame frame(&frame1_); | 875 QuicFrame frame(&frame1_); |
| 875 frames.push_back(frame); | 876 frames.push_back(frame); |
| 876 QuicPacket* packet = | 877 QuicPacket* packet = |
| 877 BuildUnsizedDataPacket(&framer_, header_, frames).packet; | 878 BuildUnsizedDataPacket(&framer_, header_, frames).packet; |
| 878 EXPECT_TRUE(packet != NULL); | 879 EXPECT_TRUE(packet != nullptr); |
| 879 return packet; | 880 return packet; |
| 880 } | 881 } |
| 881 | 882 |
| 882 QuicPacket* ConstructPingPacket(QuicPacketSequenceNumber number) { | 883 QuicPacket* ConstructPingPacket(QuicPacketSequenceNumber number) { |
| 883 header_.public_header.connection_id = connection_id_; | 884 header_.public_header.connection_id = connection_id_; |
| 884 header_.packet_sequence_number = number; | 885 header_.packet_sequence_number = number; |
| 885 header_.public_header.reset_flag = false; | 886 header_.public_header.reset_flag = false; |
| 886 header_.public_header.version_flag = false; | 887 header_.public_header.version_flag = false; |
| 887 header_.entropy_flag = false; | 888 header_.entropy_flag = false; |
| 888 header_.fec_flag = false; | 889 header_.fec_flag = false; |
| 889 header_.is_in_fec_group = NOT_IN_FEC_GROUP; | 890 header_.is_in_fec_group = NOT_IN_FEC_GROUP; |
| 890 header_.fec_group = 0; | 891 header_.fec_group = 0; |
| 891 | 892 |
| 892 QuicPingFrame ping; | 893 QuicPingFrame ping; |
| 893 | 894 |
| 894 QuicFrames frames; | 895 QuicFrames frames; |
| 895 QuicFrame frame(&ping); | 896 QuicFrame frame(&ping); |
| 896 frames.push_back(frame); | 897 frames.push_back(frame); |
| 897 QuicPacket* packet = | 898 QuicPacket* packet = |
| 898 BuildUnsizedDataPacket(&framer_, header_, frames).packet; | 899 BuildUnsizedDataPacket(&framer_, header_, frames).packet; |
| 899 EXPECT_TRUE(packet != NULL); | 900 EXPECT_TRUE(packet != nullptr); |
| 900 return packet; | 901 return packet; |
| 901 } | 902 } |
| 902 | 903 |
| 903 QuicPacket* ConstructClosePacket(QuicPacketSequenceNumber number, | 904 QuicPacket* ConstructClosePacket(QuicPacketSequenceNumber number, |
| 904 QuicFecGroupNumber fec_group) { | 905 QuicFecGroupNumber fec_group) { |
| 905 header_.public_header.connection_id = connection_id_; | 906 header_.public_header.connection_id = connection_id_; |
| 906 header_.packet_sequence_number = number; | 907 header_.packet_sequence_number = number; |
| 907 header_.public_header.reset_flag = false; | 908 header_.public_header.reset_flag = false; |
| 908 header_.public_header.version_flag = false; | 909 header_.public_header.version_flag = false; |
| 909 header_.entropy_flag = false; | 910 header_.entropy_flag = false; |
| 910 header_.fec_flag = false; | 911 header_.fec_flag = false; |
| 911 header_.is_in_fec_group = fec_group == 0u ? NOT_IN_FEC_GROUP : IN_FEC_GROUP; | 912 header_.is_in_fec_group = fec_group == 0u ? NOT_IN_FEC_GROUP : IN_FEC_GROUP; |
| 912 header_.fec_group = fec_group; | 913 header_.fec_group = fec_group; |
| 913 | 914 |
| 914 QuicConnectionCloseFrame qccf; | 915 QuicConnectionCloseFrame qccf; |
| 915 qccf.error_code = QUIC_PEER_GOING_AWAY; | 916 qccf.error_code = QUIC_PEER_GOING_AWAY; |
| 916 | 917 |
| 917 QuicFrames frames; | 918 QuicFrames frames; |
| 918 QuicFrame frame(&qccf); | 919 QuicFrame frame(&qccf); |
| 919 frames.push_back(frame); | 920 frames.push_back(frame); |
| 920 QuicPacket* packet = | 921 QuicPacket* packet = |
| 921 BuildUnsizedDataPacket(&framer_, header_, frames).packet; | 922 BuildUnsizedDataPacket(&framer_, header_, frames).packet; |
| 922 EXPECT_TRUE(packet != NULL); | 923 EXPECT_TRUE(packet != nullptr); |
| 923 return packet; | 924 return packet; |
| 924 } | 925 } |
| 925 | 926 |
| 926 void SetFeedback(QuicCongestionFeedbackFrame* feedback) { | 927 void SetFeedback(QuicCongestionFeedbackFrame* feedback) { |
| 927 receive_algorithm_ = new TestReceiveAlgorithm(feedback); | 928 receive_algorithm_ = new TestReceiveAlgorithm(feedback); |
| 928 connection_.SetReceiveAlgorithm(receive_algorithm_); | 929 connection_.SetReceiveAlgorithm(receive_algorithm_); |
| 929 } | 930 } |
| 930 | 931 |
| 931 QuicTime::Delta DefaultRetransmissionTime() { | 932 QuicTime::Delta DefaultRetransmissionTime() { |
| 932 return QuicTime::Delta::FromMilliseconds(kDefaultRetransmissionTimeMs); | 933 return QuicTime::Delta::FromMilliseconds(kDefaultRetransmissionTimeMs); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 QuicConnectionPeer::PacketEntropy(&connection_, arrived); | 970 QuicConnectionPeer::PacketEntropy(&connection_, arrived); |
| 970 } | 971 } |
| 971 | 972 |
| 972 void TriggerConnectionClose() { | 973 void TriggerConnectionClose() { |
| 973 // Send an erroneous packet to close the connection. | 974 // Send an erroneous packet to close the connection. |
| 974 EXPECT_CALL(visitor_, | 975 EXPECT_CALL(visitor_, |
| 975 OnConnectionClosed(QUIC_INVALID_PACKET_HEADER, false)); | 976 OnConnectionClosed(QUIC_INVALID_PACKET_HEADER, false)); |
| 976 // Call ProcessDataPacket rather than ProcessPacket, as we should not get a | 977 // Call ProcessDataPacket rather than ProcessPacket, as we should not get a |
| 977 // packet call to the visitor. | 978 // packet call to the visitor. |
| 978 ProcessDataPacket(6000, 0, !kEntropyFlag); | 979 ProcessDataPacket(6000, 0, !kEntropyFlag); |
| 979 EXPECT_FALSE( | 980 EXPECT_FALSE(QuicConnectionPeer::GetConnectionClosePacket(&connection_) == |
| 980 QuicConnectionPeer::GetConnectionClosePacket(&connection_) == NULL); | 981 nullptr); |
| 981 } | 982 } |
| 982 | 983 |
| 983 void BlockOnNextWrite() { | 984 void BlockOnNextWrite() { |
| 984 writer_->BlockOnNextWrite(); | 985 writer_->BlockOnNextWrite(); |
| 985 EXPECT_CALL(visitor_, OnWriteBlocked()).Times(AtLeast(1)); | 986 EXPECT_CALL(visitor_, OnWriteBlocked()).Times(AtLeast(1)); |
| 986 } | 987 } |
| 987 | 988 |
| 988 void CongestionBlockWrites() { | 989 void CongestionBlockWrites() { |
| 989 EXPECT_CALL(*send_algorithm_, | 990 EXPECT_CALL(*send_algorithm_, |
| 990 TimeUntilSend(_, _, _)).WillRepeatedly( | 991 TimeUntilSend(_, _, _)).WillRepeatedly( |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 SendAckPacketToPeer(); | 1112 SendAckPacketToPeer(); |
| 1112 EXPECT_TRUE(IsMissing(4)); | 1113 EXPECT_TRUE(IsMissing(4)); |
| 1113 } | 1114 } |
| 1114 | 1115 |
| 1115 TEST_P(QuicConnectionTest, RejectPacketTooFarOut) { | 1116 TEST_P(QuicConnectionTest, RejectPacketTooFarOut) { |
| 1116 EXPECT_CALL(visitor_, | 1117 EXPECT_CALL(visitor_, |
| 1117 OnConnectionClosed(QUIC_INVALID_PACKET_HEADER, false)); | 1118 OnConnectionClosed(QUIC_INVALID_PACKET_HEADER, false)); |
| 1118 // Call ProcessDataPacket rather than ProcessPacket, as we should not get a | 1119 // Call ProcessDataPacket rather than ProcessPacket, as we should not get a |
| 1119 // packet call to the visitor. | 1120 // packet call to the visitor. |
| 1120 ProcessDataPacket(6000, 0, !kEntropyFlag); | 1121 ProcessDataPacket(6000, 0, !kEntropyFlag); |
| 1121 EXPECT_FALSE( | 1122 EXPECT_FALSE(QuicConnectionPeer::GetConnectionClosePacket(&connection_) == |
| 1122 QuicConnectionPeer::GetConnectionClosePacket(&connection_) == NULL); | 1123 nullptr); |
| 1123 } | 1124 } |
| 1124 | 1125 |
| 1125 TEST_P(QuicConnectionTest, RejectUnencryptedStreamData) { | 1126 TEST_P(QuicConnectionTest, RejectUnencryptedStreamData) { |
| 1126 // Process an unencrypted packet from the non-crypto stream. | 1127 // Process an unencrypted packet from the non-crypto stream. |
| 1127 frame1_.stream_id = 3; | 1128 frame1_.stream_id = 3; |
| 1128 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1129 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 1129 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_UNENCRYPTED_STREAM_DATA, | 1130 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_UNENCRYPTED_STREAM_DATA, |
| 1130 false)); | 1131 false)); |
| 1131 ProcessDataPacket(1, 0, !kEntropyFlag); | 1132 ProcessDataPacket(1, 0, !kEntropyFlag); |
| 1132 EXPECT_FALSE( | 1133 EXPECT_FALSE(QuicConnectionPeer::GetConnectionClosePacket(&connection_) == |
| 1133 QuicConnectionPeer::GetConnectionClosePacket(&connection_) == NULL); | 1134 nullptr); |
| 1134 const vector<QuicConnectionCloseFrame>& connection_close_frames = | 1135 const vector<QuicConnectionCloseFrame>& connection_close_frames = |
| 1135 writer_->connection_close_frames(); | 1136 writer_->connection_close_frames(); |
| 1136 EXPECT_EQ(1u, connection_close_frames.size()); | 1137 EXPECT_EQ(1u, connection_close_frames.size()); |
| 1137 EXPECT_EQ(QUIC_UNENCRYPTED_STREAM_DATA, | 1138 EXPECT_EQ(QUIC_UNENCRYPTED_STREAM_DATA, |
| 1138 connection_close_frames[0].error_code); | 1139 connection_close_frames[0].error_code); |
| 1139 } | 1140 } |
| 1140 | 1141 |
| 1141 TEST_P(QuicConnectionTest, TruncatedAck) { | 1142 TEST_P(QuicConnectionTest, TruncatedAck) { |
| 1142 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1143 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 1143 QuicPacketSequenceNumber num_packets = 256 * 2 + 1; | 1144 QuicPacketSequenceNumber num_packets = 256 * 2 + 1; |
| 1144 for (QuicPacketSequenceNumber i = 0; i < num_packets; ++i) { | 1145 for (QuicPacketSequenceNumber i = 0; i < num_packets; ++i) { |
| 1145 SendStreamDataToPeer(3, "foo", i * 3, !kFin, NULL); | 1146 SendStreamDataToPeer(3, "foo", i * 3, !kFin, nullptr); |
| 1146 } | 1147 } |
| 1147 | 1148 |
| 1148 QuicAckFrame frame = InitAckFrame(num_packets); | 1149 QuicAckFrame frame = InitAckFrame(num_packets); |
| 1149 SequenceNumberSet lost_packets; | 1150 SequenceNumberSet lost_packets; |
| 1150 // Create an ack with 256 nacks, none adjacent to one another. | 1151 // Create an ack with 256 nacks, none adjacent to one another. |
| 1151 for (QuicPacketSequenceNumber i = 1; i <= 256; ++i) { | 1152 for (QuicPacketSequenceNumber i = 1; i <= 256; ++i) { |
| 1152 NackPacket(i * 2, &frame); | 1153 NackPacket(i * 2, &frame); |
| 1153 if (i < 256) { // Last packet is nacked, but not lost. | 1154 if (i < 256) { // Last packet is nacked, but not lost. |
| 1154 lost_packets.insert(i * 2); | 1155 lost_packets.insert(i * 2); |
| 1155 } | 1156 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 } | 1220 } |
| 1220 | 1221 |
| 1221 TEST_P(QuicConnectionTest, AckReceiptCausesAckSend) { | 1222 TEST_P(QuicConnectionTest, AckReceiptCausesAckSend) { |
| 1222 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1223 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 1223 | 1224 |
| 1224 QuicPacketSequenceNumber original; | 1225 QuicPacketSequenceNumber original; |
| 1225 QuicByteCount packet_size; | 1226 QuicByteCount packet_size; |
| 1226 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 1227 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
| 1227 .WillOnce(DoAll(SaveArg<2>(&original), SaveArg<3>(&packet_size), | 1228 .WillOnce(DoAll(SaveArg<2>(&original), SaveArg<3>(&packet_size), |
| 1228 Return(true))); | 1229 Return(true))); |
| 1229 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); | 1230 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); |
| 1230 QuicAckFrame frame = InitAckFrame(original); | 1231 QuicAckFrame frame = InitAckFrame(original); |
| 1231 NackPacket(original, &frame); | 1232 NackPacket(original, &frame); |
| 1232 // First nack triggers early retransmit. | 1233 // First nack triggers early retransmit. |
| 1233 SequenceNumberSet lost_packets; | 1234 SequenceNumberSet lost_packets; |
| 1234 lost_packets.insert(1); | 1235 lost_packets.insert(1); |
| 1235 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | 1236 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
| 1236 .WillOnce(Return(lost_packets)); | 1237 .WillOnce(Return(lost_packets)); |
| 1237 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 1238 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 1238 QuicPacketSequenceNumber retransmission; | 1239 QuicPacketSequenceNumber retransmission; |
| 1239 EXPECT_CALL(*send_algorithm_, | 1240 EXPECT_CALL(*send_algorithm_, |
| 1240 OnPacketSent(_, _, _, packet_size - kQuicVersionSize, _)) | 1241 OnPacketSent(_, _, _, packet_size - kQuicVersionSize, _)) |
| 1241 .WillOnce(DoAll(SaveArg<2>(&retransmission), Return(true))); | 1242 .WillOnce(DoAll(SaveArg<2>(&retransmission), Return(true))); |
| 1242 | 1243 |
| 1243 ProcessAckPacket(&frame); | 1244 ProcessAckPacket(&frame); |
| 1244 | 1245 |
| 1245 QuicAckFrame frame2 = InitAckFrame(retransmission); | 1246 QuicAckFrame frame2 = InitAckFrame(retransmission); |
| 1246 NackPacket(original, &frame2); | 1247 NackPacket(original, &frame2); |
| 1247 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 1248 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 1248 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | 1249 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
| 1249 .WillOnce(Return(SequenceNumberSet())); | 1250 .WillOnce(Return(SequenceNumberSet())); |
| 1250 ProcessAckPacket(&frame2); | 1251 ProcessAckPacket(&frame2); |
| 1251 | 1252 |
| 1252 // Now if the peer sends an ack which still reports the retransmitted packet | 1253 // Now if the peer sends an ack which still reports the retransmitted packet |
| 1253 // as missing, that will bundle an ack with data after two acks in a row | 1254 // as missing, that will bundle an ack with data after two acks in a row |
| 1254 // indicate the high water mark needs to be raised. | 1255 // indicate the high water mark needs to be raised. |
| 1255 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, | 1256 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, |
| 1256 HAS_RETRANSMITTABLE_DATA)); | 1257 HAS_RETRANSMITTABLE_DATA)); |
| 1257 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, NULL); | 1258 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, nullptr); |
| 1258 // No ack sent. | 1259 // No ack sent. |
| 1259 EXPECT_EQ(1u, writer_->frame_count()); | 1260 EXPECT_EQ(1u, writer_->frame_count()); |
| 1260 EXPECT_EQ(1u, writer_->stream_frames().size()); | 1261 EXPECT_EQ(1u, writer_->stream_frames().size()); |
| 1261 | 1262 |
| 1262 // No more packet loss for the rest of the test. | 1263 // No more packet loss for the rest of the test. |
| 1263 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | 1264 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
| 1264 .WillRepeatedly(Return(SequenceNumberSet())); | 1265 .WillRepeatedly(Return(SequenceNumberSet())); |
| 1265 ProcessAckPacket(&frame2); | 1266 ProcessAckPacket(&frame2); |
| 1266 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, | 1267 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, |
| 1267 HAS_RETRANSMITTABLE_DATA)); | 1268 HAS_RETRANSMITTABLE_DATA)); |
| 1268 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, NULL); | 1269 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, nullptr); |
| 1269 // Ack bundled. | 1270 // Ack bundled. |
| 1270 EXPECT_EQ(3u, writer_->frame_count()); | 1271 EXPECT_EQ(3u, writer_->frame_count()); |
| 1271 EXPECT_EQ(1u, writer_->stream_frames().size()); | 1272 EXPECT_EQ(1u, writer_->stream_frames().size()); |
| 1272 EXPECT_FALSE(writer_->ack_frames().empty()); | 1273 EXPECT_FALSE(writer_->ack_frames().empty()); |
| 1273 | 1274 |
| 1274 // But an ack with no missing packets will not send an ack. | 1275 // But an ack with no missing packets will not send an ack. |
| 1275 AckPacket(original, &frame2); | 1276 AckPacket(original, &frame2); |
| 1276 ProcessAckPacket(&frame2); | 1277 ProcessAckPacket(&frame2); |
| 1277 ProcessAckPacket(&frame2); | 1278 ProcessAckPacket(&frame2); |
| 1278 } | 1279 } |
| 1279 | 1280 |
| 1280 TEST_P(QuicConnectionTest, 20AcksCausesAckSend) { | 1281 TEST_P(QuicConnectionTest, 20AcksCausesAckSend) { |
| 1281 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1282 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 1282 | 1283 |
| 1283 SendStreamDataToPeer(1, "foo", 0, !kFin, NULL); | 1284 SendStreamDataToPeer(1, "foo", 0, !kFin, nullptr); |
| 1284 | 1285 |
| 1285 QuicAlarm* ack_alarm = QuicConnectionPeer::GetAckAlarm(&connection_); | 1286 QuicAlarm* ack_alarm = QuicConnectionPeer::GetAckAlarm(&connection_); |
| 1286 // But an ack with no missing packets will not send an ack. | 1287 // But an ack with no missing packets will not send an ack. |
| 1287 QuicAckFrame frame = InitAckFrame(1); | 1288 QuicAckFrame frame = InitAckFrame(1); |
| 1288 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 1289 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 1289 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | 1290 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
| 1290 .WillRepeatedly(Return(SequenceNumberSet())); | 1291 .WillRepeatedly(Return(SequenceNumberSet())); |
| 1291 for (int i = 0; i < 20; ++i) { | 1292 for (int i = 0; i < 20; ++i) { |
| 1292 EXPECT_FALSE(ack_alarm->IsSet()); | 1293 EXPECT_FALSE(ack_alarm->IsSet()); |
| 1293 ProcessAckPacket(&frame); | 1294 ProcessAckPacket(&frame); |
| 1294 } | 1295 } |
| 1295 EXPECT_TRUE(ack_alarm->IsSet()); | 1296 EXPECT_TRUE(ack_alarm->IsSet()); |
| 1296 } | 1297 } |
| 1297 | 1298 |
| 1298 TEST_P(QuicConnectionTest, LeastUnackedLower) { | 1299 TEST_P(QuicConnectionTest, LeastUnackedLower) { |
| 1299 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1300 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 1300 | 1301 |
| 1301 SendStreamDataToPeer(1, "foo", 0, !kFin, NULL); | 1302 SendStreamDataToPeer(1, "foo", 0, !kFin, nullptr); |
| 1302 SendStreamDataToPeer(1, "bar", 3, !kFin, NULL); | 1303 SendStreamDataToPeer(1, "bar", 3, !kFin, nullptr); |
| 1303 SendStreamDataToPeer(1, "eep", 6, !kFin, NULL); | 1304 SendStreamDataToPeer(1, "eep", 6, !kFin, nullptr); |
| 1304 | 1305 |
| 1305 // Start out saying the least unacked is 2. | 1306 // Start out saying the least unacked is 2. |
| 1306 peer_creator_.set_sequence_number(5); | 1307 peer_creator_.set_sequence_number(5); |
| 1307 QuicStopWaitingFrame frame = InitStopWaitingFrame(2); | 1308 QuicStopWaitingFrame frame = InitStopWaitingFrame(2); |
| 1308 ProcessStopWaitingPacket(&frame); | 1309 ProcessStopWaitingPacket(&frame); |
| 1309 | 1310 |
| 1310 // Change it to 1, but lower the sequence number to fake out-of-order packets. | 1311 // Change it to 1, but lower the sequence number to fake out-of-order packets. |
| 1311 // This should be fine. | 1312 // This should be fine. |
| 1312 peer_creator_.set_sequence_number(1); | 1313 peer_creator_.set_sequence_number(1); |
| 1313 // The scheduler will not process out of order acks, but all packet processing | 1314 // The scheduler will not process out of order acks, but all packet processing |
| 1314 // causes the connection to try to write. | 1315 // causes the connection to try to write. |
| 1315 EXPECT_CALL(visitor_, OnCanWrite()); | 1316 EXPECT_CALL(visitor_, OnCanWrite()); |
| 1316 QuicStopWaitingFrame frame2 = InitStopWaitingFrame(1); | 1317 QuicStopWaitingFrame frame2 = InitStopWaitingFrame(1); |
| 1317 ProcessStopWaitingPacket(&frame2); | 1318 ProcessStopWaitingPacket(&frame2); |
| 1318 | 1319 |
| 1319 // Now claim it's one, but set the ordering so it was sent "after" the first | 1320 // Now claim it's one, but set the ordering so it was sent "after" the first |
| 1320 // one. This should cause a connection error. | 1321 // one. This should cause a connection error. |
| 1321 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 1322 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
| 1322 peer_creator_.set_sequence_number(7); | 1323 peer_creator_.set_sequence_number(7); |
| 1323 EXPECT_CALL(visitor_, | 1324 EXPECT_CALL(visitor_, |
| 1324 OnConnectionClosed(QUIC_INVALID_STOP_WAITING_DATA, false)); | 1325 OnConnectionClosed(QUIC_INVALID_STOP_WAITING_DATA, false)); |
| 1325 QuicStopWaitingFrame frame3 = InitStopWaitingFrame(1); | 1326 QuicStopWaitingFrame frame3 = InitStopWaitingFrame(1); |
| 1326 ProcessStopWaitingPacket(&frame3); | 1327 ProcessStopWaitingPacket(&frame3); |
| 1327 } | 1328 } |
| 1328 | 1329 |
| 1329 TEST_P(QuicConnectionTest, LargestObservedLower) { | 1330 TEST_P(QuicConnectionTest, LargestObservedLower) { |
| 1330 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1331 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 1331 | 1332 |
| 1332 SendStreamDataToPeer(1, "foo", 0, !kFin, NULL); | 1333 SendStreamDataToPeer(1, "foo", 0, !kFin, nullptr); |
| 1333 SendStreamDataToPeer(1, "bar", 3, !kFin, NULL); | 1334 SendStreamDataToPeer(1, "bar", 3, !kFin, nullptr); |
| 1334 SendStreamDataToPeer(1, "eep", 6, !kFin, NULL); | 1335 SendStreamDataToPeer(1, "eep", 6, !kFin, nullptr); |
| 1335 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 1336 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 1336 | 1337 |
| 1337 // Start out saying the largest observed is 2. | 1338 // Start out saying the largest observed is 2. |
| 1338 QuicAckFrame frame1 = InitAckFrame(1); | 1339 QuicAckFrame frame1 = InitAckFrame(1); |
| 1339 QuicAckFrame frame2 = InitAckFrame(2); | 1340 QuicAckFrame frame2 = InitAckFrame(2); |
| 1340 ProcessAckPacket(&frame2); | 1341 ProcessAckPacket(&frame2); |
| 1341 | 1342 |
| 1342 // Now change it to 1, and it should cause a connection error. | 1343 // Now change it to 1, and it should cause a connection error. |
| 1343 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_INVALID_ACK_DATA, false)); | 1344 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_INVALID_ACK_DATA, false)); |
| 1344 EXPECT_CALL(visitor_, OnCanWrite()).Times(0); | 1345 EXPECT_CALL(visitor_, OnCanWrite()).Times(0); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1528 // stream frames with non-zero offets will fit within the packet length. | 1529 // stream frames with non-zero offets will fit within the packet length. |
| 1529 size_t length = 2 + GetPacketLengthForOneStream( | 1530 size_t length = 2 + GetPacketLengthForOneStream( |
| 1530 connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER, | 1531 connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER, |
| 1531 IN_FEC_GROUP, &payload_length); | 1532 IN_FEC_GROUP, &payload_length); |
| 1532 creator->set_max_packet_length(length); | 1533 creator->set_max_packet_length(length); |
| 1533 | 1534 |
| 1534 // Send 4 protected data packets, which should also trigger 1 FEC packet. | 1535 // Send 4 protected data packets, which should also trigger 1 FEC packet. |
| 1535 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(5); | 1536 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(5); |
| 1536 // The first stream frame will have 2 fewer overhead bytes than the other 3. | 1537 // The first stream frame will have 2 fewer overhead bytes than the other 3. |
| 1537 const string payload(payload_length * 4 + 2, 'a'); | 1538 const string payload(payload_length * 4 + 2, 'a'); |
| 1538 connection_.SendStreamDataWithStringWithFec(1, payload, 0, !kFin, NULL); | 1539 connection_.SendStreamDataWithStringWithFec(1, payload, 0, !kFin, nullptr); |
| 1539 // Expect the FEC group to be closed after SendStreamDataWithString. | 1540 // Expect the FEC group to be closed after SendStreamDataWithString. |
| 1540 EXPECT_FALSE(creator->IsFecGroupOpen()); | 1541 EXPECT_FALSE(creator->IsFecGroupOpen()); |
| 1541 EXPECT_FALSE(creator->IsFecProtected()); | 1542 EXPECT_FALSE(creator->IsFecProtected()); |
| 1542 } | 1543 } |
| 1543 | 1544 |
| 1544 TEST_P(QuicConnectionTest, FECQueueing) { | 1545 TEST_P(QuicConnectionTest, FECQueueing) { |
| 1545 // All packets carry version info till version is negotiated. | 1546 // All packets carry version info till version is negotiated. |
| 1546 size_t payload_length; | 1547 size_t payload_length; |
| 1547 QuicPacketCreator* creator = | 1548 QuicPacketCreator* creator = |
| 1548 QuicConnectionPeer::GetPacketCreator(&connection_); | 1549 QuicConnectionPeer::GetPacketCreator(&connection_); |
| 1549 size_t length = GetPacketLengthForOneStream( | 1550 size_t length = GetPacketLengthForOneStream( |
| 1550 connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER, | 1551 connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER, |
| 1551 IN_FEC_GROUP, &payload_length); | 1552 IN_FEC_GROUP, &payload_length); |
| 1552 creator->set_max_packet_length(length); | 1553 creator->set_max_packet_length(length); |
| 1553 EXPECT_TRUE(creator->IsFecEnabled()); | 1554 EXPECT_TRUE(creator->IsFecEnabled()); |
| 1554 | 1555 |
| 1555 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 1556 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
| 1556 BlockOnNextWrite(); | 1557 BlockOnNextWrite(); |
| 1557 const string payload(payload_length, 'a'); | 1558 const string payload(payload_length, 'a'); |
| 1558 connection_.SendStreamDataWithStringWithFec(1, payload, 0, !kFin, NULL); | 1559 connection_.SendStreamDataWithStringWithFec(1, payload, 0, !kFin, nullptr); |
| 1559 EXPECT_FALSE(creator->IsFecGroupOpen()); | 1560 EXPECT_FALSE(creator->IsFecGroupOpen()); |
| 1560 EXPECT_FALSE(creator->IsFecProtected()); | 1561 EXPECT_FALSE(creator->IsFecProtected()); |
| 1561 // Expect the first data packet and the fec packet to be queued. | 1562 // Expect the first data packet and the fec packet to be queued. |
| 1562 EXPECT_EQ(2u, connection_.NumQueuedPackets()); | 1563 EXPECT_EQ(2u, connection_.NumQueuedPackets()); |
| 1563 } | 1564 } |
| 1564 | 1565 |
| 1565 TEST_P(QuicConnectionTest, AbandonFECFromCongestionWindow) { | 1566 TEST_P(QuicConnectionTest, AbandonFECFromCongestionWindow) { |
| 1566 EXPECT_TRUE(QuicConnectionPeer::GetPacketCreator( | 1567 EXPECT_TRUE(QuicConnectionPeer::GetPacketCreator( |
| 1567 &connection_)->IsFecEnabled()); | 1568 &connection_)->IsFecEnabled()); |
| 1568 | 1569 |
| 1569 // 1 Data and 1 FEC packet. | 1570 // 1 Data and 1 FEC packet. |
| 1570 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2); | 1571 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2); |
| 1571 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, NULL); | 1572 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, nullptr); |
| 1572 | 1573 |
| 1573 const QuicTime::Delta retransmission_time = | 1574 const QuicTime::Delta retransmission_time = |
| 1574 QuicTime::Delta::FromMilliseconds(5000); | 1575 QuicTime::Delta::FromMilliseconds(5000); |
| 1575 clock_.AdvanceTime(retransmission_time); | 1576 clock_.AdvanceTime(retransmission_time); |
| 1576 | 1577 |
| 1577 // Abandon FEC packet and data packet. | 1578 // Abandon FEC packet and data packet. |
| 1578 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); | 1579 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); |
| 1579 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); | 1580 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); |
| 1580 EXPECT_CALL(visitor_, OnCanWrite()); | 1581 EXPECT_CALL(visitor_, OnCanWrite()); |
| 1581 connection_.OnRetransmissionTimeout(); | 1582 connection_.OnRetransmissionTimeout(); |
| 1582 } | 1583 } |
| 1583 | 1584 |
| 1584 TEST_P(QuicConnectionTest, DontAbandonAckedFEC) { | 1585 TEST_P(QuicConnectionTest, DontAbandonAckedFEC) { |
| 1585 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1586 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 1586 EXPECT_TRUE(QuicConnectionPeer::GetPacketCreator( | 1587 EXPECT_TRUE(QuicConnectionPeer::GetPacketCreator( |
| 1587 &connection_)->IsFecEnabled()); | 1588 &connection_)->IsFecEnabled()); |
| 1588 | 1589 |
| 1589 // 1 Data and 1 FEC packet. | 1590 // 1 Data and 1 FEC packet. |
| 1590 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(6); | 1591 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(6); |
| 1591 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, NULL); | 1592 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, nullptr); |
| 1592 // Send some more data afterwards to ensure early retransmit doesn't trigger. | 1593 // Send some more data afterwards to ensure early retransmit doesn't trigger. |
| 1593 connection_.SendStreamDataWithStringWithFec(3, "foo", 3, !kFin, NULL); | 1594 connection_.SendStreamDataWithStringWithFec(3, "foo", 3, !kFin, nullptr); |
| 1594 connection_.SendStreamDataWithStringWithFec(3, "foo", 6, !kFin, NULL); | 1595 connection_.SendStreamDataWithStringWithFec(3, "foo", 6, !kFin, nullptr); |
| 1595 | 1596 |
| 1596 QuicAckFrame ack_fec = InitAckFrame(2); | 1597 QuicAckFrame ack_fec = InitAckFrame(2); |
| 1597 // Data packet missing. | 1598 // Data packet missing. |
| 1598 // TODO(ianswett): Note that this is not a sensible ack, since if the FEC was | 1599 // TODO(ianswett): Note that this is not a sensible ack, since if the FEC was |
| 1599 // received, it would cause the covered packet to be acked as well. | 1600 // received, it would cause the covered packet to be acked as well. |
| 1600 NackPacket(1, &ack_fec); | 1601 NackPacket(1, &ack_fec); |
| 1601 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 1602 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 1602 ProcessAckPacket(&ack_fec); | 1603 ProcessAckPacket(&ack_fec); |
| 1603 clock_.AdvanceTime(DefaultRetransmissionTime()); | 1604 clock_.AdvanceTime(DefaultRetransmissionTime()); |
| 1604 | 1605 |
| 1605 // Don't abandon the acked FEC packet, but it will abandon 2 the subsequent | 1606 // Don't abandon the acked FEC packet, but it will abandon 2 the subsequent |
| 1606 // FEC packets. | 1607 // FEC packets. |
| 1607 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); | 1608 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); |
| 1608 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(3); | 1609 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(3); |
| 1609 connection_.GetRetransmissionAlarm()->Fire(); | 1610 connection_.GetRetransmissionAlarm()->Fire(); |
| 1610 } | 1611 } |
| 1611 | 1612 |
| 1612 TEST_P(QuicConnectionTest, AbandonAllFEC) { | 1613 TEST_P(QuicConnectionTest, AbandonAllFEC) { |
| 1613 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1614 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 1614 EXPECT_TRUE(QuicConnectionPeer::GetPacketCreator( | 1615 EXPECT_TRUE(QuicConnectionPeer::GetPacketCreator( |
| 1615 &connection_)->IsFecEnabled()); | 1616 &connection_)->IsFecEnabled()); |
| 1616 | 1617 |
| 1617 // 1 Data and 1 FEC packet. | 1618 // 1 Data and 1 FEC packet. |
| 1618 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(6); | 1619 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(6); |
| 1619 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, NULL); | 1620 connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, nullptr); |
| 1620 // Send some more data afterwards to ensure early retransmit doesn't trigger. | 1621 // Send some more data afterwards to ensure early retransmit doesn't trigger. |
| 1621 connection_.SendStreamDataWithStringWithFec(3, "foo", 3, !kFin, NULL); | 1622 connection_.SendStreamDataWithStringWithFec(3, "foo", 3, !kFin, nullptr); |
| 1622 // Advance the time so not all the FEC packets are abandoned. | 1623 // Advance the time so not all the FEC packets are abandoned. |
| 1623 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); | 1624 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); |
| 1624 connection_.SendStreamDataWithStringWithFec(3, "foo", 6, !kFin, NULL); | 1625 connection_.SendStreamDataWithStringWithFec(3, "foo", 6, !kFin, nullptr); |
| 1625 | 1626 |
| 1626 QuicAckFrame ack_fec = InitAckFrame(5); | 1627 QuicAckFrame ack_fec = InitAckFrame(5); |
| 1627 // Ack all data packets, but no fec packets. | 1628 // Ack all data packets, but no fec packets. |
| 1628 NackPacket(2, &ack_fec); | 1629 NackPacket(2, &ack_fec); |
| 1629 NackPacket(4, &ack_fec); | 1630 NackPacket(4, &ack_fec); |
| 1630 | 1631 |
| 1631 // Lose the first FEC packet and ack the three data packets. | 1632 // Lose the first FEC packet and ack the three data packets. |
| 1632 SequenceNumberSet lost_packets; | 1633 SequenceNumberSet lost_packets; |
| 1633 lost_packets.insert(2); | 1634 lost_packets.insert(2); |
| 1634 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | 1635 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1782 | 1783 |
| 1783 TEST_P(QuicConnectionTest, FramePackingSendv) { | 1784 TEST_P(QuicConnectionTest, FramePackingSendv) { |
| 1784 // Send data in 1 packet by writing multiple blocks in a single iovector | 1785 // Send data in 1 packet by writing multiple blocks in a single iovector |
| 1785 // using writev. | 1786 // using writev. |
| 1786 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 1787 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
| 1787 | 1788 |
| 1788 char data[] = "ABCD"; | 1789 char data[] = "ABCD"; |
| 1789 IOVector data_iov; | 1790 IOVector data_iov; |
| 1790 data_iov.AppendNoCoalesce(data, 2); | 1791 data_iov.AppendNoCoalesce(data, 2); |
| 1791 data_iov.AppendNoCoalesce(data + 2, 2); | 1792 data_iov.AppendNoCoalesce(data + 2, 2); |
| 1792 connection_.SendStreamData(1, data_iov, 0, !kFin, MAY_FEC_PROTECT, NULL); | 1793 connection_.SendStreamData(1, data_iov, 0, !kFin, MAY_FEC_PROTECT, nullptr); |
| 1793 | 1794 |
| 1794 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 1795 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
| 1795 EXPECT_FALSE(connection_.HasQueuedData()); | 1796 EXPECT_FALSE(connection_.HasQueuedData()); |
| 1796 | 1797 |
| 1797 // Parse the last packet and ensure multiple iovector blocks have | 1798 // Parse the last packet and ensure multiple iovector blocks have |
| 1798 // been packed into a single stream frame from one stream. | 1799 // been packed into a single stream frame from one stream. |
| 1799 EXPECT_EQ(1u, writer_->frame_count()); | 1800 EXPECT_EQ(1u, writer_->frame_count()); |
| 1800 EXPECT_EQ(1u, writer_->stream_frames().size()); | 1801 EXPECT_EQ(1u, writer_->stream_frames().size()); |
| 1801 QuicStreamFrame frame = writer_->stream_frames()[0]; | 1802 QuicStreamFrame frame = writer_->stream_frames()[0]; |
| 1802 EXPECT_EQ(1u, frame.stream_id); | 1803 EXPECT_EQ(1u, frame.stream_id); |
| 1803 EXPECT_EQ("ABCD", string(static_cast<char*> | 1804 EXPECT_EQ("ABCD", string(static_cast<char*> |
| 1804 (frame.data.iovec()[0].iov_base), | 1805 (frame.data.iovec()[0].iov_base), |
| 1805 (frame.data.iovec()[0].iov_len))); | 1806 (frame.data.iovec()[0].iov_len))); |
| 1806 } | 1807 } |
| 1807 | 1808 |
| 1808 TEST_P(QuicConnectionTest, FramePackingSendvQueued) { | 1809 TEST_P(QuicConnectionTest, FramePackingSendvQueued) { |
| 1809 // Try to send two stream frames in 1 packet by using writev. | 1810 // Try to send two stream frames in 1 packet by using writev. |
| 1810 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 1811 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
| 1811 | 1812 |
| 1812 BlockOnNextWrite(); | 1813 BlockOnNextWrite(); |
| 1813 char data[] = "ABCD"; | 1814 char data[] = "ABCD"; |
| 1814 IOVector data_iov; | 1815 IOVector data_iov; |
| 1815 data_iov.AppendNoCoalesce(data, 2); | 1816 data_iov.AppendNoCoalesce(data, 2); |
| 1816 data_iov.AppendNoCoalesce(data + 2, 2); | 1817 data_iov.AppendNoCoalesce(data + 2, 2); |
| 1817 connection_.SendStreamData(1, data_iov, 0, !kFin, MAY_FEC_PROTECT, NULL); | 1818 connection_.SendStreamData(1, data_iov, 0, !kFin, MAY_FEC_PROTECT, nullptr); |
| 1818 | 1819 |
| 1819 EXPECT_EQ(1u, connection_.NumQueuedPackets()); | 1820 EXPECT_EQ(1u, connection_.NumQueuedPackets()); |
| 1820 EXPECT_TRUE(connection_.HasQueuedData()); | 1821 EXPECT_TRUE(connection_.HasQueuedData()); |
| 1821 | 1822 |
| 1822 // Unblock the writes and actually send. | 1823 // Unblock the writes and actually send. |
| 1823 writer_->SetWritable(); | 1824 writer_->SetWritable(); |
| 1824 connection_.OnCanWrite(); | 1825 connection_.OnCanWrite(); |
| 1825 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 1826 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
| 1826 | 1827 |
| 1827 // Parse the last packet and ensure it's one stream frame from one stream. | 1828 // Parse the last packet and ensure it's one stream frame from one stream. |
| 1828 EXPECT_EQ(1u, writer_->frame_count()); | 1829 EXPECT_EQ(1u, writer_->frame_count()); |
| 1829 EXPECT_EQ(1u, writer_->stream_frames().size()); | 1830 EXPECT_EQ(1u, writer_->stream_frames().size()); |
| 1830 EXPECT_EQ(1u, writer_->stream_frames()[0].stream_id); | 1831 EXPECT_EQ(1u, writer_->stream_frames()[0].stream_id); |
| 1831 } | 1832 } |
| 1832 | 1833 |
| 1833 TEST_P(QuicConnectionTest, SendingZeroBytes) { | 1834 TEST_P(QuicConnectionTest, SendingZeroBytes) { |
| 1834 // Send a zero byte write with a fin using writev. | 1835 // Send a zero byte write with a fin using writev. |
| 1835 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 1836 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
| 1836 IOVector empty_iov; | 1837 IOVector empty_iov; |
| 1837 connection_.SendStreamData(1, empty_iov, 0, kFin, MAY_FEC_PROTECT, NULL); | 1838 connection_.SendStreamData(1, empty_iov, 0, kFin, MAY_FEC_PROTECT, nullptr); |
| 1838 | 1839 |
| 1839 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 1840 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
| 1840 EXPECT_FALSE(connection_.HasQueuedData()); | 1841 EXPECT_FALSE(connection_.HasQueuedData()); |
| 1841 | 1842 |
| 1842 // Parse the last packet and ensure it's one stream frame from one stream. | 1843 // Parse the last packet and ensure it's one stream frame from one stream. |
| 1843 EXPECT_EQ(1u, writer_->frame_count()); | 1844 EXPECT_EQ(1u, writer_->frame_count()); |
| 1844 EXPECT_EQ(1u, writer_->stream_frames().size()); | 1845 EXPECT_EQ(1u, writer_->stream_frames().size()); |
| 1845 EXPECT_EQ(1u, writer_->stream_frames()[0].stream_id); | 1846 EXPECT_EQ(1u, writer_->stream_frames()[0].stream_id); |
| 1846 EXPECT_TRUE(writer_->stream_frames()[0].fin); | 1847 EXPECT_TRUE(writer_->stream_frames()[0].fin); |
| 1847 } | 1848 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1937 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 1938 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
| 1938 } | 1939 } |
| 1939 | 1940 |
| 1940 TEST_P(QuicConnectionTest, RetransmitNackedLargestObserved) { | 1941 TEST_P(QuicConnectionTest, RetransmitNackedLargestObserved) { |
| 1941 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1942 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 1942 QuicPacketSequenceNumber largest_observed; | 1943 QuicPacketSequenceNumber largest_observed; |
| 1943 QuicByteCount packet_size; | 1944 QuicByteCount packet_size; |
| 1944 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 1945 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
| 1945 .WillOnce(DoAll(SaveArg<2>(&largest_observed), SaveArg<3>(&packet_size), | 1946 .WillOnce(DoAll(SaveArg<2>(&largest_observed), SaveArg<3>(&packet_size), |
| 1946 Return(true))); | 1947 Return(true))); |
| 1947 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); | 1948 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); |
| 1948 | 1949 |
| 1949 QuicAckFrame frame = InitAckFrame(1); | 1950 QuicAckFrame frame = InitAckFrame(1); |
| 1950 NackPacket(largest_observed, &frame); | 1951 NackPacket(largest_observed, &frame); |
| 1951 // The first nack should retransmit the largest observed packet. | 1952 // The first nack should retransmit the largest observed packet. |
| 1952 SequenceNumberSet lost_packets; | 1953 SequenceNumberSet lost_packets; |
| 1953 lost_packets.insert(1); | 1954 lost_packets.insert(1); |
| 1954 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | 1955 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
| 1955 .WillOnce(Return(lost_packets)); | 1956 .WillOnce(Return(lost_packets)); |
| 1956 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 1957 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 1957 EXPECT_CALL(*send_algorithm_, | 1958 EXPECT_CALL(*send_algorithm_, |
| 1958 OnPacketSent(_, _, _, packet_size - kQuicVersionSize, _)); | 1959 OnPacketSent(_, _, _, packet_size - kQuicVersionSize, _)); |
| 1959 ProcessAckPacket(&frame); | 1960 ProcessAckPacket(&frame); |
| 1960 } | 1961 } |
| 1961 | 1962 |
| 1962 TEST_P(QuicConnectionTest, QueueAfterTwoRTOs) { | 1963 TEST_P(QuicConnectionTest, QueueAfterTwoRTOs) { |
| 1963 for (int i = 0; i < 10; ++i) { | 1964 for (int i = 0; i < 10; ++i) { |
| 1964 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); | 1965 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); |
| 1965 connection_.SendStreamDataWithString(3, "foo", i * 3, !kFin, NULL); | 1966 connection_.SendStreamDataWithString(3, "foo", i * 3, !kFin, nullptr); |
| 1966 } | 1967 } |
| 1967 | 1968 |
| 1968 // Block the congestion window and ensure they're queued. | 1969 // Block the congestion window and ensure they're queued. |
| 1969 BlockOnNextWrite(); | 1970 BlockOnNextWrite(); |
| 1970 clock_.AdvanceTime(DefaultRetransmissionTime()); | 1971 clock_.AdvanceTime(DefaultRetransmissionTime()); |
| 1971 // Only one packet should be retransmitted. | 1972 // Only one packet should be retransmitted. |
| 1972 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); | 1973 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); |
| 1973 connection_.GetRetransmissionAlarm()->Fire(); | 1974 connection_.GetRetransmissionAlarm()->Fire(); |
| 1974 EXPECT_TRUE(connection_.HasQueuedData()); | 1975 EXPECT_TRUE(connection_.HasQueuedData()); |
| 1975 | 1976 |
| 1976 // Unblock the congestion window. | 1977 // Unblock the congestion window. |
| 1977 writer_->SetWritable(); | 1978 writer_->SetWritable(); |
| 1978 clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds( | 1979 clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds( |
| 1979 2 * DefaultRetransmissionTime().ToMicroseconds())); | 1980 2 * DefaultRetransmissionTime().ToMicroseconds())); |
| 1980 // Retransmit already retransmitted packets event though the sequence number | 1981 // Retransmit already retransmitted packets event though the sequence number |
| 1981 // greater than the largest observed. | 1982 // greater than the largest observed. |
| 1982 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(10); | 1983 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(10); |
| 1983 connection_.GetRetransmissionAlarm()->Fire(); | 1984 connection_.GetRetransmissionAlarm()->Fire(); |
| 1984 connection_.OnCanWrite(); | 1985 connection_.OnCanWrite(); |
| 1985 } | 1986 } |
| 1986 | 1987 |
| 1987 TEST_P(QuicConnectionTest, WriteBlockedThenSent) { | 1988 TEST_P(QuicConnectionTest, WriteBlockedThenSent) { |
| 1988 BlockOnNextWrite(); | 1989 BlockOnNextWrite(); |
| 1989 writer_->set_is_write_blocked_data_buffered(true); | 1990 writer_->set_is_write_blocked_data_buffered(true); |
| 1990 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); | 1991 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); |
| 1991 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); | 1992 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, nullptr); |
| 1992 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); | 1993 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); |
| 1993 | 1994 |
| 1994 writer_->SetWritable(); | 1995 writer_->SetWritable(); |
| 1995 connection_.OnCanWrite(); | 1996 connection_.OnCanWrite(); |
| 1996 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); | 1997 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); |
| 1997 } | 1998 } |
| 1998 | 1999 |
| 1999 TEST_P(QuicConnectionTest, RetransmitWriteBlockedAckedOriginalThenSent) { | 2000 TEST_P(QuicConnectionTest, RetransmitWriteBlockedAckedOriginalThenSent) { |
| 2000 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2001 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2001 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); | 2002 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); |
| 2002 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); | 2003 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); |
| 2003 | 2004 |
| 2004 BlockOnNextWrite(); | 2005 BlockOnNextWrite(); |
| 2005 writer_->set_is_write_blocked_data_buffered(true); | 2006 writer_->set_is_write_blocked_data_buffered(true); |
| 2006 // Simulate the retransmission alarm firing. | 2007 // Simulate the retransmission alarm firing. |
| 2007 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(_)); | 2008 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(_)); |
| 2008 clock_.AdvanceTime(DefaultRetransmissionTime()); | 2009 clock_.AdvanceTime(DefaultRetransmissionTime()); |
| 2009 connection_.GetRetransmissionAlarm()->Fire(); | 2010 connection_.GetRetransmissionAlarm()->Fire(); |
| 2010 | 2011 |
| 2011 // Ack the sent packet before the callback returns, which happens in | 2012 // Ack the sent packet before the callback returns, which happens in |
| 2012 // rare circumstances with write blocked sockets. | 2013 // rare circumstances with write blocked sockets. |
| 2013 QuicAckFrame ack = InitAckFrame(1); | 2014 QuicAckFrame ack = InitAckFrame(1); |
| 2014 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 2015 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 2015 EXPECT_CALL(*send_algorithm_, RevertRetransmissionTimeout()); | 2016 EXPECT_CALL(*send_algorithm_, RevertRetransmissionTimeout()); |
| 2016 ProcessAckPacket(&ack); | 2017 ProcessAckPacket(&ack); |
| 2017 | 2018 |
| 2018 writer_->SetWritable(); | 2019 writer_->SetWritable(); |
| 2019 connection_.OnCanWrite(); | 2020 connection_.OnCanWrite(); |
| 2020 // There is now a pending packet, but with no retransmittable frames. | 2021 // There is now a pending packet, but with no retransmittable frames. |
| 2021 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); | 2022 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); |
| 2022 EXPECT_FALSE(connection_.sent_packet_manager().HasRetransmittableFrames(2)); | 2023 EXPECT_FALSE(connection_.sent_packet_manager().HasRetransmittableFrames(2)); |
| 2023 } | 2024 } |
| 2024 | 2025 |
| 2025 TEST_P(QuicConnectionTest, AlarmsWhenWriteBlocked) { | 2026 TEST_P(QuicConnectionTest, AlarmsWhenWriteBlocked) { |
| 2026 // Block the connection. | 2027 // Block the connection. |
| 2027 BlockOnNextWrite(); | 2028 BlockOnNextWrite(); |
| 2028 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); | 2029 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); |
| 2029 EXPECT_EQ(1u, writer_->packets_write_attempts()); | 2030 EXPECT_EQ(1u, writer_->packets_write_attempts()); |
| 2030 EXPECT_TRUE(writer_->IsWriteBlocked()); | 2031 EXPECT_TRUE(writer_->IsWriteBlocked()); |
| 2031 | 2032 |
| 2032 // Set the send and resumption alarms. Fire the alarms and ensure they don't | 2033 // Set the send and resumption alarms. Fire the alarms and ensure they don't |
| 2033 // attempt to write. | 2034 // attempt to write. |
| 2034 connection_.GetResumeWritesAlarm()->Set(clock_.ApproximateNow()); | 2035 connection_.GetResumeWritesAlarm()->Set(clock_.ApproximateNow()); |
| 2035 connection_.GetSendAlarm()->Set(clock_.ApproximateNow()); | 2036 connection_.GetSendAlarm()->Set(clock_.ApproximateNow()); |
| 2036 connection_.GetResumeWritesAlarm()->Fire(); | 2037 connection_.GetResumeWritesAlarm()->Fire(); |
| 2037 connection_.GetSendAlarm()->Fire(); | 2038 connection_.GetSendAlarm()->Fire(); |
| 2038 EXPECT_TRUE(writer_->IsWriteBlocked()); | 2039 EXPECT_TRUE(writer_->IsWriteBlocked()); |
| 2039 EXPECT_EQ(1u, writer_->packets_write_attempts()); | 2040 EXPECT_EQ(1u, writer_->packets_write_attempts()); |
| 2040 } | 2041 } |
| 2041 | 2042 |
| 2042 TEST_P(QuicConnectionTest, NoLimitPacketsPerNack) { | 2043 TEST_P(QuicConnectionTest, NoLimitPacketsPerNack) { |
| 2043 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2044 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2044 int offset = 0; | 2045 int offset = 0; |
| 2045 // Send packets 1 to 15. | 2046 // Send packets 1 to 15. |
| 2046 for (int i = 0; i < 15; ++i) { | 2047 for (int i = 0; i < 15; ++i) { |
| 2047 SendStreamDataToPeer(1, "foo", offset, !kFin, NULL); | 2048 SendStreamDataToPeer(1, "foo", offset, !kFin, nullptr); |
| 2048 offset += 3; | 2049 offset += 3; |
| 2049 } | 2050 } |
| 2050 | 2051 |
| 2051 // Ack 15, nack 1-14. | 2052 // Ack 15, nack 1-14. |
| 2052 SequenceNumberSet lost_packets; | 2053 SequenceNumberSet lost_packets; |
| 2053 QuicAckFrame nack = InitAckFrame(15); | 2054 QuicAckFrame nack = InitAckFrame(15); |
| 2054 for (int i = 1; i < 15; ++i) { | 2055 for (int i = 1; i < 15; ++i) { |
| 2055 NackPacket(i, &nack); | 2056 NackPacket(i, &nack); |
| 2056 lost_packets.insert(i); | 2057 lost_packets.insert(i); |
| 2057 } | 2058 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2087 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2088 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2088 ProcessAckPacket(&frame1); | 2089 ProcessAckPacket(&frame1); |
| 2089 | 2090 |
| 2090 // Now the client implicitly acks 3, and explicitly acks 6. | 2091 // Now the client implicitly acks 3, and explicitly acks 6. |
| 2091 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 2092 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 2092 QuicAckFrame frame2 = InitAckFrame(6); | 2093 QuicAckFrame frame2 = InitAckFrame(6); |
| 2093 ProcessAckPacket(&frame2); | 2094 ProcessAckPacket(&frame2); |
| 2094 } | 2095 } |
| 2095 | 2096 |
| 2096 TEST_P(QuicConnectionTest, DontLatchUnackedPacket) { | 2097 TEST_P(QuicConnectionTest, DontLatchUnackedPacket) { |
| 2097 SendStreamDataToPeer(1, "foo", 0, !kFin, NULL); // Packet 1; | 2098 SendStreamDataToPeer(1, "foo", 0, !kFin, nullptr); // Packet 1; |
| 2098 // From now on, we send acks, so the send algorithm won't mark them pending. | 2099 // From now on, we send acks, so the send algorithm won't mark them pending. |
| 2099 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 2100 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
| 2100 .WillByDefault(Return(false)); | 2101 .WillByDefault(Return(false)); |
| 2101 SendAckPacketToPeer(); // Packet 2 | 2102 SendAckPacketToPeer(); // Packet 2 |
| 2102 | 2103 |
| 2103 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2104 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2104 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 2105 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 2105 QuicAckFrame frame = InitAckFrame(1); | 2106 QuicAckFrame frame = InitAckFrame(1); |
| 2106 ProcessAckPacket(&frame); | 2107 ProcessAckPacket(&frame); |
| 2107 | 2108 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2124 // Check that the outgoing ack had its sequence number as least_unacked. | 2125 // Check that the outgoing ack had its sequence number as least_unacked. |
| 2125 EXPECT_EQ(3u, least_unacked()); | 2126 EXPECT_EQ(3u, least_unacked()); |
| 2126 | 2127 |
| 2127 // Ack the ack, which updates the rtt and raises the least unacked. | 2128 // Ack the ack, which updates the rtt and raises the least unacked. |
| 2128 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 2129 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 2129 frame = InitAckFrame(3); | 2130 frame = InitAckFrame(3); |
| 2130 ProcessAckPacket(&frame); | 2131 ProcessAckPacket(&frame); |
| 2131 | 2132 |
| 2132 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 2133 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
| 2133 .WillByDefault(Return(true)); | 2134 .WillByDefault(Return(true)); |
| 2134 SendStreamDataToPeer(1, "bar", 3, false, NULL); // Packet 4 | 2135 SendStreamDataToPeer(1, "bar", 3, false, nullptr); // Packet 4 |
| 2135 EXPECT_EQ(4u, stop_waiting()->least_unacked); | 2136 EXPECT_EQ(4u, stop_waiting()->least_unacked); |
| 2136 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 2137 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
| 2137 .WillByDefault(Return(false)); | 2138 .WillByDefault(Return(false)); |
| 2138 SendAckPacketToPeer(); // Packet 5 | 2139 SendAckPacketToPeer(); // Packet 5 |
| 2139 EXPECT_EQ(4u, least_unacked()); | 2140 EXPECT_EQ(4u, least_unacked()); |
| 2140 | 2141 |
| 2141 // Send two data packets at the end, and ensure if the last one is acked, | 2142 // Send two data packets at the end, and ensure if the last one is acked, |
| 2142 // the least unacked is raised above the ack packets. | 2143 // the least unacked is raised above the ack packets. |
| 2143 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 2144 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
| 2144 .WillByDefault(Return(true)); | 2145 .WillByDefault(Return(true)); |
| 2145 SendStreamDataToPeer(1, "bar", 6, false, NULL); // Packet 6 | 2146 SendStreamDataToPeer(1, "bar", 6, false, nullptr); // Packet 6 |
| 2146 SendStreamDataToPeer(1, "bar", 9, false, NULL); // Packet 7 | 2147 SendStreamDataToPeer(1, "bar", 9, false, nullptr); // Packet 7 |
| 2147 | 2148 |
| 2148 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 2149 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 2149 frame = InitAckFrame(7); | 2150 frame = InitAckFrame(7); |
| 2150 NackPacket(5, &frame); | 2151 NackPacket(5, &frame); |
| 2151 NackPacket(6, &frame); | 2152 NackPacket(6, &frame); |
| 2152 ProcessAckPacket(&frame); | 2153 ProcessAckPacket(&frame); |
| 2153 | 2154 |
| 2154 EXPECT_EQ(6u, stop_waiting()->least_unacked); | 2155 EXPECT_EQ(6u, stop_waiting()->least_unacked); |
| 2155 } | 2156 } |
| 2156 | 2157 |
| 2157 TEST_P(QuicConnectionTest, ReviveMissingPacketAfterFecPacket) { | 2158 TEST_P(QuicConnectionTest, ReviveMissingPacketAfterFecPacket) { |
| 2158 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2159 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2159 | 2160 |
| 2160 // Don't send missing packet 1. | 2161 // Don't send missing packet 1. |
| 2161 ProcessFecPacket(2, 1, true, !kEntropyFlag, NULL); | 2162 ProcessFecPacket(2, 1, true, !kEntropyFlag, nullptr); |
| 2162 // Entropy flag should be false, so entropy should be 0. | 2163 // Entropy flag should be false, so entropy should be 0. |
| 2163 EXPECT_EQ(0u, QuicConnectionPeer::ReceivedEntropyHash(&connection_, 2)); | 2164 EXPECT_EQ(0u, QuicConnectionPeer::ReceivedEntropyHash(&connection_, 2)); |
| 2164 } | 2165 } |
| 2165 | 2166 |
| 2166 TEST_P(QuicConnectionTest, ReviveMissingPacketWithVaryingSeqNumLengths) { | 2167 TEST_P(QuicConnectionTest, ReviveMissingPacketWithVaryingSeqNumLengths) { |
| 2167 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2168 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2168 | 2169 |
| 2169 // Set up a debug visitor to the connection. | 2170 // Set up a debug visitor to the connection. |
| 2170 FecQuicConnectionDebugVisitor* fec_visitor = | 2171 FecQuicConnectionDebugVisitor* fec_visitor = |
| 2171 new FecQuicConnectionDebugVisitor(); | 2172 new FecQuicConnectionDebugVisitor(); |
| 2172 connection_.set_debug_visitor(fec_visitor); | 2173 connection_.set_debug_visitor(fec_visitor); |
| 2173 | 2174 |
| 2174 QuicPacketSequenceNumber fec_packet = 0; | 2175 QuicPacketSequenceNumber fec_packet = 0; |
| 2175 QuicSequenceNumberLength lengths[] = {PACKET_6BYTE_SEQUENCE_NUMBER, | 2176 QuicSequenceNumberLength lengths[] = {PACKET_6BYTE_SEQUENCE_NUMBER, |
| 2176 PACKET_4BYTE_SEQUENCE_NUMBER, | 2177 PACKET_4BYTE_SEQUENCE_NUMBER, |
| 2177 PACKET_2BYTE_SEQUENCE_NUMBER, | 2178 PACKET_2BYTE_SEQUENCE_NUMBER, |
| 2178 PACKET_1BYTE_SEQUENCE_NUMBER}; | 2179 PACKET_1BYTE_SEQUENCE_NUMBER}; |
| 2179 // For each sequence number length size, revive a packet and check sequence | 2180 // For each sequence number length size, revive a packet and check sequence |
| 2180 // number length in the revived packet. | 2181 // number length in the revived packet. |
| 2181 for (size_t i = 0; i < arraysize(lengths); ++i) { | 2182 for (size_t i = 0; i < arraysize(lengths); ++i) { |
| 2182 // Set sequence_number_length_ (for data and FEC packets). | 2183 // Set sequence_number_length_ (for data and FEC packets). |
| 2183 sequence_number_length_ = lengths[i]; | 2184 sequence_number_length_ = lengths[i]; |
| 2184 fec_packet += 2; | 2185 fec_packet += 2; |
| 2185 // Don't send missing packet, but send fec packet right after it. | 2186 // Don't send missing packet, but send fec packet right after it. |
| 2186 ProcessFecPacket(fec_packet, fec_packet - 1, true, !kEntropyFlag, NULL); | 2187 ProcessFecPacket(fec_packet, fec_packet - 1, true, !kEntropyFlag, nullptr); |
| 2187 // Sequence number length in the revived header should be the same as | 2188 // Sequence number length in the revived header should be the same as |
| 2188 // in the original data/fec packet headers. | 2189 // in the original data/fec packet headers. |
| 2189 EXPECT_EQ(sequence_number_length_, fec_visitor->revived_header(). | 2190 EXPECT_EQ(sequence_number_length_, fec_visitor->revived_header(). |
| 2190 public_header.sequence_number_length); | 2191 public_header.sequence_number_length); |
| 2191 } | 2192 } |
| 2192 } | 2193 } |
| 2193 | 2194 |
| 2194 TEST_P(QuicConnectionTest, ReviveMissingPacketWithVaryingConnectionIdLengths) { | 2195 TEST_P(QuicConnectionTest, ReviveMissingPacketWithVaryingConnectionIdLengths) { |
| 2195 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2196 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2196 | 2197 |
| 2197 // Set up a debug visitor to the connection. | 2198 // Set up a debug visitor to the connection. |
| 2198 FecQuicConnectionDebugVisitor* fec_visitor = | 2199 FecQuicConnectionDebugVisitor* fec_visitor = |
| 2199 new FecQuicConnectionDebugVisitor(); | 2200 new FecQuicConnectionDebugVisitor(); |
| 2200 connection_.set_debug_visitor(fec_visitor); | 2201 connection_.set_debug_visitor(fec_visitor); |
| 2201 | 2202 |
| 2202 QuicPacketSequenceNumber fec_packet = 0; | 2203 QuicPacketSequenceNumber fec_packet = 0; |
| 2203 QuicConnectionIdLength lengths[] = {PACKET_8BYTE_CONNECTION_ID, | 2204 QuicConnectionIdLength lengths[] = {PACKET_8BYTE_CONNECTION_ID, |
| 2204 PACKET_4BYTE_CONNECTION_ID, | 2205 PACKET_4BYTE_CONNECTION_ID, |
| 2205 PACKET_1BYTE_CONNECTION_ID, | 2206 PACKET_1BYTE_CONNECTION_ID, |
| 2206 PACKET_0BYTE_CONNECTION_ID}; | 2207 PACKET_0BYTE_CONNECTION_ID}; |
| 2207 // For each connection id length size, revive a packet and check connection | 2208 // For each connection id length size, revive a packet and check connection |
| 2208 // id length in the revived packet. | 2209 // id length in the revived packet. |
| 2209 for (size_t i = 0; i < arraysize(lengths); ++i) { | 2210 for (size_t i = 0; i < arraysize(lengths); ++i) { |
| 2210 // Set connection id length (for data and FEC packets). | 2211 // Set connection id length (for data and FEC packets). |
| 2211 connection_id_length_ = lengths[i]; | 2212 connection_id_length_ = lengths[i]; |
| 2212 fec_packet += 2; | 2213 fec_packet += 2; |
| 2213 // Don't send missing packet, but send fec packet right after it. | 2214 // Don't send missing packet, but send fec packet right after it. |
| 2214 ProcessFecPacket(fec_packet, fec_packet - 1, true, !kEntropyFlag, NULL); | 2215 ProcessFecPacket(fec_packet, fec_packet - 1, true, !kEntropyFlag, nullptr); |
| 2215 // Connection id length in the revived header should be the same as | 2216 // Connection id length in the revived header should be the same as |
| 2216 // in the original data/fec packet headers. | 2217 // in the original data/fec packet headers. |
| 2217 EXPECT_EQ(connection_id_length_, | 2218 EXPECT_EQ(connection_id_length_, |
| 2218 fec_visitor->revived_header().public_header.connection_id_length); | 2219 fec_visitor->revived_header().public_header.connection_id_length); |
| 2219 } | 2220 } |
| 2220 } | 2221 } |
| 2221 | 2222 |
| 2222 TEST_P(QuicConnectionTest, ReviveMissingPacketAfterDataPacketThenFecPacket) { | 2223 TEST_P(QuicConnectionTest, ReviveMissingPacketAfterDataPacketThenFecPacket) { |
| 2223 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2224 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2224 | 2225 |
| 2225 ProcessFecProtectedPacket(1, false, kEntropyFlag); | 2226 ProcessFecProtectedPacket(1, false, kEntropyFlag); |
| 2226 // Don't send missing packet 2. | 2227 // Don't send missing packet 2. |
| 2227 ProcessFecPacket(3, 1, true, !kEntropyFlag, NULL); | 2228 ProcessFecPacket(3, 1, true, !kEntropyFlag, nullptr); |
| 2228 // Entropy flag should be true, so entropy should not be 0. | 2229 // Entropy flag should be true, so entropy should not be 0. |
| 2229 EXPECT_NE(0u, QuicConnectionPeer::ReceivedEntropyHash(&connection_, 2)); | 2230 EXPECT_NE(0u, QuicConnectionPeer::ReceivedEntropyHash(&connection_, 2)); |
| 2230 } | 2231 } |
| 2231 | 2232 |
| 2232 TEST_P(QuicConnectionTest, ReviveMissingPacketAfterDataPacketsThenFecPacket) { | 2233 TEST_P(QuicConnectionTest, ReviveMissingPacketAfterDataPacketsThenFecPacket) { |
| 2233 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2234 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2234 | 2235 |
| 2235 ProcessFecProtectedPacket(1, false, !kEntropyFlag); | 2236 ProcessFecProtectedPacket(1, false, !kEntropyFlag); |
| 2236 // Don't send missing packet 2. | 2237 // Don't send missing packet 2. |
| 2237 ProcessFecProtectedPacket(3, false, !kEntropyFlag); | 2238 ProcessFecProtectedPacket(3, false, !kEntropyFlag); |
| 2238 ProcessFecPacket(4, 1, true, kEntropyFlag, NULL); | 2239 ProcessFecPacket(4, 1, true, kEntropyFlag, nullptr); |
| 2239 // Ensure QUIC no longer revives entropy for lost packets. | 2240 // Ensure QUIC no longer revives entropy for lost packets. |
| 2240 EXPECT_EQ(0u, QuicConnectionPeer::ReceivedEntropyHash(&connection_, 2)); | 2241 EXPECT_EQ(0u, QuicConnectionPeer::ReceivedEntropyHash(&connection_, 2)); |
| 2241 EXPECT_NE(0u, QuicConnectionPeer::ReceivedEntropyHash(&connection_, 4)); | 2242 EXPECT_NE(0u, QuicConnectionPeer::ReceivedEntropyHash(&connection_, 4)); |
| 2242 } | 2243 } |
| 2243 | 2244 |
| 2244 TEST_P(QuicConnectionTest, ReviveMissingPacketAfterDataPacket) { | 2245 TEST_P(QuicConnectionTest, ReviveMissingPacketAfterDataPacket) { |
| 2245 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2246 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2246 | 2247 |
| 2247 // Don't send missing packet 1. | 2248 // Don't send missing packet 1. |
| 2248 ProcessFecPacket(3, 1, false, !kEntropyFlag, NULL); | 2249 ProcessFecPacket(3, 1, false, !kEntropyFlag, nullptr); |
| 2249 // Out of order. | 2250 // Out of order. |
| 2250 ProcessFecProtectedPacket(2, true, !kEntropyFlag); | 2251 ProcessFecProtectedPacket(2, true, !kEntropyFlag); |
| 2251 // Entropy flag should be false, so entropy should be 0. | 2252 // Entropy flag should be false, so entropy should be 0. |
| 2252 EXPECT_EQ(0u, QuicConnectionPeer::ReceivedEntropyHash(&connection_, 2)); | 2253 EXPECT_EQ(0u, QuicConnectionPeer::ReceivedEntropyHash(&connection_, 2)); |
| 2253 } | 2254 } |
| 2254 | 2255 |
| 2255 TEST_P(QuicConnectionTest, ReviveMissingPacketAfterDataPackets) { | 2256 TEST_P(QuicConnectionTest, ReviveMissingPacketAfterDataPackets) { |
| 2256 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2257 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2257 | 2258 |
| 2258 ProcessFecProtectedPacket(1, false, !kEntropyFlag); | 2259 ProcessFecProtectedPacket(1, false, !kEntropyFlag); |
| 2259 // Don't send missing packet 2. | 2260 // Don't send missing packet 2. |
| 2260 ProcessFecPacket(6, 1, false, kEntropyFlag, NULL); | 2261 ProcessFecPacket(6, 1, false, kEntropyFlag, nullptr); |
| 2261 ProcessFecProtectedPacket(3, false, kEntropyFlag); | 2262 ProcessFecProtectedPacket(3, false, kEntropyFlag); |
| 2262 ProcessFecProtectedPacket(4, false, kEntropyFlag); | 2263 ProcessFecProtectedPacket(4, false, kEntropyFlag); |
| 2263 ProcessFecProtectedPacket(5, true, !kEntropyFlag); | 2264 ProcessFecProtectedPacket(5, true, !kEntropyFlag); |
| 2264 // Ensure entropy is not revived for the missing packet. | 2265 // Ensure entropy is not revived for the missing packet. |
| 2265 EXPECT_EQ(0u, QuicConnectionPeer::ReceivedEntropyHash(&connection_, 2)); | 2266 EXPECT_EQ(0u, QuicConnectionPeer::ReceivedEntropyHash(&connection_, 2)); |
| 2266 EXPECT_NE(0u, QuicConnectionPeer::ReceivedEntropyHash(&connection_, 3)); | 2267 EXPECT_NE(0u, QuicConnectionPeer::ReceivedEntropyHash(&connection_, 3)); |
| 2267 } | 2268 } |
| 2268 | 2269 |
| 2269 TEST_P(QuicConnectionTest, TLP) { | 2270 TEST_P(QuicConnectionTest, TLP) { |
| 2270 QuicSentPacketManagerPeer::SetMaxTailLossProbes( | 2271 QuicSentPacketManagerPeer::SetMaxTailLossProbes( |
| 2271 QuicConnectionPeer::GetSentPacketManager(&connection_), 1); | 2272 QuicConnectionPeer::GetSentPacketManager(&connection_), 1); |
| 2272 | 2273 |
| 2273 SendStreamDataToPeer(3, "foo", 0, !kFin, NULL); | 2274 SendStreamDataToPeer(3, "foo", 0, !kFin, nullptr); |
| 2274 EXPECT_EQ(1u, stop_waiting()->least_unacked); | 2275 EXPECT_EQ(1u, stop_waiting()->least_unacked); |
| 2275 QuicTime retransmission_time = | 2276 QuicTime retransmission_time = |
| 2276 connection_.GetRetransmissionAlarm()->deadline(); | 2277 connection_.GetRetransmissionAlarm()->deadline(); |
| 2277 EXPECT_NE(QuicTime::Zero(), retransmission_time); | 2278 EXPECT_NE(QuicTime::Zero(), retransmission_time); |
| 2278 | 2279 |
| 2279 EXPECT_EQ(1u, writer_->header().packet_sequence_number); | 2280 EXPECT_EQ(1u, writer_->header().packet_sequence_number); |
| 2280 // Simulate the retransmission alarm firing and sending a tlp, | 2281 // Simulate the retransmission alarm firing and sending a tlp, |
| 2281 // so send algorithm's OnRetransmissionTimeout is not called. | 2282 // so send algorithm's OnRetransmissionTimeout is not called. |
| 2282 clock_.AdvanceTime(retransmission_time.Subtract(clock_.Now())); | 2283 clock_.AdvanceTime(retransmission_time.Subtract(clock_.Now())); |
| 2283 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 2u, _, _)); | 2284 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 2u, _, _)); |
| 2284 connection_.GetRetransmissionAlarm()->Fire(); | 2285 connection_.GetRetransmissionAlarm()->Fire(); |
| 2285 EXPECT_EQ(2u, writer_->header().packet_sequence_number); | 2286 EXPECT_EQ(2u, writer_->header().packet_sequence_number); |
| 2286 // We do not raise the high water mark yet. | 2287 // We do not raise the high water mark yet. |
| 2287 EXPECT_EQ(1u, stop_waiting()->least_unacked); | 2288 EXPECT_EQ(1u, stop_waiting()->least_unacked); |
| 2288 } | 2289 } |
| 2289 | 2290 |
| 2290 TEST_P(QuicConnectionTest, RTO) { | 2291 TEST_P(QuicConnectionTest, RTO) { |
| 2291 QuicTime default_retransmission_time = clock_.ApproximateNow().Add( | 2292 QuicTime default_retransmission_time = clock_.ApproximateNow().Add( |
| 2292 DefaultRetransmissionTime()); | 2293 DefaultRetransmissionTime()); |
| 2293 SendStreamDataToPeer(3, "foo", 0, !kFin, NULL); | 2294 SendStreamDataToPeer(3, "foo", 0, !kFin, nullptr); |
| 2294 EXPECT_EQ(1u, stop_waiting()->least_unacked); | 2295 EXPECT_EQ(1u, stop_waiting()->least_unacked); |
| 2295 | 2296 |
| 2296 EXPECT_EQ(1u, writer_->header().packet_sequence_number); | 2297 EXPECT_EQ(1u, writer_->header().packet_sequence_number); |
| 2297 EXPECT_EQ(default_retransmission_time, | 2298 EXPECT_EQ(default_retransmission_time, |
| 2298 connection_.GetRetransmissionAlarm()->deadline()); | 2299 connection_.GetRetransmissionAlarm()->deadline()); |
| 2299 // Simulate the retransmission alarm firing. | 2300 // Simulate the retransmission alarm firing. |
| 2300 clock_.AdvanceTime(DefaultRetransmissionTime()); | 2301 clock_.AdvanceTime(DefaultRetransmissionTime()); |
| 2301 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); | 2302 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); |
| 2302 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 2u, _, _)); | 2303 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 2u, _, _)); |
| 2303 connection_.GetRetransmissionAlarm()->Fire(); | 2304 connection_.GetRetransmissionAlarm()->Fire(); |
| 2304 EXPECT_EQ(2u, writer_->header().packet_sequence_number); | 2305 EXPECT_EQ(2u, writer_->header().packet_sequence_number); |
| 2305 // We do not raise the high water mark yet. | 2306 // We do not raise the high water mark yet. |
| 2306 EXPECT_EQ(1u, stop_waiting()->least_unacked); | 2307 EXPECT_EQ(1u, stop_waiting()->least_unacked); |
| 2307 } | 2308 } |
| 2308 | 2309 |
| 2309 TEST_P(QuicConnectionTest, RTOWithSameEncryptionLevel) { | 2310 TEST_P(QuicConnectionTest, RTOWithSameEncryptionLevel) { |
| 2310 QuicTime default_retransmission_time = clock_.ApproximateNow().Add( | 2311 QuicTime default_retransmission_time = clock_.ApproximateNow().Add( |
| 2311 DefaultRetransmissionTime()); | 2312 DefaultRetransmissionTime()); |
| 2312 use_tagging_decrypter(); | 2313 use_tagging_decrypter(); |
| 2313 | 2314 |
| 2314 // A TaggingEncrypter puts kTagSize copies of the given byte (0x01 here) at | 2315 // A TaggingEncrypter puts kTagSize copies of the given byte (0x01 here) at |
| 2315 // the end of the packet. We can test this to check which encrypter was used. | 2316 // the end of the packet. We can test this to check which encrypter was used. |
| 2316 connection_.SetEncrypter(ENCRYPTION_NONE, new TaggingEncrypter(0x01)); | 2317 connection_.SetEncrypter(ENCRYPTION_NONE, new TaggingEncrypter(0x01)); |
| 2317 SendStreamDataToPeer(3, "foo", 0, !kFin, NULL); | 2318 SendStreamDataToPeer(3, "foo", 0, !kFin, nullptr); |
| 2318 EXPECT_EQ(0x01010101u, writer_->final_bytes_of_last_packet()); | 2319 EXPECT_EQ(0x01010101u, writer_->final_bytes_of_last_packet()); |
| 2319 | 2320 |
| 2320 connection_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(0x02)); | 2321 connection_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(0x02)); |
| 2321 connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL); | 2322 connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL); |
| 2322 SendStreamDataToPeer(3, "foo", 0, !kFin, NULL); | 2323 SendStreamDataToPeer(3, "foo", 0, !kFin, nullptr); |
| 2323 EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet()); | 2324 EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet()); |
| 2324 | 2325 |
| 2325 EXPECT_EQ(default_retransmission_time, | 2326 EXPECT_EQ(default_retransmission_time, |
| 2326 connection_.GetRetransmissionAlarm()->deadline()); | 2327 connection_.GetRetransmissionAlarm()->deadline()); |
| 2327 { | 2328 { |
| 2328 InSequence s; | 2329 InSequence s; |
| 2329 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); | 2330 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); |
| 2330 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 3, _, _)); | 2331 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 3, _, _)); |
| 2331 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 4, _, _)); | 2332 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 4, _, _)); |
| 2332 } | 2333 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2346 use_tagging_decrypter(); | 2347 use_tagging_decrypter(); |
| 2347 // A TaggingEncrypter puts kTagSize copies of the given byte (0x01 here) at | 2348 // A TaggingEncrypter puts kTagSize copies of the given byte (0x01 here) at |
| 2348 // the end of the packet. We can test this to check which encrypter was used. | 2349 // the end of the packet. We can test this to check which encrypter was used. |
| 2349 connection_.SetEncrypter(ENCRYPTION_NONE, new TaggingEncrypter(0x01)); | 2350 connection_.SetEncrypter(ENCRYPTION_NONE, new TaggingEncrypter(0x01)); |
| 2350 | 2351 |
| 2351 // Attempt to send a handshake message and have the socket block. | 2352 // Attempt to send a handshake message and have the socket block. |
| 2352 EXPECT_CALL(*send_algorithm_, | 2353 EXPECT_CALL(*send_algorithm_, |
| 2353 TimeUntilSend(_, _, _)).WillRepeatedly( | 2354 TimeUntilSend(_, _, _)).WillRepeatedly( |
| 2354 testing::Return(QuicTime::Delta::Zero())); | 2355 testing::Return(QuicTime::Delta::Zero())); |
| 2355 BlockOnNextWrite(); | 2356 BlockOnNextWrite(); |
| 2356 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); | 2357 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, nullptr); |
| 2357 // The packet should be serialized, but not queued. | 2358 // The packet should be serialized, but not queued. |
| 2358 EXPECT_EQ(1u, connection_.NumQueuedPackets()); | 2359 EXPECT_EQ(1u, connection_.NumQueuedPackets()); |
| 2359 | 2360 |
| 2360 // Switch to the new encrypter. | 2361 // Switch to the new encrypter. |
| 2361 connection_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(0x02)); | 2362 connection_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(0x02)); |
| 2362 connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL); | 2363 connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL); |
| 2363 | 2364 |
| 2364 // Now become writeable and flush the packets. | 2365 // Now become writeable and flush the packets. |
| 2365 writer_->SetWritable(); | 2366 writer_->SetWritable(); |
| 2366 EXPECT_CALL(visitor_, OnCanWrite()); | 2367 EXPECT_CALL(visitor_, OnCanWrite()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2396 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); | 2397 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); |
| 2397 writer_->SetWritable(); | 2398 writer_->SetWritable(); |
| 2398 connection_.OnCanWrite(); | 2399 connection_.OnCanWrite(); |
| 2399 } | 2400 } |
| 2400 | 2401 |
| 2401 TEST_P(QuicConnectionTest, RetransmitPacketsWithInitialEncryption) { | 2402 TEST_P(QuicConnectionTest, RetransmitPacketsWithInitialEncryption) { |
| 2402 use_tagging_decrypter(); | 2403 use_tagging_decrypter(); |
| 2403 connection_.SetEncrypter(ENCRYPTION_NONE, new TaggingEncrypter(0x01)); | 2404 connection_.SetEncrypter(ENCRYPTION_NONE, new TaggingEncrypter(0x01)); |
| 2404 connection_.SetDefaultEncryptionLevel(ENCRYPTION_NONE); | 2405 connection_.SetDefaultEncryptionLevel(ENCRYPTION_NONE); |
| 2405 | 2406 |
| 2406 SendStreamDataToPeer(1, "foo", 0, !kFin, NULL); | 2407 SendStreamDataToPeer(1, "foo", 0, !kFin, nullptr); |
| 2407 | 2408 |
| 2408 connection_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(0x02)); | 2409 connection_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(0x02)); |
| 2409 connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL); | 2410 connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL); |
| 2410 | 2411 |
| 2411 SendStreamDataToPeer(2, "bar", 0, !kFin, NULL); | 2412 SendStreamDataToPeer(2, "bar", 0, !kFin, nullptr); |
| 2412 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); | 2413 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); |
| 2413 | 2414 |
| 2414 connection_.RetransmitUnackedPackets(ALL_INITIAL_RETRANSMISSION); | 2415 connection_.RetransmitUnackedPackets(ALL_INITIAL_RETRANSMISSION); |
| 2415 } | 2416 } |
| 2416 | 2417 |
| 2417 TEST_P(QuicConnectionTest, BufferNonDecryptablePackets) { | 2418 TEST_P(QuicConnectionTest, BufferNonDecryptablePackets) { |
| 2418 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2419 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2419 use_tagging_decrypter(); | 2420 use_tagging_decrypter(); |
| 2420 | 2421 |
| 2421 const uint8 tag = 0x07; | 2422 const uint8 tag = 0x07; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2439 // reprocess the buffered packet. | 2440 // reprocess the buffered packet. |
| 2440 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(1); | 2441 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(1); |
| 2441 ProcessDataPacketAtLevel(3, 0, kEntropyFlag, ENCRYPTION_INITIAL); | 2442 ProcessDataPacketAtLevel(3, 0, kEntropyFlag, ENCRYPTION_INITIAL); |
| 2442 } | 2443 } |
| 2443 | 2444 |
| 2444 TEST_P(QuicConnectionTest, TestRetransmitOrder) { | 2445 TEST_P(QuicConnectionTest, TestRetransmitOrder) { |
| 2445 QuicByteCount first_packet_size; | 2446 QuicByteCount first_packet_size; |
| 2446 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).WillOnce( | 2447 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).WillOnce( |
| 2447 DoAll(SaveArg<3>(&first_packet_size), Return(true))); | 2448 DoAll(SaveArg<3>(&first_packet_size), Return(true))); |
| 2448 | 2449 |
| 2449 connection_.SendStreamDataWithString(3, "first_packet", 0, !kFin, NULL); | 2450 connection_.SendStreamDataWithString(3, "first_packet", 0, !kFin, nullptr); |
| 2450 QuicByteCount second_packet_size; | 2451 QuicByteCount second_packet_size; |
| 2451 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).WillOnce( | 2452 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).WillOnce( |
| 2452 DoAll(SaveArg<3>(&second_packet_size), Return(true))); | 2453 DoAll(SaveArg<3>(&second_packet_size), Return(true))); |
| 2453 connection_.SendStreamDataWithString(3, "second_packet", 12, !kFin, NULL); | 2454 connection_.SendStreamDataWithString(3, "second_packet", 12, !kFin, nullptr); |
| 2454 EXPECT_NE(first_packet_size, second_packet_size); | 2455 EXPECT_NE(first_packet_size, second_packet_size); |
| 2455 // Advance the clock by huge time to make sure packets will be retransmitted. | 2456 // Advance the clock by huge time to make sure packets will be retransmitted. |
| 2456 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10)); | 2457 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10)); |
| 2457 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); | 2458 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); |
| 2458 { | 2459 { |
| 2459 InSequence s; | 2460 InSequence s; |
| 2460 EXPECT_CALL(*send_algorithm_, | 2461 EXPECT_CALL(*send_algorithm_, |
| 2461 OnPacketSent(_, _, _, first_packet_size, _)); | 2462 OnPacketSent(_, _, _, first_packet_size, _)); |
| 2462 EXPECT_CALL(*send_algorithm_, | 2463 EXPECT_CALL(*send_algorithm_, |
| 2463 OnPacketSent(_, _, _, second_packet_size, _)); | 2464 OnPacketSent(_, _, _, second_packet_size, _)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2475 OnPacketSent(_, _, _, second_packet_size, _)); | 2476 OnPacketSent(_, _, _, second_packet_size, _)); |
| 2476 } | 2477 } |
| 2477 connection_.GetRetransmissionAlarm()->Fire(); | 2478 connection_.GetRetransmissionAlarm()->Fire(); |
| 2478 } | 2479 } |
| 2479 | 2480 |
| 2480 TEST_P(QuicConnectionTest, RetransmissionCountCalculation) { | 2481 TEST_P(QuicConnectionTest, RetransmissionCountCalculation) { |
| 2481 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2482 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2482 QuicPacketSequenceNumber original_sequence_number; | 2483 QuicPacketSequenceNumber original_sequence_number; |
| 2483 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 2484 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
| 2484 .WillOnce(DoAll(SaveArg<2>(&original_sequence_number), Return(true))); | 2485 .WillOnce(DoAll(SaveArg<2>(&original_sequence_number), Return(true))); |
| 2485 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); | 2486 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); |
| 2486 | 2487 |
| 2487 EXPECT_TRUE(QuicConnectionPeer::IsSavedForRetransmission( | 2488 EXPECT_TRUE(QuicConnectionPeer::IsSavedForRetransmission( |
| 2488 &connection_, original_sequence_number)); | 2489 &connection_, original_sequence_number)); |
| 2489 EXPECT_FALSE(QuicConnectionPeer::IsRetransmission( | 2490 EXPECT_FALSE(QuicConnectionPeer::IsRetransmission( |
| 2490 &connection_, original_sequence_number)); | 2491 &connection_, original_sequence_number)); |
| 2491 // Force retransmission due to RTO. | 2492 // Force retransmission due to RTO. |
| 2492 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10)); | 2493 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10)); |
| 2493 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); | 2494 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); |
| 2494 QuicPacketSequenceNumber rto_sequence_number; | 2495 QuicPacketSequenceNumber rto_sequence_number; |
| 2495 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 2496 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2524 EXPECT_FALSE(QuicConnectionPeer::IsSavedForRetransmission( | 2525 EXPECT_FALSE(QuicConnectionPeer::IsSavedForRetransmission( |
| 2525 &connection_, rto_sequence_number)); | 2526 &connection_, rto_sequence_number)); |
| 2526 ASSERT_TRUE(QuicConnectionPeer::IsSavedForRetransmission( | 2527 ASSERT_TRUE(QuicConnectionPeer::IsSavedForRetransmission( |
| 2527 &connection_, nack_sequence_number)); | 2528 &connection_, nack_sequence_number)); |
| 2528 EXPECT_TRUE(QuicConnectionPeer::IsRetransmission( | 2529 EXPECT_TRUE(QuicConnectionPeer::IsRetransmission( |
| 2529 &connection_, nack_sequence_number)); | 2530 &connection_, nack_sequence_number)); |
| 2530 } | 2531 } |
| 2531 | 2532 |
| 2532 TEST_P(QuicConnectionTest, SetRTOAfterWritingToSocket) { | 2533 TEST_P(QuicConnectionTest, SetRTOAfterWritingToSocket) { |
| 2533 BlockOnNextWrite(); | 2534 BlockOnNextWrite(); |
| 2534 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); | 2535 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, nullptr); |
| 2535 // Make sure that RTO is not started when the packet is queued. | 2536 // Make sure that RTO is not started when the packet is queued. |
| 2536 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); | 2537 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); |
| 2537 | 2538 |
| 2538 // Test that RTO is started once we write to the socket. | 2539 // Test that RTO is started once we write to the socket. |
| 2539 writer_->SetWritable(); | 2540 writer_->SetWritable(); |
| 2540 connection_.OnCanWrite(); | 2541 connection_.OnCanWrite(); |
| 2541 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); | 2542 EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); |
| 2542 } | 2543 } |
| 2543 | 2544 |
| 2544 TEST_P(QuicConnectionTest, DelayRTOWithAckReceipt) { | 2545 TEST_P(QuicConnectionTest, DelayRTOWithAckReceipt) { |
| 2545 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2546 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2546 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 2547 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
| 2547 .Times(2); | 2548 .Times(2); |
| 2548 connection_.SendStreamDataWithString(2, "foo", 0, !kFin, NULL); | 2549 connection_.SendStreamDataWithString(2, "foo", 0, !kFin, nullptr); |
| 2549 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, NULL); | 2550 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, nullptr); |
| 2550 QuicAlarm* retransmission_alarm = connection_.GetRetransmissionAlarm(); | 2551 QuicAlarm* retransmission_alarm = connection_.GetRetransmissionAlarm(); |
| 2551 EXPECT_TRUE(retransmission_alarm->IsSet()); | 2552 EXPECT_TRUE(retransmission_alarm->IsSet()); |
| 2552 EXPECT_EQ(clock_.Now().Add(DefaultRetransmissionTime()), | 2553 EXPECT_EQ(clock_.Now().Add(DefaultRetransmissionTime()), |
| 2553 retransmission_alarm->deadline()); | 2554 retransmission_alarm->deadline()); |
| 2554 | 2555 |
| 2555 // Advance the time right before the RTO, then receive an ack for the first | 2556 // Advance the time right before the RTO, then receive an ack for the first |
| 2556 // packet to delay the RTO. | 2557 // packet to delay the RTO. |
| 2557 clock_.AdvanceTime(DefaultRetransmissionTime()); | 2558 clock_.AdvanceTime(DefaultRetransmissionTime()); |
| 2558 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 2559 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 2559 QuicAckFrame ack = InitAckFrame(1); | 2560 QuicAckFrame ack = InitAckFrame(1); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2577 EXPECT_TRUE(retransmission_alarm->IsSet()); | 2578 EXPECT_TRUE(retransmission_alarm->IsSet()); |
| 2578 QuicTime next_rto_time = retransmission_alarm->deadline(); | 2579 QuicTime next_rto_time = retransmission_alarm->deadline(); |
| 2579 QuicTime expected_rto_time = | 2580 QuicTime expected_rto_time = |
| 2580 connection_.sent_packet_manager().GetRetransmissionTime(); | 2581 connection_.sent_packet_manager().GetRetransmissionTime(); |
| 2581 EXPECT_EQ(next_rto_time, expected_rto_time); | 2582 EXPECT_EQ(next_rto_time, expected_rto_time); |
| 2582 } | 2583 } |
| 2583 | 2584 |
| 2584 TEST_P(QuicConnectionTest, TestQueued) { | 2585 TEST_P(QuicConnectionTest, TestQueued) { |
| 2585 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 2586 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
| 2586 BlockOnNextWrite(); | 2587 BlockOnNextWrite(); |
| 2587 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); | 2588 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, nullptr); |
| 2588 EXPECT_EQ(1u, connection_.NumQueuedPackets()); | 2589 EXPECT_EQ(1u, connection_.NumQueuedPackets()); |
| 2589 | 2590 |
| 2590 // Unblock the writes and actually send. | 2591 // Unblock the writes and actually send. |
| 2591 writer_->SetWritable(); | 2592 writer_->SetWritable(); |
| 2592 connection_.OnCanWrite(); | 2593 connection_.OnCanWrite(); |
| 2593 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 2594 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
| 2594 } | 2595 } |
| 2595 | 2596 |
| 2596 TEST_P(QuicConnectionTest, CloseFecGroup) { | 2597 TEST_P(QuicConnectionTest, CloseFecGroup) { |
| 2597 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2598 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2639 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2640 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2640 ProcessPacket(1); | 2641 ProcessPacket(1); |
| 2641 } | 2642 } |
| 2642 | 2643 |
| 2643 TEST_P(QuicConnectionTest, DontUpdateQuicCongestionFeedbackFrameForRevived) { | 2644 TEST_P(QuicConnectionTest, DontUpdateQuicCongestionFeedbackFrameForRevived) { |
| 2644 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2645 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2645 SendAckPacketToPeer(); | 2646 SendAckPacketToPeer(); |
| 2646 // Process an FEC packet, and revive the missing data packet | 2647 // Process an FEC packet, and revive the missing data packet |
| 2647 // but only contact the receive_algorithm once. | 2648 // but only contact the receive_algorithm once. |
| 2648 EXPECT_CALL(*receive_algorithm_, RecordIncomingPacket(_, _, _)); | 2649 EXPECT_CALL(*receive_algorithm_, RecordIncomingPacket(_, _, _)); |
| 2649 ProcessFecPacket(2, 1, true, !kEntropyFlag, NULL); | 2650 ProcessFecPacket(2, 1, true, !kEntropyFlag, nullptr); |
| 2650 } | 2651 } |
| 2651 | 2652 |
| 2652 TEST_P(QuicConnectionTest, InitialTimeout) { | 2653 TEST_P(QuicConnectionTest, InitialTimeout) { |
| 2653 if (!FLAGS_quic_unified_timeouts) { | 2654 if (!FLAGS_quic_unified_timeouts) { |
| 2654 EXPECT_TRUE(connection_.connected()); | 2655 EXPECT_TRUE(connection_.connected()); |
| 2655 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false)); | 2656 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false)); |
| 2656 EXPECT_CALL(*send_algorithm_, | 2657 EXPECT_CALL(*send_algorithm_, |
| 2657 OnPacketSent(_, _, _, _, _)).Times(AnyNumber()); | 2658 OnPacketSent(_, _, _, _, _)).Times(AnyNumber()); |
| 2658 | 2659 |
| 2659 QuicTime default_timeout = clock_.ApproximateNow().Add( | 2660 QuicTime default_timeout = clock_.ApproximateNow().Add( |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2710 connection_.SetNetworkTimeouts(timeout, timeout); | 2711 connection_.SetNetworkTimeouts(timeout, timeout); |
| 2711 EXPECT_TRUE(connection_.connected()); | 2712 EXPECT_TRUE(connection_.connected()); |
| 2712 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(AnyNumber()); | 2713 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(AnyNumber()); |
| 2713 | 2714 |
| 2714 QuicTime overall_timeout = clock_.ApproximateNow().Add(timeout).Subtract( | 2715 QuicTime overall_timeout = clock_.ApproximateNow().Add(timeout).Subtract( |
| 2715 QuicTime::Delta::FromSeconds(1)); | 2716 QuicTime::Delta::FromSeconds(1)); |
| 2716 EXPECT_EQ(overall_timeout, connection_.GetTimeoutAlarm()->deadline()); | 2717 EXPECT_EQ(overall_timeout, connection_.GetTimeoutAlarm()->deadline()); |
| 2717 EXPECT_TRUE(connection_.connected()); | 2718 EXPECT_TRUE(connection_.connected()); |
| 2718 | 2719 |
| 2719 // Send and ack new data 3 seconds later to lengthen the idle timeout. | 2720 // Send and ack new data 3 seconds later to lengthen the idle timeout. |
| 2720 SendStreamDataToPeer(1, "GET /", 0, kFin, NULL); | 2721 SendStreamDataToPeer(1, "GET /", 0, kFin, nullptr); |
| 2721 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(3)); | 2722 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(3)); |
| 2722 QuicAckFrame frame = InitAckFrame(1); | 2723 QuicAckFrame frame = InitAckFrame(1); |
| 2723 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2724 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2724 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 2725 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 2725 ProcessAckPacket(&frame); | 2726 ProcessAckPacket(&frame); |
| 2726 | 2727 |
| 2727 // Fire early to verify it wouldn't timeout yet. | 2728 // Fire early to verify it wouldn't timeout yet. |
| 2728 connection_.GetTimeoutAlarm()->Fire(); | 2729 connection_.GetTimeoutAlarm()->Fire(); |
| 2729 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); | 2730 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); |
| 2730 EXPECT_TRUE(connection_.connected()); | 2731 EXPECT_TRUE(connection_.connected()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2748 | 2749 |
| 2749 TEST_P(QuicConnectionTest, PingAfterSend) { | 2750 TEST_P(QuicConnectionTest, PingAfterSend) { |
| 2750 EXPECT_TRUE(connection_.connected()); | 2751 EXPECT_TRUE(connection_.connected()); |
| 2751 EXPECT_CALL(visitor_, HasOpenDataStreams()).WillRepeatedly(Return(true)); | 2752 EXPECT_CALL(visitor_, HasOpenDataStreams()).WillRepeatedly(Return(true)); |
| 2752 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); | 2753 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); |
| 2753 | 2754 |
| 2754 // Advance to 5ms, and send a packet to the peer, which will set | 2755 // Advance to 5ms, and send a packet to the peer, which will set |
| 2755 // the ping alarm. | 2756 // the ping alarm. |
| 2756 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); | 2757 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); |
| 2757 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); | 2758 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); |
| 2758 SendStreamDataToPeer(1, "GET /", 0, kFin, NULL); | 2759 SendStreamDataToPeer(1, "GET /", 0, kFin, nullptr); |
| 2759 EXPECT_TRUE(connection_.GetPingAlarm()->IsSet()); | 2760 EXPECT_TRUE(connection_.GetPingAlarm()->IsSet()); |
| 2760 EXPECT_EQ(clock_.ApproximateNow().Add(QuicTime::Delta::FromSeconds(15)), | 2761 EXPECT_EQ(clock_.ApproximateNow().Add(QuicTime::Delta::FromSeconds(15)), |
| 2761 connection_.GetPingAlarm()->deadline()); | 2762 connection_.GetPingAlarm()->deadline()); |
| 2762 | 2763 |
| 2763 // Now recevie and ACK of the previous packet, which will move the | 2764 // Now recevie and ACK of the previous packet, which will move the |
| 2764 // ping alarm forward. | 2765 // ping alarm forward. |
| 2765 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); | 2766 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); |
| 2766 QuicAckFrame frame = InitAckFrame(1); | 2767 QuicAckFrame frame = InitAckFrame(1); |
| 2767 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2768 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2768 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 2769 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2895 connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER, | 2896 connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER, |
| 2896 NOT_IN_FEC_GROUP, &payload_length); | 2897 NOT_IN_FEC_GROUP, &payload_length); |
| 2897 QuicConnectionPeer::GetPacketCreator(&connection_)->set_max_packet_length( | 2898 QuicConnectionPeer::GetPacketCreator(&connection_)->set_max_packet_length( |
| 2898 length); | 2899 length); |
| 2899 | 2900 |
| 2900 // Queue the first packet. | 2901 // Queue the first packet. |
| 2901 EXPECT_CALL(*send_algorithm_, | 2902 EXPECT_CALL(*send_algorithm_, |
| 2902 TimeUntilSend(_, _, _)).WillOnce( | 2903 TimeUntilSend(_, _, _)).WillOnce( |
| 2903 testing::Return(QuicTime::Delta::FromMicroseconds(10))); | 2904 testing::Return(QuicTime::Delta::FromMicroseconds(10))); |
| 2904 const string payload(payload_length, 'a'); | 2905 const string payload(payload_length, 'a'); |
| 2905 EXPECT_EQ(0u, | 2906 EXPECT_EQ(0u, connection_.SendStreamDataWithString(3, payload, 0, !kFin, |
| 2906 connection_.SendStreamDataWithString(3, payload, 0, | 2907 nullptr).bytes_consumed); |
| 2907 !kFin, NULL).bytes_consumed); | |
| 2908 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 2908 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
| 2909 } | 2909 } |
| 2910 | 2910 |
| 2911 TEST_P(QuicConnectionTest, LoopThroughSendingPackets) { | 2911 TEST_P(QuicConnectionTest, LoopThroughSendingPackets) { |
| 2912 // All packets carry version info till version is negotiated. | 2912 // All packets carry version info till version is negotiated. |
| 2913 size_t payload_length; | 2913 size_t payload_length; |
| 2914 // GetPacketLengthForOneStream() assumes a stream offset of 0 in determining | 2914 // GetPacketLengthForOneStream() assumes a stream offset of 0 in determining |
| 2915 // packet length. The size of the offset field in a stream frame is 0 for | 2915 // packet length. The size of the offset field in a stream frame is 0 for |
| 2916 // offset 0, and 2 for non-zero offsets up through 16K. Increase | 2916 // offset 0, and 2 for non-zero offsets up through 16K. Increase |
| 2917 // max_packet_length by 2 so that subsequent packets containing subsequent | 2917 // max_packet_length by 2 so that subsequent packets containing subsequent |
| 2918 // stream frames with non-zero offets will fit within the packet length. | 2918 // stream frames with non-zero offets will fit within the packet length. |
| 2919 size_t length = 2 + GetPacketLengthForOneStream( | 2919 size_t length = 2 + GetPacketLengthForOneStream( |
| 2920 connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER, | 2920 connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER, |
| 2921 NOT_IN_FEC_GROUP, &payload_length); | 2921 NOT_IN_FEC_GROUP, &payload_length); |
| 2922 QuicConnectionPeer::GetPacketCreator(&connection_)->set_max_packet_length( | 2922 QuicConnectionPeer::GetPacketCreator(&connection_)->set_max_packet_length( |
| 2923 length); | 2923 length); |
| 2924 | 2924 |
| 2925 // Queue the first packet. | 2925 // Queue the first packet. |
| 2926 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(7); | 2926 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(7); |
| 2927 // The first stream frame will have 2 fewer overhead bytes than the other six. | 2927 // The first stream frame will have 2 fewer overhead bytes than the other six. |
| 2928 const string payload(payload_length * 7 + 2, 'a'); | 2928 const string payload(payload_length * 7 + 2, 'a'); |
| 2929 EXPECT_EQ(payload.size(), | 2929 EXPECT_EQ(payload.size(), |
| 2930 connection_.SendStreamDataWithString(1, payload, 0, | 2930 connection_.SendStreamDataWithString(1, payload, 0, !kFin, nullptr) |
| 2931 !kFin, NULL).bytes_consumed); | 2931 .bytes_consumed); |
| 2932 } | 2932 } |
| 2933 | 2933 |
| 2934 TEST_P(QuicConnectionTest, SendDelayedAck) { | 2934 TEST_P(QuicConnectionTest, SendDelayedAck) { |
| 2935 QuicTime ack_time = clock_.ApproximateNow().Add(DefaultDelayedAckTime()); | 2935 QuicTime ack_time = clock_.ApproximateNow().Add(DefaultDelayedAckTime()); |
| 2936 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2936 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2937 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 2937 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
| 2938 const uint8 tag = 0x07; | 2938 const uint8 tag = 0x07; |
| 2939 connection_.SetDecrypter(new StrictTaggingDecrypter(tag), | 2939 connection_.SetDecrypter(new StrictTaggingDecrypter(tag), |
| 2940 ENCRYPTION_INITIAL); | 2940 ENCRYPTION_INITIAL); |
| 2941 framer_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag)); | 2941 framer_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag)); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3020 writer_->Reset(); | 3020 writer_->Reset(); |
| 3021 // Now only set the timer on the 6th packet, instead of sending another ack. | 3021 // Now only set the timer on the 6th packet, instead of sending another ack. |
| 3022 ProcessPacket(6); | 3022 ProcessPacket(6); |
| 3023 EXPECT_EQ(0u, writer_->frame_count()); | 3023 EXPECT_EQ(0u, writer_->frame_count()); |
| 3024 EXPECT_TRUE(connection_.GetAckAlarm()->IsSet()); | 3024 EXPECT_TRUE(connection_.GetAckAlarm()->IsSet()); |
| 3025 } | 3025 } |
| 3026 | 3026 |
| 3027 TEST_P(QuicConnectionTest, SendDelayedAckOnOutgoingPacket) { | 3027 TEST_P(QuicConnectionTest, SendDelayedAckOnOutgoingPacket) { |
| 3028 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3028 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 3029 ProcessPacket(1); | 3029 ProcessPacket(1); |
| 3030 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 0, | 3030 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 0, !kFin, |
| 3031 !kFin, NULL); | 3031 nullptr); |
| 3032 // Check that ack is bundled with outgoing data and that delayed ack | 3032 // Check that ack is bundled with outgoing data and that delayed ack |
| 3033 // alarm is reset. | 3033 // alarm is reset. |
| 3034 EXPECT_EQ(3u, writer_->frame_count()); | 3034 EXPECT_EQ(3u, writer_->frame_count()); |
| 3035 EXPECT_FALSE(writer_->stop_waiting_frames().empty()); | 3035 EXPECT_FALSE(writer_->stop_waiting_frames().empty()); |
| 3036 EXPECT_FALSE(writer_->ack_frames().empty()); | 3036 EXPECT_FALSE(writer_->ack_frames().empty()); |
| 3037 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 3037 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
| 3038 } | 3038 } |
| 3039 | 3039 |
| 3040 TEST_P(QuicConnectionTest, SendDelayedAckOnOutgoingCryptoPacket) { | 3040 TEST_P(QuicConnectionTest, SendDelayedAckOnOutgoingCryptoPacket) { |
| 3041 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3041 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 3042 ProcessPacket(1); | 3042 ProcessPacket(1); |
| 3043 connection_.SendStreamDataWithString(kCryptoStreamId, "foo", 0, !kFin, NULL); | 3043 connection_.SendStreamDataWithString(kCryptoStreamId, "foo", 0, !kFin, |
| 3044 nullptr); |
| 3044 // Check that ack is bundled with outgoing crypto data. | 3045 // Check that ack is bundled with outgoing crypto data. |
| 3045 EXPECT_EQ(3u, writer_->frame_count()); | 3046 EXPECT_EQ(3u, writer_->frame_count()); |
| 3046 EXPECT_FALSE(writer_->ack_frames().empty()); | 3047 EXPECT_FALSE(writer_->ack_frames().empty()); |
| 3047 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 3048 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
| 3048 } | 3049 } |
| 3049 | 3050 |
| 3050 TEST_P(QuicConnectionTest, BlockAndBufferOnFirstCHLOPacketOfTwo) { | 3051 TEST_P(QuicConnectionTest, BlockAndBufferOnFirstCHLOPacketOfTwo) { |
| 3051 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3052 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 3052 ProcessPacket(1); | 3053 ProcessPacket(1); |
| 3053 BlockOnNextWrite(); | 3054 BlockOnNextWrite(); |
| 3054 writer_->set_is_write_blocked_data_buffered(true); | 3055 writer_->set_is_write_blocked_data_buffered(true); |
| 3055 connection_.SendStreamDataWithString(kCryptoStreamId, "foo", 0, !kFin, NULL); | 3056 connection_.SendStreamDataWithString(kCryptoStreamId, "foo", 0, !kFin, |
| 3057 nullptr); |
| 3056 EXPECT_TRUE(writer_->IsWriteBlocked()); | 3058 EXPECT_TRUE(writer_->IsWriteBlocked()); |
| 3057 EXPECT_FALSE(connection_.HasQueuedData()); | 3059 EXPECT_FALSE(connection_.HasQueuedData()); |
| 3058 connection_.SendStreamDataWithString(kCryptoStreamId, "bar", 3, !kFin, NULL); | 3060 connection_.SendStreamDataWithString(kCryptoStreamId, "bar", 3, !kFin, |
| 3061 nullptr); |
| 3059 EXPECT_TRUE(writer_->IsWriteBlocked()); | 3062 EXPECT_TRUE(writer_->IsWriteBlocked()); |
| 3060 EXPECT_TRUE(connection_.HasQueuedData()); | 3063 EXPECT_TRUE(connection_.HasQueuedData()); |
| 3061 } | 3064 } |
| 3062 | 3065 |
| 3063 TEST_P(QuicConnectionTest, BundleAckForSecondCHLO) { | 3066 TEST_P(QuicConnectionTest, BundleAckForSecondCHLO) { |
| 3064 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3067 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 3065 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 3068 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
| 3066 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce( | 3069 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce( |
| 3067 IgnoreResult(InvokeWithoutArgs(&connection_, | 3070 IgnoreResult(InvokeWithoutArgs(&connection_, |
| 3068 &TestConnection::SendCryptoStreamData))); | 3071 &TestConnection::SendCryptoStreamData))); |
| 3069 // Process a packet from the crypto stream, which is frame1_'s default. | 3072 // Process a packet from the crypto stream, which is frame1_'s default. |
| 3070 // Receiving the CHLO as packet 2 first will cause the connection to | 3073 // Receiving the CHLO as packet 2 first will cause the connection to |
| 3071 // immediately send an ack, due to the packet gap. | 3074 // immediately send an ack, due to the packet gap. |
| 3072 ProcessPacket(2); | 3075 ProcessPacket(2); |
| 3073 // Check that ack is sent and that delayed ack alarm is reset. | 3076 // Check that ack is sent and that delayed ack alarm is reset. |
| 3074 EXPECT_EQ(3u, writer_->frame_count()); | 3077 EXPECT_EQ(3u, writer_->frame_count()); |
| 3075 EXPECT_FALSE(writer_->stop_waiting_frames().empty()); | 3078 EXPECT_FALSE(writer_->stop_waiting_frames().empty()); |
| 3076 EXPECT_EQ(1u, writer_->stream_frames().size()); | 3079 EXPECT_EQ(1u, writer_->stream_frames().size()); |
| 3077 EXPECT_FALSE(writer_->ack_frames().empty()); | 3080 EXPECT_FALSE(writer_->ack_frames().empty()); |
| 3078 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 3081 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
| 3079 } | 3082 } |
| 3080 | 3083 |
| 3081 TEST_P(QuicConnectionTest, BundleAckWithDataOnIncomingAck) { | 3084 TEST_P(QuicConnectionTest, BundleAckWithDataOnIncomingAck) { |
| 3082 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3085 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 3083 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 0, | 3086 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 0, !kFin, |
| 3084 !kFin, NULL); | 3087 nullptr); |
| 3085 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 3, | 3088 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 3, !kFin, |
| 3086 !kFin, NULL); | 3089 nullptr); |
| 3087 // Ack the second packet, which will retransmit the first packet. | 3090 // Ack the second packet, which will retransmit the first packet. |
| 3088 QuicAckFrame ack = InitAckFrame(2); | 3091 QuicAckFrame ack = InitAckFrame(2); |
| 3089 NackPacket(1, &ack); | 3092 NackPacket(1, &ack); |
| 3090 SequenceNumberSet lost_packets; | 3093 SequenceNumberSet lost_packets; |
| 3091 lost_packets.insert(1); | 3094 lost_packets.insert(1); |
| 3092 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | 3095 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
| 3093 .WillOnce(Return(lost_packets)); | 3096 .WillOnce(Return(lost_packets)); |
| 3094 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 3097 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 3095 ProcessAckPacket(&ack); | 3098 ProcessAckPacket(&ack); |
| 3096 EXPECT_EQ(1u, writer_->frame_count()); | 3099 EXPECT_EQ(1u, writer_->frame_count()); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3189 | 3192 |
| 3190 QuicBlockedFrame blocked; | 3193 QuicBlockedFrame blocked; |
| 3191 blocked.stream_id = 3; | 3194 blocked.stream_id = 3; |
| 3192 EXPECT_CALL(visitor_, OnBlockedFrames(_)); | 3195 EXPECT_CALL(visitor_, OnBlockedFrames(_)); |
| 3193 ProcessFramePacket(QuicFrame(&blocked)); | 3196 ProcessFramePacket(QuicFrame(&blocked)); |
| 3194 } | 3197 } |
| 3195 | 3198 |
| 3196 TEST_P(QuicConnectionTest, InvalidPacket) { | 3199 TEST_P(QuicConnectionTest, InvalidPacket) { |
| 3197 EXPECT_CALL(visitor_, | 3200 EXPECT_CALL(visitor_, |
| 3198 OnConnectionClosed(QUIC_INVALID_PACKET_HEADER, false)); | 3201 OnConnectionClosed(QUIC_INVALID_PACKET_HEADER, false)); |
| 3199 QuicEncryptedPacket encrypted(NULL, 0); | 3202 QuicEncryptedPacket encrypted(nullptr, 0); |
| 3200 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), encrypted); | 3203 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), encrypted); |
| 3201 // The connection close packet should have error details. | 3204 // The connection close packet should have error details. |
| 3202 ASSERT_FALSE(writer_->connection_close_frames().empty()); | 3205 ASSERT_FALSE(writer_->connection_close_frames().empty()); |
| 3203 EXPECT_EQ("Unable to read public flags.", | 3206 EXPECT_EQ("Unable to read public flags.", |
| 3204 writer_->connection_close_frames()[0].error_details); | 3207 writer_->connection_close_frames()[0].error_details); |
| 3205 } | 3208 } |
| 3206 | 3209 |
| 3207 TEST_P(QuicConnectionTest, MissingPacketsBeforeLeastUnacked) { | 3210 TEST_P(QuicConnectionTest, MissingPacketsBeforeLeastUnacked) { |
| 3208 // Set the sequence number of the ack packet to be least unacked (4). | 3211 // Set the sequence number of the ack packet to be least unacked (4). |
| 3209 peer_creator_.set_sequence_number(3); | 3212 peer_creator_.set_sequence_number(3); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3221 ProcessDataPacket(3, 1, !kEntropyFlag); | 3224 ProcessDataPacket(3, 1, !kEntropyFlag); |
| 3222 ProcessDataPacket(7, 1, kEntropyFlag); | 3225 ProcessDataPacket(7, 1, kEntropyFlag); |
| 3223 EXPECT_EQ(146u, outgoing_ack()->entropy_hash); | 3226 EXPECT_EQ(146u, outgoing_ack()->entropy_hash); |
| 3224 } | 3227 } |
| 3225 | 3228 |
| 3226 TEST_P(QuicConnectionTest, ReceivedEntropyHashCalculationHalfFEC) { | 3229 TEST_P(QuicConnectionTest, ReceivedEntropyHashCalculationHalfFEC) { |
| 3227 // FEC packets should not change the entropy hash calculation. | 3230 // FEC packets should not change the entropy hash calculation. |
| 3228 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(AtLeast(1)); | 3231 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(AtLeast(1)); |
| 3229 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3232 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 3230 ProcessDataPacket(1, 1, kEntropyFlag); | 3233 ProcessDataPacket(1, 1, kEntropyFlag); |
| 3231 ProcessFecPacket(4, 1, false, kEntropyFlag, NULL); | 3234 ProcessFecPacket(4, 1, false, kEntropyFlag, nullptr); |
| 3232 ProcessDataPacket(3, 3, !kEntropyFlag); | 3235 ProcessDataPacket(3, 3, !kEntropyFlag); |
| 3233 ProcessFecPacket(7, 3, false, kEntropyFlag, NULL); | 3236 ProcessFecPacket(7, 3, false, kEntropyFlag, nullptr); |
| 3234 EXPECT_EQ(146u, outgoing_ack()->entropy_hash); | 3237 EXPECT_EQ(146u, outgoing_ack()->entropy_hash); |
| 3235 } | 3238 } |
| 3236 | 3239 |
| 3237 TEST_P(QuicConnectionTest, UpdateEntropyForReceivedPackets) { | 3240 TEST_P(QuicConnectionTest, UpdateEntropyForReceivedPackets) { |
| 3238 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(AtLeast(1)); | 3241 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(AtLeast(1)); |
| 3239 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3242 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 3240 ProcessDataPacket(1, 1, kEntropyFlag); | 3243 ProcessDataPacket(1, 1, kEntropyFlag); |
| 3241 ProcessDataPacket(5, 1, kEntropyFlag); | 3244 ProcessDataPacket(5, 1, kEntropyFlag); |
| 3242 ProcessDataPacket(4, 1, !kEntropyFlag); | 3245 ProcessDataPacket(4, 1, !kEntropyFlag); |
| 3243 EXPECT_EQ(34u, outgoing_ack()->entropy_hash); | 3246 EXPECT_EQ(34u, outgoing_ack()->entropy_hash); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3318 QuicFrame frame(&frame1_); | 3321 QuicFrame frame(&frame1_); |
| 3319 frames.push_back(frame); | 3322 frames.push_back(frame); |
| 3320 scoped_ptr<QuicPacket> packet( | 3323 scoped_ptr<QuicPacket> packet( |
| 3321 BuildUnsizedDataPacket(&framer_, header, frames).packet); | 3324 BuildUnsizedDataPacket(&framer_, header, frames).packet); |
| 3322 scoped_ptr<QuicEncryptedPacket> encrypted( | 3325 scoped_ptr<QuicEncryptedPacket> encrypted( |
| 3323 framer_.EncryptPacket(ENCRYPTION_NONE, 12, *packet)); | 3326 framer_.EncryptPacket(ENCRYPTION_NONE, 12, *packet)); |
| 3324 | 3327 |
| 3325 framer_.set_version(version()); | 3328 framer_.set_version(version()); |
| 3326 connection_.set_is_server(true); | 3329 connection_.set_is_server(true); |
| 3327 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); | 3330 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); |
| 3328 EXPECT_TRUE(writer_->version_negotiation_packet() != NULL); | 3331 EXPECT_TRUE(writer_->version_negotiation_packet() != nullptr); |
| 3329 | 3332 |
| 3330 size_t num_versions = arraysize(kSupportedQuicVersions); | 3333 size_t num_versions = arraysize(kSupportedQuicVersions); |
| 3331 ASSERT_EQ(num_versions, | 3334 ASSERT_EQ(num_versions, |
| 3332 writer_->version_negotiation_packet()->versions.size()); | 3335 writer_->version_negotiation_packet()->versions.size()); |
| 3333 | 3336 |
| 3334 // We expect all versions in kSupportedQuicVersions to be | 3337 // We expect all versions in kSupportedQuicVersions to be |
| 3335 // included in the packet. | 3338 // included in the packet. |
| 3336 for (size_t i = 0; i < num_versions; ++i) { | 3339 for (size_t i = 0; i < num_versions; ++i) { |
| 3337 EXPECT_EQ(kSupportedQuicVersions[i], | 3340 EXPECT_EQ(kSupportedQuicVersions[i], |
| 3338 writer_->version_negotiation_packet()->versions[i]); | 3341 writer_->version_negotiation_packet()->versions[i]); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3362 | 3365 |
| 3363 framer_.set_version(version()); | 3366 framer_.set_version(version()); |
| 3364 connection_.set_is_server(true); | 3367 connection_.set_is_server(true); |
| 3365 BlockOnNextWrite(); | 3368 BlockOnNextWrite(); |
| 3366 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); | 3369 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); |
| 3367 EXPECT_EQ(0u, writer_->last_packet_size()); | 3370 EXPECT_EQ(0u, writer_->last_packet_size()); |
| 3368 EXPECT_TRUE(connection_.HasQueuedData()); | 3371 EXPECT_TRUE(connection_.HasQueuedData()); |
| 3369 | 3372 |
| 3370 writer_->SetWritable(); | 3373 writer_->SetWritable(); |
| 3371 connection_.OnCanWrite(); | 3374 connection_.OnCanWrite(); |
| 3372 EXPECT_TRUE(writer_->version_negotiation_packet() != NULL); | 3375 EXPECT_TRUE(writer_->version_negotiation_packet() != nullptr); |
| 3373 | 3376 |
| 3374 size_t num_versions = arraysize(kSupportedQuicVersions); | 3377 size_t num_versions = arraysize(kSupportedQuicVersions); |
| 3375 ASSERT_EQ(num_versions, | 3378 ASSERT_EQ(num_versions, |
| 3376 writer_->version_negotiation_packet()->versions.size()); | 3379 writer_->version_negotiation_packet()->versions.size()); |
| 3377 | 3380 |
| 3378 // We expect all versions in kSupportedQuicVersions to be | 3381 // We expect all versions in kSupportedQuicVersions to be |
| 3379 // included in the packet. | 3382 // included in the packet. |
| 3380 for (size_t i = 0; i < num_versions; ++i) { | 3383 for (size_t i = 0; i < num_versions; ++i) { |
| 3381 EXPECT_EQ(kSupportedQuicVersions[i], | 3384 EXPECT_EQ(kSupportedQuicVersions[i], |
| 3382 writer_->version_negotiation_packet()->versions[i]); | 3385 writer_->version_negotiation_packet()->versions[i]); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3477 OnConnectionClosed(QUIC_INVALID_VERSION_NEGOTIATION_PACKET, | 3480 OnConnectionClosed(QUIC_INVALID_VERSION_NEGOTIATION_PACKET, |
| 3478 false)); | 3481 false)); |
| 3479 scoped_ptr<QuicEncryptedPacket> encrypted( | 3482 scoped_ptr<QuicEncryptedPacket> encrypted( |
| 3480 framer_.BuildVersionNegotiationPacket( | 3483 framer_.BuildVersionNegotiationPacket( |
| 3481 header.public_header, supported_versions)); | 3484 header.public_header, supported_versions)); |
| 3482 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); | 3485 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); |
| 3483 } | 3486 } |
| 3484 | 3487 |
| 3485 TEST_P(QuicConnectionTest, CheckSendStats) { | 3488 TEST_P(QuicConnectionTest, CheckSendStats) { |
| 3486 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 3489 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
| 3487 connection_.SendStreamDataWithString(3, "first", 0, !kFin, NULL); | 3490 connection_.SendStreamDataWithString(3, "first", 0, !kFin, nullptr); |
| 3488 size_t first_packet_size = writer_->last_packet_size(); | 3491 size_t first_packet_size = writer_->last_packet_size(); |
| 3489 | 3492 |
| 3490 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 3493 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
| 3491 connection_.SendStreamDataWithString(5, "second", 0, !kFin, NULL); | 3494 connection_.SendStreamDataWithString(5, "second", 0, !kFin, nullptr); |
| 3492 size_t second_packet_size = writer_->last_packet_size(); | 3495 size_t second_packet_size = writer_->last_packet_size(); |
| 3493 | 3496 |
| 3494 // 2 retransmissions due to rto, 1 due to explicit nack. | 3497 // 2 retransmissions due to rto, 1 due to explicit nack. |
| 3495 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); | 3498 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); |
| 3496 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(3); | 3499 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(3); |
| 3497 | 3500 |
| 3498 // Retransmit due to RTO. | 3501 // Retransmit due to RTO. |
| 3499 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10)); | 3502 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10)); |
| 3500 connection_.GetRetransmissionAlarm()->Fire(); | 3503 connection_.GetRetransmissionAlarm()->Fire(); |
| 3501 | 3504 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3535 } | 3538 } |
| 3536 | 3539 |
| 3537 TEST_P(QuicConnectionTest, CheckReceiveStats) { | 3540 TEST_P(QuicConnectionTest, CheckReceiveStats) { |
| 3538 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3541 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 3539 | 3542 |
| 3540 size_t received_bytes = 0; | 3543 size_t received_bytes = 0; |
| 3541 received_bytes += ProcessFecProtectedPacket(1, false, !kEntropyFlag); | 3544 received_bytes += ProcessFecProtectedPacket(1, false, !kEntropyFlag); |
| 3542 received_bytes += ProcessFecProtectedPacket(3, false, !kEntropyFlag); | 3545 received_bytes += ProcessFecProtectedPacket(3, false, !kEntropyFlag); |
| 3543 // Should be counted against dropped packets. | 3546 // Should be counted against dropped packets. |
| 3544 received_bytes += ProcessDataPacket(3, 1, !kEntropyFlag); | 3547 received_bytes += ProcessDataPacket(3, 1, !kEntropyFlag); |
| 3545 received_bytes += ProcessFecPacket(4, 1, true, !kEntropyFlag, NULL); | 3548 received_bytes += ProcessFecPacket(4, 1, true, !kEntropyFlag, nullptr); |
| 3546 | 3549 |
| 3547 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillOnce( | 3550 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillOnce( |
| 3548 Return(QuicBandwidth::Zero())); | 3551 Return(QuicBandwidth::Zero())); |
| 3549 const uint32 kSlowStartThreshold = 23u; | 3552 const uint32 kSlowStartThreshold = 23u; |
| 3550 EXPECT_CALL(*send_algorithm_, GetSlowStartThreshold()).WillOnce( | 3553 EXPECT_CALL(*send_algorithm_, GetSlowStartThreshold()).WillOnce( |
| 3551 Return(kSlowStartThreshold)); | 3554 Return(kSlowStartThreshold)); |
| 3552 | 3555 |
| 3553 const QuicConnectionStats& stats = connection_.GetStats(); | 3556 const QuicConnectionStats& stats = connection_.GetStats(); |
| 3554 EXPECT_EQ(received_bytes, stats.bytes_received); | 3557 EXPECT_EQ(received_bytes, stats.bytes_received); |
| 3555 EXPECT_EQ(4u, stats.packets_received); | 3558 EXPECT_EQ(4u, stats.packets_received); |
| 3556 | 3559 |
| 3557 EXPECT_EQ(1u, stats.packets_revived); | 3560 EXPECT_EQ(1u, stats.packets_revived); |
| 3558 EXPECT_EQ(1u, stats.packets_dropped); | 3561 EXPECT_EQ(1u, stats.packets_dropped); |
| 3559 | 3562 |
| 3560 EXPECT_EQ(kSlowStartThreshold, stats.slow_start_threshold); | 3563 EXPECT_EQ(kSlowStartThreshold, stats.slow_start_threshold); |
| 3561 } | 3564 } |
| 3562 | 3565 |
| 3563 TEST_P(QuicConnectionTest, TestFecGroupLimits) { | 3566 TEST_P(QuicConnectionTest, TestFecGroupLimits) { |
| 3564 // Create and return a group for 1. | 3567 // Create and return a group for 1. |
| 3565 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 1) != NULL); | 3568 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 1) != nullptr); |
| 3566 | 3569 |
| 3567 // Create and return a group for 2. | 3570 // Create and return a group for 2. |
| 3568 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 2) != NULL); | 3571 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 2) != nullptr); |
| 3569 | 3572 |
| 3570 // Create and return a group for 4. This should remove 1 but not 2. | 3573 // Create and return a group for 4. This should remove 1 but not 2. |
| 3571 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 4) != NULL); | 3574 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 4) != nullptr); |
| 3572 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 1) == NULL); | 3575 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 1) == nullptr); |
| 3573 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 2) != NULL); | 3576 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 2) != nullptr); |
| 3574 | 3577 |
| 3575 // Create and return a group for 3. This will kill off 2. | 3578 // Create and return a group for 3. This will kill off 2. |
| 3576 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 3) != NULL); | 3579 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 3) != nullptr); |
| 3577 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 2) == NULL); | 3580 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 2) == nullptr); |
| 3578 | 3581 |
| 3579 // Verify that adding 5 kills off 3, despite 4 being created before 3. | 3582 // Verify that adding 5 kills off 3, despite 4 being created before 3. |
| 3580 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 5) != NULL); | 3583 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 5) != nullptr); |
| 3581 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 4) != NULL); | 3584 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 4) != nullptr); |
| 3582 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 3) == NULL); | 3585 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 3) == nullptr); |
| 3583 } | 3586 } |
| 3584 | 3587 |
| 3585 TEST_P(QuicConnectionTest, ProcessFramesIfPacketClosedConnection) { | 3588 TEST_P(QuicConnectionTest, ProcessFramesIfPacketClosedConnection) { |
| 3586 // Construct a packet with stream frame and connection close frame. | 3589 // Construct a packet with stream frame and connection close frame. |
| 3587 header_.public_header.connection_id = connection_id_; | 3590 header_.public_header.connection_id = connection_id_; |
| 3588 header_.packet_sequence_number = 1; | 3591 header_.packet_sequence_number = 1; |
| 3589 header_.public_header.reset_flag = false; | 3592 header_.public_header.reset_flag = false; |
| 3590 header_.public_header.version_flag = false; | 3593 header_.public_header.version_flag = false; |
| 3591 header_.entropy_flag = false; | 3594 header_.entropy_flag = false; |
| 3592 header_.fec_flag = false; | 3595 header_.fec_flag = false; |
| 3593 header_.fec_group = 0; | 3596 header_.fec_group = 0; |
| 3594 | 3597 |
| 3595 QuicConnectionCloseFrame qccf; | 3598 QuicConnectionCloseFrame qccf; |
| 3596 qccf.error_code = QUIC_PEER_GOING_AWAY; | 3599 qccf.error_code = QUIC_PEER_GOING_AWAY; |
| 3597 QuicFrame close_frame(&qccf); | 3600 QuicFrame close_frame(&qccf); |
| 3598 QuicFrame stream_frame(&frame1_); | 3601 QuicFrame stream_frame(&frame1_); |
| 3599 | 3602 |
| 3600 QuicFrames frames; | 3603 QuicFrames frames; |
| 3601 frames.push_back(stream_frame); | 3604 frames.push_back(stream_frame); |
| 3602 frames.push_back(close_frame); | 3605 frames.push_back(close_frame); |
| 3603 scoped_ptr<QuicPacket> packet( | 3606 scoped_ptr<QuicPacket> packet( |
| 3604 BuildUnsizedDataPacket(&framer_, header_, frames).packet); | 3607 BuildUnsizedDataPacket(&framer_, header_, frames).packet); |
| 3605 EXPECT_TRUE(NULL != packet.get()); | 3608 EXPECT_TRUE(nullptr != packet.get()); |
| 3606 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket( | 3609 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket( |
| 3607 ENCRYPTION_NONE, 1, *packet)); | 3610 ENCRYPTION_NONE, 1, *packet)); |
| 3608 | 3611 |
| 3609 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PEER_GOING_AWAY, true)); | 3612 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PEER_GOING_AWAY, true)); |
| 3610 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(1); | 3613 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(1); |
| 3611 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3614 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 3612 | 3615 |
| 3613 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); | 3616 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); |
| 3614 } | 3617 } |
| 3615 | 3618 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3640 // Shouldn't be able to find a mutually supported version. | 3643 // Shouldn't be able to find a mutually supported version. |
| 3641 QuicVersionVector unsupported_version; | 3644 QuicVersionVector unsupported_version; |
| 3642 unsupported_version.push_back(QUIC_VERSION_UNSUPPORTED); | 3645 unsupported_version.push_back(QUIC_VERSION_UNSUPPORTED); |
| 3643 EXPECT_FALSE(connection_.SelectMutualVersion(unsupported_version)); | 3646 EXPECT_FALSE(connection_.SelectMutualVersion(unsupported_version)); |
| 3644 } | 3647 } |
| 3645 | 3648 |
| 3646 TEST_P(QuicConnectionTest, ConnectionCloseWhenWritable) { | 3649 TEST_P(QuicConnectionTest, ConnectionCloseWhenWritable) { |
| 3647 EXPECT_FALSE(writer_->IsWriteBlocked()); | 3650 EXPECT_FALSE(writer_->IsWriteBlocked()); |
| 3648 | 3651 |
| 3649 // Send a packet. | 3652 // Send a packet. |
| 3650 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); | 3653 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, nullptr); |
| 3651 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 3654 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
| 3652 EXPECT_EQ(1u, writer_->packets_write_attempts()); | 3655 EXPECT_EQ(1u, writer_->packets_write_attempts()); |
| 3653 | 3656 |
| 3654 TriggerConnectionClose(); | 3657 TriggerConnectionClose(); |
| 3655 EXPECT_EQ(2u, writer_->packets_write_attempts()); | 3658 EXPECT_EQ(2u, writer_->packets_write_attempts()); |
| 3656 } | 3659 } |
| 3657 | 3660 |
| 3658 TEST_P(QuicConnectionTest, ConnectionCloseGettingWriteBlocked) { | 3661 TEST_P(QuicConnectionTest, ConnectionCloseGettingWriteBlocked) { |
| 3659 BlockOnNextWrite(); | 3662 BlockOnNextWrite(); |
| 3660 TriggerConnectionClose(); | 3663 TriggerConnectionClose(); |
| 3661 EXPECT_EQ(1u, writer_->packets_write_attempts()); | 3664 EXPECT_EQ(1u, writer_->packets_write_attempts()); |
| 3662 EXPECT_TRUE(writer_->IsWriteBlocked()); | 3665 EXPECT_TRUE(writer_->IsWriteBlocked()); |
| 3663 } | 3666 } |
| 3664 | 3667 |
| 3665 TEST_P(QuicConnectionTest, ConnectionCloseWhenWriteBlocked) { | 3668 TEST_P(QuicConnectionTest, ConnectionCloseWhenWriteBlocked) { |
| 3666 BlockOnNextWrite(); | 3669 BlockOnNextWrite(); |
| 3667 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); | 3670 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, nullptr); |
| 3668 EXPECT_EQ(1u, connection_.NumQueuedPackets()); | 3671 EXPECT_EQ(1u, connection_.NumQueuedPackets()); |
| 3669 EXPECT_EQ(1u, writer_->packets_write_attempts()); | 3672 EXPECT_EQ(1u, writer_->packets_write_attempts()); |
| 3670 EXPECT_TRUE(writer_->IsWriteBlocked()); | 3673 EXPECT_TRUE(writer_->IsWriteBlocked()); |
| 3671 TriggerConnectionClose(); | 3674 TriggerConnectionClose(); |
| 3672 EXPECT_EQ(1u, writer_->packets_write_attempts()); | 3675 EXPECT_EQ(1u, writer_->packets_write_attempts()); |
| 3673 } | 3676 } |
| 3674 | 3677 |
| 3675 TEST_P(QuicConnectionTest, AckNotifierTriggerCallback) { | 3678 TEST_P(QuicConnectionTest, AckNotifierTriggerCallback) { |
| 3676 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3679 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 3677 | 3680 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3693 | 3696 |
| 3694 // Create a delegate which we don't expect to be called. | 3697 // Create a delegate which we don't expect to be called. |
| 3695 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); | 3698 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); |
| 3696 EXPECT_CALL(*delegate.get(), OnAckNotification(_, _, _, _, _)).Times(0); | 3699 EXPECT_CALL(*delegate.get(), OnAckNotification(_, _, _, _, _)).Times(0); |
| 3697 | 3700 |
| 3698 // Send some data, which will register the delegate to be notified. This will | 3701 // Send some data, which will register the delegate to be notified. This will |
| 3699 // not be ACKed and so the delegate should never be called. | 3702 // not be ACKed and so the delegate should never be called. |
| 3700 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get()); | 3703 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get()); |
| 3701 | 3704 |
| 3702 // Send some other data which we will ACK. | 3705 // Send some other data which we will ACK. |
| 3703 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); | 3706 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, nullptr); |
| 3704 connection_.SendStreamDataWithString(1, "bar", 0, !kFin, NULL); | 3707 connection_.SendStreamDataWithString(1, "bar", 0, !kFin, nullptr); |
| 3705 | 3708 |
| 3706 // Now we receive ACK for packets 2 and 3, but importantly missing packet 1 | 3709 // Now we receive ACK for packets 2 and 3, but importantly missing packet 1 |
| 3707 // which we registered to be notified about. | 3710 // which we registered to be notified about. |
| 3708 QuicAckFrame frame = InitAckFrame(3); | 3711 QuicAckFrame frame = InitAckFrame(3); |
| 3709 NackPacket(1, &frame); | 3712 NackPacket(1, &frame); |
| 3710 SequenceNumberSet lost_packets; | 3713 SequenceNumberSet lost_packets; |
| 3711 lost_packets.insert(1); | 3714 lost_packets.insert(1); |
| 3712 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | 3715 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
| 3713 .WillOnce(Return(lost_packets)); | 3716 .WillOnce(Return(lost_packets)); |
| 3714 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 3717 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 3715 ProcessAckPacket(&frame); | 3718 ProcessAckPacket(&frame); |
| 3716 } | 3719 } |
| 3717 | 3720 |
| 3718 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterRetransmission) { | 3721 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterRetransmission) { |
| 3719 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3722 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 3720 | 3723 |
| 3721 // Create a delegate which we expect to be called. | 3724 // Create a delegate which we expect to be called. |
| 3722 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); | 3725 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); |
| 3723 EXPECT_CALL(*delegate.get(), OnAckNotification(_, _, _, _, _)).Times(1); | 3726 EXPECT_CALL(*delegate.get(), OnAckNotification(_, _, _, _, _)).Times(1); |
| 3724 | 3727 |
| 3725 // Send four packets, and register to be notified on ACK of packet 2. | 3728 // Send four packets, and register to be notified on ACK of packet 2. |
| 3726 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); | 3729 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); |
| 3727 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, delegate.get()); | 3730 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, delegate.get()); |
| 3728 connection_.SendStreamDataWithString(3, "baz", 0, !kFin, NULL); | 3731 connection_.SendStreamDataWithString(3, "baz", 0, !kFin, nullptr); |
| 3729 connection_.SendStreamDataWithString(3, "qux", 0, !kFin, NULL); | 3732 connection_.SendStreamDataWithString(3, "qux", 0, !kFin, nullptr); |
| 3730 | 3733 |
| 3731 // Now we receive ACK for packets 1, 3, and 4 and lose 2. | 3734 // Now we receive ACK for packets 1, 3, and 4 and lose 2. |
| 3732 QuicAckFrame frame = InitAckFrame(4); | 3735 QuicAckFrame frame = InitAckFrame(4); |
| 3733 NackPacket(2, &frame); | 3736 NackPacket(2, &frame); |
| 3734 SequenceNumberSet lost_packets; | 3737 SequenceNumberSet lost_packets; |
| 3735 lost_packets.insert(2); | 3738 lost_packets.insert(2); |
| 3736 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | 3739 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
| 3737 .WillOnce(Return(lost_packets)); | 3740 .WillOnce(Return(lost_packets)); |
| 3738 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 3741 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 3739 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 3742 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3793 // previously nacked, even though the retransmission has a different | 3796 // previously nacked, even though the retransmission has a different |
| 3794 // sequence number. | 3797 // sequence number. |
| 3795 TEST_P(QuicConnectionTest, AckNotifierCallbackForAckOfNackedPacket) { | 3798 TEST_P(QuicConnectionTest, AckNotifierCallbackForAckOfNackedPacket) { |
| 3796 InSequence s; | 3799 InSequence s; |
| 3797 | 3800 |
| 3798 // Create a delegate which we expect to be called. | 3801 // Create a delegate which we expect to be called. |
| 3799 scoped_refptr<MockAckNotifierDelegate> delegate( | 3802 scoped_refptr<MockAckNotifierDelegate> delegate( |
| 3800 new StrictMock<MockAckNotifierDelegate>); | 3803 new StrictMock<MockAckNotifierDelegate>); |
| 3801 | 3804 |
| 3802 // Send four packets, and register to be notified on ACK of packet 2. | 3805 // Send four packets, and register to be notified on ACK of packet 2. |
| 3803 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); | 3806 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); |
| 3804 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, delegate.get()); | 3807 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, delegate.get()); |
| 3805 connection_.SendStreamDataWithString(3, "baz", 0, !kFin, NULL); | 3808 connection_.SendStreamDataWithString(3, "baz", 0, !kFin, nullptr); |
| 3806 connection_.SendStreamDataWithString(3, "qux", 0, !kFin, NULL); | 3809 connection_.SendStreamDataWithString(3, "qux", 0, !kFin, nullptr); |
| 3807 | 3810 |
| 3808 // Now we receive ACK for packets 1, 3, and 4 and lose 2. | 3811 // Now we receive ACK for packets 1, 3, and 4 and lose 2. |
| 3809 QuicAckFrame frame = InitAckFrame(4); | 3812 QuicAckFrame frame = InitAckFrame(4); |
| 3810 NackPacket(2, &frame); | 3813 NackPacket(2, &frame); |
| 3811 SequenceNumberSet lost_packets; | 3814 SequenceNumberSet lost_packets; |
| 3812 lost_packets.insert(2); | 3815 lost_packets.insert(2); |
| 3813 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3816 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 3814 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | 3817 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
| 3815 .WillOnce(Return(lost_packets)); | 3818 .WillOnce(Return(lost_packets)); |
| 3816 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 3819 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3837 TEST_P(QuicConnectionTest, AckNotifierFECTriggerCallback) { | 3840 TEST_P(QuicConnectionTest, AckNotifierFECTriggerCallback) { |
| 3838 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3841 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 3839 | 3842 |
| 3840 // Create a delegate which we expect to be called. | 3843 // Create a delegate which we expect to be called. |
| 3841 scoped_refptr<MockAckNotifierDelegate> delegate( | 3844 scoped_refptr<MockAckNotifierDelegate> delegate( |
| 3842 new MockAckNotifierDelegate); | 3845 new MockAckNotifierDelegate); |
| 3843 EXPECT_CALL(*delegate.get(), OnAckNotification(_, _, _, _, _)).Times(1); | 3846 EXPECT_CALL(*delegate.get(), OnAckNotification(_, _, _, _, _)).Times(1); |
| 3844 | 3847 |
| 3845 // Send some data, which will register the delegate to be notified. | 3848 // Send some data, which will register the delegate to be notified. |
| 3846 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get()); | 3849 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get()); |
| 3847 connection_.SendStreamDataWithString(2, "bar", 0, !kFin, NULL); | 3850 connection_.SendStreamDataWithString(2, "bar", 0, !kFin, nullptr); |
| 3848 | 3851 |
| 3849 // Process an ACK from the server with a revived packet, which should trigger | 3852 // Process an ACK from the server with a revived packet, which should trigger |
| 3850 // the callback. | 3853 // the callback. |
| 3851 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 3854 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 3852 QuicAckFrame frame = InitAckFrame(2); | 3855 QuicAckFrame frame = InitAckFrame(2); |
| 3853 NackPacket(1, &frame); | 3856 NackPacket(1, &frame); |
| 3854 frame.revived_packets.insert(1); | 3857 frame.revived_packets.insert(1); |
| 3855 ProcessAckPacket(&frame); | 3858 ProcessAckPacket(&frame); |
| 3856 // If the ack is processed again, the notifier should not be called again. | 3859 // If the ack is processed again, the notifier should not be called again. |
| 3857 ProcessAckPacket(&frame); | 3860 ProcessAckPacket(&frame); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4005 QuicBlockedFrame blocked; | 4008 QuicBlockedFrame blocked; |
| 4006 blocked.stream_id = 3; | 4009 blocked.stream_id = 3; |
| 4007 EXPECT_CALL(visitor_, OnBlockedFrames(_)); | 4010 EXPECT_CALL(visitor_, OnBlockedFrames(_)); |
| 4008 ProcessFramePacket(QuicFrame(&blocked)); | 4011 ProcessFramePacket(QuicFrame(&blocked)); |
| 4009 EXPECT_TRUE(ack_alarm->IsSet()); | 4012 EXPECT_TRUE(ack_alarm->IsSet()); |
| 4010 } | 4013 } |
| 4011 | 4014 |
| 4012 } // namespace | 4015 } // namespace |
| 4013 } // namespace test | 4016 } // namespace test |
| 4014 } // namespace net | 4017 } // namespace net |
| OLD | NEW |