Vyatta – QOS – Quality of service

Качество на услугата (QoS – Quality of service) е функция, която дава възможност на мрежовите администратори да идентифицират различни транспортни потоци и да ги управляват в съответствие с индивидуалните им изисквания. Vyatta има различни механизми за QoS управление на трафика, които преминават през интерфейсите. Някои от тях се отнася само за входящ трафик а други само за изходящ.
1. Механизмът drop tail се прилага само за изходящ трафик. Той осигурява чист FIFO (First In First Out) queuing. С други думи, пакетите с данни се изпращат в същия ред в който пристигат. Има само една опашка за целият трафик и всички пакети се третират еднакво. С други думи, няма приоритизация на трафика.
2. fair queue механизма се прилага само за изходящ трафик. В този алгоритъм имаме установени от протокол, източник адрес и / или адреса на получателя. По този начин имаме по справедлив достъп до мрежовите ресурси. С други думи, повече от един поток може да използва по-голямата част от честотната лента.
3. Механизмът rate limit се отнася само за изходящ трафик. Този алгоритъм пропуска пакетите, пристигащи в размер които не надвишават административно определения лимит. Възможно е, обаче, препълване на буфера и влошаване на връзките при повече от зададения размер.
4. Механизмът traffic shaper се прилага само за изходящ трафик. Този алгоритъм дава възможност за доста по финна настройка на лимитиране на трафика.
5. Механизмът traffic limiter се прилага само за входящ трафик. Целият трафик e в рамките на един поток, който когато пристигне в повече от зададената честотната лента отпада.

QOS – Based shaper

set interfaces ethernet eth1 duplex full
set interfaces ethernet eth1 speed 1000
 
set qos-policy traffic-limiter SHAPER-IN class 10 bandwidth 128kbit
set qos-policy traffic-limiter SHAPER-IN class 10 match 1 ip source address 172.16.10.253/32
set interfaces ethernet eth1 qos-policy in SHAPER-IN
 
set qos-policy traffic-shaper SHAPER-OUT default bandwidth 128kbit
set qos-policy traffic-shaper SHAPER-OUT class 10 bandwidth 128kbit
set qos-policy traffic-shaper SHAPER-OUT class 10 match 1 ip destination address 172.16.10.253/32
set interfaces ethernet eth1 qos-policy out SHAPER-OUT
 
vyatta@vyatta# show interfaces
 ethernet eth0 {
     address 93.155.130.11/28
     hw-id 00:0c:29:93:44:22
 }
 ethernet eth1 {
     address 172.16.10.254/24
     duplex full
     hw-id 00:0c:29:93:44:2c
     qos-policy {
         in SHAPER-IN
         out SHAPER-OUT
     }
      speed 1000
 }
 loopback lo {
 }
[edit]
 
vyatta@vyatta# show qos-policy
 traffic-limiter SHAPER-IN {
     class 10 {
         bandwidth 128kbit
         match 1 {
             ip {
                 source {
                     address 172.16.10.253/32
                 }
             }
         }
     }
 }
 traffic-shaper SHAPER-OUT {
     class 10 {
         bandwidth 128kbit
         match 1 {
             ip {
                 destination {
                     address 172.16.10.253/32
                 }
             }
         }
     }
     default {
         bandwidth 128kbit
     }
 }
[edit]
 
root@core2# run show queueing
Output Queues:
Interface  Qos-Policy             Sent    Dropped  Overlimit
eth0       default           161927946          0          0
eth1       traffic-shaper      3197144        401       9936
 
Input:
Ifname     Qos-Policy         Received    Dropped  Overlimit
eth1       traffic-limiter      119717          0          0
[edit]

QOS – Advanced shaper

set qos-policy traffic-limiter SHAPER-IN class 10 bandwidth 128kbit
set qos-policy traffic-limiter SHAPER-IN class 10 burst 25k
set qos-policy traffic-limiter SHAPER-IN class 10 match 1 ip source address 172.16.10.253/32
set qos-policy traffic-limiter SHAPER-IN class 10 description user1
set qos-policy traffic-limiter SHAPER-IN class 20 bandwidth 128kbit
set qos-policy traffic-limiter SHAPER-IN class 20 burst 25k
set qos-policy traffic-limiter SHAPER-IN class 20 match 2 ip source address 172.16.10.252/32
set qos-policy traffic-limiter SHAPER-IN class 20 description user2
set interfaces ethernet eth1 qos-policy in SHAPER-IN
 
set qos-policy traffic-shaper SHAPER-OUT default bandwidth 128kbit
set qos-policy traffic-shaper SHAPER-OUT class 10 bandwidth 128kbit
set qos-policy traffic-shaper SHAPER-OUT class 10 ceiling 512kbit
set qos-policy traffic-shaper SHAPER-OUT class 10 burst 15k
set qos-policy traffic-shaper SHAPER-OUT class 10 match 1 ip destination address 172.16.10.253/32
set qos-policy traffic-shaper SHAPER-OUT class 10 priority 2
set qos-policy traffic-shaper SHAPER-OUT class 10 description user1
set qos-policy traffic-shaper SHAPER-OUT class 20 bandwidth 128kbit
set qos-policy traffic-shaper SHAPER-OUT class 20 ceiling 1024kbit
set qos-policy traffic-shaper SHAPER-OUT class 20 burst 15k
set qos-policy traffic-shaper SHAPER-OUT class 20 match 2 ip destination address 172.16.10.252/32
set qos-policy traffic-shaper SHAPER-OUT class 20 priority 5
set qos-policy traffic-shaper SHAPER-OUT class 20 description user2
set interfaces ethernet eth1 qos-policy out SHAPER-OUT
 
vyatta@vyatta# show interfaces
 ethernet eth0 {
     address 93.155.130.11/28
     hw-id 00:0c:29:93:44:22
 }
 ethernet eth1 {
     address 172.16.10.254/24
     hw-id 00:0c:29:93:44:2c
     qos-policy {
         in SHAPER-IN
         out SHAPER-OUT
     }
 }
 loopback lo {
 }
[edit]
 
vyatta@vyatta# show qos-policy
 traffic-limiter SHAPER-IN {
     class 10 {
         bandwidth 128kbit
         burst 25k
         description user1
         match 1 {
             ip {
                 source {
                     address 172.16.10.253/32
                 }
             }
         }
     }
     class 20 {
         bandwidth 128kbit
         burst 25k
         description user2
         match 2 {
             ip {
                 source {
                     address 172.16.10.252/32
                 }
             }
         }
     }
 }
 traffic-shaper SHAPER-OUT {
     class 10 {
         bandwidth 128kbit
         ceiling 512kbit
         description user1
         match 1 {
             ip {
                 destination {
                     address 172.16.10.253/32
                 }
             }
         }
         priority 2
     }
     class 20 {
         ceiling 1024kbit
         description user2
         priority 5
     }
     default {
         bandwidth 128kbit
     }
 }
[edit]

QOS – Shape tunnel’s

set qos-policy traffic-shaper SHAPER-OUT default bandwidth 100kbit
set qos-policy traffic-shaper SHAPER-OUT class 2 bandwidth 1024kbit
set qos-policy traffic-shaper SHAPER-OUT class 2 match 2 ip destination address 0.0.0.0/0
set interfaces tunnel tun0 qos-policy out SHAPER-OUT
 
set qos-policy traffic-limiter SHAPER-IN class 2 bandwidth 1024kbit
set qos-policy traffic-limiter SHAPER-IN class 2 match 2 ip source address 0.0.0.0/0
set interfaces tunnel tun0 qos-policy in SHAPER-IN
 
vyatta@core3# show interfaces tunnel tun0
 address 172.16.100.2/24
 encapsulation gre
 local-ip 93.155.130.10
 qos-policy {
     in SHAPER-IN
     out SHAPER-OUT
 }
 remote-ip 93.155.130.1
[edit]
 
vyatta@core3# show qos-policy
 traffic-limiter SHAPER-IN {
     class 2 {
         bandwidth 1024kbit
         match 2 {
             ip {
                 source {
                     address 0.0.0.0/0
                 }
             }
         }
     }
 }
 traffic-shaper SHAPER-OUT {
     class 2 {
         bandwidth 1024kbit
         match 2 {
             ip {
                 destination {
                     address 0.0.0.0/0
                 }
             }
         }
     }
     default {
         bandwidth 100kbit
     }
 }
[edit]
 
vyatta@core3# run show queueing
Output Queues:
Interface  Qos-Policy             Sent    Dropped  Overlimit
eth0       default            12654699          0          0
eth1       default           125145857          0          0
tun0       traffic-shaper      2755927          0        195
 
Input:
Ifname     Qos-Policy         Received    Dropped  Overlimit
tun0       traffic-limiter    68481690      32120          0
[edit]

QOS – generating script

Създаваме файл с име cmd и права за изпълнение:

sudo su
nano cmd
chmod 755 cmd

Коннфигурираме ип адресите и мрежовия интерфейс във файла

#!/bin/bash
echo configure
echo set qos-policy traffic-shaper SHAPER-OUT default bandwidth 100kbit
IPCLIENT="192.168.100.50 \
192.168.100.51 \
192.168.100.52 \
192.168.100.53 \
192.168.100.54 \
192.168.100.55 \
192.168.100.56 \
192.168.100.57 \
192.168.100.58 \
192.168.100.59 \
192.168.100.60";
for IPCLIENT in $IPCLIENT; do
MARK=$(grep -v \# /home/vyatta/cmd | grep -w -n $IPCLIENT | cut -d":" -f1)
MARKUP=$(($MARK + 50))
echo set qos-policy traffic-shaper SHAPER-OUT class $MARKUP bandwidth 1024kbit
echo set qos-policy traffic-shaper SHAPER-OUT class $MARKUP match $MARKUP ip destination address ${IPCLIENT[0]}
echo set qos-policy traffic-limiter SHAPER-IN class $MARKUP bandwidth 1024kbit
echo set qos-policy traffic-limiter SHAPER-IN class $MARKUP match $MARKUP ip source address ${IPCLIENT[0]}
done;
echo set interfaces ethernet eth2 qos-policy out SHAPER-OUT
echo set interfaces ethernet eth2 qos-policy in SHAPER-IN
echo commit
echo exit
echo exit

След което изпълняваме

./cmd > script

И ако прегледаме файла script трябва да сме генерирали следната конфигурация

configure
set qos-policy traffic-shaper SHAPER-OUT default bandwidth 100kbit
set qos-policy traffic-shaper SHAPER-OUT class 53 bandwidth 1024kbit
set qos-policy traffic-shaper SHAPER-OUT class 53 match 53 ip destination address 192.168.100.50/32
set qos-policy traffic-limiter SHAPER-IN class 53 bandwidth 1024kbit
set qos-policy traffic-limiter SHAPER-IN class 53 match 53 ip source address 192.168.100.50/32
set qos-policy traffic-shaper SHAPER-OUT class 54 bandwidth 1024kbit
set qos-policy traffic-shaper SHAPER-OUT class 54 match 54 ip destination address 192.168.100.51/32
set qos-policy traffic-limiter SHAPER-IN class 54 bandwidth 1024kbit
set qos-policy traffic-limiter SHAPER-IN class 54 match 54 ip source address 192.168.100.51/32
set qos-policy traffic-shaper SHAPER-OUT class 55 bandwidth 1024kbit
set qos-policy traffic-shaper SHAPER-OUT class 55 match 55 ip destination address 192.168.100.52/32
set qos-policy traffic-limiter SHAPER-IN class 55 bandwidth 1024kbit
set qos-policy traffic-limiter SHAPER-IN class 55 match 55 ip source address 192.168.100.52/32
set qos-policy traffic-shaper SHAPER-OUT class 56 bandwidth 1024kbit
set qos-policy traffic-shaper SHAPER-OUT class 56 match 56 ip destination address 192.168.100.53/32
set qos-policy traffic-limiter SHAPER-IN class 56 bandwidth 1024kbit
set qos-policy traffic-limiter SHAPER-IN class 56 match 56 ip source address 192.168.100.53/32
set qos-policy traffic-shaper SHAPER-OUT class 57 bandwidth 1024kbit
set qos-policy traffic-shaper SHAPER-OUT class 57 match 57 ip destination address 192.168.100.54/32
set qos-policy traffic-limiter SHAPER-IN class 57 bandwidth 1024kbit
set qos-policy traffic-limiter SHAPER-IN class 57 match 57 ip source address 192.168.100.54/32
set qos-policy traffic-shaper SHAPER-OUT class 58 bandwidth 1024kbit
set qos-policy traffic-shaper SHAPER-OUT class 58 match 58 ip destination address 192.168.100.55/32
set qos-policy traffic-limiter SHAPER-IN class 58 bandwidth 1024kbit
set qos-policy traffic-limiter SHAPER-IN class 58 match 58 ip source address 192.168.100.55/32
set qos-policy traffic-shaper SHAPER-OUT class 59 bandwidth 1024kbit
set qos-policy traffic-shaper SHAPER-OUT class 59 match 59 ip destination address 192.168.100.56/32
set qos-policy traffic-limiter SHAPER-IN class 59 bandwidth 1024kbit
set qos-policy traffic-limiter SHAPER-IN class 59 match 59 ip source address 192.168.100.56/32
set qos-policy traffic-shaper SHAPER-OUT class 60 bandwidth 1024kbit
set qos-policy traffic-shaper SHAPER-OUT class 60 match 60 ip destination address 192.168.100.57/32
set qos-policy traffic-limiter SHAPER-IN class 60 bandwidth 1024kbit
set qos-policy traffic-limiter SHAPER-IN class 60 match 60 ip source address 192.168.100.57/32
set qos-policy traffic-shaper SHAPER-OUT class 61 bandwidth 1024kbit
set qos-policy traffic-shaper SHAPER-OUT class 61 match 61 ip destination address 192.168.100.58/32
set qos-policy traffic-limiter SHAPER-IN class 61 bandwidth 1024kbit
set qos-policy traffic-limiter SHAPER-IN class 61 match 61 ip source address 192.168.100.58/32
set qos-policy traffic-shaper SHAPER-OUT class 62 bandwidth 1024kbit
set qos-policy traffic-shaper SHAPER-OUT class 62 match 62 ip destination address 192.168.100.59/32
set qos-policy traffic-limiter SHAPER-IN class 62 bandwidth 1024kbit
set qos-policy traffic-limiter SHAPER-IN class 62 match 62 ip source address 192.168.100.59/32
set qos-policy traffic-shaper SHAPER-OUT class 63 bandwidth 1024kbit
set qos-policy traffic-shaper SHAPER-OUT class 63 match 63 ip destination address 192.168.100.60/32
set qos-policy traffic-limiter SHAPER-IN class 63 bandwidth 1024kbit
set qos-policy traffic-limiter SHAPER-IN class 63 match 63 ip source address 192.168.100.60/32
set interfaces ethernet eth2 qos-policy out SHAPER-OUT
set interfaces ethernet eth2 qos-policy in SHAPER-IN
commit
exit
exit

За да копираме и изпълним всичко това в терминала трябва като потребител vyatta да изпълним следния ред:

cat script | ssh -tt vyatta@127.0.0.1

Промпта ще ни попита за парола след което ще изпълни командите и ще се върне обратно в user$ режим …

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.