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

Unified Diff: net/quic/quic_unacked_packet_map_test.cc

Issue 561513003: Landing Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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') | no next file » | 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 16d1df2bcde22953a6e00146448f5e3d22a35223..c9d4491cf8a2e680b81453e711d0f8a3d35954c3 100644
--- a/net/quic/quic_unacked_packet_map_test.cc
+++ b/net/quic/quic_unacked_packet_map_test.cc
@@ -7,6 +7,8 @@
#include "net/quic/test_tools/quic_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
+using std::min;
+
namespace net {
namespace test {
namespace {
@@ -113,6 +115,18 @@ TEST_F(QuicUnackedPacketMapTest, RttOnly) {
VerifyRetransmittablePackets(NULL, 0);
}
+TEST_F(QuicUnackedPacketMapTest, DiscardOldRttOnly) {
+ // Acks are only tracked for RTT measurement purposes, and are discarded
+ // when more than 200 accumulate.
+ for (int i = 1; i < 400; ++i) {
+ unacked_packets_.AddPacket(CreateNonRetransmittablePacket(i));
+ unacked_packets_.SetSent(i, now_, kDefaultAckLength, false);
+ unacked_packets_.RemoveObsoletePackets();
+ EXPECT_EQ(static_cast<size_t>(min(i, 200)),
+ unacked_packets_.GetNumUnackedPacketsDebugOnly());
+ }
+}
+
TEST_F(QuicUnackedPacketMapTest, RetransmittableInflightAndRtt) {
// Simulate a retransmittable packet being sent and acked.
unacked_packets_.AddPacket(CreateRetransmittablePacket(1));
@@ -234,6 +248,43 @@ TEST_F(QuicUnackedPacketMapTest, RetransmitThreeTimes) {
VerifyInFlightPackets(pending4, arraysize(pending4));
QuicPacketSequenceNumber retransmittable4[] = { 7 };
VerifyRetransmittablePackets(retransmittable4, arraysize(retransmittable4));
+
+ // Remove the older two transmissions from in flight.
+ unacked_packets_.RemoveFromInFlight(3);
+ unacked_packets_.RemoveFromInFlight(5);
+ QuicPacketSequenceNumber pending5[] = { 7 };
+ VerifyInFlightPackets(pending5, arraysize(pending5));
+
+ // Now test ClearAllPreviousTransmissions, leaving one packet.
+ unacked_packets_.ClearAllPreviousRetransmissions();
+ QuicPacketSequenceNumber unacked5[] = { 7 };
+ VerifyUnackedPackets(unacked5, arraysize(unacked5));
+ QuicPacketSequenceNumber retransmittable5[] = { 7 };
+ VerifyRetransmittablePackets(retransmittable5, arraysize(retransmittable5));
+}
+
+TEST_F(QuicUnackedPacketMapTest, RestoreInflight) {
+ // Simulate a retransmittable packet being sent, retransmitted, and the first
+ // transmission being acked.
+ unacked_packets_.AddPacket(CreateRetransmittablePacket(1));
+ unacked_packets_.SetSent(1, now_, kDefaultLength, true);
+ unacked_packets_.OnRetransmittedPacket(1, 2, RTO_RETRANSMISSION);
+ unacked_packets_.RemoveFromInFlight(1);
+ unacked_packets_.SetSent(2, now_, kDefaultLength, true);
+
+ QuicPacketSequenceNumber unacked[] = { 1, 2 };
+ VerifyUnackedPackets(unacked, arraysize(unacked));
+ QuicPacketSequenceNumber retransmittable[] = { 2 };
+ VerifyInFlightPackets(retransmittable, arraysize(retransmittable));
+ VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable));
+ EXPECT_EQ(kDefaultLength, unacked_packets_.bytes_in_flight());
+
+ // Simulate an F-RTO, and restore 1 to flight.
+ unacked_packets_.RestoreInFlight(1);
+ VerifyUnackedPackets(unacked, arraysize(unacked));
+ VerifyInFlightPackets(unacked, arraysize(unacked));
+ VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable));
+ EXPECT_EQ(2 * kDefaultLength, unacked_packets_.bytes_in_flight());
}
} // namespace
« no previous file with comments | « net/quic/quic_unacked_packet_map.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698