Introduction to Linux mtr
In the Linux ecosystem, the mtr is a command-line network diagnostic tool or utility. The mtr command will display detailed information of the route and the network packets from the source host to the destination host. In Linux, we need to use the different commands for the route information i.e. traceroute. Similarly, for the ping command, we need to use the “ping” command. But the functionality of both commands can come in a single tool i.e. the mtr tool.
The mtr tool is not displaying the garbage information like the traceroute command. It is only showing valid information from source to destination information with percentage statistics.
mtr [OPTION]HOSTNAME [PACKETSIZE]
- mtr: We can use the mtr keyword in the syntax or command. It will take the argument as an option and hostname. It will provide the end-to-end reachability status from the source machine to the destination machine.
- OPTION: We can provide the different flags as options that are compatible with the mtr command
- HOSTNAME: As per the requirement, we can pass the hostname or the IP address.
- PACKETSIZE: As per the requirement or network topology, we can specify the packet size.
How does Linux Mtr Command work?
The mtr command is a network diagnostic tool. Once, we will initialize the mtr command, the popup with the network connection window in between the source machine to the remote machine. The connection is established in two different ways. First, it will establish with connection with the network hopes like bridges, switches, gateways, routers, etc. Second, it will ping the destination machine to check the quality of the network link.
Below are the lists of field available in the mtr command.
|Sr No||File Name||Description|
|1||L||It will give them information on the loss packet ratio|
|2||D||It will give them information on Dropped packets|
|3||R||Get the information of received packets|
|4||S||Get the information of sent packets|
|5||N||Get the information in the newest RTT in milliseconds.|
|6||B||Get the information in the Min/Best RTT in milliseconds.|
|7||A||Get the information in the Average RTT in milliseconds.|
|8||W||Get the information in the Max/Worst RTT in milliseconds.|
|9||V||Get the information in standard deviation|
|10||G||Information of Geometric Mean|
|11||J||Get the information of Current Jitter|
|12||M||Get the information of Jitter Mean/Avg|
|13||X||Get the information of Worst Jitter|
|14||I||Get the information of Interarrival Jitter|
Examples to Implement Linux Mtr Command
Below are the examples to implement Linux mtr:
It is a very simple and common mtr command in a Linux environment. It will print the default routing and ping command status of the destination machine/host.
Explanation: As per the above command, we are able to find the route path of the hostname as well as the ping response from the destination source.
2. Mtr Command – With “-n” Option
The mtr command is very flexible; we can print the IP address instead of the hostname.
mtr -n www.google.com
Explanation: By default, the route information comes in the hostname format. But if we need it in IP format, then we can use the “-n” option with the mtr command.
3. Mtr Command – With “-b” Option
In mtr command, we are having the functionality to print both the IP address and the hostname.
mtr -b www.google.com
Explanation: In some cases, we need the hope or hostname in both the format i.e. IP as well as in hostname (in the same command). Then we need to use the “-n” option with the mtr command.
4. MtrCommand – With “-c” Option
In the mtr command, we are able to specify the number of ping values. It will only consider the specific number for the ping operation.
mtr -c3 www.google.com
Explanation: In the mtr command, we are able to specify the number of ping responses. As per the above command, we have specified the 3 values. So the mtr command will send only 3 ECHO/Ping responses to the destination host after that the mtr windows will vanish and come to the normal shell window.
5. MtrCommand – With “-w” Option
The “-w” option enables the wide report method for the mtr command. It will help with a clear output.
mtr -rw -c 3 google.com > mtr-report
Explanation: In the mtr command, we are able to redirect the command output to a different file. As per the above command, we are redirecting the mtr command output to the “mtr-report” file.
6. Mtr command – With “-m” Option
In the mtr command, we are having the functionality to specify the number of hopes that will be considered.
mtr -m 2 www.google.com
Explanation: As per the above command, we have defined the “2” hopes only. The mtr command will traceroute to 2 hopes only. After that, it will be stuck.
7. Mtr Command – With “-o” Option
In the mtr command, we are having the functionality to rearrange the output fields.
mtr -o "LSDR NBAW JMXI" www.google.com
Explanation: In the mtr command, we can rearrange the mtr command output. As per the requirement, we can do the modification in it.
8. Mtr Command – With “-i” Option
In the mtr command, we can define the frequency of the ECHO or ping request.
mtr -i 3 www.google.com
Explanation: As per the above mtr command, we have defined the 3 value as the second value. It states that the ping command response will happen after 3 seconds. By default, it will happen within 1 sec.
We have seen the uncut concept of “Linux mtr command” with the proper example, explanation, and command with different outputs. The mtr command is a combination of traceroute and ping command. It is a really good tool for network diagnostic on a cross-platform level.
This is a guide to Linux mtr. Here we discuss an introduction, syntax, how does it work with examples to implement Linux mtr. You can also go through our other related articles to learn more –