HFSC is a Linux classifier very efficient. In conjunction with iptables connmark and layer7, it provides a very powerful solution for qos on Linux
For the sake of completeness, there are another page reporting experiences with hfsc: http://www.voip-info.org/wiki/view/QoS+Linux+with+HFSC
This new one howto shows how hfsc can be used in combination with other linux features: connmark and layer7, provided from iptables.
For people who want just download the (latest) code:
last version is always at: https://github.com/k0smik0/e-hfsc (a little howto is in file header)
direct link to file is https://raw2.github.com/k0smik0/e-hfsc/master/e-hfsc
Instead, for people who want read the code right here:
For the sake of completeness, there are another page reporting experiences with hfsc: http://www.voip-info.org/wiki/view/QoS+Linux+with+HFSC
This new one howto shows how hfsc can be used in combination with other linux features: connmark and layer7, provided from iptables.
For people who want just download the (latest) code:
last version is always at: https://github.com/k0smik0/e-hfsc (a little howto is in file header)
direct link to file is https://raw2.github.com/k0smik0/e-hfsc/master/e-hfsc
Instead, for people who want read the code right here:
#!/bin/bash
# encoding: UTF-8
#
# HFSC enhanced script for gain voip, interactive and http traffic, allowing also p2p
#
# heavily based on Bliziński's hfsc script, from http://automatthias.wordpress.com/
#
# // license
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# // license
#
# References:
# http://www.voip-info.org/wiki/view/QoS+Linux+with+HFSC
# http://www.nslu2-linux.org/wiki/HowTo/EnableTrafficShaping
# http://www.cs.cmu.edu/~hzhang/HFSC/main.html
# ABOUT:
# - egress traffic (from internal to external):
# 1. is handled directly, applying rules on physical interface (eth*)
# 2. is shaped granularly, using tc classes and filters
# - ingress traffic:
# 1. is handled using ifb interface
# 2. is shaped using tc ingress qdisc (a better classification has to come)
# HOWTO:
# 1) you have ifb interfaces available in your kernel
# 2) every section has its relative howto, see each ones
# Specify parameters of your xDSL. Give values slightly lower than the
# nominal ones. For example, my line is 8000/348, so I specify 8000/320.
# Uplink and downlink speeds
DOWNLINK=8000
UPLINK=320 # not max (348)
# Device that connects you to the Internet
DEV=eth1
# ifb device used to shape ingress traffic
IFB=ifb0
# IP addresses of the VoIP phones,
# if none, set VOIPIPS=""
VOIP_IPS="192.168.0.200"
MAX_VOIP_UPLINK=${UPLINK} #max
# PROTO/PORTS SYNTAX - BE CAREFUL
# proto1,proto2:multiple_ports_comma_separated|port-range:[c/s]
# where: proto1,proto2: tcp,udp, and c/s is "client/server"
# i.e. "tcp:24650-24690:c" means "tcp ports from 24650 to 24690 as client"
#
# "c" and "s" are optionals:
# if specified, they are used only, respectively,
# "c" for destination traffic (acting as client),
# "s" for source (acting as server)
#
# so, if you have a server listening on tcp 12345 port, use "tcp:12345:s",
# while if you have a http server, use "tcp:80,443:cs", since your server
# listens on 80 and 443 but your box is also probably a client for external
# http server (hence "c")
# VoIP telephony
VOIP_PROTOS="sip rtp rtsp"
#VOIP_PORTS="udp:5060,5061 udp:4000-4099:cs udp:16150-16199:cs" # 10000:11000 5000:5059 8000:8016 5004 1720 1731"
VOIP_PORTS="udp:5060,5061 udp:4000-4099:cs udp:16384-16482:cs" # 10000:11000 5000:5059 8000:8016 5004 1720 1731"
# Interactive class: ssh, telnet, dns, vnc, openvpn, irc
INTERACTIVE_PORTS="tcp:22 tcp:23:c udp:53:c tcp:5900,5901 udp:1190 tcp:6667-6670:c"
# WWW, jabber and IRC
BROWSING_PORTS="tcp:80:c tcp:443:c tcp:8080-8082:c"
# The lowest priority traffic: eDonkey, Bittorrent, etc. ...