OK @gba and others, I have merged the changes from the 'starlink-testing' branch to the main branch. Clearly more work is to be done in terms of figuring out how to best optimize for Starlink, but I like these changes so far to the overall flow anyway.
I now prepend 'dl' or 'ul' to the 'load_condition' identifiers, as follows:
1657044342.191073 25874 1296 97 5 [1657044342.173162] 8.8.8.8 53 36441 46800 10369 25990 1 dl_high_sss ul_low_sss 26695 25000
1657044342.249335 23124 1444 86 5 [1657044342.230145] 8.8.4.4 52 38338 49200 10872 25986 0 dl_high ul_low 26961 25250
1657044342.293023 23124 1444 85 5 [1657044342.269984] 1.1.1.1 56 39484 46900 7423 25976 0 dl_high ul_low 27230 25250
Thus we have the following form now for the load identifiers:
[dl|ul]_[low|med|high]_[bb|bb_sss]
And this allows differentiation in the case of Starlink satellite switch compensation based on whether the load is download or upload.
For now I have amended the get_next_shaper_rate() function such that we only drop down to the minimum shaper rate in respect of upload:
case $load_condition in
# Starlink satelite switching compensation, so drop down to minimum rate through switching period
ul*sss)
shaper_rate_kbps=$min_shaper_rate_kbps
;;
# bufferbloat detected, so decrease the rate providing not inside bufferbloat refractory period
*bb*)
if (( $t_next_rate_us > ($t_last_bufferbloat_us+$bufferbloat_refractory_period_us) )); then
adjusted_achieved_rate_kbps=$(( ($achieved_rate_kbps*$achieved_rate_adjust_down_bufferbloat)/1000 ))
adjusted_shaper_rate_kbps=$(( ($shaper_rate_kbps*$shaper_rate_adjust_down_bufferbloat)/1000 ))
shaper_rate_kbps=$(( $adjusted_achieved_rate_kbps < $adjusted_shaper_rate_kbps ? $adjusted_achieved_rate_kbps : $adjusted_shaper_rate_kbps ))
t_last_bufferbloat_us=${EPOCHREALTIME/./}
fi
;;
# high load, so increase rate providing not inside bufferbloat refractory period
*high*)
if (( $t_next_rate_us > ($t_last_bufferbloat_us+$bufferbloat_refractory_period_us) )); then
shaper_rate_kbps=$(( ($shaper_rate_kbps*$shaper_rate_adjust_up_load_high)/1000 ))
fi
;;
# medium load, so just maintain rate as is, i.e. do nothing
*med*)
:
;;
# low or idle load, so determine whether to decay down towards base rate, decay up towards base rate, or set as base rate
*low*|*idle*)
if (($t_next_rate_us > ($t_last_decay_us+$decay_refractory_period_us) )); then
if (($shaper_rate_kbps > $base_shaper_rate_kbps)); then
decayed_shaper_rate_kbps=$(( ($shaper_rate_kbps*$shaper_rate_adjust_down_load_low)/1000 ))
shaper_rate_kbps=$(( $decayed_shaper_rate_kbps > $base_shaper_rate_kbps ? $decayed_shaper_rate_kbps : $base_shaper_rate_kbps))
elif (($shaper_rate_kbps < $base_shaper_rate_kbps)); then
decayed_shaper_rate_kbps=$(( ($shaper_rate_kbps*$shaper_rate_adjust_up_load_low)/1000 ))
shaper_rate_kbps=$(( $decayed_shaper_rate_kbps < $base_shaper_rate_kbps ? $decayed_shaper_rate_kbps : $base_shaper_rate_kbps))
fi
t_last_decay_us=${EPOCHREALTIME/./}
fi
;;
esac
@gba you can tweak this behaviour as desired for testing. If you want to drop down to the minimum shaper rate for both upload and download, then just replace 'ul * sss' with '*sss'. Or alternatively we can split things out and provide separate patterns 'ul * sss' and 'dl * sss' to match against upload and download separately, and then we can, for example, drop down to the minimum shaper rate for upload and min(base shaper rate, previous shaper_rate) for download.
Latest code for testing is in the main branch here: