Computer Networks

Routing Protocols

RIP, OSPF, BGP: how routers learn paths they did not configure by hand.

Level: advanced

What is it?

Routing protocols exchange reachability information so routers can compute or select paths beyond directly connected networks. Interior Gateway Protocols such as OSPF operate within an administrative system; BGP exchanges reachability between autonomous systems using policy.

Why does it matter?

Networks change through failures, maintenance, and topology growth. Protocols update routes so operators do not have to configure every path manually, while metrics and policy control which routes are preferred.

Mental model

A routing protocol learns and evaluates candidate paths; the router installs selected routes in its routing information base, then programs forwarding entries for packet handling. Route learning and packet forwarding are distinct jobs.

How it works

  • Distance-vector, link-state, and path-vector protocols use different information and convergence models.
  • OSPF is a link-state IGP that computes paths using topology information and configured costs.
  • BGP is path-vector and policy-rich; AS_PATH and other attributes inform route selection, not simply shortest hop count.
  • Administrative distance or route preference between sources is implementation-specific and separate from a protocol's metric.
  • Incorrect route redistribution or policy can leak routes, create loops, or cause traffic to take unexpected paths.

Steps

  • Routers discover neighbors and exchange protocol-specific routing information.
  • They validate, filter, and compute candidate routes from topology/attributes and policy.
  • The selected route is installed in the RIB and relevant forwarding plane.
  • When a link or route changes, the protocol converges and operators verify the actual forwarding path.

Real-world usage

  • Operating enterprise or service-provider networks.
  • Explaining OSPF versus BGP and routing convergence.
  • Troubleshooting asymmetric routes and route leaks.

Common mistakes

  • Assuming routing always chooses the path with fewest hops.
  • Confusing route advertisements with actual forwarding entries.
  • Changing BGP/OSPF policy without considering export filters, aggregation, and failure behavior.

Interview questions

How does OSPF differ from BGP?

OSPF is a link-state interior routing protocol; BGP is a path-vector protocol used between autonomous systems and strongly shaped by policy.

What is convergence?

The process by which routers update their state and forwarding choices after a topology or reachability change.

Prerequisites

Related concepts

Continue learning

Browse the full computer science library