Auto turn “On“ SQM when gaming is detected!


Is there a way to make SQM automatically turn “ ON “when gaming or specific IP or Port is online and turn off when it’s offline/don’t detect gaming ?

No, just leave it on. There's virtually no downside.


The only way I could imagine this being useful is if you have a slow router and you want to throttle your connection heavily during gaming and leave it unthrottled when you aren't gaming. But an RPi4 for about $120 will do SQM on a full gigabit. So the best bet is just upgrade your router because the time it takes to develop the software is worth much more than $120

1 Like

The down side comes when you have 4G/5G connection.

For example if you have almost all the time 500mbps down and 100mbps up . For SQM you need to put it much lower than that ! Like 150 down and 50 up or even lower just in case the speeds drop since you know 4G/5G their speed are not consistent.

So why Auto turn on when gaming ?

Because if this feature is available the speed will goes automatically to 500~ down and 100~up when no one is gaming . And goes down only when someone need that ( someone is gaming )

Hope it’s clear .

Is their a way to pay a trusted developer for that ?

It would be much more fun to learn to do this yourself rather than paying someone else :slight_smile:

Is the gaming traffic easily identifiable? For example, does it always use a specific port? If so, you could have a cron job that checks the conntrack table and enables SQM if a matching connection is present, and disables it if not.

My cable connection is pretty variable too, so I have the same problem with SQM either limiting the bandwidth too much, or not working properly if the real bandwidth is lower than the the config.

@dlakelan wrote a script to auto-adjust SQM bandwidth a while ago, but it didn't quite do everything I wanted so I wrote my own. However, mine is an absolute beast and not really fit for public consumption (it's written in perl for one thing :rofl:)


Not all people have the time to “learn “ something , I would be happy to pay someone to do it , the other person will also be “ payed “ the amount me and he agreed on , so I’m sure he will be happy to do it .

I don’t know how to write script. I’m just a basic user who use the Ui “ Luci “ since I can’t deal very well with commands ext.... ( the point is learning all of these will take so much time that I really don’t have. Also make in mind that these issues might be very hard to fix for someone who has just learn script ext.. )

On the other hand there is someone who already know them all, but maybe he will not work on ( Auto SQM bandwidth , Auto enable SQM ) because he don’t have a reason to do it since he is not “ payed “ to do that or is just not interested on it because he is not facing our issues we have .

So hopefully being Payed might let them being interested on working and fixing our issues.

Hope my point is clear.

Is the gaming traffic easily identifiable? For example, does it always use a specific port?

If you can answer this question you might find people here willing to help for nothing.


How to know that ?

Also would it be much easier if we can just make SQM work if certain IP address or LAN port is online ?

Netduma gaming routers have the ability to turn On QoS just when “ Gaming traffic “ is detected . I don’t know how they do it exactly but I think that may help ...

Also would it be much easier if we can just make SQM work if certain IP address or LAN port is online ?

Yes, that would be very easy.

Netduma gaming routers have the ability to turn On QoS just when “ Gaming traffic “ is detected . I don’t know how they do it exactly

A quick google tells me they use a combination of packet inspection for traffic from PCs, and prioritising all UDP traffic from devices classified as consoles.

1 Like

No, there is not, but you can easily manually toggle this either in OpenWrt's luci GUI, or via the command lime with SSH. I am sure you could hack up some heuristic that would work with your rig, and you wud also learn a lot in the process ;).
Toggling SQM explicitly really is easy, and automating it via script is also not rocket science, the biggest challenge in your idea I see is to come up with a robust heuristic that triggers fast and reliable enough for your gaming demands (so few false negative detections) and yet does not trigger too often when no gaming is on-going (so few false positive detections).

Actively toggling SQM manually on game start and end removes all of those ambiguities completely, no heuristic required.

That is all you need to know for manually toggling SQM, so it seems you are set.

1 Like

As long as you know the port the game use, creating something that autoenables sqm shouldn't be that hard. But again problem is find a reliable way to understand automagically when you are gaming and when you are not.

Think the easiest way to do this would be create a script and provide the ports manually with an uci config.


Also would it be much easier if we can just make SQM work if certain IP address or LAN port is online ?

This is the sort of script I'd use in this scenario, run as a cron job every minute:


# List of gaming device IP addresses / hostnames

# Logger command
LOGGER="logger -p -t Auto-SQM"

# Check whether or not the SQM service is currently running
if ( ls /tmp/run/sqm/*.state 1>/dev/null 2>&1 )

# Check whether any of the devices in the list are online
        if ( ping -c 1 -W 3 $IP >/dev/null 2>&1 )

if [[ $GAMING_DEVICE_ONLINE -eq 1 && $SQM_RUNNING -eq 0 ]]
        $LOGGER "Gaming device detected - starting SQM"
        service sqm start

if [[ $GAMING_DEVICE_ONLINE -eq 0 && $SQM_RUNNING -eq 1 ]]
        $LOGGER "No gaming devices detected - stopping SQM"
        service sqm stop

This script checks whether the gaming device is pingable, which is not at all the same thing as if it's actively gaming. Any device that's turned on whether you're using it or not will result in SQM being enabled.

To really know whether it's active we should detect some amount of most likely UDP traffic from that device. One way is to use a rule to detect the traffic of interest and print a LOG message. then the script runs and if it detects a log message in the logread, it enables SQM for an hour or something basically like that.

1 Like

Agree 100%. I was implementing the specific (limited) approach that I quoted. It would actually work pretty well if the gaming devices in question were consoles.

Detecting gaming traffic by ports, protocols and destination IPs is a lot harder to get right. You basically need a different rule for every game. I do a fair bit of this myself for DSCP tagging but it's pretty tedious and never completely reliable.

If you have an ipset of gaming devices you can look for UDP connections matching more than 20 pps of UDP on any port you can probably do well. for example if you have all your gaming ips in an ipset something like this might work (needs trial/debugging)

iptables -A FORWARD -p udp -m set --match-set gamingmachines src,dst -m connbytes --connbytes 20: --connbytes-dir both --connbytes-mode packets -m limit --limit 10/hour --limit-burst 10 -j LOG --log-prefix "GAME TRAFFIC DETECTED"

is very good idea like this you keep the speed bandwith when you not play it's right ?

This script can be run at all times it should handle your regular traffic well.

Sorry I thought this was my script thread, but I see it's not so I don't understand the question.

haha no worries dlakelan the question was that the sqm only triggers when playing a game and not constantly and I find that a good idea which avoids having a reduced bandwidth all the time :slight_smile:

In general if you have consistent speeds then you should get a router fast enough to run SQM at full speed and you will get a good experience. But if you have variable speed then you may need to cut the speed so low that much of the time you can't use very much of your speed. In that case then yes running a system that detects gaming is a good alternative plan

1 Like