mtr (My Traceroute)

The mtr command, also known as My Traceroute, is a network diagnostic tool that combines the functionality of traceroute and ping. It provides a dynamic, real-time view of the route packets take to reach a destination and measures the performance of each hop along the way. Here's a detailed explanation of how to use mtr, its options, and what information it provides:

Basic Usage

To use mtr, open a terminal and type:

mtr <hostname or IP address>

For example:

mtr google.com

This command starts mtr in an interactive mode, displaying the network path to the specified host and providing real-time statistics about each hop.

Output Explanation

The default mtr output consists of columns representing different metrics for each hop:

  • Host: The hostname or IP address of each hop.

  • Loss%: The percentage of packet loss at each hop.

  • Snt: The number of packets sent to each hop.

  • Last: The round-trip time (RTT) of the last packet sent.

  • Avg: The average RTT.

  • Best: The best (shortest) RTT.

  • Wrst: The worst (longest) RTT.

  • StDev: The standard deviation of the RTT.

Example output:

Start: Sun Jul 21 12:34:56 2024
HOST: myhostname                Loss%   Snt   Last   Avg  Best  Wrst StDev
  1.|-- 192.168.1.1              0.0%    10    0.5   0.4   0.3   0.7   0.1
  2.|-- 10.0.0.1                 0.0%    10    2.1   2.0   1.9   2.3   0.2
  3.|-- 172.16.0.1               0.0%    10   10.5  10.3   9.8  11.2   0.5
  4.|-- google.com               0.0%    10   20.8  21.0  20.4  21.7   0.4

Additional Options

mtr provides several options to customize its behavior and output. Some of the most commonly used options are:

  • -r: Generate a report in non-interactive mode.

  • -c : Specify the number of pings to send.

  • -w: Use wide output format (show both IPv4 and IPv6 addresses).

  • -b: Show both the hostnames and IP addresses of the hops.

  • -n: Do not resolve hostnames (show only IP addresses).

  • -i : Set the interval between packets (default is 1 second).

Example command using options:

mtr -r -c 10 -w google.com

This command generates a report (-r) with 10 pings (-c 10) and uses a wide output format (-w).

Use Cases

  1. Network Troubleshooting: Identify where packet loss or high latency occurs in the network path to a destination.

  2. Performance Monitoring: Monitor the performance of network links over time.

  3. Network Planning: Assess the quality of different routes for network optimization.

Conclusion

mtr is a powerful network diagnostic tool that provides real-time information about the path packets take to a destination and the performance of each hop. By understanding its output and options, administrators and users can effectively troubleshoot network issues, monitor performance, and optimize network routes.

Last updated