All of lore.kernel.org
 help / color / mirror / Atom feed
* [LARTC] Little problem with IMQ
@ 2004-08-09 15:29 Lenthir
  2004-08-09 21:03 ` Andre Correa
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Lenthir @ 2004-08-09 15:29 UTC (permalink / raw)
  To: lartc

When I try to put all incoming traffic to IMQ on PREROUTING I can't discern
traffic to LAN and traffic to server.

When I try to put only INPUT traffic to IMQ... I can't discern traffic from
LAN and from internet.

Help me plizz to put all incoming traffic to one IMQ device and all
outcoming to other IMQ device and (it's very important) discern traffic to
clients and server.

(Sorry for my English... It is not well.)

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LARTC] Little problem with IMQ
  2004-08-09 15:29 [LARTC] Little problem with IMQ Lenthir
@ 2004-08-09 21:03 ` Andre Correa
  2004-08-10  8:47 ` Lenthir
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Andre Correa @ 2004-08-09 21:03 UTC (permalink / raw)
  To: lartc


Lenthir, please be more specific in your question. We need to know about 
your environment, kernel, iptables and distro versions. We need to know 
what you want to do, what you are doing now and what is not working. 
This way we can try to help you. Your iptables and tc rules will help as 
well.

This is not about your english, it is about describing your scenario and 
problem in details.

Cheers.

Andre Correa


Lenthir wrote:
> When I try to put all incoming traffic to IMQ on PREROUTING I can't discern
> traffic to LAN and traffic to server.
> 
> When I try to put only INPUT traffic to IMQ... I can't discern traffic from
> LAN and from internet.
> 
> Help me plizz to put all incoming traffic to one IMQ device and all
> outcoming to other IMQ device and (it's very important) discern traffic to
> clients and server.
> 
> (Sorry for my English... It is not well.)
> 
> _______________________________________________
> LARTC mailing list / LARTC@mailman.ds9a.nl
> http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
> 
> 

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LARTC] Little problem with IMQ
  2004-08-09 15:29 [LARTC] Little problem with IMQ Lenthir
  2004-08-09 21:03 ` Andre Correa
@ 2004-08-10  8:47 ` Lenthir
  2004-08-11  3:05 ` Roy
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Lenthir @ 2004-08-10  8:47 UTC (permalink / raw)
  To: lartc

[-- Attachment #1: Type: text/plain, Size: 509 bytes --]

Ok.... I attached my script...

rc.htb is now working for me. But packet addressed to server don't match
correct class.

htb1.2rc3 don't work because i can't discern traffic to LAN and traffic to
server.

in script
prs it is address of server
lan[0], lan[1] - lists of IP address to each interfaces... (defined in
dev_lan)

I tried on two types of compiled kernel - 2.4.26 with only IMQ patch and
2.4.26 with IMQ and NAT patch.
I don't see any differences...

I have iptables 1.2.11 compiled with the kernel.

[-- Attachment #2: rc.htb --]
[-- Type: application/octet-stream, Size: 7834 bytes --]

#!/bin/bash
#
# rc.htb 1.2_rc3, (C)Lenthir 2oo4, GNU GPL
# 2004-08-03 18:00
VER=1.2
MAX=4999
#######################
#Konfiguracja interfejsów:
dev_wan="eth0"                                  #interfejs WAN
dev_lan="eth1 eth2"                             #interfejsy LAN - 4999 u¿ytkowników MAX

lan[0]="`/sbin/lan200` `/sbin/wan200`"          #adresy IP dla interfejsów lan, bez IP serwera
lan[1]=`/sbin/lan201`

prs="217.153.104.34"                            #IP zewnêtrzny serwera

ile[0]=`echo ${lan[0]}|awk '{print NF}'`        #ilo¶ci komputerów w podsieciach, bez serwera
ile[1]=`echo ${lan[1]}|awk '{print NF}'`

TC=/sbin/tc                                     #¶cie¿ka do tc
IPTABLES=/usr/local/sbin/iptables               #¶cie¿ka do iptables
MODPROBE=/sbin/modprobe                         #¶cie¿ka do modprobe
IP=/sbin/ip                                     #¶cie¿ka do ip

u_r2q=10 					#r2q
u_quantum=1500					#quantum

#Konfiguracja prêdko¶ci (1Mbit=1024kbit=1048576bity=0,125MB/s=128kB/s=131072B/s):
#Wszystkie prêdko¶ci s± rzeczywiste. (ok. 98% prêdko¶ci teoretycznej dla WAN)
wan_dwl[0]=480                                  #maksymalna prêdko¶æ downloadu interfejsów WAN w kbit/s minus 5kbit/s na pasmo awaryjne
wan_upl[0]=480
ratio_d=1                                       # 1 = 100%
ratio_u=1

#Konfiguracja serwera
srv_dwl=16                                      #minimalna prêdko¶æ downloadu z serwera
srv_upl=16                                      #minimalna prêdko¶æ uploadu z serwera

#######################

i=0;ilosc=0
for x in $dev_lan                               #ilo¶æ komputerów
        do
        let "ilosc=$ilosc+${ile[$i]}"
        let "i=$i+1"
	done
if [[ $ilosc -ge $MAX ]]
        then
        echo "Niedopuszczalnie du¿o komputerów!"
        exit 1
        fi

#######################

stop()
{
$TC qdisc del root dev imq0 2> /dev/null		#input
$TC qdisc del root dev imq1 2> /dev/null		#output
$IP link set imq0 down                                  #opuszczanie interfejsów
$IP link set imq1 down
/etc/init.d/rc.iptables restart
}
start()
{ stop

$IPTABLES -t mangle -N znaczek
$IPTABLES -t mangle -A znaczek -d 192.168.200.5 -j MARK --set-mark 2
$IPTABLES -t mangle -A znaczek -d 192.168.201.5 -j MARK --set-mark 2
$IPTABLES -t mangle -A znaczek -s $prs -j MARK --set-mark 2
$IPTABLES -t mangle -A znaczek -d $prs -j MARK --set-mark 2
i=0;j=3
for x in $dev_lan
        do
        for usr in ${lan[$i]}
                do
                $IPTABLES -t mangle -A znaczek -s $usr -j MARK --set-mark $j
                $IPTABLES -t mangle -A znaczek -d $usr -j MARK --set-mark $j
                let "j=j+1"
                done
        let "i=i+1"
        done
$IPTABLES -t mangle -A znaczek -j RETURN

# download
$IPTABLES -t mangle -A FORWARD -i $dev_wan -j znaczek
$IPTABLES -t mangle -A INPUT -i $dev_wan -j znaczek
$IPTABLES -t mangle -A FORWARD -i $dev_wan -j IMQ --todev 0
$IPTABLES -t mangle -A INPUT -i $dev_wan -j IMQ --todev 0

tmp=$(echo "($wan_dwl-$srv_dwl)%$ilosc" | bc)
srv_dwl=$(echo "$srv_dwl+$tmp" | bc)
min=$(echo "($wan_dwl-$srv_dwl)/$ilosc" | bc)
max=$(echo "$wan_dwl*$ratio_d" | bc)

echo " Ilo¶æ komputerów: $ilosc"
echo "%===================================================================%"
echo " Ustawianie kolejki imq0"
echo " Maksymalny download: $max kbit/s"
echo " Minimalny download serwera: $srv_dwl kbit/s"
echo " Minimalny download userów: $min kbit/s"
echo " "

$TC qdisc add dev imq0 root handle 1:0 htb default 1 r2q $u_r2q
$TC class add dev imq0 parent 1:0 classid 1:1 htb rate ${wan_dwl[0]}kbit ceil ${wan_dwl[0]}kbit

# Serwer
$TC class add dev imq0 parent 1:1 classid 1:2 htb rate ${srv_dwl}kbit ceil ${max}kbit quantum $u_quantum
$TC qdisc add dev imq0 parent 1:2 sfq perturb 10
$TC filter add dev imq0 protocol ip parent 1:0 handle 2 fw flowid 1:2

i=0;j=3
for x in $dev_lan
        do
        for usr in ${lan[$i]}
                do
                $TC class add dev imq0 parent 1:1 classid 1:$j htb rate ${min}kbit ceil ${max}kbit quantum $u_quantum
                $TC qdisc add dev imq0 parent 1:$j sfq perturb 10
                $TC filter add dev imq0 protocol ip parent 1:0 handle $j fw flowid 1:$j
                let "j=j+1"
                done
        let "i=i+1"
        done
$IP link set imq0 up

# upload
$IPTABLES -t mangle -A FORWARD -o $dev_wan -j znaczek
$IPTABLES -t mangle -A OUTPUT -o $dev_wan -j znaczek
$IPTABLES -t mangle -A FORWARD -o $dev_wan -j IMQ --todev 1
$IPTABLES -t mangle -A OUTPUT -o $dev_wan -j IMQ --todev 1

tmp=$(echo "($wan_upl-$srv_upl)%$ilosc" | bc)
srv_upl=$(echo "$srv_upl+$tmp" | bc)
min=$(echo "($wan_upl-$srv_upl)/$ilosc" | bc)
max=$(echo "$wan_upl*$ratio_u" | bc)

echo " Ustawianie kolejki imq1"
echo " Maksymalny upload: $max kbit/s"
echo " Minimalny upload serwera: $srv_upl kbit/s"
echo " Minimalny upload userów: $min kbit/s"
echo "%===================================================================%"

$TC qdisc add dev imq1 root handle 2:0 htb default 1 r2q $u_r2q
$TC class add dev imq1 parent 2:0 classid 2:1 htb rate ${wan_upl[0]}kbit ceil ${wan_upl[0]}kbit

$TC class add dev imq1 parent 2:1 classid 2:2 htb rate ${srv_upl}kbit ceil ${max}kbit quantum $u_quantum
$TC qdisc add dev imq1 parent 2:2 sfq perturb 10
$TC filter add dev imq1 protocol ip parent 2:0 handle 2 fw flowid 2:2

i=0;j=3
for x in $dev_lan
        do
        for usr in ${lan[$i]}
                do
                $TC class add dev imq1 parent 2:1 classid 2:$j htb rate ${min}kbit ceil ${max}kbit quantum $u_quantum
                $TC qdisc add dev imq1 parent 2:$j sfq perturb 10
                $TC filter add dev imq1 protocol ip parent 2:0 handle $j fw flowid 2:$j
                let "j=j+1"
                done
        let "i=i+1"
        done
$IP link set imq1 up
}
echo "rc.htb 1.2_rc3, (C)Lenthir 2oo4, GNU GPL"
echo "2004-08-03 18:00"
case "$1" in
    'start')
      echo "Uruchamianie kolejkowania..."
      start
      echo "Chyba wszystko OK"
      exit 0
      ;;
    'stop')
      echo -n "Zatrzymywanie kolejkowania..."
      stop
      echo " wykonano."
      ;;
    'restart')
      echo "Restartowanie kolejkowania..."
      start
      echo "Chyba wszystko OK"
      ;;
    'status')
      echo "Klasy na interfejsie imq0 - download"
      echo "%====================================%"
      $TC class show dev imq0 | grep root
      $TC class show dev imq0 | grep -v root | sort | nl
      echo "Klasy na interfejsie imq1 - upload"
      echo "%====================================%"
      $TC class show dev imq1 | grep root
      $TC class show dev imq1 | grep -v root | sort | nl
      ;;
    'stat')
      if [[ "$2" == "" ]]; then
        echo "Script need second argument - adress IP"
        exit 1
      elif [[ "$2" == "server" ]]; then
        watch -d -n 1 "echo \"Serwer:\" && tc -s class show dev imq0 | grep -A 3 \"1:2 \" && tc -s class show dev imq1 | grep -A 3 \"2:2 \""
      else
      i=0;j=3
        for x in $dev_lan
        do
        for usr in ${lan[$i]}
                do
                if [[ "$2" == "$usr" ]]; then
                        watch -d -n 1 "echo \"Download: \" && tc -s class show dev imq0 | grep -A 3 \"1:$j \" && echo && echo \"Upload: \" && tc -s class show dev imq1 | grep -A 3 \"2:$j \""
                        echo "Zakoñczono."
                        exit 0
                fi
                let "j=j+1"
                done
        let "i=i+1"
        done
      fi
      ;;
    *)
      echo
      echo "U¿ycie: rc.htb start|stop|restart|status"
      echo "rc.htb stat <server|adress IP>"
      exit 1
      ;;
esac

[-- Attachment #3: htb1.2rc3 --]
[-- Type: application/octet-stream, Size: 7892 bytes --]

#!/bin/bash
#
# rc.htb 1.2_rc3, (C)Lenthir 2oo4, GNU GPL
# 2004-08-03 18:00
VER=1.2
MAX=4999
#######################
#Konfiguracja interfejsów:
dev_wan="eth0"                                  #interfejs WAN
dev_lan="eth1 eth2"                             #interfejsy LAN - 4999 u¿ytkowników MAX

lan[0]="`/sbin/lan200` `/sbin/wan200`"          #adresy IP dla interfejsów lan, bez IP serwera
lan[1]=`/sbin/lan201`

prs="217.153.104.34"                            #IP zewnêtrzny serwera

ile[0]=`echo ${lan[0]}|awk '{print NF}'`        #ilo¶ci komputerów w podsieciach, bez serwera
ile[1]=`echo ${lan[1]}|awk '{print NF}'`

TC=/sbin/tc                                     #¶cie¿ka do tc
IPTABLES=/usr/local/sbin/iptables               #¶cie¿ka do iptables
MODPROBE=/sbin/modprobe                         #¶cie¿ka do modprobe
IP=/sbin/ip                                     #¶cie¿ka do ip

u_r2q=10                                        #r2q
u_quantum=1500                                  #quantum

#Konfiguracja prêdko¶ci (1Mbit=1024kbit=1048576bity=0,125MB/s=128kB/s=131072B/s):
#Wszystkie prêdko¶ci s± rzeczywiste. (ok. 98% prêdko¶ci teoretycznej dla WAN)
wan_dwl[0]=480                                  #maksymalna prêdko¶æ downloadu interfejsów WAN w kbit/s minus 5kbit/s na pasmo awaryjne
wan_upl[0]=480
ratio_d=1                                       # 1 = 100%
ratio_u=1

#Konfiguracja serwera
srv_dwl=16                                      #minimalna prêdko¶æ downloadu z serwera
srv_upl=16                                      #minimalna prêdko¶æ uploadu z serwera

#######################

i=0;ilosc=0
for x in $dev_lan                               #ilo¶æ komputerów
        do
        let "ilosc=$ilosc+${ile[$i]}"
        let "i=$i+1"
	done
if [[ $ilosc -ge $MAX ]]
        then
        echo "Niedopuszczalnie du¿o komputerów!"
        exit 1
        fi

#######################

stop()
{
$TC qdisc del root dev imq0 2> /dev/null		#input
$TC qdisc del root dev imq1 2> /dev/null		#output
$IP link set imq0 down                                  #opuszczanie interfejsów
$IP link set imq1 down
/etc/init.d/rc.iptables restart
}
start()
{ stop

$IPTABLES -t mangle -N znaczek
$IPTABLES -t mangle -A znaczek -d $prs -j MARK --set-mark 1
$IPTABLES -t mangle -A znaczek -s $prs -j MARK --set-mark 2
i=0;j=3
for x in $dev_lan
        do
        for usr in ${lan[$i]}
                do
                $IPTABLES -t mangle -A znaczek -s $usr -j MARK --set-mark $j
                $IPTABLES -t mangle -A znaczek -d $usr -j MARK --set-mark $j
                let "j=j+1"
                done
        let "i=i+1"
        done
$IPTABLES -t mangle -A znaczek -j RETURN

# download
$IPTABLES -t mangle -A PREROUTING -i $dev_wan -j znaczek
$IPTABLES -t mangle -A PREROUTING -i $dev_wan -j IMQ --todev 0

tmp=$(echo "($wan_dwl-$srv_dwl)%$ilosc" | bc)
srv_dwl=$(echo "$srv_dwl+$tmp" | bc)
min=$(echo "($wan_dwl-$srv_dwl)/$ilosc" | bc)
max=$(echo "$wan_dwl*$ratio_d" | bc)

echo " Ilo¶æ komputerów: $ilosc"
echo "%===================================================================%"
echo " Ustawianie kolejki imq0"
echo " Maksymalny download: $max kbit/s"
echo " Minimalny download serwera: $srv_dwl kbit/s"
echo " Minimalny download userów: $min kbit/s"
echo " "

$TC qdisc add dev imq0 root handle 1:0 htb default 1 r2q $u_r2q
$TC class add dev imq0 parent 1:0 classid 1:1 htb rate ${wan_dwl[0]}kbit ceil ${wan_dwl[0]}kbit

# Serwer
$TC class add dev imq0 parent 1:1 classid 1:2 htb rate ${srv_dwl}kbit ceil ${max}kbit quantum $u_quantum
$TC qdisc add dev imq0 parent 1:2 sfq perturb 10
$TC filter add dev imq0 protocol ip parent 1:0 handle 1 fw flowid 1:2
$TC filter add dev imq0 protocol ip parent 1:0 u32 match ip dst $prs flowid 1:2
$TC filter add dev imq0 protocol ip parent 1:0 u32 match ip dst 127.0.0.1 flowid 1:2
$TC filter add dev imq0 protocol ip parent 1:0 u32 match ip dst 192.168.200.5 flowid 1:2
$TC filter add dev imq0 protocol ip parent 1:0 u32 match ip dst 192.168.201.5 flowid 1:2

i=0;j=3
for x in $dev_lan
        do
        for usr in ${lan[$i]}
                do
                $TC class add dev imq0 parent 1:1 classid 1:$j htb rate ${min}kbit ceil ${max}kbit quantum $u_quantum
                $TC qdisc add dev imq0 parent 1:$j sfq perturb 10
                $TC filter add dev imq0 protocol ip parent 1:0 handle $j fw flowid 1:$j
                let "j=j+1"
                done
        let "i=i+1"
        done
$IP link set imq0 up

# upload
$IPTABLES -t mangle -A POSTROUTING -o $dev_wan -j znaczek
$IPTABLES -t mangle -A POSTROUTING -o $dev_wan -j IMQ --todev 1

tmp=$(echo "($wan_upl-$srv_upl)%$ilosc" | bc)
srv_upl=$(echo "$srv_upl+$tmp" | bc)
min=$(echo "($wan_upl-$srv_upl)/$ilosc" | bc)
max=$(echo "$wan_upl*$ratio_u" | bc)

echo " Ustawianie kolejki imq1"
echo " Maksymalny upload: $max kbit/s"
echo " Minimalny upload serwera: $srv_upl kbit/s"
echo " Minimalny upload userów: $min kbit/s"
echo "%===================================================================%"

$TC qdisc add dev imq1 root handle 2:0 htb default 1 r2q $u_r2q
$TC class add dev imq1 parent 2:0 classid 2:1 htb rate ${wan_upl[0]}kbit ceil ${wan_upl[0]}kbit

$TC class add dev imq1 parent 2:1 classid 2:2 htb rate ${srv_upl}kbit ceil ${max}kbit quantum $u_quantum
$TC qdisc add dev imq1 parent 2:2 sfq perturb 10
$TC filter add dev imq1 protocol ip parent 2:0 handle 2 fw flowid 2:2

i=0;j=3
for x in $dev_lan
        do
        for usr in ${lan[$i]}
                do
                $TC class add dev imq1 parent 2:1 classid 2:$j htb rate ${min}kbit ceil ${max}kbit quantum $u_quantum
                $TC qdisc add dev imq1 parent 2:$j sfq perturb 10
                $TC filter add dev imq1 protocol ip parent 2:0 handle $j fw flowid 2:$j
                let "j=j+1"
                done
        let "i=i+1"
        done
$IP link set imq1 up
}
echo "rc.htb 1.2_rc3, (C)Lenthir 2oo4, GNU GPL"
echo "2004-08-03 18:00"
case "$1" in
    'start')
      echo "Uruchamianie kolejkowania..."
      start
      echo "Chyba wszystko OK"
      exit 0
      ;;
    'stop')
      echo -n "Zatrzymywanie kolejkowania..."
      stop
      echo " wykonano."
      ;;
    'restart')
      echo "Restartowanie kolejkowania..."
      start
      echo "Chyba wszystko OK"
      ;;
    'status')
      echo "Klasy na interfejsie imq0 - download"
      echo "%====================================%"
      $TC class show dev imq0 | grep root
      $TC class show dev imq0 | grep -v root | sort | nl
      echo "Klasy na interfejsie imq1 - upload"
      echo "%====================================%"
      $TC class show dev imq1 | grep root
      $TC class show dev imq1 | grep -v root | sort | nl
      ;;
    'stat')
      if [[ "$2" == "" ]]; then
        echo "Script need second argument - adress IP"
        exit 1
      elif [[ "$2" == "server" ]]; then
        watch -d -n 1 "echo \"Serwer:\" && tc -s class show dev imq0 | grep -A 3 \"1:2 \" && tc -s class show dev imq1 | grep -A 3 \"2:2 \""
      else
      i=0;j=3
        for x in $dev_lan
        do
        for usr in ${lan[$i]}
                do
                if [[ "$2" == "$usr" ]]; then
                        watch -d -n 1 "echo \"Download: \" && tc -s class show dev imq0 | grep -A 3 \"1:$j \" && echo && echo \"Upload: \" && tc -s class show dev imq1 | grep -A 3 \"2:$j \""
                        echo "Zakoñczono."
                        exit 0
                fi
                let "j=j+1"
                done
        let "i=i+1"
        done
      fi
      ;;
    *)
      echo
      echo "U¿ycie: rc.htb start|stop|restart|status"
      echo "rc.htb stat <server|adress IP>"
      exit 1
      ;;
esac

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LARTC] Little problem with IMQ
  2004-08-09 15:29 [LARTC] Little problem with IMQ Lenthir
  2004-08-09 21:03 ` Andre Correa
  2004-08-10  8:47 ` Lenthir
@ 2004-08-11  3:05 ` Roy
  2004-08-11  7:47 ` Lenthir
  2004-08-11  9:56 ` Lenthir
  4 siblings, 0 replies; 6+ messages in thread
From: Roy @ 2004-08-11  3:05 UTC (permalink / raw)
  To: lartc

Originaly this always was imq problem, because prerouting and postrouting
hooks do not alow do what you want.
you can only capture all ingress, or all egress which is same as usual tc
just unstable.

you can change imq source to hook on other places, like input and forward.

or you can use my version where I already did that.

http://pupa.da.ru/imq/


----- Original Message ----- 
From: "Lenthir" <lth@wp.pl>
To: "$LARTC" <lartc@mailman.ds9a.nl>
Sent: Tuesday, August 10, 2004 11:47 AM
Subject: Re: [LARTC] Little problem with IMQ


> rc.htb is now working for me. But packet addressed to server don't match
> correct class.
>
> htb1.2rc3 don't work because i can't discern traffic to LAN and traffic to
> server.
>
> in script
> prs it is address of server
> lan[0], lan[1] - lists of IP address to each interfaces... (defined in
> dev_lan)
>
> I tried on two types of compiled kernel - 2.4.26 with only IMQ patch and
> 2.4.26 with IMQ and NAT patch.
> I don't see any differences...
>
> I have iptables 1.2.11 compiled with the kernel.
>
>
>

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LARTC] Little problem with IMQ
  2004-08-09 15:29 [LARTC] Little problem with IMQ Lenthir
                   ` (2 preceding siblings ...)
  2004-08-11  3:05 ` Roy
@ 2004-08-11  7:47 ` Lenthir
  2004-08-11  9:56 ` Lenthir
  4 siblings, 0 replies; 6+ messages in thread
From: Lenthir @ 2004-08-11  7:47 UTC (permalink / raw)
  To: lartc

Hm... nice patch :)

I'll write if I have some problems.
Now I'm testing :)
_______________________________________________
LARTC mailing list / LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LARTC] Little problem with IMQ
  2004-08-09 15:29 [LARTC] Little problem with IMQ Lenthir
                   ` (3 preceding siblings ...)
  2004-08-11  7:47 ` Lenthir
@ 2004-08-11  9:56 ` Lenthir
  4 siblings, 0 replies; 6+ messages in thread
From: Lenthir @ 2004-08-11  9:56 UTC (permalink / raw)
  To: lartc

[-- Attachment #1: Type: text/plain, Size: 143 bytes --]

OK... I rewrite my script.... all is OK, but server outgoing traffic can't
match correct class.

I attached my new script. (in develop now :d)

[-- Attachment #2: htb1.3en --]
[-- Type: application/octet-stream, Size: 5649 bytes --]

#!/bin/bash
#
# rc.htb 1.3, (C)Lenthir 2oo4, GNU GPL
# 2004-08-11 15:00
VER=1.3
MAX=4990
#######################
#Configuration

lan="`/sbin/lan200` `/sbin/wan200` `/sbin/lan201`" #IP adresses, without server IP
srv="217.153.104.34"                               #outgoing server IP

ile=`echo ${lan}|awk '{print NF}'`                 #this is always correct :P

TC=/sbin/tc                                        #where is tc
MODPROBE=/sbin/modprobe                            #where is modprobe
IP=/sbin/ip                                        #where is ip

#u_r2q=10                                          #r2q
u_quantum=1500                                     #quantum

#Connection speed configuration
wan_dwl[0]=480                                  #MAX for your ISP (download)
wan_upl[0]=480                                  #(upload)
ratio_d=1                                       #MAX ratio for users (download) - 1 = 100%
ratio_u=1                                       #(upload)

#Konfiguracja serwera
srv_dwl=16                                      #MIN for server download
srv_upl=16                                      #MIN for server upload

#######################

if [[ $ile -ge $MAX ]]
        then
        echo "Too many computers!"
        exit 1
        fi

#######################

stop()
{
$TC qdisc del root dev imq 2> /dev/null
$IP link set imq down
}
start()
{ stop

if [[ u_r2q=="" ]]; then
$TC qdisc add dev imq root handle 1:0 htb
else
$TC qdisc add dev imq root handle 1:0 htb r2q $u_r2q
fi

# download
tmp=$(echo "($wan_dwl-$srv_dwl)%$ile" | bc)
srv_dwl=$(echo "$srv_dwl+$tmp" | bc)
min=$(echo "($wan_dwl-$srv_dwl)/$ile" | bc)
max=$(echo "$wan_dwl*$ratio_d" | bc)

echo " Computers: $ile"
echo "%===================================================================%"
echo " Setting download classes."
echo " Max download - ISP: $max kbit/s"
echo " Min download - server: $srv_dwl kbit/s"
echo " Min download - LAN: $min kbit/s"
echo " "

$TC class add dev imq parent 1:0 classid 1:1 htb rate ${wan_dwl[0]}kbit ceil ${wan_dwl[0]}kbit

# Server
$TC class add dev imq parent 1:1 classid 1:3 htb rate ${srv_dwl}kbit ceil ${max}kbit quantum $u_quantum
$TC qdisc add dev imq parent 1:3 sfq perturb 10
$TC filter add dev imq protocol ip parent 1:0 u32 match ip dst $srv flowid 1:3

i=0;j=5
for usr in $lan
        do
        $TC class add dev imq parent 1:1 classid 1:$j htb rate ${min}kbit ceil ${max}kbit quantum $u_quantum
        $TC qdisc add dev imq parent 1:$j sfq perturb 10
        $TC filter add dev imq protocol ip parent 1:0 u32 match ip dst $usr flowid 1:$j
        let "j=j+2"
        done

# upload
tmp=$(echo "($wan_upl-$srv_upl)%$ile" | bc)
srv_upl=$(echo "$srv_upl+$tmp" | bc)
min=$(echo "($wan_upl-$srv_upl)/$ile" | bc)
max=$(echo "$wan_upl*$ratio_u" | bc)

echo " Setting upload classes."
echo " Max upload - ISP: $max kbit/s"
echo " Min upload - server: $srv_upl kbit/s"
echo " Min upload - LAN: $min kbit/s"
echo "%===================================================================%"

$TC class add dev imq parent 1:0 classid 1:2 htb rate ${wan_upl[0]}kbit ceil ${wan_upl[0]}kbit

$TC class add dev imq parent 1:2 classid 1:4 htb rate ${srv_upl}kbit ceil ${max}kbit quantum $u_quantum
$TC qdisc add dev imq parent 1:4 sfq perturb 10
$TC filter add dev imq protocol ip parent 1:0 u32 match ip src $srv flowid 1:4             #don't work!!
$TC filter add dev imq protocol ip parent 1:0 u32 match ip src 127.0.0.1 flowid 1:4        #don't know why!
$TC filter add dev imq protocol ip parent 1:0 u32 match ip src 192.168.200.5 flowid 1:4
$TC filter add dev imq protocol ip parent 1:0 u32 match ip src 192.168.201.5 flowid 1:4

i=0;j=6
for usr in $lan
        do
        $TC class add dev imq parent 1:2 classid 1:$j htb rate ${min}kbit ceil ${max}kbit quantum $u_quantum
        $TC qdisc add dev imq parent 1:$j sfq perturb 10
        $TC filter add dev imq protocol ip parent 1:0 u32 match ip src $usr flowid 1:$j
        let "j=j+2"
        done

$IP link set imq up
}
echo "rc.htb 1.3, (C)Lenthir 2oo4, GNU GPL"
echo "2004-08-11 15:00"
case "$1" in
    'start')
      echo "Starting HTB..."
      start
      echo "Done."
      exit 0
      ;;
    'stop')
      echo -n "Stopping HTB..."
      stop
      echo " done."
      ;;
    'restart')
      echo "Restarting HTB..."
      start
      echo "Done."
      ;;
    'status')
      echo "Class on interface imq!"
      echo "%====================================%"
      $TC class show dev imq | grep root
      $TC class show dev imq | grep -v root | sort | nl
      ;;
    'stat')
      if [[ "$2" == "" ]]; then
        echo "Script need second argument - adress IP"
        exit 1
      elif [[ "$2" == "server" ]]; then
        watch -d -n 1 "echo \"Serwer:\" && tc -s class show dev imq | grep -A 3 \"1:3 \" && tc -s class show dev imq | grep -A 3 \"1:4 \""
      else
      i=0;j=5
        for usr in ${lan[$i]}
                do
                if [[ "$2" == "$usr" ]]; then
                        watch -d -n 1 "echo \"Download: \" && tc -s class show dev imq | grep -A 3 \"1:$j \" && echo && echo \"Upload: \" && tc -s class show dev imq | grep -A 3 \"1:$[$j+1] \""
                        echo "Done."
                        exit 0
                fi
                let "j=j+2"
                done
      fi
      ;;
    *)
      echo
      echo "Use: rc.htb start|stop|restart|status"
      echo "or: rc.htb stat <server|adress IP>"
      exit 1
      ;;
esac

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-08-11  9:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-09 15:29 [LARTC] Little problem with IMQ Lenthir
2004-08-09 21:03 ` Andre Correa
2004-08-10  8:47 ` Lenthir
2004-08-11  3:05 ` Roy
2004-08-11  7:47 ` Lenthir
2004-08-11  9:56 ` Lenthir

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.