tylertreat / comcast

Simulating shitty network connections so you can build better systems.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

On MAC OSX dnctl plr applied to interface but disregards target-addr and target-proto filters

jonmadsen opened this issue · comments

I am not familiar with the internals of dnctl and how it configures the packet loss rate, but what I am finding is that if I set the packet loss rate the target-addr (src-ip, dst-ip) portion of the filter is ignored. For example if I set the plr to 100%, I cannot ping the localhost. See the following snippet:

➜ ~ ping 127.0.0.1 PING 127.0.0.1 (127.0.0.1): 56 data bytes 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.089 ms 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.096 ms 64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.108 ms 64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.115 ms ^C --- 127.0.0.1 ping statistics --- 4 packets transmitted, 4 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 0.089/0.102/0.115/0.010 ms ➜ ~ sudo ./go/bin/comcast --device=utun0 --latency=250 --target-bw=100 --packet-loss=100% --target-addr=10.169.99.196 --target-proto=tcp,udp,icmp sudo pfctl -E (cat /etc/pf.conf && echo "dummynet-anchor \"mop\"" && echo "anchor \"mop\"") | sudo pfctl -f - echo $'dummynet in all pipe 1' | sudo pfctl -a mop -f - sudo dnctl pipe 1 config delay 250ms bw 100Kbit/s plr 1.0000 mask src-ip 10.169.99.196 proto tcp sudo dnctl pipe 1 config delay 250ms bw 100Kbit/s plr 1.0000 mask src-ip 10.169.99.196 proto udp sudo dnctl pipe 1 config delay 250ms bw 100Kbit/s plr 1.0000 mask src-ip 10.169.99.196 proto icmp sudo dnctl pipe 1 config delay 250ms bw 100Kbit/s plr 1.0000 mask dst-ip 10.169.99.196 proto tcp sudo dnctl pipe 1 config delay 250ms bw 100Kbit/s plr 1.0000 mask dst-ip 10.169.99.196 proto udp sudo dnctl pipe 1 config delay 250ms bw 100Kbit/s plr 1.0000 mask dst-ip 10.169.99.196 proto icmp Packet rules setup... Run sudo pfctl -sa | grep -i enabledto double check Run./go/bin/comcast --stop` to reset
➜ ~ ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
^C
--- 127.0.0.1 ping statistics ---
6 packets transmitted, 0 packets received, 100.0% packet loss