I am trying to slow down incoming packets for a specific program, while a second one will have full access to the unused bandwidth. In other words, I want to control the network bandwidth sharing in order to prioritize one app over another one.
Here is my current configuration, inpired from https://github.com/rfrail3/misc/blob/master/tc/traffic-control.sh :
# Set up a virtual interface
modprobe ifb
ip link set dev ifb0 up
# Set up eth0 in order to redirect incoming packets
tc qdisc add dev eth0 handle ffff: ingress
# Filter to make the packet going on ifb0
tc filter add dev eth0 protocol ip parent ffff: u32 match u32 0 0 action mirred egress redirect dev ifb0
# ifb0 configuration
tc qdisc add dev ifb0 root handle 2: htb
tc class add dev ifb0 parent 2: classid 2:1 htb rate 1000mbit
tc class add dev ifb0 parent 2:1 classid 2:10 htb rate 999mbit ceil 1000mbit
tc class add dev ifb0 parent 2:1 classid 2:11 htb rate 1mbit ceil 1000mbit
Then, I am applying filters on ifb0 to redirect my packet on 2:10 (the high priority class) or 2:11 (low priority class).
The packets are assigned to the classes as expected, but, the network is shared fairly between both applications (50/50, instead of 1/99 as I would expect from the HTB config).
Actually, I don't see why my network is fairly shared and my rates/ceils are not respected. What am I doing wrong here ?
Best Answer
You are setting the default traffic to go handle 20, but this one not exists so will never match any rate/ceils.
tc qdisc add dev ifb0 root handle 2: htb default 20
_________________________________________^^^^^^^^^^
try add one rule
classid 2:20
i recommend a fast read on this page for more explanation: http://lartc.org/lartc.html#AEN1071