Path-Vector Routing: How BGP Sees the Internet
Why BGP is a path-vector protocol - carrying the whole AS_PATH for loop prevention, policy, and internet-scale routing.
Path-Vector Routing: How BGP Sees the Internet
Every routing protocol has to answer one question: "To reach this destination, where do I send the packet?" What separates the protocol families is how much each router knows when it answers. BGP belongs to its own family, path-vector, and the difference is the key to how it scales to the entire internet. Let's place it next to its two cousins.
The three families at a glance
| Family | Examples | What each router knows |
|---|---|---|
| Distance-vector | RIP, EIGRP | A destination + a metric, via a neighbor |
| Link-state | OSPF, IS-IS | A full map of the whole domain |
| Path-vector | BGP | The full list of ASes to reach a destination |
Distance-vector: "trust your neighbor's homework"
A distance-vector router never sees the network. It only hears, from each directly-connected neighbor, "I can reach 10.0.0.0/8 at a cost of 3 hops." It adds the cost of the link to that neighbor and picks the lowest total. This is the Bellman-Ford algorithm, routing by rumor.
It's simple and cheap, but it has a famous flaw. Because no router sees the topology, only "distance via a neighbor", when a link fails, routers can keep advertising stale distances back and forth, each incrementing the metric. This is the count-to-infinity problem, and it makes classic distance-vector protocols converge slowly.
Link-state: "everyone holds the same map"
Link-state protocols flip the model. Every router floods a description of its own links to every other router, so they all build an identical Link-State Database (LSDB): a complete map of the domain. Each router then runs Dijkstra's algorithm (SPF) on that map to compute the shortest path to everything.
This converges fast and avoids loops, because nobody is routing by rumor; they're all reading the same map. It's excellent inside a single organization. But it does not work for the whole internet:
- A global LSDB would be impossibly huge, and every change would re-flood everywhere.
- It would expose internal topology: no operator wants to publish their internal router map to the world.
Link-state is built for one administrative domain, not for a network of competing networks.
Path-vector: distance-vector that remembers the whole road
BGP keeps the simple "tell your neighbor" style of distance-vector, but instead of a hop-count metric, each advertisement carries the AS_PATH: the ordered list of every autonomous system the route passed through. You don't learn a distance; you learn the whole road.
Watch an AS_PATH build up, one AS at a time, as the prefix 203.0.113.0/24 (originated in AS 64500) travels outward:
By the time the route reaches AS 64503, its AS_PATH is 64503 64502 64501 64500, which reads as: "to reach 203.0.113.0/24, go through these ASes, ending at AS 64500 where it lives." Every AS that re-advertises the prefix prepends its own ASN to the front. The full provenance travels with the route.
The killer feature: loop prevention
That carried path isn't just informational: it's how BGP stays loop-free, with no count-to-infinity at all. The rule is one line:
If a router receives a route whose AS_PATH already contains its own ASN, it rejects the route.
A router seeing itself in the path knows the advertisement is an echo that already passed through it.
No metric counting up to infinity, no waiting for timers: the loop is caught instantly by inspecting the path. This is why path-vector converges cleanly at internet scale.
The same path drives policy
Because the AS_PATH is right there in every route, it also powers BGP's decision-making:
- Default preference: when two paths reach the same prefix, BGP prefers the one with the shorter AS_PATH: fewer ASes to traverse.
- Policy filtering: operators can match on the path itself, "don't accept any route that transits AS 64502," or "only accept customer routes."
- Tie-breaking: AS_PATH length is a major step in BGP's best-path selection algorithm (we walk the full decision tree later in the Path Attributes & Best-Path Selection module).
The path is data and policy lever at once.
Why path-vector scales: abstraction
Here's the punchline. A link-state protocol would need every router on the internet in one database. BGP never does that. It abstracts away internal topology: you only ever see the AS-level path, never the routers inside each AS.
Each AS is a single opaque node on the path. The internet has fewer than 100,000 ASes but millions of routers. By routing at the AS level, BGP shrinks an impossible problem to a merely large one, while letting every operator keep their internals private.
What's next
You now have the mental model: BGP is path-vector: distance-vector that carries the entire AS_PATH, using it for loop prevention, policy, and scale. Next, in bgp-sessions-and-messages, we get concrete about how two BGP routers actually talk: the TCP/179 connection, the four message types, and the state machine a session climbs to reach Established.