@@ -266,10 +266,11 @@ pub struct RecvdPackets {
266266unacknowledged_count :  PacketNumber , 
267267    /// The number of contiguous packets that can be received without 
268268/// 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 , 
273274    // The counts of different ECN marks that have been received. 
274275    ecn_count :  ecn:: Count , 
275276} 
@@ -287,13 +288,19 @@ impl RecvdPackets {
287288            ack_frequency_seqno :  0 , 
288289            ack_delay :  DEFAULT_ACK_DELAY , 
289290            unacknowledged_count :  0 , 
290-             unacknowledged_tolerance :  if  space == PacketNumberSpace :: ApplicationData  { 
291+             ack_eliciting_threshold :  if  space == PacketNumberSpace :: ApplicationData  { 
291292                DEFAULT_ACK_PACKET_TOLERANCE 
292293            }  else  { 
293294                // ACK more aggressively 
294295                0 
295296            } , 
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 , 
297304            ecn_count :  ecn:: Count :: default ( ) , 
298305        } 
299306    } 
@@ -312,18 +319,18 @@ impl RecvdPackets {
312319pub  fn  ack_freq ( 
313320        & mut  self , 
314321        seqno :  u64 , 
315-         tolerance :  PacketNumber , 
322+         ack_eliciting_threshold :  PacketNumber , 
316323        delay :  Duration , 
317-         ignore_order :   bool , 
324+         reordering_threshold :   u64 , 
318325    )  { 
319326        // Yes, this means that we will overwrite values if a sequence number is 
320327        // reused, but that is better than using an `Option<PacketNumber>` 
321328        // when it will always be `Some`. 
322329        if  seqno >= self . ack_frequency_seqno  { 
323330            self . ack_frequency_seqno  = seqno; 
324-             self . unacknowledged_tolerance  = tolerance ; 
331+             self . ack_eliciting_threshold  = ack_eliciting_threshold ; 
325332            self . ack_delay  = delay; 
326-             self . ignore_order  = ignore_order ; 
333+             self . reordering_threshold  = reordering_threshold ; 
327334        } 
328335    } 
329336
@@ -399,8 +406,16 @@ impl RecvdPackets {
399406            self . unacknowledged_count  += 1 ; 
400407
401408            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 ; 
404419
405420            let  ack_time = if  immediate_ack { 
406421                now
@@ -579,13 +594,13 @@ impl AckTracker {
579594    pub  fn  ack_freq ( 
580595        & mut  self , 
581596        seqno :  u64 , 
582-         tolerance :  PacketNumber , 
597+         ack_eliciting_threshold :  PacketNumber , 
583598        delay :  Duration , 
584-         ignore_order :   bool , 
599+         reordering_threshold :   u64 , 
585600    )  { 
586601        // Only ApplicationData ever delays ACK. 
587602        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 ) ; 
589604        } 
590605    } 
591606
@@ -758,7 +773,7 @@ mod tests {
758773        assert ! ( rp. ack_time( ) . is_none( ) ) ; 
759774        assert ! ( !rp. ack_now( now( ) ,  RTT ) ) ; 
760775
761-         rp. ack_freq ( 0 ,  COUNT ,  DELAY ,  false ) ; 
776+         rp. ack_freq ( 0 ,  COUNT ,  DELAY ,  0 ) ; 
762777
763778        // Some packets won't cause an ACK to be needed. 
764779        for  i in  0 ..COUNT  { 
@@ -848,7 +863,7 @@ mod tests {
848863        let  mut  rp = RecvdPackets :: new ( PacketNumberSpace :: ApplicationData ) ; 
849864
850865        // 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 ) ; 
852867
853868        rp. set_received ( now ( ) ,  1 ,  true ) ; 
854869        assert_ne ! ( Some ( now( ) ) ,  rp. ack_time( ) ) ; 
@@ -865,7 +880,7 @@ mod tests {
865880        write_frame ( & mut  rp) ; 
866881
867882        // 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 ) ; 
869884
870885        rp. set_received ( now ( ) ,  3 ,  true ) ; 
871886        assert_ne ! ( Some ( now( ) ) ,  rp. ack_time( ) ) ; 
@@ -880,7 +895,7 @@ mod tests {
880895#[ test]  
881896    fn  non_ack_eliciting_skip ( )  { 
882897        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 ) ; 
884899
885900        // This should be ignored. 
886901        rp. set_received ( now ( ) ,  0 ,  false ) ; 
@@ -896,7 +911,7 @@ mod tests {
896911#[ test]  
897912    fn  non_ack_eliciting_reorder ( )  { 
898913        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 ) ; 
900915
901916        // These are out of order, but they are not ack-eliciting. 
902917        rp. set_received ( now ( ) ,  1 ,  false ) ; 
@@ -915,7 +930,7 @@ mod tests {
915930    fn  aggregate_ack_time ( )  { 
916931        const  DELAY :  Duration  = Duration :: from_millis ( 17 ) ; 
917932        let  mut  tracker = AckTracker :: default ( ) ; 
918-         tracker. ack_freq ( 0 ,  1 ,  DELAY ,  false ) ; 
933+         tracker. ack_freq ( 0 ,  1 ,  DELAY ,  1 ) ; 
919934        // This packet won't trigger an ACK. 
920935        tracker
921936            . get_mut ( PacketNumberSpace :: Handshake ) 
0 commit comments