I would like all UDP traffic on my localhost to have 1% packet loss, 10 ms propagation delay, 10Mbit/s bandwidth.
On other computers I have experience using ipfw something like this:
ipfw add pipe 1 in
ipfw add pipe 2 out
ipfw pipe 1 config delay 5ms plr 0.005 bw 10Mbits/s
ipfw pipe 2 config delay 5ms plr 0.005 bw 10Mbits/s
I thought I could use macOS' built-in dummynet to achieve something similar.
I ran at the terminal
sudo dnctl pipe 1 config bw 10Mbit/s delay 10 plr 0.01
echo "dummynet out proto udp from any to any pipe 1" | sudo pfctl -f -
sudo pfctl -sa
and sudo dnctl list
show the expected outputs (the rule seems to have been added).
DUMMYNET RULES: dummynet out proto udp all pipe 1
00001: 10.000 Mbit/s 10 ms 50 sl.plr 0.010000 0 queues (1 buckets) droptail mask: 0x00 0x00000000/0x0000 -> 0x00000000/0x0000
Now I expect all udp traffic to be slowed.
But, the UDP traffic through my localhost is clearly not having any dropped packets at least, and is likely not following any of the other rules.
What's the correct method to simulate poorer network connections on macOS?
Best Answer
Your own commands are actually almost the solution. You basically just need to ensure that pf is enabled, and then repeat your rule for outgoing packets to also apply to incoming packets.
You can do this like this: