Concepts of Routing Tables and Shortest Path Algorithms

✔ What is a Routing Table?

A routing table is like a map inside a router. It tells the router where to send the data.

Every time a packet arrives, the router checks this map and chooses the best path.


✔ What does a Routing Table contain?

Think of it like a delivery guide:

TermSimple Meaning
DestinationWhere the packet wants to go
Next HopThe next router on the way (like the next city)
MetricHow good the path is (lower = better)
InterfaceWhich door (port) the router should send the packet through

✔ Types of Routes

1️⃣ Direct Routes – The network is directly connected.
2️⃣ Static Routes – The Administrator manually adds the route.
3️⃣ Dynamic Routes – Router learns routes automatically (RIP/OSPF/BGP).


✔ How does the router choose the route?

Very simple:

  1. Find the closest matching route
  2. Choose the route with the smallest metric
  3. Forward the packet

That’s it!


Shortest Path Algorithms

Routers use algorithms to decide the best path to send the data.

Two important algorithms:

  • Dijkstra (used by OSPF)
  • Bellman-Ford (used by RIP)

🌟 1. Dijkstra’s Algorithm

Think of Dijkstra like Google Maps:

✔ Always picks the shortest and fastest path
✔ Works very quickly
✔ Needs the full map of the network

Steps (super simple):

  1. Start at the source
  2. See all the neighbors
  3. Choose the closest one
  4. Continue until the destination is reached

👉 Used in OSPF


🌟 2. Bellman-Ford Algorithm

Bellman-Ford is like asking neighbors:

✔ Each router tells its neighbors how far other networks are
✔ It slowly learns the best path
✔ Works even if links change often
✔ Slower than Dijkstra

Steps:

  1. Start with “infinity” distance
  2. Keep improving the distance step by step
  3. Repeat many times until the best path is found

👉 Used in RIP


Dijkstra vs Bellman-Ford

FeatureDijkstra (OSPF)Neighbour info only
SpeedFastSlow
Info NeededFull mapNeighbor info only
Best ForLarge networksSmall networks
Supports Negative Cost?NoYes
Real UseOSPFRIP

Simple Memory Tricks

✔ Routing Table

“Destination → Next Hop → Best Metric = Best Path”

✔ Dijkstra

“D = Direct Fast Path”

✔ Bellman-Ford

“BF = Best Found after asking friends (neighbors)”


Final Summary

  • A routing table is a map that tells the router where to send data.
  • Dijkstra = fast, shortest-path method (OSPF).
  • Bellman-Ford = slower, neighbor-based method (RIP).
  • Both help routers choose the best path to forward data.