TC="/sbin/tc" # sudo ifconfig dummy0 up sudo ifconfig dummy1 up DEV1="eth0" DEV2="eth1" # # # sudo $TC qdisc del dev $DEV1 ingress sudo $TC qdisc add dev $DEV1 ingress sudo $TC qdisc del dev $DEV2 ingress sudo $TC qdisc add dev $DEV2 ingress #Note - older tc did not pipe for skbedit (add "pipe" if this is rejected) sudo $TC filter add dev $DEV1 parent ffff: protocol ip pref 10 \ u32 match ip protocol 1 0xff flowid 1:10 \ action skbedit mark 11 \ action police rate 10kbit burst 10k pipe index 1 \ action skbedit mark 12 \ action police rate 20kbit burst 20k pipe index 2 \ action action mirred egress mirror dev dummy0 #note sharing of the two policers by two flows #across multiple devices sudo $TC filter add dev $DEV2 parent ffff: protocol ip pref 10 \ u32 match ip protocol 1 0xff flowid 1:10 \ action skbedit mark 21 \ action police rate 10kbit burst 10k pipe index 1 \ action skbedit mark 22 \ action police rate 20kbit burst 20k pipe index 2 \ action action mirred egress mirror dev dummy1 # # # now do a ping -f to somewhere, for more exciting results # do a -s 2048 or so # sudo ping -f 192.168.1.100 -c 10000 # sudo ping -f 127.0.0.1 -c 10000 # sudo tc -s filter ls dev $DEV1 parent ffff: protocol ip sudo tc -s filter ls dev $DEV2 parent ffff: protocol ip sudo tc -s actions ls action police sudo tc -s actions ls action skbedit