# Compute a sensible number of steps between the MIN and MAX bandwidth
# boundaries configured.
# XXX TODO impl. tunable for acting more fine-grained?
-function slice_bw_window_rx(bw_lower_bound_rx, bw_upper_bound_rx) {
+function slice_bw_window_rx(bw_lower_bound_rx, bw_upper_bound_rx, k) {
bw_bound_delta_rx = (bw_upper_bound_rx - bw_lower_bound_rx)
bw_steps_rx = 1 + int((log(bw_bound_delta_rx) / log(10)) ^ bw_slice_exponent)
print "# STEPS_RX=" bw_steps_rx
}
-function get_time() {
+function get_time( upt) {
getline upt < "/proc/uptime"
close("/proc/uptime")
split(upt, ts, " ")
# Called after parsing each latency record in the fping stream.
function process_record(pn, bytes, lat) {
- # If fing happens to pass in a latency record with a peername that was not
+ # If fping happens to pass in a latency record with a peername that was not
# announced upon startup, we exit here. Should never happen, but provides
# SOME protection against fping changing record format in a potential future
# version.
thresh_fudged = (FUDGE + (ping_avgs[peername] * THRESHOLD))
if (last2avg > thresh_fudged) {
if (latency > ping_prev[peername] && latency > ping_pprev[peername]) {
+ peers_delayed[peername]=1
+ if (len_arr(peers_delayed) > 1) { # more than one peer appears slower than usual
+ } else {
+ # print "# " ts " NOOP first/only delayed peer detected, assuming fluke"
+ return
+ }
if (prefer_high_bw == 0) {
_low_step = max(0, int((bw_step_rx_cur / 2) - 2))
bw_step_rx_next = _low_step
}
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)) {
+ delete peers_delayed[peername]
if (prefer_high_bw == 0) { # no preference for high bw caps configured
if (rx_rate < (0.9 * STEPS_RX[bw_step_rx_cur])) { # line not loaded close to current cap, so skip increasing bw
not_increasing_count[peername]++
# Simple helper function to compute the average over a peer's PINGSLOTS.
-function update_ping_avgs(peername) {
+function update_ping_avgs(peername, ping_sum, k) {
ping_sum = 0
for (k = 0; k <= PINGSLOTS; ++k) {
ps = peername ":" k
}
-function max (a, b) {
+function max( a, b) {
if (a > b) {
return a
}
}
+function len_arr(arrvar, i, ec) {
+ ec = 0
+ for(i in arrvar) ec++
+ return ec
+}
+
+
END {
print "# " ts " BYE"
# Usually not reached.