1

Does anyone know if tc (iproute2) can be used to percentually divide the currently available bandwidth? We're on a GPRS connection on which the available bandwidth changes frequently. What I want to achieve is the following:

  • Egress to port x: 60% of available bandwidth
  • Egress to port y: 30% of available bandwidth
  • All other egress traffic: 10% of available bandwidth

With tc I managed to achieve something in this direction by using an htb qdisc, and creating 3 classes with a rate of 60 / 30 / 10 kbps. By using a ceiling of 100kbs the classes would use any available bandwidth under 100kbs if available, but never more.

This kind of statically configured bandwidth is however not a solution that would work for us, since our bandwidth is extremely variable and we don't want to configure a ceiling. Our goal is to use the available bandwidth as much as possible. Ideally, we do not want to configure a rate in bytes/seconds but in a percentage. Is this be possible? I looked a the prio qdisc but the documentation there is really lacking.

Thanks!

2
  • How is your router supposed to know what is available? There's no possible way for that to happen.
    – EEAA
    Feb 1, 2016 at 11:54
  • I was afraid this is already theoretically impossible. Thanks for the reply!
    – Jeroen
    Feb 1, 2016 at 11:56

2 Answers 2

1

After some research and thanks to the comment of EEAA, it is clear that dividing the available bandwidth percentually is not possible.

0

You should be able to shape your traffic with hfsc : linkshare m2 bandwidth is supposed to be percentual. Here is some documentation : (1, 2, 3)

You can try this code for example :

iptables -t mangle -A POSTROUTING -p tcp --dport 80 -j CLASSIFY --set-class 1:100
iptables -t mangle -A POSTROUTING -p tcp --dport 80 -j ACCEPT
iptables -t mangle -A POSTROUTING -p tcp --dport 22 -j CLASSIFY --set-class 1:200
iptables -t mangle -A POSTROUTING -p tcp --dport 22 -j ACCEPT
iptables -t mangle -A POSTROUTING -j CLASSIFY --set-class 1:300

tc qdisc del dev enp0s3 root
tc qdisc add dev enp0s3 root handle 1:0 hfsc default 100

tc class add dev enp0s3 parent 1:0 classid 1:10 hfsc ls m2 1000kbit

tc class add dev enp0s3 parent 1:10 classid 1:100 hfsc ls m2 600kbit
tc qdisc add dev enp0s3 parent 1:100 handle 110: fq_codel

tc class add dev enp0s3 parent 1:10 classid 1:200 hfsc ls m2 300kbit
tc qdisc add dev enp0s3 parent 1:200 handle 210: fq_codel

tc class add dev enp0s3 parent 1:10 classid 1:300 hfsc ls m2 100kbit
tc qdisc add dev enp0s3 parent 1:300 handle 310: fq_codel

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .