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

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

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

Powered by Google App Engine
This is Rietveld 408576698