Subscribe via RSS Feed Connect on Google Plus Connect on LinkedIn
1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 4,50 out of 5)
Loading...Loading...

Habilitando Múltiplos Caminhos para um mesmo Destino (ECMP – Equal Cost Multipath Load Balance) em Switches e Roteadores Juniper

18 de agosto de 2013 0 Comments
ShareTweet about this on TwitterShare on TumblrShare on LinkedInShare on Google+Share on FacebookPin on PinterestEmail this to someonePrint this page

Por default os switches e roteadores Juniper habilitam somente um caminho para um mesmo destino na forwarding-table (FIB). Mesmo que você insira vários caminhos para um mesmo destino, o Juniper escolhe somente um de forma randômica usando seu algoritmo chamado de "random fashion" e só instala a escolhida na forwarding-table.

Vamos para a prática…

 

 

Vamos inserir várias rotas para um mesmo destino 192.168.0.1/32 por vários caminhos (gateways):

 

set routing-options static route 192.168.0.1/32 next-hop 10.135.128.2
set routing-options static route 192.168.0.1/32 next-hop 10.135.128.3
set routing-options static route 192.168.0.1/32 next-hop 10.135.128.4
set routing-options static route 192.168.0.1/32 next-hop 10.135.128.5
set routing-options static route 192.168.0.1/32 next-hop 10.135.128.6
set routing-options static route 192.168.0.1/32 next-hop 10.135.128.7
set routing-options static route 192.168.0.1/32 next-hop 10.135.128.8
set routing-options static route 192.168.0.1/32 next-hop 10.135.128.9
set routing-options static route 192.168.0.1/32 next-hop 10.135.128.10
set routing-options static route 192.168.0.1/32 next-hop 10.135.128.11
set routing-options static route 192.168.0.1/32 next-hop 10.135.128.12
set routing-options static route 192.168.0.1/32 next-hop 10.135.128.13
set routing-options static route 192.168.0.1/32 next-hop 10.135.128.14
set routing-options static route 192.168.0.1/32 next-hop 10.135.128.15
set routing-options static route 192.168.0.1/32 next-hop 10.135.128.16
set routing-options static route 192.168.0.1/32 next-hop 10.135.128.17
set routing-options static route 192.168.0.1/32 next-hop 10.135.128.18
set routing-options static route 192.168.0.1/32 next-hop 10.135.128.19
set routing-options static route 192.168.0.1/32 next-hop 10.135.128.20
 

Vamos ver como ficou a tabela de roteamento (RIB):

 

root@LAB-NETADM> show route 192.168.0.1
 
inet.0: 215 destinations, 249 routes (215 active, 0 holddown, 0 hidden)
+ = Active Route, – = Last Active, * = Both
 
192.168.0.1/32     *[Static/5] 18:45:43
                      to 10.135.128.2 via ge-0/0/2.0
                      to 10.135.128.3 via ge-0/0/2.0
                      to 10.135.128.4 via ge-0/0/2.0
                      to 10.135.128.5 via ge-0/0/2.0
                      to 10.135.128.6 via ge-0/0/2.0
                    > to 10.135.128.7 via ge-0/0/2.0
                      to 10.135.128.8 via ge-0/0/2.0
                      to 10.135.128.9 via ge-0/0/2.0
                      to 10.135.128.10 via ge-0/0/2.0
                      to 10.135.128.11 via ge-0/0/2.0
                      to 10.135.128.12 via ge-0/0/2.0
                      to 10.135.128.13 via ge-0/0/2.0
                      to 10.135.128.14 via ge-0/0/2.0
                      to 10.135.128.15 via ge-0/0/2.0
                      to 10.135.128.16 via ge-0/0/2.0
                      to 10.135.128.17 via ge-0/0/2.0
 
{master:0}

 

enlightened Nesse exemplo usamos switches EX-4200. O número máximo de ECMP nesses switches é 16.

 

Aparentemente tudo beleza certo? ERRADO!

Essa aí é a routing-table, para verificarmos a forwarding table temos que dar o seguinte comando:

 

root@LAB-NETADM> show route forwarding-table destination 192.168.0.1 
Routing table: default.inet
Internet:
Destination        Type RtRef Next hop           Type Index NhRef Netif
192.168.0.1/32     user     0 10.135.128.7       hold  1390     3 ge-0/0/2.0
 
Routing table: __master.anon__.inet
Internet:
Destination        Type RtRef Next hop           Type Index NhRef Netif
default            perm     0                    rjct  1291     1
 
{master:0}

 

 

Habilitando ECMP – Equal Cost Multipath Load Balance

 

Como dissemos anteriormente, o Juniper escolhe um caminho de forma randômica e coloca na forwarding table.

Para habilitarmos múltiplos caminhos para um mesmo destino fazendo load balance entre eles, temos criar uma policy definindo a ação de load-balance per-packet e aplicarmos essa policy na routing-table para que as rotas sejam exportadas para a forwarding-table com load-balance para múltiplos caminhos:

set policy-options policy-statement LOADBALANCE then load-balance per-packet
set routing-options forwarding-table export LOADBALANCE

 

Agora sim, temos ECMP Load-Balance!

root@LAB-NETADM> show route forwarding-table destination 192.168.0.1                            

Routing table: default.inet
Internet:
Destination        Type RtRef Next hop           Type Index NhRef Netif
192.168.0.1/32     user     0                    ulst 131075     2
                              10.135.128.2       hold  1385     2 ge-0/0/2.0
                              10.135.128.3       hold  1392     2 ge-0/0/2.0
                              10.135.128.4       hold  1393     2 ge-0/0/2.0
                              10.135.128.5       hold  1394     2 ge-0/0/2.0
                              10.135.128.6       hold  1395     2 ge-0/0/2.0
                              10.135.128.7       hold  1390     3 ge-0/0/2.0
                              10.135.128.8       hold  1396     2 ge-0/0/2.0
                              10.135.128.9       hold  1397     2 ge-0/0/2.0
                              10.135.128.10      hold  1398     2 ge-0/0/2.0
                              10.135.128.11      hold  1399     2 ge-0/0/2.0
                              10.135.128.12      hold  1400     2 ge-0/0/2.0
                              10.135.128.13      hold  1401     2 ge-0/0/2.0
                              10.135.128.14      hold  1402     2 ge-0/0/2.0
                              10.135.128.15      hold  1403     2 ge-0/0/2.0
                              10.135.128.16      hold  1404     2 ge-0/0/2.0
                              10.135.128.17      hold  1405     2 ge-0/0/2.0
 
Routing table: __master.anon__.inet
Internet:
Destination        Type RtRef Next hop           Type Index NhRef Netif
default            perm     0                    rjct  1291     1
 
{master:0}

 

BGP

Há um truque a mais no protocolo BGP para o funcionamento de ECMP Load Balance. Por default o protocolo não trabalha com multipath. Veja abaixo alguns show's sem o parâmetro:

root@LAB-NETADM> show bgp summary   

Groups: 1 Peers: 20 Down peers: 0
Table          Tot Paths  Act Paths Suppressed    History Damp State    Pending
inet.0                40          2          0          0          0          0
Peer                     AS      InPkt     OutPkt    OutQ   Flaps Last Up/Dwn State|#Active/Received/Accepted/Damped…
10.1.1.1              65310         30         30       0       1          19 2/2/2/0              0/0/0/0
10.1.2.1              65310          3          3       0       1          19 0/2/2/0              0/0/0/0
10.1.3.1              65310          3          3       0       1          15 0/2/2/0              0/0/0/0
10.1.4.1              65310          3          3       0       1          11 0/2/2/0              0/0/0/0
10.1.5.1              65310          3          3       0       1           7 0/2/2/0              0/0/0/0
10.1.6.1              65310          3          3       0       1           3 0/2/2/0              0/0/0/0
10.1.7.1              65310         28         29       0       1          19 0/2/2/0              0/0/0/0
10.1.8.1              65310          3          3       0       1          19 0/2/2/0              0/0/0/0
10.1.9.1              65310         28         28       0       1          15 0/2/2/0              0/0/0/0
10.1.10.1             65310          3          3       0       1          11 0/2/2/0              0/0/0/0
10.1.11.1             65310          3          3       0       1           7 0/2/2/0              0/0/0/0
10.1.12.1             65310          3          3       0       1           3 0/2/2/0              0/0/0/0
10.1.13.1             65310         28         29       0       1          19 0/2/2/0              0/0/0/0
10.1.14.1             65310          3          3       0       1          19 0/2/2/0              0/0/0/0
10.1.15.1             65310         28         29       0       1          15 0/2/2/0              0/0/0/0
10.1.16.1             65310          3          3       0       1          11 0/2/2/0              0/0/0/0
10.1.17.1             65310          3          3       0       1           7 0/2/2/0              0/0/0/0
10.1.18.1             65310          3          3       0       1           3 0/2/2/0              0/0/0/0
10.1.19.1             65310         28         29       0       1          19 0/2/2/0              0/0/0/0
10.1.20.1             65310          3          3       0       1          19 0/2/2/0              0/0/0/0
 
{master:0}
 
 
 
root@LAB-NETADM> show route 60.60.60.60
 
inet.0: 89 destinations, 127 routes (89 active, 0 holddown, 0 hidden)
+ = Active Route, – = Last Active, * = Both
 
60.60.60.60/32     *[BGP/170] 00:00:25, localpref 100
                      AS path: 65310 I
                    > to 10.1.1.1 via ge-0/0/0.0
                    [BGP/170] 00:00:25, localpref 100
                      AS path: 65310 I
                    > to 10.1.2.1 via ge-0/0/0.0
                    [BGP/170] 00:00:21, localpref 100
                      AS path: 65310 I
                    > to 10.1.3.1 via ge-0/0/0.0
                    [BGP/170] 00:00:17, localpref 100
                      AS path: 65310 I
                    > to 10.1.4.1 via ge-0/0/0.0
                    [BGP/170] 00:00:13, localpref 100
                      AS path: 65310 I
                    > to 10.1.5.1 via ge-0/0/0.0
                    [BGP/170] 00:00:09, localpref 100
                      AS path: 65310 I
                    > to 10.1.6.1 via ge-0/0/0.0
                    [BGP/170] 00:00:25, localpref 100
                      AS path: 65310 I
                    > to 10.1.7.1 via ge-0/0/0.0
                    [BGP/170] 00:00:25, localpref 100
                      AS path: 65310 I
                    > to 10.1.8.1 via ge-0/0/0.0
                    [BGP/170] 00:00:21, localpref 100
                      AS path: 65310 I
                    > to 10.1.9.1 via ge-0/0/0.0
                    [BGP/170] 00:00:17, localpref 100
                      AS path: 65310 I
                    > to 10.1.10.1 via ge-0/0/0.0
                    [BGP/170] 00:00:13, localpref 100
                      AS path: 65310 I
                    > to 10.1.11.1 via ge-0/0/0.0
                    [BGP/170] 00:00:09, localpref 100
                      AS path: 65310 I
                    > to 10.1.12.1 via ge-0/0/0.0
                    [BGP/170] 00:00:25, localpref 100
                      AS path: 65310 I
                    > to 10.1.13.1 via ge-0/0/0.0
                    [BGP/170] 00:00:25, localpref 100
                      AS path: 65310 I
                    > to 10.1.14.1 via ge-0/0/0.0
                    [BGP/170] 00:00:21, localpref 100
                      AS path: 65310 I
                    > to 10.1.15.1 via ge-0/0/0.0
                    [BGP/170] 00:00:17, localpref 100
                      AS path: 65310 I
                    > to 10.1.16.1 via ge-0/0/0.0
                    [BGP/170] 00:00:13, localpref 100
                      AS path: 65310 I
                    > to 10.1.17.1 via ge-0/0/0.0
                    [BGP/170] 00:00:09, localpref 100
                      AS path: 65310 I
                    > to 10.1.18.1 via ge-0/0/0.0
                    [BGP/170] 00:00:25, localpref 100
                      AS path: 65310 I
                    > to 10.1.19.1 via ge-0/0/0.0
                    [BGP/170] 00:00:25, localpref 100
                      AS path: 65310 I
                    > to 10.1.20.1 via ge-0/0/0.0
 
{master:0}
 
 
root@LAB-NETADM> show route forwarding-table destination 60.60.60.60
Routing table: default.inet
Internet:
Destination        Type RtRef Next hop           Type Index NhRef Netif
60.60.60.60/32     user     0 10.1.1.1           ucst  1417     6 ge-0/0/0.0
 
Routing table: __master.anon__.inet
Internet:
Destination        Type RtRef Next hop           Type Index NhRef Netif
default            perm     0                    rjct  1286     1
 
{master:0}

 

 

Além habilitar a policy LOADBALANCE, no BGP é necessário habilitar a feature multipath dentro da configuração do protocolo:

set protocols bgp group ANYCAST multipath

 

Vejam que, agora, os 16 peers BGP ficaram com suas rotas ativas na tabela de roteamento:

 

root@LAB-NETADM> show bgp summary   
Groups: 1 Peers: 20 Down peers: 0
Table          Tot Paths  Act Paths Suppressed    History Damp State    Pending
inet.0                40         32          0          0          0          0
Peer                     AS      InPkt     OutPkt    OutQ   Flaps Last Up/Dwn State|#Active/Received/Accepted/Damped…
10.1.1.1              65310         55         55       0       1       11:43 2/2/2/0              0/0/0/0
10.1.2.1              65310         28         28       0       1       11:43 2/2/2/0              0/0/0/0
10.1.3.1              65310         27         28       0       1       11:39 2/2/2/0              0/0/0/0
10.1.4.1              65310         27         27       0       1       11:35 2/2/2/0              0/0/0/0
10.1.5.1              65310         27         27       0       1       11:31 2/2/2/0              0/0/0/0
10.1.6.1              65310         27         27       0       1       11:27 2/2/2/0              0/0/0/0
10.1.7.1              65310         53         54       0       1       11:43 2/2/2/0              0/0/0/0
10.1.8.1              65310         28         28       0       1       11:43 2/2/2/0              0/0/0/0
10.1.9.1              65310         52         53       0       1       11:39 2/2/2/0              0/0/0/0
10.1.10.1             65310         27         27       0       1       11:35 2/2/2/0              0/0/0/0
10.1.11.1             65310         27         27       0       1       11:31 2/2/2/0              0/0/0/0
10.1.12.1             65310         27         27       0       1       11:27 2/2/2/0              0/0/0/0
10.1.13.1             65310         53         54       0       1       11:43 2/2/2/0              0/0/0/0
10.1.14.1             65310         27         28       0       1       11:43 2/2/2/0              0/0/0/0
10.1.15.1             65310         52         54       0       1       11:39 2/2/2/0              0/0/0/0
10.1.16.1             65310         27         28       0       1       11:35 2/2/2/0              0/0/0/0
10.1.17.1             65310         27         27       0       1       11:31 0/2/2/0              0/0/0/0
10.1.18.1             65310         27         27       0       1       11:27 0/2/2/0              0/0/0/0
10.1.19.1             65310         53         54       0       1       11:43 0/2/2/0              0/0/0/0
10.1.20.1             65310         27         28       0       1       11:43 0/2/2/0              0/0/0/0
 
{master:0}
 
 
root@LAB-NETADM> show route forwarding-table destination 60.60.60.60   
Routing table: default.inet
Internet:
Destination        Type RtRef Next hop           Type Index NhRef Netif
60.60.60.60/32     user     0                    ulst 131070     5
                              10.1.1.1           ucst  1417     3 ge-0/0/0.0
                              10.1.2.1           ucst  1416     3 ge-0/0/0.0
                              10.1.3.1           ucst  1418     3 ge-0/0/0.0
                              10.1.4.1           ucst  1419     4 ge-0/0/0.0
                              10.1.5.1           ucst  1420     3 ge-0/0/0.0
                              10.1.6.1           ucst  1421     3 ge-0/0/0.0
                              10.1.7.1           ucst  1422     3 ge-0/0/0.0
                              10.1.8.1           ucst  1423     3 ge-0/0/0.0
                              10.1.9.1           ucst  1424     3 ge-0/0/0.0
                              10.1.10.1          ucst  1425     3 ge-0/0/0.0
                              10.1.11.1          ucst  1426     3 ge-0/0/0.0
                              10.1.12.1          ucst  1427     3 ge-0/0/0.0
                              10.1.13.1          ucst  1470     3 ge-0/0/0.0
                              10.1.14.1          ucst  1471     3 ge-0/0/0.0
                              10.1.15.1          ucst  1472     3 ge-0/0/0.0
                              10.1.16.1          ucst  1473     3 ge-0/0/0.0
 
Routing table: __master.anon__.inet
Internet:
Destination        Type RtRef Next hop           Type Index NhRef Netif
default            perm     0                    rjct  1286     1
 
{master:0}

 

 

 

Mais da funcionalidade

 

O load balance per-packet depende do modelo do processador do equipamento e atua de duas maneiras:

O Internet Processor I ASIC suporta 8 equal cost multipath e o load balance é realmente per-packet em round-robin.

O Internet Processor II ASIC suporta 16 caminhos equal cost multipath (e, em roteadores com o comando chassis maximum-ecmp pode suportar 32 ou 64) e o load balance é por fluxo (per-flow), ou seja, um mesmo fluxo sai pela mesma interface. O fluxo é reconhecido verificando os seguintes parâmetros do pacote:

 

Source IP address

Destination IP address

Protocol

Source port number

Destination port number

Source interface index

Type of service (ToS)

 

 

 

 

Referências:
 

 

Seu ip é:
54.146.27.245

ShareTweet about this on TwitterShare on TumblrShare on LinkedInShare on Google+Share on FacebookPin on PinterestEmail this to someonePrint this page

About the Author:

O autor trabalha com tecnologia de redes há 13 anos, participa de congressos no Brasil e no mundo, e contribui para melhoria de protocolos e sistemas com fabricantes de equipamentos de rede.