Skip to content

Commit

Permalink
updated readme and comments in script
Browse files Browse the repository at this point in the history
  • Loading branch information
rickkatquanzadotnet committed Feb 17, 2023
1 parent e1c3318 commit face940
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 42 deletions.
37 changes: 24 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,39 @@ Currently only supports nssfq-codel and no traffic classification / marking due

## Requirements

* An SQM enabled build such as https://github.com/ACwifidude/openwrt
* An SQM enabled OpenWRT build such as https://github.com/ACwifidude/openwrt
* sqm-scripts package
* luci-app-sqm package (for configuration from the GUI)

## Manual Installation
## Installation

### Package Installation

* Download the .ipk package file here
* Go to the System -> Software menu on your router and upload the .ipk package file

### Manual Installation

* Just copy the nss-rk.qos and nss-rk.qos.help files to /usr/lib/sqm on your router

### Installation via feeds

If you're building OpenWRT yourselves, you can add this script to your build with a feed:

echo "src-git sqm_scripts_nss https://github.com/rickkdotnet/sqm-scripts-nss.git >> feeds.conf
./scripts/feeds update
./scripts/feeds install sqm-scripts-nss

Now you can find the script in menuconfig under 'Extra packages'.

## Configuration

* Just copy the nss.qos and nss.qos.help files to /usr/lib/sqm on your router
* Go to Network -> SQM QoS in luci
* Add a a queue or change your existing one
* Select your physical uplink interface (usually eth0)
* Sheck the 'enable this SQM instance' checkbox
* Enter your down and upload speeds, 95% of your actual line speed is a good ballpark figure
* Go to the queue discipline tab and select "fq_codel" as discipline and and "nss.qos" for the script
* Go to the queue discipline tab and select "fq_codel" as discipline and and "nss-rk.qos" for the script
* Configure other parameters if you want, although the defaults should work well. If you like to play with the codel interval, you can do by entering 'interval XXms' in the 'advanced option string'.
* Click "save and apply"

Expand Down Expand Up @@ -47,15 +67,6 @@ If it's working the output from tc should look something like this:
maxpacket 1518 drop_overlimit 0 new_flow_count 5081 ecn_mark 0
new_flows_len 0 old_flows_len 1

## Installation via feeds

If you're building OpenWRT yourselves, you can add this script to your build with a feed:

echo "src-git sqm_scripts_nss https://github.com/rickkdotnet/sqm-scripts-nss.git >> feeds.conf
./scripts/feeds update
./scripts/feeds install sqm-scripts-nss

Now you can find the script in menuconfig under 'Extra packages'.


## Known bugs, limitations
Expand Down
53 changes: 26 additions & 27 deletions files/usr/lib/sqm/nss-rk.qos
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
################################################################################
# nss.qos (HW Accelerated Simple Traffic Shaper)
# version 20230217a
# nss-rk.qos (HW Accelerated Simple Traffic Shaper)
# version 20230217b
#
# sqm script to use the NSS accelerated nssfq_codel qdisc
#
# Based on https://github.com/ricsc/sqm-scripts/blob/master/src/nss.qos
# and simple.qos.
# Based on simple.qos and nss.qos by ricsc.
# Modified by rickk to allow configuration via (l)uci and play nicely with
# the standard sqm scripts without throwing all kinds of errors.
#
# This script should be placed in your /usr/lib/sqm directory together with
# nss.qos.help.
# nss-rk.qos.help.
#
# To use it, select fq_codel as a queue discipline in (l)uci and nss.qos
# for the script.
#
# Works on my machine certified.
# Works on my machine (R7800 with OpenWRT 22.03.3) certified.
#
# Original can be found at https://github.com/rickkdotnet/sqm-scripts-nss
#
################################################################################

Expand Down Expand Up @@ -50,7 +51,7 @@ egress() {
# a lower codel quantum is rumoured to improve priority for interactive flows
# at lower speed interfaces.
if [ ${UPLINK} -lt 100000 ]; then
sqm_debug "Uplink speed is below 100Mb, setting codel quantum to 300"
sqm_debug "Uplink speed is below 100Mb, setting codel quantum to 300"
EQUANTUM=300
else
# use the interface mtu, this seems to work well in almost all cases
Expand All @@ -60,9 +61,8 @@ egress() {
# this allows you to set the codel interval via (l)uci eqdisc_opts
# if no interval statement is present, set a sensible default
if [[ "${EQDISC_OPTS}" != *"interval"* ]]; then
sqm_debug "No interval specified via advanced option string, going with 100ms"
# 100ms works well in most cases, unless the link speed is so slow that target > interval
# but you probably don't want/need NSS in that case anyway
sqm_debug "No interval specified via advanced option string, going with 100ms" # 100ms works well in most cases, unless the link speed is so slow that target > interval
# but you probably don't want/need NSS in that case anyway
EQDISC_OPTS="interval 100ms ${EQDISC_OPTS}"
fi

Expand Down Expand Up @@ -112,7 +112,7 @@ ingress() {
# this allows you to set the codel interval via (l)uci iqdisc_opts
# if no interval statement is present, set a sensible default
if [[ "${IQDISC_OPTS}" != *"interval"* ]]; then
sqm_debug "No interval specified via advanced option string, going with 100ms."
sqm_debug "No interval specified via advanced option string, going with 100ms."
IQDISC_OPTS="interval 100ms ${IQDISC_OPTS}"
fi

Expand All @@ -139,14 +139,14 @@ sqm_prepare_script() {
# sqm-scripts standard do_modules does not insert the necessary nss_ifb module
# load it here if it's not loaded, so we can keep all NSS changes together in this script
if [ ! -d /sys/module/nss_ifb ]; then
sqm_debug "required nss_ifb kernel module not detected, loading it now.. "
insmod nss-ifb 2>>${OUTPUT_TARGET} || return 1
sqm_debug "required nss_ifb kernel module not detected, loading it now.. "
insmod nss-ifb 2>>${OUTPUT_TARGET} || return 1
fi

# the default sqm-stop script deletes the nssifb interface
if [ ! `SILENT=1 $IP link show dev nssifb` ]; then
sqm_debug "nssifb interface does not exist, trying to create a new one.. "
$IP link add dev nssifb type nss_ifb || return 1
sqm_debug "nssifb interface does not exist, trying to create a new one.. "
$IP link add dev nssifb type nss_ifb || return 1
fi

verify_iptables || return 1
Expand All @@ -171,23 +171,23 @@ sqm_start() {

if [ "${UPLINK}" -ne 0 ];
then
CUR_DIRECTION="egress"
fn_exists egress && egress || sqm_warn "sqm_start_default: ${SCRIPT} lacks an egress() function"
sqm_debug "sqm_start: egress shaping activated"
CUR_DIRECTION="egress"
fn_exists egress && egress || sqm_warn "sqm_start_default: ${SCRIPT} lacks an egress() function"
sqm_debug "sqm_start: egress shaping activated"
else
sqm_debug "sqm_start_default: egress shaping deactivated"
SILENT=1 $TC qdisc del dev ${IFACE} root
sqm_debug "sqm_start_default: egress shaping deactivated"
SILENT=1 $TC qdisc del dev ${IFACE} root
fi

if [ "${DOWNLINK}" -ne 0 ];
then
CUR_DIRECTION="ingress"
fn_exists ingress && ingress || sqm_warn "sqm_start_default: ${SCRIPT} lacks an ingress() function"
sqm_debug "sqm_start_default: ingress shaping activated"
CUR_DIRECTION="ingress"
fn_exists ingress && ingress || sqm_warn "sqm_start_default: ${SCRIPT} lacks an ingress() function"
sqm_debug "sqm_start_default: ingress shaping activated"
else
sqm_debug "sqm_start_default: ingress shaping deactivated"
SILENT=1 $TC qdisc del dev ${DEV} root
SILENT=1 $TC qdisc del dev ${IFACE} ingress
sqm_debug "sqm_start_default: ingress shaping deactivated"
SILENT=1 $TC qdisc del dev ${DEV} root
SILENT=1 $TC qdisc del dev ${IFACE} ingress
fi

return 0
Expand Down Expand Up @@ -228,5 +228,4 @@ CUR_IFB=nssifb
# configure the WAN interface as a subinterface
# just strip off the vlan tag here
IFACE=`echo ${IFACE} | sed 's/\.[0-9]*//g'`
sqm_debug "Setting nssifb physical interface to ${IFACE}"

4 changes: 2 additions & 2 deletions openwrt/sqm-scripts-nss/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=sqm-scripts-nss
PKG_VERSION:=20230217a
PKG_RELEASE:=3
PKG_VERSION:=20230217b
PKG_RELEASE:=1

include $(INCLUDE_DIR)/package.mk

Expand Down

0 comments on commit face940

Please sign in to comment.