mtr

2024-10-14

Understanding mtr’s Output

The core strength of mtr lies in its detailed output. It displays real-time statistics, allowing you to monitor network performance dynamically. Key metrics included are:

Basic Usage: Tracing to a Website

Let’s start with the simplest use case: tracing the network path to a website like google.com. The command is straightforward:

mtr google.com

This command will immediately start sending packets and displaying the results in your terminal. Press Ctrl+C to stop the continuous monitoring. You’ll see a table similar to the one described above, showing the performance characteristics for each hop along the way to Google’s servers. Observe the Loss%, Avg, and StDev columns to identify potential bottlenecks.

Specifying the Target IP Address

Instead of using a hostname, you can directly specify the IP address of your target:

mtr 8.8.8.8

This will trace the path to Google’s public DNS server (8.8.8.8). Using IP addresses is particularly useful when you suspect hostname resolution issues.

Controlling mtr’s Behavior with Options

mtr offers various options to fine-tune its behavior. Here are a few useful ones:

mtr -c 20 google.com  # Sends 20 probes to each hop
mtr -r summary google.com  # Generates a summary report
mtr -n 8.8.8.8 #Uses IP address only, no hostname lookup.
mtr -i 2 google.com # Sends packets every 2 seconds.
mtr -w mtr_results.txt google.com # Saves the output to mtr_results.txt

Identifying Network Problems with mtr

By analyzing the output of mtr, you can pinpoint potential sources of network issues. High packet loss (Loss%) at a specific hop suggests a problem with that segment of the network. High average latency (Avg) indicates slow performance. High standard deviation (StDev) indicates significant jitter (variation in latency), often associated with network congestion or instability.

By combining these parameters you can effectively diagnose your network connectivity issues.

Advanced Usage: Customizing Packet Sizes and TTL

mtr allows more fine-grained control over packet behavior through advanced options, including control over the Time To Live (TTL) field within the packets, which controls how many hops a packet can traverse before being discarded. Consult the mtr man page (man mtr) for a complete list of options and advanced usage scenarios.