How to reserve bandwidth for Stadia in your home network - MacGyver style [UPDATE]

11 January 2022

Update 2022-01-11

I've made a few changes.

I'm not using any streaming apps on my Chromecast with Google TV anymore, but instead opted to use a Chromecast Ultra and a hardware Steam Link for my gaming needs. Doing this gives me more flexibility when it comes to optimize the network for each device.
There's also a nice bonus: Turning on the SN30 Pro+ or the Stadia Controller will now automatically wake up the Steam Link or the CCU with Stadia and turn on the TV. Very neat!

I've updated the text below to reflect the changes.


Why, tho?

Stadia has been my main gaming platform for a few months now and I've clocked about 300 hours without any issues whatsoever.

Me and my wife usually play games together, but not every game interests her in the same way, which means she sometimes does her own surfing and streaming while I play and, depending on what she's doing, that can cause my stream to hiccup every once in a while. Not really a big deal, but it can be annoying, depending on what's going on.

I'm using a Fritz!Box 7530 and I've set up different SSIDs for 2.4 GHz and 5 GHz WiFi.
All our mobile devices are using the 2.4 GHz network by default and because of the different SSIDs they can't clog up the 5 GHz WiFi even if they wanted to. They wouldn't benefit much from 5 GHz WiFi anyway and in their case the longer range of 2.4 GHz is highly appreciated.

The devices I use for gaming, such as the Chromecast Ultra (Stadia) and the hardware Steam Link (Desktop PC) are plugged in via ethernet. The Stadia Controller and my Desktop PC (which is upstairs) are connected via the 5GHz WiFi.

I've explored several ideas to limit the bandwidth on the 2.4 GHz network, but the basic QoS settings of my router simply do not offer such a feature. The higher tiered 7590 has an option to "reserve bandwidth for your home network" when setting up guest WiFi, but I don't have one of those and even if I did there would be no way to automate it. Also the guest WiFi always uses 2.4 GHz and 5 GHz with no way of splitting them. Maybe not a big deal if you don't use WiFi for cloud gaming, but something to keep in mind.

OpenWrt Logo
OpenWrt Logo

The solution: OpenWrt

Then I remembered reading about custom OS' for routers called OpenWrt (or the alternative dd-wrt) and, lo and behold, there is an official build for an old and unused TP-Link WiFi Repeater I had lying around. The bad news is, that the device is extremely low spec and outdated and while you can flash and boot the latest version, all the settings will be wiped upon reboot, since there is no space left to actually store them. A fate which a lot of similar devices share. One possible workaround would be to look for an older and working version or buy a more recent and better supported device, but I wanted the best I could get with the device I had and I was prepared to let go of a graphical user interface if need be, since I'm quite comfortable with CLIs.

How I set it up

I will now explain how I set up my device, but this is by no means a comprehensive tutorial. My solution is very specific to how my home network is set up and how all my devices connect to it. With this blog post I want to give you a small headstart on tackling your own problem. This is easily adaptable and can be used for more than to Stadia or other cloud gaming services.
If you're lucky you may find a fully featured and ready to flash build of OpenWrt for your specific router or repeater. In that case setting it up will probably be as easy as reading a few simple guides and using the graphical user interface of OpenWrt through a web browser, just like you would setup and configure an OEM router.
If you're unlucky, like me, you will have to have basic knowledge of using a UNIX command line and know how to solve problems by doing extensive research. Maybe you will even have to compile or build the OS yourself.
Or just throw money at the problem. That always works, too.

It took me a few hours of research and trial and error, but I finally created my own build where I had every module I needed while still having enough space left to store settings and scripts. It's not quite bleeding edge, but it's at least as up to date as the latest official release for that device. Compiling from the latest source did work, but even with all the changes I made, the filesize was way to big. I didn't bother with compilation much longer, as it takes quite some time and would add up quickly. I instead settled for the imagebuilder, where I could create different builds in a matter of seconds. With a bit more patience, knowledge and skill, maybe even the latest version from source would have been possible, but for me it wasn't worth the extra time and effort.

My build doesn't offer a GUI anymore, nor does it have IPv6 support, ppp, or a firewall, all things which aren't needed in my case, since the router takes care of them already. I also dropped USB support (it doesn't even have a port), added support for WPA encryption and, most importantly, an SQM (smart queue management) module, which I could abuse to get what I set out to achieve.

I then set it up as a "dumb access point" and used the same SSID and password of my 2.4 GHz network for a seamless transition. On the router I disabled the 2.4 GHz network, but left the 5 GHz one enabled. Now every mobile device will automatically connect to the repeater instead of the router, which means the repeater has full control over their bandwith.

After getting basic access point functionality I went on to configure the SQM module. It was really straightforward. I just had to change a few values in a single config file and restart the service.

SQM config
SQM config

It worked brilliantly! I configured it to limit the bandwidth to 16 Mbit/s down and 4 Mbit/s up. The rest would be reserved for 5 GHz WiFi and other ethernet ports of my router.
But we're not quite there, yet. I didn't want to manually toggle it on and off, nor did I want to leave it on all the time, so I needed something to do that for me.
First I had to go into the router settings and set up fixed IPs for both of my Stadia Controllers. Then I wrote a small script and utilized the power of cron to run it every minute.

shell script
shell script

In the first two lines I ping each controller. They will respond when they're online and their respective variable will be filled with either a 1 (true) or a 0 (false).
If either one is online, then each of the five LEDs which used to indicate the WiFi strength (which aren't used anymore, since this is now a tethered access point and no wireless repeater) will be turned on and the SQM service will be started. If both are offline then the LEDs and the SQM service will be turned off.
This works perfectly and gives me a nice visual indicator as well. I'm toying with the idea of using the full LED ring while in Stadia mode with some kind of Stadia inspired animation, but I'm not sure yet.

The result

Now every time I turn on my Stadia controller the TV will turn on automatically as well and every mobile device will be throttled. When I turn off Stadia everything will turn back to normal.
My PC is still connected via 5 GHz WiFi (using another, more modern TP-Link repeater with exceptionally good WiFi strength) because it's upstairs and too far away from the router, but I've had no issues so far. Streaming to the Steam Link works perfectly and since everything is in house the bandwidth is high enough by default to not require throttling of other devices.