Instructions how to create/copy/configure/run dlakelan Gamer QoS script (or any script)

Hello ...we need more testers..so here is Instructions how to create-->copy-->configure-->run of @dlakelan script.

CONFIGURE THE SCRIPT
Everyone has different speeds...different MTU..different type of connection...

First of all without running any qos/sqm with a wired pc (preferred) and with no one using internet except your pc..run a speed test...and write down your Download speed and Upload..remember that values in script is in Kbps (Kbit).

When you do this the only values that needs to set up when you create the script are the following.
LINKTYPE="atm" #available values is "atm","DOCSIS", "*".
WAN={your WAN interface name as appears in Interfaces tab}
UPRATE={your upload speed from speedtest etc 15000}
LAN={your LAN interface name as appears in Intefaces->LAN->Edit->Psysical settings...look photo}


DOWNRATE={your download speed from speedtest etc 45000}
GAMEUP={how much speed must allocated in game udp traffic for upload etc 800}
GAMEDOWN={how much speed must allocated in game udp traffic for download etc 1500}
GAMINGIP="192.168.1.XXX" {change to your console ip}
scroll down a little...
OH={your packet overhead etc 44...values as suggested in SQM}
MTU={your MTU value etc 1492}

CREATING THE FILE

First of all the tools you need..

For linux/Osx users it is pretty simple...create a new txt file..name it as qos.sh and copy inside the code..thats it!

For Windows users..windows has "problem" with UTF-8 and "end of line” characters in text files in shell scripts. So creating the file via notepad doesn't work.
You need Notepad++.

Open Notepad++ create a new file...paste the code of script inside...then click in Edit > EOL Conversion > UNIX/OSX Format.

Then File-->Save or Save as

TRANSFER THE FILE IN OPENWRT

To copy the file in Openwrt...

For linux/Osx users it is pretty simple to...

ssh to your router and use scp command..open the directory where you create the file...right click > open terminal here.
Now you are in the directory..in terminal now write..etc

scp qos.sh root@192.168.1.1:/root/
password:{your password}

You copy the file in the /root/ directory.

In terminal write...

ssh root@192.168.1.1
password:{your password}

Now you are "inside" openwrt ..
Type ls
You will see the file...qos.sh
Type chmod +x qos.sh
Type ls
You will see that is "green"...we make it executable.

For Windows users you need WinSCP...

  1. Download WinSCP and install it in your Windows.
  2. Start WinSCP on your Windows client, WinSCP's login window will pop up.
  3. Click on New Site on the left, then enter your OpenWrt device IP address (192.168.1.1) on the right side into Host name, keep the default port 22. In User name enter root, in Password, enter your root password (or leave blank, if you have not set a password yet).

4 Click the Login at the bottom of the Window.
5. Done. You now have an Exlorer-like view of your OpenWrt file system.

  1. In left side it is your windows folders...in the right side it is Openwrt file system.

  2. Navigate in left side where you create the script and copy it in /root/ directory in right side (Openwrt).

  3. When you transfer the file in /root/ directory of Openwrt right click in the file-->Properties

  4. You will see something like that..In Octal write 755 and hit OK.

  5. You make it executable.

RUN SCRIPT

For linux/Osx users...
ssh to your router..etc
ssh root@192.168.1.1
password:{your password}

Then type ./qos.sh and type y when asked by the script.

For Windows users......
You can enter the command on Console window (Commands > Open Terminal).
Make sure you are in directory /root/ (1)
Write (2) ./qos.sh
Click Execute (3)
You run it!
When prompt by script type y

That's it....you close WinSCP.

Both users...Linux/Osx and Windows....if you want to run script automatically when you reboot router.
Navigate in Openwrt GUI...
System--->Startup--> Local Startup
And copy/paste this BEFORE exit 0

echo "y" | /root/qos.sh

And click Save

## UPDATES ##
In newer version of script.. classify implementation via ipset's...you need the packages..
ipset
kmod-ipt-ipset
kmod-sched-ipset
iptables-mod-ipopt
And needs to configure these section's

for ip4 in 192.168.1.111 192.168.1.222; do
    ipset add realtimeset4 "$ip4"
done

for ip6 in fd01:0101::1 fd01:0101::2 ; do
    ipset add realtimeset6 "$ip6"
done

Replace ip's of example 192.168.1.111 192.168.1.222 to your consoles..will
get UDP MAX priority.
The same for IPv6 ip's fd01:0101::1 fd01:0101::2
In this section put ports or range of ports that you want to be in BULK priority.

UDPBULKPT="51413"
TCPBULKPT="51413,6881:6889"

If your ISP sends packets already tagged with DSCP values or you see that traffic falls in etc Bulk traffic with no reason..then probably packets already tagged with DSCP values and script "put" them in a class.So set the values following to "yes"..this way script will "clear" DSCP values of packets and mark them again with DSCP to fall in the classes you want.

WASHDSCPUP="yes"
WASHDSCPDOWN="yes"

That's all.
LINK for the script

4 Likes

A link to the script of course would be helpful. I'm about to push it to my github so people can always get the latest version of it there... No promises about backwards compatibility though... if I break something you buy it :wink:

1 Like

My fault sorry..

Ok, the latest script will always be here... I've made changes this morning to do ipsets rather than just a single static gaming console, and also enabled downgrading a set of torrent ports etc so you can set your torrent client to use a consistent port and always downgrade them to CS1/bulk ... if you can test it and then change the first post to include instructions for setting those correctly, it would be great!

To download it directly to your router, log in:

cd /tmp
wget https://raw.githubusercontent.com/dlakelan/routerperf/master/SimpleHFSCgamerscript.sh
2 Likes

following, will test this in my free time, good job putting it together in a simple manner for people like me to understand instead of cluttering the entire thread.

Please don't write in this thread ....here will post only instructions updates for newer versions of script...or when added functions.

If you have any problems running the script..pm us.

Note: When instructions updates posted that means that script is fully functional and working....follow the instructions.

Thank you.

3 Likes

Newest script splits out the function of tagging dscp to a second script that you can customize without too much complication

now to install:

cd /etc
wget https://raw.githubusercontent.com/dlakelan/routerperf/master/SimpleHFSCgamerscript.sh
wget https://raw.githubusercontent.com/dlakelan/routerperf/master/dscptag.sh

then adjust the speeds and interfaces etc. you can rename the scripts if you like, but you must give the name of the dscp script in a variable in the first script. better to leave the second one named dscptag.sh anyway

To clarify. With the current version of the script, it always calls out to the second dscptag.sh script to set up tagging rules... so you just need to have it there... no need to call it or edit it. If you want to edit it to customize your own dscp tagging, then you can update the main script and leave the dscptag.sh script customized and so your customizations won't be overwritten if we have bug fixes in the main script.

Since some had confusion, the current version will download the dscptag.sh script for you if you forget or don't understand.

1 Like

So i download the 2 scripts to openwrt router in directory /etc

Now i can change the lines of the script via ssh
Do i need to turn SimpleHFSCgamerscript.sh file exec.

yes it must be executable

I think I will write a README with instructions on the github as well

1 Like

script qos exec. 755

I have this error

just type the command at the command line, don't use this "Introduza comando" pop-up

There is now instructions on the github readme: https://github.com/dlakelan/routerperf

2 Likes

chmod a+x /etc/SimpleHFSCgamerscript.sh i use ssh

1 Like

exactly, and then edit the customization variables, and just run it at ssh command line:

/etc/SimpleHFSCgamerscript.sh

root@OpenWrt:~# /etc/SimpleHFSCgamerscript.sh
We limit the downrate to at most 10x the upstream rate to ensure no upstream ACK floods occur which can cause game packet drops
ipset v7.4: Set cannot be created: set with the same name already exists
ERROR: could not create realtimeset4 do you have ipsets working?
ipset v7.4: Set cannot be created: set with the same name already exists
ERROR: could not create realtimeset6 do you have ipsets working?
ipset v7.4: Element cannot be added to the set: it's already added
ipset v7.4: Element cannot be added to the set: it's already added
ipset v7.4: Element cannot be added to the set: it's already added
ipset v7.4: Element cannot be added to the set: it's already added

This script prioritizes the UDP packets from / to a set of gaming
machines into a real-time HFSC queue with guaranteed total bandwidth

Based on your settings:

Game upload guarantee = 800 kbps
Game download guarantee = 1600 kbps

Download direction only works if you install this on a wired router
and there is a separate AP wired into your network, because otherwise
there are multiple parallel queues for traffic to leave your router
heading to the LAN.

Based on your link total bandwidth, the minimum amount of jitter
you should expect in your network is about:

UP = 3 ms

DOWN = 0 ms

In order to get lower minimum jitter you must upgrade the speed of
your link, no queuing system can help.

Please note for your display rate that:

at 30Hz, one on screen frame lasts: 33.3 ms
at 60Hz, one on screen frame lasts: 16.6 ms
at 144Hz, one on screen frame lasts: 6.9 ms

This means the typical gamer is sensitive to as little as on the order
of 5ms of jitter. To get 5ms minimum jitter you should have bandwidth
in each direction of at least:

7200 kbps

The queue system can ONLY control bandwidth and jitter in the link
between your router and the VERY FIRST device in the ISP
network. Typically you will have 5 to 10 devices between your router
and your gaming server, any of those can have variable delay and ruin
your gaming, and there is NOTHING that your router can do about it.

adding fq_codel qdisc for non-game traffic due to fast link
adding fq_codel qdisc for non-game traffic due to fast link

We are going to add classification rules via iptables to the
POSTROUTING chain. You should actually read and ensure that these
rules make sense in your firewall before running this script.

Continue? (type y or n and then RETURN/ENTER)

press "y" and RET... then it will finish.

iptables v1.8.4 (legacy): Couldn't load target `dscptag':No such file or directory

Try `iptables -h' or 'iptables --help' for more information.
ip6tables v1.8.4 (legacy): Couldn't load target `dscptag':No such file or directory

Try `ip6tables -h' or 'ip6tables --help' for more information.
iptables: Invalid argument. Run `dmesg' for more information.
ip6tables: Invalid argument. Run `dmesg' for more information.
iptables: Invalid argument. Run `dmesg' for more information.
ip6tables: Invalid argument. Run `dmesg' for more information.
iptables: Invalid argument. Run `dmesg' for more information.
ip6tables: Invalid argument. Run `dmesg' for more information.
iptables: Invalid argument. Run `dmesg' for more information.
ip6tables: Invalid argument. Run `dmesg' for more information.
iptables: Invalid argument. Run `dmesg' for more information.
ip6tables: Invalid argument. Run `dmesg' for more information.
iptables: Invalid argument. Run `dmesg' for more information.
ip6tables: Invalid argument. Run `dmesg' for more information.
iptables: Invalid argument. Run `dmesg' for more information.
ip6tables: Invalid argument. Run `dmesg' for more information.
iptables: Invalid argument. Run `dmesg' for more information.
ip6tables: Invalid argument. Run `dmesg' for more information.
iptables: Invalid argument. Run `dmesg' for more information.
ip6tables: Invalid argument. Run `dmesg' for more information.
iptables: Invalid argument. Run `dmesg' for more information.
ip6tables: Invalid argument. Run `dmesg' for more information.
iptables: Invalid argument. Run `dmesg' for more information.
ip6tables: Invalid argument. Run `dmesg' for more information.
iptables: Invalid argument. Run `dmesg' for more information.
ip6tables: Invalid argument. Run `dmesg' for more information.
iptables: Invalid argument. Run `dmesg' for more information.
iptables: Invalid argument. Run `dmesg' for more information.
ip6tables: Invalid argument. Run `dmesg' for more information.
ip6tables: Invalid argument. Run `dmesg' for more information.
Everything is taken care of for RED qdisc
DONE!

Can not output tc -s qdisc because it crashes on OpenWrt when using RED qdisc, but things are working!

aha. thanks for your error report. This is hard for me to test because I don't have a testing openwrt router at the moment.

I think I'm missing "-t mangle" in the command that creates dscptag chain... I fix it and push to github now. Please get both scripts again

No problem, "Obrigado" for you help...
In the script on the Downrate i put full speed or 80%

Normally you put say 90%

1 Like

1 Like