Monday, July 30, 2012

Improving League of Legends (US) Latency using 3rd Party Router Firmwares




Introduction
Ideally, online gamers should have unlimited bandwidth. Or at least 10Mbps and 1Mbps downstream and upstream bandwidth respectively. Unfortunately, reality is harsh and lots of these gamers often have to endure playing using restricted bandwidth. Even worse, we have to share these precious resources with other people whom we often have no control over. In order to reach a compromise (fairness) to allow us to game comfortably and others to use the internet as they wish, Quality of Service (or simply QoS) is an essential, if not a must, for us gamers.

Let me start by explaining my current situation. Having studied in the UK, having plenty of bandwidth (30Mbps down, 3Mbps up) have definitely spoiled me and having had to return to my home country (Brunei) where the service we subscribed to only offered 1Mbps down and 0.3Mbps up definitely makes me miss UK a little bit. I don’t generally care about throughput, I rarely stream and download big files and when I do, I have no problem waiting for days. It is the responsiveness that I crave.


Now the problem; I share this connection with 10 other people in the house. Yes, that’s 10. About 9KBps per person if everyone is using the network fairly. Laughable, I know. But I can live with that as long as I can surf websites without timeouts and as long as I can play League of Legends comfortably.  The thing is most of the times, my sisters and brothers left their uTorrent clients running on their computers while they work and as we all know just one of these is enough to stress a typical consumer router. Imagine 3 of them running concurrently; no wonder they always had to restart the router every day in my absence. Mind you, this only started when I started doing my degree so I was not there when this started.

Now that I am home, I can finally experience just how frustrating it is to use the internet. Google searches most of the time takes >10s where it should be <1s. Forget streaming Youtube, the buffering seems to take forever and that is if the router does not restart. League of Legends you say? LOL. Don’t even bother unless you can play under ~3000-5000ms latency. (I thought the maximum LoL  client can display is 999ms but if you press ctrl+f in-game you can see way more than this. Wayyyyy more J )

3rd Party Firmware
Studying computer science myself, I looked into why the router restarts itself so frequently. Few minutes of googling suggests that the router is running out of the available memory and/or that it has reached/exceeded the connections limit. At this stage, I was clueless about router but I do routinely checks the administration page of the router and never have I seen any setting to adjust the connection limits. Frustrating.

DD-WRT

More googling and then I found my first third party firmware, DD-WRT. I read lots of the reviews on the net about it and most people seems to be content with DD-WRT. General sentiment is that it is bloated but stable and support lots of different hardware configurations. I bought a new router (Asus RT-N10Plus) making sure that it is compatible with DD-WRT.

Connections Limit
Installing it was a breeze, it was just a matter of googling and following the instructions. Once loaded, I increased the connections limit to 8192 up from the default 4096. Under the administration page, we can also see just how many connections currently connected hosts are making/using. To my surprise, my brother’s PC spawned ~4000 UDP connections just after the router successfully booted up. P2P at its best.

So, by now we no longer have a router that randomly reboots but the surfing experience is still dreadful although it was a tiny bit more bearable. Websites still takes too long to load but they do finish loading all elements. Exploring the administration site introduced me to QoS.

QoS
Put simply, QoS is a way of prioritizing packets. Different firmware handles this differently so be sure to read into their documentation. With DD-WRT you can assign packets to these classes; Exempt, Premium, Express, Standard and Bulk. These packets can be classified using several ways for example by using the ports or the source or destination IPs.

So, I turned the QoS on and carefully adjusted the settings. DNS and packets of less than <1MB is classified as Premium, >1MB is Standard, LoL packets as Express and bitTorrent as Bulk. This MASSIVELY improved surfing experience but it does not really help LoL experience. Somehow, when the link is saturated the router simply started dropping packets regardless of which class it belongs to. Having huge packet loss in LoL is VERY unacceptable. Ping is lowered down to 500ms, improved but still terrible.
Unfortunately, heavy load (3 torrentors/tormentors?) still makes the router crawl. It takes a long time to access the administration page and upon checking the stats it seems that it is running out of memory (this particular router have 32MB of RAM) and the CPU usage is pretty high.

OpenWRT

After a few day of tinkering DD-WRT, it is clear that I cannot improve the gaming experience any further . I then turned to OpenWRT which is an open-source and minimal firmware alternative to DD-WRT. Under it, you can choose what you want to install and this way you can minimize any unnecessary use of the precious router’s RAM and ROM. I then installed QOS-scripts and proceeded to set up the QoS as before.
I found out that, and this may be due to my settings or my hardware or the combination of them both, the QoS under OpenWRT is much more responsive than DD-WRT. LoL experience improved further but still it was dropping packets although the latency is now down to ~400ms. Still unplayable although the router stays responsive under heavy load. Fortunately, further googling introduced me to my favourite firmware; Gargoyle!

Gargoyle

Gargoyle allows home users to play around with features usually only available on uber expensive enterprise routers; quota management. With this feature, you can decide just how much data can one client use and then either to stop their access to the internet or just throttle their bandwidth. And from experience I can tell you that it works!

With gargoyle, I can set limits to just how much bandwidth can a class in the QoS classification use. The QoS feature in Gargoyle is rather very exhaustive and I do not think I would do it any justice trying to explain it in this post. Head over to http://www.gargoyle-router.com to learn more. This is my current QoS implementation in Gargoyle:

Upload



Download



With these settings, I managed to get 210ms latency in LoL! A massive improvement indeed. Other users also gave positive responses as they noted that the router no longer restarts itself and that even while torrenting, browsing experience is generally still smooth.

However, that is not the end of my story. While Gargoyle can limit how much bandwidth a user can use, it does not allow us to limit the number of connections a client can make hence even one heavy bitTorrent user can flood the router making it unavailable for few seconds till it stabilize again. To Google we search again. BTW, as the old ASUS router is not supported by Gargoyle I had to purchase a new router Buffalo WZR-HP-G300NH which is supported by Gargoyle.

Tomato

After lots of googling, I found another 3rd Party firmware; Tomato. However, I did not use the default distribution and settled on one of the available mods called TomatoRAF. At this point, I decided that I need BOTH the bandwidth management and connection limit features so I will need both Gargoyle and TomatoRAf. So, I bought another router to run Gargoyle with plenty of RAM to handle the traffic shaping. In the end, I settled on Buffalo wzr-hp-g300nh to run Gargoyle and my old router Buffalo WHR-HP-G54 to run TomatoRAF and act as the wireless access point.

Under TomatoRAF, there is an option called IP/MAC BW Limiter where you can limit the bandwidth as well as the number of connections each user can make at any given time.  With this set, the flooding problem is solved and as an added plus, the Tomato kernel is very stable requiring very few reboots.

Limiting TCP connections per user.

Limiting UDP connections per user.

Conclusion
That is the end of LoL dilemma and what an interesting journey it was. I hope that helps somebody in their search to better online gaming experience. Although I have to buy two routers due to my rather complicated problem, many of you out there most probably only need one to satisfy your needs. The first step I recommend you guys to do is buy a router that is known to be supported by Gargoyle AND check the forum if there is any reported issues with the router under Gargoyle. Any issues like wireless dropping and random wireless disconnections, it is in your best interest to find other compatible router. With all that said, the choice is for you to make and if you decide to risk it, go with it and experiment with your setup. In my opinion, that is half of the fun with all these firmware anyway.

And just to end this post, here is my happy ending.



6 comments:

  1. Gargoyle indeed the best firmware!

    ReplyDelete
  2. What did you enter for the DD-WRT service name of LoL? I'm setting up the QoS in DD-WRT because it is pretty simple but I need the service name of LoL. I've googled for it but can't find it anywhere, so I just want to know what u entered for its service name.

    ReplyDelete
    Replies
    1. Service name won't matter as long as you correctly set up the ports/IPs so just put anything you want.

      Delete
  3. Hi, im from brunei too. Also a LOL player. Extremely frustrated with the connection we have here. Any way i could talk to you further to help me out with our e-slow connection here. Thanks

    ReplyDelete
  4. Thanks for the extremely useful post! I too am a Computer Science student in Oman trying to not get League of Legends to lag via downloads and torrents! dd-wrt is what I decided to get but it didn't do the latency reduction. So I'm going to see if I can get gargoyle and solve this once and for all :)

    ReplyDelete
  5. Great work and very nice content...
    this post is very interesting and knowledgeable for me...
    thanks for sharing this post...
    More info:- Asus Technical Support

    ReplyDelete