📖 Scenario: You are simulating a simple network router using the Distance Vector Routing protocol (RIP). Each router keeps a table of distances (costs) to other routers in the network. Your task is to create and update this routing table step-by-step.
🎯 Goal: Build a routing table for a router using Distance Vector Routing (RIP) principles. You will create the initial routing table, set a maximum hop count, update the routing table with new distances, and finalize the routing table with the correct hop counts.
📋 What You'll Learn
Create an initial routing table as a dictionary with exact router names and distances
Add a maximum hop count variable to limit route distances
Update the routing table by applying the distance vector update rule
Finalize the routing table by marking unreachable routers with 'Infinity'
💡 Why This Matters
🌍 Real World
Distance Vector Routing is used in real networks to find the best path between routers by sharing distance information.
💼 Career
Network engineers and developers working with routing protocols need to understand how routing tables update and how to simulate or troubleshoot routing behavior.
Progress0 / 4 steps
1
Create the initial routing table
Create a dictionary called routing_table with these exact entries: 'A': 0, 'B': 1, 'C': 5, 'D': 10. This represents the current known distances from the router to others.
Computer Networks
Hint
Use a Python dictionary with router names as keys and distances as values.
2
Set the maximum hop count
Create a variable called max_hops and set it to 15. This will be the maximum allowed distance for routes in the routing table.
Computer Networks
Hint
Just assign the number 15 to the variable max_hops.
3
Update routing table with new distances
Use a for loop with variables router and distance to iterate over routing_table.items(). For each router, add 1 to the distance to simulate a hop to a neighbor. Update the routing_table with the new distances only if the new distance is less than or equal to max_hops.
Computer Networks
Hint
Loop through the dictionary items, calculate new distances, and update only if within max_hops.
4
Mark unreachable routers
Use a for loop with variables router and distance to iterate over routing_table.items(). For any router with a distance greater than max_hops, set its distance to the string 'Infinity' to mark it as unreachable.
Computer Networks
Hint
Loop again to check distances and replace those too large with 'Infinity'.
Practice
(1/5)
1. What is the main metric used by Distance Vector Routing Protocol (RIP) to determine the best path?
easy
A. Hop count
B. Bandwidth
C. Delay
D. Cost
Solution
Step 1: Understand RIP metric
RIP uses hop count as the metric to measure the distance to a destination network.
Step 2: Compare with other metrics
Other protocols may use bandwidth, delay, or cost, but RIP specifically uses hop count.
Final Answer:
Hop count -> Option A
Quick Check:
RIP metric = Hop count [OK]
Hint: RIP counts hops, not speed or delay [OK]
Common Mistakes:
Confusing hop count with bandwidth
Thinking RIP uses delay as metric
Assuming cost is used in RIP
2. Which of the following is the correct way RIP routers share their routing information?
easy
A. Routers send their entire routing table to neighbors periodically
B. Routers send only changed routes immediately
C. Routers broadcast only the best route to each destination
D. Routers send routing updates only when a link fails
Solution
Step 1: Recall RIP update method
RIP routers send their full routing tables to all neighbors at regular intervals.
Step 2: Contrast with other methods
Other protocols may send only changes or triggered updates, but RIP sends full tables periodically.
Final Answer:
Routers send their entire routing table to neighbors periodically -> Option A
Quick Check:
RIP sends full tables periodically [OK]
Hint: RIP sends full tables regularly, not just changes [OK]
Common Mistakes:
Thinking RIP sends only changed routes
Assuming RIP uses triggered updates only
Believing RIP sends partial route info
3. Consider a RIP network where Router A has routes: Network X (2 hops), Network Y (3 hops). Router B receives this info and has Network X (1 hop), Network Y (4 hops). After update, what is Router B's hop count to Network Y?
medium
A. 3 hops
B. 2 hops
C. 5 hops
D. 4 hops
Solution
Step 1: Understand RIP update rule
Router B updates routes by adding 1 hop to neighbors' hop counts.
Step 2: Calculate new hop count for Network Y
Router A reports 3 hops to Network Y, so Router B's new cost is 3 + 1 = 4 hops. But Router B already has 4 hops, so it keeps 4 hops.
Step 3: Check if better route exists
Router B's own route is 4 hops, neighbor's route plus 1 is also 4 hops, so it keeps 4 hops.
Final Answer:
4 hops -> Option D
Quick Check:
Neighbor hops + 1 = 4 hops [OK]
Hint: Add 1 hop to neighbor's count, pick smallest [OK]
Common Mistakes:
Forgetting to add 1 hop to neighbor's count
Choosing neighbor's hop count without adding 1
Ignoring existing route cost
4. A RIP router is not updating its routing table correctly and keeps old routes indefinitely. What is the most likely cause?
medium
A. The router has a maximum hop count set too high
B. The router is using link-state routing instead of distance vector
C. The router is not receiving periodic updates from neighbors
D. The router is sending triggered updates too frequently
Solution
Step 1: Identify update mechanism in RIP
RIP relies on periodic updates from neighbors to refresh routing tables.
Step 2: Analyze symptom
If the router keeps old routes indefinitely, it likely isn't receiving these updates.
Final Answer:
The router is not receiving periodic updates from neighbors -> Option C
Quick Check:
No updates received = stale routes [OK]
Hint: No updates received means routes never refresh [OK]
Common Mistakes:
Confusing routing protocol type
Thinking hop count setting causes stale routes
Assuming triggered updates cause stale routes
5. In a network using RIP, a router receives two routes to the same destination: one with 3 hops via Router X and another with 3 hops via Router Y. Which route will RIP choose and why?
hard
A. The route learned first, because RIP prefers the earliest route
B. Either route, because RIP considers equal hop counts as equal cost
C. The route with the lowest IP address of the next hop router
D. The route with the highest bandwidth link
Solution
Step 1: Understand RIP route selection
RIP selects routes based on hop count; if multiple routes have the same hop count, they are considered equal cost.
Step 2: Analyze tie-breaking in RIP
RIP can load balance across equal-cost routes or pick any; it does not prefer based on IP or bandwidth.
Final Answer:
Either route, because RIP considers equal hop counts as equal cost -> Option B
Quick Check:
Equal hops = equal cost, any route chosen [OK]
Hint: Equal hops mean equal cost; RIP can use either route [OK]
Common Mistakes:
Assuming RIP prefers first learned route
Thinking RIP uses next hop IP to decide
Believing RIP considers bandwidth in route choice
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.