Skip to main content

Modern traceroute visualizer for the terminal with TUI, interactive HTML maps, and ASN/GeoIP lookups.

Project description

tracemap ๐Ÿ—บ๏ธ

Python 3.10+ License: MIT Code style: ruff

A modern traceroute visualizer for the terminal: TUI + interactive HTML maps + ASN/GeoIP lookups.

Table-first output like MTR, with replay/diff workflows for SREs, and beautiful HTML exports for incident reports.

๐Ÿ“ธ Screenshots

Interactive HTML Map Export

HTML Map - Interactive Leaflet.js with hop markers and RTT color coding

Terminal TUI

TUI Interface - Live terminal UI with map, hop table, and metadata


๐Ÿ“‹ Prerequisites

  • OS: macOS or Linux (Windows not supported)
  • Python: 3.10 or newer
  • Required Binary: System traceroute must be installed
    • macOS: Included by default
    • Linux: Install via sudo apt install traceroute (Ubuntu/Debian) or sudo yum install traceroute (RHEL/CentOS)

๐Ÿ”‘ Permissions & sudo Requirements

Tracemap uses the system traceroute binary, which often requires root privileges for certain probe types:

Protocol Flag Privileges Required? Notes
UDP Default No (usually) Standard traceroute on macOS/Linux works without root for UDP.
ICMP -P icmp Yes (sudo) Creating raw ICMP sockets requires root.
TCP -P tcp Yes (sudo) Creating raw TCP SYN packets requires root.
Paris --paris No (usually) Uses UDP with fixed ports; similar requirements to default UDP.

Recommendation: Verification commands (like doctor) run fine as a normal user. For advanced tracing (ICMP/TCP), run with sudo:

sudo tracemap trace google.com --protocol icmp

Privacy Note: By default, tracemap queries external GeoIP providers (ip-api.com, ipapi.co) for accurate location data. Use --profile private or --no-api for fully offline operation with no external calls.


โœจ What Makes This Different?

Table-first like MTR, but with maps + export:

  • ๐Ÿ“Š Clean terminal table output (default) - no endless * * * rows
  • ๐Ÿ—บ๏ธ Interactive HTML maps for visual debugging
  • ๐Ÿ’พ Built-in replay/diff for incident workflows
  • ๐Ÿ”Œ Pluggable geo/ASN backends + privacy mode
  • ๐ŸŽฏ Smart timeout cutoff (stops after 3 consecutive timeouts)

โœจ Core Features

๐Ÿ–ฅ๏ธ Modern Terminal Output

  • MTR-style table (default) - clean, professional, no clutter
  • Textual TUI (optional) - interactive split-panel layout
  • ASCII world maps (optional) - quick visualization in terminal
  • Color-coded RTT (green < 50ms, yellow 50-150ms, red > 150ms)

๐Ÿ—บ๏ธ Production-Ready Exports

  • Interactive HTML with Leaflet.js + OpenStreetMap (detach to tickets)
  • SVG export for documentation and reports
  • JSON replay - rerun analysis without re-tracing
  • Route diff - compare before/after network changes

๐ŸŒ Intelligent Geo Lookup (Resilient & Accurate!)

Automatic cascading fallback for maximum reliability:

  1. Primary API: ip-api.com (45 req/min, free)
  2. Backup API: ipapi.co (1000/day, free)
  3. Local Database: MaxMind GeoLite2 (if configured)
  4. Mock Data: Last resort fallback

Why This Matters:

  • โœ… Zero configuration - Works immediately after pip install
  • โœ… Always reliable - If one API is down, automatically tries the next
  • โœ… 100% uptime - Falls back to mock data if all APIs fail
  • โœ… Real locations - Actual cities, coordinates, ASN data

Example Cascading Behavior:

Attempting ip-api.com... โœ“ Success! (used)
โ””โ”€ If failed โ†’ Try ipapi.co... โœ“ Got result
   โ””โ”€ If failed โ†’ Try local MMDB... โœ“ Found
      โ””โ”€ If failed โ†’ Use mock data (always works)

๐Ÿ“Š Network Intelligence & UX

  • ASN lookup (Team Cymru DNS or local PyASN database)
  • Reverse DNS enabled by default - See router hostnames automatically
  • Private IP detection - Includes RFC1918, loopback, link-local, and CGNAT (100.64.0.0/10)
  • Smart timeout cutoff - Stops showing hops after 3 consecutive timeouts (MTR-style)
  • IPv4 & IPv6 support
  • Protocol selection (UDP, TCP, ICMP)
  • Loss detection and jitter calculation

๐Ÿ”ง Developer-Friendly

  • JSON export/replay for testing without re-running traces
  • Route comparison (diff command)
  • Privacy mode (--redact flag) for safe sharing
  • Pluggable backends for GeoIP and ASN
  • Cross-platform (macOS, Linux)

Quick Start

Basic Trace

# Run traceroute with clean table output
tracemap trace google.com

# Output: Clean MTR-style table with hops, RTT, geo location
# Auto-generates: trace.json + trace.html

Watch Mode (Continuous Monitoring)

# Monitor route every 30 seconds (like MTR)
tracemap watch google.com --interval 30

# Detects:
# - Route changes (IP/ASN shifts)
# - RTT spikes (>40% from baseline)
# - Packet loss patterns
# - Logs to ~/.tracemap/watch_google.com.jsonl

ECMP Detection

# Discover multiple paths through load balancers
tracemap trace --discover-paths google.com

# Paris traceroute mode (stable flow ID)
tracemap trace --paris google.com

Privacy Modes

# Offline mode (no API calls, requires local MMDB)
tracemap trace --profile offline --geoip-mmdb ~/GeoLite2.mmdb google.com

# Private mode (no external lookups, full redaction)
tracemap trace --profile private google.com

# Fast mode (skip DNS for speed)
tracemap trace --profile fast google.com

Cache Management

# View cache statistics
tracemap cache stats
# Output: Hit rate, entries, expiry info

# Clear cache
tracemap cache clear

Exports

# Markdown incident report
tracemap export trace.json --format markdown --out report.md

# HTML interactive map
tracemap export trace.json --format html --out map.html

# SVG static visualization
tracemap export trace.json --format svg --out diagram.svg

Installation

pip install tracemap

# With GeoIP database support
pip install 'tracemap[geoip]'

# With ASN lookup support
pip install 'tracemap[asn]'

# All optional features
pip install 'tracemap[all]'

# For development (includes pytest etc)
pip install -e '.[dev]'
python -m pytest

Your First Trace

# Simple trace (includes reverse DNS by default!)
tracemap trace google.com

# Example output:
# Using real-time API geo lookup (ip-api.com)
# Tracing to google.com...
# โ•ญโ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
# โ”‚1โ”‚ 10.0.0.1    โ”‚ router.local     โ”‚ 3.2 ms โ”‚ 0% โ”‚                 โ”‚              โ”‚
# โ”‚2โ”‚ 68.85.101.1 โ”‚ po-311-ar01...   โ”‚ 12.0ms โ”‚ 0% โ”‚ AS7922 (Comcast)โ”‚ San Jose, US โ”‚
# ...
# โ”‚8โ”‚ *           โ”‚                  โ”‚   -    โ”‚100%โ”‚                 โ”‚              โ”‚
# โ”‚9โ”‚ 142.251.46โ€ฆ โ”‚ sfo03s42-gw...   โ”‚ 18.7ms โ”‚ 0% โ”‚ AS15169 (Google)โ”‚ San Fran, US โ”‚
# โ•ฐโ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
# (18 more timeout hops not shown - destination likely reached or firewalled)

# With ASN lookup (enabled by default in most cases)
tracemap trace google.com --asn

# Use TCP instead of UDP
tracemap trace example.com --protocol tcp

# Launch interactive TUI
tracemap tui .tracemap/trace.json

๐Ÿ“– Usage Guide

Commands

tracemap trace <host>

Run traceroute and visualize the path.

# Basic trace
tracemap trace example.com

# Customize parameters
tracemap trace example.com \
  --max-hops 20 \
  --timeout 3 \
  --probes 5 \
  --protocol tcp

# Enable ASN lookup and save output
tracemap trace example.com \
  --asn \
  --out my-trace.json

# Privacy mode (hash IPs)
tracemap trace example.com --redact

Options:

  • --max-hops, -m: Maximum hops (default: 30)
  • --timeout, -w: Per-probe timeout in seconds (default: 2.0)
  • --probes, -q: Probes per hop (default: 3)
  • --protocol, -P: Protocol - udp, tcp, or icmp (default: udp)
  • --geoip-mmdb: Path to GeoLite2-City.mmdb file
  • --asn: Enable ASN lookup
  • --redact: Redact IP addresses in output
  • --out, -o: Output JSON path (default: .tracemap/trace.json)
  • --no-live: Disable live rendering
  • --ascii-map: Show ASCII world map (deprecated - use HTML export instead)
  • --api / --no-api: Enable/disable real-time API geo lookups (default: enabled)

tracemap replay <trace.json>

Replay a saved trace without re-running traceroute.

# View in terminal
tracemap replay .tracemap/trace.json

# Launch interactive TUI
tracemap replay .tracemap/trace.json --tui

tracemap tui [trace.json]

Launch interactive TUI interface.

# Empty TUI
tracemap tui

# Load existing trace
tracemap tui .tracemap/trace.json

Keyboard Shortcuts:

  • โ†‘/โ†“ or j/k: Navigate hops
  • Enter: Show hop details
  • e: Export to HTML
  • r: Refresh display
  • q: Quit

tracemap export <trace.json>

Export trace to HTML or SVG.

# Export to HTML (interactive map)
tracemap export .tracemap/trace.json --format html --out map.html

# Export to SVG (static image)
tracemap export .tracemap/trace.json --format svg --out map.svg

tracemap diff <trace-a.json> <trace-b.json>

Compare two traces to detect route changes.

tracemap diff morning-trace.json evening-trace.json

Example output:

โ”Œโ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ # โ”‚ Trace A IP      โ”‚ Trace B IP      โ”‚ Match โ”‚
โ”œโ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 1 โ”‚ 192.168.1.1     โ”‚ 192.168.1.1     โ”‚   โœ“   โ”‚
โ”‚ 2 โ”‚ 10.0.0.1        โ”‚ 10.0.0.1        โ”‚   โœ“   โ”‚
โ”‚ 3 โ”‚ 203.0.113.1     โ”‚ 198.51.100.1    โ”‚   โœ—   โ”‚  โ† Route changed!
โ”‚ 4 โ”‚ 8.8.8.8         โ”‚ 8.8.8.8         โ”‚   โœ“   โ”‚
โ””โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Found 1 differences

tracemap stats <trace.json>

Show detailed statistics.

tracemap stats .tracemap/trace.json

Example output:

Trace Statistics

Host: google.com
Resolved IP: 142.250.185.46
Protocol: UDP
Started: 2026-01-21 08:00:00+00:00

Hops: 12
  Responded: 10
  Timeouts: 2
  Avg Loss: 8.3%

RTT Statistics:
  Min: 1.2 ms
  Max: 156.8 ms
  Avg: 42.3 ms

Detour Alerts:
  โš ๏ธ Detour detected: hop 5โ†’6 spans 8421km

tracemap doctor

Check system prerequisites.

tracemap doctor

๐ŸŽจ Example Outputs

Default Terminal Output (Table - Recommended)

The default tracemap trace command shows a clean, MTR-style table:

$ tracemap trace google.com

โ•ญโ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ #  โ”‚ IP               โ”‚ Hostname        โ”‚ Avg RTT โ”‚ Loss โ”‚ ASN          โ”‚ Location    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  1 โ”‚ 192.168.1.1      โ”‚ gateway.local   โ”‚   2.1ms โ”‚   0% โ”‚              โ”‚             โ”‚
โ”‚  2 โ”‚ 10.50.1.1        โ”‚                 โ”‚  12.3ms โ”‚   0% โ”‚              โ”‚             โ”‚
โ”‚  3 โ”‚ 68.85.101.5      โ”‚ be-301-ar01.oak โ”‚  15.7ms โ”‚   0% โ”‚ AS7922       โ”‚ Oakland, US โ”‚
โ”‚  4 โ”‚ 162.151.86.57    โ”‚ be-298-ar01.plk โ”‚  22.4ms โ”‚   0% โ”‚ AS7922       โ”‚ San Jose    โ”‚
โ”‚  5 โ”‚ 142.251.65.142   โ”‚ 142.251.65.142  โ”‚  18.9ms โ”‚   0% โ”‚ AS15169      โ”‚ MTV, US     โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

โœ“ Saved: .tracemap/trace.json
โœ“ Saved: .tracemap/trace.html

Clean, actionable outputโ€”no endless * * * rows.

ASCII World Map (Optional - use --ascii-map)

Note: ASCII map is deprecated. Use HTML export for best visualization.

tracemap trace google.com --ascii-map

tracemap: google.com (142.250.185.46)  hops=12  responded=10
legend: ยท land  โ€ข path  0-9 hop markers

                                      ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
        ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท       ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
    ยทยทยทยทยทโ€ข โ€ข โ€ข โ€ข โ€ข โ€ขโ€ขโ€ข3 4 56ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
  ยทยทยท 1 2              ยทยทยท 7 8 ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
  ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท        ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
    ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท  ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
      ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท  ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
        ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท  ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
          ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท  ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
            ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท  ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
              ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท9 โ€ขยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
                ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท  0 ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
                  ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท  ยทยท 1ยทยทยทยทยทยทยทยทยทยทยท
                    ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท  ยท2ยทยทยทยทยทยทยท
                      ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท  ยทยทยทยทยทยทยทยทยท

โš ๏ธ Detour detected: hop 5โ†’6 spans 8421km

Interactive HTML Map

The HTML export creates a self-contained file with:

  • ๐Ÿ—บ๏ธ Interactive OpenStreetMap base layer
  • ๐Ÿ“ Color-coded hop markers (green/yellow/red by RTT)
  • ๐Ÿ”€ Curved path lines between hops
  • ๐Ÿ’ฌ Click markers for detailed popup:
    • IP address and hostname
    • RTT stats (avg/min/max)
    • Packet loss percentage
    • Geographic location
    • ASN and organization
  • ๐Ÿ“Š Summary panel with trace metadata

TUI (Textual)

โ”Œโ”€ World Map โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€ Hop Details โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                          โ”‚โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”“โ”‚
โ”‚    ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท  โ”‚โ”‚ #โ”ƒ IP          โ”ƒ Avg RTT โ”ƒ Loss โ”ƒโ”‚
โ”‚  ยทยทยทยท 1 2 3 4 56ยทยทยทยทยทยทยทยท โ”‚โ”กโ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”ฉโ”‚
โ”‚  ยทยทยทยทยทยทยทยทยทยท  ยทยทยท7 8ยทยท    โ”‚โ”‚ 1โ”‚192.168.1.1  โ”‚   1.2 msโ”‚    0%โ”‚โ”‚
โ”‚    ยทยทยทยทยทยทยทยท    ยทยทยทยท9 ยทยท  โ”‚โ”‚ 2โ”‚ 10.0.0.1    โ”‚   5.3 msโ”‚    0%โ”‚โ”‚
โ”‚      ยทยทยทยทยทยท      ยทยท โ€ข    โ”‚โ”‚ 3โ”‚203.0.113.5  โ”‚  12.1 msโ”‚    0%โ”‚โ”‚
โ”‚        ยทยทยทยท        0 1   โ”‚โ”‚ 4โ”‚203.0.113.17 โ”‚  45.2 msโ”‚   33%โ”‚โ”‚
โ”‚          ยทยท          2   โ”‚โ”‚ 5โ”‚8.8.8.8      โ”‚  42.8 msโ”‚    0%โ”‚โ”‚
โ”‚            ยท             โ”‚โ””โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”Œโ”€ Summary โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Target: google.com                                            โ”‚
โ”‚ Total Hops: 12 | Responded: 10 | Timeouts: 2 | Avg Loss: 8%  โ”‚
โ”‚                                                                โ”‚
โ”‚ โš ๏ธ Alerts:                                                    โ”‚
โ”‚   โ€ข Detour detected: hop 5โ†’6 crosses Atlantic                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
q: Quit | โ†‘/โ†“: Navigate | Enter: Details | e: Export HTML

---

## โš ๏ธ Data Accuracy & Limitations

### GeoIP Location Accuracy

**Important**: Geographic locations are **approximate** and should be used for general path visualization only.

**Why GeoIP can be misleading**:
- ๐ŸŒ **Anycast** - Same IP responds from multiple global locations
- ๐Ÿ”€ **MPLS/Tunnels** - Routers may reply from interfaces not on the forward path  
- ๐Ÿข **Corporate registration** - IP registered at HQ, not actual router location
- ๐ŸŒ **Point-of-Presence abstractions** - Router location โ‰  network path geography
- ๐Ÿ“ก **CGNAT** - Carrier-grade NAT addresses (100.64.0.0/10) have no public geo data

**Confidence indicators** (shown where available):
- โœ… High: ASN + city from multiple sources agree
- โš ๏ธ Medium: API data only, or private IP range
- โŒ Low: Mock/fallback data, or conflicting sources

### Route Interpretation

**Detour alerts** flag large geographic jumps, but these may be normal for:
- Submarine cables (e.g., US โ†’ Asia in single hop)
- Dedicated long-haul circuits  
- MPLS tunnels that obscure intermediate hops

**Always verify critical findings** with network operators or additional measurement tools.

---

## ๐Ÿ†• New in v1.0.0 (โœ… All Implemented)

> **Status Legend**: โœ… Implemented | ๐Ÿงช Experimental | ๐Ÿงญ Planned

### Persistent Caching (3-4x Faster) โœ…
Never hit API rate limits again! SQLite-based caching with automatic TTLs:

```bash
# Caching is automatic and transparent
$ tracemap trace google.com
# First run: 8-12s (API lookups)

$ tracemap trace google.com  
# Second run: 2-3s (cache hits) โšก

$ tracemap cache stats
Hit rate: 92.3% (143 hits, 12 misses)
Valid entries: 239

TTLs: GeoIP 30d, ASN 90d, DNS 24h

Watch Mode (MTR Parity) โœ…

Continuous monitoring with anomaly detection:

$ tracemap watch google.com --interval 30

# Live updating table showing:
# - Rolling RTT statistics
# - Packet loss tracking  
# - Route change alerts ๐Ÿ”ด
# - RTT spike warnings โš ๏ธ

# Logs to ~/.tracemap/watch_google.com.jsonl

Detects:

  • Route changes (new hop, IP change, ASN shift)
  • RTT spikes >40% from baseline
  • Packet loss >5%
  • Path instability

Privacy & Offline Profiles โœ…

Preset configurations for different use cases:

# Offline mode - No API calls (requires local MMDB)
$ tracemap trace --profile offline --geoip-mmdb ~/GeoLite2.mmdb google.com

# Private mode - Maximum privacy
$ tracemap trace --profile private google.com
# - No API calls
# - No DNS lookups
# - Full IP/hostname redaction

# Fast mode - Skip DNS for speed
$ tracemap trace --profile fast google.com

# Default mode - Balanced (API + caching)
$ tracemap trace --profile default google.com

Paris Traceroute & ECMP Detection โœ…

Detect load-balanced paths that traditional traceroute misses:

# Discover all ECMP paths (multi-flow probing)
$ tracemap trace --discover-paths google.com

โš ๏ธ  ECMP detected at 2 hops:
  Hop 4: 2 paths
    - 68.85.155.117
    - 68.85.155.161
  Hop 7: 3 paths
    - 162.151.86.57
    - 162.151.86.89
    - 162.151.87.13

# Paris mode (stable flow ID)
$ tracemap trace --paris google.com

Confidence Scoring โœ…

Know how trustworthy your geo data is:

## Geo Confidence
- High confidence: 8/12 hops (public IPs with ASN)
- Medium confidence: 2/12 hops (private IPs)
- Low confidence: 2/12 hops (mock data)

Plausibility checks:

  • Speed-of-light bounds (RTT vs distance)
  • Ocean crossing detection
  • Anycast/VPN detection

Markdown Export (Incident Reports) โœ…

Generate clean markdown for tickets:

$ tracemap export trace.json --format markdown --out incident.md

Creates:

  • Route summary table
  • Statistics (RTT min/avg/max, loss %)
  • Alerts and anomalies
  • Confidence breakdown
  • Metadata (platform, timestamp, tool version)

Perfect for:

  • GitHub issues
  • Confluence pages
  • Postmortems
  • SRE reports

โš™๏ธ Configuration

GeoIP Setup (Automatic with API Fallback!)

tracemap now works out-of-the-box with real geographic locations! No setup required.

How It Works

Cascading Fallback Strategy:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ 1. Try ip-api.com (primary, 45/min free)   โ”‚
โ”‚    โ”œโ”€ Success? Use this! โœ“                  โ”‚
โ”‚    โ””โ”€ Failed? โ†’ Try next...                 โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 2. Try ipapi.co (backup, 1000/day free)    โ”‚
โ”‚    โ”œโ”€ Success? Use this! โœ“                  โ”‚
โ”‚    โ””โ”€ Failed? โ†’ Try next...                 โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 3. Try local MaxMind DB (if configured)    โ”‚
โ”‚    โ”œโ”€ Success? Use this! โœ“                  โ”‚
โ”‚    โ””โ”€ Failed? โ†’ Try next...                 โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 4. Use mock data (always works)            โ”‚
โ”‚    โ””โ”€ Deterministic hash-based locations    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Default Behavior (Recommended)

# Just run - APIs enabled by default!
tracemap trace google.com

# Output:
# Using real-time API geo lookup (ip-api.com)
# No setup required! Getting real locations...

What you get:

  • โœ… Real city names (e.g., "Los Angeles, CA")
  • โœ… Accurate coordinates
  • โœ… AS numbers (e.g., AS15169 Google LLC)
  • โœ… Automatic fallback if API is down

Optional: Local Database (Offline Mode)

For complete privacy or offline use, download the MaxMind database:

Step 1: Download GeoLite2 City

Step 2: Configure tracemap

# Set environment variable
export TRACEMAP_GEOIP_MMDB=/path/to/GeoLite2-City.mmdb

# Or use CLI flag
tracemap trace google.com --geoip-mmdb /path/to/GeoLite2-City.mmdb

# Or disable API completely (offline mode)
tracemap trace google.com --no-api --geoip-mmdb /path/to/GeoLite2-City.mmdb

API Configuration Options

# Default: API enabled (ip-api.com โ†’ ipapi.co โ†’ mock)
tracemap trace example.com

# Disable API (use local DB or mock only)
tracemap trace example.com --no-api

# Hybrid: API + local DB fallback
tracemap trace example.com --geoip-mmdb ~/GeoLite2-City.mmdb

Comparison

Mode Setup Accuracy Privacy Offline Speed
API (default) None High Medium โŒ Medium
Hybrid Download DB Highest Medium Partial Fast
Offline Download DB High High โœ… Fastest

Recommendation: Use the default API mode for most cases. Enable offline mode only if you need complete privacy or work in air-gapped environments.

ASN Database (Optional)

For fastest ASN lookups, install PyASN and download an ASN database:

pip install pyasn

# Download and convert RIB data
pyasn_util_download.py --latest
pyasn_util_convert.py --single rib.*.bz2 ~/.tracemap/asn.dat

tracemap will automatically use the local database if found, or fall back to Team Cymru DNS lookups.


๐Ÿ”ฌ Advanced Usage

JSON Trace Format

Traces are saved in a structured JSON format for easy processing:

{
  "meta": {
    "tool": "tracemap",
    "version": "1.0.0",
    "host": "google.com",
    "resolved_ip": "142.250.185.46",
    "protocol": "udp",
    "max_hops": 30,
    "probes": 3,
    "started_at": "2026-01-21T08:00:00Z",
    "completed_at": "2026-01-21T08:00:42Z"
  },
  "hops": [
    {
      "hop": 1,
      "ip": "192.168.1.1",
      "hostname": "router.local",
      "probes": [
        {"rtt_ms": 1.2, "ok": true},
        {"rtt_ms": 1.1, "ok": true},
        {"rtt_ms": 1.3, "ok": true}
      ],
      "geo": {
        "lat": 37.7749,
        "lon": -122.4194,
        "city": "San Francisco",
        "country": "United States",
        "country_code": "US",
        "asn": 7922,
        "asn_org": "COMCAST"
      },
      "is_private": true,
      "is_timeout": false
    }
  ]
}

๐ŸŽฏ Technical Improvements & UX

Smart Timeout Cutoff (MTR-Style)

Problem: Traditional traceroute shows 20+ rows of * * * when destinations are firewalled.

Solution: tracemap intelligently stops after 3 consecutive timeouts and shows a clear summary.

Example:

tracemap trace firewalled.example.com

# Output stops cleanly:
โ”‚ 11 โ”‚ 150.222.111.15  โ”‚ ... โ”‚ 14.9 ms โ”‚  0% โ”‚ ...โ”‚
โ”‚ 12 โ”‚ *               โ”‚     โ”‚    -    โ”‚ 100%โ”‚    โ”‚  โ† Timeout #1
โ”‚ 13 โ”‚ *               โ”‚     โ”‚    -    โ”‚ 100%โ”‚    โ”‚   โ† Timeout #2
โ”‚ 14 โ”‚ *               โ”‚     โ”‚    -    โ”‚ 100%โ”‚    โ”‚  โ† Timeout #3 โ†’ STOP!

(16 more timeout hops not shown - destination likely reached or firewalled)

Benefits:

  • โœ… Clean, professional output (53% reduction in row count)
  • โœ… Matches industry tools like MTR
  • โœ… Allows isolated * hops (e.g., hop 8 times out, but hop 9 responds)
  • โœ… Clear explanation of why output stopped

Reverse DNS Enabled by Default

What: Router hostnames (PTR records) are now resolved automatically.

Why: Makes debugging network issues much easier - see ISP router names instead of just IPs.

Example:

# Before (no hostnames):
โ”‚ 3 โ”‚ 68.86.143.157 โ”‚          โ”‚ 15.9 ms โ”‚...โ”‚

# After (with hostnames):
โ”‚ 3 โ”‚ 68.86.143.157 โ”‚ po-311-ar01... โ”‚ 15.9 ms โ”‚...โ”‚  โ† Comcast router!

Real hostnames you'll see:

  • po-XXX โ†’ Port-channel interfaces
  • be-XXX โ†’ Bundle-Ethernet interfaces
  • ae-XXX โ†’ Aggregated Ethernet
  • sfo03s42-gw โ†’ Google datacenter routers

Private IP Detection (Including CGNAT)

Critical Update: Now correctly detects Carrier-Grade NAT addresses (100.64.0.0/10).

What is CGNAT?

  • Range: 100.64.0.0/10 (RFC 6598)
  • Used by ISPs for large-scale NAT
  • Not publicly routable - GeoIP APIs have no data for these

Impact: Prevents misleading "Mock data" fallback for CGNAT IPs.

Detection includes:

  • โœ… RFC1918 private ranges (10.x, 172.16.x, 192.168.x)
  • โœ… Loopback (127.x)
  • โœ… Link-local (169.254.x)
  • โœ… CGNAT (100.64.x - 100.127.x) โ† NEW!

Example:

# CGNAT hop correctly identified as private (no geo lookup attempted)
โ”‚ 2 โ”‚ 100.93.176.130  โ”‚ ... โ”‚ 19.4 ms โ”‚ 67% โ”‚                  โ”‚              โ”‚

๐Ÿ”ฌ Advanced Usage

Scripting and Automation

from pathlib import Path
import json
from tracemap.models import TraceRun
from tracemap.export.html import export_html

# Load trace
data = json.loads(Path(".tracemap/trace.json").read_text())
trace = TraceRun.model_validate(data)

# Check for detours
alerts = trace.get_detour_alerts(distance_threshold_km=5000)
if alerts:
    print(f"โš ๏ธ Route anomaly detected: {alerts[0]}")

# Export to HTML
export_html(trace, Path("report.html"))

# Analyze RTT
avg_rtt = sum(h.rtt_avg_ms for h in trace.hops if h.rtt_avg_ms) / trace.responded_hops
print(f"Average RTT: {avg_rtt:.1f}ms")

๐Ÿ—๏ธ Architecture

src/tracemap/
โ”œโ”€โ”€ cli.py              # Typer CLI (trace, watch, cache, export, diff, stats)
โ”œโ”€โ”€ models.py           # Pydantic models (Hop, TraceRun, TraceMeta)
โ”œโ”€โ”€ trace.py            # Traceroute execution & parsing
โ”œโ”€โ”€ geo.py              # GeoIP locators (Mock, MaxMind)
โ”œโ”€โ”€ geo_api.py          # API geo locators (ip-api, ipapi.co) with cache
โ”œโ”€โ”€ asn.py              # ASN resolvers (Team Cymru, PyASN)
โ”œโ”€โ”€ dns.py              # Reverse DNS lookup with caching
โ”œโ”€โ”€ render.py           # ASCII/tables rendering
โ”œโ”€โ”€ profiles.py         # Privacy/offline profiles โšก NEW v1.0.0
โ”‚
โ”œโ”€โ”€ cache/              # Persistent caching (SQLite) โšก NEW v1.0.0
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ sqlite.py       # 30d/90d/24h TTLs
โ”‚
โ”œโ”€โ”€ watch/              # Continuous monitoring โšก NEW v1.0.0
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ monitor.py      # TraceMonitor with rolling stats
โ”‚   โ””โ”€โ”€ alerts.py       # Anomaly detection
โ”‚
โ”œโ”€โ”€ tui/                # Interactive TUI (Textual)
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ app.py          # TraceMapApp widget
โ”‚
โ”œโ”€โ”€ export/             # Export formats
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ html.py         # Leaflet.js interactive maps
โ”‚   โ”œโ”€โ”€ svg.py          # SVG static diagrams
โ”‚   โ””โ”€โ”€ markdown.py     # Incident reports โšก NEW v1.0.0
โ”‚
โ”œโ”€โ”€ analysis/           # Confidence scoring โšก NEW v1.0.0
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ confidence.py   # Geo confidence & plausibility checks
โ”‚
โ””โ”€โ”€ probing/            # Advanced probing โšก NEW v1.0.0
    โ”œโ”€โ”€ __init__.py
    โ””โ”€โ”€ paris.py        # Paris traceroute & ECMP detection

Key Design Principles

  • Modularity: Pluggable backends for GeoIP, ASN, and rendering
  • Type Safety: Pydantic models for all data structures
  • Performance: LRU caching for DNS and ASN lookups
  • Testability: Mock data generators and replay mode
  • Portability: No binary dependencies except traceroute

๐Ÿค Contributing

Contributions welcome! Priority areas:

High Impact:

  • Windows support (tracert parsing)
  • Config file support (~/.config/tracemap/config.toml)
  • Multi-resolver DNS (parallel lookups)
  • Animated GIF export
  • Shell completions (bash, zsh, fish)

Advanced Features:

  • Multi-path visualization (display all ECMP paths in TUI)
  • Continuous integration for route monitoring
  • Source IP binding (--source flag)
  • Custom probe payloads

Already Implemented (v1.0.0):

  • โœ… Watch mode for continuous monitoring
  • โœ… ECMP detection via Paris traceroute
  • โœ… Persistent caching
  • โœ… Privacy profiles

See ROADMAP.md for full development plan.


๐Ÿ“œ License

MIT License - see LICENSE for details.


๐Ÿ™ Acknowledgments

  • MaxMind for GeoLite2 database
  • Team Cymru for free AS lookups
  • Textual for the amazing TUI framework
  • Leaflet.js for interactive maps

๐Ÿ“š See Also


Made with โค๏ธ for network engineers and SREs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tracemap-1.0.0.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tracemap-1.0.0-py3-none-any.whl (70.5 kB view details)

Uploaded Python 3

File details

Details for the file tracemap-1.0.0.tar.gz.

File metadata

  • Download URL: tracemap-1.0.0.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for tracemap-1.0.0.tar.gz
Algorithm Hash digest
SHA256 815ea3d883e4075a41be39c73146d9920d50c45a0250226ed8971002c8361fbf
MD5 e1525704f593aa345efc46b80bb631a6
BLAKE2b-256 ad53e064c207923fd352284e431d95df0aa90816c01a974e68b93e9bdbb387a5

See more details on using hashes here.

File details

Details for the file tracemap-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: tracemap-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 70.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for tracemap-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5d5765ef8af755bc5d41a2d3f9caa2c26a5422d2ffdb3141715b2582c3cc576e
MD5 7c0148d144245490c39d4b4b3b1e577b
BLAKE2b-256 ab5efbb58676a71bc912aca249ab8cdbd93416ff22d4d15771b3fcc3fcb175cf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page