Trace Packet Forwarding Paths to Detect Routing Loops

Last updated: November 29, 2026

Quick Overview

Given each router's static routing table, trace the hop-by-hop path a packet to a destination IP takes from a source router using longest prefix match at each hop, and report whether it is delivered, blackholed, or caught in a forwarding loop (returning the loop).

Arista Networks
Coding & Algorithms
Software Engineer
Arista Networks
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Given each router's static routing table, trace the hop-by-hop path a packet to a destination IP takes from a source router using longest prefix match at each hop, and report whether it is delivered, blackholed, or caught in a forwarding loop (returning the loop).

Misconfigured static routes and summary routes are a classic cause of loops and blackholes, and tooling around EOS and CloudVision validates forwarding intent before changes go live. The interviewer checks per-hop LPM, cycle detection on the visited path, and distinguishing the three outcomes.

What the Interviewer Expects
  • Apply longest prefix match independently at every hop
  • Track visited routers with their position to extract the exact loop
  • Return blackhole when no route matches
  • Treat a `local` next hop as delivery
  • Explain why per-destination tracing is needed (loops depend on the destination)
Key Topics to Cover
graph traversal
cycle detection
longest prefix match
routing
simulation
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you check all destinations at once instead of tracing one IP at a time?
  • How does TTL limit the damage of a loop in the data plane?
  • How would ECMP (several next hops per prefix) change the search?
  • How would you find the minimal set of routes causing the loop?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: tables mapping router to a list of (prefix, next_hop), where next_hop is another router or local. Output: (status, path); for a loop, the path is the cycle from its first repeated rou...

High-Level Design

Forwarding from a router is deterministic for a fixed destination, so the path is a walk on a functional graph: each router has at most one successor. Walk it, recording each router's index in the pat...


Submit Your Answer
Markdown supported

Related Questions