#!/bin/sh
# DF-3462 source-side flow control: send with bound source address
# 127.0.0.X to local 127.0.0.1; the flow cpu = toeplitz(dst=127.0.0.1,
# src=127.0.0.X).  First classify each X with the count rule (104),
# then run the deny-delivery differential (105).
pcnt() {
	ipfw3 -S show 104 | sed 's/^# DISABLED  *//' | awk '{print $2}'
}

echo "state: $(ipfw3 set show | head -1)"
echo "=== classify source aliases via count rule @44990"
printf "%14s %s\n" srcaddr delta
for x in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24; do
	c0=$(pcnt)
	/root/udp1shot 127.0.0.1 44990 x 0 127.0.0.$x >/dev/null 2>&1
	sleep 0.15
	c1=$(pcnt)
	printf "127.0.0.%-9d %d\n" $x $((c1 - c0))
done
