From 3c5bb78126e51a15a9a060df527e4d461bbbeec3 Mon Sep 17 00:00:00 2001 From: Johannes Truschnigg Date: Sun, 20 Mar 2022 10:31:44 +0100 Subject: [PATCH] Make low-latency mode step downwards more gracefully --- __lagdetect.awk | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/__lagdetect.awk b/__lagdetect.awk index c97a8fc..5ba3751 100644 --- a/__lagdetect.awk +++ b/__lagdetect.awk @@ -254,8 +254,9 @@ function adjust_sqm(peername, latency) { if (last2avg > thresh_fudged) { if (latency > ping_prev[peername] && latency > ping_pprev[peername]) { if (prefer_high_bw == 0) { - bw_step_rx_next = 0 - bw_step_rx_cur = 0 + _low_step = max(0, int((bw_step_rx_cur / 2) - 2)) + bw_step_rx_next = _low_step + bw_step_rx_cur = _low_step print "--- " ts " low-latency mode enforces step " bw_step_rx_next " := " STEPS_RX[bw_step_rx_next] "Kbps rx=" rx_rate " tx=" tx_rate set_bw(IFACE_RX, STEPS_RX[bw_step_rx_next]) return @@ -350,6 +351,14 @@ function set_bw(dev, kbit) { } +function max (a, b) { + if (a > b) { + return a + } + return b +} + + END { print "# " ts " BYE" # Usually not reached. -- 2.39.5