FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
www.co30.com

Linksys Router QoS

 
Post new topic   Reply to topic    forums.co30.com Forum Index -> Tech Talk & Hardware Discussion
View previous topic :: View next topic  
Author Message
Sarge(Co30)
is a Veteran Poster


Joined: 17 Aug 2003
Posts: 155
Location: Capital City ON Canada eh!

PostPosted: Sat Oct 29, 2005 11:55 am GMT    Post subject: Linksys Router QoS Reply with quote

So you want to have the best possible gaming connection eh? Low delay, no packet loss, no congestion because someone on your LAN is uploading MP3s or sharing in a Torrent transfer. Some ISP's will tell you you need more bandwidth and try and up-sell you on the next latest bandwidth package. Well what you really need is QoS. The Linksys router I'm using (WRT54G) has it and its pretty easy to configure, click two buttons and enter your Internet connection upload bandwidth limit and you're off to the races!

Here's what I mean. The following three images from the router GUI shows you where to go and which items to set.

The first image shows you the default page once you have logged into your router.


The second image indicates where to locate the QoS setup page in the GUI.


The third and last page shows you which items to set to make QoS active on your router, set items 1, 2 and 3 then click the save settings button at the bottom of the page.


So what just happen?
By selecting buttons 1 and 3 you have just activated the routers QoS classification and marking features. Based on a set of pre-defined TCP/UDP ports, packets leaving your home network heading off to the great and wonderful Internet are being specially marked to indicate to the ISPís routers and switches that your marked packets should get preferential treatment. In this case they are marked with the DSCP EF classification. This puts your game packets into the same class of service as VoIP traffic (low delay, high throughput) which means you get low or consistent packet jitter and consistent delay.

So how are the packets marked?
Well, since the WRT54G runs a Linux kernel (http://tinyurl.com/8b7x8 ) it uses Netfilter (iptables) to classify and mark the packets. Here is the default classification that is enabled by the ďOptimize Gaming ApplicationsĒ checkbox in the GUI.
Code:
Chain PREROUTING (policy ACCEPT)
target  prot opt source   destination         
DSCP   udp  --  0.0.0.0/0   0.0.0.0/0   udp dpt:27900 DSCP set 0x2e
DSCP   udp  --  0.0.0.0/0   0.0.0.0/0   udp dpts:7777:7783 DSCP set 0x2e
DSCP   udp  --  0.0.0.0/0   0.0.0.0/0   udp dpt:27952 DSCP set 0x2e
DSCP   udp  --  0.0.0.0/0   0.0.0.0/0   udp dpt:27965 DSCP set 0x2e
DSCP   udp  --  0.0.0.0/0   0.0.0.0/0   udp dpt:8080 DSCP set 0x2e
DSCP   udp  --  0.0.0.0/0   0.0.0.0/0   udp dpt:27950 DSCP set 0x2e
DSCP   udp  --  0.0.0.0/0   0.0.0.0/0   udp dpt:27660 DSCP set 0x2e
DSCP   udp  --  0.0.0.0/0   0.0.0.0/0   udp dpt:27960 DSCP set 0x2e
DSCP   udp  --  0.0.0.0/0   0.0.0.0/0   udp dpt:27015 DSCP set 0x2e
DSCP   udp  --  0.0.0.0/0   0.0.0.0/0   udp dpt:27011 DSCP set 0x2e
DSCP   udp  --  0.0.0.0/0   0.0.0.0/0   udp dpt:27910 DSCP set 0x2e
DSCP   udp  --  0.0.0.0/0   0.0.0.0/0   udp dpt:27005 DSCP set 0x2e
DSCP   udp  --  0.0.0.0/0   0.0.0.0/0   udp dpts:1024:6000 DSCP set 0x2e
DSCP   udp  --  0.0.0.0/0   0.0.0.0/0   udp dpt:27010 DSCP set 0x2e
DSCP   udp  --  0.0.0.0/0   0.0.0.0/0   udp dpt:7000 DSCP set 0x2e
DSCP   udp  --  0.0.0.0/0   0.0.0.0/0   udp dpts:6112:6119 DSCP set 0x2e
DSCP   udp  --  0.0.0.0/0   0.0.0.0/0   udp dpts:2302:2400 DSCP set 0x2e
DSCP   udp  --  0.0.0.0/0   0.0.0.0/0   udp dpts:27000:27015 DSCP set 0x2e
DSCP   udp  --  0.0.0.0/0   0.0.0.0/0   udp dpt:6073 DSCP set 0x2e
DSCP   tcp  --  0.0.0.0/0   0.0.0.0/0   tcp dpts:7777:7783 DSCP set 0x2e
DSCP   tcp  --  0.0.0.0/0   0.0.0.0/0   tcp dpt:27900 DSCP set 0x2e
DSCP   tcp  --  0.0.0.0/0   0.0.0.0/0   tcp dpt:8080 DSCP set 0x2e
DSCP   tcp  --  0.0.0.0/0   0.0.0.0/0   tcp dpt:27660 DSCP set 0x2e
DSCP   tcp  --  0.0.0.0/0   0.0.0.0/0   tcp dpt:27910 DSCP set 0x2e
DSCP   tcp  --  0.0.0.0/0   0.0.0.0/0   tcp dpt:7002 DSCP set 0x2e
DSCP   tcp  --  0.0.0.0/0   0.0.0.0/0   tcp dpt:6003 DSCP set 0x2e
DSCP   tcp  --  0.0.0.0/0   0.0.0.0/0   tcp dpts:1024:6000 DSCP set 0x2e
DSCP   tcp  --  0.0.0.0/0   0.0.0.0/0   tcp dpt:7000 DSCP set 0x2e
DSCP   tcp  --  0.0.0.0/0   0.0.0.0/0   tcp dpts:6112:6119 DSCP set 0x2e
DSCP   tcp  --  0.0.0.0/0   0.0.0.0/0   tcp dpt:4000 DSCP set 0x2e
DSCP   tcp  --  0.0.0.0/0   0.0.0.0/0   tcp dpts:2302:2400 DSCP set 0x2e
DSCP   tcp  --  0.0.0.0/0   0.0.0.0/0   tcp dpt:6073 DSCP set 0x2e
DSCP   tcp  --  0.0.0.0/0   0.0.0.0/0   tcp dpts:27030:27039 DSCP set 0x2e
MARK   all  --  0.0.0.0/0   0.0.0.0/0   MARK set 0x100

To determine if your favorite game is being classified and marked you will need to determine the TCP or UDP ports it uses and then look in this list to see if they are already defined. If not you can easily add then in the GUI in the fields below the ďOptimize Gaming ApplicationsĒ checkbox. If a port range is required just add the range separated by a colon (i.e.: 4567:4580).

Now these markings will tell the ISPís how to handle your traffic, but what if your upload bandwidth is congested because of that pesky file sharing going on?
This is where you need some traffic control on your upstream connection. For that the router uses a mechanism called Ďtcí. It employs a number of different packet queuing strategies to determine which packets should be sent first, held (buffered) or dropped. To enable this feature of the router you need to enter the upload bandwidth value less 5 to 10% in field #2, ďUpstream BandwidthĒ. So if you have 300kbps (kilo bits per second) then use a value between 270 and 285 so you donít cause packets to be dropped or be excessively delayed because there isnít any available bandwidth left on the upstream link. Donít forget to Save the new Settings.

So now what is happening in the router?
By simply entering a value in this field the router GUI set up a number of packet queues. These queues are filled with packets based on the marking we listed above. Here is the queue structure in ASCII art.
Code:
               1:1       <--- root queue htb 750kbit upload
              / | \
             /  |  \
            /   |   \
          10:1 10:2 10:3  <--- priority queue with three bands, #1 is de-queued
          /     |     \        first, then #2 and #3 is not used.
         /      |      \
      100:     20:1     ? <--- 100: is the highest priority queue, anything   
     pr0       htb*                 in this queue gets sent out first.  All
     IPP5    / /|\ \                the "gaming" traffic goes in this queue
           /  / | \  \              as it is marked IP Precedence 5 (same as
         /   /  |  \   \            VoIP traffic)
       /    /   |   \    \
     /     /    |    \     \
   /      /     |     \      \
20:10  20:20  20:30  20:40  20:50 <- all other traffic falls to these queues.
 htb    htb    htb    htb    htb     Basically, a queue for 5 levels of service
 600k   75k    37k    30k     8k     each having a rate in kbps that the queue
  |      |      |      |      |      is limited to, if the uplink is maxed out.
 210:   220:   230:   240:   250:    Traffic is marked by IP Precedence levels
 pr1    pr2    pr3    pr4    pr5     IPP 0 through 4, with 20:50->250: being the
 IPP1   IPP2   IPP3   IPP4   IPP0    default catch all queue.

My personal Internet link has 800kbps of upstream bandwidth so I set the field in the GUI to 750. Six queues are created (100:, 210:, 220:, 230:, 240: and 250:). Each queue is filled with packets of a different marking. Like so:
100: manages all packets with DSCP mark EF or IP Precedence 5 (highest)
210: manages all packets with DSCP mark AF1x or IP Precedence 1 (high)
220: manages all packets with DSCP mark AF2x or IP Precedence 2
230: manages all packets with DSCP mark AF3x or IP Precedence 3 (medium)
240: manages all packets with DSCP mark AF4x or IP Precedence 4
250: manages all packets with no DSCP marking or IP Precedence 0 (low)

Each queue also has a rate limit that it can not exceed when there is congestion on the upstream link.
100: limited to 750 kbps
210: limited to 600 kbps
220: limited to 75 kbps
230: limited to 37 kbps
240: limited to 30 kbps
250: limited to 8 kbps

So if there were packets in every queue going at high rates each queue would be emptied at the set rate. Extra packets would get dropped, and in a TCP conversation this would cause the transfer rate to drop down so as not to exceed the rate causing further packet drops.

Queue 100: has the highest priority when the router is looking for packets to send. Any packet in this queue will be sent first, the other queues have to wait. Queue 250: is the default queue. All the P2P and un-marked traffic goes here. So when the link is congested this queue is limited to just 8kbps Wink
BTW: each queue can hold only 100 packets before it is full !
Here is what is set up in the router:
Code:
qdisc pfifo 250: limit 100p
qdisc pfifo 240: limit 100p
qdisc pfifo 230: limit 100p
qdisc pfifo 220: limit 100p
qdisc pfifo 210: limit 100p
qdisc htb 20: r2q 10 default 50 direct_packets_stat 0
qdisc pfifo 100: limit 100p
qdisc prio 10: bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
qdisc htb 1: r2q 10 default 0 direct_packets_stat 677

class htb 1:1 root leaf 10: prio 0 rate 750Kbit ceil
 Sent 2756994 bytes 30251 pkts (dropped 0, overlimits 0)
 rate 13bps
 lended: 30251 borrowed: 0 giants: 0
 tokens: 20609 ctokens: 20609

class prio 10:1 parent 10: leaf 100:
 qdisc pfifo 100: limit 100p
 Sent 1857266 bytes 21733 pkts (dropped 0, overlimits 0)
*****   all the UT2k4 traffic goes in here, cool!  *****

class prio 10:2 parent 10: leaf 20:
 qdisc htb 20: r2q 10 default 50 direct_packets_stat 0
 Sent 901451 bytes 8543 pkts (dropped 0, overlimits 0)

class htb 20:1 root rate 750Kbit ceil 750Kbit burst 2624b cburst 2624b
 Sent 900116 bytes 8525 pkts (dropped 0, overlimits 0)
 lended: 1895 borrowed: 0 giants: 0
 tokens: 20289 ctokens: 20289

class htb 20:10 parent 20:1 leaf 210: prio 1 rate 600Kbit ceil 750Kbit
 Sent 740 bytes 10 pkts (dropped 0, overlimits 0)
 lended: 10 borrowed: 0 giants: 0
 tokens: 60721 ctokens: 20417

class htb 20:20 parent 20:1 leaf 220: prio 2 rate 75Kbit ceil 750Kbit
 Sent 740 bytes 10 pkts (dropped 0, overlimits 0)
 lended: 10 borrowed: 0 giants: 0
 tokens: 485761 ctokens: 20417

class htb 20:30 parent 20:1 leaf 230: prio 3 rate 37Kbit ceil 750Kbit
 Sent 740 bytes 10 pkts (dropped 0, overlimits 0)
 lended: 10 borrowed: 0 giants: 0
 tokens: 971521 ctokens: 20417

class htb 20:40 parent 20:1 leaf 240: prio 4 rate 30Kbit ceil 750Kbit
 Sent 740 bytes 10 pkts (dropped 0, overlimits 0)
 lended: 10 borrowed: 0 giants: 0
 tokens: 1214401 ctokens: 20417

class htb 20:50 parent 20:1 leaf 250: prio 5 rate 8Kbit ceil 750Kbit
 Sent 897156 bytes 8485 pkts (dropped 0, overlimits 0)
 lended: 6590 borrowed: 1895 giants: 0
 tokens: 4844801 ctokens: 20289

So how do I know this all works?
To demonstrate the effectiveness of the classification, marking and queuing I did an upload of a HUGE file and then ran a ping test setting the TOS variable such that packets would pass through each of the queues. You can see in the section above, (Sent 740 bytes 10 pkts) in each queue statistic output. This was the result of the ping and confirms that the marking is working (I sent 10 packets marked for each queue).

What about congestion?
During that HUGE upload I did two pings, one for default (unmarked) traffic and one for high priority traffic, like our gaming traffic.
Here are the results for the unmarked ping test:
Code:
C:\>ping -n 10 xgs.co30.com
Pinging xgs.co30.com [69.12.89.136] with 32 bytes of data:
Reply from 69.12.89.136: bytes=32 time=193ms TTL=115
Reply from 69.12.89.136: bytes=32 time=191ms TTL=115
Reply from 69.12.89.136: bytes=32 time=189ms TTL=115
Reply from 69.12.89.136: bytes=32 time=191ms TTL=115
Reply from 69.12.89.136: bytes=32 time=205ms TTL=115
Reply from 69.12.89.136: bytes=32 time=201ms TTL=115
Reply from 69.12.89.136: bytes=32 time=185ms TTL=115
Reply from 69.12.89.136: bytes=32 time=185ms TTL=115
Reply from 69.12.89.136: bytes=32 time=193ms TTL=115
Reply from 69.12.89.136: bytes=32 time=194ms TTL=115
Ping statistics for 69.12.89.136:
    Packets: Sent = 10, Received = 10, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 185ms, Maximum = 205ms, Average = 192ms

As you can see the ping times fluctuated between 185 and 205 milli-seconds (no packets lost). This would be like ZoŽ(Co30) playing via his dialup connection, OUCH!

But I have a cable modem connection and with the ping packets marked as if they were gaming traffic the ping test reveals a different story:
Code:
C:\>ping -v 184 -n 10 xgs.co30.com
Pinging xgs.co30.com [69.12.89.136] with 32 bytes of data:
Reply from 69.12.89.136: bytes=32 time=49ms TTL=115
Reply from 69.12.89.136: bytes=32 time=48ms TTL=115
Reply from 69.12.89.136: bytes=32 time=48ms TTL=115
Reply from 69.12.89.136: bytes=32 time=49ms TTL=115
Reply from 69.12.89.136: bytes=32 time=50ms TTL=115
Reply from 69.12.89.136: bytes=32 time=50ms TTL=115
Reply from 69.12.89.136: bytes=32 time=61ms TTL=115
Reply from 69.12.89.136: bytes=32 time=62ms TTL=115
Reply from 69.12.89.136: bytes=32 time=45ms TTL=115
Reply from 69.12.89.136: bytes=32 time=57ms TTL=115
Ping statistics for 69.12.89.136:
    Packets: Sent = 10, Received = 10, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 45ms, Maximum = 62ms, Average = 51ms

Here you can see while my HUGE upload was going on my average ping time was 51msecs. Now this I can live with!

And you can see no packet loss on that upload either.
Code:
class htb 20:50 parent 20:1 leaf 250: prio 5 rate 8Kbit ceil 750Kbit
 Sent 15304683 bytes 26588 pkts (dropped 0, overlimits 0)
 rate 92133bps 115pps backlog 19p     <--- rate is in Bytes/sec
 lended: 6974 borrowed: 19595 giants: 0
 tokens: -4861181 ctokens: -13976

Clap Thumb

Here are some references to information and tools regarding QoS and the Linksys router.
Linksys GPL code:
http://tinyurl.com/8b7x8

QoS FAQ:
http://www.opalsoft.net/qos/DS.htm

Hacking the Linksys router:
http://www.batbox.org/wrt54g-linux.html
http://openwrt.org/
http://seattlewireless.net/index.cgi/LinksysWrt54g

Microsoft TOS KB article:
http://support.microsoft.com/default.aspx?scid=kb;en-us;248611


Last edited by Sarge(Co30) on Sat Mar 11, 2006 8:42 am GMT; edited 5 times in total
Back to top
Zoe
is a Veteran Poster


Joined: 10 Nov 2004
Posts: 363
Location: Maryland

PostPosted: Sat Oct 29, 2005 5:42 pm GMT    Post subject: Reply with quote

Great post Sarge. Lots of good info there. Its not useful to me at the moment, but hopefully it will be in the not too distant future Thumb
Back to top
OLDMAN(Co30)
has Posting Diarrhea


Joined: 10 May 2003
Posts: 573
Location: USA

PostPosted: Wed Nov 16, 2005 1:18 pm GMT    Post subject: Reply with quote

Well thanks to Sarge and TeamSpeak he got me up and running also, glad we have you Sarge the tech stuff sometimes drives me nuts, and I could just see me hosing up my router or even worse no connection. Thumb
Back to top
Sarge(Co30)
is a Veteran Poster


Joined: 17 Aug 2003
Posts: 155
Location: Capital City ON Canada eh!

PostPosted: Thu Nov 17, 2005 7:31 pm GMT    Post subject: Reply with quote

Glad I could help Thumb

Now, you own me a few frags Wink
_________________
Back to top
Atvar(Co30)
is a Veteran Poster


Joined: 23 Jun 2003
Posts: 130
Location: Ottawa, Canada

PostPosted: Thu Nov 17, 2005 10:22 pm GMT    Post subject: Reply with quote

I actually have the same router as you Sarge, but it looks like my firmware version is several upgrades behind. All I have under "applications and gaming" is Port Forwarding and DMZ. I will upgrade when I am not working all the dang time.

Atvar
_________________
"2+2=5" 1984 by George Orwell
Back to top
{[WWF]}Dr4g
is a Newbie


Joined: 24 May 2007
Posts: 3

PostPosted: Fri May 25, 2007 9:26 am GMT    Post subject: Reply with quote

I have the newest Linksys Router out.

Linksys WRT300N Wireless-N Router

http://www.s2.com.br/s2arquivos/450/Imagens/2867Image.jpg

It rocks your socks!

I recommend it highly. Smilie
Back to top
Display posts from previous:   
Post new topic   Reply to topic    forums.co30.com Forum Index -> Tech Talk & Hardware Discussion All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group