Help me update my HFSC shaper scripts for fw4/nftables

@hydra - do you need to add rm /usr/share/nftables.d/ruleset-post aswell?

No, because when you stop the service, the dscptag.nft file gets removed anyway.

1 Like

Fellas i need help setting this whole thing up, here is my setup:


I installed everything and renamed the interfaces inside of SimpleHFSCgamerscript but there is no internet connexion.
How would you set it up in this situation
I need WIFI running aswell.

A little bit more context/info’s would be helpful?

How did you set up the script?

Which script did you install? The original script from Daniel or my version? If you installed my version, did you follow the instructions on the github readme?

Thanks for taking the time to help me first of all.
So i used your command that installs everything including a veth interface that i dont know what its for tbh. I edited the WAN and LAN names accordingly into eth0.1 and eth0.2 but there was no internet connection after starting the script. Everything there was understood from for what interfaces to set and to make sure i keep the WIFI interface running.

Which command?

Please redo everything and follow the instructions on my github step by step:

hudra0/routerperf: OpenWRT router performance data collection and analysis script (github.com)

Actually, you don't need a veth interface anymore (though the script still supports it). The script now supports ctinfo (the default method for downshaping), which is the preferred method for shaping download traffic. You will also find some explanations in the readme...

What should i set as WAN LAN interfaces in the script according to the screenshot? Because when set according to the read me everything connects but i get no internet.

I would say:
WAN=eth0.2
LAN=eth0.1

Please show the output of:

ubus call system board; 
uci export network;
service SimpleHFSCgamerscript status;

redact sensitive informations....

Also please show how you set up the script. Everything from:

/etc/SimpleHFSCgamerscript.sh

to this line:

######################################## CUSTOMIZATIONS GO ABOVE THIS LINE ###############################################
##########################################################################################################################

ubus call system board:

{
        "kernel": "5.10.176",
        "hostname": "OpenWrt",
        "system": "bcm63xx/96328dg2x2 (0x6328/0xB0)",
        "model": "D-Link DSL-2750U rev C1",
        "board_name": "d-link,dsl-2750u-c1",
        "rootfs_type": "squashfs",
        "release": {
                "distribution": "OpenWrt",
                "version": "22.03.5",
                "revision": "r20134-5f15225c1e",
                "target": "bcm63xx/generic",
                "description": "OpenWrt 22.03.5 r20134-5f15225c1e"
        }
}

uci export network:

package network

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fdd0:ebee:3ce2::/48'

config device
        option name 'br-lan'
        option type 'bridge'
        list ports 'eth0.1'
        list ports 'eth0.2'
        list ports 'eth0.3'
        list ports 'eth0.4'

config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '1'

config switch_vlan
        option device 'switch0'
        option vlan '1'
        option ports '8t 0'

config interface 'WAN'
        option proto 'dhcp'
        option device 'eth0.2'

config interface 'LAN'
        option proto 'static'
        option device 'eth0.1'
        option ipaddr '192.168.10.1'
        option netmask '255.255.255.0'

config switch_vlan
        option device 'switch0'
        option ports '8t 3'
        option vlan '2'

config device
        option name 'eth0.2'
        option type '8021q'
        option ifname 'eth0'
        option vid '2'

config device
        option name 'eth0.3'
        option type '8021q'
        option ifname 'eth0'
        option vid '3'

config device
        option name 'eth0.4'
        option type '8021q'
        option ifname 'eth0'
        option vid '4'

config interface 'GUESTWIFI'
        option proto 'static'
        option ipaddr '192.168.8.1'
        option netmask '255.255.255.0'
        list dns '8.8.8.8'
        list dns '8.8.4.4'
        list dns '1.1.1.1'
        list dns '1.0.0.1'
        option device 'wlan0'

config switch_vlan
        option device 'switch0'
        option vlan '3'
        option ports '8t 1'

config switch_vlan
        option device 'switch0'
        option ports '8t 2'
        option vlan '4'

config device
        option type 'bridge'
        option name 'VLANS'
        list ports 'eth0.3'
        list ports 'VLANS.20'
        list ports 'VLANS.30'
        list ports 'VLANS.60'

config bridge-vlan
        option device 'VLANS'
        option vlan '20'
        list ports 'eth0.3:t'
        list ports 'VLANS.20:t'

config bridge-vlan
        option device 'VLANS'
        option vlan '30'
        list ports 'eth0.3:t'
        list ports 'VLANS.30:t'

config bridge-vlan
        option device 'VLANS'
        option vlan '60'
        list ports 'eth0.3:t'
        list ports 'VLANS.60:t'

config interface 'veth'
        option proto 'none'
        option ifname 'lanveth'
        option device 'lanveth'


-service SimpleHFSCgamerscript status:

Service "SimpleHFSCgamerscript" not found:

The script setup:

#!/bin/sh

## "atm" for old-school DSL or change to "DOCSIS" for cable modem, or
## "other" or anything else, for everything else

LINKTYPE="atm"

USEVETHDOWN=no
LANBR=br-lan

WAN=eth0.2 # change this to your WAN device name
UPRATE=1000 #change this to your kbps upload speed
LAN=eth0.1 # change to your LAN device if you don't use veth/bridge,
	   # leave it alone if you use veth, it will get set in the
	   # script below


DOWNRATE=10000 #change this to about 80% of your download speed (in kbps)
OH=44 # number of bytes of Overhead on your line (37 is reasonable
      # starting point, better to be too big than too small) probably
      # likely values are between 20 and 50

PFIFOMIN=5 ## minimum number of packets in pfifo, 4 to 10 is good guess
PACKETSIZE=350 # bytes per game packet avg (guess, 250 to 500 is likely) 
MAXDEL=25 # ms we try to keep max delay below for game packets after
	  # burst 10-25 is good 1 clock tick at 64Hz is ~16ms

BWMAXRATIO=20 ## prevent ack floods by limiting download to at most
	      ## upload times this amount... ratio somewhere between
	      ## 10 and 20 probably optimal. we down-prioritize
	      ## certain ACKs to reduce the chance of a flood as well.

if [ $((DOWNRATE > UPRATE*BWMAXRATIO)) -eq 1 ]; then
    echo "We limit the downrate to at most $BWMAXRATIO times the upstream rate to ensure no upstream ACK floods occur which can cause game packet drops"
    DOWNRATE=$((BWMAXRATIO*UPRATE))
fi

## how many kbps of UDP upload and download do you need for your games
## across all gaming machines? 

## you can tune these yourself, but a good starting point is this
## formula.  this script will not work for UPRATE less than about
## 600kbps or downrate less than about 1000kbps

GAMEUP=$((UPRATE*15/100+400))
GAMEDOWN=$((DOWNRATE*15/100+400))

## you can try setting GAMEUP and GAMEDOWN manually, some report this
## works well for CoD
#GAMEUP=400
#GAMEDOWN=800


DSCPSCRIPT="/usr/share/nftables.d/ruleset-post/dscptag.nft"

if [ ! -f $DSCPSCRIPT ]; then
    workdir=$(pwd)
    echo "You do not have the DSCP tagging script, downloading from github"
    cd /usr/share/nftables.d/ruleset-post/
    wget https://raw.githubusercontent.com/dlakelan/routerperf/master/dscptag.nft
    cd $workdir
fi



## Right now there are four possible leaf qdiscs: pfifo, red,
## fq_codel, or netem. If you use netem it's so you can intentionally
## add delay to your packets, set netemdelayms to the number of ms you
## want to add each direction. Our default is pfifo it is reported to
## be the best for use in the realtime queue

gameqdisc="pfifo"

#gameqdisc="netem"

netemdelayms="1"
netemjitterms="7"
netemdist="normal"

pktlossp="none" # set to "none" for no packet loss, or use a fraction
		# like 0.015 for 1.5% packet loss in the realtime UDP
		# streams


if [ $gameqdisc != "fq_codel" -a $gameqdisc != "red" -a $gameqdisc != "pfifo" -a $gameqdisc != "netem" ]; then
    echo "Other qdiscs are not tested and do not work on OpenWrt yet anyway, reverting to red"
    gameqdisc="red"
fi




## Help the system prioritize your gaming by telling it what is bulk
## traffic ... define a list of udp and tcp ports used for bulk
## traffic such as torrents. By default we include the transmission
## torrent client default port 51413 and the default TCP ports for
## bittorrent. Use comma separated values or ranges A:B as shown. Set
## your torrent client to use a known port and include it here

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


WASHDSCPUP="yes"
WASHDSCPDOWN="yes"


######################### CUSTOMIZATIONS GO ABOVE THIS LINE ###########

I cant start the service because i lose connection if i do so, everything connects fine but no internet access.

You are using an old version of the script. If you compare your script with the actual script in my repo you will see there is a difference:

That's why I told you

Let's start from scratch:

First delete all script files:

rm /etc/init.d/SimpleHFSCgamerscript && rm /etc/SimpleHFSCgamerscript.sh && rm /etc/config/hfscscript && rm /etc/hotplug.d/iface/13-SimpleHFSCGamerScriptHotplug

Then start here:

Okay done everything here is how it looks atm. I use a DSL connection with 12mb download and 1mb upload.

#!/bin/sh

##############################
# General settings
##############################
# "atm" for old-school DSL, "DOCSIS" for cable modem, or "other" for anything else
LINKTYPE="atm" 
WAN=eth0.2 # Change this to your WAN device name
LAN=eth0.1 # Change to your LAN device if you don't use veth/bridge, leave it alone if you use veth
DOWNRATE=10000 # Change this to about 80% of your download speed (in kbps)
UPRATE=1000 # Change this to your kbps upload speed
OH=44 # Number of bytes of Overhead on your line
PRESERVE_CONFIG_FILES="yes"  # Set to "yes" to preserve, "no" to ignore during sysupgrade

##############################
# Downstream shaping method
##############################
DOWNSHAPING_METHOD="ctinfo" # Options: "veth", "ctinfo", "lan"

## "ctinfo"  Uses connection tracking information to restore DSCP markings on incoming packets
## "veth" Utilizes a virtual Ethernet pair to control incoming traffic
## "lan" Applies traffic shaping directly on the LAN interface, (ideal) for environments with a single interface directed towards the LAN. 

##############################
# Veth-specific settings (only adjust if using the Veth setup)
##############################
LANBR=br-lan # LAN bridge interface name, only relevant if USEVETHDOWN is set to "yes"

##############################
# Performance settings
##############################

BWMAXRATIO=20 ## prevent ack floods by limiting download to at most
	      ## upload times this amount... ratio somewhere between
	      ## 10 and 20 probably optimal. we down-prioritize
	      ## certain ACKs to reduce the chance of a flood as well.

if [ $((DOWNRATE > UPRATE*BWMAXRATIO)) -eq 1 ]; then
    echo "We limit the downrate to at most $BWMAXRATIO times the upstream rate to ensure no upstream ACK floods occur which can cause game packet drops"
    DOWNRATE=$((BWMAXRATIO*UPRATE))
fi

## how many kbps of UDP upload and download do you need for your games across all gaming machines? 

## you can tune these yourself, but a good starting point is this formula. this script will not work for UPRATE less than about
## 600kbps or downrate less than about 1000kbps

GAMEUP=$((UPRATE*15/100+400))
GAMEDOWN=$((DOWNRATE*15/100+400))

## you can try setting GAMEUP and GAMEDOWN manually, some report this works well for CoD
#GAMEUP=550
#GAMEDOWN=2000

Putting LINKTYPE as "atm" is correct or should i leave it as ethernet?

Added my gaming pc as a real time priority device and the rest are wifi devices put in the low priority section.

UDPBULKPORT="51413"
TCPBULKPORT="51413,6881-6889"
VIDCONFPORTS="10000,3478-3479,8801-8802,19302-19309,5938,53"
REALTIME4="192.168.10.164" # example, just add all your game console here
REALTIME6="fd90::129a" ## example only replace with game console
LOWPRIOLAN4="192.168.8.227,192.168.8.158,192.168.8.111,192.168.8.111,192.168.8.122" # example, add your low priority lan machines here
LOWPRIOLAN6="fd90::129a" ## example, add your low priority lan ipv6 PUBLIC addr here

Looks good to me now...

Yea should be fine...

Good, seems like it's working now. What is the output of:

service SimpleHFSCgamerscript status

Well my wifi isnt connecting but my pc is working.
Nothing is coming up when entering this command

service SimpleHFSCgamerscript status

Then the script isn't working.

Have you enabled and started the script as indicated in the readme?

service SimpleHFSCgamerscript enable 
service SimpleHFSCgamerscript start

Yeah i did start the script and as soon as i did that it started to slow down

Do you get any output when you start the script?

No it just froze there disconnecting everything.

What happens when you start the script directly:

/etc/SimpleHFSCgamerscript.sh

Is there any output?

Nothing worked. Is it better than cake+piece of cake?


This is what am dealing with using cake and piece of cake.