tylertreat / comcast

Simulating shitty network connections so you can build better systems.
Apache License 2.0
10.31k stars 384 forks source link

Failed to stop packet controls #37

Closed jberryman closed 8 years ago

jberryman commented 9 years ago
:~$ comcast --version
Comcast version 1.0.0

5 is the same, but was apparently fixed. Let me know what information would be helpful.

~$ comcast --device=lo --latency=250 --target-bw=40 --default-bw=1000000 --packet-loss=50% --target-addr=127.0.0.0/24 --target-proto=tcp,udp,icmp --target-port=4369,5672
sudo tc qdisc show | grep "netem"
sudo tc qdisc add dev lo handle 10: root htb
sudo tc class add dev lo parent 10: classid 10:1 htb rate 1000000kbit
sudo tc class add dev lo parent 10:1 classid 10:10 htb rate 1000000kbit
sudo tc qdisc add dev lo parent 10:10 handle 100: netem delay 250ms rate 40kbit loss 50.00%
sudo iptables -A POSTROUTING -t mangle -j CLASSIFY --set-class 10:10 -p tcp --match multiport --dports 4369,5672 -d 127.0.0.0/24
sudo iptables -A POSTROUTING -t mangle -j CLASSIFY --set-class 10:10 -p udp --match multiport --dports 4369,5672 -d 127.0.0.0/24
sudo iptables -A POSTROUTING -t mangle -j CLASSIFY --set-class 10:10 -p icmp -d 127.0.0.0/24
Packet rules setup...
Run `sudo tc -s qdisc` to double check
Run `comcast --stop` to reset

~$ comcast --stop
sudo tc qdisc show | grep "netem"
sudo iptables -t mangle -D POSTROUTING -d 127.0.0.0/24 -p tcp -m multiport --dports 4369,5672 -j CLASSIFY --set-class 0010:0010
sudo iptables -t mangle -D POSTROUTING -d 127.0.0.0/24 -p udp -m multiport --dports 4369,5672 -j CLASSIFY --set-class 0010:0010
sudo iptables -t mangle -D POSTROUTING -d 127.0.0.0/24 -p icmp -j CLASSIFY --set-class 0010:0010
sudo tc qdisc del dev eth0 handle 10: root
Failed to stop packet controls

~$ sudo tc -s qdisc
qdisc htb 10: dev lo root refcnt 2 r2q 10 default 0 direct_packets_stat 4732 direct_qlen 2
 Sent 874589 bytes 4823 pkt (dropped 76, overlimits 485 requeues 0) 
 backlog 0b 0p requeues 0 
qdisc netem 100: dev lo parent 10:10 limit 1000 delay 250.0ms loss 50% rate 40000bit
 Sent 8804 bytes 91 pkt (dropped 76, overlimits 0 requeues 0) 
 backlog 0b 0p requeues 0 
qdisc pfifo_fast 0: dev eth0 root refcnt 2 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
 Sent 2497436 bytes 28521 pkt (dropped 0, overlimits 0 requeues 0) 
 backlog 0b 0p requeues 0 
qdisc pfifo_fast 0: dev eth1 root refcnt 2 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
 Sent 555740 bytes 1293 pkt (dropped 0, overlimits 0 requeues 0) 
 backlog 0b 0p requeues 0 

~$ sudo tc qdisc del dev lo root netem
RTNETLINK answers: Invalid argument
jberryman commented 9 years ago

Hm, specifying the device seemed to work: comcast --device=lo --stop