htb+beginner+error

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Good day all
So at log last I did my script
We have a 256kbite connection.This scrip runs on my gateway box(the same
for script for eth1(ext) and eth0(int)
I want to limit all other traffic to 10kbites but when I do it I give me
this error:

HTB quantum of class 10034 is to small.consider r2q <7>htb*g j=42801780

Here is my script.If you have any Idea to better it let me know.Its a
bit from here and there and some of my own

#!/bin/bash
DEV=eth1
RATEUP=256

#To get stats
if [ "$1" = "stats" ]
then
        echo "[qdisc]"
        tc -s qdisc show dev $DEV
        echo "[class]"
        tc -s class show dev $DEV
        #echo "[filter]"
        #tc -s filter show dev $DEV
        #echo "[iptables]"
        exit
fi
                                                                                                 

#Reset
tc qdisc del dev $DEV root

if [ "$1" = "stop" ]
then
        echo "Shaping removed on $DEV."
        exit
fi

###########################################################
#
# Outbound Shaping (limits total bandwidth to RATEUP)

# set queue size to give latency of about 2 seconds on low-prio packets
ip link set dev $DEV qlen 30

# changes mtu on the outbound device.  Lowering the mtu will result
# in lower latency but will also cause slightly lower throughput due 
# to IP and TCP protocol overhead.
ip link set dev $DEV mtu 1000

# add HTB root qdisc
tc qdisc add dev $DEV root handle 1: htb default 23

# add main rate limit classes
tc class add dev $DEV parent 1: classid 1:1 htb rate ${RATEUP}kbit

# add leaf classes - We grant each class at LEAST it's "fair share" of
bandwidth.
#                    this way no class will ever be starved by another
class.  Each
#                    class is also permitted to consume all of the
available bandwidth
#                    if no other classes are in use.
tc class add dev $DEV parent 1:1 classid 1:20 htb rate ${RATEUP}kbit
ceil ${RATEUP}kbit prio 0
tc class add dev $DEV parent 1:1 classid 1:21 htb rate 192kbit ceil
256kbit prio 1
tc class add dev $DEV parent 1:1 classid 1:22 htb rate 54kbit ceil
256kbit prio 2
tc class add dev $DEV parent 1:1 classid 1:23 htb rate 10kbit ceil
256kbit prio 3

# attach qdisc to leaf classes - here we at SFQ to each priority class. 
SFQ insures that
#                                within each class connections will be
treated (almost) fairly.
tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10
tc qdisc add dev $DEV parent 1:21 handle 21: sfq perturb 10
tc qdisc add dev $DEV parent 1:22 handle 22: sfq perturb 10
tc qdisc add dev $DEV parent 1:23 handle 23: sfq perturb 10



tc filter add dev $DEV protocol ip parent 1:0 prio 2 u32 \
   match ip dport 20 0xffff flowid 1:22

tc filter add dev $DEV protocol ip parent 1:0 prio 0 u32 \
   match ip dport 22 0xffff flowid 1:20


tc filter add dev $DEV protocol ip parent 1:0 prio 0 u32 \
   match ip dport 3000 0xffff flowid 1:20

tc filter add dev $DEV protocol ip parent 1:0 prio 2 u32 \
   match ip dport 25 0xffff flowid 1:22
tc filter add dev $DEV protocol ip parent 1:0 prio 2 u32 \
   match ip dport 110 0xffff flowid 1:22
tc filter add dev $DEV protocol ip parent 1:0 prio 2 u32 \
   match ip sport 25 0xffff flowid 1:22

tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 \
   match ip dport 80 0xffff flowid 1:21
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 \
   match ip dport 443 0xffff flowid 1:21

tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 \
   match ip dport 1443 0xffff flowid 1:21
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 \
    match ip sport 1443 0xffff flowid 1:21
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 \
   match ip dport 1494 0xffff flowid 1:21
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 \
    match ip sport 1494 0xffff flowid 1:21
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 \
   match ip dport 4400 0xffff flowid 1:21
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 \
    match ip sport 4400 0xffff flowid 1:21


tc filter add dev $DEV protocol ip parent 1:0 prio 0 u32 \
    match ip dport 15000 0xffff flowid 1:20
tc filter add dev $DEV protocol ip parent 1:0 prio 0 u32 \
    match ip dport 15001 0xffff flowid 1:20
tc filter add dev $DEV protocol ip parent 1:0 prio 0 u32 \
    match ip dport 15002 0xffff flowid 1:20
tc filter add dev $DEV protocol ip parent 1:0 prio 0 u32 \
    match ip dport 15003 0xffff flowid 1:20
tc filter add dev $DEV protocol ip parent 1:0 prio 0 u32 \
    match ip dport 15004 0xffff flowid 1:20
tc filter add dev $DEV protocol ip parent 1:0 prio 0 u32 \
    match ip dport 15005 0xffff flowid 1:20
tc filter add dev $DEV protocol ip parent 1:0 prio 0 u32 \
    match ip dport 15006 0xffff flowid 1:20
tc filter add dev $DEV protocol ip parent 1:0 prio 0 u32 \
    match ip dport 15007 0xffff flowid 1:20
tc filter add dev $DEV protocol ip parent 1:0 prio 0 u32 \
    match ip dport 15008 0xffff flowid 1:20
tc filter add dev $DEV protocol ip parent 1:0 prio 0 u32 \
    match ip dport 15009 0xffff flowid 1:20
tc filter add dev $DEV protocol ip parent 1:0 prio 0 u32 \
    match ip dport 15010 0xffff flowid 1:20


_______________________________________________
LARTC mailing list / LARTC@xxxxxxxxxxxxxxx
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux