Three Approaches to Route Packets
Algorithm 1: Cost-Based (Shortest Path First)
Goal: Find the cheapest path from source to destination
How it works:
- Each link has a "cost" (could be distance, time, or money)
- Calculate total cost for each possible path
- Choose the path with minimum cost
- Drop packets sent on inefficient paths
🎓 Example: The "$90 Budget" Problem
Scenario: You have $90 to get from point A to point F
Path 1: A → B → E → F (costs: $30 + $20 + $30 = $80)
Path 2: A → C → D → F (costs: $25 + $15 + $20 = $60) ✓
Result: Choose Path 2 (cheaper). Packets on Path 1 get dropped!
Metaphor: It's like choosing the cheapest flight - you book that one and ignore the expensive options.
Algorithm 2: Flooding
Goal: Make sure the packet reaches the destination (reliability over efficiency)
How it works:
- Send packets on ALL possible paths
- Avoid creating loops (no infinite cycles)
- Create a spanning tree (tree structure with no loops)
- Many duplicate packets, but guaranteed delivery
🎓 Example: Emergency Broadcast
Like sending a group text: Everyone gets the message through multiple routes!
- A sends to B and C
- B sends to D and E (but not back to A - that would be a loop)
- C sends to F and G (but not back to A)
Rule: Never send back to where you came from (prevents loops)
⚠️ Trade-off:
Pro: Guaranteed delivery, works even if some links fail
Con: Creates many duplicate packets, wastes bandwidth
Algorithm 3: Shortest Path Tree
Goal: Combine the best of both - efficient AND organized
How it works:
- Use cost information from Algorithm 1
- Use tree structure from Algorithm 2
- Create a diagram showing ONLY the optimal paths
- Visualize the "winning" routes as a tree
🎓 Example: GPS Navigation Map
Think of Google Maps:
- Calculates shortest path to each destination
- Shows you ONE best route (not all possible routes)
- Creates a "tree" of optimal paths from your location
This is the easiest algorithm to visualize - just draw the winning paths!
Calculating Duplicate Packets
In routing algorithms, you can calculate duplicate packets using:
Duplicate Packets ≈ (Number of paths tried) - (Optimal paths used)
Or use the DVR (Distance Vector Routing) tables to count entries.
💡 Quick Comparison:
Algorithm 1: Cheapest route, fewest packets ✓
Algorithm 2: Most reliable, most packets ✗
Algorithm 3: Best visualization, practical use ✓✓