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:
    1. Destination: The IP address of the destination network.
    2. Next Hop: The IP address of the next router to send the packet.
    3. Metric: A value used to choose the best path (e.g., hop count, bandwidth).
    4. Interface: The router’s outgoing interface to reach the next hop.
  • Types of Routing Entries:
    1. Directly Connected: Routes to networks directly attached to the router.
    2. Static Routes: Manually configured routes.
    3. Dynamic Routes: Automatically learned via routing protocols (e.g., RIP, OSPF, BGP).
  • Routing Table Lookup Process:
    1. Check for exact match (longest prefix match).
    2. Select the route with the lowest metric.
    3. 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:
    1. Start from the source node.
    2. Assign a cost of 0 to the source and infinity to all other nodes.
    3. Visit the node with the smallest cost and update neighbors’ costs.
    4. 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:
    1. Start with all distances set to infinity, except the source (0).
    2. Relax all edges repeatedly (update costs if a shorter path is found).
    3. 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

FeatureDijkstraBellman-Ford
TypeGreedyDynamic Programming
UpdatesRequires full topologyUses neighbor info only
ConvergenceFasterSlower
Negative WeightsNot supportedSupported
Routing ProtocolOSPFRIP

Quick Mnemonics

  1. Routing Table: “Destination Next, Metric Best!” (Destination, Next Hop, Metric).
  2. Dijkstra: “DJ = Direct Journey!” (Shortest path).
  3. Bellman-Ford: “BF = Best Friend for all paths!”