LINUX.ORG.RU
ФорумAdmin

iproute+приоретизация трафика+проблемы.


0

0

Доброго времени суток.

Исходные данные: есть домашняя машина, инет она получает через adsl-модем (24/1 Mbitps in/out). К этой машине подключен еще один компьютер через 100Mbit ethernet. На первой машине есть любитель иногда поиграть во что нибудь сетевое мультиплеерное, а на второй есть любитель торрента...

Задача: Настроить приоретизацию трафика на первой машине.

Как делал: Нашел статью, описавающюю процесс настройки с помощью iproute. Использую убунтовское ядро (не пересобирал):

anonymous

~ % cat /etc/ppp/adsl_qos #!/bin/sh

DEV_OUT=$2 IP=$3 QLEN_OUT=10 RATE_OUT=650 MTU_OUT=1400

DEV_IN=eth1 RATE_IN=12000 QLEN_IN=1000

RATE_LOCAL=100mbit IP_LOCAL=192.168.1.1

ICMP="match ip protocol 1 0xff" TCP="match ip protocol 6 0xff" UDP="match ip protocol 17 0xff" DPORT="match ip dport" SPORT="match ip sport" SRC="match ip src" DST="match ip dst" U32="protocol ip u32"

status() { echo "[qdisc out]" tc -s -d qdisc show dev $DEV_OUT echo echo "[class out]" tc -s -d class show dev $DEV_OUT echo echo "[filter out]" tc -s filter show dev $DEV_OUT echo

echo "-----------------------------------------------------------------" echo "[qdisc in]" tc -s -d qdisc show dev $DEV_IN echo echo "[class in]" tc -s -d class show dev $DEV_IN echo echo "[filter in]" tc -s filter show dev $DEV_IN exit }

stop(){ tc qdisc del dev $DEV_OUT root 2> /dev/null > /dev/null tc qdisc del dev $DEV_IN root 2> /dev/null > /dev/null }

anonymous
()
Ответ на: комментарий от anonymous

~ % cat /etc/ppp/adsl_qos 
#!/bin/sh

DEV_OUT=$2
IP=$3
QLEN_OUT=10
RATE_OUT=650
MTU_OUT=1400

DEV_IN=eth1
RATE_IN=12000
QLEN_IN=1000

RATE_LOCAL=100mbit
IP_LOCAL=192.168.1.1

ICMP="match ip protocol 1 0xff"
TCP="match ip protocol 6 0xff"
UDP="match ip protocol 17 0xff"
DPORT="match ip dport"
SPORT="match ip sport"
SRC="match ip src"
DST="match ip dst"
U32="protocol ip u32"


status() {
    echo "[qdisc out]"
    tc -s -d qdisc show dev $DEV_OUT
    echo
    echo "[class out]"
    tc -s -d class show dev $DEV_OUT
    echo
    echo "[filter out]"
    tc -s filter show dev $DEV_OUT
    echo

    echo "-----------------------------------------------------------------"
    echo "[qdisc in]"
    tc -s -d qdisc show dev $DEV_IN
    echo
    echo "[class in]"
    tc -s -d class show dev $DEV_IN
    echo
    echo "[filter in]"
    tc -s filter show dev $DEV_IN
    exit
}

stop(){
    tc qdisc del dev $DEV_OUT root 2> /dev/null > /dev/null
    tc qdisc del dev $DEV_IN root 2> /dev/null > /dev/null
}

anonymous
()
Ответ на: комментарий от anonymous

start_out(){ ip link set dev $DEV_OUT qlen $QLEN_OUT mtu $MTU_OUT

tc qdisc add dev $DEV_OUT root handle 1: htb default 17 tc class add dev $DEV_OUT parent 1: classid 1:1 htb rate ${RATE_OUT}kbit

tc class add dev $DEV_OUT parent 1:1 classid 1:10 htb rate $[$RATE_OUT/8]kbit ceil $[$RATE_OUT/3]kbit prio 0 tc class add dev $DEV_OUT parent 1:1 classid 1:11 htb rate 20kbit prio 1 tc class add dev $DEV_OUT parent 1:1 classid 1:12 htb rate $[$RATE_OUT/8]kbit ceil $[$RATE_OUT/3]kbit prio 2 tc class add dev $DEV_OUT parent 1:1 classid 1:13 htb rate $[$RATE_OUT/8]kbit ceil $[$RATE_OUT/3]kbit prio 3 tc class add dev $DEV_OUT parent 1:1 classid 1:14 htb rate $[$RATE_OUT/8]kbit ceil $[$RATE_OUT/3]kbit prio 4 tc class add dev $DEV_OUT parent 1:1 classid 1:15 htb rate $[$RATE_OUT/8]kbit ceil ${RATE_OUT}kbit prio 5 tc class add dev $DEV_OUT parent 1:1 classid 1:17 htb rate $[$RATE_OUT/8]kbit ceil ${RATE_OUT}kbit prio 7

# Urban Terror tc filter add dev $DEV_OUT parent 1:0 prio 0 $U32 $TCP $UDP $DPORT 27960 0xffff classid 1:10 tc filter add dev $DEV_OUT parent 1:0 prio 0 $U32 $TCP $UDP $SPORT 27960 0xffff classid 1:10

# ICMP tc filter add dev $DEV_OUT parent 1:0 prio 1 $U32 $ICMP classid 1:11

# DNS tc filter add dev $DEV_OUT parent 1:0 prio 2 $U32 $SPORT 53 0xffff classid 1:12 tc filter add dev $DEV_OUT parent 1:0 prio 2 $U32 $DPORT 53 0xffff classid 1:12

# other tc filter add dev $DEV_OUT parent 1:0 prio 3 $U32 $UDP classid 1:13 # http, https, smtp, etc. tc filter add dev $DEV_OUT parent 1:0 prio 3 $U32 $TCP $DPORT 80 0xffff classid 1:15 tc filter add dev $DEV_OUT parent 1:0 prio 3 $U32 $TCP $DPORT 443 0xffff classid 1:15 tc filter add dev $DEV_OUT parent 1:0 prio 3 $U32 $TCP $DPORT 3128 0xffff classid 1:15 tc filter add dev $DEV_OUT parent 1:0 prio 3 $U32 $TCP $DPORT 8080 0xffff classid 1:15 tc filter add dev $DEV_OUT parent 1:0 prio 3 $U32 $TCP $DPORT 6667 0xffff classid 1:15 tc filter add dev $DEV_OUT parent 1:0 prio 3 $U32 $TCP $DPORT 5222 0xffff classid 1:15

tc filter add dev $DEV_OUT parent 1:0 prio 3 $U32 $TCP $SPORT 25 0xffff classid 1:15 tc filter add dev $DEV_OUT parent 1:0 prio 3 $U32 $TCP $SPORT 80 0xffff classid 1:15 tc filter add dev $DEV_OUT parent 1:0 prio 3 $U32 $TCP $SPORT 443 0xffff classid 1:15 tc filter add dev $DEV_OUT parent 1:0 prio 3 $U32 $TCP $SPORT 6667 0xffff classid 1:15 tc filter add dev $DEV_OUT parent 1:0 prio 3 $U32 $TCP $SPORT 5222 0xffff classid 1:15

tc qdisc add dev $DEV_OUT parent 1:10 handle 10: sfq perturb 10 tc qdisc add dev $DEV_OUT parent 1:11 handle 11: sfq perturb 10 tc qdisc add dev $DEV_OUT parent 1:12 handle 12: sfq perturb 10 tc qdisc add dev $DEV_OUT parent 1:13 handle 13: sfq perturb 10 tc qdisc add dev $DEV_OUT parent 1:14 handle 14: sfq perturb 10 tc qdisc add dev $DEV_OUT parent 1:15 handle 15: sfq perturb 10 tc qdisc add dev $DEV_OUT parent 1:17 handle 17: sfq perturb 10 echo "Outbound shaping added to $DEV_OUT. Rate: ${RATE_OUT}Kbit/sec." }

anonymous
()
Ответ на: комментарий от anonymous

start_out(){
    ip link set dev $DEV_OUT qlen $QLEN_OUT mtu $MTU_OUT

    tc qdisc add dev $DEV_OUT root handle 1: htb default 17
    
    tc class add dev $DEV_OUT parent 1: classid 1:1 htb rate ${RATE_OUT}kbit

    tc class add dev $DEV_OUT parent 1:1 classid 1:10 htb rate $[$RATE_OUT/8]kbit ceil $[$RATE_OUT/3]kbit prio 0
    tc class add dev $DEV_OUT parent 1:1 classid 1:11 htb rate 20kbit prio 1
    tc class add dev $DEV_OUT parent 1:1 classid 1:12 htb rate $[$RATE_OUT/8]kbit ceil $[$RATE_OUT/3]kbit prio 2
    tc class add dev $DEV_OUT parent 1:1 classid 1:13 htb rate $[$RATE_OUT/8]kbit ceil $[$RATE_OUT/3]kbit prio 3
    tc class add dev $DEV_OUT parent 1:1 classid 1:14 htb rate $[$RATE_OUT/8]kbit ceil $[$RATE_OUT/3]kbit prio 4
    tc class add dev $DEV_OUT parent 1:1 classid 1:15 htb rate $[$RATE_OUT/8]kbit ceil ${RATE_OUT}kbit prio 5
    tc class add dev $DEV_OUT parent 1:1 classid 1:17 htb rate $[$RATE_OUT/8]kbit ceil ${RATE_OUT}kbit prio 7


    # Urban Terror
    tc filter add dev $DEV_OUT parent 1:0 prio 0 $U32 $TCP $UDP $DPORT 27960 0xffff classid 1:10
    tc filter add dev $DEV_OUT parent 1:0 prio 0 $U32 $TCP $UDP $SPORT 27960 0xffff classid 1:10

    # ICMP
    tc filter add dev $DEV_OUT parent 1:0 prio 1 $U32 $ICMP classid 1:11

    # DNS
    tc filter add dev $DEV_OUT parent 1:0 prio 2 $U32 $SPORT 53 0xffff classid 1:12
    tc filter add dev $DEV_OUT parent 1:0 prio 2 $U32 $DPORT 53 0xffff classid 1:12

    # other
    tc filter add dev $DEV_OUT parent 1:0 prio 3 $U32 $UDP classid 1:13
    
    # http, https, smtp, etc.
    tc filter add dev $DEV_OUT parent 1:0 prio 3 $U32 $TCP $DPORT 80 0xffff classid 1:15
    tc filter add dev $DEV_OUT parent 1:0 prio 3 $U32 $TCP $DPORT 443 0xffff classid 1:15
    tc filter add dev $DEV_OUT parent 1:0 prio 3 $U32 $TCP $DPORT 3128 0xffff classid 1:15
    tc filter add dev $DEV_OUT parent 1:0 prio 3 $U32 $TCP $DPORT 8080 0xffff classid 1:15
    tc filter add dev $DEV_OUT parent 1:0 prio 3 $U32 $TCP $DPORT 6667 0xffff classid 1:15
    tc filter add dev $DEV_OUT parent 1:0 prio 3 $U32 $TCP $DPORT 5222 0xffff classid 1:15

    tc filter add dev $DEV_OUT parent 1:0 prio 3 $U32 $TCP $SPORT 25 0xffff classid 1:15
    tc filter add dev $DEV_OUT parent 1:0 prio 3 $U32 $TCP $SPORT 80 0xffff classid 1:15
    tc filter add dev $DEV_OUT parent 1:0 prio 3 $U32 $TCP $SPORT 443 0xffff classid 1:15
    tc filter add dev $DEV_OUT parent 1:0 prio 3 $U32 $TCP $SPORT 6667 0xffff classid 1:15
    tc filter add dev $DEV_OUT parent 1:0 prio 3 $U32 $TCP $SPORT 5222 0xffff classid 1:15


    tc qdisc add dev $DEV_OUT parent 1:10 handle 10: sfq perturb 10
    tc qdisc add dev $DEV_OUT parent 1:11 handle 11: sfq perturb 10
    tc qdisc add dev $DEV_OUT parent 1:12 handle 12: sfq perturb 10
    tc qdisc add dev $DEV_OUT parent 1:13 handle 13: sfq perturb 10
    tc qdisc add dev $DEV_OUT parent 1:14 handle 14: sfq perturb 10
    tc qdisc add dev $DEV_OUT parent 1:15 handle 15: sfq perturb 10
    tc qdisc add dev $DEV_OUT parent 1:17 handle 17: sfq perturb 10
    
    echo "Outbound shaping added to $DEV_OUT.  Rate: ${RATE_OUT}Kbit/sec."
}

anonymous
()
Ответ на: комментарий от anonymous

start_in(){
    ip link set dev $DEV_IN qlen $QLEN_IN
    
    tc qdisc add dev $DEV_IN root handle 1: htb default 17
    
    tc class add dev $DEV_IN parent 1: classid 1:1 htb rate ${RATE_IN}kbit
    tc class add dev $DEV_IN parent 1:1 classid 1:10 htb rate $[$RATE_IN/8]kbit prio 0
    tc class add dev $DEV_IN parent 1:1 classid 1:11 htb rate $[$RATE_IN/8]kbit prio 1
    tc class add dev $DEV_IN parent 1:1 classid 1:12 htb rate $[$RATE_IN/8]kbit ceil $[$RATE_IN/3]kbit prio 2
    tc class add dev $DEV_IN parent 1:1 classid 1:13 htb rate $[$RATE_IN/8]kbit ceil $[$RATE_IN/3]kbit prio 3
    tc class add dev $DEV_IN parent 1:1 classid 1:14 htb rate $[$RATE_IN/8]kbit ceil $[$RATE_IN/3]kbit prio 4
    tc class add dev $DEV_IN parent 1:1 classid 1:15 htb rate $[$RATE_IN/8]kbit ceil ${RATE_IN}kbit prio 5
    tc class add dev $DEV_IN parent 1:1 classid 1:17 htb rate $[$RATE_IN/8]kbit ceil ${RATE_IN}kbit prio 7

    tc class add dev $DEV_IN parent 1: classid 1:2 htb rate $RATE_LOCAL prio 7

    tc filter add dev $DEV_IN parent 1:0 prio 1 $U32 $SRC $IP_LOCAL classid 1:2

    tc filter add dev $DEV_IN parent 1:0 prio 2 $U32 $ICMP classid 1:10
    tc filter add dev $DEV_IN parent 1:0 prio 2 $U32 $SPORT 53 0xffff classid 1:11
    tc filter add dev $DEV_IN parent 1:0 prio 3 $U32 $UDP classid 1:12
    tc filter add dev $DEV_IN parent 1:0 prio 3 $U32 $TCP $SPORT 80 0xffff classid 1:13
    tc filter add dev $DEV_IN parent 1:0 prio 3 $U32 $TCP $SPORT 443 0xffff classid 1:13
    tc filter add dev $DEV_IN parent 1:0 prio 3 $U32 $TCP $SPORT 3128 0xffff classid 1:13
    tc filter add dev $DEV_IN parent 1:0 prio 3 $U32 $TCP $SPORT 8080 0xffff classid 1:13

    tc qdisc add dev $DEV_IN parent 1:2 handle 2: pfifo

    tc qdisc add dev $DEV_OUT parent 1:10 handle 10: sfq perturb 10
    tc qdisc add dev $DEV_OUT parent 1:11 handle 11: sfq perturb 10
    tc qdisc add dev $DEV_OUT parent 1:12 handle 12: sfq perturb 10
    tc qdisc add dev $DEV_OUT parent 1:13 handle 13: sfq perturb 10
    tc qdisc add dev $DEV_OUT parent 1:14 handle 14: sfq perturb 10
    tc qdisc add dev $DEV_OUT parent 1:15 handle 15: sfq perturb 10
    tc qdisc add dev $DEV_OUT parent 1:17 handle 17: sfq perturb 10
    
    echo "Outbound shaping added to $DEV_OUT.  Rate: ${RATE_OUT}Kbit/sec."
}


case "$1" in
    start)
        stop
        start_in
        start_out
        ;;

    stop)
        stop
        echo "Shaping removed on $DEV_OUT/$DEV_IN."
        ;;
        
    status)
        status
        ;;
    
    *)
        echo "Usage: $0 {start|stop|status} ppp_interface ip"
esac

anonymous
()
Ответ на: комментарий от anonymous

Но вот что-то ничегоне работает:

# /etc/ppp/adsl_qos start
Illegal "rate"
Usage: ... qdisc add ... htb [default N] [r2q N]
 default  minor id of class to which unclassified packets are sent {0}
 r2q      DRR quantums are computed as rate in Bps/r2q {10}
 debug    string of 16 numbers each 0-3 {0}

... class add ... htb rate R1 [burst B1] [mpu B] [overhead O]
                      [prio P] [slot S] [pslot PS]
                      [ceil R2] [cburst B2] [mtu MTU] [quantum Q]
 rate     rate allocated to this class (class can still borrow)
 burst    max bytes burst which can be accumulated during idle period {computed}
 mpu      minimum packet size used in rate computations
 overhead per-packet size overhead used in rate computations
 ceil     definite upper class rate (no borrows) {rate}
 cburst   burst but for ceil {computed}
 mtu      max packet size we create rate map for {1600}
 prio     priority of leaf; lower are served first {0}
 quantum  how much bytes to serve from leaf at once {use r2q}

много раз повторяется

TC HTB version 3.3
Unknown qdisc "1:10", hence option "handle" is unparsable
Unknown qdisc "1:11", hence option "handle" is unparsable
Unknown qdisc "1:12", hence option "handle" is unparsable
Unknown qdisc "1:13", hence option "handle" is unparsable
Unknown qdisc "1:14", hence option "handle" is unparsable
Unknown qdisc "1:15", hence option "handle" is unparsable
Unknown qdisc "1:17", hence option "handle" is unparsable
Outbound shaping added to .  Rate: 650Kbit/sec.
Error: either "dev" is duplicate, or "10" is a garbage.
Cannot find device "root"
Error: Qdisc "1:" is classless.
Error: Qdisc "1:1" is classless.
Error: Qdisc "1:1" is classless.
Error: Qdisc "1:1" is classless.
Error: Qdisc "1:1" is classless.
Error: Qdisc "1:1" is classless.
Error: Qdisc "1:1" is classless.
Error: Qdisc "1:1" is classless.
Unknown filter "1:0", hence option "prio" is unparsable
Unknown filter "1:0", hence option "prio" is unparsable
Unknown filter "1:0", hence option "prio" is unparsable
Unknown filter "1:0", hence option "prio" is unparsable
Unknown filter "1:0", hence option "prio" is unparsable
Unknown filter "1:0", hence option "prio" is unparsable
Unknown filter "1:0", hence option "prio" is unparsable
Unknown filter "1:0", hence option "prio" is unparsable
Unknown filter "1:0", hence option "prio" is unparsable
Unknown filter "1:0", hence option "prio" is unparsable
Unknown filter "1:0", hence option "prio" is unparsable
Unknown filter "1:0", hence option "prio" is unparsable
Unknown filter "1:0", hence option "prio" is unparsable
Unknown filter "1:0", hence option "prio" is unparsable
Unknown filter "1:0", hence option "prio" is unparsable
Unknown filter "1:0", hence option "prio" is unparsable
Unknown filter "1:0", hence option "prio" is unparsable
Unknown qdisc "1:10", hence option "handle" is unparsable
Unknown qdisc "1:11", hence option "handle" is unparsable
Unknown qdisc "1:12", hence option "handle" is unparsable
Unknown qdisc "1:13", hence option "handle" is unparsable
Unknown qdisc "1:14", hence option "handle" is unparsable
Unknown qdisc "1:15", hence option "handle" is unparsable
Unknown qdisc "1:17", hence option "handle" is unparsable
Outbound shaping added to .  Rate: 650Kbit/sec.

anonymous
()
Ответ на: комментарий от anonymous

Те сообщения где неправильное форматирование -- не считаются. Помогите разобраться. Заранее спасибо.

anonymous
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.