Get-rid Bufferbloat and Speed Up your Network with SQM in Linux


This posts will explain how to eliminates network buffer (delay/lag) with free open source software called SQM (Smart Queue Management)

Avatar

Zuhri

  |  3 min reads

Introduction #

Smart Queue Management , or “SQM” is shorthand for an integrated network system that performs better per-packet/per flow network scheduling, active queue length management (AQM), traffic shaping/rate limiting, and QoS (prioritization).

Notes: This adjustment will require bit sacrifies to our ISP bandwidth, for example in my network topology to get full of reliable low frequent buffer that cut off about half size, the ideal is just about 5-10% of size that happen because im not using cable into ISP so that what i’ve got.

Before we go to installation, it better to test your internet speed first in here, if there is no X, congrats! you can skip this.

Installation #

Installing dependency packages that require make git or if you using debian-derivative follow below.

apt update
apt install make git

Next step is, clone this github repo here with this command.

git clone https://github.com/tohojo/sqm-scripts.git
cd sqm-scripts

After that you need to install it.

sudo make install 

The previous command will create config file that you need to change to fit into your device network inteface, my case is eth0 (ethernet cable).

Notes: if you dont know what your, just type ip a or ifconfig.

# This command will copying default.conf into {dev}.iface.conf, which my case eth0.iface.conf.
# Then modified your config file.

cp /etc/sqm/default.conf /etc/sqm/eth0.iface.conf
micro /etc/sqm/eth0.iface.conf

This my config file, you need to create changes value in UPLINK and DOWNLINK variable.

Notes: to calculate what your value you need cut it into 5-10% of size ISP bandwidth my case 20Mbps, just for remember my case is over wireless! so, i go with 11Mbps which mean my value is 11000kbps by both varible, then save it.

# Default SQM conf; the variables defined here will be applied to all
# interfaces. To override values for a particular interface, copy this file to

# <dev>Aiface.conf (e.g., "eth0.iface.conf" for eth0).
#
# When using ifupdown, the interface config file needs to exist for sqm-scripts
# to be activated on that interface. However, these defaults are still applied,
# so the interface config can be empty.

# Uplink  Downlink values are in kbps
UPLINK=11000
DOWNLINK=11000

# SQM recipe to use. For more information, see /usr/lib/sqm/*.help
SCRIPT=piece_of_cake.qos

# Optional/advanced config

#ENABLED=1
#QDISC=cake

#LLAM=tc_stab
#LINKLAYER=none
#OVERHEAD=0
#STAB_MTU=2047
#STAB_TSIZE=512
#STAB_MPU=0

#ILIMIT=
#ELIMIT=
#ITARGET=
#ETARGET=

# ECN ingress resp. egress. Values are ECN or NOECN.
#IECN=ECN
#EECN=ECN

# Extra qdisc options ingress resp. egress
#IQDISC_OPTS=""
#EQDISC_OPTS=""

# CoDel target
#TARGET=5ms

#ZERO_DSCP_INGRESS=1
#IGNORE_DSCP_INGRESS=1

Next is you need to run systemd services, to make it start on boot by default.

Notes: Again, in my case is eth0.

systemctl enable --now sqm@eth0.service

Then check services status.

systemctl status sqm@eth0.service

If show something like that, you’re done.

● sqm@eth0.service - SQM scripts for iface eth0
     Loaded: loaded (/lib/systemd/system/sqm@.service; enabled; preset: enabled)
     Active: active (exited) since Fri 2025-04-04 13:17:03 WIB; 1 day 4h ago
   Main PID: 436 (code=exited, status=0/SUCCESS)
        CPU: 444ms

Apr 04 13:17:02 router systemd[1]: Starting sqm@eth0.service - SQM scripts for iface eth0...
Apr 04 13:17:02 router start-sqm[436]: Starting SQM script: piece_of_cake.qos on eth0, in: 11000 Kbps, out: 11000 Kbps
Apr 04 13:17:03 router start-sqm[436]: piece_of_cake.qos was started on eth0 successfully
Apr 04 13:17:03 router systemd[1]: Finished sqm@eth0.service - SQM scripts for iface eth0.

Then check here again.

Want to uninstall it?

systemctl disable --now sqm@eth0.service

Go to previous sqm-scripts cloned again, then type.

make uninstall

Conclusion #

After we develop our infrastructure network, so necessary to optimize it to prevent bufferbloat (lag), the impact will significantly boost and create benefit if you have something real-time purpose like gaming, selfhosted or whatever.