@@ -311,7 +311,8 @@ impl Bbr {
311311 // available.
312312 if self . pacing_rate == 0 && self . min_rtt . total_micros ( ) != 0 {
313313 self . pacing_rate =
314- BandwidthEstimation :: bw_from_delta ( self . init_cwnd as u64 , self . min_rtt ) . unwrap_or ( 0 ) ;
314+ BandwidthEstimation :: bw_from_delta ( self . init_cwnd as u64 , self . min_rtt )
315+ . unwrap_or ( 0 ) ;
315316 return ;
316317 }
317318
@@ -328,7 +329,8 @@ impl Bbr {
328329 let mut target_window = self . get_target_cwnd ( self . cwnd_gain ) ;
329330 if self . is_at_full_bandwidth {
330331 // Add the max recently measured ack aggregation to CWND.
331- target_window = target_window. saturating_add ( self . ack_aggregation . max_ack_height . get ( ) as usize ) ;
332+ target_window =
333+ target_window. saturating_add ( self . ack_aggregation . max_ack_height . get ( ) as usize ) ;
332334 } else {
333335 // Add the most recent excess acked. Because CWND never decreases in
334336 // STARTUP, this will automatically create a very localized max filter.
@@ -339,7 +341,9 @@ impl Bbr {
339341 // time.
340342 if self . is_at_full_bandwidth {
341343 self . cwnd = target_window. min ( self . cwnd . saturating_add ( bytes_acked) ) ;
342- } else if ( self . cwnd_gain < target_window as f32 ) || ( self . acked_bytes < self . init_cwnd as u64 ) {
344+ } else if ( self . cwnd_gain < target_window as f32 )
345+ || ( self . acked_bytes < self . init_cwnd as u64 )
346+ {
343347 // If the connection is not yet out of startup phase, do not decrease
344348 // the window.
345349 self . cwnd = self . cwnd . saturating_add ( bytes_acked) ;
@@ -351,7 +355,12 @@ impl Bbr {
351355 }
352356 }
353357
354- fn calculate_recovery_window ( & mut self , bytes_acked : usize , bytes_lost : usize , in_flight : usize ) {
358+ fn calculate_recovery_window (
359+ & mut self ,
360+ bytes_acked : usize ,
361+ bytes_lost : usize ,
362+ in_flight : usize ,
363+ ) {
355364 if !self . recovery_state . in_recovery ( ) {
356365 return ;
357366 }
@@ -412,7 +421,8 @@ impl Bbr {
412421 self . max_acked_packet_number = packet_number;
413422
414423 // Update bandwidth estimation with app_limited state
415- self . max_bandwidth . on_ack ( now, now, bytes, self . round_count , self . app_limited ) ;
424+ self . max_bandwidth
425+ . on_ack ( now, now, bytes, self . round_count , self . app_limited ) ;
416426 self . acked_bytes += bytes;
417427
418428 if self . min_rtt == Duration :: ZERO || self . min_rtt > rtt. min_rtt ( ) {
@@ -427,7 +437,8 @@ impl Bbr {
427437 self . round_count ,
428438 self . max_bandwidth . get_estimate ( ) ,
429439 ) as usize ;
430- self . max_bandwidth . end_acks ( self . round_count , self . app_limited ) ;
440+ self . max_bandwidth
441+ . end_acks ( self . round_count , self . app_limited ) ;
431442
432443 let mut is_round_start = false ;
433444 if bytes_acked > 0 {
@@ -706,7 +717,11 @@ mod test {
706717 // BBR should track losses
707718 assert ! ( bbr. loss_state. has_losses( ) ) ;
708719
709- println ! ( "BBR: cwnd before loss = {}, after loss = {}" , cwnd_before, bbr. window( ) ) ;
720+ println ! (
721+ "BBR: cwnd before loss = {}, after loss = {}" ,
722+ cwnd_before,
723+ bbr. window( )
724+ ) ;
710725 }
711726
712727 #[ test]
@@ -724,7 +739,11 @@ mod test {
724739 // BBR should track this as a loss signal
725740 assert ! ( bbr. loss_state. has_losses( ) ) ;
726741
727- println ! ( "BBR: cwnd before dup ack = {}, after = {}" , cwnd_before, bbr. window( ) ) ;
742+ println ! (
743+ "BBR: cwnd before dup ack = {}, after = {}" ,
744+ cwnd_before,
745+ bbr. window( )
746+ ) ;
728747 }
729748
730749 #[ test]
@@ -744,7 +763,11 @@ mod test {
744763 assert ! ( cwnd >= bbr. min_cwnd) ;
745764 }
746765
747- println ! ( "BBR: min_cwnd = {}, final cwnd = {}" , bbr. min_cwnd, bbr. window( ) ) ;
766+ println ! (
767+ "BBR: min_cwnd = {}, final cwnd = {}" ,
768+ bbr. min_cwnd,
769+ bbr. window( )
770+ ) ;
748771 }
749772
750773 #[ test]
@@ -766,7 +789,11 @@ mod test {
766789 // Window should not exceed remote window
767790 assert ! ( bbr. window( ) <= remote_window) ;
768791
769- println ! ( "BBR: remote_window = {}, cwnd = {}" , remote_window, bbr. window( ) ) ;
792+ println ! (
793+ "BBR: remote_window = {}, cwnd = {}" ,
794+ remote_window,
795+ bbr. window( )
796+ ) ;
770797 }
771798
772799 #[ test]
@@ -785,7 +812,7 @@ mod test {
785812 let now = Instant :: from_millis ( 1000 ) ;
786813
787814 // First call should transition to Drain mode
788- bbr. maybe_exit_startup_or_drain ( now, bbr. window ( ) * 2 ) ; // High in_flight to stay in Drain
815+ bbr. maybe_exit_startup_or_drain ( now, bbr. window ( ) * 2 ) ; // High in_flight to stay in Drain
789816 assert_eq ! ( bbr. mode, Mode :: Drain ) ;
790817 println ! ( "BBR: After full BW = {:?}" , bbr. mode) ;
791818
@@ -920,7 +947,13 @@ mod test {
920947 // Simulate stalled bandwidth growth
921948 bbr. bw_at_last_round = 1000000 ;
922949 bbr. max_bandwidth . on_sent ( Instant :: from_millis ( 0 ) , 1000 ) ;
923- bbr. max_bandwidth . on_ack ( Instant :: from_millis ( 10 ) , Instant :: from_millis ( 0 ) , 1000 , 0 , false ) ;
950+ bbr. max_bandwidth . on_ack (
951+ Instant :: from_millis ( 10 ) ,
952+ Instant :: from_millis ( 0 ) ,
953+ 1000 ,
954+ 0 ,
955+ false ,
956+ ) ;
924957
925958 // If bandwidth doesn't grow for 3 rounds, should detect full bandwidth
926959 for _ in 0 ..4 {
@@ -940,17 +973,21 @@ mod test {
940973
941974 // Set up some bandwidth
942975 for i in 0 ..5i64 {
943- bbr. max_bandwidth . on_sent ( Instant :: from_millis ( i * 10 ) , 1480 ) ;
944- bbr. max_bandwidth . on_ack ( Instant :: from_millis ( i * 10 + 5 ) , Instant :: from_millis ( i * 10 ) , 1480 , i as u64 , false ) ;
976+ bbr. max_bandwidth
977+ . on_sent ( Instant :: from_millis ( i * 10 ) , 1480 ) ;
978+ bbr. max_bandwidth . on_ack (
979+ Instant :: from_millis ( i * 10 + 5 ) ,
980+ Instant :: from_millis ( i * 10 ) ,
981+ 1480 ,
982+ i as u64 ,
983+ false ,
984+ ) ;
945985 }
946986
947987 let bw = bbr. max_bandwidth . get_estimate ( ) ;
948- let excess = bbr. ack_aggregation . update_ack_aggregation_bytes (
949- 5000 ,
950- now,
951- 5 ,
952- bw,
953- ) ;
988+ let excess = bbr
989+ . ack_aggregation
990+ . update_ack_aggregation_bytes ( 5000 , now, 5 , bw) ;
954991
955992 println ! ( "BBR: ack aggregation excess = {} bytes" , excess) ;
956993 }
@@ -969,7 +1006,10 @@ mod test {
9691006 // cwnd should not be less than min_cwnd
9701007 assert ! ( bbr. cwnd >= bbr. min_cwnd) ;
9711008
972- println ! ( "BBR: After set_mss(1500), min_cwnd = {}, cwnd = {}" , bbr. min_cwnd, bbr. cwnd) ;
1009+ println ! (
1010+ "BBR: After set_mss(1500), min_cwnd = {}, cwnd = {}" ,
1011+ bbr. min_cwnd, bbr. cwnd
1012+ ) ;
9731013 }
9741014
9751015 #[ test]
@@ -1000,16 +1040,29 @@ mod test {
10001040 let cwnd = bbr. window ( ) ;
10011041 bbr. on_send_ready ( now, cwnd + 1000 ) ;
10021042 assert ! ( !bbr. app_limited) ;
1003- println ! ( "BBR: With {} bytes available (cwnd={}), app_limited={}" , cwnd + 1000 , cwnd, bbr. app_limited) ;
1043+ println ! (
1044+ "BBR: With {} bytes available (cwnd={}), app_limited={}" ,
1045+ cwnd + 1000 ,
1046+ cwnd,
1047+ bbr. app_limited
1048+ ) ;
10041049
10051050 // With less data than cwnd, should be app-limited
10061051 bbr. on_send_ready ( now, cwnd / 2 ) ;
10071052 assert ! ( bbr. app_limited) ;
1008- println ! ( "BBR: With {} bytes available (cwnd={}), app_limited={}" , cwnd / 2 , cwnd, bbr. app_limited) ;
1053+ println ! (
1054+ "BBR: With {} bytes available (cwnd={}), app_limited={}" ,
1055+ cwnd / 2 ,
1056+ cwnd,
1057+ bbr. app_limited
1058+ ) ;
10091059
10101060 // With no data, should be app-limited
10111061 bbr. on_send_ready ( now, 0 ) ;
10121062 assert ! ( bbr. app_limited) ;
1013- println ! ( "BBR: With 0 bytes available (cwnd={}), app_limited={}" , cwnd, bbr. app_limited) ;
1063+ println ! (
1064+ "BBR: With 0 bytes available (cwnd={}), app_limited={}" ,
1065+ cwnd, bbr. app_limited
1066+ ) ;
10141067 }
10151068}
0 commit comments