QoSmate: (Yet Another) Quality of Service Tool for OpenWrt

just installed

root@ImmortalWrt:~# opkg list-installed | grep lua
liblua5.1.5 - 5.1.5-r11
lua - 5.1.5-r11
lua-cjson - 2.1.0-r3

1 Like

rebooted and working now :+1:

1 Like

Alright, thank you for your help! I’ve updated the one-liner for installing the connections tab to also include the installation of Lua.

4 Likes

btw, awesome addon for openwrt. A+ on bufferbloat tests. And in my imagination when playing fast paces fps games @dlakelans script feels snappier than cake

3 Likes

something is still not ok with the connection script, in syslog:

luci: failed login on /admin/network/qosmate/rules for root

as result of course i cannot login via luci

I've been trying to reproduce your issue. I set up a VM with a fresh OpenWRT installation, installed everything from scratch and didn't encounter any problems at all. So let's try to identify where the issue might be...

What OpenWrt version are you using?

ubus call system board

Did you use the the whole command I provided?

Did you clear your browser cache afterward and restart your browser? Sometimes, after clearing the browser cache, you need to close all browser windows and start a completely new instance. A faster way to avoid browser cache issues is to:

  1. Open the developer tools.
  2. Go to the "Network" tab.
  3. Enable the "Disable Cache" option.

With this enabled, you just need to have the developer tools open, refresh the page, and nothing will be cached.

However, your error message might indicate a permission issue.

ubus call system board
{
        "kernel": "5.15.162",
        "hostname": "OpenWrt",
        "system": "AMD GX-420CA SOC with Radeon(tm) HD Graphics",
        "model": "Hewlett-Packard HP t620 PLUS Quad Core TC",
        "board_name": "hewlett-packard-hp-t620-plus-quad-core-tc",
        "rootfs_type": "ext4",
        "release": {
                "distribution": "OpenWrt",
                "version": "23.05.4",
                "revision": "r24012-d8dd03c46f",
                "target": "x86/64",
                "description": "OpenWrt 23.05.4 r24012-d8dd03c46f"
        }
}

i used all your commands (again), after the uhttpd restart it happens again, working in browser dev mode with disabled cache, i cannot login. restarting rpcd helps to login and i can go to qosmate's Connections tab in luci but it fails to load. there is a POST call to http://192.168.1.1/ubus? which fails (blocked status) with response message [{"jsonrpc":"2.0","id":2,"error":{"code":-32000,"message":"Object not found"}}]

also

ubus call luci.qosmate getConntrackDSCP
Command failed: Not found

plus:

This page uses the non standard property “zoom”. Consider using calc() in the relevant property values, or using “transform” along with “transform-origin: 0 0”. connections
Error: XHR request timed out
    handleReadyStateChange http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:69
    request http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:47
    request http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:47
    promise callback*request http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:47
    flushRequestQueue http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:39
    request http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:50
    request http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:47
    promise callback*request http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:47
    post http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:71
    call http://192.168.1.1/luci-static/resources/rpc.js?v=git-24.086.45142-09d5a38:5
    declare http://192.168.1.1/luci-static/resources/rpc.js?v=git-24.086.45142-09d5a38:23
    declare http://192.168.1.1/luci-static/resources/rpc.js?v=git-24.086.45142-09d5a38:20
    load http://192.168.1.1/luci-static/resources/view/qosmate/connections.js?v=git-24.086.45142-09d5a38:65
    __init__ http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:147
    super http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:22
    ClassConstructor http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:12
    compileClass http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:182
    promise callback*compileClass http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:178
    promise callback*require http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:184
    instantiateView http://192.168.1.1/luci-static/resources/ui.js?v=git-24.086.45142-09d5a38:359
    <anonymous> http://192.168.1.1/cgi-bin/luci/admin/network/qosmate/connections:50
    promise callback* http://192.168.1.1/cgi-bin/luci/admin/network/qosmate/connections:49
luci.js:161:9
Uncaught (in promise) Error: XHR request timed out
    handleReadyStateChange http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:69
    request http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:47
    request http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:47
    promise callback*request http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:47
    flushRequestQueue http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:39
    request http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:50
    request http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:47
    promise callback*request http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:47
    post http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:71
    call http://192.168.1.1/luci-static/resources/rpc.js?v=git-24.086.45142-09d5a38:5
    declare http://192.168.1.1/luci-static/resources/rpc.js?v=git-24.086.45142-09d5a38:23
    declare http://192.168.1.1/luci-static/resources/rpc.js?v=git-24.086.45142-09d5a38:20
    load http://192.168.1.1/luci-static/resources/view/qosmate/connections.js?v=git-24.086.45142-09d5a38:65
    __init__ http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:147
    super http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:22
    ClassConstructor http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:12
    compileClass http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:182
    promise callback*compileClass http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:178
    promise callback*require http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:184
    instantiateView http://192.168.1.1/luci-static/resources/ui.js?v=git-24.086.45142-09d5a38:359
    <anonymous> http://192.168.1.1/cgi-bin/luci/admin/network/qosmate/connections:50
    promise callback* http://192.168.1.1/cgi-bin/luci/admin/network/qosmate/connections:49
luci.js:69:20
    error http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:165
    (Async: promise callback)
    __init__ http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:147
    super http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:22
    ClassConstructor http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:12
    compileClass http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:182
    (Async: promise callback)
    compileClass http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:178
    (Async: promise callback)
    require http://192.168.1.1/luci-static/resources/luci.js?v=git-24.086.45142-09d5a38:184
    instantiateView http://192.168.1.1/luci-static/resources/ui.js?v=git-24.086.45142-09d5a38:359
    <anonymous> http://192.168.1.1/cgi-bin/luci/admin/network/qosmate/connections:50
    (Async: promise callback)
    <anonymous> http://192.168.1.1/cgi-bin/luci/admin/network/qosmate/connections:49

@Hudra

Great work on your project, thanks.

Does /etc/init.d/qosmate status show you your actual queue discipline settings similar to tc -s qdisc?

I ask as I don't see the correct overhead applied for example.

Hello Hudra, somewhat related to QoSmate, do you think it's possible to improve SQM and add a login interface, for example, to see the DSCPs that have been added, etc.? Thank you.

config queue
	option enabled '1'
	option interface 'eth1'
	option download '750000'
	option upload '750000'
	option debug_logging '0'
	option verbosity '5'
	option qdisc 'cake'
	option script 'layer_cake.qos'
	option qdisc_advanced '1'
	option squash_dscp '1'
	option squash_ingress '1'
	option ingress_ecn 'ECN'
	option egress_ecn 'NOECN'
	option qdisc_really_really_advanced '1'
	option iqdisc_opts 'diffserv4 dual-dsthost nat ingress nowash noatm overhead 44'
	option eqdisc_opts 'diffserv4  dual-srchost nat wash noatm overhead 44'
	option linklayer 'none'

config rule
	list dest_ip '192.168.2.168'
	option set_dscp 'CS4'
	option target 'DSCP'
	option src 'wan'
	option name 'port 3074 ps5 julien'
	option family 'ipv4'
	option dest 'lan'
	list proto 'tcp'
	list proto 'udp'
	list proto 'icmp'


connexion dscp

my little gameplay is more efficient with SQM i have impression because i think i has a gigabit connexion he just my feeling

Summary

This text will be hidden

Alright, if this command fails, there might be an issue with the Lua script that retrieves the conntrack data.

What output do you get when you enter the following commands?

ls -l /usr/libexec/rpcd/luci.qosmate

lua /usr/libexec/rpcd/luci.qosmate

Thank you. The command /etc/init.d/qosmate status provides a combination of information, including the output of tc -s qdisc.

When using HFSC?

I'm not entirely sure what you mean by "login interface." In general, if you have questions or suggestions about SQM, it would be best to create your own post.

I just created the topic, thank you very much!

1 Like

Yes, using HFSC.

Excellent script and excellent person. The script works perfectly on wired connections, it does its job. The best thing is the luci interface, this is something very striking and is great for people with little knowledge. After many hours and tests with hudra I can say that it works quite well on my x86 machine. Great job. If your internet doesn't work well with this script, it's because your ISP has little stability.

3 Likes
root@OpenWrt:/usr/libexec/rpcd# ls -l /usr/libexec/rpcd/luci.qosmate
-rwxr-xr-x    1 root     root          2404 Aug 22 19:44 /usr/libexec/rpcd/luci.qosmate
root@OpenWrt:/usr/libexec/rpcd# lua /usr/libexec/rpcd/luci.qosmate
root@OpenWrt:/usr/libexec/rpcd# lua /usr/libexec/rpcd/luci.qosmate list
{"getConntrackDSCP":{}}

with "call" parameter it waits for input from stdin and I can make it "work" by pressing Ctrl+D (EOF)

root@OpenWrt:/usr/libexec/rpcd# lua /usr/libexec/rpcd/luci.qosmate call getConntrackDSCP
{"connections":{"ipv4:tcp:192.168.1.100:427:192.168.1.1:59895" ...

but i am not sure what you are waiting for, the args variable looks like not used later on, and it looks stdin.read(*) is a blocking read.

You're correct about the stdin behavior. This is how rpcd plugin executables are designed to work in OpenWrt. If you want to execute the script directly you would have to use:

echo '{}' | lua /usr/libexec/rpcd/luci.qosmate call getConntrackDSCP

Here are the corresponding lines in the luci-app-example lua:

    -- Input parsing - the RPC daemon calls the Lua script and
    -- sends input to it via stdin, not as an argument on the CLI.
    -- Thus, any testing via the lua interpreter needs to be in the form
    -- echo '{jsondata}' | lua /usr/libexec/rpcd/script call method_name

or read here:
https://openwrt.org/docs/techref/rpcd#:~:text=The%20actual%20data,might%20have%20expected.

The difference you're seeing is due to how the script is called:

  1. Direct call (lua /usr/libexec/rpcd/luci.qosmate call getConntrackDSCP): It acts as a standalone program, expecting stdin input.
  2. ubus call (ubus call luci.qosmate getConntrackDSCP): ubus handles the communication, so no stdin wait.

The luci web interface uses ubus for RPC calls, which is why it works for most users.

Your issue is likely not with the script itself, but could be related to ubus, ACL settings or rpcd service.

To troubleshoot, please try:

  1. Check if luci.qosmate is listed:
ubus list
  1. Verify ACL settings:
cat /usr/share/rpcd/acl.d/luci-app-qosmate.json
  1. Restart services:
/etc/init.d/rpcd restart
/etc/init.d/uhttpd restart
  1. Check logs:
logread | grep -i "qosmate\|ubus\|rpcd"

Maybe restart the router?

Let me know the results, and we'll proceed from there.

When using HFSC this value only affects the setup when the LINKTYPE is set to "atm". In cases where LINKTYPE is not "atm" or "DOCSIS (OH = 25)," a default overhead of 40 is used, which is likely an overestimation in most cases. However, overestimating the overhead generally does not lead to significant negative impacts. Underestimating it, on the other hand, could result in suboptimal network performance.

This behavior has been consistent, even in previous implementations like the SimpleHFSCgamerscript. If there is a need to adjust the overhead manually, a small modification could be made to make this value configurable. However, since no one has pointed out any issues with it so far, there's been no real reason to adjust it.

3 Likes
root@OpenWrt-23.05.4-sda3:~# ubus list
container
dhcp
dnsmasq
dnsmasq.dns
hotplug.block
hotplug.dhcp
hotplug.iface
hotplug.neigh
hotplug.net
hotplug.ntp
hotplug.online
hotplug.tftp
log
network
network.device
network.interface
network.interface.docker
network.interface.guest
network.interface.guest2
network.interface.iot
network.interface.lan
network.interface.lan2
network.interface.lan3
network.interface.lan4
network.interface.loopback
network.interface.wan
network.interface.wan6
network.interface.wan_6
network.interface.wg0
network.wireless
service
system
root@OpenWrt-23.05.4-sda3:~# cat /usr/share/rpcd/acl.d/luci-app-qosmate.json

{
    "luci-app-qosmate": {
        "description": "Grant access to QoSmate configuration",
        "read": {
            "ubus": {
                "luci.qosmate": [ "getConntrackDSCP", "getDscpStats" ],
                "luci": [ "getInitList", "setInitAction", "getInitActionStatus", "exec" ]
            },
            "uci": [ "qosmate" ],
            "file": {
                "/etc/qosmate.sh": [ "read" ],
                "/etc/init.d/qosmate": [ "read", "exec" ],
                "/etc/hotplug.d/iface/13-qosmateHotplug": [ "read" ],
                "/etc/config/qosmate": [ "read" ],
                "/tmp/qosmate_auto_setup_output.txt": [ "read" ]
            }
        },
        "write": {
            "ubus": {
                "luci": [ "setInitAction", "exec" ]
            },
            "uci": [ "qosmate" ],
            "file": {
                "/etc/qosmate.sh": [ "write" ],
                "/etc/init.d/qosmate": [ "write" ],
                "/etc/hotplug.d/iface/13-qosmateHotplug": [ "write" ]
            }
        }
    }
}

as you see from the ubus list all luci.* is missing which is to some extent understandable due to above JS errors. am not sure what happens, if no one has similar issue most probably locally i have something.

after restarting rpcd luci* stuff loaded too.

root@OpenWrt-23.05.4-sda3:~# service rpcd restart
root@OpenWrt-23.05.4-sda3:~# ubus list
container
dhcp
dnsmasq
dnsmasq.dns
file
hotplug.block
hotplug.dhcp
hotplug.iface
hotplug.neigh
hotplug.net
hotplug.ntp
hotplug.online
hotplug.tftp
iwinfo
log
luci
luci-rpc
luci.ddns
luci.qosmate
luci.upnp
luci.wireguard
network
network.device
network.interface
network.interface.docker
network.interface.guest
network.interface.guest2
network.interface.iot
network.interface.lan
network.interface.lan2
network.interface.lan3
network.interface.lan4
network.interface.loopback
network.interface.wan
network.interface.wan6
network.interface.wan_6
network.interface.wg0
network.rrdns
network.wireless
rc
service
session
system
uci

i have these components installed by the way

liblua5.1.5 - 5.1.5-11
liblucihttp-lua - 2023-03-15-9b5b683f-1
liblucihttp-ucode - 2023-03-15-9b5b683f-1
liblucihttp0 - 2023-03-15-9b5b683f-1
libubus-lua - 2023-06-05-f787c97b-1
lua - 5.1.5-11
luci-app-ddns - git-23.346.52990-28c4a65
luci-app-firewall - git-24.067.01746-69867db
luci-app-upnp - git-24.025.85485-89a9b58
luci-base - git-24.086.45142-09d5a38
luci-lib-base - git-22.308.54612-9118452
luci-lib-ip - git-23.311.79290-c2a887e
luci-lib-jsonc - git-23.298.74571-62eb535
luci-lib-nixio - git-24.034.54875-21210dc
luci-light - git-23.024.33244-34dee82
luci-lua-runtime - git-23.233.52805-dae2684
luci-mod-admin-full - git-19.253.48496-3f93650
luci-mod-network - git-24.111.76511-ff6b275
luci-mod-status - git-24.141.29354-5cfe7a7
luci-mod-system - git-24.067.01860-7a82b2f
luci-proto-ipv6 - git-24.086.45108-51aee90
luci-proto-ppp - git-24.135.44542-f1ec9c2
luci-proto-wireguard - git-24.047.55123-7964117
luci-ssl - git-23.035.26083-7550ad6
luci-theme-bootstrap - git-24.086.46634-1ffe078
rpcd - 2023-07-01-c07ab2f9-1
rpcd-mod-file - 2023-07-01-c07ab2f9-1
rpcd-mod-iwinfo - 2023-07-01-c07ab2f9-1
rpcd-mod-luci - 20240305-1
rpcd-mod-rrdns - 20170710
rpcd-mod-ucode - 2023-07-01-c07ab2f9-1
ucode-mod-lua - 1

are you developing/running on a snapshot version maybe?

The ACL JSON looks good but it seems like your rpcd is crashing.

My main router is running on a self compiled snapshot version (not the latest one), and I am also testing on two virtual machines. One is also running a snapshot version, and the other is on 23.05.4. All three are x86_64, just like yours, and I am not encountering this issue on any of them. It also seems like other users are not experiencing this error, either. I even tried installing all of your packages to see if there might be conflicts with the stable version, but unfortunately, I can't reproduce the error.

Have you perhaps set something different in the rpcd config file?

What is the output of cat /etc/config/rpcd?

Also is there anything in the syslog?

logread | grep -i "qosmate\|ubus\|rpcd"

Also please check the console in your browser dev tools.