Using traffic shaping (tc) on Linux, trying to limit throughput in 2 levels.
Class 1:20 inherits from 1:10 but traffic restriction does not apply. The traffic is being limiting using the limit of the last class.
class htb 1:1 root rate 1Gbit ceil 1Gbit burst 15125b cburst 1375b
class htb 1:10 parent 1:1 rate 4Mbit ceil 5Mbit burst 15Kb cburst 1600b
class htb 1:20 parent 1:10 leaf 200: prio 0 rate 9Mbit ceil 10Mbit burst 15Kb cburst 1600b
class htb 1:30 parent 1:10 leaf 300: prio 0 rate 9Mbit ceil 10Mbit burst 15Kb cburst 1600b
I'm filtering per station using the following filter:
filter parent 1: protocol all pref 5 u32
filter parent 1: protocol all pref 5 u32 fh 800: ht divisor 1
filter parent 1: protocol all pref 5 u32 fh 800::20 order 32 key ht 800 bkt 0 flowid 1:20
match 00000800/0000ffff at -4
match 5be42dc1/ffffffff at -12
match 00009cd3/0000ffff at -16
Using iperf TCP to test:
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 1.0 sec 1.25 MBytes 10.5 Mbits/sec
[ 3] 1.0- 2.0 sec 1.12 MBytes 9.44 Mbits/sec
[ 3] 2.0- 3.0 sec 1.00 MBytes 8.39 Mbits/sec
All traffic is passing though the 2 classes:
class htb 1:10 parent 1:1 rate 4Mbit ceil 5Mbit linklayer ethernet burst 15Kb/1 mpu 0b overhead 0b cburst 1600b/1 mpu 0b overhead 0b level 6
Sent 31091090 bytes 20545 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
lended: 0 borrowed: 0 giants: 0
tokens: -135041557 ctokens: -86778070
class htb 1:20 parent 1:10 leaf 200: prio 0 quantum 112500 rate 9Mbit ceil 10Mbit linklayer ethernet burst 15Kb/1 mpu 0b overhead 0b cburst 1600b/1 mpu 0b overhead 0b level 0
Sent 31091090 bytes 20545 pkt (dropped 17, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 101p requeues 0
lended: 20545 borrowed: 0 giants: 0
tokens: -20701 ctokens: 1075
If you want to limit traffic per ip then you can use this method (i`m using it to limit virtual servers bandwidth virtualized with openvz, but you can customize it by your requirements):
and then for each ipv4 address:
For each ipv6:
DS48236.vpsnet.com:~$ tc qdisc show
If you want to limit traffic per one interface then you need to modify:
For each ipv4 address:
and do not create qdisc and class for venet0
So with one interface it will look something like:
For each ip: