Setup the server:
iperf -s
Run the client against the server for 7 seconds:
iperf -c localhost -t 7
You should get a throughput in (GMk)bits/sec
## Packet and Firewall filtering
### pfctl + dnctl (MacOSX Yosemite+)
sudo dnctl list
sudo pfctl -sa -v -v
(cat /etc/pf.conf && echo "dummynet-anchor \"mop\"" && echo "anchor \"mop\"") | sudo pfctl -f -
echo "dummynet in quick proto tcp from any to any port 5001 pipe 1" | sudo pfctl -a mop -f -
sudo dnctl pipe 1 config bw 1Mbit/s
Observe traffic is now shaped to 100Mbit/s:
iperf -s -D # Run as Daemon (-D)
iperf -c localhost -t 5
[ 5] local 127.0.0.1 port 59573 connected with 127.0.0.1 port 5001 [ ID] Interval Transfer Bandwidth [ 5] 0.0- 5.0 sec 60.5 MBytes 101 Mbits/sec
Delays packet transmission by 20ms:
sudo dnctl pipe 1 config delay 20
Drop 35% of packets on the pipe:
sudo dnctl pipe 1 config plr 0.35
sudo dnctl pipe 1 config plr .35
sudo dnctl pipe 1 config noerror
Don't report the error back to the sender - simulate loss at a remote router
To undo whatever mess you've created back to the default...
sudo dnctl -q flush
sudo pfctl -f /etc/pf.conf