Layered Bandwidth Management for Internet Cafe and Home Networks
The state of bandwidth utilization of internet cafe in the Philippines is from poor to nonexistent. This is either cafe owners have no knowledge on how to properly utilize their bandwidth or they are simply unwilling to configure them despite the limited bandwidth provided by their Internet Service Provider.
I have decided to make a tutorial or you can also consider it as a proposal on how to utilize your bandwidth using the QoS feature of Tomato Firmware.
THE DEVICE AND SOFTWARE
Below are the information that I am using for this tutorial / proposal:
Router Device: Linksys E2500
Firmware: Tomato by shibby build 123 ( http://tomato.groov.pl/ )
Supported Router List: http://tomato.groov.pl/?page_id=69
Theoretical Bandwidth Upload: 924 kbps
Theoretical Bandwidth Download: 4215 kbps
The Theoretical Values above are from my PLDT Modem.
Aside from linksys, you can use other brands as well like Asus, D-link, Buffalo, Netgear and Tenda. Please do look at the tomato by shibby site for other models that can use this firmware. The cheapest that you can use is a Tenda N6 or Tenda N60. Download link is here http://tomato.groov.pl/download/K26RT-N/build5x-124-EN/Tenda/
Below is a screenshot of the system information for tomato firmware that I am using.
THE INITIAL SETTING
The first thing that we need to do is to set the values for our TCP and UDP Timeout. This can be found in:
Advanced -> Conntrack / Netfilter
You can leave the default values but I have done some testing and the values that is being used in the screenshot below are far more effective than the default.
Credit to http://www.linksysinfo.org/index.php?threads/using-qos-tutorial-and-discussion.28349/ for these values.
If you have VOIP, the recommended UDP Settings are:
This is to prevent drop calls.
THE BANDWIDTH SETTINGS
The next thing to do is to activate the QoS feature in
QoS -> Basic Settings
By default, other features are already enabled once you have activated the QoS.
Also consider changing your Default Class to Crawl so as to automatically categorize those that are not included in your QoS Rules. Example of which are torrents.
Just go to the QoS Class Names first to label them before tinkering with the bandwidth setting in the Incoming and Outgoing Rates. Just click on "(Toggle Visibility)" to reveal class priorities. You can label them whatever you like as long as it is does not have contain a space and a maximum of 10 characters. However, the most important thing to remember is how they are prioritized.
If your router is a door, then Priority Class 1 are the first ones to go in or out. these are followed by 2 up to 10. Any port/s classified in this class and the succeeding classes will be prioritized accordingly.
In my setup, I labeled my Priority Class 1 as "Service". I just intend to put the DNS service in here. Other network services that can be considered are Time (NTP), DHCP and other services that your network is using.
Then input your Theoretical Upload Speed under the Outbound Rates / Limits. In this example, 924 kbits/s is so small that I did not bother limiting the bandwidth for each category. I just set 80% to all categories.
The first field is Guaranteed Speed, starts with 1%, the second field is the Maximum Bandwidth up to 100%.
There is a proper way to determine your Upload and Download Speed as featured in a lot of tutorials in the internet. That is to do 5 sets of test in Speedtest.net and get the average. Then use about 85% of the result for your Upload and Download values.
However for simplicity, I choose to use my theoretical bandwidth and just use 80% for the upload.
The next section is to set the maximum Download Speed or the Inbound Rates / Limit. Unlike the outbound rates, I have set appropriate maximum bandwidth in this section to control the limits of each class or category.
THE QoS RULES
Actual QoS rules are set in:
QoS -> Classification
By default, there are already predefined rules in this section. However, to avoid confusion, I chose to delete them and make my own.
Below are some of the rules that I made and a simple explanation on why they are made.
Rule No. 1 is about DNS with the Class "Service" or the highest priority, as I consider DNS the most important in playing games as well as browsing the internet.
Rule No. 2 is for the toredo port and was the only default rule that I chose to keep.
Rule No. 3 are Wifi devices for personal use. These IP Addresses are automatically assigned by the router. It also has the lowest priority and a maximum bandwidth of 422 kbit/s
Rules 4, 5 and 6 will be discussed in details below.
The rest are rules for Gaming Ports that has the second highest priority in the QoS Class and a maximum bandwidth of 50%. Although games do not usually eat a lot of bandwidth but they are very sensitive to latency thus they are needed to be prioritized first in order to avoid lag. Higher class Qos can steal bandwidth from the lower class. However, the time it takes during the transition would surely affect the latency of the games thus it is much efficient to limit the bandwidth of other classes rather than making them all 80% like in the Outbound Rates.
THE BANDWIDTH CONTROL
The reason I wanted to explain rules 4, 5 and 6 separately is because they have a special condition that if met, becomes the controlling factor in this setup.
So we all know that any port classified as "Game" will have Priority 2. But what about those that are classified as WWW (Priority 4), Media (Priority 5) and FileXFer(Priority 7). Where do they fit in?
Rule 4 in WWW and these are the conditions for the rule. The source (Src IP) must come from computers in my Gaming PC. It must be from or to ports 80 (HTTP), 443 (HTTPS) and 8777 (ports used by most streaming sites nowadays). The transfer rate must be from 0 to 1024 kbit/s.
This simply means that as long as the transfer rate is between 0 to 1024 kbit/s from the ports above, it will remain in the WWW (Priority 4) Category and will prioritized 4th in line to others. No matter how many connections are there, the WWW Class will have a maximum bandwidth of 843 kbit/s as set in the Inbound Rates / Limit Section.
What happen when the transfer rate from ports 80, 443 and 8777 exceeds 1024 kbit/s?
This is what rule 5 is about. Rule 5 is Media Class and has a Priority 5 with a maximum bandwidth of 1265 kbit/s.
Conditions for the rules for the most part are the same with Rule No. 4 and the only difference is in the Transfer rate where it became 1024 - 30720 kbit/s (1 Mbit/s to 30 Mbit/s).
It simply means that once the transfer rate from ports 80, 443 and 8777 exceeds 1 Mbit/s, it will be removed from the WWW Class and will be transferred to the Media Class with its own bandwidth rule as defined in the Inbound Rates / Limit.
What happen when the transfer rate from ports 80, 443 and 8777 exceeds 30720 kbit/s?
It will simply be transferred to a lower Class. In this case FileXFer Class or Priority 7.
Conditions of Rule6 are the same to 4 and 5 except the transfer rate. This is from 30720 kbit/s and above. In the Transferred Entry, I just put 30720 in the first field and left the second field blank as this will automatically mean that it will have no limit. This becoming 30720+ kbit/s.
It simply means that once the transfer rate from ports 80, 443 and 8777 exceeds 30 Mbit/s, it will be removed from the Media Class and will be transferred to the FileXFer Class with its own bandwidth rule as defined in the Inbound Rates / Limit.
Rules 7 and beyond are gaming rules and messengers. Anything classified as Game will always be Priority 2 no matter what rule number they are in the QoS Classification Section.
Any ports that does not have matching criteria on the rules in this section will automatically classified as Crawl (Priority 10) as defined in QoS -> Basic Settings -> Default Class Field. This will include torrent ports.
If you are not using Personal Wifi, Then just set you Crawl bandwidth to 1% in Inbound Rate.
Below is a graph of actual usage. Look at the Bandwidth Distribution (Inbound). This graph is during the first few minutes of me playing a game and streaming movies. The Game will always have a low bandwidth as most games do and a bandwidth in WWW and Media.
After a few more minutes, The bandwidth from media transferred to FileXFer as it simply means that my streaming has already reached the 30 Mbit/s transfer. My games are still lag free.
If for example you tend to max your Media Class often, you can always increase its bandwidth but not to the point that will will affect your game. What was presented here are just settings that works for me. You can adjust these values on what will work for you.
Comments and questions are welcome. Please feel free to drop one and I will answer them when I have the time.