2020#include "src/transport/xqc_send_ctl.h"
2121#include "src/transport/xqc_packet.h"
2222
23- #define XQC_BBR_MAX_DATAGRAMSIZE XQC_QUIC_MSS
23+ #define XQC_BBR_MAX_DATAGRAMSIZE XQC_MSS
2424#define XQC_BBR_MIN_WINDOW (4 * XQC_BBR_MAX_DATAGRAMSIZE)
2525#define XQC_BBR_MAX_WINDOW (100 * XQC_BBR_MAX_DATAGRAMSIZE)
2626/* The RECOMMENDED value is the minimum of 10 * kMaxDatagramSize and max(2* kMaxDatagramSize, 14720)) */
@@ -147,10 +147,12 @@ xqc_bbr_init(void *cong_ctl, xqc_sample_t *sampler, xqc_cc_params_t cc_params)
147147 bbr -> rttvar_compensation_on = 1 ;
148148 }
149149#endif
150+ #ifndef XQC_BBR_DISABLE_CWND_AI
150151 bbr -> beyond_target_cwnd = 0 ;
151152 bbr -> snd_cwnd_cnt_bytes = 0 ;
152153 bbr -> ai_scale = 1 ;
153154 bbr -> ai_scale_accumulated_bytes = 0 ;
155+ #endif
154156 bbr -> min_rtt = sampler -> srtt ? sampler -> srtt : XQC_BBR_INF ;
155157 bbr -> min_rtt_stamp = now ;
156158 bbr -> probe_rtt_min_us = sampler -> srtt ? sampler -> srtt : XQC_BBR_INF ;
@@ -266,7 +268,7 @@ static uint32_t
266268xqc_bbr_compensate_cwnd_for_rttvar (xqc_bbr_t * bbr , xqc_sample_t * sampler )
267269{
268270 xqc_usec_t srtt = sampler -> srtt ;
269- xqc_usec_t recent_max_rtt = xqc_win_filter_get_u64 (& bbr -> max_rtt );
271+ xqc_usec_t recent_max_rtt = xqc_win_filter_get (& bbr -> max_rtt );
270272 xqc_usec_t compensation_thresh = (1 + bbr -> rtt_compensation_thresh ) *
271273 bbr -> min_rtt ;
272274 uint32_t cwnd_addition = 0 ;
@@ -546,6 +548,8 @@ xqc_bbr_update_min_rtt(xqc_bbr_t *bbr, xqc_sample_t *sampler)
546548 xqc_log (sampler -> send_ctl -> ctl_conn -> log , XQC_LOG_DEBUG , "|minrtt expire|rtt:%ui, old_rtt:%ui|" ,
547549 bbr -> probe_rtt_min_us ,
548550 bbr -> min_rtt );
551+
552+ #ifndef XQC_BBR_DISABLE_CWND_AI
549553 if (bbr -> probe_rtt_min_us_stamp != bbr -> min_rtt_stamp
550554 || min_rtt_expired )
551555 {
@@ -562,6 +566,8 @@ xqc_bbr_update_min_rtt(xqc_bbr_t *bbr, xqc_sample_t *sampler)
562566 bbr -> ai_scale_accumulated_bytes = 0 ;
563567 }
564568 }
569+ #endif
570+
565571 bbr -> min_rtt = bbr -> probe_rtt_min_us ;
566572 bbr -> min_rtt_stamp = bbr -> probe_rtt_min_us_stamp ;
567573 }
@@ -712,14 +718,16 @@ xqc_bbr_reset_cwnd(void *cong_ctl)
712718 }
713719 /* reset recovery start time in any case */
714720 bbr -> recovery_start_time = 0 ;
721+ #ifndef XQC_BBR_DISABLE_CWND_AI
715722 /* If losses happened, we do not increase cwnd beyond target_cwnd. */
716723 bbr -> snd_cwnd_cnt_bytes = 0 ;
717724 bbr -> beyond_target_cwnd = 0 ;
718725 bbr -> ai_scale = 1 ;
719726 bbr -> ai_scale_accumulated_bytes = 0 ;
727+ #endif
720728}
721729
722-
730+ #ifndef XQC_BBR_DISABLE_CWND_AI
723731static void
724732xqc_bbr_cong_avoid_ai (xqc_bbr_t * bbr , uint32_t cwnd , uint32_t acked )
725733{
@@ -744,6 +752,7 @@ xqc_bbr_cong_avoid_ai(xqc_bbr_t *bbr, uint32_t cwnd, uint32_t acked)
744752 bbr -> ai_scale_accumulated_bytes -= delta * cwnd_thresh ;
745753 }
746754}
755+ #endif
747756
748757static void
749758xqc_bbr_set_cwnd (xqc_bbr_t * bbr , xqc_sample_t * sampler )
@@ -772,6 +781,7 @@ xqc_bbr_set_cwnd(xqc_bbr_t *bbr, xqc_sample_t *sampler)
772781 xqc_bbr_modulate_cwnd_for_recovery (bbr , sampler );
773782 if (!bbr -> packet_conservation ) {
774783 if (bbr -> full_bandwidth_reached ) {
784+ #ifndef XQC_BBR_DISABLE_CWND_AI
775785 if ((bbr -> congestion_window + sampler -> acked
776786 >= (target_cwnd + bbr -> beyond_target_cwnd ))
777787 && sampler -> send_ctl -> ctl_is_cwnd_limited )
@@ -789,6 +799,7 @@ xqc_bbr_set_cwnd(xqc_bbr_t *bbr, xqc_sample_t *sampler)
789799 sampler -> acked ,
790800 bbr -> snd_cwnd_cnt_bytes ,
791801 bbr -> beyond_target_cwnd );
802+ #endif
792803 bbr -> congestion_window = xqc_min (target_cwnd ,
793804 bbr -> congestion_window +
794805 sampler -> acked );
@@ -820,11 +831,13 @@ xqc_bbr_on_lost(void *cong_ctl, xqc_usec_t lost_sent_time)
820831 */
821832 xqc_bbr_save_cwnd (bbr );
822833 bbr -> recovery_start_time = xqc_monotonic_timestamp ();
834+ #ifndef XQC_BBR_DISABLE_CWND_AI
823835 /* If losses happened, we do not increase cwnd beyond target_cwnd. */
824836 bbr -> snd_cwnd_cnt_bytes = 0 ;
825837 bbr -> beyond_target_cwnd = 0 ;
826838 bbr -> ai_scale = 1 ;
827839 bbr -> ai_scale_accumulated_bytes = 0 ;
840+ #endif
828841}
829842
830843static void
@@ -870,14 +883,14 @@ xqc_bbr_on_ack(void *cong_ctl, xqc_sample_t *sampler)
870883 /* maintain windowed max rtt here */
871884 if (bbr -> rttvar_compensation_on ) {
872885 if (sampler -> rtt >= 0 ) {
873- xqc_usec_t last_max_rtt = xqc_win_filter_get_u64 (& bbr -> max_rtt );
874- xqc_win_filter_max_u64 (& bbr -> max_rtt , bbr -> max_rtt_win_len ,
886+ xqc_usec_t last_max_rtt = xqc_win_filter_get (& bbr -> max_rtt );
887+ xqc_win_filter_max (& bbr -> max_rtt , bbr -> max_rtt_win_len ,
875888 bbr -> round_cnt , sampler -> rtt );
876889 xqc_log (sampler -> send_ctl -> ctl_conn -> log , XQC_LOG_DEBUG ,
877890 "|rttvar_compensation|windowed max rtt info|"
878891 "rtt %ui, last_max %ui, max %ui|" ,
879892 sampler -> rtt , last_max_rtt ,
880- xqc_win_filter_get_u64 (& bbr -> max_rtt ));
893+ xqc_win_filter_get (& bbr -> max_rtt ));
881894 }
882895 }
883896#endif
@@ -1034,7 +1047,7 @@ static xqc_bbr_info_interface_t xqc_bbr_info_cb = {
10341047const xqc_cong_ctrl_callback_t xqc_bbr_cb = {
10351048 .xqc_cong_ctl_size = xqc_bbr_size ,
10361049 .xqc_cong_ctl_init_bbr = xqc_bbr_init ,
1037- .xqc_cong_ctl_bbr = xqc_bbr_on_ack ,
1050+ .xqc_cong_ctl_on_ack_multiple_pkts = xqc_bbr_on_ack ,
10381051 .xqc_cong_ctl_get_cwnd = xqc_bbr_get_cwnd ,
10391052 .xqc_cong_ctl_get_pacing_rate = xqc_bbr_get_pacing_rate ,
10401053 .xqc_cong_ctl_get_bandwidth_estimate = xqc_bbr_get_bandwidth ,
0 commit comments