@@ -266,10 +266,11 @@ pub struct RecvdPackets {
266
266
unacknowledged_count : PacketNumber ,
267
267
/// The number of contiguous packets that can be received without
268
268
/// acknowledging immediately.
269
- unacknowledged_tolerance : PacketNumber ,
270
- /// Whether we are ignoring packets that arrive out of order
271
- /// for the purposes of generating immediate acknowledgment.
272
- ignore_order : bool ,
269
+ ack_eliciting_threshold : PacketNumber ,
270
+ /// > the maximum packet reordering before eliciting an immediate ACK
271
+ ///
272
+ /// <https://www.ietf.org/archive/id/draft-ietf-quic-ack-frequency-10.html#section-4>
273
+ reordering_threshold : u64 ,
273
274
// The counts of different ECN marks that have been received.
274
275
ecn_count : ecn:: Count ,
275
276
}
@@ -287,13 +288,19 @@ impl RecvdPackets {
287
288
ack_frequency_seqno : 0 ,
288
289
ack_delay : DEFAULT_ACK_DELAY ,
289
290
unacknowledged_count : 0 ,
290
- unacknowledged_tolerance : if space == PacketNumberSpace :: ApplicationData {
291
+ ack_eliciting_threshold : if space == PacketNumberSpace :: ApplicationData {
291
292
DEFAULT_ACK_PACKET_TOLERANCE
292
293
} else {
293
294
// ACK more aggressively
294
295
0
295
296
} ,
296
- ignore_order : false ,
297
+ // > If no ACK_FREQUENCY frames have been received, the data receiver
298
+ // > immediately acknowledges any subsequent packets that are received
299
+ // > out-of-order, as specified in Section 13.2 of [QUIC-TRANSPORT],
300
+ // > corresponding to a default value of 1.
301
+ //
302
+ // <https://www.ietf.org/archive/id/draft-ietf-quic-ack-frequency-10.html#section-4>
303
+ reordering_threshold : 1 ,
297
304
ecn_count : ecn:: Count :: default ( ) ,
298
305
}
299
306
}
@@ -312,18 +319,18 @@ impl RecvdPackets {
312
319
pub fn ack_freq (
313
320
& mut self ,
314
321
seqno : u64 ,
315
- tolerance : PacketNumber ,
322
+ ack_eliciting_threshold : PacketNumber ,
316
323
delay : Duration ,
317
- ignore_order : bool ,
324
+ reordering_threshold : u64 ,
318
325
) {
319
326
// Yes, this means that we will overwrite values if a sequence number is
320
327
// reused, but that is better than using an `Option<PacketNumber>`
321
328
// when it will always be `Some`.
322
329
if seqno >= self . ack_frequency_seqno {
323
330
self . ack_frequency_seqno = seqno;
324
- self . unacknowledged_tolerance = tolerance ;
331
+ self . ack_eliciting_threshold = ack_eliciting_threshold ;
325
332
self . ack_delay = delay;
326
- self . ignore_order = ignore_order ;
333
+ self . reordering_threshold = reordering_threshold ;
327
334
}
328
335
}
329
336
@@ -399,8 +406,16 @@ impl RecvdPackets {
399
406
self . unacknowledged_count += 1 ;
400
407
401
408
let immediate_ack = self . space != PacketNumberSpace :: ApplicationData
402
- || ( pn != next_in_order_pn && !self . ignore_order )
403
- || self . unacknowledged_count > self . unacknowledged_tolerance ;
409
+ // > If no ACK_FREQUENCY frames have been received, the data
410
+ // > receiver immediately acknowledges any subsequent packets that are
411
+ // > received out-of-order, as specified in Section 13.2 of
412
+ // > [QUIC-TRANSPORT], corresponding to a default value of 1. A value
413
+ // > of 0 indicates out-of-order packets do not elicit an immediate
414
+ // > ACK.
415
+ //
416
+ // <https://www.ietf.org/archive/id/draft-ietf-quic-ack-frequency-10.html#section-4>
417
+ || ( self . reordering_threshold != 0 && pn. saturating_sub ( next_in_order_pn) >= self . reordering_threshold )
418
+ || self . unacknowledged_count > self . ack_eliciting_threshold ;
404
419
405
420
let ack_time = if immediate_ack {
406
421
now
@@ -579,13 +594,13 @@ impl AckTracker {
579
594
pub fn ack_freq (
580
595
& mut self ,
581
596
seqno : u64 ,
582
- tolerance : PacketNumber ,
597
+ ack_eliciting_threshold : PacketNumber ,
583
598
delay : Duration ,
584
- ignore_order : bool ,
599
+ reordering_threshold : u64 ,
585
600
) {
586
601
// Only ApplicationData ever delays ACK.
587
602
if let Some ( space) = self . get_mut ( PacketNumberSpace :: ApplicationData ) {
588
- space. ack_freq ( seqno, tolerance , delay, ignore_order ) ;
603
+ space. ack_freq ( seqno, ack_eliciting_threshold , delay, reordering_threshold ) ;
589
604
}
590
605
}
591
606
@@ -758,7 +773,7 @@ mod tests {
758
773
assert ! ( rp. ack_time( ) . is_none( ) ) ;
759
774
assert ! ( !rp. ack_now( now( ) , RTT ) ) ;
760
775
761
- rp. ack_freq ( 0 , COUNT , DELAY , false ) ;
776
+ rp. ack_freq ( 0 , COUNT , DELAY , 0 ) ;
762
777
763
778
// Some packets won't cause an ACK to be needed.
764
779
for i in 0 ..COUNT {
@@ -848,7 +863,7 @@ mod tests {
848
863
let mut rp = RecvdPackets :: new ( PacketNumberSpace :: ApplicationData ) ;
849
864
850
865
// Set tolerance to 2 and then it takes three packets.
851
- rp. ack_freq ( 0 , 2 , Duration :: from_millis ( 10 ) , true ) ;
866
+ rp. ack_freq ( 0 , 2 , Duration :: from_millis ( 10 ) , 1 ) ;
852
867
853
868
rp. set_received ( now ( ) , 1 , true ) ;
854
869
assert_ne ! ( Some ( now( ) ) , rp. ack_time( ) ) ;
@@ -865,7 +880,7 @@ mod tests {
865
880
write_frame ( & mut rp) ;
866
881
867
882
// Set tolerance to 2 and then it takes three packets.
868
- rp. ack_freq ( 0 , 2 , Duration :: from_millis ( 10 ) , true ) ;
883
+ rp. ack_freq ( 0 , 2 , Duration :: from_millis ( 10 ) , 1 ) ;
869
884
870
885
rp. set_received ( now ( ) , 3 , true ) ;
871
886
assert_ne ! ( Some ( now( ) ) , rp. ack_time( ) ) ;
@@ -880,7 +895,7 @@ mod tests {
880
895
#[ test]
881
896
fn non_ack_eliciting_skip ( ) {
882
897
let mut rp = RecvdPackets :: new ( PacketNumberSpace :: ApplicationData ) ;
883
- rp. ack_freq ( 0 , 1 , Duration :: from_millis ( 10 ) , true ) ;
898
+ rp. ack_freq ( 0 , 1 , Duration :: from_millis ( 10 ) , 1 ) ;
884
899
885
900
// This should be ignored.
886
901
rp. set_received ( now ( ) , 0 , false ) ;
@@ -896,7 +911,7 @@ mod tests {
896
911
#[ test]
897
912
fn non_ack_eliciting_reorder ( ) {
898
913
let mut rp = RecvdPackets :: new ( PacketNumberSpace :: ApplicationData ) ;
899
- rp. ack_freq ( 0 , 1 , Duration :: from_millis ( 10 ) , false ) ;
914
+ rp. ack_freq ( 0 , 1 , Duration :: from_millis ( 10 ) , 1 ) ;
900
915
901
916
// These are out of order, but they are not ack-eliciting.
902
917
rp. set_received ( now ( ) , 1 , false ) ;
@@ -915,7 +930,7 @@ mod tests {
915
930
fn aggregate_ack_time ( ) {
916
931
const DELAY : Duration = Duration :: from_millis ( 17 ) ;
917
932
let mut tracker = AckTracker :: default ( ) ;
918
- tracker. ack_freq ( 0 , 1 , DELAY , false ) ;
933
+ tracker. ack_freq ( 0 , 1 , DELAY , 1 ) ;
919
934
// This packet won't trigger an ACK.
920
935
tracker
921
936
. get_mut ( PacketNumberSpace :: Handshake )
0 commit comments