I was plagued by an internet usage problem because I'm currently sharing my 2Mbps ADSL with two other guys. Whenever someone downloads or watches on-line TV using resource-hungry P2P protocal based software such as Thunder and PPstream(PPstream will use as much uplink and downlink bandwidth as it can, even though it doesn't require that much of bandwidth to be able to play on-line TV or moives smoothly on it.), the other two people could hardly open a web page on their PCs. I tried to settle this with the IP based bandwith limit function that my old D-Link DI-504 router supports, but in vain. Then I purchased a used Netgear 614 V6 router with DD-WRT installed on it. Everything worked out since then. Now I'd like to share with you how I optimized my internet usage with DD-WRT.
I have DD-WRT V24 Sp2 build 15962 installed on my router. It's the lastest edition in 2010. To access to the QoS setting tag, first we enter the GUI management page then click on the NAT/QoS tag and then the QoS sub-tag:
First, I enabled the QoS in the settings and select WAN as the port that I want to control. I chose HTB as the packet scheduler because HSFC doesn't work well(even though it has been fixed since an eariler version). Then I entered 80%-100% of the maximum meansured downlink and uplink bandwidth into downlink and uplink blocks respectively. (Meansured in kbit/s, ignoring the Optimize for Gaming opiton as it never works).
DD-WRT supports four kinds of bandwidth controls: Service, Netmast(IP), MAC and Ethernet Port based controls. The Ethernet port based control only works with a few older model routers so ignore it as well. I personally prefer MAC based priority because it is easier to set up. Service based priority would be better if you do it right. The bandwidth won't waste when there's only one guy's surfing the net. But it is hard to config. You have to know exactly which ports or port ranges that a certain software uses. Software like Thunder and PPstream uses random ports, so it is really hard to restrict them via service based priority. One thing worth pointing out is:
Bandwidth classification based on the four categories will be enabled first on the hardware ports, then on MAC addresses, then netmasks and finally services. For example, if you enable classification based on a MAC address, this will override netmask and service classifications. However, the LAN port based classification will work together with MAC, netmask and service classifications, and will not override them.
Then I added the MAC of the computers that connecting to my router into the MAC addresses based control. As you can see in the above pictures, there are actually four MACs. Two of them are mine(desktop and laptop) and the rest belong to the other guys. You can specify a classification to each MAC. There are a total of five classifications over there: Exempt, Premium, Express, Standard and Bulk. Except Exempt, DD-WRT doesn't exactly tell you how each of the rest four classifications is defined. Never mind, we can define it by ourself.
I opened the management page:
Do you see the Cron text box? That's what is gonna help us re-define each classification. DD-WRT is a linux based third part firmware so it actually supports linux scripts. I put the following commands into the Cron text box, saved and applied them. Don't forget to reboot your router to let the settings take effect.
* * * * * root tc class replace dev imq0 parent 1:2 classid 1:10 htb rate 640kbit ceil 1200kbit
* * * * * root tc class replace dev imq0 parent 1:2 classid 1:20 htb rate 620kbit ceil 1180kbit
* * * * * root tc class replace dev imq0 parent 1:2 classid 1:30 htb rate 600kbit ceil 1160kbit
* * * * * root tc class replace dev imq0 parent 1:2 classid 1:40 htb rate 512kbit ceil 1000kbit
* * * * * root tc class replace dev ppp0 parent 1:2 classid 1:10 htb rate 50kbit ceil 200kbit
* * * * * root tc class replace dev ppp0 parent 1:2 classid 1:20 htb rate 50kbit ceil 200kbit
* * * * * root tc class replace dev ppp0 parent 1:2 classid 1:30 htb rate 50kbit ceil 200kbit
* * * * * root tc class replace dev ppp0 parent 1:2 classid 1:40 htb rate 50kbit ceil 200kbit
The first four lines(from top to bottom) describes the download controls and the rest four for the upload. 10=premium, 20=Express, 30=Standard and 40=Bulk. I'll take this command for example:
* * * * * root tc class replace dev imq0 parent 1:2 classid 1:10 htb rate 640kbit ceil 1200kbit
It means that services/computers at premium classfication will get a downlink bandwidth as low as 640kbit/s and as high as 1200kbit/s. But it isn't that accurate. You can change the values by your will.
If you think these settings don't satisfy you, then go to the Commands page. You could input scripts there. Saving them as firewall or startup, ect. And run the commands you saved. If you are not familiar with writting linux scripts, there are script generators available on the net.
Newer versions of DD-WRT also support various of TCP Congestion Control settings (also on the Management page). Even though they don't actually belong to QoS, to some extent, they are doning the same job. And TCP Congestion Control could work with QoS. The DD-WRT on my router has three TCP Congestion Control options: Vegas, Westwood and BIC. I set it to BIC. I don't know exactly what they mean and how they work, but my impression is BIC works better for me.
After all these settings have been done. Now if there's only one user is downloading or watching on-line TV, the others won't be affected too much. That's because the P2P software can't eat up all the uplink and downlink bandwidth. And now my internet connection is capable of handling up to two users watching on-line TV smoothly at the same time.
Okay, this is the longest article I've ever written in English. I Hope it is helpful to you. And as my signature says, please tell me about anything in my articles that doesn't sound natural to you. Thanks.