Overview of additional packages: AdditionalPackages
An update has been tried, but may not be complete. New info may only apply to the latest CRs (please review).
Changes were inspiered in the information found here:
http://wl500g.dyndns.org/
(under the section "Custom firmware features" and subsection "Important changes").
Wondershaper
Wondershaper is a Bash script which implements a set of rules to provide Quality of Service also know as bandwidth management for your network trafic.
Request
- a web based configuration will help lots of newbies here.
Features
- Maintain low latency for interactive traffic at all times This means that downloading or uploading files should not disturb SSH or even telnet. These are the most important things, even 200ms latency is sluggish to work over.
- Allow 'surfing' at reasonable speeds while up or downloading Even though http is 'bulk' traffic, other traffic should not drown it out too much.
- Make sure uploads don't harm downloads, and the other way around This is a much observed phenomenon where upstream traffic simply destroys download speed. It turns out that all this is possible, at the cost of a tiny bit of bandwidth. The reason that uploads, downloads and ssh hurt eachother is the presence of large queues in many domestic access devices like cable or DSL modems.
Download
The Wondershaper script is included in firmwares v1.7.5.9 CR4 (Oleg) and up.
Source
The homepage of Wondershaper can be found here:
http://lartc.org/wondershaper/
There is also a link to the Linux Advanced Router & Shaping HowTo here:
http://lartc.org/ which contains all the background information and a sample script like Wondershaper.
Installation
NOTE: Anyone who's still using BootCmd's should migrate first to the Flashfs-boot method before continuing. Flashfs-boot is explained here: FlashfsBoot
To use QoS you have to add the Bash script to your boot sequence. Add for example the following to the /usr/local/sbin/post-firewall script, where 1000 and 500 are the maximum download and upload speeds of your ISP connection:
/init/wshaper start $1 1000 500 (old CR versions)
/sbin/wshaper start $1 1000 500 (new CR versions--1.8.x.x and above)
Please use your own connection parameters, though slightly lower than the maximum possible values; suggestion: check the real maximum possible values using a speed test like
http://www.speedtest.nl/TestSuite/).
Some may find that download speed becomes slower when activating Wondershaper (for example, when using 3000 as a download speed with Wondershaper it may seem to be limited to a mere 2000 Kbps). Using a download speed value higher than the maximum tested speed (by extents as great even as 25%) may solve this "problem" if indeed it is a problem.
NOTE: $1 is only available when the command is executed inside the post-firewall script. When the system executes post-firewall, it notifies it of the WAN interface name, the WAN IP address, and the LAN interface name via parameters. $1 is the parameter for the acutal used WAN interface and, when used in post-firewall, should not be replaced by a fixed device unless executed manually. To determine your WAN interface name manually, execute the nvram get wan_ifname command or use ifconfig to list all available interfaces.
Once you've setup Wondershaper you should check if the upload and download speed settings provide the correct shaping for you. If you still have problems with applications (e.g. VoIP) during uploads and downloads, you should change these setting to a lower value until everything works fine for you.
Configuration options
The script accepts a variable number of parameters (some of which are allready described above). Below is a full list and its options:
- DEV - the device over which the data is shaped
- DOWNLINK - The maximum speed of the download link (data comes from the internet)
- UPLINK - The maximum speed of the upload link (data moves towards the internet)
- NOPRIOHOSTSRC - Hosts from which all data has low priority
- NOPRIOHOSTDST - Hosts to which all data has low priority
- NOPRIOPORTSRC - Ports from which all data has low priority
- NOPRIOPORTDST - Ports to which all data has low priority
The parameters 4 to 7 are optional.
Customizing the script
This is an advanced topic, intended for anyone who wants non-standard shaping.
Because Wondershaper is in fact a script you can change it to you own likings. Possible changes are:
- Individual shaping for each computer on the LAN
- Shaping WLAN trafic
- Shaping of specific protocols like VoIP etc
- More.
To change the script you have to do the following steps:
Make a copy of the original script to /usr/local/sbin using
cp /sbin/wshaper /usr/local/sbin
- Edit the /usr/local/sbin/post-firewall script to use the custom script
- Edit the /usr/local/sbin/wshaper script to your likings
- Commit the changes to flash using flashfs save and flashfs commit
- Active changes using reboot or by a similar command like /usr/local/sbin/wshaper start eth1 1000 500
NOTE: Replace /usr/local/sbin by /usr/local/init (and /sbin/ by /init/) if using an older CR.
Examples
- should be lots of examples to make this easier to digest for newbies.
- example for limiting p2p/downloads/etc
example for prioritizing voip/im/games/etc
Prioritizing VOIP
Instead of distinguishing VOIP traffic by port numbers, use the following in your wondershaper script: (be sure to add it to a tc filter command)
match ip tos 0x68 0xff
and ...
match ip tos 0xb8 0xff \
0x68 is the TOS (Type of Service) identifier that SIP signalling traffic is usually classified as, and
0xb8 is the TOS (Type of Service) identifier that RTP voice traffic is usually classified as
A good VOIP QoS script can be found at
http://www.voip-info.org/wiki/view/QoS+with+Linux+using+PRIO+and+HTB
Below a simple explanation for newbies on how to setup QoS for VOIP in the WL500g using the WonderShaper? script. The script
- written by Akbor is used (thanks!), based on the information that is found in the following forum-thread
To prioritize VOIP you can use the following steps:
1. Use putty.exe to setup a telnet connection to your WL500g and login using your username and password.
2. Check which word is used for you WAN interface by typing:
ifconfig
The one that shows you external IP address is the WAN interface and if this is different than eth1 this should be
used instead of eth1 in the subsequent steps.
3. Check whether the wshaper script is turned off by typing:
wshaper status eth1
If the script is already running, turn it off by disabling "Bandwidth Management" in the web-interface to your WL500g
and restarting the router.
4. Check what files are in the local user-directory by typing:
cd /usr/local/sbin
ls
5. The wshaper script should not be here (yet), you can remove it by typing:
rm wshaper
6. Make a new file in the local folder that contains the new wshaper script (can be done without any harm!) using
vi /usr/local/sbin/wshaper
7a. VI is an editor that you can use to input the script. Do this by hitting ESC, pressing i (insert mode) and typing
in the script. If something goes wrong, just exit the VI editor by hitting ESC and typing:
:q!
If you are ready save the file by pressing ESC and typing (shift-ZZ):
ZZ
7b. OR copy-paste the script from below in the VI editor in the putty-window. First you have to turn of auto-indent
in the VI editor by pressing ESC and typing:
:set noai!
Pasting can be done by entering the insert mode (ESC and then i) and pressing the right mouse button in the putty-
window.
Copy the script below (from user Akbor, see forum thread for more info) using control-C and pressing the right mouse
button. Afterwards save the script by ESC and shift-ZZ.
#!/bin/sh
# Wonder Shaper, last modified by Robert Koch (aka akbor)
#
# Set the following values to somewhat less than your actual download
# and uplink speed. In kilobits. Also set the device that is to be shaped.
DOWNLINK=$3
UPLINK=$4
DEV=$2
# low priority OUTGOING traffic - you can leave this blank if you want
# low priority source netmasks
NOPRIOHOSTSRC="$5"
# low priority destination netmasks
NOPRIOHOSTDST="$6"
# low priority source ports
NOPRIOPORTSRC="$7"
# low priority destination ports
NOPRIOPORTDST="$8"
if [ "$1" = "status" ]
then
tc -s qdisc ls dev $DEV
tc -s class ls dev $DEV
exit
fi
# clean existing down- and uplink qdiscs, hide errors
tc qdisc del dev $DEV root 2> /dev/null > /dev/null
tc qdisc del dev $DEV ingress 2> /dev/null > /dev/null
if [ "$1" = "stop" ]
then
exit
fi
########## uplink ##########
# install root HTB, point default traffic to 1:20:
tc qdisc add dev $DEV root handle 1: htb default 20
# shape everything at $UPLINK speed - this prevents huge queues in your
# DSL modem which destroy latency:
tc class add dev $DEV parent 1: classid 1:1 htb rate ${UPLINK}kbit \
ceil ${UPLINK}kbit burst 6k
# high prio class 1:10 - gets 50 to 100% traffic and highest priority:
tc class add dev $DEV parent 1:1 classid 1:10 htb rate $((5*$UPLINK/10))kbit \
ceil ${UPLINK}kbit burst 6k prio 1
# bulk & default class 1:20 - gets 40 to 100% traffic and lower priority:
tc class add dev $DEV parent 1:1 classid 1:20 htb rate $((4*$UPLINK/10))kbit \
ceil ${UPLINK}kbit burst 6k prio 2
# lowest priority class 1:30 - gets 10 to 100% traffic and lowest priority:
tc class add dev $DEV parent 1:1 classid 1:30 htb rate $((1*$UPLINK/10))kbit \
ceil ${UPLINK}kbit burst 6k prio 3
# all get Stochastic Fairness:
tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10
tc qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10
# high priority for VoIP traffic (by TOS)
tc filter add dev $DEV parent 1:0 protocol ip prio 1 u32 \
match ip tos 0x68 0xff \
match ip protocol 0x11 0xff \
flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 1 u32 \
match ip tos 0xb8 0xff \
match ip protocol 0x11 0xff \
flowid 1:10
# high priority for VoIP traffic (by source port)
tc filter add dev $DEV parent 1:0 protocol ip prio 1 u32 \
match ip sport 5004 0xffff \
match ip protocol 0x11 0xff \
flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 1 u32 \
match ip sport 5060 0xffff \
match ip protocol 0x11 0xff \
flowid 1:10
# TOS Minimum Delay (ssh, NOT scp) in 1:10:
tc filter add dev $DEV parent 1:0 protocol ip prio 3 u32 \
match ip tos 0x10 0xff \
flowid 1:10
# ICMP (ip protocol 1) in the interactive class 1:10 so we
# can do measurements & impress our friends:
tc filter add dev $DEV parent 1:0 protocol ip prio 1 u32 \
match ip protocol 1 0xff \
flowid 1:10
# To speed up downloads while an upload is going on, put ACK packets in
# the interactive class:
tc filter add dev $DEV parent 1: protocol ip prio 2 u32 \
match ip protocol 6 0xff \
match u8 0x05 0x0f at 0 \
match u16 0x0000 0xffc0 at 2 \
match u8 0x10 0xff at 33 \
flowid 1:10
# some traffic however suffers a worse fate
for a in $NOPRIOPORTDST
do
tc filter add dev $DEV parent 1: protocol ip prio 14 u32 \
match ip dport $a 0xffff flowid 1:30
done
for a in $NOPRIOPORTSRC
do
tc filter add dev $DEV parent 1: protocol ip prio 15 u32 \
match ip sport $a 0xffff flowid 1:30
done
for a in $NOPRIOHOSTSRC
do
tc filter add dev $DEV parent 1: protocol ip prio 16 u32 \
match ip src $a flowid 1:30
done
for a in $NOPRIOHOSTDST
do
tc filter add dev $DEV parent 1: protocol ip prio 17 u32 \
match ip dst $a flowid 1:30
done
# rest is 'non-interactive' ie 'bulk' and ends up in 1:20
tc filter add dev $DEV parent 1: protocol ip prio 1 u32 \
match ip dst 0.0.0.0/0 flowid 1:20
########## downlink ##########
# slow downloads down to somewhat less than the real speed to prevent
# queuing at our ISP. Tune to see how high you can set it.
# ISPs tend to have *huge* queues to make sure big downloads are fast
#
# attach ingress policer:
tc qdisc add dev $DEV handle ffff: ingress
# filter *everything* to it (0.0.0.0/0), drop everything that's
# coming in too fast:
tc filter add dev $DEV parent ffff: protocol ip prio 50 u32 match ip src \
0.0.0.0/0 police rate ${DOWNLINK}kbit burst 10k drop flowid :1
9. Before you are able to test/run the script you have to change the permission to the file (to allow execution.)
chmod +x /usr/local/sbin/wshaper
10. Before testing the script you have to save the file to flash (harmless!) so that it is kept also after a reboot of
the WL500g. Commit the changes to flash using:
flashfs save
flashfs commit
11. Now you can reboot the WL500g by:
reboot
11. Check the download and upload speed of your connection by using e.g.
http://www.speedguide.net/speedtest/
http://www.speedtest.nl/
12. Start the script by typing (replace the numbers by taking 80% of the download and upload speeds found):
/usr/local/sbin/wshaper start eth1 1000 200
13. Test if the script is working properly by using:
wshaper status eth1
When you make a phone-call over your VOIP connection the numbers for the 1:10 class should increase, when you surf
the internet of ftp, the number in the 1:20 class should increase. This proofs the QoS is taken care of by the
WonderShaper? script. Class 1:30 is (somehow) not working.
If you are satisfied you can implement the script in your post-firewall script as described elsewhere on this page so
that the script is also started after a reboot.
Prioritizing Xbox Live
Xbox Live connects to remote UDP ports 88 and 3074 and TCP port 3074. It does not listen on any ports.
tc filter add dev $DEV parent 1:0 protocol ip prio 11 u32 \match ip dport 88 0xffff \
match ip protocol 17 0xff \
flowid 1:10tc filter add dev $DEV parent 1:0 protocol ip prio 11 u32 \
match ip dport 3074 0xffff \
match ip protocol 17 0xff \
flowid 1:10tc filter add dev $DEV parent 1:0 protocol ip prio 11 u32 \
match ip dport 3074 0xffff \
flowid 1:10
Related links
Topics on wl500g.info Forum:
- Wondershaper QoS discussion
http://wl500g.info/showthread.php?t=752 - Would it be possible to implement wondershaper?
http://wl500g.info/showthread.php?t=192 - Firmware v1.7.5.9 CR4 (Oleg)
http://wl500g.info/showthread.php?t=738
Elsewhere:
- (description) (url)
Known problems
- (none I hope)
Problems
Problem 1
xxx@xxxxx root?$ wshaper start "$1" 256 40
Cannot find device "root"
Error: Qdisc "1:" is classless.
Error: Qdisc "1:1" is classless.
Error: Qdisc "1:1" is classless.
Error: Qdisc "1:1" is classless.
Unknown qdisc "1:10", hence option "handle" is unparsable
Unknown qdisc "1:20", hence option "handle" is unparsable
Unknown qdisc "1:30", hence option "handle" is unparsable
Unknown filter "1:0", hence option "protocol" is unparsable
Unknown filter "1:0", hence option "protocol" is unparsable
Unknown filter "1:", hence option "protocol" is unparsable
Unknown filter "1:", hence option "protocol" is unparsable
Unknown qdisc "ffff:", hence option "ingress" is unparsable
Unknown filter "ffff:", hence option "protocol" is unparsable
Answer to problem 1
Replace the "$1" by eth1 (or any other relevant device label) like this:
xxx@xxxxx root?$ wshaper start eth1 256 40
$1 is only defined if you are using the command in the post-firewall script...
