NetBSD ALTQ

playing with TOS vs. DiffServ bits

Requirements

Re-compile your kernel for enabling the ALTQ options.

Preliminaries

Evaluate maximum bandwidth by means of physical device capability

dmesg | grep ^vioif
dmesg | grep ^xennet

and against some network path (another network vs public) to take intermediate hops into account including modems

By means of FTP (choose your closest mirror)

export PKG_PATH=ftp://ftp.ee.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/8.0/All/
#export PKG_PATH=ftp://ftp.fr.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/8.0/All/
export PASSIVE_FTP=yes
ftp -a $PKG_PATH
bye

By means of iPerf

pkg_add -v iperf3
pkg_info | grep iperf3

Routing & ECN

sysctl -w net.inet.ip.forwarding=1      
sysctl -w net.inet6.ip6.forwarding=1
sysctl -w net.inet.tcp.ecn.enable=1  

cat >> /etc/sysctl.conf <<-EOF
net.inet.ip.forwarding=1      
net.inet6.ip6.forwarding=1
net.inet.tcp.ecn.enable=1
EOF

Setting up ALTQ

Start with a very low overall bandwidth just for testing. Here PRIQ for simplicity. ICMP and UDP priority, from 0 to 15, the latter being the highest priority. Choose your protocol number carefully.

vi /etc/altq.conf # new file

interface xennet0 bandwidth xxxK priq
class priq xennet0 classicmp NULL priority 14
class priq xennet0 classudp NULL priority 13
class priq xennet0 classlow NULL priority 0 default
filter xennet0 classicmp 0 0 0 0 1
filter xennet0 classudp 0 0 0 0 0 17

interface xennet1 bandwidth xxxK priq
class priq xennet1 classicmp NULL priority 14
class priq xennet1 classudp NULL priority 13
class priq xennet1 classlow NULL priority 0 default
filter xennet1 classicmp 0 0 0 0 1
filter xennet1 classudp 0 0 0 0 17

Now if you tag the packets from another router or yourself, using a conditioner, eventually get rid of the protocol number (write 0 instead) and add the tos keyword and value to further classify your network stream. Beware about ToS vs. DiffServ.

ICMP -- 1
TCP -- 6
UDP -- 17

tos -- 0x10
tos -- 0x60
tos -- 0x

The manual says that class name must be unique per interface, this means we can use same name for differents interfaces.

echo altqd=yes >> /etc/rc.conf
/etc/rc.d/altqd start

Acceptance

ALTQ provides some statistics by itself

altqstat -i xennet0
altqstat -i xennet1

TCP first

iperf3 --time 0 -c x.x.x.x

meanwhile UDP

iperf3 --time 0 -u -c x.x.x.x -p 5202

then ICMP

ping -f x.x.x.x

You might need to change the UDP bandwidth manually, see the iperf3 manual. Also notice there are two more columns with the UDP output of iperf3.

Additional notes

Sniff

tcpdump -i NETIF host ENDPOINT -vvv

Alternatives to iPerf3

pkgsrc -- net/netperf
pkgsrc -- net/aria2

Resources

QoS https://nethence.com/lectures/network07-qos.slides.pdf

QoS Resources https://nethence.com/lectures/network07-qos.resources.pdf

preliminaries

Public iPerf3 servers https://iperf.fr/iperf-servers.php

Public Iperf3 servers https://iperf.cc/

altq

Protocol Numbers https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml

altqd traffic shaping example https://wiki.netbsd.org/tutorials/altqd_traffic_shaping_example/

altq.conf – ALTQ configuration file https://man.netbsd.org/altq.conf.5

ALTQ: Alternate Queueing for BSD UNIX (version 3.1) https://www.iijlab.net/~kjc/software/ https://www2.sonycsl.co.jp/person/kjc/kjc/software.html

ALTQ Tips https://www.iijlab.net/~kjc/software/TIPS.txt https://www2.sonycsl.co.jp/person/kjc/software/TIPS.txt

(deprecated –> NPF) https://www.netbsd.org/docs/network/pf.html#altq

src/usr.sbin/altq/altqd/altq.conf.samples/ http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.sbin/altq/altqd/altq.conf.samples/?only_with_tag=MAIN

acceptance

ping – send ICMP ECHO_REQUEST packets to network hosts https://man.netbsd.org/ping.8 –> Flood

Change between iPerf 2.0, iPerf 3.0 and iPerf 3.1 https://iperf.fr/iperf-doc.php#3change –> Setting DSCP/TOS bit vectors (-S)

iPerf 3 user documentation https://iperf.fr/iperf-doc.php#3doc –> -S, –tos n

benchmarks/netperf - The NetBSD Packages Collection http://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/benchmarks/netperf/README.html

net/aria2 - The NetBSD Packages Collection http://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/net/aria2/README.html

List of IP protocol numbers https://en.wikipedia.org/wiki/List_of_IP_protocol_numbers


GUIDES | LECTURES | BENCHMARKS | SMTP HEALTH