Linux-Bulgaria.ORG
навигация

 

начало

пощенски списък

архив на групата

семинари ...

документи

как да ...

 

 

Предишно писмо Следващо писмо Предишно по тема Следващо по тема По Дата По тема (thread)

Re: lug-bg: HTB problem


  • Subject: Re: lug-bg: HTB problem
  • From: "hell" <hell@xxxxxxxxx>
  • Date: Mon, 3 Nov 2003 17:26:00 -0800

Eto ti oste edin "working" sample:

#!/bin/sh
#

cd /root

TC=tc

$TC qdisc del dev eth0 root
$TC qdisc add dev eth0 root handle 1: htb default 1000
$TC class add dev eth0 parent 1: classid 1:1 htb rate 30mbit
$TC filter add dev eth0 parent 1:0 protocol ip prio 7 u32 match ip dst
0.0.0.0/0 flowid 1:2


$TC class add dev eth0 parent 1:1 classid 1:2 htb rate 30mbit burst 10k
$TC filter add dev eth0 parent 1:1 protocol ip prio 7 u32 match ip dst
0.0.0.0/0 flowid 1:2
$TC qdisc add dev eth0 parent 1:2 sfq


#---------------Izhodqst 1
$TC class add dev eth0 parent 1:2 classid 1:10 htb rate 2mbit ceil 7Mbit
burst 2k
$TC qdisc add dev eth0 parent 1:10 sfq perturb 10
$TC filter add dev eth0 parent 1:2 protocol ip prio 2 u32 match ip dst
<ip.1> flowid 1:10

#---------------Izhodqst 2
$TC class add dev eth0 parent 1:2 classid 1:11 htb rate 2mbit ceil 7Mbit
burst 2k
$TC qdisc add dev eth0 parent 1:11 sfq perturb 10
$TC filter add dev eth0 parent 1:2 protocol ip prio 2 u32 match ip dst
<ip.2> flowid 1:11

#---------------Izhodqst 3
$TC class add dev eth0 parent 1:2 classid 1:12 htb rate 2mbit ceil 7Mbit
burst 2k
$TC qdisc add dev eth0 parent 1:12 sfq perturb 10
$TC filter add dev eth0 parent 1:2 protocol ip prio 2 u32 match ip dst
<ip.3> flowid 1:12

#---------------Izhodqst 4
$TC class add dev eth0 parent 1:2 classid 1:13 htb rate 2mbit ceil 7Mbit
burst 2k
$TC qdisc add dev eth0 parent 1:13 sfq perturb 10
$TC filter add dev eth0 parent 1:2 protocol ip prio 2 u32 match ip dst
<ip.4> flowid 1:13

#---------------Izhodqst ostanali
$TC class add dev eth0 parent 1:2 classid 1:14 htb rate 5mbit ceil 30Mbit
burst 2k
$TC qdisc add dev eth0 parent 1:14 sfq perturb 10
$TC filter add dev eth0 parent 1:2 protocol ip prio 3 u32 match ip dst
0.0.0.0/0 flowid 1:14


#---------------Default class
$TC class add dev eth0 parent 1:1 classid 1:1000 htb rate 1mbit ceil 7mbit
burst 2k
$TC qdisc add dev eth0 parent 1:1000 sfq perturb 10

Imai predvid, che ako imash 2 interface-a eth0 i eth1, za da shape-ish
trafika ot internet kum klientite i obratno, trqbva da dobavish dev eth1 s
oste tolkova klasove, kakto i da ne oburkash dst  i src.


----- Original Message -----
From: "Qsin" <qsin@xxxxxxxxxxxx>
To: <lug-bg@xxxxxxxxxxxxxxxxxx>
Sent: Monday, November 03, 2003 6:34 AM
Subject: lug-bg: HTB problem


> Нужно ми беше решение за HTB подобно на описания от Никола Колев в
>
> http://www.mail-archive.com/lug-bg@xxxxxxxxxxxxxxxxxx/msg15376.html
>
> Като начало реших да опитам скрипта без никакво изменение:
>
> #!/bin/bash
>
>
>
> # изходящ интерфейс
>
> dev=eth0
>
>
>
> # път до tc
>
> tc=/sbin/tc
>
>
>
> htb_stats ()
>
> {
>
> # show class stats
>
> $tc -s -d class show dev $dev
>
> # show qdisc stats
>
> $tc -s -d qdisc show dev $dev
>
> } #htb_stats
>
>
>
> htb_stop ()
>
> {
>
> # remove all qdiscs from $dev
>
> $tc qdisc del dev $dev root &>/dev/null
>
> } # htb_stop
>
>
>
> htb_start ()
>
> {
>
> set -x
>
>
>
> # attach root discipline
>
> $tc qdisc add dev $dev root handle 1: htb default 1000 r2q 10
>
>
>
> # клас за клиент с гарантирани 256Кбита
>
> $tc class add dev $dev parent 1: classid 1:10 htb rate 256Kbit
>
> $tc filter add dev $dev protocol ip parent 1:0 prio 4 u32 \
>
> match ip dst 192.168.0.119 flowid 1:10
>
> $tc qdisc add dev $dev parent 1:10 handle 10: sfq perturb 20
>
>
>
> # клас за клиент с гарантирани 128Кбита
>
> $tc class add dev $dev parent 1: classid 1:20 htb rate 128Kbit
>
> $tc filter add dev $dev protocol ip parent 1:0 prio 4 u32 \
>
> match ip dst 192.168.0.210 flowid 1:20
>
> $tc qdisc add dev $dev parent 1:20 handle 20: sfq perturb 20
>
>
>
> # клас за клиент с гарантирани 64Кбита
>
> $tc class add dev $dev parent 1: classid 1:30 htb rate 64Kbit
>
> $tc filter add dev $dev protocol ip parent 1:0 prio 4 u32 \
>
> match ip dst 192.168.0.11 flowid 1:30
>
> $tc qdisc add dev $dev parent 1:30 handle 30: sfq perturb 20
>
>
>
> # default клас, в който попадат всички останали
>
> # за него заделяме 64Кбита
>
>
>
> $tc class add dev $dev parent 1:0 classid 1:1000 htb \
>
> rate 64Kbit ceil 64Kbit
>
> $tc qdisc add dev $dev parent 1:1000 handle 1000: sfq perturb 20
>
> } # htb_start
>
>
>
> case "$1" in
>
>
>
>     ### START ###
>
>         start)
>
>             htb_start
>
>         ;;
>
>
>
>     ### STOP ###
>
>         stop)
>
>             htb_stop
>
>         ;;
>
>
>
>     ### RESTART ###
>
>         restart)
>
>             $0 stop
>
>             $0 start
>
>         ;;
>
>
>
>     ### STATS ###
>
>         stats)
>
>             htb_stats
>
>         ;;
>
>
>
>     ### default ###
>
>         *)
>
>     echo "Usage: " `basename $0` "{start|stop|restart|stats}"
>
> esac
>
>
>
>
>
> При което получих следното със рязко забавяне на машината:
>
>
>
> /htb.3 start
>
>
>
> + /sbin/tc qdisc add dev eth0 root handle 1: htb default 1000 r2q 10
>
> + /sbin/tc class add dev eth0 parent 1: classid 1:10 htb rate 256Kbit
>
> + /sbin/tc filter add dev eth0 protocol ip parent 1:0 prio 4 u32 match ip
> dst 192.168.0.119 flowid 1:10
>
> RTNETLINK answers: Invalid argument
>
> + /sbin/tc qdisc add dev eth0 parent 1:10 handle 10: sfq perturb 20
>
> + /sbin/tc class add dev eth0 parent 1: classid 1:20 htb rate 128Kbit
>
> + /sbin/tc filter add dev eth0 protocol ip parent 1:0 prio 4 u32 match ip
> dst 192.168.0.210 flowid 1:20
>
> RTNETLINK answers: Invalid argument
>
> + /sbin/tc qdisc add dev eth0 parent 1:20 handle 20: sfq perturb 20
>
> + /sbin/tc class add dev eth0 parent 1: classid 1:30 htb rate 64Kbit
>
> + /sbin/tc filter add dev eth0 protocol ip parent 1:0 prio 4 u32 match ip
> dst 192.168.0.11 flowid 1:30
>
> RTNETLINK answers: Invalid argument
>
> + /sbin/tc qdisc add dev eth0 parent 1:30 handle 30: sfq perturb 20
>
> + /sbin/tc class add dev eth0 parent 1:0 classid 1:1000 htb rate 64Kbit
ceil
> 64Kbit
>
> + /sbin/tc qdisc add dev eth0 parent 1:1000 handle 1000: sfq perturb 20
>
>
>
> А и трафика през мойта машина (192.168.0.210) нямаще нищо общо с 128 Kbit
>
>
>
> Явор Атанасов
>
>
============================================================================
> A mail-list of Linux Users Group - Bulgaria (bulgarian linuxers).
> http://www.linux-bulgaria.org - Hosted by Internet Group Ltd. - Stara
Zagora
> To unsubscribe: http://www.linux-bulgaria.org/public/mail_list.html
>
============================================================================
>

============================================================================
A mail-list of Linux Users Group - Bulgaria (bulgarian linuxers).
http://www.linux-bulgaria.org - Hosted by Internet Group Ltd. - Stara Zagora
To unsubscribe: http://www.linux-bulgaria.org/public/mail_list.html
============================================================================



 

наши приятели

 

линукс за българи
http://linux-bg.org

FSA-BG
http://fsa-bg.org

OpenFest
http://openfest.org

FreeBSD BG
http://bg-freebsd.org

KDE-BG
http://kde.fsa-bg.org/

Gnome-BG
http://gnome.cult.bg/

проект OpenFMI
http://openfmi.net

NetField Forum
http://netField.ludost.net/forum/

 

 

Linux-Bulgaria.ORG

Mailing list messages are © Copyright their authors.