How to use the command 'pathping' (with examples)

How to use the command 'pathping' (with examples)

The ‘pathping’ command is a Windows utility that combines the features of ‘ping’ and ’tracert’ to provide a more detailed analysis of the network path between a source and a destination. It performs a traceroute-like operation by sending ICMP Echo Request messages (“pings”) to each hop along the path and measures packet loss and latency at each hop.

Use case 1: Ping and trace the route to a host

Code:

pathping hostname

Motivation: This use case allows you to ping a specific host and trace the route taken by the packets to reach it. It provides valuable information about the network path and helps identify potential bottlenecks or issues with connectivity.

Explanation: The ‘hostname’ parameter specifies the target host or IP address you want to ping and trace. This could be a domain name (e.g., google.com) or an IP address. By default, pathping performs a reverse lookup to resolve the IP address to a hostname.

Example Output:

Tracing route to google.com [172.217.167.110]
over a maximum of 30 hops:
0  MY-PC [192.168.0.1]
1  192.168.0.254
2  10.10.100.1
3  172.100.200.1
...

Use case 2: Do not perform reverse lookup of IP address to hostname

Code:

pathping hostname -n

Motivation: Performing reverse lookups of IP addresses can slow down the pathping process, especially when dealing with a large number of hops. Disabling this lookup saves time and provides a quicker analysis of the network path.

Explanation: The ‘-n’ option instructs pathping not to perform a reverse lookup of IP addresses to hostnames. This option is useful when you only need to analyze the network path without the overhead of name resolution.

Example Output:

Tracing route to 172.217.167.110 over a maximum of 30 hops:
0  MY-PC [192.168.0.1]
1  192.168.0.254
2  10.10.100.1
3  172.100.200.1
...

Use case 3: Specify the maximum number of hops to search for the target

Code:

pathping hostname -h max_hops

Motivation: By default, pathping searches for a target host within a maximum of 30 hops. However, in some cases, you may want to limit or extend the number of hops to trace the network path more accurately or avoid excessive waiting times.

Explanation: The ‘-h’ option followed by ‘max_hops’ sets the maximum number of hops pathping will search to reach the target host. For example, if you set ‘max_hops’ to 15, pathping will stop tracing after reaching the 15th hop.

Example Output:

Tracing route to google.com [172.217.167.110]
over a maximum of 15 hops:
0  MY-PC [192.168.0.1]
1  192.168.0.254
2  10.10.100.1
3  172.100.200.1
...

Use case 4: Specify the milliseconds to wait between pings

Code:

pathping hostname -p time

Motivation: By default, pathping waits for 240 milliseconds between pings. However, in some cases, you may need to adjust this value to better analyze the network path, especially when dealing with low-latency connections.

Explanation: The ‘-p’ option followed by ’time’ sets the milliseconds to wait between pings. For example, if you set ’time’ to 100, pathping will wait for 100 milliseconds between each ping.

Example Output:

Tracing route to google.com [172.217.167.110]
over a maximum of 30 hops:
0  MY-PC [192.168.0.1]
1  192.168.0.254
2  10.10.100.1
3  172.100.200.1
...

Use case 5: Specify the number of queries per hop

Code:

pathping hostname -q queries

Motivation: By default, pathping sends 100 queries per hop to measure packet loss and latency. However, in some cases, you may want to increase or decrease the number of queries for a more accurate analysis or faster results.

Explanation: The ‘-q’ option followed by ‘queries’ sets the number of queries pathping will send per hop. For example, if you set ‘queries’ to 50, pathping will send 50 queries per hop.

Example Output:

Tracing route to google.com [172.217.167.110]
over a maximum of 30 hops:
0  MY-PC [192.168.0.1]
1  192.168.0.254
2  10.10.100.1
3  172.100.200.1
...

Use case 6: Force IPV4 usage

Code:

pathping hostname -4

Motivation: In certain situations, you may want to force the use of IPv4 addresses to analyze the network path, especially when dealing with compatibility issues or troubleshooting specific IPv4-related problems.

Explanation: The ‘-4’ option instructs pathping to force the usage of IPV4 addresses only. This option excludes any IPv6 components while tracing the network path.

Example Output:

Tracing route to google.com [172.217.167.110]
over a maximum of 30 hops:
0  MY-PC [192.168.0.1]
1  192.168.0.254
2  10.10.100.1
3  172.100.200.1
...

Use case 7: Force IPV6 usage

Code:

pathping hostname -6

Motivation: Similar to the previous use case, there may be instances where you want to enforce the use of IPv6 addresses instead of IPv4. This could be useful for troubleshooting IPv6 connectivity issues or analyzing the network path specifically for IPv6.

Explanation: The ‘-6’ option instructs pathping to force the usage of IPV6 addresses only. This option excludes any IPv4 components while tracing the network path.

Example Output:

Tracing route to google.com [2607:f8b0:4005:805::200e]
over a maximum of 30 hops:
0  MY-PC [fe80::a1b2:c3d4:e5f6:789a%11]
1  2600:1234:5678::abcd
2  2600:2345:6789::bcde
3  2607:f123:4567::cdef
...

Use case 8: Display detailed usage information

Code:

pathping /?

Motivation: When you need a quick reminder of the available options and how to use them, displaying the detailed usage information can be helpful.

Explanation: The ‘/?’ option displays the command’s extensive usage information, including a list of available options and their explanations. It is useful for understanding all the possibilities and features the ‘pathping’ command offers.

Example Output:

Usage: pathping [-g host-list] [-h maximum_hops] [-i address] [-n] [-p period]
                [-q num_queries] [-w timeout] [-4] [-6] target_name

Options:
  -g host-list     Loose source route along host-list.
  -h maximum_hops  Maximum number of hops to search for target.
  -i address       Use the specified source address.
  -n               Do not resolve addresses to hostnames.
  -p period        Wait period milliseconds between pings.
  -q num_queries   Number of queries per hop.
  -w timeout       Wait timeout milliseconds for each reply.
  -4               Force using IPv4.
  -6               Force using IPv6.

Conclusion:

The ‘pathping’ command is a powerful tool for analyzing network paths by providing essential information about packet loss, latency, and the route taken between a source and a destination. With its combination of ‘ping’ and ’tracert’ functionality, ‘pathping’ is an invaluable utility for network administrators and troubleshooting network connectivity issues. By understanding the different use cases and options available, you can leverage the full potential of this command to gain insights into your network’s performance.

Related Posts

Using the ftype command (with examples)

Using the ftype command (with examples)

1: Display a list of all file types Code: ftype Motivation: When working with file extensions and associations in Windows, it can be useful to have a comprehensive list of all file types currently registered on the system.

Read More
How to use the command qlmanage (with examples)

How to use the command qlmanage (with examples)

The qlmanage command is a QuickLook server tool that allows users to interact with QuickLook, a feature in macOS that enables users to preview the content of a file without opening it.

Read More
How to use the command 'shar' (with examples)

How to use the command 'shar' (with examples)

The shar command, short for “shell archive”, is used to create a shell script that can extract files from itself when executed.

Read More