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

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

Issue 559373003: Landing Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compiler errors 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 unified diff | Download patch
« no previous file with comments | « net/quic/quic_unacked_packet_map.cc ('k') | net/quic/quic_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_unacked_packet_map.h" 5 #include "net/quic/quic_unacked_packet_map.h"
6 6
7 #include "net/quic/test_tools/quic_test_utils.h" 7 #include "net/quic/test_tools/quic_test_utils.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 using std::min; 10 using std::min;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 unacked_packets_.IncreaseLargestObserved(1); 112 unacked_packets_.IncreaseLargestObserved(1);
113 VerifyUnackedPackets(NULL, 0); 113 VerifyUnackedPackets(NULL, 0);
114 VerifyInFlightPackets(NULL, 0); 114 VerifyInFlightPackets(NULL, 0);
115 VerifyRetransmittablePackets(NULL, 0); 115 VerifyRetransmittablePackets(NULL, 0);
116 } 116 }
117 117
118 TEST_F(QuicUnackedPacketMapTest, DiscardOldRttOnly) { 118 TEST_F(QuicUnackedPacketMapTest, DiscardOldRttOnly) {
119 // Acks are only tracked for RTT measurement purposes, and are discarded 119 // Acks are only tracked for RTT measurement purposes, and are discarded
120 // when more than 200 accumulate. 120 // when more than 200 accumulate.
121 for (int i = 1; i < 400; ++i) { 121 const size_t kNumUnackedPackets = 200;
122 for (size_t i = 1; i < 400; ++i) {
122 unacked_packets_.AddPacket(CreateNonRetransmittablePacket(i)); 123 unacked_packets_.AddPacket(CreateNonRetransmittablePacket(i));
123 unacked_packets_.SetSent(i, now_, kDefaultAckLength, false); 124 unacked_packets_.SetSent(i, now_, kDefaultAckLength, false);
124 unacked_packets_.RemoveObsoletePackets(); 125 unacked_packets_.RemoveObsoletePackets();
125 EXPECT_EQ(static_cast<size_t>(min(i, 200)), 126 EXPECT_EQ(min(i, kNumUnackedPackets),
126 unacked_packets_.GetNumUnackedPacketsDebugOnly()); 127 unacked_packets_.GetNumUnackedPacketsDebugOnly());
127 } 128 }
128 } 129 }
129 130
130 TEST_F(QuicUnackedPacketMapTest, RetransmittableInflightAndRtt) { 131 TEST_F(QuicUnackedPacketMapTest, RetransmittableInflightAndRtt) {
131 // Simulate a retransmittable packet being sent and acked. 132 // Simulate a retransmittable packet being sent and acked.
132 unacked_packets_.AddPacket(CreateRetransmittablePacket(1)); 133 unacked_packets_.AddPacket(CreateRetransmittablePacket(1));
133 unacked_packets_.SetSent(1, now_, kDefaultLength, true); 134 unacked_packets_.SetSent(1, now_, kDefaultLength, true);
134 135
135 QuicPacketSequenceNumber unacked[] = { 1 }; 136 QuicPacketSequenceNumber unacked[] = { 1 };
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 VerifyInFlightPackets(pending5, arraysize(pending5)); 257 VerifyInFlightPackets(pending5, arraysize(pending5));
257 258
258 // Now test ClearAllPreviousTransmissions, leaving one packet. 259 // Now test ClearAllPreviousTransmissions, leaving one packet.
259 unacked_packets_.ClearAllPreviousRetransmissions(); 260 unacked_packets_.ClearAllPreviousRetransmissions();
260 QuicPacketSequenceNumber unacked5[] = { 7 }; 261 QuicPacketSequenceNumber unacked5[] = { 7 };
261 VerifyUnackedPackets(unacked5, arraysize(unacked5)); 262 VerifyUnackedPackets(unacked5, arraysize(unacked5));
262 QuicPacketSequenceNumber retransmittable5[] = { 7 }; 263 QuicPacketSequenceNumber retransmittable5[] = { 7 };
263 VerifyRetransmittablePackets(retransmittable5, arraysize(retransmittable5)); 264 VerifyRetransmittablePackets(retransmittable5, arraysize(retransmittable5));
264 } 265 }
265 266
267 TEST_F(QuicUnackedPacketMapTest, RetransmitFourTimes) {
268 // Simulate a retransmittable packet being sent and retransmitted twice.
269 unacked_packets_.AddPacket(CreateRetransmittablePacket(1));
270 unacked_packets_.SetSent(1, now_, kDefaultLength, true);
271 unacked_packets_.AddPacket(CreateRetransmittablePacket(2));
272 unacked_packets_.SetSent(2, now_, kDefaultLength, true);
273
274 QuicPacketSequenceNumber unacked[] = { 1, 2 };
275 VerifyUnackedPackets(unacked, arraysize(unacked));
276 VerifyInFlightPackets(unacked, arraysize(unacked));
277 QuicPacketSequenceNumber retransmittable[] = { 1, 2 };
278 VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable));
279
280 // Early retransmit 1 as 3.
281 unacked_packets_.IncreaseLargestObserved(2);
282 unacked_packets_.RemoveFromInFlight(2);
283 unacked_packets_.RemoveRetransmittability(2);
284 unacked_packets_.RemoveFromInFlight(1);
285 unacked_packets_.OnRetransmittedPacket(1, 3, LOSS_RETRANSMISSION);
286 unacked_packets_.SetSent(3, now_, kDefaultLength, true);
287
288 QuicPacketSequenceNumber unacked2[] = { 1, 3 };
289 VerifyUnackedPackets(unacked2, arraysize(unacked2));
290 QuicPacketSequenceNumber pending2[] = { 3 };
291 VerifyInFlightPackets(pending2, arraysize(pending2));
292 QuicPacketSequenceNumber retransmittable2[] = { 3 };
293 VerifyRetransmittablePackets(retransmittable2, arraysize(retransmittable2));
294
295 // TLP 3 (formerly 1) as 4, and don't remove 1 from unacked.
296 unacked_packets_.OnRetransmittedPacket(3, 4, TLP_RETRANSMISSION);
297 unacked_packets_.SetSent(4, now_, kDefaultLength, true);
298 unacked_packets_.AddPacket(CreateRetransmittablePacket(5));
299 unacked_packets_.SetSent(5, now_, kDefaultLength, true);
300
301 QuicPacketSequenceNumber unacked3[] = { 1, 3, 4, 5 };
302 VerifyUnackedPackets(unacked3, arraysize(unacked3));
303 QuicPacketSequenceNumber pending3[] = { 3, 4, 5 };
304 VerifyInFlightPackets(pending3, arraysize(pending3));
305 QuicPacketSequenceNumber retransmittable3[] = { 4, 5 };
306 VerifyRetransmittablePackets(retransmittable3, arraysize(retransmittable3));
307
308 // Early retransmit 4 as 6 and ensure in flight packet 3 is removed.
309 unacked_packets_.IncreaseLargestObserved(5);
310 unacked_packets_.RemoveFromInFlight(5);
311 unacked_packets_.RemoveRetransmittability(5);
312 unacked_packets_.RemoveFromInFlight(3);
313 unacked_packets_.RemoveFromInFlight(4);
314 unacked_packets_.OnRetransmittedPacket(4, 6, LOSS_RETRANSMISSION);
315 unacked_packets_.SetSent(6, now_, kDefaultLength, true);
316
317 QuicPacketSequenceNumber unacked4[] = { 4, 6 };
318 VerifyUnackedPackets(unacked4, arraysize(unacked4));
319 QuicPacketSequenceNumber pending4[] = { 6 };
320 VerifyInFlightPackets(pending4, arraysize(pending4));
321 QuicPacketSequenceNumber retransmittable4[] = { 6 };
322 VerifyRetransmittablePackets(retransmittable4, arraysize(retransmittable4));
323 }
324
266 TEST_F(QuicUnackedPacketMapTest, RestoreInflight) { 325 TEST_F(QuicUnackedPacketMapTest, RestoreInflight) {
267 // Simulate a retransmittable packet being sent, retransmitted, and the first 326 // Simulate a retransmittable packet being sent, retransmitted, and the first
268 // transmission being acked. 327 // transmission being acked.
269 unacked_packets_.AddPacket(CreateRetransmittablePacket(1)); 328 unacked_packets_.AddPacket(CreateRetransmittablePacket(1));
270 unacked_packets_.SetSent(1, now_, kDefaultLength, true); 329 unacked_packets_.SetSent(1, now_, kDefaultLength, true);
271 unacked_packets_.OnRetransmittedPacket(1, 2, RTO_RETRANSMISSION); 330 unacked_packets_.OnRetransmittedPacket(1, 2, RTO_RETRANSMISSION);
272 unacked_packets_.RemoveFromInFlight(1); 331 unacked_packets_.RemoveFromInFlight(1);
273 unacked_packets_.SetSent(2, now_, kDefaultLength, true); 332 unacked_packets_.SetSent(2, now_, kDefaultLength, true);
274 333
275 QuicPacketSequenceNumber unacked[] = { 1, 2 }; 334 QuicPacketSequenceNumber unacked[] = { 1, 2 };
276 VerifyUnackedPackets(unacked, arraysize(unacked)); 335 VerifyUnackedPackets(unacked, arraysize(unacked));
277 QuicPacketSequenceNumber retransmittable[] = { 2 }; 336 QuicPacketSequenceNumber retransmittable[] = { 2 };
278 VerifyInFlightPackets(retransmittable, arraysize(retransmittable)); 337 VerifyInFlightPackets(retransmittable, arraysize(retransmittable));
279 VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable)); 338 VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable));
280 EXPECT_EQ(kDefaultLength, unacked_packets_.bytes_in_flight()); 339 EXPECT_EQ(kDefaultLength, unacked_packets_.bytes_in_flight());
281 340
282 // Simulate an F-RTO, and restore 1 to flight. 341 // Simulate an F-RTO, and restore 1 to flight.
283 unacked_packets_.RestoreInFlight(1); 342 unacked_packets_.RestoreInFlight(1);
284 VerifyUnackedPackets(unacked, arraysize(unacked)); 343 VerifyUnackedPackets(unacked, arraysize(unacked));
285 VerifyInFlightPackets(unacked, arraysize(unacked)); 344 VerifyInFlightPackets(unacked, arraysize(unacked));
286 VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable)); 345 VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable));
287 EXPECT_EQ(2 * kDefaultLength, unacked_packets_.bytes_in_flight()); 346 EXPECT_EQ(2 * kDefaultLength, unacked_packets_.bytes_in_flight());
288 } 347 }
289 348
349 TEST_F(QuicUnackedPacketMapTest, SendWithGap) {
350 // Simulate a retransmittable packet being sent, retransmitted, and the first
351 // transmission being acked.
352 unacked_packets_.AddPacket(CreateRetransmittablePacket(1));
353 unacked_packets_.SetSent(1, now_, kDefaultLength, true);
354 unacked_packets_.AddPacket(CreateRetransmittablePacket(3));
355 unacked_packets_.SetSent(3, now_, kDefaultLength, true);
356 unacked_packets_.OnRetransmittedPacket(1, 5, LOSS_RETRANSMISSION);
357 unacked_packets_.SetSent(5, now_, kDefaultLength, true);
358
359 EXPECT_EQ(1u, unacked_packets_.GetLeastUnacked());
360 EXPECT_TRUE(unacked_packets_.IsUnacked(1));
361 EXPECT_FALSE(unacked_packets_.IsUnacked(2));
362 EXPECT_TRUE(unacked_packets_.IsUnacked(3));
363 EXPECT_FALSE(unacked_packets_.IsUnacked(4));
364 EXPECT_TRUE(unacked_packets_.IsUnacked(5));
365 EXPECT_EQ(5u, unacked_packets_.largest_sent_packet());
366 }
367
368
290 } // namespace 369 } // namespace
291 } // namespace test 370 } // namespace test
292 } // namespace net 371 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_unacked_packet_map.cc ('k') | net/quic/quic_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698