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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 class TestConnection : public QuicConnection { | 400 class TestConnection : public QuicConnection { |
401 public: | 401 public: |
402 TestConnection(QuicConnectionId connection_id, | 402 TestConnection(QuicConnectionId connection_id, |
403 IPEndPoint address, | 403 IPEndPoint address, |
404 TestConnectionHelper* helper, | 404 TestConnectionHelper* helper, |
405 TestPacketWriter* writer, | 405 TestPacketWriter* writer, |
406 bool is_server, | 406 bool is_server, |
407 QuicVersion version) | 407 QuicVersion version) |
408 : QuicConnection(connection_id, address, helper, writer, is_server, | 408 : QuicConnection(connection_id, address, helper, writer, is_server, |
409 SupportedVersions(version)), | 409 SupportedVersions(version)), |
410 helper_(helper), | |
411 writer_(writer) { | 410 writer_(writer) { |
412 // Disable tail loss probes for most tests. | 411 // Disable tail loss probes for most tests. |
413 QuicSentPacketManagerPeer::SetMaxTailLossProbes( | 412 QuicSentPacketManagerPeer::SetMaxTailLossProbes( |
414 QuicConnectionPeer::GetSentPacketManager(this), 0); | 413 QuicConnectionPeer::GetSentPacketManager(this), 0); |
415 writer_->set_is_server(is_server); | 414 writer_->set_is_server(is_server); |
416 } | 415 } |
417 | 416 |
418 void SendAck() { | 417 void SendAck() { |
419 QuicConnectionPeer::SendAck(this); | 418 QuicConnectionPeer::SendAck(this); |
420 } | 419 } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 } | 524 } |
526 | 525 |
527 TestConnectionHelper::TestAlarm* GetTimeoutAlarm() { | 526 TestConnectionHelper::TestAlarm* GetTimeoutAlarm() { |
528 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( | 527 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( |
529 QuicConnectionPeer::GetTimeoutAlarm(this)); | 528 QuicConnectionPeer::GetTimeoutAlarm(this)); |
530 } | 529 } |
531 | 530 |
532 using QuicConnection::SelectMutualVersion; | 531 using QuicConnection::SelectMutualVersion; |
533 | 532 |
534 private: | 533 private: |
535 TestConnectionHelper* helper_; | |
536 TestPacketWriter* writer_; | 534 TestPacketWriter* writer_; |
537 | 535 |
538 DISALLOW_COPY_AND_ASSIGN(TestConnection); | 536 DISALLOW_COPY_AND_ASSIGN(TestConnection); |
539 }; | 537 }; |
540 | 538 |
541 class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> { | 539 class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> { |
542 protected: | 540 protected: |
543 QuicConnectionTest() | 541 QuicConnectionTest() |
544 : connection_id_(42), | 542 : connection_id_(42), |
545 framer_(SupportedVersions(version()), QuicTime::Zero(), false), | 543 framer_(SupportedVersions(version()), QuicTime::Zero(), false), |
(...skipping 17 matching lines...) Expand all Loading... |
563 *send_algorithm_, TimeUntilSend(_, _, _, _)).WillRepeatedly(Return( | 561 *send_algorithm_, TimeUntilSend(_, _, _, _)).WillRepeatedly(Return( |
564 QuicTime::Delta::Zero())); | 562 QuicTime::Delta::Zero())); |
565 EXPECT_CALL(*receive_algorithm_, | 563 EXPECT_CALL(*receive_algorithm_, |
566 RecordIncomingPacket(_, _, _)).Times(AnyNumber()); | 564 RecordIncomingPacket(_, _, _)).Times(AnyNumber()); |
567 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 565 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
568 .Times(AnyNumber()); | 566 .Times(AnyNumber()); |
569 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()).WillRepeatedly( | 567 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()).WillRepeatedly( |
570 Return(QuicTime::Delta::Zero())); | 568 Return(QuicTime::Delta::Zero())); |
571 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillRepeatedly(Return( | 569 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillRepeatedly(Return( |
572 QuicBandwidth::FromKBitsPerSecond(100))); | 570 QuicBandwidth::FromKBitsPerSecond(100))); |
573 EXPECT_CALL(*send_algorithm_, SmoothedRtt()).WillRepeatedly(Return( | |
574 QuicTime::Delta::FromMilliseconds(100))); | |
575 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 571 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
576 .WillByDefault(Return(true)); | 572 .WillByDefault(Return(true)); |
577 EXPECT_CALL(visitor_, HasPendingWrites()).Times(AnyNumber()); | 573 EXPECT_CALL(visitor_, HasPendingWrites()).Times(AnyNumber()); |
578 EXPECT_CALL(visitor_, HasPendingHandshake()).Times(AnyNumber()); | 574 EXPECT_CALL(visitor_, HasPendingHandshake()).Times(AnyNumber()); |
579 EXPECT_CALL(visitor_, OnCanWrite()).Times(AnyNumber()); | 575 EXPECT_CALL(visitor_, OnCanWrite()).Times(AnyNumber()); |
580 | 576 |
581 EXPECT_CALL(*loss_algorithm_, GetLossTimeout()) | 577 EXPECT_CALL(*loss_algorithm_, GetLossTimeout()) |
582 .WillRepeatedly(Return(QuicTime::Zero())); | 578 .WillRepeatedly(Return(QuicTime::Zero())); |
583 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) | 579 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
584 .WillRepeatedly(Return(SequenceNumberSet())); | 580 .WillRepeatedly(Return(SequenceNumberSet())); |
585 } | 581 } |
586 | 582 |
587 QuicVersion version() { | 583 QuicVersion version() { |
588 return GetParam(); | 584 return GetParam(); |
589 } | 585 } |
590 | 586 |
591 QuicAckFrame* outgoing_ack() { | 587 QuicAckFrame* outgoing_ack() { |
592 outgoing_ack_.reset(QuicConnectionPeer::CreateAckFrame(&connection_)); | 588 outgoing_ack_.reset(QuicConnectionPeer::CreateAckFrame(&connection_)); |
593 return outgoing_ack_.get(); | 589 return outgoing_ack_.get(); |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 | 1049 |
1054 QuicAckFrame frame = InitAckFrame(num_packets, 1); | 1050 QuicAckFrame frame = InitAckFrame(num_packets, 1); |
1055 SequenceNumberSet lost_packets; | 1051 SequenceNumberSet lost_packets; |
1056 // Create an ack with 256 nacks, none adjacent to one another. | 1052 // Create an ack with 256 nacks, none adjacent to one another. |
1057 for (QuicPacketSequenceNumber i = 1; i <= 256; ++i) { | 1053 for (QuicPacketSequenceNumber i = 1; i <= 256; ++i) { |
1058 NackPacket(i * 2, &frame); | 1054 NackPacket(i * 2, &frame); |
1059 if (i < 256) { // Last packet is nacked, but not lost. | 1055 if (i < 256) { // Last packet is nacked, but not lost. |
1060 lost_packets.insert(i * 2); | 1056 lost_packets.insert(i * 2); |
1061 } | 1057 } |
1062 } | 1058 } |
1063 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) | 1059 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
1064 .WillOnce(Return(lost_packets)); | 1060 .WillOnce(Return(lost_packets)); |
1065 EXPECT_CALL(entropy_calculator_, | 1061 EXPECT_CALL(entropy_calculator_, |
1066 EntropyHash(511)).WillOnce(testing::Return(0)); | 1062 EntropyHash(511)).WillOnce(testing::Return(0)); |
1067 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 1063 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
1068 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(256); | 1064 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(256); |
1069 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(255); | 1065 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(255); |
1070 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(255); | 1066 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(255); |
1071 ProcessAckPacket(&frame); | 1067 ProcessAckPacket(&frame); |
1072 | 1068 |
1073 QuicReceivedPacketManager* received_packet_manager = | 1069 QuicReceivedPacketManager* received_packet_manager = |
1074 QuicConnectionPeer::GetReceivedPacketManager(&connection_); | 1070 QuicConnectionPeer::GetReceivedPacketManager(&connection_); |
1075 // A truncated ack will not have the true largest observed. | 1071 // A truncated ack will not have the true largest observed. |
1076 EXPECT_GT(num_packets, | 1072 EXPECT_GT(num_packets, |
1077 received_packet_manager->peer_largest_observed_packet()); | 1073 received_packet_manager->peer_largest_observed_packet()); |
1078 | 1074 |
1079 AckPacket(192, &frame); | 1075 AckPacket(192, &frame); |
1080 | 1076 |
1081 // Removing one missing packet allows us to ack 192 and one more range, but | 1077 // Removing one missing packet allows us to ack 192 and one more range, but |
1082 // 192 has already been declared lost, so it doesn't register as an ack. | 1078 // 192 has already been declared lost, so it doesn't register as an ack. |
1083 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) | 1079 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
1084 .WillOnce(Return(SequenceNumberSet())); | 1080 .WillOnce(Return(SequenceNumberSet())); |
1085 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 1081 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
1086 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1); | 1082 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1); |
1087 ProcessAckPacket(&frame); | 1083 ProcessAckPacket(&frame); |
1088 EXPECT_EQ(num_packets, | 1084 EXPECT_EQ(num_packets, |
1089 received_packet_manager->peer_largest_observed_packet()); | 1085 received_packet_manager->peer_largest_observed_packet()); |
1090 } | 1086 } |
1091 | 1087 |
1092 TEST_P(QuicConnectionTest, AckReceiptCausesAckSendBadEntropy) { | 1088 TEST_P(QuicConnectionTest, AckReceiptCausesAckSendBadEntropy) { |
1093 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1089 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 QuicByteCount packet_size; | 1133 QuicByteCount packet_size; |
1138 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, _)) | 1134 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, _)) |
1139 .WillOnce(DoAll(SaveArg<1>(&original), SaveArg<2>(&packet_size), | 1135 .WillOnce(DoAll(SaveArg<1>(&original), SaveArg<2>(&packet_size), |
1140 Return(true))); | 1136 Return(true))); |
1141 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); | 1137 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); |
1142 QuicAckFrame frame = InitAckFrame(original, 1); | 1138 QuicAckFrame frame = InitAckFrame(original, 1); |
1143 NackPacket(original, &frame); | 1139 NackPacket(original, &frame); |
1144 // First nack triggers early retransmit. | 1140 // First nack triggers early retransmit. |
1145 SequenceNumberSet lost_packets; | 1141 SequenceNumberSet lost_packets; |
1146 lost_packets.insert(1); | 1142 lost_packets.insert(1); |
1147 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) | 1143 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
1148 .WillOnce(Return(lost_packets)); | 1144 .WillOnce(Return(lost_packets)); |
1149 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 1145 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
1150 EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)).Times(1); | 1146 EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)).Times(1); |
1151 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1); | 1147 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1); |
1152 QuicPacketSequenceNumber retransmission; | 1148 QuicPacketSequenceNumber retransmission; |
1153 EXPECT_CALL(*send_algorithm_, | 1149 EXPECT_CALL(*send_algorithm_, |
1154 OnPacketSent(_, _, packet_size - kQuicVersionSize, | 1150 OnPacketSent(_, _, packet_size - kQuicVersionSize, |
1155 NACK_RETRANSMISSION, _)) | 1151 NACK_RETRANSMISSION, _)) |
1156 .WillOnce(DoAll(SaveArg<1>(&retransmission), Return(true))); | 1152 .WillOnce(DoAll(SaveArg<1>(&retransmission), Return(true))); |
1157 | 1153 |
1158 ProcessAckPacket(&frame); | 1154 ProcessAckPacket(&frame); |
1159 | 1155 |
1160 QuicAckFrame frame2 = InitAckFrame(retransmission, 1); | 1156 QuicAckFrame frame2 = InitAckFrame(retransmission, 1); |
1161 NackPacket(original, &frame2); | 1157 NackPacket(original, &frame2); |
1162 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 1158 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
1163 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)); | 1159 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)); |
1164 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) | 1160 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
1165 .WillOnce(Return(SequenceNumberSet())); | 1161 .WillOnce(Return(SequenceNumberSet())); |
1166 ProcessAckPacket(&frame2); | 1162 ProcessAckPacket(&frame2); |
1167 | 1163 |
1168 // Now if the peer sends an ack which still reports the retransmitted packet | 1164 // Now if the peer sends an ack which still reports the retransmitted packet |
1169 // as missing, that will bundle an ack with data after two acks in a row | 1165 // as missing, that will bundle an ack with data after two acks in a row |
1170 // indicate the high water mark needs to be raised. | 1166 // indicate the high water mark needs to be raised. |
1171 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, | 1167 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, |
1172 HAS_RETRANSMITTABLE_DATA)); | 1168 HAS_RETRANSMITTABLE_DATA)); |
1173 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, NULL); | 1169 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, NULL); |
1174 // No ack sent. | 1170 // No ack sent. |
1175 EXPECT_EQ(1u, writer_->frame_count()); | 1171 EXPECT_EQ(1u, writer_->frame_count()); |
1176 EXPECT_EQ(1u, writer_->stream_frames()->size()); | 1172 EXPECT_EQ(1u, writer_->stream_frames()->size()); |
1177 writer_->Reset(); | 1173 writer_->Reset(); |
1178 | 1174 |
1179 // No more packet loss for the rest of the test. | 1175 // No more packet loss for the rest of the test. |
1180 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) | 1176 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
1181 .WillRepeatedly(Return(SequenceNumberSet())); | 1177 .WillRepeatedly(Return(SequenceNumberSet())); |
1182 ProcessAckPacket(&frame2); | 1178 ProcessAckPacket(&frame2); |
1183 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, | 1179 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, |
1184 HAS_RETRANSMITTABLE_DATA)); | 1180 HAS_RETRANSMITTABLE_DATA)); |
1185 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, NULL); | 1181 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, NULL); |
1186 // Ack bundled. | 1182 // Ack bundled. |
1187 if (version() > QUIC_VERSION_15) { | 1183 if (version() > QUIC_VERSION_15) { |
1188 EXPECT_EQ(3u, writer_->frame_count()); | 1184 EXPECT_EQ(3u, writer_->frame_count()); |
1189 } else { | 1185 } else { |
1190 EXPECT_EQ(2u, writer_->frame_count()); | 1186 EXPECT_EQ(2u, writer_->frame_count()); |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1550 connection_.SendStreamDataWithString(3, "foo", 6, !kFin, NULL); | 1546 connection_.SendStreamDataWithString(3, "foo", 6, !kFin, NULL); |
1551 | 1547 |
1552 QuicAckFrame ack_fec = InitAckFrame(5, 1); | 1548 QuicAckFrame ack_fec = InitAckFrame(5, 1); |
1553 // Ack all data packets, but no fec packets. | 1549 // Ack all data packets, but no fec packets. |
1554 NackPacket(2, &ack_fec); | 1550 NackPacket(2, &ack_fec); |
1555 NackPacket(4, &ack_fec); | 1551 NackPacket(4, &ack_fec); |
1556 | 1552 |
1557 // Lose the first FEC packet and ack the three data packets. | 1553 // Lose the first FEC packet and ack the three data packets. |
1558 SequenceNumberSet lost_packets; | 1554 SequenceNumberSet lost_packets; |
1559 lost_packets.insert(2); | 1555 lost_packets.insert(2); |
1560 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) | 1556 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
1561 .WillOnce(Return(lost_packets)); | 1557 .WillOnce(Return(lost_packets)); |
1562 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 1558 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
1563 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(3); | 1559 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(3); |
1564 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)); | 1560 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)); |
1565 EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _)); | 1561 EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _)); |
1566 ProcessAckPacket(&ack_fec); | 1562 ProcessAckPacket(&ack_fec); |
1567 | 1563 |
1568 clock_.AdvanceTime(DefaultRetransmissionTime().Subtract( | 1564 clock_.AdvanceTime(DefaultRetransmissionTime().Subtract( |
1569 QuicTime::Delta::FromMilliseconds(1))); | 1565 QuicTime::Delta::FromMilliseconds(1))); |
1570 | 1566 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1837 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 1833 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
1838 EXPECT_CALL(*send_algorithm_, OnPacketAcked(1, _)); | 1834 EXPECT_CALL(*send_algorithm_, OnPacketAcked(1, _)); |
1839 QuicAckFrame ack_one = InitAckFrame(1, 0); | 1835 QuicAckFrame ack_one = InitAckFrame(1, 0); |
1840 ProcessAckPacket(&ack_one); | 1836 ProcessAckPacket(&ack_one); |
1841 | 1837 |
1842 // Lose a packet and ensure it triggers retransmission. | 1838 // Lose a packet and ensure it triggers retransmission. |
1843 QuicAckFrame nack_two = InitAckFrame(3, 0); | 1839 QuicAckFrame nack_two = InitAckFrame(3, 0); |
1844 NackPacket(2, &nack_two); | 1840 NackPacket(2, &nack_two); |
1845 SequenceNumberSet lost_packets; | 1841 SequenceNumberSet lost_packets; |
1846 lost_packets.insert(2); | 1842 lost_packets.insert(2); |
1847 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) | 1843 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
1848 .WillOnce(Return(lost_packets)); | 1844 .WillOnce(Return(lost_packets)); |
1849 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 1845 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
1850 EXPECT_CALL(*send_algorithm_, OnPacketAcked(3, _)); | 1846 EXPECT_CALL(*send_algorithm_, OnPacketAcked(3, _)); |
1851 EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _)).Times(1); | 1847 EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _)).Times(1); |
1852 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)).Times(1); | 1848 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)).Times(1); |
1853 EXPECT_CALL(*send_algorithm_, | 1849 EXPECT_CALL(*send_algorithm_, |
1854 OnPacketSent(_, _, second_packet_size - kQuicVersionSize, | 1850 OnPacketSent(_, _, second_packet_size - kQuicVersionSize, |
1855 NACK_RETRANSMISSION, _)).Times(1); | 1851 NACK_RETRANSMISSION, _)).Times(1); |
1856 ProcessAckPacket(&nack_two); | 1852 ProcessAckPacket(&nack_two); |
1857 } | 1853 } |
1858 | 1854 |
1859 TEST_P(QuicConnectionTest, DiscardRetransmit) { | 1855 TEST_P(QuicConnectionTest, DiscardRetransmit) { |
1860 QuicPacketSequenceNumber last_packet; | 1856 QuicPacketSequenceNumber last_packet; |
1861 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1 | 1857 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1 |
1862 SendStreamDataToPeer(1, "foos", 3, !kFin, &last_packet); // Packet 2 | 1858 SendStreamDataToPeer(1, "foos", 3, !kFin, &last_packet); // Packet 2 |
1863 SendStreamDataToPeer(1, "fooos", 7, !kFin, &last_packet); // Packet 3 | 1859 SendStreamDataToPeer(1, "fooos", 7, !kFin, &last_packet); // Packet 3 |
1864 | 1860 |
1865 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1861 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1866 | 1862 |
1867 // Instigate a loss with an ack. | 1863 // Instigate a loss with an ack. |
1868 QuicAckFrame nack_two = InitAckFrame(3, 0); | 1864 QuicAckFrame nack_two = InitAckFrame(3, 0); |
1869 NackPacket(2, &nack_two); | 1865 NackPacket(2, &nack_two); |
1870 // The first nack should trigger a fast retransmission, but we'll be | 1866 // The first nack should trigger a fast retransmission, but we'll be |
1871 // write blocked, so the packet will be queued. | 1867 // write blocked, so the packet will be queued. |
1872 BlockOnNextWrite(); | 1868 BlockOnNextWrite(); |
1873 SequenceNumberSet lost_packets; | 1869 SequenceNumberSet lost_packets; |
1874 lost_packets.insert(2); | 1870 lost_packets.insert(2); |
1875 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) | 1871 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
1876 .WillOnce(Return(lost_packets)); | 1872 .WillOnce(Return(lost_packets)); |
1877 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 1873 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
1878 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(2); | 1874 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(2); |
1879 EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _)); | 1875 EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _)); |
1880 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)); | 1876 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)); |
1881 ProcessAckPacket(&nack_two); | 1877 ProcessAckPacket(&nack_two); |
1882 EXPECT_EQ(1u, connection_.NumQueuedPackets()); | 1878 EXPECT_EQ(1u, connection_.NumQueuedPackets()); |
1883 | 1879 |
1884 // Now, ack the previous transmission. | 1880 // Now, ack the previous transmission. |
1885 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) | 1881 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
1886 .WillOnce(Return(SequenceNumberSet())); | 1882 .WillOnce(Return(SequenceNumberSet())); |
1887 QuicAckFrame ack_all = InitAckFrame(3, 0); | 1883 QuicAckFrame ack_all = InitAckFrame(3, 0); |
1888 ProcessAckPacket(&ack_all); | 1884 ProcessAckPacket(&ack_all); |
1889 | 1885 |
1890 // Unblock the socket and attempt to send the queued packets. However, | 1886 // Unblock the socket and attempt to send the queued packets. However, |
1891 // since the previous transmission has been acked, we will not | 1887 // since the previous transmission has been acked, we will not |
1892 // send the retransmission. | 1888 // send the retransmission. |
1893 EXPECT_CALL(*send_algorithm_, | 1889 EXPECT_CALL(*send_algorithm_, |
1894 OnPacketSent(_, _, _, _, _)).Times(0); | 1890 OnPacketSent(_, _, _, _, _)).Times(0); |
1895 | 1891 |
(...skipping 10 matching lines...) Expand all Loading... |
1906 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, _)) | 1902 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, _)) |
1907 .WillOnce(DoAll(SaveArg<1>(&largest_observed), SaveArg<2>(&packet_size), | 1903 .WillOnce(DoAll(SaveArg<1>(&largest_observed), SaveArg<2>(&packet_size), |
1908 Return(true))); | 1904 Return(true))); |
1909 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); | 1905 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); |
1910 | 1906 |
1911 QuicAckFrame frame = InitAckFrame(1, largest_observed); | 1907 QuicAckFrame frame = InitAckFrame(1, largest_observed); |
1912 NackPacket(largest_observed, &frame); | 1908 NackPacket(largest_observed, &frame); |
1913 // The first nack should retransmit the largest observed packet. | 1909 // The first nack should retransmit the largest observed packet. |
1914 SequenceNumberSet lost_packets; | 1910 SequenceNumberSet lost_packets; |
1915 lost_packets.insert(1); | 1911 lost_packets.insert(1); |
1916 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) | 1912 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
1917 .WillOnce(Return(lost_packets)); | 1913 .WillOnce(Return(lost_packets)); |
1918 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 1914 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
1919 EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)).Times(1); | 1915 EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)).Times(1); |
1920 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1); | 1916 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1); |
1921 EXPECT_CALL(*send_algorithm_, | 1917 EXPECT_CALL(*send_algorithm_, |
1922 OnPacketSent(_, _, packet_size - kQuicVersionSize, | 1918 OnPacketSent(_, _, packet_size - kQuicVersionSize, |
1923 NACK_RETRANSMISSION, _)); | 1919 NACK_RETRANSMISSION, _)); |
1924 ProcessAckPacket(&frame); | 1920 ProcessAckPacket(&frame); |
1925 } | 1921 } |
1926 | 1922 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2030 // Ack 15, nack 1-14. | 2026 // Ack 15, nack 1-14. |
2031 SequenceNumberSet lost_packets; | 2027 SequenceNumberSet lost_packets; |
2032 QuicAckFrame nack = InitAckFrame(15, 0); | 2028 QuicAckFrame nack = InitAckFrame(15, 0); |
2033 for (int i = 1; i < 15; ++i) { | 2029 for (int i = 1; i < 15; ++i) { |
2034 NackPacket(i, &nack); | 2030 NackPacket(i, &nack); |
2035 lost_packets.insert(i); | 2031 lost_packets.insert(i); |
2036 } | 2032 } |
2037 | 2033 |
2038 // 14 packets have been NACK'd and lost. In TCP cubic, PRR limits | 2034 // 14 packets have been NACK'd and lost. In TCP cubic, PRR limits |
2039 // the retransmission rate in the case of burst losses. | 2035 // the retransmission rate in the case of burst losses. |
2040 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) | 2036 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
2041 .WillOnce(Return(lost_packets)); | 2037 .WillOnce(Return(lost_packets)); |
2042 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 2038 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
2043 EXPECT_CALL(*send_algorithm_, OnPacketAcked(15, _)).Times(1); | 2039 EXPECT_CALL(*send_algorithm_, OnPacketAcked(15, _)).Times(1); |
2044 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(14); | 2040 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(14); |
2045 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(14); | 2041 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(14); |
2046 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(14); | 2042 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(14); |
2047 ProcessAckPacket(&nack); | 2043 ProcessAckPacket(&nack); |
2048 } | 2044 } |
2049 | 2045 |
2050 // Test sending multiple acks from the connection to the session. | 2046 // Test sending multiple acks from the connection to the session. |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2394 connection_.GetRetransmissionAlarm()->Fire(); | 2390 connection_.GetRetransmissionAlarm()->Fire(); |
2395 EXPECT_FALSE(QuicConnectionPeer::IsSavedForRetransmission( | 2391 EXPECT_FALSE(QuicConnectionPeer::IsSavedForRetransmission( |
2396 &connection_, original_sequence_number)); | 2392 &connection_, original_sequence_number)); |
2397 ASSERT_TRUE(QuicConnectionPeer::IsSavedForRetransmission( | 2393 ASSERT_TRUE(QuicConnectionPeer::IsSavedForRetransmission( |
2398 &connection_, rto_sequence_number)); | 2394 &connection_, rto_sequence_number)); |
2399 EXPECT_TRUE(QuicConnectionPeer::IsRetransmission( | 2395 EXPECT_TRUE(QuicConnectionPeer::IsRetransmission( |
2400 &connection_, rto_sequence_number)); | 2396 &connection_, rto_sequence_number)); |
2401 // Once by explicit nack. | 2397 // Once by explicit nack. |
2402 SequenceNumberSet lost_packets; | 2398 SequenceNumberSet lost_packets; |
2403 lost_packets.insert(rto_sequence_number); | 2399 lost_packets.insert(rto_sequence_number); |
2404 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) | 2400 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
2405 .WillOnce(Return(lost_packets)); | 2401 .WillOnce(Return(lost_packets)); |
2406 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)).Times(1); | 2402 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)).Times(1); |
2407 EXPECT_CALL(*send_algorithm_, OnPacketLost(rto_sequence_number, _)).Times(1); | 2403 EXPECT_CALL(*send_algorithm_, OnPacketLost(rto_sequence_number, _)).Times(1); |
2408 EXPECT_CALL(*send_algorithm_, | 2404 EXPECT_CALL(*send_algorithm_, |
2409 OnPacketAbandoned(rto_sequence_number, _)).Times(1); | 2405 OnPacketAbandoned(rto_sequence_number, _)).Times(1); |
2410 QuicPacketSequenceNumber nack_sequence_number = 0; | 2406 QuicPacketSequenceNumber nack_sequence_number = 0; |
2411 // Ack packets might generate some other packets, which are not | 2407 // Ack packets might generate some other packets, which are not |
2412 // retransmissions. (More ack packets). | 2408 // retransmissions. (More ack packets). |
2413 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, _)) | 2409 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, _)) |
2414 .Times(AnyNumber()); | 2410 .Times(AnyNumber()); |
(...skipping 27 matching lines...) Expand all Loading... |
2442 } | 2438 } |
2443 | 2439 |
2444 TEST_P(QuicConnectionTest, DelayRTOWithAckReceipt) { | 2440 TEST_P(QuicConnectionTest, DelayRTOWithAckReceipt) { |
2445 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2441 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
2446 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, _)) | 2442 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, _)) |
2447 .Times(2); | 2443 .Times(2); |
2448 connection_.SendStreamDataWithString(2, "foo", 0, !kFin, NULL); | 2444 connection_.SendStreamDataWithString(2, "foo", 0, !kFin, NULL); |
2449 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, NULL); | 2445 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, NULL); |
2450 QuicAlarm* retransmission_alarm = connection_.GetRetransmissionAlarm(); | 2446 QuicAlarm* retransmission_alarm = connection_.GetRetransmissionAlarm(); |
2451 EXPECT_TRUE(retransmission_alarm->IsSet()); | 2447 EXPECT_TRUE(retransmission_alarm->IsSet()); |
| 2448 EXPECT_EQ(clock_.Now().Add(DefaultRetransmissionTime()), |
| 2449 retransmission_alarm->deadline()); |
2452 | 2450 |
2453 // Advance the time right before the RTO, then receive an ack for the first | 2451 // Advance the time right before the RTO, then receive an ack for the first |
2454 // packet to delay the RTO. | 2452 // packet to delay the RTO. |
2455 clock_.AdvanceTime(DefaultRetransmissionTime()); | 2453 clock_.AdvanceTime(DefaultRetransmissionTime()); |
2456 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 2454 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
2457 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1); | 2455 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1); |
2458 QuicAckFrame ack = InitAckFrame(1, 0); | 2456 QuicAckFrame ack = InitAckFrame(1, 0); |
2459 ProcessAckPacket(&ack); | 2457 ProcessAckPacket(&ack); |
2460 EXPECT_TRUE(retransmission_alarm->IsSet()); | 2458 EXPECT_TRUE(retransmission_alarm->IsSet()); |
| 2459 EXPECT_GT(retransmission_alarm->deadline(), clock_.Now()); |
2461 | 2460 |
2462 // Move forward past the original RTO and ensure the RTO is still pending. | 2461 // Move forward past the original RTO and ensure the RTO is still pending. |
2463 clock_.AdvanceTime(DefaultRetransmissionTime()); | 2462 clock_.AdvanceTime(DefaultRetransmissionTime().Multiply(2)); |
2464 | 2463 |
2465 // Ensure the second packet gets retransmitted when it finally fires. | 2464 // Ensure the second packet gets retransmitted when it finally fires. |
2466 EXPECT_TRUE(retransmission_alarm->IsSet()); | 2465 EXPECT_TRUE(retransmission_alarm->IsSet()); |
2467 EXPECT_LT(retransmission_alarm->deadline(), clock_.ApproximateNow()); | 2466 EXPECT_LT(retransmission_alarm->deadline(), clock_.ApproximateNow()); |
2468 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); | 2467 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); |
2469 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, RTO_RETRANSMISSION, _)); | 2468 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, RTO_RETRANSMISSION, _)); |
2470 // Manually cancel the alarm to simulate a real test. | 2469 // Manually cancel the alarm to simulate a real test. |
2471 connection_.GetRetransmissionAlarm()->Fire(); | 2470 connection_.GetRetransmissionAlarm()->Fire(); |
2472 | 2471 |
2473 // The new retransmitted sequence number should set the RTO to a larger value | 2472 // The new retransmitted sequence number should set the RTO to a larger value |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2911 | 2910 |
2912 TEST_P(QuicConnectionTest, BundleAckWithDataOnIncomingAck) { | 2911 TEST_P(QuicConnectionTest, BundleAckWithDataOnIncomingAck) { |
2913 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2912 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
2914 connection_.SendStreamDataWithString(kStreamId3, "foo", 0, !kFin, NULL); | 2913 connection_.SendStreamDataWithString(kStreamId3, "foo", 0, !kFin, NULL); |
2915 connection_.SendStreamDataWithString(kStreamId3, "foo", 3, !kFin, NULL); | 2914 connection_.SendStreamDataWithString(kStreamId3, "foo", 3, !kFin, NULL); |
2916 // Ack the second packet, which will retransmit the first packet. | 2915 // Ack the second packet, which will retransmit the first packet. |
2917 QuicAckFrame ack = InitAckFrame(2, 0); | 2916 QuicAckFrame ack = InitAckFrame(2, 0); |
2918 NackPacket(1, &ack); | 2917 NackPacket(1, &ack); |
2919 SequenceNumberSet lost_packets; | 2918 SequenceNumberSet lost_packets; |
2920 lost_packets.insert(1); | 2919 lost_packets.insert(1); |
2921 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) | 2920 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
2922 .WillOnce(Return(lost_packets)); | 2921 .WillOnce(Return(lost_packets)); |
2923 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 2922 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
2924 EXPECT_CALL(*send_algorithm_, OnPacketAcked(2, _)).Times(1); | 2923 EXPECT_CALL(*send_algorithm_, OnPacketAcked(2, _)).Times(1); |
2925 EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)).Times(1); | 2924 EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)).Times(1); |
2926 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1); | 2925 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1); |
2927 ProcessAckPacket(&ack); | 2926 ProcessAckPacket(&ack); |
2928 EXPECT_EQ(1u, writer_->frame_count()); | 2927 EXPECT_EQ(1u, writer_->frame_count()); |
2929 EXPECT_EQ(1u, writer_->stream_frames()->size()); | 2928 EXPECT_EQ(1u, writer_->stream_frames()->size()); |
2930 writer_->Reset(); | 2929 writer_->Reset(); |
2931 | 2930 |
2932 // Now ack the retransmission, which will both raise the high water mark | 2931 // Now ack the retransmission, which will both raise the high water mark |
2933 // and see if there is more data to send. | 2932 // and see if there is more data to send. |
2934 ack = InitAckFrame(3, 0); | 2933 ack = InitAckFrame(3, 0); |
2935 NackPacket(1, &ack); | 2934 NackPacket(1, &ack); |
2936 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) | 2935 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
2937 .WillOnce(Return(SequenceNumberSet())); | 2936 .WillOnce(Return(SequenceNumberSet())); |
2938 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 2937 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
2939 EXPECT_CALL(*send_algorithm_, OnPacketAcked(3, _)).Times(1); | 2938 EXPECT_CALL(*send_algorithm_, OnPacketAcked(3, _)).Times(1); |
2940 ProcessAckPacket(&ack); | 2939 ProcessAckPacket(&ack); |
2941 | 2940 |
2942 // Check that no packet is sent and the ack alarm isn't set. | 2941 // Check that no packet is sent and the ack alarm isn't set. |
2943 EXPECT_EQ(0u, writer_->frame_count()); | 2942 EXPECT_EQ(0u, writer_->frame_count()); |
2944 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 2943 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
2945 writer_->Reset(); | 2944 writer_->Reset(); |
2946 | 2945 |
2947 // Send the same ack, but send both data and an ack together. | 2946 // Send the same ack, but send both data and an ack together. |
2948 ack = InitAckFrame(3, 0); | 2947 ack = InitAckFrame(3, 0); |
2949 NackPacket(1, &ack); | 2948 NackPacket(1, &ack); |
2950 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) | 2949 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
2951 .WillOnce(Return(SequenceNumberSet())); | 2950 .WillOnce(Return(SequenceNumberSet())); |
2952 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce( | 2951 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce( |
2953 IgnoreResult(InvokeWithoutArgs( | 2952 IgnoreResult(InvokeWithoutArgs( |
2954 &connection_, | 2953 &connection_, |
2955 &TestConnection::EnsureWritableAndSendStreamData5))); | 2954 &TestConnection::EnsureWritableAndSendStreamData5))); |
2956 ProcessAckPacket(&ack); | 2955 ProcessAckPacket(&ack); |
2957 | 2956 |
2958 // Check that ack is bundled with outgoing data and the delayed ack | 2957 // Check that ack is bundled with outgoing data and the delayed ack |
2959 // alarm is reset. | 2958 // alarm is reset. |
2960 if (version() > QUIC_VERSION_15) { | 2959 if (version() > QUIC_VERSION_15) { |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3399 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10)); | 3398 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10)); |
3400 connection_.GetRetransmissionAlarm()->Fire(); | 3399 connection_.GetRetransmissionAlarm()->Fire(); |
3401 | 3400 |
3402 // Retransmit due to explicit nacks. | 3401 // Retransmit due to explicit nacks. |
3403 QuicAckFrame nack_three = InitAckFrame(4, 0); | 3402 QuicAckFrame nack_three = InitAckFrame(4, 0); |
3404 NackPacket(3, &nack_three); | 3403 NackPacket(3, &nack_three); |
3405 NackPacket(1, &nack_three); | 3404 NackPacket(1, &nack_three); |
3406 SequenceNumberSet lost_packets; | 3405 SequenceNumberSet lost_packets; |
3407 lost_packets.insert(1); | 3406 lost_packets.insert(1); |
3408 lost_packets.insert(3); | 3407 lost_packets.insert(3); |
3409 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) | 3408 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
3410 .WillOnce(Return(lost_packets)); | 3409 .WillOnce(Return(lost_packets)); |
3411 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 3410 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
3412 EXPECT_CALL(*send_algorithm_, OnPacketAcked(4, _)).Times(1); | 3411 EXPECT_CALL(*send_algorithm_, OnPacketAcked(4, _)).Times(1); |
3413 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(2); | 3412 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(2); |
3414 EXPECT_CALL(visitor_, OnCanWrite()).Times(2); | 3413 EXPECT_CALL(visitor_, OnCanWrite()).Times(2); |
3415 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3414 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3416 ProcessAckPacket(&nack_three); | 3415 ProcessAckPacket(&nack_three); |
3417 | 3416 |
3418 EXPECT_CALL(*send_algorithm_, SmoothedRtt()).WillOnce( | |
3419 Return(QuicTime::Delta::Zero())); | |
3420 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillOnce( | 3417 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillOnce( |
3421 Return(QuicBandwidth::Zero())); | 3418 Return(QuicBandwidth::Zero())); |
3422 | 3419 |
3423 const QuicConnectionStats& stats = connection_.GetStats(); | 3420 const QuicConnectionStats& stats = connection_.GetStats(); |
3424 EXPECT_EQ(3 * first_packet_size + 2 * second_packet_size - kQuicVersionSize, | 3421 EXPECT_EQ(3 * first_packet_size + 2 * second_packet_size - kQuicVersionSize, |
3425 stats.bytes_sent); | 3422 stats.bytes_sent); |
3426 EXPECT_EQ(5u, stats.packets_sent); | 3423 EXPECT_EQ(5u, stats.packets_sent); |
3427 EXPECT_EQ(2 * first_packet_size + second_packet_size - kQuicVersionSize, | 3424 EXPECT_EQ(2 * first_packet_size + second_packet_size - kQuicVersionSize, |
3428 stats.bytes_retransmitted); | 3425 stats.bytes_retransmitted); |
3429 EXPECT_EQ(3u, stats.packets_retransmitted); | 3426 EXPECT_EQ(3u, stats.packets_retransmitted); |
3430 EXPECT_EQ(1u, stats.rto_count); | 3427 EXPECT_EQ(1u, stats.rto_count); |
3431 } | 3428 } |
3432 | 3429 |
3433 TEST_P(QuicConnectionTest, CheckReceiveStats) { | 3430 TEST_P(QuicConnectionTest, CheckReceiveStats) { |
3434 if (version() < QUIC_VERSION_15) { | 3431 if (version() < QUIC_VERSION_15) { |
3435 return; | 3432 return; |
3436 } | 3433 } |
3437 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3434 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3438 | 3435 |
3439 size_t received_bytes = 0; | 3436 size_t received_bytes = 0; |
3440 received_bytes += ProcessFecProtectedPacket(1, false, !kEntropyFlag); | 3437 received_bytes += ProcessFecProtectedPacket(1, false, !kEntropyFlag); |
3441 received_bytes += ProcessFecProtectedPacket(3, false, !kEntropyFlag); | 3438 received_bytes += ProcessFecProtectedPacket(3, false, !kEntropyFlag); |
3442 // Should be counted against dropped packets. | 3439 // Should be counted against dropped packets. |
3443 received_bytes += ProcessDataPacket(3, 1, !kEntropyFlag); | 3440 received_bytes += ProcessDataPacket(3, 1, !kEntropyFlag); |
3444 received_bytes += ProcessFecPacket(4, 1, true, !kEntropyFlag, NULL); | 3441 received_bytes += ProcessFecPacket(4, 1, true, !kEntropyFlag, NULL); |
3445 | 3442 |
3446 EXPECT_CALL(*send_algorithm_, SmoothedRtt()).WillOnce( | |
3447 Return(QuicTime::Delta::Zero())); | |
3448 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillOnce( | 3443 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillOnce( |
3449 Return(QuicBandwidth::Zero())); | 3444 Return(QuicBandwidth::Zero())); |
3450 | 3445 |
3451 const QuicConnectionStats& stats = connection_.GetStats(); | 3446 const QuicConnectionStats& stats = connection_.GetStats(); |
3452 EXPECT_EQ(received_bytes, stats.bytes_received); | 3447 EXPECT_EQ(received_bytes, stats.bytes_received); |
3453 EXPECT_EQ(4u, stats.packets_received); | 3448 EXPECT_EQ(4u, stats.packets_received); |
3454 | 3449 |
3455 EXPECT_EQ(1u, stats.packets_revived); | 3450 EXPECT_EQ(1u, stats.packets_revived); |
3456 EXPECT_EQ(1u, stats.packets_dropped); | 3451 EXPECT_EQ(1u, stats.packets_dropped); |
3457 } | 3452 } |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3633 // Send some other data which we will ACK. | 3628 // Send some other data which we will ACK. |
3634 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); | 3629 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); |
3635 connection_.SendStreamDataWithString(1, "bar", 0, !kFin, NULL); | 3630 connection_.SendStreamDataWithString(1, "bar", 0, !kFin, NULL); |
3636 | 3631 |
3637 // Now we receive ACK for packets 2 and 3, but importantly missing packet 1 | 3632 // Now we receive ACK for packets 2 and 3, but importantly missing packet 1 |
3638 // which we registered to be notified about. | 3633 // which we registered to be notified about. |
3639 QuicAckFrame frame = InitAckFrame(3, 0); | 3634 QuicAckFrame frame = InitAckFrame(3, 0); |
3640 NackPacket(1, &frame); | 3635 NackPacket(1, &frame); |
3641 SequenceNumberSet lost_packets; | 3636 SequenceNumberSet lost_packets; |
3642 lost_packets.insert(1); | 3637 lost_packets.insert(1); |
3643 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) | 3638 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
3644 .WillOnce(Return(lost_packets)); | 3639 .WillOnce(Return(lost_packets)); |
3645 EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)); | 3640 EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)); |
3646 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)); | 3641 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)); |
3647 ProcessAckPacket(&frame); | 3642 ProcessAckPacket(&frame); |
3648 } | 3643 } |
3649 | 3644 |
3650 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterRetransmission) { | 3645 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterRetransmission) { |
3651 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3646 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3652 | 3647 |
3653 // Create a delegate which we expect to be called. | 3648 // Create a delegate which we expect to be called. |
3654 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); | 3649 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); |
3655 EXPECT_CALL(*delegate, OnAckNotification()).Times(1); | 3650 EXPECT_CALL(*delegate, OnAckNotification()).Times(1); |
3656 | 3651 |
3657 // Send four packets, and register to be notified on ACK of packet 2. | 3652 // Send four packets, and register to be notified on ACK of packet 2. |
3658 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); | 3653 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); |
3659 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, delegate.get()); | 3654 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, delegate.get()); |
3660 connection_.SendStreamDataWithString(3, "baz", 0, !kFin, NULL); | 3655 connection_.SendStreamDataWithString(3, "baz", 0, !kFin, NULL); |
3661 connection_.SendStreamDataWithString(3, "qux", 0, !kFin, NULL); | 3656 connection_.SendStreamDataWithString(3, "qux", 0, !kFin, NULL); |
3662 | 3657 |
3663 // Now we receive ACK for packets 1, 3, and 4 and lose 2. | 3658 // Now we receive ACK for packets 1, 3, and 4 and lose 2. |
3664 QuicAckFrame frame = InitAckFrame(4, 0); | 3659 QuicAckFrame frame = InitAckFrame(4, 0); |
3665 NackPacket(2, &frame); | 3660 NackPacket(2, &frame); |
3666 SequenceNumberSet lost_packets; | 3661 SequenceNumberSet lost_packets; |
3667 lost_packets.insert(2); | 3662 lost_packets.insert(2); |
3668 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) | 3663 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
3669 .WillOnce(Return(lost_packets)); | 3664 .WillOnce(Return(lost_packets)); |
3670 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 3665 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
3671 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(3); | 3666 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(3); |
3672 EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _)); | 3667 EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _)); |
3673 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)); | 3668 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)); |
3674 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 3669 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
3675 ProcessAckPacket(&frame); | 3670 ProcessAckPacket(&frame); |
3676 | 3671 |
3677 // Now we get an ACK for packet 5 (retransmitted packet 2), which should | 3672 // Now we get an ACK for packet 5 (retransmitted packet 2), which should |
3678 // trigger the callback. | 3673 // trigger the callback. |
3679 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _, _)) | 3674 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
3680 .WillRepeatedly(Return(SequenceNumberSet())); | 3675 .WillRepeatedly(Return(SequenceNumberSet())); |
3681 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); | 3676 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
3682 EXPECT_CALL(*send_algorithm_, OnPacketAcked(5, _)); | 3677 EXPECT_CALL(*send_algorithm_, OnPacketAcked(5, _)); |
3683 QuicAckFrame second_ack_frame = InitAckFrame(5, 0); | 3678 QuicAckFrame second_ack_frame = InitAckFrame(5, 0); |
3684 ProcessAckPacket(&second_ack_frame); | 3679 ProcessAckPacket(&second_ack_frame); |
3685 } | 3680 } |
3686 | 3681 |
3687 // TODO(rjshade): Add a similar test that FEC recovery on peer (and resulting | 3682 // TODO(rjshade): Add a similar test that FEC recovery on peer (and resulting |
3688 // ACK) triggers notification on our end. | 3683 // ACK) triggers notification on our end. |
3689 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterFECRecovery) { | 3684 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterFECRecovery) { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3830 QuicBlockedFrame blocked; | 3825 QuicBlockedFrame blocked; |
3831 blocked.stream_id = 3; | 3826 blocked.stream_id = 3; |
3832 EXPECT_CALL(visitor_, OnBlockedFrames(_)); | 3827 EXPECT_CALL(visitor_, OnBlockedFrames(_)); |
3833 ProcessFramePacket(QuicFrame(&blocked)); | 3828 ProcessFramePacket(QuicFrame(&blocked)); |
3834 EXPECT_TRUE(ack_alarm->IsSet()); | 3829 EXPECT_TRUE(ack_alarm->IsSet()); |
3835 } | 3830 } |
3836 | 3831 |
3837 } // namespace | 3832 } // namespace |
3838 } // namespace test | 3833 } // namespace test |
3839 } // namespace net | 3834 } // namespace net |
OLD | NEW |