- Moderate traffic peaking from your nodes on your Linux box
Rocky Linux 9.4, bash
It appears that shielding my router and ISP from peaks in upload bandwidth helps keeping latency stable and low, and helps lowering router CPU load somewhat and keeping it more stable. Code below inspired by wondershaper is just an example that works somehow but probably can be improved. Will tuning of safe node traffic shaping become a thing?
IFACE="enp1s0" # interface to apply this to
sudo tc qdisc replace dev "$IFACE" root handle 1: htb default 20
USPEED="200000" #200000kbit for 200Mbps ISP upload service
sudo tc class replace dev "$IFACE" parent 1: classid 1:1 htb rate "${USPEED}kbit" prio 5
RATE=$((20*${USPEED}/100))
if [ "$RATE" -eq 0 ]; then RATE=1 ; fi
sudo tc class add dev "$IFACE" parent 1:1 classid 1:30 htb rate "${RATE}kbit" ceil $((90*${USPEED}/100))kbit prio 3
# source ports range (or replace by list of ports) to cap bandwidth for using class "1:30"
NOPRIOPORTSRC=($(seq 30600 1 30699));
for sport in "${NOPRIOPORTSRC[@]}"; do
[ -n "$sport" ] || continue
sudo tc filter add dev "$IFACE" parent 1: protocol ip prio 15 u32 match ip sport "$sport" 0xffff flowid 1:30;
done
3 Likes