In IGP best path is chosen based on the lowest metric value.
But in BGP we can choose the best path based on many other parameters other than metric.
This feature of not depending on metric for selecting the best path gives the network engineer more flexibility.
BGP forms neighborship with the neigboring router and then shares the topology information with that neighbor.
BGP advertises the IPv4 prefixes.
In BGP, its not compulsoy for the two routers to be on the same subnet to become neighbors.The BGP messages are exchanged between the two neighbors through a TCP connection which uses the port 179. Because of this reason, the two neighbors can be on the same subnet or away from each other with many other routers between them.
BGP shares the information called BGP path attributes in its updates. It uses these path attributes to choose the best path.
In BGP AS path PA consists of a list of ASN's ............
The AS_Path can be used to choose the best route and to prevent routing loops.
Example
R4 advertises the route outside ASN4. So R4 adds its own ANS(4) to the AS_Path PA when advertising the route.
R8 when advertising the route outside ASN8 will add its own ASN(8) to the AS_Path PA. Their advertised AS_Path is then (4,8).
R7 when advertising the route outside ASN7 will add its own ASN(7) to the AS_Path PA. Their advertised AS_Path is then (4,8,7).
R6 when advertising the route outside ASN6 will add its own ASN(6) to the AS_Path PA. Their advertised AS_Path is then (4,8,7,6).
R3 when advertising the route outside ASN3 will add its own ASN(3) to the AS_Path PA. Their advertised AS_Path is then (4,8,7,6,3).
R2 will learn the routes from two different ASN's ASN6 and ASN3 with two different AS_Path PA as below
x.x.x.x ((4,8,7,6)
x.x.x.x (4,8,7,6,3)
Now the BGP will choose the shortest AS_Path as the path for the prefix, which is x.x.x.x ((4,8,7,6).
BGP also uses the AS_Path PA to prevent loops. When the BGP router receives a route advertisement which contains its own ASN in the AS_Path then the router ignores that route.
x