šŸŽ“ BookMCQ
← Back to 20. Unicast Routing

šŸ“ Link State Routing algorithm Dijkstra (16 MCQs)

Topology-Based Routing with Dijkstra Shortest Paths

Link state routing allows each router to build a map of the routing area from advertised link information. Routers describe their interfaces, neighbors, and link costs through link-state advertisements, which are distributed to other routers in the same area. Each router then independently runs a shortest-path algorithm to calculate routes from its own position rather than only directly connected immediate neighbors.

Link-State Database and Dijkstra Processing

The collected advertisements form a link-state database representing the area's topology. Dijkstra's algorithm starts with the calculating router as the root, repeatedly selects the closest unprocessed node, and relaxes the costs of its adjacent links. The resulting shortest-path tree supplies preferred next hops for reachable networks and prefixes throughout that area.

Neighbor Discovery, Flooding and Route Installation

Routers first discover neighbors and form protocol adjacencies. They exchange database information, request missing link-state records, and flood new or changed advertisements reliably within the area. After updating the database, each router runs the shortest-path calculation and installs eligible routes in its routing table, repeating the process when topology changes require recalculation.

A Simple Dijkstra Route Calculation

Assume Router A has links to B with cost 2 and to C with cost 5; B connects to C with cost 1. Dijkstra first selects B at cost 2, then updates the path to C through B to cost 3. The preferred route from A to C therefore passes through B, not the direct link costing 5.

OSPF as a Link-State Routing Protocol

Open Shortest Path First uses link-state routing within an autonomous system and organizes routers into areas to limit topology information and calculation scope. Link-state advertisements describe network information, while the link-state database provides the input to shortest-path calculation. Area Border Routers exchange inter-area reachability between areas, with Area 0 serving as the backbone within large routing domains of the organization.

Misconceptions About Link-State Routing

'Every router receives every Internet route through OSPF' is incorrect because OSPF operates within an autonomous system and scopes link-state data by area. 'Dijkstra runs only on one central router' is incorrect because each router calculates its own tree. 'An LSA is the same as an IP data packet' is incorrect because it carries routing control information.

Solving Dijkstra and OSPF Questions

Students should construct a shortest-path tree, update tentative distances, and identify each final predecessor or next hop. For OSPF, distinguish neighbor discovery, adjacency formation, LSA flooding, database synchronization, and SPF calculation. Recognize common OSPF packet functions and explain how areas reduce the amount of topology information processed by routers when topology changes.

Link State Routing algorithm Dijkstra: Key Terms

  • Link state - Information describing a router link.
  • LSA - Advertisement carrying link-state information.
  • LSDB - Database of collected link-state advertisements.
  • Dijkstra - Algorithm that calculates shortest paths.
  • SPF tree - Shortest-path tree rooted at a router.
  • Area - OSPF topology and flooding scope.
5
Easy
7
Medium
4
Hard

šŸ“ All Link State Routing algorithm Dijkstra MCQs

Q1. What is the primary purpose of a link‑state advertisement (LSA) in link‑state routing?

A.To broadcast distance vectors
B.To describe the state of directly attached links āœ…
C.To elect a router as a backup
D.To synchronize clocks
šŸ’” Difficulty: easy | āœ… Correct: B

šŸ“– Explanation: An LSA carries information about each link that a router directly knows, including the cost and status of those links. This data enables every router to build a consistent view of the network topology, which is essential for computing shortest‑path trees. Therefore, the LSA’s main role is to describe the state of directly attached links.

Q2. Which algorithm is most commonly used by link-state routers to compute shortest‑path trees?

A.Bellman‑Ford
B.Dijkstra āœ…
C.Floyd‑Warshall
D.RIP
šŸ’” Difficulty: easy | āœ… Correct: B

šŸ“– Explanation: Link‑state routers use Dijkstra’s algorithm to compute the shortest‑path tree from the perspective of each router. The algorithm systematically selects the minimum‑cost node not yet processed and updates neighboring costs, guaranteeing the least‑cost paths. Consequently, Dijkstra’s algorithm is the standard method for constructing link‑state routing tables.

Q3. If router A’s least‑cost tree shows a path A→B→E→F with total cost 7, and router B’s tree shows a path B→E→F with total cost 5, what can be inferred about the cost of link (A,B)?

A.2 āœ…
B.0
C.1
D.3
šŸ’” Difficulty: easy | āœ… Correct: A

šŸ“– Explanation: The total cost from A to F is 7, while from B to F it is 5. Since the path from B to F is a sub‑path of the A‑to‑F route, the extra cost incurred when starting at A is the cost of the link (A,B). Subtracting the two totals gives 7ā€Æāˆ’ā€Æ5 = 2, so the link cost is 2.

Q4. Given that all routers compute identical shortest‑path trees, which of the following statements must be true?

A.All routers will select the same next hop for any destination āœ…
B.Some routers may select different next hops
C.Paths may differ in cost
D.Trees may have cycles
šŸ’” Difficulty: easy | āœ… Correct: A

šŸ“– Explanation: When every router runs the same shortest‑path algorithm with identical link costs, the resulting trees are consistent. For any destination, the algorithm selects the unique minimum‑cost neighbor, guaranteeing that all routers agree on the next hop for that destination. Hence, identical next‑hop selections across routers must hold.

Q5. Suppose the cost of link (C,D) increases from 3 to 6. How does this affect the total cost of the least‑cost path from A to D?

A.Increases by 3 āœ…
B.Decreases by 1
C.Remains unchanged
D.Increases by 6
šŸ’” Difficulty: easy | āœ… Correct: A

šŸ“– Explanation: Increasing the cost of a single link on the current shortest‑path adds exactly that increase to the overall path cost, provided no alternative route becomes cheaper. The original path A→…→D included the (C,D) link with cost 3; raising it to 6 adds 3 to the total, so the least‑cost path cost rises by 3.

Q6. The total cost of the path G→A→B→F is 9 and cost(A,B)=2. What is the minimum possible value of the sum of the costs of links (G,A) and (F,B)?

A.5
B.6
C.7 āœ…
D.8
šŸ’” Difficulty: medium | āœ… Correct: C

šŸ“– Explanation: The total cost of the path G→A→B→F is 9, which can be expressed as cost(G,A)+2+cost(B,F). Thus cost(G,A)+cost(B,F)=7. The smallest possible sum of two non‑negative link costs that satisfies this equation is 7, making option C the correct answer.

Q7. Compare the least‑cost trees rooted at routers A and D. Which statement correctly describes their relationship?

A.They are identical
B.They share the same total cost for every destination
C.They may have different parent nodes for the same destination āœ…
D.They cannot both be shortest‑path trees
šŸ’” Difficulty: medium | āœ… Correct: C

šŸ“– Explanation: Least‑cost trees are rooted at different routers, so while they share the same underlying graph, the parent‑child relationships can differ. For example, a node may choose a different neighbor as its parent depending on the root’s perspective. Therefore, the trees may have different parent nodes for the same destination.

Q8. If a link failure occurs on edge (E,F), how will routers recompute their least‑cost trees?

A.They will immediately discard all LSAs containing (E,F) and run Dijkstra again āœ…
B.They will wait for a periodic update before recomputing
C.They will use distance‑vector updates
D.They will keep the old tree unchanged
šŸ’” Difficulty: medium | āœ… Correct: A

šŸ“– Explanation: When a link fails, the routers that detect the failure generate new LSAs that omit the failed edge. These LSAs are flooded throughout the network, causing every router to recompute its shortest‑path tree using Dijkstra’s algorithm with the updated topology. This immediate reaction ensures that routing tables reflect the new network state.

Q9. Router C’s tree shows a path to G with cost 8 via D, while router D’s tree shows a path to G with cost 7 via C. Assuming symmetric link costs, what is the cost of edge (C,D)?

A.1 āœ…
B.2
C.3
D.4
šŸ’” Difficulty: medium | āœ… Correct: A

šŸ“– Explanation: Both routers report total costs that differ by 1 while sharing the same intermediate edge (C,D). Assuming symmetric costs, the only way for the totals to differ by 1 is if the cost of the edge (C,D) itself accounts for that difference. Therefore, the cost of (C,D) must be 1.

Q10. Which scenario would cause the least‑cost trees of all routers to change?

A.Increase cost of a non‑critical edge
B.Adding a new router with zero‑cost links
C.Decreasing cost of an existing edge that lies on at least one shortest path āœ…
D.Removing a LAN that is not part of any shortest path
šŸ’” Difficulty: medium | āœ… Correct: C

šŸ“– Explanation: When the cost of an edge that lies on at least one shortest‑path is reduced, the affected paths become cheaper, prompting all routers to recalculate their trees. This change propagates throughout the network, altering the least‑cost trees of every router. Hence, decreasing the cost of such an edge triggers a global update.

Q11. In a network where all link costs are integers, what can be said about the uniqueness of least‑cost trees if all edge costs are distinct?

A.The tree is guaranteed unique āœ…
B.Multiple trees may still exist
C.Uniqueness depends on the root
D.Uniqueness is unrelated to edge costs
šŸ’” Difficulty: medium | āœ… Correct: A

šŸ“– Explanation: If all edge costs are distinct integers, the ordering of path costs becomes strict, eliminating ties. Dijkstra’s algorithm will then select a unique minimum‑cost neighbor at each step, producing a single spanning tree for each root. Consequently, the least‑cost tree is guaranteed to be unique under these conditions.

Q12. How does the concept of ā€˜consistent criteria’ affect the formation of least‑cost trees across routers?

A.It ensures identical total costs for all destinations
B.It forces routers to select the same root
C.It guarantees that each router’s tree is a spanning tree
D.It aligns the metric used for cost calculation āœ…
šŸ’” Difficulty: medium | āœ… Correct: D

šŸ“– Explanation: Consistent criteria refer to using the same metric (e.g., hop count, bandwidth, delay) across all routers when evaluating link costs. By aligning the cost calculation method, each router builds its tree based on comparable values, ensuring that the resulting trees are coherent and can be correctly interpreted by every router in the network.

Q13. Given the weighted graph in Figure 20.2 with edge costs as shown, calculate the total cost of the least‑cost tree rooted at router B. Use the costs: (A,B)=2, (B,E)=3, (E,F)=2, (B,C)=4, (C,G)=5, (B,D)=6, (D,G)=3. What is the total cost?

A.19 āœ…
B.20
C.21
D.22
šŸ’” Difficulty: hard | āœ… Correct: A

šŸ“– Explanation: To form the least‑cost tree rooted at B, we select the cheapest edges that connect all six routers without creating cycles. The optimal set includes B‑A (2), B‑E (3), E‑F (2), B‑C (4), C‑G (5), and G‑D (3). Adding these costs yields 2 + 3 + 2 + 4 + 5 + 3 = 19, which matches option A.

Q14. If router A detects that the cost of edge (A,G) has doubled from 1 to 2, and all other costs remain unchanged, which destinations will experience a change in their next‑hop selection in A’s least‑cost tree?

A.Only destination G
B.Destinations G and F
C.All destinations reachable via G āœ…
D.No destinations change
šŸ’” Difficulty: hard | āœ… Correct: C

šŸ“– Explanation: Doubling the cost of (A,G) directly affects any route that uses this link. Destinations that are reachable only through G will now have a higher total cost, causing the router to consider alternative next hops. Therefore, every destination whose shortest path traverses the (A,G) edge will see a change in next‑hop selection.

Q15. Consider a network where LSAs are flooded reliably. If a malicious router injects a false LSA indicating a zero‑cost link to every other router, what is the most likely impact on the network’s routing tables?

A.All routers will select the malicious router as next hop āœ…
B.The network will detect and discard the LSA
C.Routing loops will form
D.No impact because LSAs are authenticated
šŸ’” Difficulty: hard | āœ… Correct: A

šŸ“– Explanation: Without authentication, a malicious router can advertise a zero‑cost link to all peers. Since LSAs are trusted, every router will incorporate this link into its topology database and compute shortest‑path trees that favor the malicious router as the next hop for all destinations, effectively hijacking traffic.

Q16. Assume two routers, X and Y, have computed their least‑cost trees. The path from X to Z in X’s tree is X→M→N→Z with total cost 10, while the path from Y to Z in Y’s tree is Y→N→M→Z with total cost 12. If the cost of edge (M,N) is 3, what is the difference between the sums of the remaining edge costs on the two paths?

A.1
B.2 āœ…
C.3
D.4
šŸ’” Difficulty: hard | āœ… Correct: B

šŸ“– Explanation: For the path from X, the remaining edges (excluding M‑N) sum to 10ā€Æāˆ’ā€Æ3 = 7. For the path from Y, the remaining edges sum to 12ā€Æāˆ’ā€Æ3 = 9. The difference between these sums is 9ā€Æāˆ’ā€Æ7 = 2, which corresponds to option B.)

šŸ”— Related Topics (MCQs)