Discussion:
[OpenWrt-Users] Help with traffic shaping: limiting bandwidth for a host
Stefan Monnier
2018-04-16 17:40:24 UTC
Permalink
I'm trying to limit bandwidth usage of a particular set of hosts.

After reading various manpages and webpages about tc, qdisc, classes and
whatnot, I believe I mostly know what I'd like to do and how, but the
final details still elude me:

Basically, I want to pass traffic destined to a particular set of local
hosts (say 192.168.1.16/29) through the `tbf` traffic shaping scheduler.

Now if these hosts were connected to their own network interfaces,
I believe I could just do something like

tc qdisc add dev $IF root tbf burst 1mb rate 100kbps

but since these are connected to the same network interface as several
other machines (for which I do not want to do any particular traffic
shaping), I have to do it differently:

iptables -t mangle -A POSTROUTING -j CLASSIFY \
--dst 192.168.1.16/29 --set-class 1:10

supposedly sets a "class 1:10" on each package destined to one of those
hosts, and I "just" need to setup my $IF such that packets of this class
go through the tbf scheduler.

But that's where I'm stumped, because `tbf` is a classless scheduler, so
I need to set a classful scheduler on $IF which divides the traffic
between 2 classes one of which goes through the tbf scheduler.
And I haven't been able to figure out how to do that. Any help?


Stefan
Luiz Angelo Daros de Luca
2018-04-16 20:44:52 UTC
Permalink
Hi Stefan,

It's way more complex than that. I just published a PR for a new package
that does traffic shaping:

https://github.com/openwrt/packages/pull/5926

You can give a feedback at github.

If you are not familiar with building a package, just copy
/etc/init.d/trafficshaper, /etc/config/trafficshaper
and /etc/hotplug.d/iface/11-trafficshaper to your router.

Regards,
Post by Stefan Monnier
I'm trying to limit bandwidth usage of a particular set of hosts.
After reading various manpages and webpages about tc, qdisc, classes and
whatnot, I believe I mostly know what I'd like to do and how, but the
Basically, I want to pass traffic destined to a particular set of local
hosts (say 192.168.1.16/29) through the `tbf` traffic shaping scheduler.
Now if these hosts were connected to their own network interfaces,
I believe I could just do something like
tc qdisc add dev $IF root tbf burst 1mb rate 100kbps
but since these are connected to the same network interface as several
other machines (for which I do not want to do any particular traffic
iptables -t mangle -A POSTROUTING -j CLASSIFY \
--dst 192.168.1.16/29 --set-class 1:10
supposedly sets a "class 1:10" on each package destined to one of those
hosts, and I "just" need to setup my $IF such that packets of this class
go through the tbf scheduler.
But that's where I'm stumped, because `tbf` is a classless scheduler, so
I need to set a classful scheduler on $IF which divides the traffic
between 2 classes one of which goes through the tbf scheduler.
And I haven't been able to figure out how to do that. Any help?
Stefan
_______________________________________________
openwrt-users mailing list
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-users
--
Luiz Angelo Daros de Luca
***@gmail.com
Nishant Sharma
2018-04-17 07:25:47 UTC
Permalink
Hi,
Post by Luiz Angelo Daros de Luca
It's way more complex than that. I just published a PR for a new package
https://github.com/openwrt/packages/pull/5926
It looks great.

A question though, does it act friendly with "qos" package? There are scenarios where I would want to prioritise bandwidth to certain services.

If both the packages work together, then I will be able to prioritise the type of traffic within allocated bandwidths for the hosts.

Regards,
Nishant
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Luiz Angelo Daros de Luca
2018-04-17 13:50:00 UTC
Permalink
Post by Nishant Sharma
A question though, does it act friendly with "qos" package? There are
scenarios where I would want to prioritise bandwidth to certain services.


Unfortunately no. All QoS packages (qos-scripts, sqm-scripts) conflict on
each other.

You can prioritise a device based on its LAN address. It does not need to
be a "network address". A host address will do just fine.
I use cake as leaf scheduler, which does a pretty nice job on keeping
latency low. So, you get both low latency and bandwidth reservation.

I would do something like this to allow torrent to use only idle bandwidth
but keep chromecast share if needed.
(BTW, I must fix network options in my default config in my PR)

config class 'lan'
list network '192.168.1.0/24'
option reserved_downlink '50%'
option reserved_uplink '50%'
option allowed_downlink '100%'
option allowed_uplink '100%'

config class 'chromecast'
list network '192.168.1.12/32'
option reserved_downlink '45%'
option reserved_uplink '5%'
option allowed_downlink '100%'
option allowed_uplink '100%'

config class 'torrent'
list network '192.168.1.22/32'
option reserved_downlink '5%'
option reserved_uplink '5%'
option allowed_downlink '100%'
option allowed_uplink '100%'

If chromecast is idle and torrent and lan uses all bandwidth, lan might get
a little more than 90% and torrent a little less than 10%.
If both lan and chromecast are idle, torrent will use everything.

Regards,

Loading...