A from-scratch traceroute built for low latency. Uses a single raw ICMP
socket and fires all 30 hops × 3 probes (90 packets) at once, then collects
replies in one receive loop. No threads, no locks, no per-thread sockets.
The stock traceroute walks the path one hop at a time: send TTL=1, wait for
every reply (or a multi-second timeout), print, then TTL=2. If one router is
silent, the whole run stalls. Wall time = sum of every hop's wait.
This version:
- fires all 90 probes in one burst (
fire_probes), - collects replies in a single receive loop with a per-probe 200ms timeout,
- matches replies to probes by ICMP id/sequence,
- records RTT + source IP.
The run stops early as soon as the destination replies and every earlier hop is accounted for. Total wall time ≈ max(slowest hop RTT, last unanswered timeout).
A 4-way parallel benchmark against system traceroute:
benchmark 1.1.1.1:
mine (fire-all) | wall time: 224 ms
system traceroute | wall time: 421 ms
make
sudo ./traceroute google.com # default hop count 30
sudo ./traceroute google.com 10 # 10 hops maxRaw sockets require root (CAP_NET_RAW).
traceroute to 1.1.1.1, 30 hops max, 3 probes/hop
1 192.168.0.1 1.1 ms 1.0 ms 0.9 ms
2 10.0.0.1 5.2 ms 5.1 ms 5.0 ms
...
10 1.1.1.1 23.4 ms 22.9 ms 23.1 ms
completed in 224 ms
Unanswered hops print * * *.