]> johannes.truschnigg.info Git - sqm_lagthrottle/commitdiff
Implement TREND_DECISION tunable
authorJohannes Truschnigg <johannes@truschnigg.info>
Sat, 19 Mar 2022 16:56:33 +0000 (17:56 +0100)
committerJohannes Truschnigg <johannes@truschnigg.info>
Sat, 19 Mar 2022 16:56:33 +0000 (17:56 +0100)
__lagdetect.awk
lagdetect.sh

index ad5406cefc6d7d254be7c56bd67829c822ce2f85..8b2bd324da9f9a1743e0fd5ed2be1b3b91f25d8d 100644 (file)
@@ -29,6 +29,7 @@ BEGIN {
   print "# INIT=" systime()
   print "# THRESHOLD=" THRESHOLD
   print "# FUDGE=" FUDGE
+  print "# DECISION=" DECISION
   print "# PINGSLOTS=" PINGSLOTS
   print "# BW_MAX_RX=" BW_MAX_RX
   print "# BW_MIN_RX=" BW_MIN_RX
@@ -56,7 +57,18 @@ BEGIN {
   rx_rate_max = 100 # make something up
   tx_rate_max = 100 # make something up
   update_bw()
-  update_bw_min_delta = (0.02 * peer_count)
+  if (DECISION == "eager") {
+    update_bw_min_delta = 0.02
+    decision_pingslots_factor = 3
+    adjust_sqm_mindelta = 0.5
+  } else if (DECISION == "relaxed") {
+    update_bw_min_delta = (0.02 * peer_count)
+    decision_pingslots_factor = 5
+    adjust_sqm_mindelta = 1
+  } else {
+    print "FATAL: BOGUS DECISION SETTING: " DECISION
+    exit 1
+  }
 }
 
 
@@ -90,7 +102,7 @@ BEGIN {
 # XXX TODO impl. tunable for acting more fine-grained?
 function slice_bw_window_rx(bw_lower_bound_rx, bw_upper_bound_rx) {
   bw_bound_delta_rx = (bw_upper_bound_rx - bw_lower_bound_rx)
-  bw_steps_rx = 1+int((log(bw_bound_delta_rx)/log(10)) ^ 1.6)
+  bw_steps_rx = 1 + int((log(bw_bound_delta_rx) / log(10)) ^ 1.6)
   print "# STEPS_RX=" bw_steps_rx
   for (k = 0; k <= bw_steps_rx; k++) {
     STEPS_RX[k] = int((bw_lower_bound_rx + (k * (bw_bound_delta_rx / bw_steps_rx))))
@@ -109,7 +121,7 @@ function update_ts() {
   ts_delta = ts - ts_old
   if (ts_delta < update_bw_min_delta) {
     # Let caller know that not much time has passed since the last update,
-    # so maybe not waste time with useless calculations in the face of very
+    # so maybe not waste time with pointless calculations in the face of very
     # little actual change.
     return 0
   }
@@ -196,8 +208,8 @@ function process_record(pn, bytes, lat) {
 function adjust_sqm(peername, latency) {
   adjust_ts_delta = (ts - adjust_old)
 
-  # Do not try to adjust bw more than once a second.
-  if (adjust_ts_delta < 1.0) {
+  # Do not try to adjust bw more than the DECISION policy dictates
+  if (adjust_ts_delta < adjust_sqm_mindelta) {
     # print "# " ts " looping too fast, skipping SQM update adjust_ts_delta=" adjust_ts_delta
     return
   }
@@ -243,7 +255,7 @@ function adjust_sqm(peername, latency) {
     }
     not_increasing_count[peername] = 0
   } else if (latency < (ping_prev[peername] + FUDGE / 2) && latency < (ping_pprev[peername] + FUDGE / 2) && ping_prev[peername] < (ping_pprev[peername] + FUDGE/2)) {
-    if (not_increasing_count[peername] > (5 * PINGSLOTS)) {
+    if (not_increasing_count[peername] > (decision_pingslots_factor * PINGSLOTS)) {
       if (bw_cur_step_rx < bw_maxindex_rx) {
         bw_next_step_rx = bw_cur_step_rx + 1
         print "+++ " ts " choosing bw rx step " bw_next_step_rx " := " STEPS_RX[bw_next_step_rx] "Kbps rx=" rx_rate " tx=" tx_rate
index 331cf63836583610bd1271a64a40c593c5c9c1c9..54492b3663a82d308e2f0cb98d9a67c4a1e6980d 100755 (executable)
@@ -36,6 +36,7 @@ STATS_TX='/sys/class/net/eth1/statistics/tx_bytes' # upstream bandwidth accounti
 IFACE_TX='eth1' # interface to apply upstream SQM to (presently not used)
 BW_MIN_RX=10000 # your min. acceptable downstream bandwidth to shape to in Kbps
 BW_MAX_RX=30000 # your max. desired downstream bandwidth to shape to in Kbps
+TREND_DECISION="relaxed" # choose either "eager" or "relaxed" - the latter trades additional CPU load for quicker decision making
 
 
 
@@ -189,6 +190,18 @@ do
 done
 
 
+case "${TREND_DECISION}" in
+  eager)
+  ;;
+  relaxed)
+  ;;
+  *)
+    printf 'FATAL: Interface "%s" does not seem to have cake SQM set up\n' "${i}"
+    exit 1
+  ;;
+esac
+
+
 set -u
 
 
@@ -201,6 +214,7 @@ fping --loop --retry=1 --size=1280 --period="${PING_INTERVAL}" --random ${PING_P
   -v BW_MIN_RX="${BW_MIN_RX}" \
   -v BW_MAX_RX="${BW_MAX_RX}" \
   -v THRESHOLD="${THRESHOLD}" \
+  -v DECISION="${TREND_DECISION}" \
   -v PINGSLOTS="${PING_SLOTS_PER_PEER}" \
   -v FUDGE="${FUDGE_MS}" \
   -v PING_PEERS="${PING_PEERS}" \