done
_goon() {
-echo "" >&2
-echo "${1:-Hit the [ENTER] key when ready, or [CTRL]+[C] to abort...}" >&2
-read -s _ >/dev/null
-echo "" >&2
+ echo "" >&2
+ echo "${1:-Hit the [ENTER] key when ready, or [CTRL]+[C] to abort...}" >&2
+ read -s _ >/dev/null
+ printf '\n\n' >&2
}
fpo="/tmp/fping_${$}.out"
echo "Welcome to the interactive sqm_lagthrottle configuration wizard." >&2
echo "" >&2
-printf 'This script will prompt you for a number of settings\n(recommending sensible defaults where thought possible)\nrequired for proper operation of sqm_lagthrottle.\n\nPlease take a few minutes to follow its instructions\nto make the most out of dynamically adjusting your bandwidth shaper.\n'
+printf 'This script will prompt you for a number of settings\n(recommending sensible defaults where thought possible)\nrequired for proper operation of sqm_lagthrottle.\n\nPlease take a few minutes to follow its instructions\nto make the most out of dynamically adjusting your\nbandwidth shaper.\n'
_goon
-echo "" >&2
-printf 'After this process, a configuration file drop-in will be created at\n\t%s\n\nYou can rename and use that file as your sqm_lagthrottle configuration\nfile as per its instructions.\n' "${cfgo}" >&2
+
+printf 'After this process, a configuration file drop-in will be created at\n\t%s\n\nYou may rename and use that file as your sqm_lagthrottle configuration\nfile as per its instructions.\n' "${cfgo}" >&2
echo "" >&2
_goon
exit 1
fi
-printf 'Now, we will ping potential ICMP ECHO peers for two minutes,\nrecord stats, and determine the top four choices.\n\nPlease keep your Internet-directed traffic at a minimum while this happens!\n' >&2
-_goon
+printf 'sqm_lagthrottle can be configured to prioritize bandwith over latency,\nor vice versa.\n\nIf you would prefer to keep configured target bandwidth high even in\nthe face of worsening latency/bufferbloat, please key in "bandwith" below.\n\nAll other inputs will lead to a preference for lower latency.\n\n\t'
+read bw_or_lat_bias
+if [ x${bw_or_lat_bias} = xbandwidth ]
+then
+ bw_or_lat_bias="bandwidth"
+else
+ bw_or_lat_bias="latency"
+fi
+printf 'Effective choice: [%s]\n\n' "${bw_or_lat_bias}"
+
+printf 'sqm_lagthrottle can be configured to be eager or more relaxed\nwhen making shaper adjustment decisions.\n\nWith eager mode, decisions to try to react meaningfully to changing\ncircumstances are taken more often.\n\nIn relaxed mode, the bandwidth limits will be adjusted less frequently,\nwhich MAY save some CPU time.\n\nKeying in "relaxed" below chooses that mode.\nAll other inputs will lead to eager operation.\n\n\t'
+read relaxed_or_eager
+if [ x${relaxed_or_eager} = xrelaxed ]
+then
+ relaxed_or_eager="relaxed"
+else
+ relaxed_or_eager="eager"
+fi
+printf 'Effective choice: [%s]\n\n' "${relaxed_or_eager}"
echo "" >&2
+echo "" >&2
+
+printf 'Now, we will ping potential ICMP ECHO peers for a few minutes,\nrecord stats, and determine the top four peer choices.\n\nPlease keep your Internet-directed traffic at a minimum while this is happening!\n' >&2
+_goon
+
printf 'Performing pings, please be patient...' >&2
#set -x
(
s=0
- while [ $s -lt 100 ]
+ while [ $s -lt 120 ]
do
sleep 10
printf '..' >&2
fping --all --addr --count="${P_COUNT}" --period=250 --retry=0 --size=1280 ${POTENTIAL_PING_PEERS} >"${fpo}" 2>&1
wait
+echo "" >&2
+echo "" >&2
set -e
printf 'BW_MIN_RX="%d"\n' "${bw_down_min}" >> "${cfgo}"
printf 'BW_MAX_RX="%d"\n' "${bw_down_max}" >> "${cfgo}"
printf 'STATS_RX="%s"\n' "${stats_rx}" >> "${cfgo}"
-printf 'IFACE_RX="%s"\n' "${iface_rx}" >> "${cfgo}"
+printf 'IFACE_RX="%s"\n' "${iface_rx##*/}" >> "${cfgo}"
+printf 'OPTIMIZATION_PREFERENCE="%s"\n' "${bw_or_lat_bias}" >> "${cfgo}"
+printf 'TREND_DECISION="%s"\n' "${relaxed_or_eager}" >> "${cfgo}"
echo "" >&2
-printf 'Determined suggested values saved in "%s"\n\n' "${cfgo}" >&2
+printf 'Suggested configuration values saved to\n\t%s\n\n' "${cfgo}" >&2
-_goon "Hit the [ENTER] to display full stats, or [CTRL]+[C] to exit." >&2
+_goon 'Hit the [ENTER] to display full stats, or [CTRL]+[C] to exit.' >&2
cat "${sto}" >&2
echo "" >&2
+printf 'In case you missed it the first time around:\nSuggested configuration values saved to\n\t%s\n\n' "${cfgo}" >&2
rm -f "${fpo}" "${sto}"