Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: net/quic/quic_connection_test.cc

Issue 181693005: Test-only change to QuicConnectionTest to use MockLossAlgorithm instead (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "net/quic/congestion_control/loss_detection_interface.h"
11 #include "net/quic/congestion_control/receive_algorithm_interface.h" 12 #include "net/quic/congestion_control/receive_algorithm_interface.h"
12 #include "net/quic/congestion_control/send_algorithm_interface.h" 13 #include "net/quic/congestion_control/send_algorithm_interface.h"
13 #include "net/quic/crypto/null_encrypter.h" 14 #include "net/quic/crypto/null_encrypter.h"
14 #include "net/quic/crypto/quic_decrypter.h" 15 #include "net/quic/crypto/quic_decrypter.h"
15 #include "net/quic/crypto/quic_encrypter.h" 16 #include "net/quic/crypto/quic_encrypter.h"
16 #include "net/quic/quic_protocol.h" 17 #include "net/quic/quic_protocol.h"
17 #include "net/quic/quic_sent_packet_manager.h" 18 #include "net/quic/quic_sent_packet_manager.h"
18 #include "net/quic/quic_utils.h" 19 #include "net/quic/quic_utils.h"
19 #include "net/quic/test_tools/mock_clock.h" 20 #include "net/quic/test_tools/mock_clock.h"
20 #include "net/quic/test_tools/mock_random.h" 21 #include "net/quic/test_tools/mock_random.h"
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 } 420 }
420 421
421 void SetReceiveAlgorithm(TestReceiveAlgorithm* receive_algorithm) { 422 void SetReceiveAlgorithm(TestReceiveAlgorithm* receive_algorithm) {
422 QuicConnectionPeer::SetReceiveAlgorithm(this, receive_algorithm); 423 QuicConnectionPeer::SetReceiveAlgorithm(this, receive_algorithm);
423 } 424 }
424 425
425 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) { 426 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) {
426 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm); 427 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm);
427 } 428 }
428 429
430 void SetLossAlgorithm(LossDetectionInterface* loss_algorithm) {
431 QuicSentPacketManagerPeer::SetLossAlgorithm(
432 QuicConnectionPeer::GetSentPacketManager(this), loss_algorithm);
433 }
434
429 void SendPacket(EncryptionLevel level, 435 void SendPacket(EncryptionLevel level,
430 QuicPacketSequenceNumber sequence_number, 436 QuicPacketSequenceNumber sequence_number,
431 QuicPacket* packet, 437 QuicPacket* packet,
432 QuicPacketEntropyHash entropy_hash, 438 QuicPacketEntropyHash entropy_hash,
433 HasRetransmittableData retransmittable) { 439 HasRetransmittableData retransmittable) {
434 RetransmittableFrames* retransmittable_frames = 440 RetransmittableFrames* retransmittable_frames =
435 retransmittable == HAS_RETRANSMITTABLE_DATA ? 441 retransmittable == HAS_RETRANSMITTABLE_DATA ?
436 new RetransmittableFrames() : NULL; 442 new RetransmittableFrames() : NULL;
437 OnSerializedPacket( 443 OnSerializedPacket(
438 SerializedPacket(sequence_number, PACKET_6BYTE_SEQUENCE_NUMBER, 444 SerializedPacket(sequence_number, PACKET_6BYTE_SEQUENCE_NUMBER,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 DISALLOW_COPY_AND_ASSIGN(TestConnection); 538 DISALLOW_COPY_AND_ASSIGN(TestConnection);
533 }; 539 };
534 540
535 class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> { 541 class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
536 protected: 542 protected:
537 QuicConnectionTest() 543 QuicConnectionTest()
538 : guid_(42), 544 : guid_(42),
539 framer_(SupportedVersions(version()), QuicTime::Zero(), false), 545 framer_(SupportedVersions(version()), QuicTime::Zero(), false),
540 creator_(guid_, &framer_, &random_generator_, false), 546 creator_(guid_, &framer_, &random_generator_, false),
541 send_algorithm_(new StrictMock<MockSendAlgorithm>), 547 send_algorithm_(new StrictMock<MockSendAlgorithm>),
548 loss_algorithm_(NULL),
542 helper_(new TestConnectionHelper(&clock_, &random_generator_)), 549 helper_(new TestConnectionHelper(&clock_, &random_generator_)),
543 writer_(new TestPacketWriter(version())), 550 writer_(new TestPacketWriter(version())),
544 connection_(guid_, IPEndPoint(), helper_.get(), writer_.get(), 551 connection_(guid_, IPEndPoint(), helper_.get(), writer_.get(),
545 false, version()), 552 false, version()),
546 frame1_(1, false, 0, MakeIOVector(data1)), 553 frame1_(1, false, 0, MakeIOVector(data1)),
547 frame2_(1, false, 3, MakeIOVector(data2)), 554 frame2_(1, false, 3, MakeIOVector(data2)),
548 accept_packet_(true) { 555 accept_packet_(true) {
549 connection_.set_visitor(&visitor_); 556 connection_.set_visitor(&visitor_);
550 connection_.SetSendAlgorithm(send_algorithm_); 557 connection_.SetSendAlgorithm(send_algorithm_);
551 framer_.set_received_entropy_calculator(&entropy_calculator_); 558 framer_.set_received_entropy_calculator(&entropy_calculator_);
(...skipping 12 matching lines...) Expand all
564 QuicBandwidth::FromKBitsPerSecond(100))); 571 QuicBandwidth::FromKBitsPerSecond(100)));
565 EXPECT_CALL(*send_algorithm_, SmoothedRtt()).WillRepeatedly(Return( 572 EXPECT_CALL(*send_algorithm_, SmoothedRtt()).WillRepeatedly(Return(
566 QuicTime::Delta::FromMilliseconds(100))); 573 QuicTime::Delta::FromMilliseconds(100)));
567 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 574 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
568 .WillByDefault(Return(true)); 575 .WillByDefault(Return(true));
569 EXPECT_CALL(visitor_, HasPendingWrites()).Times(AnyNumber()); 576 EXPECT_CALL(visitor_, HasPendingWrites()).Times(AnyNumber());
570 EXPECT_CALL(visitor_, HasPendingHandshake()).Times(AnyNumber()); 577 EXPECT_CALL(visitor_, HasPendingHandshake()).Times(AnyNumber());
571 EXPECT_CALL(visitor_, OnCanWrite()).Times(AnyNumber()); 578 EXPECT_CALL(visitor_, OnCanWrite()).Times(AnyNumber());
572 } 579 }
573 580
581 void SetUpMockLossAlgorithm() {
582 loss_algorithm_ = new MockLossAlgorithm();
583 connection_.SetLossAlgorithm(loss_algorithm_);
584 EXPECT_CALL(*loss_algorithm_, GetLossTimeout())
585 .WillRepeatedly(Return(QuicTime::Zero()));
586 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
587 .WillRepeatedly(Return(SequenceNumberSet()));
588 }
589
574 QuicVersion version() { 590 QuicVersion version() {
575 return GetParam(); 591 return GetParam();
576 } 592 }
577 593
578 QuicAckFrame* outgoing_ack() { 594 QuicAckFrame* outgoing_ack() {
579 outgoing_ack_.reset(QuicConnectionPeer::CreateAckFrame(&connection_)); 595 outgoing_ack_.reset(QuicConnectionPeer::CreateAckFrame(&connection_));
580 return outgoing_ack_.get(); 596 return outgoing_ack_.get();
581 } 597 }
582 598
583 QuicPacketSequenceNumber least_unacked() { 599 QuicPacketSequenceNumber least_unacked() {
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 writer_->BlockOnNextWrite(); 911 writer_->BlockOnNextWrite();
896 EXPECT_CALL(visitor_, OnWriteBlocked()).Times(AtLeast(1)); 912 EXPECT_CALL(visitor_, OnWriteBlocked()).Times(AtLeast(1));
897 } 913 }
898 914
899 QuicGuid guid_; 915 QuicGuid guid_;
900 QuicFramer framer_; 916 QuicFramer framer_;
901 QuicPacketCreator creator_; 917 QuicPacketCreator creator_;
902 MockEntropyCalculator entropy_calculator_; 918 MockEntropyCalculator entropy_calculator_;
903 919
904 MockSendAlgorithm* send_algorithm_; 920 MockSendAlgorithm* send_algorithm_;
921 MockLossAlgorithm* loss_algorithm_;
905 TestReceiveAlgorithm* receive_algorithm_; 922 TestReceiveAlgorithm* receive_algorithm_;
906 MockClock clock_; 923 MockClock clock_;
907 MockRandom random_generator_; 924 MockRandom random_generator_;
908 scoped_ptr<TestConnectionHelper> helper_; 925 scoped_ptr<TestConnectionHelper> helper_;
909 scoped_ptr<TestPacketWriter> writer_; 926 scoped_ptr<TestPacketWriter> writer_;
910 TestConnection connection_; 927 TestConnection connection_;
911 StrictMock<MockConnectionVisitor> visitor_; 928 StrictMock<MockConnectionVisitor> visitor_;
912 929
913 QuicPacketHeader header_; 930 QuicPacketHeader header_;
914 QuicStreamFrame frame1_; 931 QuicStreamFrame frame1_;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 ProcessPacket(1); 1119 ProcessPacket(1);
1103 // Should ack immediately, since this fills the last hole. 1120 // Should ack immediately, since this fills the last hole.
1104 EXPECT_EQ(3u, writer_->packets_write_attempts()); 1121 EXPECT_EQ(3u, writer_->packets_write_attempts());
1105 1122
1106 ProcessPacket(4); 1123 ProcessPacket(4);
1107 // Should not cause an ack. 1124 // Should not cause an ack.
1108 EXPECT_EQ(3u, writer_->packets_write_attempts()); 1125 EXPECT_EQ(3u, writer_->packets_write_attempts());
1109 } 1126 }
1110 1127
1111 TEST_P(QuicConnectionTest, AckReceiptCausesAckSend) { 1128 TEST_P(QuicConnectionTest, AckReceiptCausesAckSend) {
1129 SetUpMockLossAlgorithm();
1112 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 1130 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1113 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(1); 1131
1114 QuicPacketSequenceNumber original; 1132 QuicPacketSequenceNumber original;
1115 QuicByteCount packet_size; 1133 QuicByteCount packet_size;
1116 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, _)) 1134 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, _))
1117 .WillOnce(DoAll(SaveArg<1>(&original), SaveArg<2>(&packet_size), 1135 .WillOnce(DoAll(SaveArg<1>(&original), SaveArg<2>(&packet_size),
1118 Return(true))); 1136 Return(true)));
1119 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1);
1120 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); 1137 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL);
1121 QuicAckFrame frame = InitAckFrame(original, 1); 1138 QuicAckFrame frame = InitAckFrame(original, 1);
1122 NackPacket(original, &frame); 1139 NackPacket(original, &frame);
1123 // First nack triggers early retransmit. 1140 // First nack triggers early retransmit.
1141 SequenceNumberSet lost_packets;
1142 lost_packets.insert(1);
1143 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
1144 .WillOnce(Return(lost_packets));
1124 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); 1145 EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
1146 EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)).Times(1);
1147 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1);
1125 QuicPacketSequenceNumber retransmission; 1148 QuicPacketSequenceNumber retransmission;
1126 EXPECT_CALL(*send_algorithm_, 1149 EXPECT_CALL(*send_algorithm_,
1127 OnPacketSent(_, _, packet_size - kQuicVersionSize, 1150 OnPacketSent(_, _, packet_size - kQuicVersionSize,
1128 NACK_RETRANSMISSION, _)) 1151 NACK_RETRANSMISSION, _))
1129 .WillOnce(DoAll(SaveArg<1>(&retransmission), Return(true))); 1152 .WillOnce(DoAll(SaveArg<1>(&retransmission), Return(true)));
1130 1153
1131 ProcessAckPacket(&frame); 1154 ProcessAckPacket(&frame);
1132 1155
1133 QuicAckFrame frame2 = InitAckFrame(retransmission, 1); 1156 QuicAckFrame frame2 = InitAckFrame(retransmission, 1);
1134 NackPacket(original, &frame2); 1157 NackPacket(original, &frame2);
1135 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); 1158 EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
1136 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)); 1159 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _));
1160 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
1161 .WillOnce(Return(SequenceNumberSet()));
1137 ProcessAckPacket(&frame2); 1162 ProcessAckPacket(&frame2);
1138 1163
1139 // 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
1140 // 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
1141 // indicate the high water mark needs to be raised. 1166 // indicate the high water mark needs to be raised.
1142 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, 1167 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION,
1143 HAS_RETRANSMITTABLE_DATA)); 1168 HAS_RETRANSMITTABLE_DATA));
1144 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, NULL); 1169 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, NULL);
1145 // No ack sent. 1170 // No ack sent.
1146 EXPECT_EQ(1u, writer_->frame_count()); 1171 EXPECT_EQ(1u, writer_->frame_count());
1147 EXPECT_EQ(1u, writer_->stream_frames()->size()); 1172 EXPECT_EQ(1u, writer_->stream_frames()->size());
1148 writer_->Reset(); 1173 writer_->Reset();
1149 1174
1175 // No more packet loss for the rest of the test.
1176 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
1177 .WillRepeatedly(Return(SequenceNumberSet()));
1150 ProcessAckPacket(&frame2); 1178 ProcessAckPacket(&frame2);
1151 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, 1179 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION,
1152 HAS_RETRANSMITTABLE_DATA)); 1180 HAS_RETRANSMITTABLE_DATA));
1153 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, NULL); 1181 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, NULL);
1154 // Ack bundled. 1182 // Ack bundled.
1155 if (version() > QUIC_VERSION_15) { 1183 if (version() > QUIC_VERSION_15) {
1156 EXPECT_EQ(3u, writer_->frame_count()); 1184 EXPECT_EQ(3u, writer_->frame_count());
1157 } else { 1185 } else {
1158 EXPECT_EQ(2u, writer_->frame_count()); 1186 EXPECT_EQ(2u, writer_->frame_count());
1159 } 1187 }
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
1781 1809
1782 // Parse the last packet and ensure it's the two stream frames from 1810 // Parse the last packet and ensure it's the two stream frames from
1783 // two different streams. 1811 // two different streams.
1784 EXPECT_EQ(2u, writer_->frame_count()); 1812 EXPECT_EQ(2u, writer_->frame_count());
1785 EXPECT_EQ(2u, writer_->stream_frames()->size()); 1813 EXPECT_EQ(2u, writer_->stream_frames()->size());
1786 EXPECT_EQ(kStreamId3, (*writer_->stream_frames())[0].stream_id); 1814 EXPECT_EQ(kStreamId3, (*writer_->stream_frames())[0].stream_id);
1787 EXPECT_EQ(kStreamId5, (*writer_->stream_frames())[1].stream_id); 1815 EXPECT_EQ(kStreamId5, (*writer_->stream_frames())[1].stream_id);
1788 } 1816 }
1789 1817
1790 TEST_P(QuicConnectionTest, RetransmitOnNack) { 1818 TEST_P(QuicConnectionTest, RetransmitOnNack) {
1791 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); 1819 SetUpMockLossAlgorithm();
1792 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _));
1793 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(1);
1794 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)).Times(1);
1795 QuicPacketSequenceNumber last_packet; 1820 QuicPacketSequenceNumber last_packet;
1796 QuicByteCount second_packet_size; 1821 QuicByteCount second_packet_size;
1797 SendStreamDataToPeer(3, "foo", 0, !kFin, &last_packet); // Packet 1 1822 SendStreamDataToPeer(3, "foo", 0, !kFin, &last_packet); // Packet 1
1798 second_packet_size = 1823 second_packet_size =
1799 SendStreamDataToPeer(3, "foos", 3, !kFin, &last_packet); // Packet 2 1824 SendStreamDataToPeer(3, "foos", 3, !kFin, &last_packet); // Packet 2
1800 SendStreamDataToPeer(3, "fooos", 7, !kFin, &last_packet); // Packet 3 1825 SendStreamDataToPeer(3, "fooos", 7, !kFin, &last_packet); // Packet 3
1801 1826
1802 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 1827 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1803 1828
1804 // Peer acks one but not two or three. Right now we only retransmit on 1829 // Don't lose a packet on an ack, and nothing is retransmitted.
1805 // explicit nack, so it should not trigger a retransmission. 1830 EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
1831 EXPECT_CALL(*send_algorithm_, OnPacketAcked(1, _));
1806 QuicAckFrame ack_one = InitAckFrame(1, 0); 1832 QuicAckFrame ack_one = InitAckFrame(1, 0);
1807 ProcessAckPacket(&ack_one); 1833 ProcessAckPacket(&ack_one);
1808 ProcessAckPacket(&ack_one);
1809 ProcessAckPacket(&ack_one);
1810 1834
1811 // Peer acks up to 3 with two explicitly missing. 1835 // Lose a packet and ensure it triggers retransmission.
1812 // Early retransmit causes 2 to be retransmitted on the first ack.
1813 QuicAckFrame nack_two = InitAckFrame(3, 0); 1836 QuicAckFrame nack_two = InitAckFrame(3, 0);
1814 NackPacket(2, &nack_two); 1837 NackPacket(2, &nack_two);
1815 // The third nack should trigger a retransmission. 1838 SequenceNumberSet lost_packets;
1839 lost_packets.insert(2);
1840 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
1841 .WillOnce(Return(lost_packets));
1816 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); 1842 EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
1817 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)); 1843 EXPECT_CALL(*send_algorithm_, OnPacketAcked(3, _));
1844 EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _)).Times(1);
1845 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)).Times(1);
1818 EXPECT_CALL(*send_algorithm_, 1846 EXPECT_CALL(*send_algorithm_,
1819 OnPacketSent(_, _, second_packet_size - kQuicVersionSize, 1847 OnPacketSent(_, _, second_packet_size - kQuicVersionSize,
1820 NACK_RETRANSMISSION, _)).Times(1); 1848 NACK_RETRANSMISSION, _)).Times(1);
1821 ProcessAckPacket(&nack_two); 1849 ProcessAckPacket(&nack_two);
1822 } 1850 }
1823 1851
1824 TEST_P(QuicConnectionTest, DiscardRetransmit) { 1852 TEST_P(QuicConnectionTest, DiscardRetransmit) {
1825 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); 1853 SetUpMockLossAlgorithm();
1826 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _));
1827 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(1);
1828 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)).Times(1);
1829 QuicPacketSequenceNumber last_packet; 1854 QuicPacketSequenceNumber last_packet;
1830 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1 1855 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1
1831 SendStreamDataToPeer(1, "foos", 3, !kFin, &last_packet); // Packet 2 1856 SendStreamDataToPeer(1, "foos", 3, !kFin, &last_packet); // Packet 2
1832 SendStreamDataToPeer(1, "fooos", 7, !kFin, &last_packet); // Packet 3 1857 SendStreamDataToPeer(1, "fooos", 7, !kFin, &last_packet); // Packet 3
1833 1858
1834 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 1859 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1835 1860
1836 // Peer acks one but not two or three. Right now we only retransmit on 1861 // Instigate a loss with an ack.
1837 // explicit nack, so it should not trigger a retransmission.
1838 QuicAckFrame ack_one = InitAckFrame(1, 0);
1839 ProcessAckPacket(&ack_one);
1840 ProcessAckPacket(&ack_one);
1841 ProcessAckPacket(&ack_one);
1842
1843 // Peer acks up to 3 with two explicitly missing. Two nacks should cause no
1844 // change.
1845 QuicAckFrame nack_two = InitAckFrame(3, 0); 1862 QuicAckFrame nack_two = InitAckFrame(3, 0);
1846 NackPacket(2, &nack_two); 1863 NackPacket(2, &nack_two);
1847 // The first nack should trigger a fast retransmission, but we'll be 1864 // The first nack should trigger a fast retransmission, but we'll be
1848 // write blocked, so the packet will be queued. 1865 // write blocked, so the packet will be queued.
1849 BlockOnNextWrite(); 1866 BlockOnNextWrite();
1867 SequenceNumberSet lost_packets;
1868 lost_packets.insert(2);
1869 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
1870 .WillOnce(Return(lost_packets));
1850 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); 1871 EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
1851 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)); 1872 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(2);
1873 EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _));
1874 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _));
1852 ProcessAckPacket(&nack_two); 1875 ProcessAckPacket(&nack_two);
1853 EXPECT_EQ(1u, connection_.NumQueuedPackets()); 1876 EXPECT_EQ(1u, connection_.NumQueuedPackets());
1854 1877
1855 // Now, ack the previous transmission. 1878 // Now, ack the previous transmission.
1879 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
1880 .WillOnce(Return(SequenceNumberSet()));
1856 QuicAckFrame ack_all = InitAckFrame(3, 0); 1881 QuicAckFrame ack_all = InitAckFrame(3, 0);
1857 ProcessAckPacket(&ack_all); 1882 ProcessAckPacket(&ack_all);
1858 1883
1859 // Unblock the socket and attempt to send the queued packets. However, 1884 // Unblock the socket and attempt to send the queued packets. However,
1860 // since the previous transmission has been acked, we will not 1885 // since the previous transmission has been acked, we will not
1861 // send the retransmission. 1886 // send the retransmission.
1862 EXPECT_CALL(*send_algorithm_, 1887 EXPECT_CALL(*send_algorithm_,
1863 OnPacketSent(_, _, _, _, _)).Times(0); 1888 OnPacketSent(_, _, _, _, _)).Times(0);
1864 1889
1865 writer_->SetWritable(); 1890 writer_->SetWritable();
1866 connection_.OnCanWrite(); 1891 connection_.OnCanWrite();
1867 1892
1868 EXPECT_EQ(0u, connection_.NumQueuedPackets()); 1893 EXPECT_EQ(0u, connection_.NumQueuedPackets());
1869 } 1894 }
1870 1895
1871 TEST_P(QuicConnectionTest, RetransmitNackedLargestObserved) { 1896 TEST_P(QuicConnectionTest, RetransmitNackedLargestObserved) {
1897 SetUpMockLossAlgorithm();
1872 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 1898 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1873 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(1);
1874 QuicPacketSequenceNumber largest_observed; 1899 QuicPacketSequenceNumber largest_observed;
1875 QuicByteCount packet_size; 1900 QuicByteCount packet_size;
1876 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, _)) 1901 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, _))
1877 .WillOnce(DoAll(SaveArg<1>(&largest_observed), SaveArg<2>(&packet_size), 1902 .WillOnce(DoAll(SaveArg<1>(&largest_observed), SaveArg<2>(&packet_size),
1878 Return(true))); 1903 Return(true)));
1879 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1);
1880 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); 1904 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL);
1905
1881 QuicAckFrame frame = InitAckFrame(1, largest_observed); 1906 QuicAckFrame frame = InitAckFrame(1, largest_observed);
1882 NackPacket(largest_observed, &frame); 1907 NackPacket(largest_observed, &frame);
1883 // The first nack should retransmit the largest observed packet. 1908 // The first nack should retransmit the largest observed packet.
1909 SequenceNumberSet lost_packets;
1910 lost_packets.insert(1);
1911 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
1912 .WillOnce(Return(lost_packets));
1884 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); 1913 EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
1914 EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)).Times(1);
1915 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1);
1885 EXPECT_CALL(*send_algorithm_, 1916 EXPECT_CALL(*send_algorithm_,
1886 OnPacketSent(_, _, packet_size - kQuicVersionSize, 1917 OnPacketSent(_, _, packet_size - kQuicVersionSize,
1887 NACK_RETRANSMISSION, _)); 1918 NACK_RETRANSMISSION, _));
1888 ProcessAckPacket(&frame); 1919 ProcessAckPacket(&frame);
1889 } 1920 }
1890 1921
1891 TEST_P(QuicConnectionTest, QueueAfterTwoRTOs) { 1922 TEST_P(QuicConnectionTest, QueueAfterTwoRTOs) {
1892 for (int i = 0; i < 10; ++i) { 1923 for (int i = 0; i < 10; ++i) {
1893 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); 1924 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
1894 connection_.SendStreamDataWithString(3, "foo", i * 3, !kFin, NULL); 1925 connection_.SendStreamDataWithString(3, "foo", i * 3, !kFin, NULL);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 // attempt to write. 2007 // attempt to write.
1977 connection_.GetResumeWritesAlarm()->Set(clock_.ApproximateNow()); 2008 connection_.GetResumeWritesAlarm()->Set(clock_.ApproximateNow());
1978 connection_.GetSendAlarm()->Set(clock_.ApproximateNow()); 2009 connection_.GetSendAlarm()->Set(clock_.ApproximateNow());
1979 connection_.GetResumeWritesAlarm()->Fire(); 2010 connection_.GetResumeWritesAlarm()->Fire();
1980 connection_.GetSendAlarm()->Fire(); 2011 connection_.GetSendAlarm()->Fire();
1981 EXPECT_TRUE(writer_->IsWriteBlocked()); 2012 EXPECT_TRUE(writer_->IsWriteBlocked());
1982 EXPECT_EQ(1u, writer_->packets_write_attempts()); 2013 EXPECT_EQ(1u, writer_->packets_write_attempts());
1983 } 2014 }
1984 2015
1985 TEST_P(QuicConnectionTest, NoLimitPacketsPerNack) { 2016 TEST_P(QuicConnectionTest, NoLimitPacketsPerNack) {
2017 SetUpMockLossAlgorithm();
1986 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 2018 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1987 int offset = 0; 2019 int offset = 0;
1988 // Send packets 1 to 15. 2020 // Send packets 1 to 15.
1989 for (int i = 0; i < 15; ++i) { 2021 for (int i = 0; i < 15; ++i) {
1990 SendStreamDataToPeer(1, "foo", offset, !kFin, NULL); 2022 SendStreamDataToPeer(1, "foo", offset, !kFin, NULL);
1991 offset += 3; 2023 offset += 3;
1992 } 2024 }
1993 2025
1994 // Ack 15, nack 1-14. 2026 // Ack 15, nack 1-14.
2027 SequenceNumberSet lost_packets;
1995 QuicAckFrame nack = InitAckFrame(15, 0); 2028 QuicAckFrame nack = InitAckFrame(15, 0);
1996 for (int i = 1; i < 15; ++i) { 2029 for (int i = 1; i < 15; ++i) {
1997 NackPacket(i, &nack); 2030 NackPacket(i, &nack);
2031 lost_packets.insert(i);
1998 } 2032 }
1999 2033
2000 // 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
2001 // the retransmission rate in the case of burst losses. 2035 // the retransmission rate in the case of burst losses.
2036 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
2037 .WillOnce(Return(lost_packets));
2002 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); 2038 EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
2003 EXPECT_CALL(*send_algorithm_, OnPacketAcked(15, _)).Times(1); 2039 EXPECT_CALL(*send_algorithm_, OnPacketAcked(15, _)).Times(1);
2004 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(14); 2040 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(14);
2005 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(14); 2041 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(14);
2006 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(14); 2042 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(14);
2007 ProcessAckPacket(&nack); 2043 ProcessAckPacket(&nack);
2008 } 2044 }
2009 2045
2010 // Test sending multiple acks from the connection to the session. 2046 // Test sending multiple acks from the connection to the session.
2011 TEST_P(QuicConnectionTest, MultipleAcks) { 2047 TEST_P(QuicConnectionTest, MultipleAcks) {
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
2860 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 2896 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2861 ProcessPacket(1); 2897 ProcessPacket(1);
2862 connection_.SendStreamDataWithString(kCryptoStreamId, "foo", 0, !kFin, NULL); 2898 connection_.SendStreamDataWithString(kCryptoStreamId, "foo", 0, !kFin, NULL);
2863 // Check that ack is not bundled with outgoing data. 2899 // Check that ack is not bundled with outgoing data.
2864 EXPECT_EQ(1u, writer_->frame_count()); 2900 EXPECT_EQ(1u, writer_->frame_count());
2865 EXPECT_FALSE(writer_->ack()); 2901 EXPECT_FALSE(writer_->ack());
2866 EXPECT_TRUE(connection_.GetAckAlarm()->IsSet()); 2902 EXPECT_TRUE(connection_.GetAckAlarm()->IsSet());
2867 } 2903 }
2868 2904
2869 TEST_P(QuicConnectionTest, BundleAckWithDataOnIncomingAck) { 2905 TEST_P(QuicConnectionTest, BundleAckWithDataOnIncomingAck) {
2906 SetUpMockLossAlgorithm();
2870 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 2907 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2871 connection_.SendStreamDataWithString(kStreamId3, "foo", 0, !kFin, NULL); 2908 connection_.SendStreamDataWithString(kStreamId3, "foo", 0, !kFin, NULL);
2872 connection_.SendStreamDataWithString(kStreamId3, "foo", 3, !kFin, NULL); 2909 connection_.SendStreamDataWithString(kStreamId3, "foo", 3, !kFin, NULL);
2873 // Ack the second packet, which will retransmit the first packet. 2910 // Ack the second packet, which will retransmit the first packet.
2874 QuicAckFrame ack = InitAckFrame(2, 0); 2911 QuicAckFrame ack = InitAckFrame(2, 0);
2875 NackPacket(1, &ack); 2912 NackPacket(1, &ack);
2913 SequenceNumberSet lost_packets;
2914 lost_packets.insert(1);
2915 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
2916 .WillOnce(Return(lost_packets));
2876 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); 2917 EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
2877 EXPECT_CALL(*send_algorithm_, OnPacketAcked(2, _)).Times(1); 2918 EXPECT_CALL(*send_algorithm_, OnPacketAcked(2, _)).Times(1);
2878 EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)).Times(1); 2919 EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)).Times(1);
2879 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1); 2920 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1);
2880 ProcessAckPacket(&ack); 2921 ProcessAckPacket(&ack);
2881 EXPECT_EQ(1u, writer_->frame_count()); 2922 EXPECT_EQ(1u, writer_->frame_count());
2882 EXPECT_EQ(1u, writer_->stream_frames()->size()); 2923 EXPECT_EQ(1u, writer_->stream_frames()->size());
2883 writer_->Reset(); 2924 writer_->Reset();
2884 2925
2885 // Now ack the retransmission, which will both raise the high water mark 2926 // Now ack the retransmission, which will both raise the high water mark
2886 // and see if there is more data to send. 2927 // and see if there is more data to send.
2887 ack = InitAckFrame(3, 0); 2928 ack = InitAckFrame(3, 0);
2888 NackPacket(1, &ack); 2929 NackPacket(1, &ack);
2930 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
2931 .WillOnce(Return(SequenceNumberSet()));
2889 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); 2932 EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
2890 EXPECT_CALL(*send_algorithm_, OnPacketAcked(3, _)).Times(1); 2933 EXPECT_CALL(*send_algorithm_, OnPacketAcked(3, _)).Times(1);
2891 ProcessAckPacket(&ack); 2934 ProcessAckPacket(&ack);
2892 2935
2893 // Check that no packet is sent and the ack alarm isn't set. 2936 // Check that no packet is sent and the ack alarm isn't set.
2894 EXPECT_EQ(0u, writer_->frame_count()); 2937 EXPECT_EQ(0u, writer_->frame_count());
2895 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); 2938 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
2896 writer_->Reset(); 2939 writer_->Reset();
2897 2940
2898 // Send the same ack, but send both data and an ack together. 2941 // Send the same ack, but send both data and an ack together.
2899 ack = InitAckFrame(3, 0); 2942 ack = InitAckFrame(3, 0);
2900 NackPacket(1, &ack); 2943 NackPacket(1, &ack);
2944 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
2945 .WillOnce(Return(SequenceNumberSet()));
2901 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce( 2946 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(
2902 IgnoreResult(InvokeWithoutArgs( 2947 IgnoreResult(InvokeWithoutArgs(
2903 &connection_, 2948 &connection_,
2904 &TestConnection::EnsureWritableAndSendStreamData5))); 2949 &TestConnection::EnsureWritableAndSendStreamData5)));
2905 ProcessAckPacket(&ack); 2950 ProcessAckPacket(&ack);
2906 2951
2907 // Check that ack is bundled with outgoing data and the delayed ack 2952 // Check that ack is bundled with outgoing data and the delayed ack
2908 // alarm is reset. 2953 // alarm is reset.
2909 if (version() > QUIC_VERSION_15) { 2954 if (version() > QUIC_VERSION_15) {
2910 EXPECT_EQ(3u, writer_->frame_count()); 2955 EXPECT_EQ(3u, writer_->frame_count());
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
3558 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get()); 3603 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get());
3559 3604
3560 // Process an ACK from the server which should trigger the callback. 3605 // Process an ACK from the server which should trigger the callback.
3561 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); 3606 EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
3562 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1); 3607 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1);
3563 QuicAckFrame frame = InitAckFrame(1, 0); 3608 QuicAckFrame frame = InitAckFrame(1, 0);
3564 ProcessAckPacket(&frame); 3609 ProcessAckPacket(&frame);
3565 } 3610 }
3566 3611
3567 TEST_P(QuicConnectionTest, AckNotifierFailToTriggerCallback) { 3612 TEST_P(QuicConnectionTest, AckNotifierFailToTriggerCallback) {
3613 SetUpMockLossAlgorithm();
3568 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 3614 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3569 3615
3570 // Create a delegate which we don't expect to be called. 3616 // Create a delegate which we don't expect to be called.
3571 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); 3617 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate);
3572 EXPECT_CALL(*delegate, OnAckNotification()).Times(0); 3618 EXPECT_CALL(*delegate, OnAckNotification()).Times(0);
3573 3619
3574 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); 3620 EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
3575 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(2); 3621 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(2);
3576 3622
3577 // Send some data, which will register the delegate to be notified. This will 3623 // Send some data, which will register the delegate to be notified. This will
3578 // not be ACKed and so the delegate should never be called. 3624 // not be ACKed and so the delegate should never be called.
3579 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get()); 3625 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get());
3580 3626
3581 // Send some other data which we will ACK. 3627 // Send some other data which we will ACK.
3582 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); 3628 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL);
3583 connection_.SendStreamDataWithString(1, "bar", 0, !kFin, NULL); 3629 connection_.SendStreamDataWithString(1, "bar", 0, !kFin, NULL);
3584 3630
3585 // Now we receive ACK for packets 2 and 3, but importantly missing packet 1 3631 // Now we receive ACK for packets 2 and 3, but importantly missing packet 1
3586 // which we registered to be notified about. 3632 // which we registered to be notified about.
3587 QuicAckFrame frame = InitAckFrame(3, 0); 3633 QuicAckFrame frame = InitAckFrame(3, 0);
3588 NackPacket(1, &frame); 3634 NackPacket(1, &frame);
3589 EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)); 3635 SequenceNumberSet lost_packets;
3590 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)); 3636 lost_packets.insert(1);
3637 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
3638 .WillOnce(Return(lost_packets));
3639 EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _));
3640 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _));
3591 ProcessAckPacket(&frame); 3641 ProcessAckPacket(&frame);
3592 } 3642 }
3593 3643
3594 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterRetransmission) { 3644 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterRetransmission) {
3645 SetUpMockLossAlgorithm();
3595 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 3646 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3596 3647
3597 // Create a delegate which we expect to be called. 3648 // Create a delegate which we expect to be called.
3598 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); 3649 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate);
3599 EXPECT_CALL(*delegate, OnAckNotification()).Times(1); 3650 EXPECT_CALL(*delegate, OnAckNotification()).Times(1);
3600 3651
3601 // In total expect ACKs for all 4 packets.
3602 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)).Times(2);
3603 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(4);
3604
3605 // 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.
3606 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); 3653 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL);
3607 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, delegate.get()); 3654 connection_.SendStreamDataWithString(3, "bar", 0, !kFin, delegate.get());
3608 connection_.SendStreamDataWithString(3, "baz", 0, !kFin, NULL); 3655 connection_.SendStreamDataWithString(3, "baz", 0, !kFin, NULL);
3609 connection_.SendStreamDataWithString(3, "qux", 0, !kFin, NULL); 3656 connection_.SendStreamDataWithString(3, "qux", 0, !kFin, NULL);
3610 3657
3611 // Now we receive ACK for packets 1, 3, and 4, which invokes fast retransmit. 3658 // Now we receive ACK for packets 1, 3, and 4 and lose 2.
3612 QuicAckFrame frame = InitAckFrame(4, 0); 3659 QuicAckFrame frame = InitAckFrame(4, 0);
3613 NackPacket(2, &frame); 3660 NackPacket(2, &frame);
3661 SequenceNumberSet lost_packets;
3662 lost_packets.insert(2);
3663 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
3664 .WillOnce(Return(lost_packets));
3665 EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
3666 EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(3);
3614 EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _)); 3667 EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _));
3615 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)); 3668 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _));
3616 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); 3669 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
3617 ProcessAckPacket(&frame); 3670 ProcessAckPacket(&frame);
3618 3671
3619 // 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
3620 // trigger the callback. 3673 // trigger the callback.
3674 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
3675 .WillRepeatedly(Return(SequenceNumberSet()));
3676 EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
3677 EXPECT_CALL(*send_algorithm_, OnPacketAcked(5, _));
3621 QuicAckFrame second_ack_frame = InitAckFrame(5, 0); 3678 QuicAckFrame second_ack_frame = InitAckFrame(5, 0);
3622 ProcessAckPacket(&second_ack_frame); 3679 ProcessAckPacket(&second_ack_frame);
3623 } 3680 }
3624 3681
3625 // 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
3626 // ACK) triggers notification on our end. 3683 // ACK) triggers notification on our end.
3627 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterFECRecovery) { 3684 TEST_P(QuicConnectionTest, AckNotifierCallbackAfterFECRecovery) {
3628 if (version() < QUIC_VERSION_15) { 3685 if (version() < QUIC_VERSION_15) {
3629 return; 3686 return;
3630 } 3687 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
3768 QuicBlockedFrame blocked; 3825 QuicBlockedFrame blocked;
3769 blocked.stream_id = 3; 3826 blocked.stream_id = 3;
3770 EXPECT_CALL(visitor_, OnBlockedFrames(_)); 3827 EXPECT_CALL(visitor_, OnBlockedFrames(_));
3771 ProcessFramePacket(QuicFrame(&blocked)); 3828 ProcessFramePacket(QuicFrame(&blocked));
3772 EXPECT_TRUE(ack_alarm->IsSet()); 3829 EXPECT_TRUE(ack_alarm->IsSet());
3773 } 3830 }
3774 3831
3775 } // namespace 3832 } // namespace
3776 } // namespace test 3833 } // namespace test
3777 } // namespace net 3834 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698