1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| NIC=docker0 PORT=20111 DELAY=100ms LOSS=50%
sudo iptables -t mangle -A OUTPUT -p tcp --dport ${PORT} -j MARK --set-mark 1
sudo tc qdisc add dev ${NIC} root handle 1: prio
sudo tc qdisc add dev ${NIC} parent 1:3 handle 30: netem delay ${DELAY} loss ${LOSS}
sudo tc filter add dev ${NIC} protocol ip parent 1:0 prio 3 handle 1 fw flowid 1:3
sudo iptables -t mangle -D OUTPUT -p tcp --dport ${PORT} -j MARK --set-mark 1
sudo tc qdisc del dev ${NIC} root
|