#!/usr/bin/awk -f
BEGIN {
+ CONVFMT="%.3f"
print "# INIT=" systime()
print "# THRESHOLD=" THRESHOLD
print "# FUDGE=" FUDGE
print "# IFACE_TX=" IFACE_TX
print "# STATS_RX=" STATS_RX
print "# IFACE_RX=" IFACE_RX
- split(PING_PEERS, pps, " ")
+ peer_count = split(PING_PEERS, pps, " ")
for (pp in pps) {
pn = pps[pp]
print "# PEERS+=" pn
not_increasing_count[pn]=0 # number of consecutive cycles with no (fudged) latency increase
}
update_bw()
+ update_bw_min_delta = (0.02 * peer_count)
}
function update_ts() {
ts = get_time()
- if( (ts - ts_old) < 0.1 ) {
+ 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
+ # little actual change.
return 0
}
ts_old = ts
return ts[1]
}
+
function update_bw() {
if (! (update_ts())) {
- #print "too fast, skiping bw reads " ts - ts_old
+ #print "too fast, skiping bw updates " ts - ts_old
return
}
getline rx < STATS_RX
close(STATS_RX)
- rxdelta=(rx - rx_old)
- txdelta=(tx - tx_old)
- #print "rx_delta=" rxdelta " tx_delta=" txdelta
+ rx_delta=(rx - rx_old)
+ rx_rate=(rx_delta / (ts_delta))
+ tx_delta=(tx - tx_old)
+ tx_rate=(tx_delta / (ts_delta))
+ printf("# (Kbyte/s) rx_rate=%-12.2f tx_rate=%-12.2f ts_delta=%-1.2f\n", (rx_rate / 1024), (tx_rate / 1024), ts_delta)
}