Traffic Shaping tc-tbf

1.8k views Asked by At

i'm trying set traffic shaping with tc and tbf qdisk on my wireless interface, to limit download bandwidth. By now I successfully wrote wondershaper, which use HTB. I'd like to use classless shaping, and read that the right qdisk for this job is TBF.

But when I try to set it, had no effect: download keeps going fast.

I tried different ways to do it, but it never worked:

tc qdisc add dev wlan0 root tbf rate 0.5mbit burst 5kb latency 70ms peakrate 1mbit minburst 1540


tc qdisc add dev wlan0 handle 1:0 root dsmark indices 1 default_index 0
tc qdisc add dev wlan0 handle 2:0 parent 1:0 tbf burst 20480 limit 20480 mtu 1514 rate 32000bps

tc qdisc add dev wlan0 root tbf rate 10Mbit burst 10kb latency 5ms

tc qdisc add dev wlan0 root tbf rate 220kbit latency 50ms burst 1540

Could anyone give me any advice on how to do it, or where I'm doing wrong??

1

There are 1 answers

0
Helmut Grohne On

You need to distinguish the packet direction. The two directions are:

  • egress: This is about packets leaving your system. In case your system produces packets faster than the medium can handle, your system queues packets. When queuing happens, you can control the order of the queue (scheduling), you can delay sending of packets (shaping) and you can drop packets (dropping).
  • ingress: This is about packets arriving at your system. You have no control about when packets arrive. All you can do is decide whether you want to process them or not. This is called "policing".

Since your use case is downloading, we are talking about ingress. The token bucket filter is a queuing algorithm, so it does not apply here. The only way to influence a download is to drop packets (or simulate dropping by using ECN). You can find more information about policing in LARTC.