2

I'm trying to police my downstream bandwith for a given port - but it seems unless I have a gigantic limit and burst, the download stops completely

IF="wlp3s0"
LIMIT="100kbit"
BURST="100kbit"
PORT="80"

echo "resetting tc"
tc qdisc del dev ${IF} ingress

echo "setting tc"

tc filter add dev ${IF} parent ffff: \
   protocol ip prio 1 \
   u32 match ip dport ${PORT} 0xffff \
   police rate ${LIMIT} burst $BURST drop \
   flowid :1
tc filter add dev ${IF} parent ffff: \
   protocol ip prio 1 \
   u32 match ip sport ${PORT} 0xffff \
   police rate ${LIMIT} burst $BURST drop \
   flowid :1

I've been tweaking things for quite some time, trying out all sorts of different values for limit and burst - wgetting chozabu.net/testfile (12mb)

any suggestions very welcome!

1

I am not quite sure about the wlan interface you are using but I guess you are missing the virtual interface which is supposed to redirect the traffic from ethX or in your case wlan3s0 into ifb which than controls the incoming packet

So, something similar to

modprobe ifb numifbs=1
ip link set dev ifb0 up
tc filter add dev wlp3s0 parent ffff: protocol ip u32 match u32 0 0 action mirred egress redirect dev ifb0
tc qdisc add dev $VIRTUAL root handle 2: htb
tc filter add dev $VIRTUAL protocol ip parent 2: prio 1 u32 match ip sport ${PORT} 0xffff police rate ${LIMIT} burst $BURST drop \
flowid :1

I have created a bash script which allows you to filter bandwidth for incoming and/or outgoing traffic on specific ip address (or network)

https://gist.github.com/ole1986/d9d6be5218affd41796610a35e3b069c

Usage: ./traffic-control.sh [-r|--remove] [-i|--incoming] [-o|--outgoing] <IP>

Arguments:
  -r|--remove     : removes all traffic control being set
  -i|--incoming   : limit the bandwidth only for incoming packetes
  -o|--outgoing   : limit the bandwidth only for outgoing packetes
  <IP>            : the ip address to limit the traffic for

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.