This tutorial is for openWrt routers only and assumes you’ve completed https://www.stoplagging.com/openwrt-method-fq_codel-cake/ with cake set up.
Why do we need to do this? Normally cake is fine by itself and ensures fair usage of your shared Internet at home. This great for gamers, video conferences, and VOIP call in general.
However, as a twitch streamer your situation is unique. If you have small upload bandwidth such as 5Mbps up, and stream at a bitrate of 3Mbps or higher you need to configure cake to be unfair and give more upload to your twitch streaming packets. The download direction can remain fair and doesn’t need to be configured.
Overall there are 2 things that need to be done. First is to make room in the Priority Bucket by making it higher than the default. The second is to mark your twitch packets with DSCP so that it goes into the Priority Bucket.
If you’re not streaming and are just looking to mark DSCP packets for your games so that it ends up in a higher priority bucket please skip section 1 and jump to section 2.
Credits: to moeller0 for helping me find this solution.
1. OpenWrt Section
First SSH into your router. If you don’t know how to SSH don’t worry just download PuTTY and install it. After that, launch PuTTY, and type in your router’s IP address under “Host Name (or IP Address)” and click on open. After that login as your username and password. That’s pretty much SSHing to your router!
Install nano text editor
Do this if you’re not familiar with vi or linux shell in general.
opkg update
opkg install nano
Make a copy of simple.qos to twitch.qos and edit it
cd /usr/lib/sqm
ls
cp simple.qos twitch.qos
nano twitch.qos
nano twitch.qos will open the nano text editor and allow you to edit the twitch.qos file.
What you need to do is modify the following from PRIO_RATE=`expr $CEIL / 3`
to PRIO_RATE=3500
under the egress() code block. Egress means upload traffic.
It doesn’t have to be 3500 but don’t put in your max bandwidth because you will starve the other buckets. My max bandwidth is 5000, I stream at 3000 so I wanted to leave an extra 500 headroom for other computers and gaming traffic in the priority bucket by setting it to 3500. The remaining 1500 will be for non-priority buckets.
If you’re unfamiliar with nano text editor you can search for PRIO_RATE= with Ctrl+W. Just type what you’re searching for and press Enter to jump to it. Do make sure you’re in the egress block as shown in the photo above.
Finally after modifying this you want to Save & Exit. To do this do Ctrl + O and press Enter.
You can now exit PuTTY.
Login to your router’s webpage in the browser. Change the queue setup script from whatever you were using to twitch.qos. Then press Save & Exit.
2. Marking Twitch Stream Packets in Windows PowerShell
Search for powershell in Windows 10 and run as administrator
In my example I want to mark DSCP packets going out of OBS… OBS is called “obs64.exe” yours may be different, like “valorant.exe” if you’re trying to mark a game. To find out your game/app’s name you can go to Task Manager while the game/app is running and click on the Details tab to see.
Type in the following below in Powershell to mark packets coming out of obs64.exe as DSCP.
New-NetQosPolicy -Name "twitch" -AppPathNameMatchCondition "obs64.exe" -PolicyStore ActiveStore -NetworkProfile All -DSCPAction 46
Use Get-NetQosPolicy -Store ActiveStore
to list existing policies and Remove-NetQosPolicy -Name "twitch" -Store ActiveStore
to remove policy if you do not need them anymore.
3. Optional: How to check if streaming packets are marked with Wireshark
This step is optional and helps prove that your twitch packets are being marked properly.
Install Wireshark. https://www.wireshark.org/download.html
Run Wireshark as administrator.
Select your Ethernet interface that you use to connect to the Internet.
To filter packets marked by DSCP type in “ip.dsfield.dscp==46” on the filter.
Notes: 46 Means Expediated Forwarding as described in RFC 2475.
To filter packets based on the RTMP protocol (which twitch uses) and the DSCP mark type in the following for the filter. 1
ip.dsfield.dscp==46 && rtmpt
To add a DSCP Column to wireguard, Right click on a column. Click on “Column Preferences…”, press the + Sign. Title = DSCP. Type = Custom. Fields = “ip.dsfield.dscp”. Then resize columns until you see the DSCP column.