From: Andre Correa <andre.correa@pobox.com>
To: lartc@vger.kernel.org
Subject: Re: [LARTC] Htb, imq and sfq traffic shaping
Date: Wed, 26 Jan 2005 16:18:16 +0000 [thread overview]
Message-ID: <41F7C2C8.3000308@pobox.com> (raw)
In-Reply-To: <20050124150857.7d530d34@drak.aard.net>
You shouldn't point your filters to the sfq qdisc, point then to the
leaf classes that have sfq qdiscs as child.
Andre
Ixen Gerthannes wrote:
> Hello,
> I wrote a simple traffic shaping script (below) that should have allowed me to shape my internet traffic a bit (ppp0 - adsl 128kbit/64kbit; local interface eth0).
> The script works only partially - the speed is being limited but too much. Without running this script my download rate is about 10kBytes (with second computer also downloading at about 6kBytes). After running it my download speed decreases to about 1..2kBytes and so the second computer.
> Could you tell me what have I done wrong ?
>
> Thank you for replies.
> Ixen
>
> --------------
> My configuration:
> Celeron 450MHz, 256MB RAM
> Kernel 2.6.9 patched for imq support (imq devices compiled into kernel)
> iptables 1.2.11 (also patched for imq)
>
> Script:
> #!/bin/sh
>
> DOWNIF='imq0'
> UPIF='imq1'
> rc_done=" done"
> rc_failed=" failed"
>
> TC='/sbin/tc'
> IPTABLES='/usr/sbin/iptables'
> IFCONFIG='/sbin/ifconfig'
> MODPROBE='/sbin/modprobe'
>
> return=$rc_done
>
> tc_reset ()
> {
> # remove old devices if any
> echo "Removing old root qdisc..."
> $TC qdisc del dev $DOWNIF root
> $TC qdisc del dev $UPIF root
> }
>
> tc_status ()
> {
> echo "===================="
> echo "[qdisc - $DOWNIF]"
> $TC -s qdisc show dev $DOWNIF
> echo "[qdisc - $UPIF]"
> $TC -s qdisc show dev $UPIF
> echo "----------------------------------------"
> echo
> echo "[class - $DOWNIF]"
> $TC -s class show dev $DOWNIF
> echo "[class - $UPIF]"
> $TC -s class show dev $UPIF
> }
>
> tc_showfilter ()
> {
> echo "[filter - $DOWNIF]"
> $TC -s filter show dev $DOWNIF
> echo "[filter - $UPIF]"
> $TC -s filter show dev $UPIF
> }
>
> case "$1" in
>
> start)
> echo "Starting traffic shaping..."
> tc_reset
>
> # setup imq devices - imq0 for download, imq1 for upload
> # $MODPROBE imq numdevs 2
>
> $IFCONFIG imq0 up
> $IFCONFIG imq1 up
>
> # ROOT DEVICE
> echo " Setting root devices for $DOWNIF and $UPIF"
>
> # download
> $TC qdisc add dev $DOWNIF root handle 1: htb default 99
> $TC qdisc add dev $DOWNIF parent 1: classid 1:10 htb rate 128kbit
> # upload
> $TC qdisc add dev $UPIF root handle 1: htb default 98
> $TC class add dev $UPIF parent 1: classid 1:20 htb rate 64kbit
>
> # ADDRESSES
> echo " 192.168.0.30"
> # 192.168.0.30
> $TC class add dev $DOWNIF parent 1:10 classid 1:1000 htb rate 48kbit ceil 128kbit
> $TC qdisc add dev $DOWNIF parent 1:1000 handle 1000 sfq
> $TC filter add dev $DOWNIF parent 1:0 protocol ip prio 200 handle 1000 fw classid 1:1000
>
> $TC class add dev $UPIF parent 1:20 classid 1:2000 htb rate 24kbit ceil 64kbit
> $TC qdisc add dev $UPIF parent 1:2000 handle 2000 sfq
> $TC filter add dev $UPIF parent 1:0 protocol ip prio 200 handle 2000 fw classid 1:2000
>
> $IPTABLES -t mangle -A POSTROUTING -d 192.168.0.30 -j MARK --set-mark 1000
> $IPTABLES -t mangle -A POSTROUTING -s 192.168.0.30 -j MARK --set-mark 2000
>
> # 192.168.0.178
> echo " 192.168.0.178"
> $TC class add dev $DOWNIF parent 1:10 classid 1:1010 htb rate 16kbit ceil 100kbit
> $TC qdisc add dev $DOWNIF parent 1:1010 handle 1010 sfq
> $TC filter add dev $DOWNIF parent 1:0 protocol ip prio 200 handle 1010 fw classid 1:1010
>
> $TC class add dev $UPIF parent 1:20 classid 1:2010 htb rate 8kbit ceil 60kbit
> $TC qdisc add dev $UPIF parent 1:2010 handle 2010 sfq
> $TC filter add dev $UPIF parent 1:0 protocol ip prio 200 handle 2010 fw classid 1:2010
>
> $IPTABLES -t mangle -A POSTROUTING -d 192.168.0.178 -j MARK --set-mark 1010
> $IPTABLES -t mangle -A POSTROUTING -s 192.168.0.178 -j MARK --set-mark 2010
>
> # 192.168.0.55
> echo " 192.168.0.55"
> $TC class add dev $DOWNIF parent 1:10 classid 1:1020 htb rate 16kbit ceil 100kbit
> $TC qdisc add dev $DOWNIF parent 1:1020 handle 1020 sfq
> $TC filter add dev $DOWNIF parent 1:0 protocol ip prio 200 handle 1020 fw classid 1:1020
>
> $TC class add dev $UPIF parent 1:20 classid 1:2020 htb rate 8kbit ceil 60kbit
> $TC qdisc add dev $UPIF parent 1:2020 handle 2020 sfq
> $TC filter add dev $UPIF parent 1:0 protocol ip prio 200 handle 2020 fw classid 1:2020
>
> $IPTABLES -t mangle -A POSTROUTING -d 192.168.0.55 -j MARK --set-mark 1020
> $IPTABLES -t mangle -A POSTROUTING -s 192.168.0.55 -j MARK --set-mark 2020
>
> # other
> echo " other..."
> $TC class add dev $DOWNIF parent 1:10 classid 1:99 htb rate 100bit ceil 8kbit
> $TC class add dev $UPIF parent 1:20 classid 1:98 htb rate 100bit ceil 8kbit
>
> # route traffic
> echo " Traffic redirecting"
> # download
> $IPTABLES -t mangle -A POSTROUTING -d 192.168.0.0/24 -j IMQ --todev 0
> #upload
> $IPTABLES -t mangle -A POSTROUTING -s 192.168.0.0/24 -j IMQ --todev 1
>
> tc_status
> ;;
>
> stop)
> echo -n "Stopping traffic shaper..."
> tc_reset || return=$rc_failed
> echo -e "$return"
> ;;
>
> restart|reload)
> $0 stop && $0 start || return=$rc_failed
> ;;
>
> stats|status)
> tc_status
> ;;
>
> filter)
> tc_showfilter
> ;;
>
> *)
> echo "Usage: $0 {start|stop|restart|stats|filter}"
> esac
> _______________________________________________
> LARTC mailing list / LARTC@mailman.ds9a.nl
> http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
>
>
--
-----------------------------------------------------------------------
Confidentiality Notice: This e-mail communication and any attachments
may contain confidential and privileged information for the use of the
designated recipients named above. If you are not the intended
recipient, you are hereby notified that you have received this
communication in error and that any review, disclosure, dissemination,
distribution or copying of it or its contents is prohibited. If you have
received this communication in error, please notify me immediately by
replying to this message and deleting it from your computer.
Thank you.
_______________________________________________
LARTC mailing list / LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
prev parent reply other threads:[~2005-01-26 16:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-24 14:08 [LARTC] Htb, imq and sfq traffic shaping Ixen Gerthannes
2005-01-24 17:26 ` George Alexandru Dragoi
2005-01-25 12:23 ` Andy Furniss
2005-01-26 16:18 ` Andre Correa [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=41F7C2C8.3000308@pobox.com \
--to=andre.correa@pobox.com \
--cc=lartc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.