✔ 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:
| Term | Simple Meaning |
|---|---|
| Destination | Where the packet wants to go |
| Next Hop | The next router on the way (like the next city) |
| Metric | How good the path is (lower = better) |
| Interface | Which 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:
- Find the closest matching route
- Choose the route with the smallest metric
- 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):
- Start at the source
- See all the neighbors
- Choose the closest one
- 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:
- Start with “infinity” distance
- Keep improving the distance step by step
- Repeat many times until the best path is found
👉 Used in RIP
⭐ Dijkstra vs Bellman-Ford
| Feature | Dijkstra (OSPF) | Neighbour info only |
|---|---|---|
| Speed | Fast | Slow |
| Info Needed | Full map | Neighbor info only |
| Best For | Large networks | Small networks |
| Supports Negative Cost? | No | Yes |
| Real Use | OSPF | RIP |
⭐ 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.
