Concepts of Routing Tables and Shortest Path Algorithms
1. Concepts of Routing Tables
- What is a Routing Table?
A database used by routers to determine the best path for forwarding packets to their destination.
- Key Components of a Routing Table:
- Destination: The IP address of the destination network.
- Next Hop: The IP address of the next router to send the packet.
- Metric: A value used to choose the best path (e.g., hop count, bandwidth).
- Interface: The router’s outgoing interface to reach the next hop.
- Types of Routing Entries:
- Directly Connected: Routes to networks directly attached to the router.
- Static Routes: Manually configured routes.
- Dynamic Routes: Automatically learned via routing protocols (e.g., RIP, OSPF, BGP).
- Routing Table Lookup Process:
- Check for exact match (longest prefix match).
- Select the route with the lowest metric.
- Forward to the next hop or interface.
2. Shortest Path Algorithms
- Purpose: To find the most efficient path between two nodes in a network.
- Key Algorithms:
a. Dijkstra’s Algorithm (OSPF Uses This)
- Type: Greedy algorithm.
- Purpose: Finds the shortest path from the source to all other nodes.
- Steps:
- Start from the source node.
- Assign a cost of 0 to the source and infinity to all other nodes.
- Visit the node with the smallest cost and update neighbors’ costs.
- Repeat until all nodes are visited.
- Key Feature: Builds a shortest-path tree (SPT).
- Best for: Networks with reliable links.
b. Bellman-Ford Algorithm (RIP Uses This)
- Type: Distance-vector algorithm.
- Purpose: Calculates the shortest path from a single source to all other nodes.
- Steps:
- Start with all distances set to infinity, except the source (0).
- Relax all edges repeatedly (update costs if a shorter path is found).
- Repeat for (n-1) iterations, where n = number of nodes.
- Key Feature: Handles negative weights.
- Best for: Smaller networks or dynamic topologies.
3. Key Comparison of Dijkstra vs. Bellman-Ford
Feature | Dijkstra | Bellman-Ford |
---|
Type | Greedy | Dynamic Programming |
Updates | Requires full topology | Uses neighbor info only |
Convergence | Faster | Slower |
Negative Weights | Not supported | Supported |
Routing Protocol | OSPF | RIP |
Quick Mnemonics
- Routing Table: “Destination Next, Metric Best!” (Destination, Next Hop, Metric).
- Dijkstra: “DJ = Direct Journey!” (Shortest path).
- Bellman-Ford: “BF = Best Friend for all paths!”