BGP: Path Selection Criteria - Path Vector Protocol
Today we will talk about the BGP path selection and we will come up with all these parameters in details in another post where we will discuss the functionality of the features like Next Hop, AS Path, Local Preference, Weight ( Cisco Propriety ), MED ( Multi Exit Discriminator ) in detail as we will dedicatedly have the posts on all the BGP path selections parameters.
Lets Start with the BGP Path selection criteria. First of all I will let you know that BGP is a Path vector protocol and is as application protocol which uses TCP port number 179 on local side to communicate. So don't be confuse that it is a layer 3 protocol.
First of all we will discuss on the basic specifications of the BGP ( Border Gateway Protocol ) as below:
Specifications of BGP( Border Gateway Protocol)
TCP 179 port local and an Application Protocol.
AD: eBGP AD: 20; iBGP AD: 200
BGP used when we need to connect to different AS numbers ( Autonomous Systems) with larger values of the routes in count.
Below is the basic topology Showing the BGP in the MPLS Scenario
Highest LOCAL_PREF will be preferred ( two routers with two paths from different service providers)
Note: A path without LOCAL_PREF is considered to have had the value set with the bgp default local-preference command, or to have a value of 100 by default. It can be used with any router( Cisco, juniper, Huawei and so on)
LOCALLY ORIGINATED
locally originated path will be preferred via a network or aggregate BGP subcommand or through redistribution from an IGP.
Local paths that are sourced by the network or redistribute commands are preferred over local aggregates that are sourced by the aggregate-address command.
AS-PATH
Shortest AS_PATH will be preferred
This step is skipped if you have configured the bgp bestpath as-path ignore command.
An AS_SET counts as 1, no matter how many ASs are in the set.
The AS_CONFED_SEQUENCE and AS_CONFED_SET are not included in the AS_PATH length.
ORIGIN TYPE
Lowest origin type will be preferred.
IGP is lower than Exterior Gateway Protocol (EGP), and EGP is lower than INCOMPLETE.
MED
Lowest multi-exit discriminator (MED).
This comparison only occurs if the first (the neighboring) AS is the same in the two paths. Any confederation sub-ASs are ignored.
In other words, MEDs are compared only if the first AS in the AS_SEQUENCE is the same for multiple paths. Any preceding AS_CONFED_SEQUENCE is ignored.
THE MED of paths that are received from a neighbor with a MED of 4,294,967,295 is changed before insertion into the BGP table. The MED changes to to 4,294,967,294.
THE MED of paths that are received from a neighbor with a MED of 4,294,967,295 are considered valid and are inserted into BGP table with effect to Codes fixed for Cisco bug ID CSCef34800.
Paths received with no MED are assigned a MED of 0, unless you have enabled bgp bestpath med missing-as-worst .
If you have enabled bgp bestpath med missing-as-worst , the paths are assigned a MED of 4,294,967,294.
If you have enabled bgp bestpath med missing-as-worst , the paths are assigned a MED of 4,294,967,295 with effect to Codes fixed for Cisco bug ID CSCef34800.
The bgp deterministic-med command can also influence this step.
Refer to How BGP Routers Use the Multi-Exit Discriminator for Best Path Selection for a demonstration.
PREFFERED ROUTE
eBGP over iBGP paths will be preferred.
If bestpath is selected, go to Step 9 (multipath).
Note: Paths that contain AS_CONFED_SEQUENCE and AS_CONFED_SET are local to the confederation. Therefore, these paths are treated as internal paths. There is no distinction between Confederation External and Confederation Internal.
METRIC
Lowest IGP metric to the BGP next hop will be preferred.
Continue, even if bestpath is already selected.
MULTIPATH
Determine if multiple paths require installation in the routing table for BGP Multipath.
Continue, if bestpath is not yet selected.
OLDEST ROUTE
When both paths are external, then path that was received first (the oldest one) will be preferred.
The router ID is the same for multiple paths because the routes were received from the same router.
There is no current best path.
The current best path can be lost when, for example, the neighbor that offers the path goes down.
ROUTER-ID
BGP router with the lowest router ID.
The router ID is the highest IP address on the router, with preference given to loopback addresses. Also, you can use the bgp router-id command to manually set the router ID.
Note: If a path contains route reflector (RR) attributes, the originator ID is substituted for the router ID in the path selection process.
RR ORIGINATOR ID
If the originator or router ID is the same for multiple paths, path with the minimum cluster list length will be preferred
This is only present in BGP RR environments. It allows clients to peer with RRs or clients in other clusters. In this scenario, the client must be aware of the RR-specific BGP attribute.
NEIGHBOR ADDRESS
Path that comes from the lowest neighbor address will be preferred
This address is the IP address that is used in the BGP neighbor configuration. The address corresponds to the remote peer that is used in the TCP connection with the local router.
Thanks for be the part of this post, we will come up with the detail session and the use cases where to use which parameters and how the traffic can be controlled in the network, It can be the traffic inside to the network and going from the network to the service provider. Make sure if you are talking about these parameters BGP should be used.
Lets Start with the BGP Path selection criteria. First of all I will let you know that BGP is a Path vector protocol and is as application protocol which uses TCP port number 179 on local side to communicate. So don't be confuse that it is a layer 3 protocol.
First of all we will discuss on the basic specifications of the BGP ( Border Gateway Protocol ) as below:
Specifications of BGP( Border Gateway Protocol)
TCP 179 port local and an Application Protocol.
AD: eBGP AD: 20; iBGP AD: 200
BGP used when we need to connect to different AS numbers ( Autonomous Systems) with larger values of the routes in count.
Below is the basic topology Showing the BGP in the MPLS Scenario
Fig 1.1- BGP in MPLS Scenario |
WEIGHT
Highest WEIGHT attribute will be preferred First ( can be used in one router with two paths)
Highest WEIGHT attribute will be preferred First ( can be used in one router with two paths)
WEIGHT is a Cisco-specific parameter. It is only used when you have Cisco Routers.
LOCAL PREFERENCEFig 1.2- BGP Attributes |
Highest LOCAL_PREF will be preferred ( two routers with two paths from different service providers)
Note: A path without LOCAL_PREF is considered to have had the value set with the bgp default local-preference command, or to have a value of 100 by default. It can be used with any router( Cisco, juniper, Huawei and so on)
LOCALLY ORIGINATED
locally originated path will be preferred via a network or aggregate BGP subcommand or through redistribution from an IGP.
Local paths that are sourced by the network or redistribute commands are preferred over local aggregates that are sourced by the aggregate-address command.
AS-PATH
Shortest AS_PATH will be preferred
This step is skipped if you have configured the bgp bestpath as-path ignore command.
An AS_SET counts as 1, no matter how many ASs are in the set.
The AS_CONFED_SEQUENCE and AS_CONFED_SET are not included in the AS_PATH length.
ORIGIN TYPE
Lowest origin type will be preferred.
IGP is lower than Exterior Gateway Protocol (EGP), and EGP is lower than INCOMPLETE.
MED
Lowest multi-exit discriminator (MED).
This comparison only occurs if the first (the neighboring) AS is the same in the two paths. Any confederation sub-ASs are ignored.
In other words, MEDs are compared only if the first AS in the AS_SEQUENCE is the same for multiple paths. Any preceding AS_CONFED_SEQUENCE is ignored.
- If bgp always-compare-med is enabled, MEDs are compared for all paths.
- You must disable this option over the entire AS. Otherwise, routing loops can occur.
- If bgp bestpath med-confed is enabled, MEDs are compared for all paths that consist only of AS_CONFED_SEQUENCE.
THE MED of paths that are received from a neighbor with a MED of 4,294,967,295 is changed before insertion into the BGP table. The MED changes to to 4,294,967,294.
THE MED of paths that are received from a neighbor with a MED of 4,294,967,295 are considered valid and are inserted into BGP table with effect to Codes fixed for Cisco bug ID CSCef34800.
Paths received with no MED are assigned a MED of 0, unless you have enabled bgp bestpath med missing-as-worst .
If you have enabled bgp bestpath med missing-as-worst , the paths are assigned a MED of 4,294,967,294.
If you have enabled bgp bestpath med missing-as-worst , the paths are assigned a MED of 4,294,967,295 with effect to Codes fixed for Cisco bug ID CSCef34800.
The bgp deterministic-med command can also influence this step.
Refer to How BGP Routers Use the Multi-Exit Discriminator for Best Path Selection for a demonstration.
PREFFERED ROUTE
eBGP over iBGP paths will be preferred.
If bestpath is selected, go to Step 9 (multipath).
Note: Paths that contain AS_CONFED_SEQUENCE and AS_CONFED_SET are local to the confederation. Therefore, these paths are treated as internal paths. There is no distinction between Confederation External and Confederation Internal.
METRIC
Lowest IGP metric to the BGP next hop will be preferred.
Continue, even if bestpath is already selected.
MULTIPATH
Determine if multiple paths require installation in the routing table for BGP Multipath.
Continue, if bestpath is not yet selected.
OLDEST ROUTE
When both paths are external, then path that was received first (the oldest one) will be preferred.
The router ID is the same for multiple paths because the routes were received from the same router.
There is no current best path.
The current best path can be lost when, for example, the neighbor that offers the path goes down.
ROUTER-ID
BGP router with the lowest router ID.
The router ID is the highest IP address on the router, with preference given to loopback addresses. Also, you can use the bgp router-id command to manually set the router ID.
Note: If a path contains route reflector (RR) attributes, the originator ID is substituted for the router ID in the path selection process.
RR ORIGINATOR ID
If the originator or router ID is the same for multiple paths, path with the minimum cluster list length will be preferred
This is only present in BGP RR environments. It allows clients to peer with RRs or clients in other clusters. In this scenario, the client must be aware of the RR-specific BGP attribute.
NEIGHBOR ADDRESS
Path that comes from the lowest neighbor address will be preferred
This address is the IP address that is used in the BGP neighbor configuration. The address corresponds to the remote peer that is used in the TCP connection with the local router.
Thanks for be the part of this post, we will come up with the detail session and the use cases where to use which parameters and how the traffic can be controlled in the network, It can be the traffic inside to the network and going from the network to the service provider. Make sure if you are talking about these parameters BGP should be used.