Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

async_traceroute

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.

Why this approach

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:

  1. fires all 90 probes in one burst (fire_probes),
  2. collects replies in a single receive loop with a per-probe 200ms timeout,
  3. matches replies to probes by ICMP id/sequence,
  4. 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

Build & run

make
sudo ./traceroute google.com        # default hop count 30
sudo ./traceroute google.com 10     # 10 hops max

Raw sockets require root (CAP_NET_RAW).

Output

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 * * *.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages