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

Unified Diff: net/quic/quic_unacked_packet_map_test.cc

Issue 411823002: Land Recent QUIC Changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase TOT Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_unacked_packet_map.cc ('k') | net/quic/test_tools/quic_connection_peer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_unacked_packet_map_test.cc
diff --git a/net/quic/quic_unacked_packet_map_test.cc b/net/quic/quic_unacked_packet_map_test.cc
index c5264fd16e906db066c02a598f6411dde8b5b1ce..87c6ca818fbb0afe77a54935deb6b4ed124e553e 100644
--- a/net/quic/quic_unacked_packet_map_test.cc
+++ b/net/quic/quic_unacked_packet_map_test.cc
@@ -33,8 +33,8 @@ class QuicUnackedPacketMapTest : public ::testing::Test {
sequence_number, PACKET_1BYTE_SEQUENCE_NUMBER, NULL, 0, NULL);
}
- void VerifyPendingPackets(QuicPacketSequenceNumber* packets,
- size_t num_packets) {
+ void VerifyInFlightPackets(QuicPacketSequenceNumber* packets,
+ size_t num_packets) {
if (num_packets == 0) {
EXPECT_FALSE(unacked_packets_.HasInFlightPackets());
EXPECT_FALSE(unacked_packets_.HasMultipleInFlightPackets());
@@ -43,11 +43,21 @@ class QuicUnackedPacketMapTest : public ::testing::Test {
if (num_packets == 1) {
EXPECT_TRUE(unacked_packets_.HasInFlightPackets());
EXPECT_FALSE(unacked_packets_.HasMultipleInFlightPackets());
+ ASSERT_TRUE(unacked_packets_.IsUnacked(packets[0]));
+ EXPECT_TRUE(unacked_packets_.GetTransmissionInfo(packets[0]).in_flight);
}
for (size_t i = 0; i < num_packets; ++i) {
ASSERT_TRUE(unacked_packets_.IsUnacked(packets[i]));
EXPECT_TRUE(unacked_packets_.GetTransmissionInfo(packets[i]).in_flight);
}
+ size_t in_flight_count = 0;
+ for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
+ it != unacked_packets_.end(); ++it) {
+ if (it->second.in_flight) {
+ ++in_flight_count;
+ }
+ }
+ EXPECT_EQ(num_packets, in_flight_count);
}
void VerifyUnackedPackets(QuicPacketSequenceNumber* packets,
@@ -61,6 +71,12 @@ class QuicUnackedPacketMapTest : public ::testing::Test {
for (size_t i = 0; i < num_packets; ++i) {
EXPECT_TRUE(unacked_packets_.IsUnacked(packets[i])) << packets[i];
}
+ size_t unacked_count = 0;
+ for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
+ it != unacked_packets_.end(); ++it) {
+ ++unacked_count;
+ }
+ EXPECT_EQ(num_packets, unacked_count);
}
void VerifyRetransmittablePackets(QuicPacketSequenceNumber* packets,
@@ -90,12 +106,12 @@ TEST_F(QuicUnackedPacketMapTest, RttOnly) {
QuicPacketSequenceNumber unacked[] = { 1 };
VerifyUnackedPackets(unacked, arraysize(unacked));
- VerifyPendingPackets(NULL, 0);
+ VerifyInFlightPackets(NULL, 0);
VerifyRetransmittablePackets(NULL, 0);
unacked_packets_.IncreaseLargestObserved(1);
VerifyUnackedPackets(NULL, 0);
- VerifyPendingPackets(NULL, 0);
+ VerifyInFlightPackets(NULL, 0);
VerifyRetransmittablePackets(NULL, 0);
}
@@ -106,22 +122,22 @@ TEST_F(QuicUnackedPacketMapTest, RetransmittableInflightAndRtt) {
QuicPacketSequenceNumber unacked[] = { 1 };
VerifyUnackedPackets(unacked, arraysize(unacked));
- VerifyPendingPackets(unacked, arraysize(unacked));
+ VerifyInFlightPackets(unacked, arraysize(unacked));
VerifyRetransmittablePackets(unacked, arraysize(unacked));
unacked_packets_.RemoveRetransmittability(1);
VerifyUnackedPackets(unacked, arraysize(unacked));
- VerifyPendingPackets(unacked, arraysize(unacked));
+ VerifyInFlightPackets(unacked, arraysize(unacked));
VerifyRetransmittablePackets(NULL, 0);
unacked_packets_.IncreaseLargestObserved(1);
VerifyUnackedPackets(unacked, arraysize(unacked));
- VerifyPendingPackets(unacked, arraysize(unacked));
+ VerifyInFlightPackets(unacked, arraysize(unacked));
VerifyRetransmittablePackets(NULL, 0);
unacked_packets_.RemoveFromInFlight(1);
VerifyUnackedPackets(NULL, 0);
- VerifyPendingPackets(NULL, 0);
+ VerifyInFlightPackets(NULL, 0);
VerifyRetransmittablePackets(NULL, 0);
}
@@ -135,32 +151,78 @@ TEST_F(QuicUnackedPacketMapTest, RetransmittedPacket) {
QuicPacketSequenceNumber unacked[] = { 1, 2 };
VerifyUnackedPackets(unacked, arraysize(unacked));
- VerifyPendingPackets(unacked, arraysize(unacked));
+ VerifyInFlightPackets(unacked, arraysize(unacked));
QuicPacketSequenceNumber retransmittable[] = { 2 };
VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable));
unacked_packets_.RemoveRetransmittability(1);
VerifyUnackedPackets(unacked, arraysize(unacked));
- VerifyPendingPackets(unacked, arraysize(unacked));
+ VerifyInFlightPackets(unacked, arraysize(unacked));
VerifyRetransmittablePackets(NULL, 0);
unacked_packets_.IncreaseLargestObserved(2);
VerifyUnackedPackets(unacked, arraysize(unacked));
- VerifyPendingPackets(unacked, arraysize(unacked));
+ VerifyInFlightPackets(unacked, arraysize(unacked));
VerifyRetransmittablePackets(NULL, 0);
unacked_packets_.RemoveFromInFlight(2);
QuicPacketSequenceNumber unacked2[] = { 1 };
VerifyUnackedPackets(unacked, arraysize(unacked2));
- VerifyPendingPackets(unacked, arraysize(unacked2));
+ VerifyInFlightPackets(unacked, arraysize(unacked2));
VerifyRetransmittablePackets(NULL, 0);
unacked_packets_.RemoveFromInFlight(1);
VerifyUnackedPackets(NULL, 0);
- VerifyPendingPackets(NULL, 0);
+ VerifyInFlightPackets(NULL, 0);
VerifyRetransmittablePackets(NULL, 0);
}
+TEST_F(QuicUnackedPacketMapTest, RetransmitTwice) {
+ // Simulate a retransmittable packet being sent and retransmitted twice.
+ unacked_packets_.AddPacket(CreateRetransmittablePacket(1));
+ unacked_packets_.SetSent(1, now_, kDefaultLength, true);
+ unacked_packets_.AddPacket(CreateRetransmittablePacket(2));
+ unacked_packets_.SetSent(2, now_, kDefaultLength, true);
+
+ QuicPacketSequenceNumber unacked[] = { 1, 2 };
+ VerifyUnackedPackets(unacked, arraysize(unacked));
+ VerifyInFlightPackets(unacked, arraysize(unacked));
+ QuicPacketSequenceNumber retransmittable[] = { 1, 2 };
+ VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable));
+
+ // Early retransmit 1 as 3 and send new data as 4.
+ unacked_packets_.IncreaseLargestObserved(2);
+ unacked_packets_.RemoveFromInFlight(2);
+ unacked_packets_.RemoveRetransmittability(2);
+ unacked_packets_.RemoveFromInFlight(1);
+ unacked_packets_.OnRetransmittedPacket(1, 3, LOSS_RETRANSMISSION);
+ unacked_packets_.SetSent(3, now_, kDefaultLength, true);
+ unacked_packets_.AddPacket(CreateRetransmittablePacket(4));
+ unacked_packets_.SetSent(4, now_, kDefaultLength, true);
+
+ QuicPacketSequenceNumber unacked2[] = { 1, 3, 4 };
+ VerifyUnackedPackets(unacked2, arraysize(unacked2));
+ QuicPacketSequenceNumber pending2[] = { 3, 4, };
+ VerifyInFlightPackets(pending2, arraysize(pending2));
+ QuicPacketSequenceNumber retransmittable2[] = { 3, 4 };
+ VerifyRetransmittablePackets(retransmittable2, arraysize(retransmittable2));
+
+ // Early retransmit 3 (formerly 1) as 5, and remove 1 from unacked.
+ unacked_packets_.IncreaseLargestObserved(4);
+ unacked_packets_.RemoveFromInFlight(4);
+ unacked_packets_.RemoveRetransmittability(4);
+ unacked_packets_.RemoveFromInFlight(3);
+ unacked_packets_.OnRetransmittedPacket(3, 5, LOSS_RETRANSMISSION);
+ unacked_packets_.SetSent(5, now_, kDefaultLength, true);
+
+ QuicPacketSequenceNumber unacked3[] = { 3, 5 };
+ VerifyUnackedPackets(unacked3, arraysize(unacked3));
+ QuicPacketSequenceNumber pending3[] = { 5 };
+ VerifyInFlightPackets(pending3, arraysize(pending3));
+ QuicPacketSequenceNumber retransmittable3[] = { 5 };
+ VerifyRetransmittablePackets(retransmittable3, arraysize(retransmittable3));
+}
+
} // namespace
} // namespace test
} // namespace net
« no previous file with comments | « net/quic/quic_unacked_packet_map.cc ('k') | net/quic/test_tools/quic_connection_peer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698