OLD | NEW |
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 namespace net { | 10 namespace net { |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 VerifyUnackedPackets(unacked, arraysize(unacked2)); | 170 VerifyUnackedPackets(unacked, arraysize(unacked2)); |
171 VerifyInFlightPackets(unacked, arraysize(unacked2)); | 171 VerifyInFlightPackets(unacked, arraysize(unacked2)); |
172 VerifyRetransmittablePackets(NULL, 0); | 172 VerifyRetransmittablePackets(NULL, 0); |
173 | 173 |
174 unacked_packets_.RemoveFromInFlight(1); | 174 unacked_packets_.RemoveFromInFlight(1); |
175 VerifyUnackedPackets(NULL, 0); | 175 VerifyUnackedPackets(NULL, 0); |
176 VerifyInFlightPackets(NULL, 0); | 176 VerifyInFlightPackets(NULL, 0); |
177 VerifyRetransmittablePackets(NULL, 0); | 177 VerifyRetransmittablePackets(NULL, 0); |
178 } | 178 } |
179 | 179 |
180 TEST_F(QuicUnackedPacketMapTest, RetransmitTwice) { | 180 TEST_F(QuicUnackedPacketMapTest, RetransmitThreeTimes) { |
181 // Simulate a retransmittable packet being sent and retransmitted twice. | 181 // Simulate a retransmittable packet being sent and retransmitted twice. |
182 unacked_packets_.AddPacket(CreateRetransmittablePacket(1)); | 182 unacked_packets_.AddPacket(CreateRetransmittablePacket(1)); |
183 unacked_packets_.SetSent(1, now_, kDefaultLength, true); | 183 unacked_packets_.SetSent(1, now_, kDefaultLength, true); |
184 unacked_packets_.AddPacket(CreateRetransmittablePacket(2)); | 184 unacked_packets_.AddPacket(CreateRetransmittablePacket(2)); |
185 unacked_packets_.SetSent(2, now_, kDefaultLength, true); | 185 unacked_packets_.SetSent(2, now_, kDefaultLength, true); |
186 | 186 |
187 QuicPacketSequenceNumber unacked[] = { 1, 2 }; | 187 QuicPacketSequenceNumber unacked[] = { 1, 2 }; |
188 VerifyUnackedPackets(unacked, arraysize(unacked)); | 188 VerifyUnackedPackets(unacked, arraysize(unacked)); |
189 VerifyInFlightPackets(unacked, arraysize(unacked)); | 189 VerifyInFlightPackets(unacked, arraysize(unacked)); |
190 QuicPacketSequenceNumber retransmittable[] = { 1, 2 }; | 190 QuicPacketSequenceNumber retransmittable[] = { 1, 2 }; |
(...skipping 13 matching lines...) Expand all Loading... |
204 VerifyUnackedPackets(unacked2, arraysize(unacked2)); | 204 VerifyUnackedPackets(unacked2, arraysize(unacked2)); |
205 QuicPacketSequenceNumber pending2[] = { 3, 4, }; | 205 QuicPacketSequenceNumber pending2[] = { 3, 4, }; |
206 VerifyInFlightPackets(pending2, arraysize(pending2)); | 206 VerifyInFlightPackets(pending2, arraysize(pending2)); |
207 QuicPacketSequenceNumber retransmittable2[] = { 3, 4 }; | 207 QuicPacketSequenceNumber retransmittable2[] = { 3, 4 }; |
208 VerifyRetransmittablePackets(retransmittable2, arraysize(retransmittable2)); | 208 VerifyRetransmittablePackets(retransmittable2, arraysize(retransmittable2)); |
209 | 209 |
210 // Early retransmit 3 (formerly 1) as 5, and remove 1 from unacked. | 210 // Early retransmit 3 (formerly 1) as 5, and remove 1 from unacked. |
211 unacked_packets_.IncreaseLargestObserved(4); | 211 unacked_packets_.IncreaseLargestObserved(4); |
212 unacked_packets_.RemoveFromInFlight(4); | 212 unacked_packets_.RemoveFromInFlight(4); |
213 unacked_packets_.RemoveRetransmittability(4); | 213 unacked_packets_.RemoveRetransmittability(4); |
214 unacked_packets_.RemoveFromInFlight(3); | |
215 unacked_packets_.OnRetransmittedPacket(3, 5, LOSS_RETRANSMISSION); | 214 unacked_packets_.OnRetransmittedPacket(3, 5, LOSS_RETRANSMISSION); |
216 unacked_packets_.SetSent(5, now_, kDefaultLength, true); | 215 unacked_packets_.SetSent(5, now_, kDefaultLength, true); |
| 216 unacked_packets_.AddPacket(CreateRetransmittablePacket(6)); |
| 217 unacked_packets_.SetSent(6, now_, kDefaultLength, true); |
217 | 218 |
218 QuicPacketSequenceNumber unacked3[] = { 3, 5 }; | 219 QuicPacketSequenceNumber unacked3[] = { 3, 5, 6 }; |
219 VerifyUnackedPackets(unacked3, arraysize(unacked3)); | 220 VerifyUnackedPackets(unacked3, arraysize(unacked3)); |
220 QuicPacketSequenceNumber pending3[] = { 5 }; | 221 QuicPacketSequenceNumber pending3[] = { 3, 5, 6 }; |
221 VerifyInFlightPackets(pending3, arraysize(pending3)); | 222 VerifyInFlightPackets(pending3, arraysize(pending3)); |
222 QuicPacketSequenceNumber retransmittable3[] = { 5 }; | 223 QuicPacketSequenceNumber retransmittable3[] = { 5, 6 }; |
223 VerifyRetransmittablePackets(retransmittable3, arraysize(retransmittable3)); | 224 VerifyRetransmittablePackets(retransmittable3, arraysize(retransmittable3)); |
| 225 |
| 226 // Early retransmit 5 as 7 and ensure in flight packet 3 is not removed. |
| 227 unacked_packets_.IncreaseLargestObserved(6); |
| 228 unacked_packets_.RemoveFromInFlight(6); |
| 229 unacked_packets_.RemoveRetransmittability(6); |
| 230 unacked_packets_.OnRetransmittedPacket(5, 7, LOSS_RETRANSMISSION); |
| 231 unacked_packets_.SetSent(7, now_, kDefaultLength, true); |
| 232 |
| 233 QuicPacketSequenceNumber unacked4[] = { 3, 5, 7 }; |
| 234 VerifyUnackedPackets(unacked4, arraysize(unacked4)); |
| 235 QuicPacketSequenceNumber pending4[] = { 3, 5, 7 }; |
| 236 VerifyInFlightPackets(pending4, arraysize(pending4)); |
| 237 QuicPacketSequenceNumber retransmittable4[] = { 7 }; |
| 238 VerifyRetransmittablePackets(retransmittable4, arraysize(retransmittable4)); |
224 } | 239 } |
225 | 240 |
226 } // namespace | 241 } // namespace |
227 } // namespace test | 242 } // namespace test |
228 } // namespace net | 243 } // namespace net |
OLD | NEW |