Limitação de taxa baseada em VLAN usando tc

4

Tenho tentado limitar a taxa baseada em VLAN em um projeto acadêmico em que estou trabalhando. O projeto usa o Openflow (com o controlador Beacon) e a rede é emulada usando o Mininet. A rede é composta de OpenVSwitches.

Para meu projeto, preciso limitar o tráfego em cada VLAN na rede. Eu escolhi o tc (com htb) para isso e tenho tentado de vários dias para conseguir isso funcionar. Estas são as metas que eu quero alcançar usando tc: 1) Taxa limite a todas as VLANs com uma determinada taxa de dados. 2) Certifique-se de que, uma vez definidos os limites de taxa, todas as VLANs que usam um link físico entre os switches obtenham a mesma taxa de dados máxima (ou quase igual).

Portanto, se eu definir o limite de taxa de dados em cada uma das VLANs como 100 Mbps e houver 5 VLANs usando um link físico, desejo que todas essas VLANs NÃO excedam 100 Mbps e, ao mesmo tempo, obtenham taxas de dados máximas de cerca de 100 Mbps cada.

Eu escrevi script para essa topologia:

s2---s4
|
s6---s8
|
s10---s12

Este é o script:

#!/bin/bash

# delete prev: 
tc qdisc del dev s10-eth2 root
tc qdisc del dev s2-eth3 root
tc qdisc del dev s6-eth2 root
tc qdisc del dev s6-eth3 root
tc qdisc del dev s6-eth4 root
tc qdisc del dev s8-eth2 root

# create "roots":
tc qdisc add dev s10-eth2 root handle 1: htb default 1000
tc class add dev s10-eth2 parent 1: classid 1:1 htb rate 1000Mbit ceil 1000Mbit
tc qdisc add dev s2-eth3 root handle 2: htb default 1001
tc class add dev s2-eth3 parent 2: classid 2:1 htb rate 1000Mbit ceil 1000Mbit
tc qdisc add dev s6-eth2 root handle 3: htb default 1002
tc class add dev s6-eth2 parent 3: classid 3:1 htb rate 1000Mbit ceil 1000Mbit
tc qdisc add dev s6-eth3 root handle 4: htb default 1003
tc class add dev s6-eth3 parent 4: classid 4:1 htb rate 1000Mbit ceil 1000Mbit
tc qdisc add dev s6-eth4 root handle 5: htb default 1004
tc class add dev s6-eth4 parent 5: classid 5:1 htb rate 1000Mbit ceil 1000Mbit
tc qdisc add dev s8-eth2 root handle 6: htb default 1005
tc class add dev s8-eth2 parent 6: classid 6:1 htb rate 1000Mbit ceil 1000Mbit

# classes for all vlans (ie: VLAN ids 541, 542 and 543) on each interface:
tc class add dev s10-eth2 parent 1:1 classid 1:541 htb rate 100Mbit ceil 100Mbit prio 1
tc class add dev s10-eth2 parent 1:1 classid 1:542 htb rate 100Mbit ceil 100Mbit prio 1
tc class add dev s10-eth2 parent 1:1 classid 1:543 htb rate 100Mbit ceil 100Mbit prio 1
tc class add dev s2-eth3 parent 2:1 classid 2:542 htb rate 100Mbit ceil 100Mbit prio 1
tc class add dev s6-eth2 parent 3:1 classid 3:542 htb rate 100Mbit ceil 100Mbit prio 1
tc class add dev s6-eth3 parent 4:1 classid 4:543 htb rate 100Mbit ceil 100Mbit prio 1
tc class add dev s6-eth4 parent 5:1 classid 5:541 htb rate 100Mbit ceil 100Mbit prio 1
tc class add dev s6-eth4 parent 5:1 classid 5:542 htb rate 100Mbit ceil 100Mbit prio 1
tc class add dev s6-eth4 parent 5:1 classid 5:543 htb rate 100Mbit ceil 100Mbit prio 1
tc class add dev s8-eth2 parent 6:1 classid 6:543 htb rate 100Mbit ceil 100Mbit prio 1

# parent filter:
tc filter add dev s10-eth2 parent 1: prio 1 protocol 802.1q u32
tc filter add dev s2-eth3 parent 2: prio 1 protocol 802.1q u32
tc filter add dev s6-eth2 parent 3: prio 1 protocol 802.1q u32
tc filter add dev s6-eth3 parent 4: prio 1 protocol 802.1q u32
tc filter add dev s6-eth4 parent 5: prio 1 protocol 802.1q u32
tc filter add dev s8-eth2 parent 6: prio 1 protocol 802.1q u32

# filter for each VLAN (with VLAN ids 541, 542 and 543):
tc filter add dev s10-eth2 parent 1: prio 1 protocol 802.1q u32 match u16 0x021D 0x0fff at -4 flowid 1:541
tc filter add dev s10-eth2 parent 1: prio 1 protocol 802.1q u32 match u16 0x021E 0x0fff at -4 flowid 1:542
tc filter add dev s10-eth2 parent 1: prio 1 protocol 802.1q u32 match u16 0x021F 0x0fff at -4 flowid 1:543
tc filter add dev s2-eth3 parent 2: prio 1 protocol 802.1q u32 match u16 0x021E 0x0fff at -4 flowid 2:542
tc filter add dev s6-eth2 parent 3: prio 1 protocol 802.1q u32 match u16 0x021E 0x0fff at -4 flowid 3:542
tc filter add dev s6-eth3 parent 4: prio 1 protocol 802.1q u32 match u16 0x021F 0x0fff at -4 flowid 4:543
tc filter add dev s6-eth4 parent 5: prio 1 protocol 802.1q u32 match u16 0x021D 0x0fff at -4 flowid 5:541
tc filter add dev s6-eth4 parent 5: prio 1 protocol 802.1q u32 match u16 0x021E 0x0fff at -4 flowid 5:542
tc filter add dev s6-eth4 parent 5: prio 1 protocol 802.1q u32 match u16 0x021F 0x0fff at -4 flowid 5:543
tc filter add dev s8-eth2 parent 6: prio 1 protocol 802.1q u32 match u16 0x021F 0x0fff at -4 flowid 6:543

E estas são as estatísticas, depois de eu executar este script e executar a transmissão:

qdisc htb 1: root refcnt 2 r2q 10 default 1000 direct_packets_stat 82134
 Sent 5425380 bytes 82134 pkt (dropped 0, overlimits 0 requeues 0) 
 backlog 0b 0p requeues 0 
qdisc htb 2: root refcnt 2 r2q 10 default 1001 direct_packets_stat 306284
 Sent 462713848 bytes 306284 pkt (dropped 0, overlimits 0 requeues 0) 
 backlog 0b 0p requeues 0 
qdisc htb 3: root refcnt 2 r2q 10 default 1002 direct_packets_stat 62794
 Sent 4144482 bytes 62795 pkt (dropped 0, overlimits 0 requeues 0) 
 backlog 0b 0p requeues 0 
qdisc htb 4: root refcnt 2 r2q 10 default 1003 direct_packets_stat 0
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
 backlog 0b 0p requeues 0 
qdisc htb 5: root refcnt 2 r2q 10 default 1004 direct_packets_stat 831269
 Sent 1257477000 bytes 831270 pkt (dropped 0, overlimits 0 requeues 0) 
 backlog 0b 0p requeues 0 
qdisc htb 6: root refcnt 2 r2q 10 default 1005 direct_packets_stat 0
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
 backlog 0b 0p requeues 0 

Estou tentando definir um limite de taxa de dados de 100 Mbps em todas as VLANs usando esse script. A limitação de taxa não funciona de todo, na verdade eles se descontrolam. As taxas de dados que cada um dos meus hosts atinge são superiores a 300+ Mbps, o que é muito superior ao que defini, e nenhum dos fluxos de dados que usam as VLANs obtém taxas de dados uniformes.

Seria ótimo se alguém pudesse me ajudar a obter esse script corrigido e funcionando. Obrigado.

    
por user1449265 27.12.2012 / 14:37

1 resposta

1

Eu fiz um script que molda o tráfego em VLANs separadas passando uma ponte. Espero que isso possa ser útil para alguém que procura uma solução.

#!/bin/bash
## in this example I use vlan 2001-2004, which are hex equivalents of 0x07D1 -0x07D4

# internet facing interface
INET=eth2
# downlink facing interface
DOWN=eth3

### configuring download rules:
tc qdisc del dev $DOWN root
tc qdisc replace dev $DOWN root handle 1: htb
tc class replace dev $DOWN parent 1: classid 1:2001 htb rate 11mbit
tc class replace dev $DOWN parent 1: classid 1:2002 htb rate 21mbit
tc class replace dev $DOWN parent 1: classid 1:2003 htb rate 31mbit
tc class replace dev $DOWN parent 1: classid 1:2004 htb rate 41mbit
tc filter replace dev $DOWN protocol all parent 1: prio 100 basic match "meta(vlan mask 0xfff eq 0x07D1)" flowid 1:2001
tc filter replace dev $DOWN protocol all parent 1: prio 100 basic match "meta(vlan mask 0xfff eq 0x07D2)" flowid 1:2002
tc filter replace dev $DOWN protocol all parent 1: prio 100 basic match "meta(vlan mask 0xfff eq 0x07D3)" flowid 1:2003
tc filter replace dev $DOWN protocol all parent 1: prio 100 basic match "meta(vlan mask 0xfff eq 0x07D4)" flowid 1:2004

printf "########## Printout for DOWNLOAD: ###################\n"
printf "\n"
printf "$(tc filter show dev $DOWN)\n"
printf "$(tc class show dev $DOWN)\n"
printf "$(tc qdisc show dev $DOWN)\n"
printf "\n"

### configuring upload rules:
tc qdisc del dev $INET root
tc qdisc replace dev $INET root handle 2: htb
tc class replace dev $INET parent 2: classid 2:2001 htb rate 11mbit
tc class replace dev $INET parent 2: classid 2:2002 htb rate 21mbit
tc class replace dev $INET parent 2: classid 2:2003 htb rate 31mbit
tc class replace dev $INET parent 2: classid 2:2004 htb rate 41mbit
tc filter replace dev $INET protocol all parent 2: prio 100 basic match "meta(vlan mask 0xfff eq 0x07D1)" flowid 2:2001
tc filter replace dev $INET protocol all parent 2: prio 100 basic match "meta(vlan mask 0xfff eq 0x07D2)" flowid 2:2002
tc filter replace dev $INET protocol all parent 2: prio 100 basic match "meta(vlan mask 0xfff eq 0x07D3)" flowid 2:2003
tc filter replace dev $INET protocol all parent 2: prio 100 basic match "meta(vlan mask 0xfff eq 0x07D4)" flowid 2:2004

printf "########## Printout for UPLOAD: #####################\n"
printf "\n"
printf "$(tc filter show dev $INET)\n"
printf "$(tc class show dev $INET)\n"
printf "$(tc qdisc show dev $INET)\n"
printf "\n"

exit 0
    
por 09.12.2015 / 18:23