Page 1 of 2

Optimizing your internet usage with the Qos functionality of DD-WRT

PostPosted: April 26th, 2011, 3:21 am
by duckula
Before you read the following article, please note that NOT all wifi routers support DD-WRT. Checking out the device supporting list at DD-WRT's offical website before you try to install it. There're risks that you might either brick your router or invalidate its warranty with a third part firmware. And sometimes with certain models of routers, you can't go back to the stock fireware once DD-WRT has been installed. I'm not responsible for any mental depression, physical damages or any money loss caused by DD-WRT. :P

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:
Image

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:
Image

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.
Image

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. :D And as my signature says, please tell me about anything in my articles that doesn't sound natural to you. Thanks.

RE: Optimizing your internet usage with the Qos functionality of DD-WRT

PostPosted: April 26th, 2011, 6:57 am
by duckula
shovenose wrote:Looks interesting...I'm looking forward to a continuation.


Check back! :lol:

RE: Optimizing your internet usage with the Qos functionality of DD-WRT

PostPosted: April 26th, 2011, 4:37 pm
by duckula
Thanks so much. I'm waiting for the big wave of corrections approaching. :thnx:

RE: Optimizing your internet usage with the Qos functionality of DD-WRT

PostPosted: April 26th, 2011, 4:58 pm
by duckula
:thnx: :thnx: :thnx: :thnx:

I have fixed all my mistakes you pointed out. Looking forward to more corrections. :D

RE: Optimizing your internet usage with the Qos functionality of DD-WRT

PostPosted: April 26th, 2011, 7:29 pm
by shovenose
"valid" in the 1st paragraph should be "invalidated"...

also,
I was plagued by an internet usage problem because I'm currently sharing my 2Mbps ADSL with two other guys. Once someone downloads something or watchs on-line moives using resource-hungry P2P 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 could hardly open a web page on their PCs.

this whole thing is awkward. see if you can revise it...

RE: Optimizing your internet usage with the Qos functionality of DD-WRT

PostPosted: April 26th, 2011, 7:49 pm
by shovenose
By the way, Duckula, I want to congratulate you for the outstanding article. It's excellent, better written that most native English language people, and is a fun read.
Would you be interested in me making you an account on the main page so you can post it there?

RE: Optimizing your internet usage with the Qos functionality of DD-WRT

PostPosted: April 26th, 2011, 7:58 pm
by duckula
shovenose wrote:"valid" in the 1st paragraph should be "invalidated"...

Fixed :thnx: I actually meant "void" while I typed "valid". Does void fit this position?

also,
I was plagued by an internet usage problem because I'm currently sharing my 2Mbps ADSL with two other guys. Once someone downloads something or watchs on-line moives using resource-hungry P2P 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 could hardly open a web page on their PCs.

this whole thing is awkward. see if you can revise it...


I'll try to rewrite this paragraph later. It's lunch time now. :P Yeah, these sentences sound ackward to me too. Especially this one: Once someone downloads something or watchs on-line moives using resource-hungry P2P based software such as Thunder and PPstream he other two could hardly open a web page on their PCs"

:D Hoping I don't have to revise the whole article. :lol2: :blush:

RE: Optimizing your internet usage with the Qos functionality of DD-WRT

PostPosted: April 26th, 2011, 8:00 pm
by shovenose
i think it's awkware because "the other two"...the other what? movies? people? pies? emails?...

RE: Optimizing your internet usage with the Qos functionality of DD-WRT

PostPosted: April 26th, 2011, 8:09 pm
by duckula
:) And I think the sentence structure I used is no good the way it is.

RE: Optimizing your internet usage with the Qos functionality of DD-WRT

PostPosted: April 26th, 2011, 10:34 pm
by duckula
shovenose wrote:By the way, Duckula, I want to congratulate you for the outstanding article. It's excellent, better written that most native English language people, and is a fun read.
Would you be interested in me making you an account on the main page so you can post it there?


:P I wonder how I missed this post. I'd like to post it on the main page if you allow me. And before that, I have to make sure that there're any misspellings, gramma mistakes and bad sentence structures in my artical.