Using ChatGPT to make a QOS script for PS5, Opinions?

Hey everyone nobody Mikrotik user here. I have been using Chat GPT to learn how to configure Mikrotik routers. Its great because I can ask it endless questions without it getting frustrated and laughing at me XD anyway after a few days of learning how to write scripts and how the rules affect the network i’m trying to build, we have come up with this script shown below.

The goal of this script is to Prioritise gaming traffic to a PS5 this is important to my son to have low ping at home, he’s actually really good and plays in a lot of tournaments so i’m all for supporting him. This means keeping ping below 10ms as much as possible.

The purpose of this post is to see what the Mikrotik experts on here think of an AI generated script. Is there any mistakes? or conflicting rules? and perhaps more importantly is this the best way to do it?

Edited [ after 2 days of using this I am encountering issues with “add name=“GAMING_D” parent=“MASTER_DOWN” packet-mark=“GAMING” queue=default limit-at=75M max-limit=225M priority=1” all other queue tree rules are showing traffic on it except Gaming down, it only ever shows 0 I wonder if there is some mangle rule that is missing for this Queue?)

he partly AI generated SCRIPT:

/ip firewall mangle
# DNS requests. Mark in two places because DNS is sent out by the router (itself) too.
add chain=prerouting action=mark-connection protocol=udp port=53 connection-state=new new-connection-mark="DNS" comment="DNS"
add chain=postrouting action=mark-connection protocol=udp port=53 connection-state=new new-connection-mark="DNS"
add chain=postrouting action=mark-packet passthrough=no connection-mark="DNS" new-packet-mark="DNS"
# Mark all VoIP traffic (adjust ports and protocols as needed).
add chain=prerouting action=mark-connection protocol=tcp dscp=46 new-connection-mark="VOIP" comment="VOIP"
add chain=prerouting action=mark-connection protocol=udp dscp=46 new-connection-mark="VOIP"
add chain=prerouting action=mark-packet passthrough=no connection-mark="VOIP" new-packet-mark="VOIP"
# Mark gaming traffic (adjust ports as needed for your PS5).
add chain=prerouting action=mark-connection protocol=udp port=3074,9308 new-connection-mark="GAMING" comment="Gaming"
add chain=prerouting action=mark-packet passthrough=no connection-mark="GAMING" new-packet-mark="GAMING"
# Ping replies. Mark in two places because ICMP is sent out by the router (itself) too.
add chain=prerouting action=mark-connection protocol=icmp connection-state=new new-connection-mark="ICMP" comment="ICMP"
add chain=postrouting action=mark-connection protocol=icmp connection-state=new new-connection-mark="ICMP"
add chain=postrouting action=mark-packet passthrough=no connection-mark="ICMP" new-packet-mark="ICMP"
# Mark everything else that has no mark applied.
add chain=prerouting action=mark-connection connection-mark=no-mark new-connection-mark="OTHER" comment="OTHER"
add chain=prerouting action=mark-packet passthrough=no connection-mark="OTHER" new-packet-mark="OTHER"

/ip firewall filter
add chain=input action=accept connection-state=established,related comment="Allow established/related connections"
add chain=input action=drop in-interface=ether1 comment="Drop invalid connections on WAN interface"
add chain=input action=accept in-interface=ether1 dst-port=53 protocol=udp comment="Allow DNS UDP"
add chain=input action=accept in-interface=ether1 dst-port=53 protocol=tcp comment="Allow DNS TCP"
add chain=input action=accept in-interface=ether1 dst-port=3074,9308 protocol=udp comment="Allow Gaming UDP (Adjust Ports)"
add chain=input action=accept in-interface=ether1 protocol=icmp comment="Allow ICMP"
add chain=input action=accept in-interface=ether1 dst-port=80,443 protocol=tcp comment="Allow HTTP/HTTPS"
add chain=input action=drop in-interface=ether1 comment="Drop all other incoming traffic on WAN interface"
add chain=forward action=fasttrack-connection connection-mark=GAMING comment="Fast Track Gaming" 
add chain=forward action=fasttrack-connection connection-mark=DNS comment="Fast Track DNS" 
add chain=forward action=accept connection-state=established,related comment="Allow established/related connections"
add chain=forward action=accept connection-state=new in-interface=ether1 comment="Allow new connections from LAN to WAN"
add chain=forward action=drop connection-state=invalid comment="Drop invalid connections"
add chain=forward action=accept in-interface=bridge comment="Allow traffic from LAN to WAN"
add chain=forward action=drop comment="Drop all other traffic from LAN to WAN"

/queue tree
add name=“MASTER_UP” parent=“ether1” queue=default max-limit=90M priority=8
add name=“MASTER_DOWN” parent=“ether2” queue=default max-limit=900M priority=8
# Prioritize gaming traffic
add name="GAMING_U" parent="MASTER_UP" packet-mark="GAMING" queue=default limit-at=7500k max-limit=22500k priority=1
add name="GAMING_D" parent="MASTER_DOWN" packet-mark="GAMING" queue=default limit-at=75M max-limit=225M priority=1
# Prioritize other important traffic
add name="VOIP_U" parent="MASTER_UP" packet-mark="VOIP" queue=default limit-at=7500k max-limit=22500k priority=2
add name="VOIP_D" parent="MASTER_DOWN" packet-mark="VOIP" queue=default limit-at=75M max-limit=225M priority=2
add name="DNS_U" parent="MASTER_UP" packet-mark="DNS" queue=default limit-at=7500k max-limit=22500k priority=3
add name="DNS_D" parent="MASTER_DOWN" packet-mark="DNS" queue=default limit-at=75M max-limit=225M priority=3
add name="ICMP_U" parent="MASTER_UP" packet-mark="ICMP" queue=default limit-at=7500k max-limit=22500k priority=4
add name="ICMP_D" parent="MASTER_DOWN" packet-mark="ICMP" queue=default limit-at=75M max-limit=225M priority=4
# Mark everything else as lower priority
add name="OTHER_U" parent="MASTER_UP" packet-mark="OTHER" queue=default limit-at=7500k max-limit=22500k priority=5
add name="OTHER_D" parent="MASTER_DOWN" packet-mark="OTHER" queue=default limit-at=75M max-limit=225M priority=5

Bufferbloat test: (bare in mind i’m not sure how to test if the script its effecting the bufferbloat on the PS5 directly. This test was done on a MAC via ethernet, the MAC is not optimised for in the queue tree so results may not be very useful?)

https://www.waveform.com/tools/bufferbloat?test-id=75b127ff-8de2-47ac-ae08-efe21448d12c

Thanks for reading :]
Bufferbloat and Internet Speed Test - Waveform.pdf (235 KB)

ChatGPT is just a dumb language model that makes up a lot of stuff so you can never ever trust it to supply the correct facts. It’s better to find another source for your project.

Yes i’ve caught it out on mistakes many a Time its not perfect, I would still like to know whether the above script is done correctly or if anyone knows a better way im all ears. What GPT is good at is explaining certain things that are hard to quickly grasp for a Leyman. I am looking into other sources including many posts on here about qos, it’s just all so personalised to peoples needs etc… The best post on qos I have come across so far is PCunites qos post for making a basic qos but even his “basic qos” seems to prioritise VOIP traffic. (http://forum.mikrotik.com/t/using-routeros-to-qos-your-network-2020-edition/66683/1)

ChatGPT does better at things like bash scripts, Dockerfiles, or DNS BIND9 zone files, etc. For RouterOS is doesn’t have a transformer to help it, so results are often context-less version of reddit post.

Anyway, seems it working other than your “gaming queue”. The issue is the ports used vary by game. You can look at /ip/firewall/connections and filter on your PS5’s IP address and see what port/protocols it’s uses and mark them specifically. You can also just mark GAMING traffic based on the PS5’s IP (and add DHCP static lease for it), not just specific port/protocol, so any port it uses are covers and given priority.

At the risk of starting another QoS debate thread…

  1. Get the best Internet service you can afford (many latency issues occur on the WAN side, where you can’t control anything).

  2. You can’t improve your base latency with QoS, because schedulers/traffic shapers always add latency and CPU time. Only the average latency under load can be improved.

  3. Less is more. While pcunite’s guide is spot-on (and very educational) for his use case, it’s also resource intensive IMO by its scope. Every rule and packet mark has to be processed by the small processor in your router. Do you really need to process every packet to achieve your goal ? There’s a post in that thread with a brilliant and cleverly implemented 3 tier setup (microCAKE). It basically prioritizes time critical packets (you can add your gaming ports in that class i.e. 3074) and buffers/drops everything else as required. Alternatively, a simple queue with CoDel or SFQ might suffice without any additional tweaks.

Hence, in that regard, I love Amm0’s simple approach: prioritize the console over everything else. You can also limit traffic from other devices and reserve a portion for the console, so it never has to fight over other packets. Real time gaming packets are very small, after all…

Lastly, you probably should not use ChatGPT…the only smart thing about it is how it plagiarizes the work of others without crediting them…

In fact, you can see the effect…





Using ChatGPT to make a QOS script for PS5, Opinions?

…and then you have problems and come and ask here…
Why don’t you ask that question to ChatGPT?

It is like visiting a fairy … ChatGPT “tells” you what you want to “hear” but you never know if the fairytale is true or correct in narration.
If only the “story” matches your expectations good enough then you are convinced that this is a correct “answer”.

Have anyone seen the possibility to negate the ChatGPT answer? It’s answers are the truth revealed.
It is a newer version of Facesomething where you had no chance to negate the post so every post was treated as positive or super postive.

Suggest a CHAT GPT forum withini MT, where all chatGPT conversations can go, and we never have to visit. :slight_smile:

No it’s the ChatGPT part that gets folks all rilled up.

But @moba’s post above is spot on, see http://forum.mikrotik.com/t/using-chatgpt-to-make-a-qos-script-for-ps5-opinions/169366/1

I’m a fan of prioritizing the device(s), then SFQ rest in queue tree. Every config line in a “mangle” or “queue” is slowing down packet processing, so “less is more” is a great summary :slight_smile:.

Perhaps you can add also a simple queue for Wi-Fi to throttle client speeds which reduce load before it gets to WAN queue tree be another addition. If router has lightly loaded CPU before queueing, perhaps newer CoDel/FQCoDel/CAKE likely might add benefits over older (but simple/low-overhead) SFQ.

FWIW I don’t know what “microCAKE” is.

It was a v6 config posted in pcunite’s QoS thread that was meant to somewhat replicate CAKE before it became available with the kernel update in v7. It used SFQ type queues with a minimal amount of mangle rules.