From 5fcbe4ea6e70006de693fd2c47084d1aa128af9c Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Tue, 22 Aug 2023 12:44:55 +0200 Subject: [PATCH 1/6] Change Glorytun TCP buffer size --- glorytun/init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glorytun/init b/glorytun/init index a21afcd9f3..d10019fcc3 100755 --- a/glorytun/init +++ b/glorytun/init @@ -82,7 +82,7 @@ start_instance() { retry count -1 const 5000000 \ timeout ${timeout} \ keepalive count 5 idle 20 interval 2 \ - buffer-size 327680 + buffer-size 65536 procd_set_param respawn 0 30 0 procd_set_param file /tmp/${PROG_NAME}-${1}.key From 765a1307fb33ebee7898db9f9998ea4ef88486ef Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Tue, 22 Aug 2023 12:45:21 +0200 Subject: [PATCH 2/6] Change MLVPN interface description --- luci-app-mlvpn/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/luci-app-mlvpn/Makefile b/luci-app-mlvpn/Makefile index 80d97c856e..77a8ceb242 100644 --- a/luci-app-mlvpn/Makefile +++ b/luci-app-mlvpn/Makefile @@ -5,8 +5,8 @@ include $(TOPDIR)/rules.mk -LUCI_TITLE:=LuCI Interface to Glorytun TCP -LUCI_DEPENDS:=+glorytun +LUCI_TITLE:=LuCI Interface to MLVPN +LUCI_DEPENDS:=+mlvpn PKG_LICENSE:=GPLv3 From 8eabafb54182cad2b73bb663c98418939785d62a Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Tue, 22 Aug 2023 12:46:35 +0200 Subject: [PATCH 3/6] Update sqm-autorate --- .../luci-static/resources/view/network/sqm.js | 2 +- .../usr/share/sqm-autorate/cake-autorate.sh | 88 +++++++++++++++---- .../usr/share/sqm-autorate/config_template.sh | 18 ++-- .../root/usr/share/sqm-autorate/defaults.sh | 79 ++++++++++------- 4 files changed, 127 insertions(+), 60 deletions(-) diff --git a/luci-app-sqm-autorate/htdocs/luci-static/resources/view/network/sqm.js b/luci-app-sqm-autorate/htdocs/luci-static/resources/view/network/sqm.js index 40abf47d91..a717683d2d 100644 --- a/luci-app-sqm-autorate/htdocs/luci-static/resources/view/network/sqm.js +++ b/luci-app-sqm-autorate/htdocs/luci-static/resources/view/network/sqm.js @@ -273,7 +273,7 @@ return view.extend({ o.depends("autorate","1"); o = s.taboption("tab_autorate", form.Value, "delay_thr_ms",_("delay threshold in ms:")); - o.default = "25"; + o.default = "25.0"; o.depends("autorate","1"); o = s.taboption("tab_autorate", form.Flag, "enable_sleep_function", _("Sleep functionnality")); diff --git a/luci-app-sqm-autorate/root/usr/share/sqm-autorate/cake-autorate.sh b/luci-app-sqm-autorate/root/usr/share/sqm-autorate/cake-autorate.sh index 68edafd1cc..c81ead0fa4 100755 --- a/luci-app-sqm-autorate/root/usr/share/sqm-autorate/cake-autorate.sh +++ b/luci-app-sqm-autorate/root/usr/share/sqm-autorate/cake-autorate.sh @@ -14,7 +14,7 @@ # Author and maintainer: lynxthecat # Contributors: rany2; moeller0; richb-hanover -cake_autorate_version="2.0.0" +cake_autorate_version="3.1.0-PRERELEASE" ## cake-autorate uses multiple asynchronous processes including: ## main - main process @@ -157,7 +157,7 @@ print_headers() { log_msg "DEBUG" "Starting: ${FUNCNAME[0]} with PID: ${BASHPID}" - header="DATA_HEADER; LOG_DATETIME; LOG_TIMESTAMP; PROC_TIME_US; DL_ACHIEVED_RATE_KBPS; UL_ACHIEVED_RATE_KBPS; DL_LOAD_PERCENT; UL_LOAD_PERCENT; RTT_TIMESTAMP; REFLECTOR; SEQUENCE; DL_OWD_BASELINE; DL_OWD_US; DL_OWD_DELTA_EWMA_US; DL_OWD_DELTA_US; DL_ADJ_DELAY_THR; UL_OWD_BASELINE; UL_OWD_US; UL_OWD_DELTA_EWMA_US; UL_OWD_DELTA_US; UL_ADJ_DELAY_THR; SUM_DL_DELAYS; SUM_UL_DELAYS; DL_LOAD_CONDITION; UL_LOAD_CONDITION; CAKE_DL_RATE_KBPS; CAKE_UL_RATE_KBPS" + header="DATA_HEADER; LOG_DATETIME; LOG_TIMESTAMP; PROC_TIME_US; DL_ACHIEVED_RATE_KBPS; UL_ACHIEVED_RATE_KBPS; DL_LOAD_PERCENT; UL_LOAD_PERCENT; ICMP_TIMESTAMP; REFLECTOR; SEQUENCE; DL_OWD_BASELINE; DL_OWD_US; DL_OWD_DELTA_EWMA_US; DL_OWD_DELTA_US; DL_ADJ_DELAY_THR; UL_OWD_BASELINE; UL_OWD_US; UL_OWD_DELTA_EWMA_US; UL_OWD_DELTA_US; UL_ADJ_DELAY_THR; DL_SUM_DELAYS; DL_AVG_OWD_DELTA_US; DL_ADJ_OWD_DELTA_THR_US; UL_SUM_DELAYS; UL_AVG_OWD_DELTA; UL_ADJ_OWD_DELTA_THR_US; DL_LOAD_CONDITION; UL_LOAD_CONDITION; CAKE_DL_RATE_KBPS; CAKE_UL_RATE_KBPS" ((log_to_file)) && printf '%s\n' "${header}" >> "${log_file_path}" ((terminal)) && printf '%s\n' "${header}" @@ -168,6 +168,10 @@ print_headers() header="REFLECTOR_HEADER; LOG_DATETIME; LOG_TIMESTAMP; PROC_TIME_US; REFLECTOR; MIN_SUM_OWD_BASELINES_US; SUM_OWD_BASELINES_US; SUM_OWD_BASELINES_DELTA_US; SUM_OWD_BASELINES_DELTA_THR_US; MIN_DL_DELTA_EWMA_US; DL_DELTA_EWMA_US; DL_DELTA_EWMA_DELTA_US; DL_DELTA_EWMA_DELTA_THR; MIN_UL_DELTA_EWMA_US; UL_DELTA_EWMA_US; UL_DELTA_EWMA_DELTA_US; UL_DELTA_EWMA_DELTA_THR" ((log_to_file)) && printf '%s\n' "${header}" >> "${log_file_path}" ((terminal)) && printf '%s\n' "${header}" + + header="SUMMARY_HEADER; LOG_DATETIME; LOG_TIMESTAMP; DL_ACHIEVED_RATE_KBPS; UL_ACHIEVED_RATE_KBPS; DL_SUM_DELAYS; UL_SUM_DELAYS; DL_AVG_OWD_DELTA_US; UL_AVG_OWD_DELTA_US; DL_LOAD_CONDITION; UL_LOAD_CONDITION; CAKE_DL_RATE_KBPS; CAKE_UL_RATE_KBPS" + ((log_to_file)) && printf '%s\n' "${header}" >> "${log_file_path}" + ((terminal)) && printf '%s\n' "${header}" } # MAINTAIN_LOG_FILE + HELPER FUNCTIONS @@ -374,9 +378,18 @@ update_shaper_rate() *bb*) if (( t_start_us > (t_last_bufferbloat_us["${direction}"]+bufferbloat_refractory_period_us) )) then - adjusted_achieved_rate_kbps=$(( (achieved_rate_kbps["${direction}"]*achieved_rate_adjust_down_bufferbloat)/1000 )) - adjusted_shaper_rate_kbps=$(( (shaper_rate_kbps["${direction}"]*shaper_rate_adjust_down_bufferbloat)/1000 )) - shaper_rate_kbps["${direction}"]=$(( adjusted_achieved_rate_kbps > min_shaper_rate_kbps["${direction}"] && adjusted_achieved_rate_kbps < adjusted_shaper_rate_kbps ? adjusted_achieved_rate_kbps : adjusted_shaper_rate_kbps )) + if (( avg_owd_delta_thr_us["${direction}"] == 0 )) + then + shaper_rate_adjust_down_bufferbloat_factor=1000 + elif (( avg_owd_delta_us["${direction}"] > 0 )) + then + shaper_rate_adjust_down_bufferbloat_factor=$(( (1000*avg_owd_delta_us["${direction}"])/compensated_avg_owd_delta_thr_us["${direction}"] )) + (( shaper_rate_adjust_down_bufferbloat_factor > 1000 )) && shaper_rate_adjust_down_bufferbloat_factor=1000 + else + shaper_rate_adjust_down_bufferbloat_factor=0 + fi + shaper_rate_adjust_down_bufferbloat=$(( 1000000-shaper_rate_adjust_down_bufferbloat_factor*(1000-shaper_rate_max_adjust_down_bufferbloat) )) + shaper_rate_kbps["${direction}"]=$(( (shaper_rate_kbps["${direction}"]*shaper_rate_adjust_down_bufferbloat)/1000000 )) t_last_bufferbloat_us["${direction}"]="${EPOCHREALTIME/./}" fi ;; @@ -1543,12 +1556,14 @@ update_max_wire_packet_compensation() # Compensate for delays imposed by active traffic shaper # This will serve to increase the delay thr at rates below around 12Mbit/s - # compensated OWD delay thresholds in microseconds - compensated_dl_delay_thr_us=$(( dl_delay_thr_us + (1000*dl_max_wire_packet_size_bits)/shaper_rate_kbps[dl] )) - compensated_ul_delay_thr_us=$(( ul_delay_thr_us + (1000*ul_max_wire_packet_size_bits)/shaper_rate_kbps[ul] )) + dl_compensation_us=$(( (1000*dl_max_wire_packet_size_bits)/shaper_rate_kbps[dl] )) + ul_compensation_us=$(( (1000*ul_max_wire_packet_size_bits)/shaper_rate_kbps[ul] )) - printf "SET_VAR compensated_dl_delay_thr_us %s\n" "${compensated_dl_delay_thr_us}" >&"${maintain_pingers_fd}" - printf "SET_VAR compensated_dl_delay_thr_us %s\n" "${compensated_dl_delay_thr_us}" >&"${maintain_pingers_fd}" + compensated_owd_delta_thr_us[dl]=$(( dl_owd_delta_thr_us + dl_compensation_us )) + compensated_owd_delta_thr_us[ul]=$(( ul_owd_delta_thr_us + ul_compensation_us )) + + compensated_avg_owd_delta_thr_us[dl]=$(( dl_avg_owd_delta_thr_us + dl_compensation_us )) + compensated_avg_owd_delta_thr_us[ul]=$(( ul_avg_owd_delta_thr_us + ul_compensation_us )) max_wire_packet_rtt_us=$(( (1000*dl_max_wire_packet_size_bits)/shaper_rate_kbps[dl] + (1000*ul_max_wire_packet_size_bits)/shaper_rate_kbps[ul] )) @@ -1926,13 +1941,14 @@ verify_ifs_up # Convert human readable parameters to values that work with integer arithmetic -printf -v dl_delay_thr_us %.0f "${dl_delay_thr_ms}e3" -printf -v ul_delay_thr_us %.0f "${ul_delay_thr_ms}e3" +printf -v dl_owd_delta_thr_us %.0f "${dl_owd_delta_thr_ms}e3" +printf -v ul_owd_delta_thr_us %.0f "${ul_owd_delta_thr_ms}e3" +printf -v dl_avg_owd_delta_thr_us %.0f "${dl_avg_owd_delta_thr_ms}e3" +printf -v ul_avg_owd_delta_thr_us %.0f "${ul_avg_owd_delta_thr_ms}e3" printf -v alpha_baseline_increase %.0f "${alpha_baseline_increase}e6" printf -v alpha_baseline_decrease %.0f "${alpha_baseline_decrease}e6" printf -v alpha_delta_ewma %.0f "${alpha_delta_ewma}e6" -printf -v achieved_rate_adjust_down_bufferbloat %.0f "${achieved_rate_adjust_down_bufferbloat}e3" -printf -v shaper_rate_adjust_down_bufferbloat %.0f "${shaper_rate_adjust_down_bufferbloat}e3" +printf -v shaper_rate_max_adjust_down_bufferbloat %.0f "${shaper_rate_max_adjust_down_bufferbloat}e3" printf -v shaper_rate_adjust_up_load_high %.0f "${shaper_rate_adjust_up_load_high}e3" printf -v shaper_rate_adjust_down_load_low %.0f "${shaper_rate_adjust_down_load_low}e3" printf -v shaper_rate_adjust_up_load_low %.0f "${shaper_rate_adjust_up_load_low}e3" @@ -1976,6 +1992,10 @@ declare -A min_shaper_rate_kbps declare -A max_shaper_rate_kbps declare -A interface declare -A adjust_shaper_rate +declare -A avg_owd_delta_us +declare -A avg_owd_delta_thr_us +declare -A compensated_owd_delta_thr_us +declare -A compensated_avg_owd_delta_thr_us base_shaper_rate_kbps[dl]="${base_dl_shaper_rate_kbps}" base_shaper_rate_kbps[ul]="${base_ul_shaper_rate_kbps}" @@ -2003,6 +2023,12 @@ ul_max_wire_packet_size_bits=0 get_max_wire_packet_size_bits "${dl_if}" dl_max_wire_packet_size_bits get_max_wire_packet_size_bits "${ul_if}" ul_max_wire_packet_size_bits +avg_owd_delta_us[dl]=0 +avg_owd_delta_us[ul]=0 + +avg_owd_delta_thr_us[dl]="${dl_avg_owd_delta_thr_us}" +avg_owd_delta_thr_us[ul]="${ul_avg_owd_delta_thr_us}" + set_shaper_rate "dl" set_shaper_rate "ul" @@ -2023,10 +2049,14 @@ reflectors_last_timestamp_us="${EPOCHREALTIME/./}" mapfile -t dl_delays < <(for ((i=1; i <= bufferbloat_detection_window; i++)); do echo 0; done) mapfile -t ul_delays < <(for ((i=1; i <= bufferbloat_detection_window; i++)); do echo 0; done) +mapfile -t dl_owd_deltas_us < <(for ((i=1; i <= bufferbloat_detection_window; i++)); do echo 0; done) +mapfile -t ul_owd_deltas_us < <(for ((i=1; i <= bufferbloat_detection_window; i++)); do echo 0; done) delays_idx=0 sum_dl_delays=0 sum_ul_delays=0 +sum_dl_owd_deltas_us=0 +sum_ul_owd_deltas_us=0 if ((debug)) then @@ -2142,18 +2172,32 @@ do continue fi - # Keep track of number of delays across detection window + # Keep track of delays across detection window + # .. for download: (( dl_delays[delays_idx] )) && ((sum_dl_delays--)) - dl_delays[delays_idx]=$(( dl_owd_delta_us > compensated_dl_delay_thr_us ? 1 : 0 )) + dl_delays[delays_idx]=$(( dl_owd_delta_us > compensated_owd_delta_thr_us[dl] ? 1 : 0 )) ((dl_delays[delays_idx])) && ((sum_dl_delays++)) + + (( sum_dl_owd_deltas_us -= dl_owd_deltas_us[delays_idx] )) + (( dl_owd_deltas_us[delays_idx] = dl_owd_delta_us )) + (( sum_dl_owd_deltas_us += dl_owd_delta_us )) + # .. for upload (( ul_delays[delays_idx] )) && ((sum_ul_delays--)) - ul_delays[delays_idx]=$(( ul_owd_delta_us > compensated_ul_delay_thr_us ? 1 : 0 )) + ul_delays[delays_idx]=$(( ul_owd_delta_us > compensated_owd_delta_thr_us[ul] ? 1 : 0 )) ((ul_delays[delays_idx])) && ((sum_ul_delays++)) + + (( sum_ul_owd_deltas_us -= ul_owd_deltas_us[delays_idx] )) + (( ul_owd_deltas_us[delays_idx] = ul_owd_delta_us )) + (( sum_ul_owd_deltas_us += ul_owd_delta_us )) + # .. and move index on (( delays_idx=(delays_idx+1)%bufferbloat_detection_window )) + (( avg_owd_delta_us[dl] = sum_dl_owd_deltas_us / bufferbloat_detection_window )) + (( avg_owd_delta_us[ul] = sum_ul_owd_deltas_us / bufferbloat_detection_window )) + bufferbloat_detected[dl]=$(( sum_dl_delays >= bufferbloat_detection_thr ? 1 : 0 )) bufferbloat_detected[ul]=$(( sum_ul_delays >= bufferbloat_detection_thr ? 1 : 0 )) @@ -2171,10 +2215,16 @@ do if (( output_processing_stats )) then - printf -v processing_stats '%s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s' "${EPOCHREALTIME}" "${achieved_rate_kbps[dl]}" "${achieved_rate_kbps[ul]}" "${load_percent[dl]}" "${load_percent[ul]}" "${timestamp}" "${reflector}" "${seq}" "${dl_owd_baseline_us}" "${dl_owd_us}" "${dl_owd_delta_ewma_us}" "${dl_owd_delta_us}" "${compensated_dl_delay_thr_us}" "${ul_owd_baseline_us}" "${ul_owd_us}" "${ul_owd_delta_ewma_us}" "${ul_owd_delta_us}" "${compensated_ul_delay_thr_us}" "${sum_dl_delays}" "${sum_ul_delays}" "${load_condition[dl]}" "${load_condition[ul]}" "${shaper_rate_kbps[dl]}" "${shaper_rate_kbps[ul]}" + printf -v processing_stats '%s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s; %s' "${EPOCHREALTIME}" "${achieved_rate_kbps[dl]}" "${achieved_rate_kbps[ul]}" "${load_percent[dl]}" "${load_percent[ul]}" "${timestamp}" "${reflector}" "${seq}" "${dl_owd_baseline_us}" "${dl_owd_us}" "${dl_owd_delta_ewma_us}" "${dl_owd_delta_us}" "${compensated_owd_delta_thr_us[dl]}" "${ul_owd_baseline_us}" "${ul_owd_us}" "${ul_owd_delta_ewma_us}" "${ul_owd_delta_us}" "${compensated_owd_delta_thr_us[ul]}" "${sum_dl_delays}" "${avg_owd_delta_us[dl]}" "${compensated_avg_owd_delta_thr_us[dl]}" "${sum_ul_delays}" "${avg_owd_delta_us[ul]}" "${compensated_avg_owd_delta_thr_us[ul]}" "${load_condition[dl]}" "${load_condition[ul]}" "${shaper_rate_kbps[dl]}" "${shaper_rate_kbps[ul]}" log_msg "DATA" "${processing_stats}" fi + if (( output_summary_stats )) + then + printf -v summary_stats '%s; %s; %s; %s; %s; %s; %s; %s; %s; %s' "${achieved_rate_kbps[dl]}" "${achieved_rate_kbps[ul]}" "${sum_dl_delays}" "${sum_ul_delays}" "${avg_owd_delta_us[dl]}" "${avg_owd_delta_us[ul]}" "${load_condition[dl]}" "${load_condition[ul]}" "${shaper_rate_kbps[dl]}" "${shaper_rate_kbps[ul]}" + log_msg "SUMMARY" "${summary_stats}" + fi + # If base rate is sustained, increment sustained base rate timer (and break out of processing loop if enough time passes) if (( enable_sleep_function )) then @@ -2204,7 +2254,7 @@ do log_msg "DEBUG" "Warning: no reflector response within: ${stall_detection_timeout_s} seconds. Checking loads." - #log_msg "DEBUG" "load check is: (( ${achieved_rate_kbps[dl]} kbps > ${connection_stall_thr_kbps} kbps for download && ${achieved_rate_kbps[ul]} kbps > ${connection_stall_thr_kbps} kbps for upload ))" + log_msg "DEBUG" "load check is: (( ${achieved_rate_kbps[dl]} kbps > ${connection_stall_thr_kbps} kbps for download && ${achieved_rate_kbps[ul]} kbps > ${connection_stall_thr_kbps} kbps for upload ))" # non-zero load so despite no reflector response within stall interval, the connection not considered to have stalled # and therefore resume normal operation diff --git a/luci-app-sqm-autorate/root/usr/share/sqm-autorate/config_template.sh b/luci-app-sqm-autorate/root/usr/share/sqm-autorate/config_template.sh index 63848c0bf8..0cce4cc1c5 100755 --- a/luci-app-sqm-autorate/root/usr/share/sqm-autorate/config_template.sh +++ b/luci-app-sqm-autorate/root/usr/share/sqm-autorate/config_template.sh @@ -15,6 +15,7 @@ INTERFACE=$(basename "$1" | cut -d. -f2) output_processing_stats=$(uci -q get sqm.${INTERFACE}.output_processing_stats || echo '0') # enable (1) or disable (0) output monitoring lines showing processing stats output_load_stats=$(uci -q get sqm.${INTERFACE}.output_load_stats || echo '0') # enable (1) or disable (0) output monitoring lines showing achieved loads output_reflector_stats=$(uci -q get sqm.${INTERFACE}.output_reflector_stats || echo '0') # enable (1) or disable (0) output monitoring lines showing reflector stats +output_summary_stats=1 # enable (1) or disable (0) output monitoring lines showing summary stats output_cake_changes=$(uci -q get sqm.${INTERFACE}.output_cake_changes || echo '0') # enable (1) or disable (0) output monitoring lines showing cake bandwidth changes debug=$(uci -q get sqm.${INTERFACE}.debug || echo '0') # enable (1) or disable (0) out of debug lines @@ -77,8 +78,14 @@ reflector_ping_interval_s=$(uci -q get sqm.${INTERFACE}.reflector_ping_interval_ # these are automatically adjusted based on maximum on the wire packet size # (adjustment significant at sub 12Mbit/s rates, else negligible) #logger -t "sqm-autorate" "ping for ${INTERFACE} (${ul_if}): $(echo $(/sbin/uci -q get sqm.${INTERFACE}.delay_thr_ms || echo '100'))" -dl_delay_thr_ms=$(echo $(uci -q get sqm.${INTERFACE}.delay_thr_ms || echo $(($(/usr/bin/ping -B -w 5 -c 5 -I ${ul_if} 1.1.1.1 | cut -d '/' -s -f6 | cut -d '.' -f1 | tr -d '\n' 2>/dev/null)+30)) || echo "100")) # (milliseconds) -ul_delay_thr_ms=${dl_delay_thr_ms} +dl_owd_delta_thr_ms=$(echo $(echo $(uci -q get sqm.${INTERFACE}.delay_thr_ms || echo $(($(/usr/bin/ping -B -w 5 -c 5 -I ${ul_if} 1.1.1.1 | cut -d '/' -s -f6 | tr -d '\n' 2>/dev/null)+30)) || echo "100")) + "0.1" | bc) # (milliseconds) +ul_owd_delta_thr_ms=${dl_owd_delta_thr_ms} + +# average owd delta threshold in ms at which maximum adjust_down_bufferbloat is applied +# set value(s) to 0 to disable and always apply maximum adjust_down_bufferbloat +dl_avg_owd_delta_thr_ms=$(echo "$dl_owd_delta_thr_ms * 2" | bc) # (milliseconds) +ul_avg_owd_delta_thr_ms=$(echo "$ul_owd_delta_thr_ms * 2" | bc) # (milliseconds) + # Set either of the below to 0 to adjust one direction only # or alternatively set both to 0 to simply use cake-autorate to monitor a connection adjust_dl_shaper_rate=1 # enable (1) or disable (0) actually changing the dl shaper rate @@ -159,8 +166,7 @@ alpha_delta_ewma=0.095 # bufferbloat adjustment works with the lower of the adjusted achieved rate and adjusted shaper rate # to exploit that transfer rates during bufferbloat provide an indication of line capacity # otherwise shaper rate is adjusted up on load high, and down on load idle or low -achieved_rate_adjust_down_bufferbloat=0.9 # how rapidly to reduce achieved rate upon detection of bufferbloat -shaper_rate_adjust_down_bufferbloat=0.9 # how rapidly to reduce shaper rate upon detection of bufferbloat +#shaper_rate_adjust_down_bufferbloat=0.75 # how rapidly to reduce shaper rate upon detection of bufferbloat shaper_rate_adjust_up_load_high=1.01 # how rapidly to increase shaper rate upon high load detected shaper_rate_adjust_down_load_low=0.99 # how rapidly to return down to base shaper rate upon idle or low load detected shaper_rate_adjust_up_load_low=1.01 # how rapidly to return up to base shaper rate upon idle or low load detected @@ -191,7 +197,7 @@ reflector_replacement_interval_mins=60 # how often to replace a random reflector reflector_comparison_interval_mins=1 # how often to compare reflectors #reflector_sum_owd_baseline_delta_thr_ms=30 # max increase from min sum owd baselines before reflector rotated -reflector_owd_delta_ewma_delta_thr_ms=10 # mac increase from min delta ewma before reflector rotated +reflector_owd_delta_ewma_delta_thr_ms=10.0 # mac increase from min delta ewma before reflector rotated # stall is detected when the following two conditions are met: # 1) no reflector responses within $stall_detection_thr*$ping_response_interval_us; and @@ -199,7 +205,7 @@ reflector_owd_delta_ewma_delta_thr_ms=10 # mac increase from min delta ewma be stall_detection_thr=5 connection_stall_thr_kbps=10 -global_ping_response_timeout_s=${dl_delay_thr_ms} # timeout to set shaper rates to min on no ping response whatsoever (seconds) +global_ping_response_timeout_s=${dl_owd_delta_thr_ms} # timeout to set shaper rates to min on no ping response whatsoever (seconds) if_up_check_interval_s=10.0 # time to wait before re-checking if rx/tx bytes files exist (e.g. from boot state or sleep recovery) diff --git a/luci-app-sqm-autorate/root/usr/share/sqm-autorate/defaults.sh b/luci-app-sqm-autorate/root/usr/share/sqm-autorate/defaults.sh index 7c953290f0..e67141531c 100755 --- a/luci-app-sqm-autorate/root/usr/share/sqm-autorate/defaults.sh +++ b/luci-app-sqm-autorate/root/usr/share/sqm-autorate/defaults.sh @@ -1,11 +1,17 @@ #!/bin/bash -# cake-autorate automatically adjusts bandwidth for CAKE in dependence on detected load and RTT - -# cake-autorate_config.sh is a script that sets up defaults for cake-autorate - -# Author: @Lynx (OpenWrt forum) -# Inspiration taken from: @moeller0 (OpenWrt forum) +# defaults.sh -- default configuration values for cake-autorate.sh +# +# This file is part of cake-autorate. +# +# CAKE-AUTORATE IS HIGHLY CONFIGURABLE AND THIS FILE MAY BE +# CONSULTED IN RESPECT OF OVERRIDING VARIABLES IN A CONFIG FILE. +# +# DO NOT MODIFY THIS FILE. ANY CHANGES NEED TO BE MADE TO +# THE CONFIG FILE FOR A GIVEN INSTANCE OF CAKE-AUTORATE. +# MODIFYING THIS FILE WILL RESULT IN THE LOSS OF ANY CHANGES +# DURING AN UPDATE OR UNEXPECTED BEHAVIOR AFTER AN UPDATE +# IF THE OLD DEFAULT FILE WAS IN USE. INTERFACE="" @@ -14,15 +20,16 @@ INTERFACE="" output_processing_stats=1 # enable (1) or disable (0) output monitoring lines showing processing stats output_load_stats=1 # enable (1) or disable (0) output monitoring lines showing achieved loads output_reflector_stats=1 # enable (1) or disable (0) output monitoring lines showing reflector stats +output_summary_stats=1 # enable (1) or disable (0) output monitoring lines showing summary stats output_cake_changes=0 # enable (1) or disable (0) output monitoring lines showing cake bandwidth changes debug=1 # enable (1) or disable (0) out of debug lines # This can generate a LOT of records so be careful: -log_DEBUG_messages_to_syslog=0 # enable (1) or disable (0) logging of all DEBUG records into the system log. +log_DEBUG_messages_to_syslog=0 # enable (1) or disable (0) logging of all DEBUG records into the system log. # ** Take care with these settings to ensure you won't run into OOM issues on your router *** # every write the cumulative write time and bytes associated with each log line are checked -# and if either exceeds the configured values below, the log log file is rotated +# and if either exceeds the configured values below, the log file is rotated log_to_file=1 # enable (1) or disable (0) output logging to file (/tmp/cake-autorate.log) log_file_max_time_mins=10 # maximum time between log file rotations log_file_max_size_KB=2000 # maximum KB (i.e. bytes/1024) worth of log lines between log file rotations @@ -33,21 +40,21 @@ log_file_path_override="" # *** STANDARD CONFIGURATION OPTIONS *** -### For multihomed setups, it is the responsibility of the user to ensure that the probes +### For multihomed setups, it is the responsibility of the user to ensure that the probes ### sent by this instance of cake-autorate actually travel through these interfaces. ### See ping_extra_args and ping_prefix_string dl_if=ifb-wan # download interface ul_if=wan # upload interface -# pinger selection can be any of: +# pinger binary selection can be any of: # fping - round robin pinging (rtts) +# tsping - round robin pinging using ICMP type 13 (owds) # ping - (iputils-ping) individual pinging (rtts) -# hping3 - individidual pinging (owds) pinger_binary=fping # list of reflectors to use and number of pingers to initiate -# pingers will be initiated with reflectors in the order specified in the list +# pingers will be initiated with reflectors in the order specified in the list # additional reflectors will be used to replace any reflectors that go stale # so e.g. if 6 reflectors are specified and the number of pingers is set to 4, the first 4 reflectors will be used initially # and the remaining 2 reflectors in the list will be used in the event any of the first 4 go bad @@ -71,13 +78,18 @@ randomize_reflectors=1 # enable (1) or disable (0) randomization of reflectors o no_pingers=6 # number of pingers to maintain reflector_ping_interval_s=0.3 # (seconds, e.g. 0.2s or 2s) -# delay threshold in ms is the extent of OWD increase to classify as a delay +# owd delta threshold in ms is the extent of OWD increase to classify as a delay # these are automatically adjusted based on maximum on the wire packet size -# (adjustment significant at sub 12Mbit/s rates, else negligible) -dl_delay_thr_ms=30 # (milliseconds) -ul_delay_thr_ms=30 # (milliseconds) +# (adjustment significant at sub 12Mbit/s rates, else negligible) +dl_owd_delta_thr_ms=30.0 # (milliseconds) +ul_owd_delta_thr_ms=30.0 # (milliseconds) + +# average owd delta threshold in ms at which maximum adjust_down_bufferbloat is applied +# set value(s) to 0 to disable and always apply maximum adjust_down_bufferbloat +dl_avg_owd_delta_thr_ms=60.0 # (milliseconds) +ul_avg_owd_delta_thr_ms=60.0 # (milliseconds) -# Set either of the below to 0 to adjust one direction only +# Set either of the below to 0 to adjust one direction only # or alternatively set both to 0 to simply use cake-autorate to monitor a connection adjust_dl_shaper_rate=1 # enable (1) or disable (0) actually changing the dl shaper rate adjust_ul_shaper_rate=1 # enable (1) or disable (0) actually changing the ul shaper rate @@ -92,7 +104,7 @@ max_ul_shaper_rate_kbps=35000 # maximum bandwidth for upload (Kbit/s) # sleep functionality saves unecessary pings and CPU cycles by # pausing all active pingers when connection is not in active use -enable_sleep_function=1 # enable (1) or disable (0) sleep functonality +enable_sleep_function=1 # enable (1) or disable (0) sleep functonality connection_active_thr_kbps=1000 # threshold in Kbit/s below which dl/ul is considered idle sustained_idle_sleep_thr_s=60.0 # time threshold to put pingers to sleep on sustained dl/ul achieved rate < idle_thr (seconds) @@ -135,8 +147,8 @@ ping_prefix_string="" # interval in ms for monitoring achieved rx/tx rates # this is automatically adjusted based on maximum on the wire packet size -# (adjustment significant at sub 12Mbit/s rates, else negligible) -monitor_achieved_rates_interval_ms=200 # (milliseconds) +# (adjustment significant at sub 12Mbit/s rates, else negligible) +monitor_achieved_rates_interval_ms=200 # (milliseconds) # bufferbloat is detected when (bufferbloat_detection_thr) samples # out of the last (bufferbloat detection window) samples are delayed @@ -153,21 +165,20 @@ alpha_baseline_decrease=0.9 # how rapidly baseline RTT is allowed to decrease # OWD delta from baseline is tracked using ewma with alpha set below alpha_delta_ewma=0.095 -# rate adjustment parameters -# bufferbloat adjustment works with the lower of the adjusted achieved rate and adjusted shaper rate -# to exploit that transfer rates during bufferbloat provide an indication of line capacity +# rate adjustment parameters +# shaper rate is adjusted by a maximum of shaper_rate_max_adjust_down_bufferbloat on detection of bufferbloat +# and this is scaled by the average delta owd / average owd delta threshold # otherwise shaper rate is adjusted up on load high, and down on load idle or low -achieved_rate_adjust_down_bufferbloat=0.9 # how rapidly to reduce achieved rate upon detection of bufferbloat -shaper_rate_adjust_down_bufferbloat=0.9 # how rapidly to reduce shaper rate upon detection of bufferbloat -shaper_rate_adjust_up_load_high=1.01 # how rapidly to increase shaper rate upon high load detected -shaper_rate_adjust_down_load_low=0.99 # how rapidly to return down to base shaper rate upon idle or low load detected -shaper_rate_adjust_up_load_low=1.01 # how rapidly to return up to base shaper rate upon idle or low load detected +shaper_rate_max_adjust_down_bufferbloat=0.75 # how rapidly to reduce shaper rate upon detection of bufferbloat +shaper_rate_adjust_up_load_high=1.01 # how rapidly to increase shaper rate upon high load detected +shaper_rate_adjust_down_load_low=0.99 # how rapidly to return down to base shaper rate upon idle or low load detected +shaper_rate_adjust_up_load_low=1.01 # how rapidly to return up to base shaper rate upon idle or low load detected # the load is categoried as low if < high_load_thr and high if > high_load_thr relative to the current shaper rate high_load_thr=0.75 # % of currently set bandwidth for detecting high load # refractory periods between successive bufferbloat/decay rate changes -# the bufferbloat refractory period should be greater than the +# the bufferbloat refractory period should be greater than the # average time it would take to replace the bufferbloat # detection window with new samples upon a bufferbloat event bufferbloat_refractory_period_ms=300 # (milliseconds) @@ -181,15 +192,15 @@ reflector_response_deadline_s=1.0 # (seconds) # reflector misbehaving is detected when $reflector_misbehaving_detection_thr samples # out of the last (reflector misbehaving detection window) samples are offences # thus with a 1s interval, window 60 and detection_thr 3, this is tantamount to -# 3 offences within the last 60s +# 3 offences within the last 60s reflector_misbehaving_detection_window=60 reflector_misbehaving_detection_thr=3 reflector_replacement_interval_mins=60 # how often to replace a random reflector from the present list -reflector_comparison_interval_mins=1 # how often to compare reflectors -reflector_sum_owd_baselines_delta_thr_ms=20 # max increase from min sum owd baselines before reflector rotated -reflector_owd_delta_ewma_delta_thr_ms=10 # max increase from min delta ewma before reflector rotated +reflector_comparison_interval_mins=1 # how often to compare reflectors +reflector_sum_owd_baselines_delta_thr_ms=20.0 # max increase from min sum owd baselines before reflector rotated +reflector_owd_delta_ewma_delta_thr_ms=10.0 # max increase from min delta ewma before reflector rotated # stall is detected when the following two conditions are met: # 1) no reflector responses within $stall_detection_thr*$ping_response_interval_us; and @@ -197,7 +208,7 @@ reflector_owd_delta_ewma_delta_thr_ms=10 # max increase from min delta ewma befo stall_detection_thr=5 connection_stall_thr_kbps=10 -global_ping_response_timeout_s=10 # timeout to set shaper rates to min on no ping response whatsoever (seconds) +global_ping_response_timeout_s=10.0 # timeout to set shaper rates to min on no ping response whatsoever (seconds) if_up_check_interval_s=10.0 # time to wait before re-checking if rx/tx bytes files exist (e.g. from boot state or sleep recovery) From e2cfa2b79015e9e9add49f91ff2f1a681143ca96 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Tue, 22 Aug 2023 13:48:52 +0200 Subject: [PATCH 4/6] Fix for ubond and SQM --- .../luasrc/controller/openmptcprouter.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua b/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua index 1f979d871c..12775aa6cd 100644 --- a/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua +++ b/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua @@ -541,7 +541,7 @@ function wizard_add() vpn_intf = "mlvpn0" ucic:set("network","omrvpn","proto","dhcp") elseif default_vpn == "ubond" then - vpn_port = 65201 + vpn_port = 65251 vpn_intf = "ubond0" ucic:set("network","omrvpn","proto","dhcp") elseif default_vpn == "dsvpn" then @@ -1003,7 +1003,7 @@ function wizard_add() local ubond_password = luci.http.formvalue("ubond_password") if ubond_password ~= "" then ucic:set("ubond","general","password",ubond_password) - ucic:set("ubond","general","firstport","65201") + ucic:set("ubond","general","firstport","65251") ucic:set("ubond","general","interface_name","ubond0") else --ucic:set("ubond","general","enable",0) @@ -1054,7 +1054,7 @@ function wizard_add() luci.sys.call("/etc/init.d/glorytun restart >/dev/null 2>/dev/null") luci.sys.call("/etc/init.d/glorytun-udp restart >/dev/null 2>/dev/null") luci.sys.call("/etc/init.d/mlvpn restart >/dev/null 2>/dev/null") - --luci.sys.call("/etc/init.d/ubond restart >/dev/null 2>/dev/null") + luci.sys.call("/etc/init.d/ubond restart >/dev/null 2>/dev/null") luci.sys.call("/etc/init.d/mptcpovervpn restart >/dev/null 2>/dev/null") luci.sys.call("/etc/init.d/openvpn restart >/dev/null 2>/dev/null") luci.sys.call("/etc/init.d/openvpnbonding restart >/dev/null 2>/dev/null") @@ -1063,6 +1063,7 @@ function wizard_add() luci.sys.call("/etc/init.d/omr-6in4 restart >/dev/null 2>/dev/null") luci.sys.call("/etc/init.d/vnstat restart >/dev/null 2>/dev/null") luci.sys.call("/etc/init.d/v2ray restart >/dev/null 2>/dev/null") + luci.sys.call("/etc/init.d/sqm restart >/dev/null 2>/dev/null") luci.sys.call("/etc/init.d/sqm-autorate restart >/dev/null 2>/dev/null") luci.sys.call("/etc/init.d/sysntpd restart >/dev/null 2>/dev/null") luci.http.redirect(luci.dispatcher.build_url("admin/system/" .. menuentry:lower() .. "/status")) From 41bda6b275e6b027436b2c0a0d1461fe931d2ec5 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Tue, 22 Aug 2023 13:49:27 +0200 Subject: [PATCH 5/6] Enable MPTCP via sysctl --- mptcp/files/etc/init.d/mptcp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mptcp/files/etc/init.d/mptcp b/mptcp/files/etc/init.d/mptcp index 192932a9ad..29790f1dd1 100755 --- a/mptcp/files/etc/init.d/mptcp +++ b/mptcp/files/etc/init.d/mptcp @@ -37,6 +37,11 @@ global_multipath_settings() { # Global MPTCP configuration if [ -f /proc/sys/net/mptcp/mptcp_enabled ]; then sysctl -qew net.mptcp.mptcp_enabled="$multipath_status" + if [ -z "$(grep net.mptcp.mptcp_enabled /etc/sysctl.d/zzz_openmptcprouter.conf)" ]; then + echo "net.mptcp.mptcp_enabled=${multipath_status}" >> /etc/sysctl.d/zzz_openmptcprouter.conf + else + sed -i "s:^net.mptcp.mptcp_enabled=[0-1]*:net.mptcp.mptcp_enabled=${multipath_status}:" /etc/sysctl.d/zzz_openmptcprouter.conf + fi [ -z "$mptcp_path_manager" ] || sysctl -qew net.mptcp.mptcp_path_manager="$mptcp_path_manager" [ -z "$mptcp_scheduler" ] || sysctl -qew net.mptcp.mptcp_scheduler="$mptcp_scheduler" [ -z "$mptcp_checksum" ] || sysctl -qew net.mptcp.mptcp_checksum="$mptcp_checksum" @@ -50,6 +55,11 @@ global_multipath_settings() { [ -z "$mptcp_version" ] || sysctl -qew net.mptcp.mptcp_version="$mptcp_version" elif [ -f /proc/sys/net/mptcp/enabled ]; then sysctl -qew net.mptcp.enabled="$multipath_status" + if [ -z "$(grep net.mptcp.enabled /etc/sysctl.d/zzz_openmptcprouter.conf)" ]; then + echo "net.mptcp.enabled=${multipath_status}" >> /etc/sysctl.d/zzz_openmptcprouter.conf + else + sed -i "s:^net.mptcp.enabled=[0-1]*:net.mptcp.enabled=${multipath_status}:" /etc/sysctl.d/zzz_openmptcprouter.conf + fi ip mptcp limits set add_addr_accepted $mptcp_add_addr_accepted subflows $mptcp_subflows 2>&1 >/dev/null #[ -z "$mptcp_debug" ] || sysctl -qew net.mptcp.mptcp_debug="$mptcp_debug" [ -z "$mptcp_checksum" ] || sysctl -qew net.mptcp.mptcp_checksum="$mptcp_checksum" From 229f7231e809f31f9ee57ad9fa82ab90d9b4520b Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Tue, 22 Aug 2023 14:26:46 +0200 Subject: [PATCH 6/6] Disable speedtest by default in wizard --- luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm index e30f5dfc0a..28cc694aef 100644 --- a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm +++ b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm @@ -995,7 +995,7 @@

<%=ifname%>

- checked<% end %> /> + checked<% end %> />
<%:Run an automatic speedtest to calculate max download & upload speed.%>