Routing is the process of forwarding packets from source to destination across intermediate routers. Each router maintains a routing table that tells it which interface to forward a packet through for each destination network.
Static vs Dynamic Routing
| Static | Dynamic | |
|---|---|---|
| Configuration | Manual | Automatic via routing protocols |
| Adaptability | Doesn’t adapt to failures | Automatically recovers from failures |
| Overhead | None | Protocol traffic, CPU usage |
| Use case | Small, stable networks | Large, changing networks |
Distance Vector (e.g., RIP)
Each router periodically shares its entire routing table with directly connected neighbors.
- Metric: hop count (max 16 = unreachable)
- Algorithm: Bellman-Ford
- Update frequency: Every 30 seconds
- Problems: Slow convergence (count to infinity), routing loops
Count-to-infinity: Router A loses link to X. Router B says “I can reach X in 2 hops” (stale info). A updates to 3 hops via B. B now sees “A can reach X in 3 hops” → B updates to 4. The number increases until it reaches ∞ (16 for RIP).
Link State (e.g., OSPF)
Each router floods information about its directly connected links to all routers in the area. Every router builds a complete map of the network and runs Dijkstra’s algorithm.
- Metric: Cost (typically based on bandwidth)
- Algorithm: Dijkstra’s Shortest Path First (SPF)
- Update: Only when a link state changes (triggered updates)
- Convergence: Fast — milliseconds to seconds
EGP vs IGP
| Type | Purpose | Examples |
|---|---|---|
| IGP (Interior Gateway Protocol) | Routing within an Autonomous System | RIP, OSPF, EIGRP |
| EGP (Exterior Gateway Protocol) | Routing between Autonomous Systems | BGP |
BGP is the routing protocol of the internet — ISPs use it to exchange routes globally.
Q: Compare RIP and OSPF.
A: RIP is distance vector — shares entire table with neighbors, uses hop count (max 15), slow convergence. OSPF is link state — floods link info to all routers, uses cost metric, runs Dijkstra, fast convergence. Use RIP for small/simple networks; OSPF for larger enterprise networks.
Q: What is an Autonomous System (AS)?
A: A collection of IP networks under a single administrative domain — e.g., an ISP, a university, or a company like Google. Each AS has a unique ASN (16-bit or 32-bit number) used in BGP routing.
Q: What is a default route?
A: 0.0.0.0/0 — the “catch-all” entry. If no more specific route matches, the router forwards the packet via the default route (usually toward the internet gateway).
Q: What is the count-to-infinity problem?
A: In distance vector routing, when a link fails, routers can form a loop where each thinks the other has a path. The hop count increments until it reaches infinity (16 in RIP), causing slow convergence. Solved by split horizon, route poisoning, and hold-down timers.
Premium Content
Unlock Routing Basics & Algorithms and all premium lessons with a subscription.
From ₹199.99/year — See plans