All of lore.kernel.org
 help / color / mirror / Atom feed
* Can't get tc to limit network traffic
@ 2014-09-15  1:37 Teresa e Junior
  2014-09-15  4:18 ` Mike Schmidt
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Teresa e Junior @ 2014-09-15  1:37 UTC (permalink / raw)
  To: lartc

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-09-15 21:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-15  1:37 Can't get tc to limit network traffic Teresa e Junior
2014-09-15  4:18 ` Mike Schmidt
2014-09-15  5:09 ` Teresa e Junior
2014-09-15  5:49 ` Mike Schmidt
2014-09-15 16:03 ` Andy Furniss
2014-09-15 16:33 ` Dave Taht
2014-09-15 17:27 ` Andy Furniss
2014-09-15 17:41 ` Dave Taht
2014-09-15 21:56 ` Teresa e Junior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.