Search This Blog

Saturday, July 4, 2015

BGP equal-cost load-balance using maximum-path

In the following post I will examine the maximum-path option for BGP.

This is the lab topology I’m going to use:



R12 advertise network 192.120.1.0/24.

Now let’s see R1 BGP table:

R1#show ip bgp
BGP table version is 26, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 * i 192.120.1.0      10.1.24.4                0    100      0 65034 65007 65009 65120 ?
 *                    10.1.14.4                              0 65034 65007 65009 65120 ?
 *                    10.1.15.5                              0 65005 65007 65009 65120 ?
 *>                   10.1.13.3                              0 65034 65007 65009 65120 ? <OUTPUT_OMMITED>

We can see that R1 learns about 192.120.1.0/24 network from 3 different peers (R3, R4 and R5) but install only the best in his RIB - that is R3.

Now let’s say we want to configure equal-cost load-balance on R1, for this purpose we can use the BGP maximum-path command.

The BGP command maximum-path allow us to install more then one path in the RIB but only when both (or more) paths have the same characteristics –

From Cisco BGP Best Path Selection Algorithm document:
“In order to be candidates for multipath, paths to the same destination need to have these characteristics equal to the best-path characteristics:
Weight
Local preference
AS-PATH length
Origin
MED
One of these:
 - Neighboring AS or sub-AS (before the addition of the eiBGP Multipath feature)
 - AS-PATH (after the addition of the eiBGP Multipath feature)”

URL:

So now let’s configure on R1 the maximum-path command:

R1(config-router)#maximum-paths 4

The default value is 1

Let’s see R1 BGP table again:

R1#show ip bgp
BGP table version is 29, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 * i 192.120.1.0      10.1.24.4                0    100      0 65034 65007 65009 65120 ?
 *m                   10.1.14.4                              0 65034 65007 65009 65120 ?
 *                    10.1.15.5                              0 65005 65007 65009 65120 ?
 *>                   10.1.13.3                              0 65034 65007 65009 65120 ? <OUTPUT_OMMITED>

Now we can see entries with the ‘m’ sign, toward R4, which means multipath.

Let’s see the routing table:

R1#show ip route 192.120.1.0
Routing entry for 192.120.1.0/24
  Known via "bgp 65012", distance 20, metric 0
  Tag 65034, type external
  Last update from 10.1.13.3 00:03:07 ago
  Routing Descriptor Blocks:
  * 10.1.14.4, from 10.1.14.4, 00:03:07 ago
      Route metric is 0, traffic share count is 1
      AS Hops 4
      Route tag 65034
      MPLS label: none
    10.1.13.3, from 10.1.13.3, 00:03:07 ago
      Route metric is 0, traffic share count is 1
      AS Hops 4
      Route tag 65034
      MPLS label: none

R1 has installed both paths, to R3 and to R4, in his routing table and now we gain equal-cost load-balance between these two peers, on a per-destination algorithm used by CEF:

R1#show ip cef 192.120.1.0 detail
192.120.1.0/24, epoch 0, flags rib only nolabel, rib defined all labels, per-destination sharing
  recursive via 10.1.13.3
    attached to FastEthernet0/1
  recursive via 10.1.14.4
    attached to FastEthernet1/0

But what about R5? Why R5 path didn’t installed in the RIB also?
We got the same Weight, Local preference, AS-PATH length, Origin and MED?!
That’s because R5 is in different autonomous system!

In order to install R5 path and overcome the different AS limitation we can use the following hidden command:

R1(config-router)# bgp bestpath as-path multipath-relax

Now let’s see R1 BGP table:

R1#show ip bgp
BGP table version is 45, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path

 * i 192.120.1.0      10.1.24.4                0    100      0 65034 65007 65009 65120 ?
 *m                   10.1.14.4                              0 65034 65007 65009 65120 ?
 *m                   10.1.15.5                              0 65005 65007 65009 65120 ?
 *>                   10.1.13.3                              0 65034 65007 65009 65120 ?

<OUTPUT_OMMITED>

And on the routing table:

R1# show ip route 192.120.1.0
Routing entry for 192.120.1.0/24
  Known via "bgp 65012", distance 20, metric 0
  Tag 65034, type external
  Last update from 10.1.13.3 00:06:36 ago
  Routing Descriptor Blocks:
    10.1.15.5, from 10.1.15.5, 00:06:36 ago
      Route metric is 0, traffic share count is 1
      AS Hops 4
      Route tag 65034
      MPLS label: none
  * 10.1.14.4, from 10.1.14.4, 00:06:36 ago
      Route metric is 0, traffic share count is 1
      AS Hops 4
      Route tag 65034
      MPLS label: none
    10.1.13.3, from 10.1.13.3, 00:06:36 ago
      Route metric is 0, traffic share count is 1
      AS Hops 4
      Route tag 65034
      MPLS label: none

Now we got equal-cost load-balance on all 3 links from R1.

Another option for this command is maximum-path ibgp <NUMBER> which has the same effect but with iBGP peers.


Thursday, July 2, 2015

DSCP and IP Precedence conversion

IP Precedence conversion table:

7
6
5
4
3
2
1
0
2^5
2^4
2^3
2^2
2^1
2^0
x
x
32
16
8
4
2
1
x
x

DSCP conversion table:

7
6
5
4
3
2
1
0
2^5
2^4
2^3
2^2
2^1
2^0
x
x
32
16
8
4
2
1
x
x

IP Precedence use only the 3 left-most bits, hence we will start calculate only from bit 5 up to bit 7, Were DSCP uses only the 6 left-most bits, so calculation starts from bit 2 up to bit 7.

Example #1: DSCP to decimal

Let’s say we have AF41, first we will need to translate it to decimal using the following formula:

(8 x X) + (2 x Y) - where X is the first number and Y is the second number.

(8 x 4) + (2 x 1) = 32 + 2 = 34

So AF41 equals, in decimal, to 34

Now let’s use the conversion table to convert it to binary:

7
6
5
4
3
2
1
0
2^5
2^4
2^3
2^2
2^1
2^0
x
x
32
16
8
4
2
1
x
x

We need to use the 7th bit and the 3nd bit to get 34, so in binary it will be:
10001000

Example #2: IP Precedence to decimal

Let’s say we got CS3, since IPPrec is using only 3 bits, CS3 in binary is 011

Now let’s put this value on the IPPrec table:

7
6
5
4
3
2
1
0
2^5
2^4
2^3
2^2
2^1
2^0
x
x
32
16
8
4
2
1
x
x

We got 16 + 8 which equals to 24 in decimal

ToS Conversion

In order to convert any DSCP/IPPrec decimal to ToS value just multiple it in 4.
So AF41 equals to 34, 34 x 4 = 136
CS3 equals to 24, 24 x 4 = 96