Sub topic 17
BGP and Path-Vector Routing Between Autonomous Systems
This chapter assumes you know IPv4 prefixes, longest-prefix match, routing tables, and basic graph terminology. You should also know that an autonomous system (AS) is a network under one administrative authority.
BGP and path-vector routing
The Border Gateway Protocol (BGP) exchanges reachability information between autonomous systems. Internet service providers, companies, and cloud networks use BGP to advertise which IP prefixes they can reach.
BGP is a path-vector protocol. A path vector is a route plus the sequence of AS numbers used to reach that route. This differs from distance-vector routing, which usually advertises only a distance such as a hop count.
Suppose AS 65001 advertises 203.0.113.0/24 to AS 65002. AS 65002 records an AS path such as:
203.0.113.0/24 AS_PATH: 65001If AS 65002 advertises the route to AS 65003, the path becomes:
203.0.113.0/24 AS_PATH: 65002 65001The receiving AS can reject a route if its own number already appears in AS_PATH. This prevents many routing loops.
BGP also supports policy. An administrator can prefer one provider, reject a prefix, or advertise a route only to selected neighbors. Therefore, BGP does not necessarily choose the route with the fewest AS hops. Attributes such as local preference, AS_PATH, origin, and MED can influence the decision.
BGP sessions between different autonomous systems are called eBGP sessions. Sessions between routers inside the same autonomous system are called iBGP sessions. eBGP carries inter-domain routes, while iBGP distributes those routes within an AS.
A small model of path selection can make the idea concrete:
routes = [
{"prefix": "203.0.113.0/24", "local_pref": 100, "as_path": [64520, 64530]},
{"prefix": "203.0.113.0/24", "local_pref": 200, "as_path": [64540, 64530]},
]
best = max(routes, key=lambda route: (route["local_pref"], -len(route["as_path"])))
print(best)The second route wins because its local preference is higher, even though policy attributes are considered before path length.
Comparing routing approaches
Distance-vector routers exchange distance information with neighbors and use a Bellman-Ford-style calculation. Link-state routers flood link information, build a complete topology map, and run Dijkstra's algorithm. Path-vector routers exchange destination prefixes, AS paths, and policy attributes.
| Approach | Information exchanged | Typical algorithm | Main scope |
|---|---|---|---|
| Distance vector | Distance and next hop | Bellman-Ford | Small or older internal networks |
| Link state | Link-state advertisements | Dijkstra | One autonomous system |
| Path vector | Prefix, AS path, and policy | Policy-based selection | Between autonomous systems |
Distance-vector protocols are simple but can suffer from slow convergence and count-to-infinity. Link-state protocols converge quickly and provide a detailed topology view, but they require more memory and computation. BGP scales across the Internet because each AS hides its internal topology and applies administrative policy, but convergence and configuration can be complex.
Exercise
AS 65010 receives two routes to the same prefix. Route X has local preference 100 and an AS path of [65020, 65030]. Route Y has local preference 150 and an AS path of [65040, 65050, 65030]. Which route is normally preferred?
Show answer
Route Y, because BGP considers the higher local preference before AS-path length.