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

Side by Side Diff: net/quic/congestion_control/general_loss_algorithm_test.cc

Issue 2001183002: Deprecate FLAGS_quic_simplify_loss_detection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@122429210
Patch Set: Created 4 years, 7 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/congestion_control/general_loss_algorithm.cc ('k') | net/quic/quic_flags.h » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/congestion_control/general_loss_algorithm.h" 5 #include "net/quic/congestion_control/general_loss_algorithm.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "net/quic/congestion_control/rtt_stats.h" 10 #include "net/quic/congestion_control/rtt_stats.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 }; 65 };
66 66
67 TEST_F(GeneralLossAlgorithmTest, NackRetransmit1Packet) { 67 TEST_F(GeneralLossAlgorithmTest, NackRetransmit1Packet) {
68 const size_t kNumSentPackets = 5; 68 const size_t kNumSentPackets = 5;
69 // Transmit 5 packets. 69 // Transmit 5 packets.
70 for (size_t i = 1; i <= kNumSentPackets; ++i) { 70 for (size_t i = 1; i <= kNumSentPackets; ++i) {
71 SendDataPacket(i); 71 SendDataPacket(i);
72 } 72 }
73 // No loss on one ack. 73 // No loss on one ack.
74 unacked_packets_.RemoveFromInFlight(2); 74 unacked_packets_.RemoveFromInFlight(2);
75 if (!FLAGS_quic_simplify_loss_detection) {
76 unacked_packets_.NackPacket(1, 1);
77 }
78 VerifyLosses(2, nullptr, 0); 75 VerifyLosses(2, nullptr, 0);
79 // No loss on two acks. 76 // No loss on two acks.
80 unacked_packets_.RemoveFromInFlight(3); 77 unacked_packets_.RemoveFromInFlight(3);
81 if (!FLAGS_quic_simplify_loss_detection) {
82 unacked_packets_.NackPacket(1, 2);
83 }
84 VerifyLosses(3, nullptr, 0); 78 VerifyLosses(3, nullptr, 0);
85 // Loss on three acks. 79 // Loss on three acks.
86 unacked_packets_.RemoveFromInFlight(4); 80 unacked_packets_.RemoveFromInFlight(4);
87 if (!FLAGS_quic_simplify_loss_detection) {
88 unacked_packets_.NackPacket(1, 3);
89 }
90 QuicPacketNumber lost[] = {1}; 81 QuicPacketNumber lost[] = {1};
91 VerifyLosses(4, lost, arraysize(lost)); 82 VerifyLosses(4, lost, arraysize(lost));
92 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 83 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
93 } 84 }
94 85
95 // A stretch ack is an ack that covers more than 1 packet of previously 86 // A stretch ack is an ack that covers more than 1 packet of previously
96 // unacknowledged data. 87 // unacknowledged data.
97 TEST_F(GeneralLossAlgorithmTest, NackRetransmit1PacketWith1StretchAck) { 88 TEST_F(GeneralLossAlgorithmTest, NackRetransmit1PacketWith1StretchAck) {
98 const size_t kNumSentPackets = 10; 89 const size_t kNumSentPackets = 10;
99 // Transmit 10 packets. 90 // Transmit 10 packets.
100 for (size_t i = 1; i <= kNumSentPackets; ++i) { 91 for (size_t i = 1; i <= kNumSentPackets; ++i) {
101 SendDataPacket(i); 92 SendDataPacket(i);
102 } 93 }
103 94
104 // Nack the first packet 3 times in a single StretchAck. 95 // Nack the first packet 3 times in a single StretchAck.
105 if (!FLAGS_quic_simplify_loss_detection) {
106 unacked_packets_.NackPacket(1, 3);
107 }
108 unacked_packets_.RemoveFromInFlight(2); 96 unacked_packets_.RemoveFromInFlight(2);
109 unacked_packets_.RemoveFromInFlight(3); 97 unacked_packets_.RemoveFromInFlight(3);
110 unacked_packets_.RemoveFromInFlight(4); 98 unacked_packets_.RemoveFromInFlight(4);
111 QuicPacketNumber lost[] = {1}; 99 QuicPacketNumber lost[] = {1};
112 VerifyLosses(4, lost, arraysize(lost)); 100 VerifyLosses(4, lost, arraysize(lost));
113 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 101 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
114 } 102 }
115 103
116 // Ack a packet 3 packets ahead, causing a retransmit. 104 // Ack a packet 3 packets ahead, causing a retransmit.
117 TEST_F(GeneralLossAlgorithmTest, NackRetransmit1PacketSingleAck) { 105 TEST_F(GeneralLossAlgorithmTest, NackRetransmit1PacketSingleAck) {
118 const size_t kNumSentPackets = 10; 106 const size_t kNumSentPackets = 10;
119 // Transmit 10 packets. 107 // Transmit 10 packets.
120 for (size_t i = 1; i <= kNumSentPackets; ++i) { 108 for (size_t i = 1; i <= kNumSentPackets; ++i) {
121 SendDataPacket(i); 109 SendDataPacket(i);
122 } 110 }
123 111
124 // Nack the first packet 3 times in an AckFrame with three missing packets. 112 // Nack the first packet 3 times in an AckFrame with three missing packets.
125 if (!FLAGS_quic_simplify_loss_detection) {
126 unacked_packets_.NackPacket(1, 3);
127 unacked_packets_.NackPacket(2, 2);
128 unacked_packets_.NackPacket(3, 1);
129 }
130 unacked_packets_.RemoveFromInFlight(4); 113 unacked_packets_.RemoveFromInFlight(4);
131 QuicPacketNumber lost[] = {1}; 114 QuicPacketNumber lost[] = {1};
132 VerifyLosses(4, lost, arraysize(lost)); 115 VerifyLosses(4, lost, arraysize(lost));
133 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 116 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
134 } 117 }
135 118
136 TEST_F(GeneralLossAlgorithmTest, EarlyRetransmit1Packet) { 119 TEST_F(GeneralLossAlgorithmTest, EarlyRetransmit1Packet) {
137 const size_t kNumSentPackets = 2; 120 const size_t kNumSentPackets = 2;
138 // Transmit 2 packets. 121 // Transmit 2 packets.
139 for (size_t i = 1; i <= kNumSentPackets; ++i) { 122 for (size_t i = 1; i <= kNumSentPackets; ++i) {
140 SendDataPacket(i); 123 SendDataPacket(i);
141 } 124 }
142 // Early retransmit when the final packet gets acked and the first is nacked. 125 // Early retransmit when the final packet gets acked and the first is nacked.
143 unacked_packets_.RemoveFromInFlight(2); 126 unacked_packets_.RemoveFromInFlight(2);
144 if (!FLAGS_quic_simplify_loss_detection) {
145 unacked_packets_.NackPacket(1, 1);
146 }
147 VerifyLosses(2, nullptr, 0); 127 VerifyLosses(2, nullptr, 0);
148 EXPECT_EQ(clock_.Now().Add(rtt_stats_.smoothed_rtt().Multiply(1.25)), 128 EXPECT_EQ(clock_.Now().Add(rtt_stats_.smoothed_rtt().Multiply(1.25)),
149 loss_algorithm_.GetLossTimeout()); 129 loss_algorithm_.GetLossTimeout());
150 130
151 clock_.AdvanceTime(rtt_stats_.latest_rtt().Multiply(1.25)); 131 clock_.AdvanceTime(rtt_stats_.latest_rtt().Multiply(1.25));
152 QuicPacketNumber lost[] = {1}; 132 QuicPacketNumber lost[] = {1};
153 VerifyLosses(2, lost, arraysize(lost)); 133 VerifyLosses(2, lost, arraysize(lost));
154 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 134 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
155 } 135 }
156 136
157 TEST_F(GeneralLossAlgorithmTest, EarlyRetransmitAllPackets) { 137 TEST_F(GeneralLossAlgorithmTest, EarlyRetransmitAllPackets) {
158 const size_t kNumSentPackets = 5; 138 const size_t kNumSentPackets = 5;
159 for (size_t i = 1; i <= kNumSentPackets; ++i) { 139 for (size_t i = 1; i <= kNumSentPackets; ++i) {
160 SendDataPacket(i); 140 SendDataPacket(i);
161 // Advance the time 1/4 RTT between 3 and 4. 141 // Advance the time 1/4 RTT between 3 and 4.
162 if (i == 3) { 142 if (i == 3) {
163 clock_.AdvanceTime(rtt_stats_.smoothed_rtt().Multiply(0.25)); 143 clock_.AdvanceTime(rtt_stats_.smoothed_rtt().Multiply(0.25));
164 } 144 }
165 } 145 }
166 146
167 // Early retransmit when the final packet gets acked and 1.25 RTTs have 147 // Early retransmit when the final packet gets acked and 1.25 RTTs have
168 // elapsed since the packets were sent. 148 // elapsed since the packets were sent.
169 unacked_packets_.RemoveFromInFlight(kNumSentPackets); 149 unacked_packets_.RemoveFromInFlight(kNumSentPackets);
170 // This simulates a single ack following multiple missing packets with FACK. 150 // This simulates a single ack following multiple missing packets with FACK.
171 if (!FLAGS_quic_simplify_loss_detection) {
172 for (size_t i = 1; i < kNumSentPackets; ++i) {
173 unacked_packets_.NackPacket(i, kNumSentPackets - i);
174 }
175 }
176 QuicPacketNumber lost[] = {1, 2}; 151 QuicPacketNumber lost[] = {1, 2};
177 VerifyLosses(kNumSentPackets, lost, arraysize(lost)); 152 VerifyLosses(kNumSentPackets, lost, arraysize(lost));
178 // The time has already advanced 1/4 an RTT, so ensure the timeout is set 153 // The time has already advanced 1/4 an RTT, so ensure the timeout is set
179 // 1.25 RTTs after the earliest pending packet(3), not the last(4). 154 // 1.25 RTTs after the earliest pending packet(3), not the last(4).
180 EXPECT_EQ(clock_.Now().Add(rtt_stats_.smoothed_rtt()), 155 EXPECT_EQ(clock_.Now().Add(rtt_stats_.smoothed_rtt()),
181 loss_algorithm_.GetLossTimeout()); 156 loss_algorithm_.GetLossTimeout());
182 157
183 clock_.AdvanceTime(rtt_stats_.smoothed_rtt()); 158 clock_.AdvanceTime(rtt_stats_.smoothed_rtt());
184 QuicPacketNumber lost2[] = {1, 2, 3}; 159 QuicPacketNumber lost2[] = {1, 2, 3};
185 VerifyLosses(kNumSentPackets, lost2, arraysize(lost2)); 160 VerifyLosses(kNumSentPackets, lost2, arraysize(lost2));
(...skipping 10 matching lines...) Expand all
196 // Transmit 2 packets. 171 // Transmit 2 packets.
197 for (size_t i = 1; i <= kNumSentPackets; ++i) { 172 for (size_t i = 1; i <= kNumSentPackets; ++i) {
198 SendDataPacket(i); 173 SendDataPacket(i);
199 } 174 }
200 // Neuter packet 1. 175 // Neuter packet 1.
201 unacked_packets_.RemoveRetransmittability(1); 176 unacked_packets_.RemoveRetransmittability(1);
202 177
203 // Early retransmit when the final packet gets acked and the first is nacked. 178 // Early retransmit when the final packet gets acked and the first is nacked.
204 unacked_packets_.IncreaseLargestObserved(2); 179 unacked_packets_.IncreaseLargestObserved(2);
205 unacked_packets_.RemoveFromInFlight(2); 180 unacked_packets_.RemoveFromInFlight(2);
206 if (!FLAGS_quic_simplify_loss_detection) {
207 unacked_packets_.NackPacket(1, 1);
208 }
209 VerifyLosses(2, nullptr, 0); 181 VerifyLosses(2, nullptr, 0);
210 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 182 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
211 } 183 }
212 184
213 TEST_F(GeneralLossAlgorithmTest, AlwaysLosePacketSent1RTTEarlier) { 185 TEST_F(GeneralLossAlgorithmTest, AlwaysLosePacketSent1RTTEarlier) {
214 // Transmit 1 packet and then wait an rtt plus 1ms. 186 // Transmit 1 packet and then wait an rtt plus 1ms.
215 SendDataPacket(1); 187 SendDataPacket(1);
216 clock_.AdvanceTime( 188 clock_.AdvanceTime(
217 rtt_stats_.smoothed_rtt().Add(QuicTime::Delta::FromMilliseconds(1))); 189 rtt_stats_.smoothed_rtt().Add(QuicTime::Delta::FromMilliseconds(1)));
218 190
219 // Transmit 2 packets. 191 // Transmit 2 packets.
220 SendDataPacket(2); 192 SendDataPacket(2);
221 SendDataPacket(3); 193 SendDataPacket(3);
222 194
223 // Wait another RTT and ack 2. 195 // Wait another RTT and ack 2.
224 clock_.AdvanceTime(rtt_stats_.smoothed_rtt()); 196 clock_.AdvanceTime(rtt_stats_.smoothed_rtt());
225 unacked_packets_.IncreaseLargestObserved(2); 197 unacked_packets_.IncreaseLargestObserved(2);
226 unacked_packets_.RemoveFromInFlight(2); 198 unacked_packets_.RemoveFromInFlight(2);
227 if (!FLAGS_quic_simplify_loss_detection) {
228 unacked_packets_.NackPacket(1, 1);
229 }
230 QuicPacketNumber lost[] = {1}; 199 QuicPacketNumber lost[] = {1};
231 VerifyLosses(2, lost, arraysize(lost)); 200 VerifyLosses(2, lost, arraysize(lost));
232 } 201 }
233 202
234 // Time-based loss detection tests. 203 // Time-based loss detection tests.
235 TEST_F(GeneralLossAlgorithmTest, NoLossFor500Nacks) { 204 TEST_F(GeneralLossAlgorithmTest, NoLossFor500Nacks) {
236 loss_algorithm_.SetLossDetectionType(kTime); 205 loss_algorithm_.SetLossDetectionType(kTime);
237 const size_t kNumSentPackets = 5; 206 const size_t kNumSentPackets = 5;
238 // Transmit 5 packets. 207 // Transmit 5 packets.
239 for (size_t i = 1; i <= kNumSentPackets; ++i) { 208 for (size_t i = 1; i <= kNumSentPackets; ++i) {
240 SendDataPacket(i); 209 SendDataPacket(i);
241 } 210 }
242 unacked_packets_.RemoveFromInFlight(2); 211 unacked_packets_.RemoveFromInFlight(2);
243 for (size_t i = 1; i < 500; ++i) { 212 for (size_t i = 1; i < 500; ++i) {
244 if (!FLAGS_quic_simplify_loss_detection) {
245 unacked_packets_.NackPacket(1, i);
246 }
247 VerifyLosses(2, nullptr, 0); 213 VerifyLosses(2, nullptr, 0);
248 } 214 }
249 EXPECT_EQ(rtt_stats_.smoothed_rtt().Multiply(1.25), 215 EXPECT_EQ(rtt_stats_.smoothed_rtt().Multiply(1.25),
250 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now())); 216 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now()));
251 } 217 }
252 218
253 TEST_F(GeneralLossAlgorithmTest, NoLossUntilTimeout) { 219 TEST_F(GeneralLossAlgorithmTest, NoLossUntilTimeout) {
254 loss_algorithm_.SetLossDetectionType(kTime); 220 loss_algorithm_.SetLossDetectionType(kTime);
255 const size_t kNumSentPackets = 10; 221 const size_t kNumSentPackets = 10;
256 // Transmit 10 packets at 1/10th an RTT interval. 222 // Transmit 10 packets at 1/10th an RTT interval.
257 for (size_t i = 1; i <= kNumSentPackets; ++i) { 223 for (size_t i = 1; i <= kNumSentPackets; ++i) {
258 SendDataPacket(i); 224 SendDataPacket(i);
259 clock_.AdvanceTime(rtt_stats_.smoothed_rtt().Multiply(0.1)); 225 clock_.AdvanceTime(rtt_stats_.smoothed_rtt().Multiply(0.1));
260 } 226 }
261 // Expect the timer to not be set. 227 // Expect the timer to not be set.
262 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 228 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
263 // The packet should not be lost until 1.25 RTTs pass. 229 // The packet should not be lost until 1.25 RTTs pass.
264 if (!FLAGS_quic_simplify_loss_detection) {
265 unacked_packets_.NackPacket(1, 1);
266 }
267 unacked_packets_.RemoveFromInFlight(2); 230 unacked_packets_.RemoveFromInFlight(2);
268 VerifyLosses(2, nullptr, 0); 231 VerifyLosses(2, nullptr, 0);
269 // Expect the timer to be set to 0.25 RTT's in the future. 232 // Expect the timer to be set to 0.25 RTT's in the future.
270 EXPECT_EQ(rtt_stats_.smoothed_rtt().Multiply(0.25), 233 EXPECT_EQ(rtt_stats_.smoothed_rtt().Multiply(0.25),
271 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now())); 234 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now()));
272 if (!FLAGS_quic_simplify_loss_detection) {
273 unacked_packets_.NackPacket(1, 5);
274 }
275 VerifyLosses(2, nullptr, 0); 235 VerifyLosses(2, nullptr, 0);
276 clock_.AdvanceTime(rtt_stats_.smoothed_rtt().Multiply(0.25)); 236 clock_.AdvanceTime(rtt_stats_.smoothed_rtt().Multiply(0.25));
277 QuicPacketNumber lost[] = {1}; 237 QuicPacketNumber lost[] = {1};
278 VerifyLosses(2, lost, arraysize(lost)); 238 VerifyLosses(2, lost, arraysize(lost));
279 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 239 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
280 } 240 }
281 241
282 TEST_F(GeneralLossAlgorithmTest, NoLossWithoutNack) { 242 TEST_F(GeneralLossAlgorithmTest, NoLossWithoutNack) {
283 loss_algorithm_.SetLossDetectionType(kTime); 243 loss_algorithm_.SetLossDetectionType(kTime);
284 const size_t kNumSentPackets = 10; 244 const size_t kNumSentPackets = 10;
(...skipping 21 matching lines...) Expand all
306 loss_algorithm_.SetLossDetectionType(kTime); 266 loss_algorithm_.SetLossDetectionType(kTime);
307 const size_t kNumSentPackets = 10; 267 const size_t kNumSentPackets = 10;
308 // Transmit 10 packets at once and then go forward an RTT. 268 // Transmit 10 packets at once and then go forward an RTT.
309 for (size_t i = 1; i <= kNumSentPackets; ++i) { 269 for (size_t i = 1; i <= kNumSentPackets; ++i) {
310 SendDataPacket(i); 270 SendDataPacket(i);
311 } 271 }
312 clock_.AdvanceTime(rtt_stats_.smoothed_rtt()); 272 clock_.AdvanceTime(rtt_stats_.smoothed_rtt());
313 // Expect the timer to not be set. 273 // Expect the timer to not be set.
314 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 274 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
315 // The packet should not be lost until 1.25 RTTs pass. 275 // The packet should not be lost until 1.25 RTTs pass.
316 if (!FLAGS_quic_simplify_loss_detection) {
317 for (size_t i = 1; i < kNumSentPackets; ++i) {
318 unacked_packets_.NackPacket(i, 1);
319 }
320 }
321 unacked_packets_.RemoveFromInFlight(10); 276 unacked_packets_.RemoveFromInFlight(10);
322 VerifyLosses(10, nullptr, 0); 277 VerifyLosses(10, nullptr, 0);
323 // Expect the timer to be set to 0.25 RTT's in the future. 278 // Expect the timer to be set to 0.25 RTT's in the future.
324 EXPECT_EQ(rtt_stats_.smoothed_rtt().Multiply(0.25), 279 EXPECT_EQ(rtt_stats_.smoothed_rtt().Multiply(0.25),
325 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now())); 280 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now()));
326 clock_.AdvanceTime(rtt_stats_.smoothed_rtt().Multiply(0.25)); 281 clock_.AdvanceTime(rtt_stats_.smoothed_rtt().Multiply(0.25));
327 QuicPacketNumber lost[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; 282 QuicPacketNumber lost[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
328 VerifyLosses(10, lost, arraysize(lost)); 283 VerifyLosses(10, lost, arraysize(lost));
329 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 284 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
330 } 285 }
331 286
332 TEST_F(GeneralLossAlgorithmTest, NoSpuriousLossesFromLargeReordering) { 287 TEST_F(GeneralLossAlgorithmTest, NoSpuriousLossesFromLargeReordering) {
333 FLAGS_quic_simplify_loss_detection = true;
334 FLAGS_quic_loss_recovery_use_largest_acked = true; 288 FLAGS_quic_loss_recovery_use_largest_acked = true;
335 loss_algorithm_.SetLossDetectionType(kTime); 289 loss_algorithm_.SetLossDetectionType(kTime);
336 const size_t kNumSentPackets = 10; 290 const size_t kNumSentPackets = 10;
337 // Transmit 10 packets at once and then go forward an RTT. 291 // Transmit 10 packets at once and then go forward an RTT.
338 for (size_t i = 1; i <= kNumSentPackets; ++i) { 292 for (size_t i = 1; i <= kNumSentPackets; ++i) {
339 SendDataPacket(i); 293 SendDataPacket(i);
340 } 294 }
341 clock_.AdvanceTime(rtt_stats_.smoothed_rtt()); 295 clock_.AdvanceTime(rtt_stats_.smoothed_rtt());
342 // Expect the timer to not be set. 296 // Expect the timer to not be set.
343 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 297 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
344 // The packet should not be lost until 1.25 RTTs pass. 298 // The packet should not be lost until 1.25 RTTs pass.
345 299
346 unacked_packets_.RemoveFromInFlight(10); 300 unacked_packets_.RemoveFromInFlight(10);
347 VerifyLosses(10, nullptr, 0); 301 VerifyLosses(10, nullptr, 0);
348 // Expect the timer to be set to 0.25 RTT's in the future. 302 // Expect the timer to be set to 0.25 RTT's in the future.
349 EXPECT_EQ(rtt_stats_.smoothed_rtt().Multiply(0.25), 303 EXPECT_EQ(rtt_stats_.smoothed_rtt().Multiply(0.25),
350 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now())); 304 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now()));
351 clock_.AdvanceTime(rtt_stats_.smoothed_rtt().Multiply(0.25)); 305 clock_.AdvanceTime(rtt_stats_.smoothed_rtt().Multiply(0.25));
352 // Now ack packets 1 to 9 and ensure the timer is no longer set and no packets 306 // Now ack packets 1 to 9 and ensure the timer is no longer set and no packets
353 // are lost. 307 // are lost.
354 for (QuicPacketNumber i = 1; i <= 9; ++i) { 308 for (QuicPacketNumber i = 1; i <= 9; ++i) {
355 unacked_packets_.RemoveFromInFlight(i); 309 unacked_packets_.RemoveFromInFlight(i);
356 VerifyLosses(i, nullptr, 0); 310 VerifyLosses(i, nullptr, 0);
357 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 311 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
358 } 312 }
359 } 313 }
360 314
361 TEST_F(GeneralLossAlgorithmTest, IncreaseThresholdUponSpuriousLoss) { 315 TEST_F(GeneralLossAlgorithmTest, IncreaseThresholdUponSpuriousLoss) {
362 FLAGS_quic_simplify_loss_detection = true;
363 FLAGS_quic_adaptive_loss_recovery = true; 316 FLAGS_quic_adaptive_loss_recovery = true;
364 loss_algorithm_.SetLossDetectionType(kAdaptiveTime); 317 loss_algorithm_.SetLossDetectionType(kAdaptiveTime);
365 EXPECT_EQ(16, loss_algorithm_.reordering_fraction()); 318 EXPECT_EQ(16, loss_algorithm_.reordering_fraction());
366 const size_t kNumSentPackets = 10; 319 const size_t kNumSentPackets = 10;
367 // Transmit 2 packets at 1/10th an RTT interval. 320 // Transmit 2 packets at 1/10th an RTT interval.
368 for (size_t i = 1; i <= kNumSentPackets; ++i) { 321 for (size_t i = 1; i <= kNumSentPackets; ++i) {
369 SendDataPacket(i); 322 SendDataPacket(i);
370 clock_.AdvanceTime(rtt_stats_.smoothed_rtt().Multiply(0.1)); 323 clock_.AdvanceTime(rtt_stats_.smoothed_rtt().Multiply(0.1));
371 } 324 }
372 EXPECT_EQ(QuicTime::Zero().Add(rtt_stats_.smoothed_rtt()), clock_.Now()); 325 EXPECT_EQ(QuicTime::Zero().Add(rtt_stats_.smoothed_rtt()), clock_.Now());
(...skipping 25 matching lines...) Expand all
398 // Detect another spurious retransmit and ensure the threshold doesn't 351 // Detect another spurious retransmit and ensure the threshold doesn't
399 // increase again. 352 // increase again.
400 loss_algorithm_.SpuriousRetransmitDetected(unacked_packets_, clock_.Now(), 353 loss_algorithm_.SpuriousRetransmitDetected(unacked_packets_, clock_.Now(),
401 rtt_stats_, 12); 354 rtt_stats_, 12);
402 EXPECT_EQ(2, loss_algorithm_.reordering_fraction()); 355 EXPECT_EQ(2, loss_algorithm_.reordering_fraction());
403 } 356 }
404 357
405 } // namespace 358 } // namespace
406 } // namespace test 359 } // namespace test
407 } // namespace net 360 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/general_loss_algorithm.cc ('k') | net/quic/quic_flags.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698