Basically, you cannot control inbound traffic with tc, except through policing, which is what the wondershaper rule does. Policing does not shape traffic, it simply drops the excess, which is why it is so unreliable. That is why the throttling works when only you set the src to 192.168.0.5. The solution is to use an intermediate device, like ifb, or imq, depending on the distribution you are running. A typical example is here: http://www.linuxfoundation.org/collaborate/workgroups/networking/ifb I use ifb in our company's software, where we have a number of subnets and or vlans to deal with, and ifb+hfsc has provided good results. I am not familiar with cbq, although we did use htb, which is somewhat similar, until it crashed the kernel under too much load. This problem was fixed in later kernels (>2.6.36). However, hfsc is much more precise. On Sun, Sep 14, 2014 at 9:37 PM, Teresa e Junior <teresaejunior@xxxxxxxxx> wrote: > I have asked this on http://unix.stackexchange.com/questions/154144/, > and even offered a bounty, but nobody was able to answer me (if you want > the bounty, go there and grab it fast ;) > > Based on this section of the Linux Advanced Routing & Traffic Control > HOWTO: http://lartc.org/howto/lartc.ratelimit.single.html, I can't get > tc to limit the network speed in my computer. > > Basically, I have 13 machines in the network, and this particular > machine sometimes steals all traffic available. The router is a Motorola > SurfBoard modem with a few routing capabilities and firewall. The > machine I want to limit the traffic is 192.168.0.5, and also the script > is being run from 192.168.0.5. > > Here is my adaption of the commands in the HOWTO for > /etc/NetworkManager/dispatcher.d/: > > #!/bin/sh -eu > > # clear any previous queuing disciplines (qdisc) > tc qdisc del dev wlan0 root 2>/dev/null ||: > > # add a cbq qdisc; see `man tc-cbq' for details > if [ $2 = up ]; then > # set to a 3mbit interface for more precise calculations > tc qdisc add dev wlan0 root handle 1: cbq avpkt 1000 \ > bandwidth 3mbit > > # leave 30KB (240kbps) to other machines in the network > tc class add dev wlan0 parent 1: classid 1:1 cbq \ > rate 2832kbit allot 1500 prio 5 bounded isolated > > # redirect all traffic on 192.168.0.5 to the previous class > tc filter add dev wlan0 parent 1: protocol ip prio 16 \ > u32 match ip dst 192.168.0.5 flowid 1:1 > > # change the hashing algorithm every 10s to avoid collisions > tc qdisc add dev wlan0 parent 1:1 sfq perturb 10 > fi > > The problem is that I have tried setting 2832kbit to very small values > for testing (like 16kbit), but I still can browse the web at high speed. > The problem is not in NetworkManager, because I'm testing the script > manually. Also, tc doesn't return any errors. > > I have found that by changing dst 192.168.0.5 to src 192.168.0.5, the > upload speed is reliably limited, but I still haven't figured how to get > the download speed to work, which is the most important for me. > > The following approach I have taken from wondershaper: > > tc qdisc add dev wlan0 handle ffff: ingress > tc filter add dev wlan0 parent ffff: protocol ip prio 50 u32 match ip \ > dst 192.168.0.5 police rate 200kbps burst 10k drop flowid :1 > > But the problem with this one is that it is very unreliable, it results in > unstable download speeds (if set to 200, it downloads at ~80-120). > > Thank you! > Teresa and Junior > -- > To unsubscribe from this list: send the line "unsubscribe lartc" in > the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Mike SCHMIDT CTO Intello Technologies Inc. mike.schmidt@xxxxxxxxxxx Canada: 1-888-404-6261 x320 USA: 1-888-404-6268 x320 Mobile: 514-409-6898 www.intello.com -- To unsubscribe from this list: send the line "unsubscribe lartc" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html