For purpose of continuous testing, I would like have apache server to serve static files with at least 20ms delay.
I tried to find a apache configuration setting or a plugin with similar ability, but failed.
Combination of tc and iptables might work, but I only found a way to add delay based on outgoing port, (which is different for every client).
Variables IF=lo IFSPEED=100Mbps # Get from sudo /sbin/ethtool $IF DELAY=1000ms # # Create a tree of classful HTB objects # sudo /sbin/tc qdisc add dev $IF handle 1: root htb # # Create a classful child bucket with classid 1:11 # sudo /sbin/tc class add dev $IF parent 1: classid 1:11 htb rate $IFSPEED # # Create a qdisc (classless) netem child to provide a delay for packets in this 'bucket' # sudo /sbin/tc qdisc add dev $IF parent 1:11 handle 11: netem delay $DELAY # # Filter mangled/marked traffic to the above class # sudo /sbin/tc filter add dev $IF parent 1:0 prio 1 protocol ip handle 11 fw flowid 1:11 # # Use iptables to mangle TCP packets to port 4001 and mark packet for tc filtering # sudo /sbin/iptables -A OUTPUT -t mangle -p tcp --dport 4001 -j MARK --set-mark 11
So the previous snippet work, but how to change policy so every incoming packet with destinatiom port 80 is delayed? -- attempted to try iptables with PREROUTING , but still didn't work?
iptables -t mangle -A OUTPUT -p tcp -m tcp --sport 80 -j MARK --set-mark 11
be enough? At least for me it delays the outgoing packets for 1000ms.