How to Use the Command 'pathping' (with examples)

How to Use the Command 'pathping' (with examples)

Pathping is a network utility tool that combines the features of ping and tracert to provide comprehensive insights into the performance and reliability of network paths. It is designed for Windows and helps diagnose network issues by identifying the route packets take to a destination and measuring potential packet loss at each hop. This helps users determine where in a network route the issues might be occurring, whether due to latency or other errors.

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

Code:

pathping hostname

Motivation:

When troubleshooting network connectivity issues, it is important to know the path that packets take from your local machine to the destination. Using the combined approach of pinging each hop along the route can reveal insights into where packets are dropping or where excessive latency is occurring. This can help in diagnosing whether the problem lies within your own network, at the ISP level, or with the destination server.

Explanation:

  • pathping: This is the command used to initiate the pathping tool.
  • hostname: Replace this with the domain name or IP address of the host you want to test. The tool will trace the route packets take to this host by pinging each intermediate hop.

Example Output:

Tracing route to example.com [93.184.216.34] over a maximum of 30 hops:
0  DESKTOP [192.168.1.10] 
1  192.168.1.1 
2  10.0.0.1 
3  example_isp.net [93.184.220.29] 
4  example.com [93.184.216.34] 

Computing statistics for 200 seconds...
Source to Here This Node/Link   
Hop RTT  Lost/Sent  Hop Examples
0  DESKTOP [192.168.1.10]  
100/100 = 0%  
1  192.168.1.1  
100/100 = 0%  
2  10.0.0.1  
100/100 = 0%  
3  example_isp.net [93.184.220.29] 
100/100 = 0% 
4  example.com [93.184.216.34] 
100/100 = 0% 

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

Code:

pathping hostname -n

Motivation:

Sometimes, reverse DNS lookups can slow down network diagnostics as each IP is translated to a hostname. By skipping this step, you can speed up the pathping process, especially if your focus is on the IP addresses in your network. This is particularly useful in environments where DNS resolution is slow or when you want to focus solely on numeric IP addresses.

Explanation:

  • -n: This switch tells pathping not to resolve IP addresses to hostnames during its operation, reducing the time taken to display the results.

Example Output:

Tracing route to example.com [93.184.216.34] over a maximum of 30 hops:
0  192.168.1.10 
1  192.168.1.1 
2  10.0.0.1 
3  93.184.220.29 
4  93.184.216.34 

Computing statistics for 200 seconds...
Source to Here This Node/Link   
Hop RTT  Lost/Sent  Hop Examples
0  192.168.1.10  
100/100 = 0%  
1  192.168.1.1  
100/100 = 0%  
2  10.0.0.1  
100/100 = 0%  
3  93.184.220.29 
100/100 = 0% 
4  93.184.216.34 
100/100 = 0% 

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

Code:

pathping hostname -h max_hops

Motivation:

Specifying a maximum number of hops is beneficial when you want to limit the depth of your diagnostic investigation. By setting a maximum number of hops, you can prevent unnecessary time and resource expenditure on tracing long routes, especially when you are only interested in the state of a network within a certain boundary or number of hops.

Explanation:

  • -h max_hops: The -h switch followed by a number allows you to specify the maximum number of hops that pathping should trace to reach the destination. The default is 30 hops, but you might set it lower if you are checking within a local area network or wish to limit the diagnostic boundary.

Example Output:

Tracing route to example.com [93.184.216.34] over a maximum of 10 hops:
0  DESKTOP [192.168.1.10] 
1  192.168.1.1 
2  10.0.0.1 
3  example_isp.net [93.184.220.29] 
4  example.com [93.184.216.34] 

Computing statistics for 200 seconds...
Source to Here This Node/Link   
Hop RTT  Lost/Sent  Hop Examples
0  DESKTOP [192.168.1.10]  
100/100 = 0%  
1  192.168.1.1  
100/100 = 0%  
2  10.0.0.1  
100/100 = 0%  
3  example_isp.net [93.184.220.29] 
100/100 = 0% 

Use case 4: Specify the milliseconds to wait between pings

Code:

pathping hostname -p time

Motivation:

Adjusting the time between pings is essential in environments where network congestion is sensitive to packet burst traffic. By spacing out the time between pings, you can minimize interruptions to normal traffic flow while still collecting the necessary diagnostic data. This is particularly important in bandwidth-sensitive networks or where service-level agreements require minimal disruption.

Explanation:

  • -p time: The -p switch allows you to define the time interval in milliseconds between consecutive pings. The default wait time is 240 milliseconds, but you can adjust this to suit your network’s requirements.

Example Output:

Tracing route to example.com [93.184.216.34] over a maximum of 30 hops:
0  DESKTOP [192.168.1.10] 
1  192.168.1.1 
2  10.0.0.1 
3  example_isp.net [93.184.220.29] 
4  example.com [93.184.216.34] 

Computing statistics for 200 seconds...
Source to Here This Node/Link Time(ms) between pings: 500
Hop RTT  Lost/Sent  Hop Examples
0  DESKTOP [192.168.1.10]  
100/100 = 0%  
1  192.168.1.1  
100/100 = 0%  
2  10.0.0.1  
100/100 = 0%  
3  example_isp.net [93.184.220.29] 
100/100 = 0% 

Use case 5: Specify the number of queries per hop

Code:

pathping hostname -q queries

Motivation:

When you receive sporadic reports of network issues, it is crucial to conduct thorough tests. Increasing the number of queries per hop allows for more robust data collection, offering a comprehensive view of the network’s reliability and performance over time. This thorough approach can help confirm patterns of packet loss or latency that might not be apparent with fewer queries.

Explanation:

  • -q queries: This option sets the number of echo request messages sent to each router in the path. The default is 100 queries, but increasing this number can provide a more detailed analysis of network reliability.

Example Output:

Tracing route to example.com [93.184.216.34] over a maximum of 30 hops:
0  DESKTOP [192.168.1.10] 
1  192.168.1.1 
2  10.0.0.1 
3  example_isp.net [93.184.220.29] 
4  example.com [93.184.216.34] 

Computing statistics for 200 seconds...
Source to Here This Node/Link Queries per hop: 150
Hop RTT  Lost/Sent  Hop Examples
0  DESKTOP [192.168.1.10]  
150/150 = 0%  
1  192.168.1.1  
150/150 = 0%  
2  10.0.0.1  
150/150 = 0%  
3  example_isp.net [93.184.220.29] 
150/150 = 0% 

Use case 6: Force IPv4 usage

Code:

pathping hostname -4

Motivation:

In dual-stack environments supporting both IPv4 and IPv6, there might be scenarios where you specifically need to test connectivity over IPv4 due to application requirements, compliance, or network limitations. Forcing IPv4 usage can clarify network path issues related specifically to IPv4 routing or address configuration.

Explanation:

  • -4: This switch ensures that the pathping utility uses the IPv4 protocol for the diagnostic tests, even if IPv6 is available on the network.

Example Output:

Tracing route to example.com [93.184.216.34] using IPv4 over a maximum of 30 hops:
0  DESKTOP [192.168.1.10] 
1  192.168.1.1 
2  10.0.0.1 
3  example_isp.net [93.184.220.29] 
4  example.com [93.184.216.34] 

Computing statistics for 200 seconds...
Source to Here This Node/Link   
Hop RTT  Lost/Sent  Hop Examples
0  DESKTOP [192.168.1.10]  
100/100 = 0%  
1  192.168.1.1  
100/100 = 0%  
2  10.0.0.1  
100/100 = 0%  
3  example_isp.net [93.184.220.29] 
100/100 = 0% 

Use case 7: Force IPv6 usage

Code:

pathping hostname -6

Motivation:

As networks transition to IPv6, testing connectivity in this protocol becomes necessary to ensure that application services remain accessible. Forcing IPv6 usage can be pivotal in identifying issues specific to IPv6 routing or configurations, as these issues can differ from those found in IPv4 networks.

Explanation:

  • -6: The -6 option forces the pathping tool to use the IPv6 protocol for network diagnostics, ensuring that the test path follows the IPv6 route.

Example Output:

Tracing route to example.com [2606:2800:220:1:248:1893:25c8:1946] using IPv6 over a maximum of 30 hops:
0  [fe80::a00:27ff:fe4d:abc1]
1  [fe80::a00:27ff:fea5:1234]
2  [2001:4860:4860::8888]
3  [2606:2800:200:3::1]
4  [2606:2800:220:1:248:1893:25c8:1946]

Computing statistics for 200 seconds...
Source to Here This Node/Link   
Hop RTT  Lost/Sent  Hop Examples
0  [fe80::a00:27ff:fe4d:abc1]  
100/100 = 0%  
1  [fe80::a00:27ff:fea5:1234]  
100/100 = 0%  
2  [2001:4860:4860::8888]  
100/100 = 0%  
3  [2606:2800:200:3::1] 
100/100 = 0% 

Use case 8: Display help

Code:

pathping /?

Motivation:

When using any command-line tool, understanding the full range of options and switches available can significantly enhance user efficiency and effectiveness in using the tool. Displaying the help guide offers insight into each command’s potential usage scenarios and syntax, helping the user customize their pathping commands to meet specific diagnostic needs.

Explanation:

  • /?: This switch displays the help documentation for pathping, listing all available options and their descriptions.

Example Output:

Usage: pathping [-g host-list] [-h max_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 max_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 versatile network diagnostic tool that provides valuable insights into network path performance by combining the capabilities of ping and tracert. With numerous options for customizing its behavior, pathping can help diagnose a wide array of network issues by revealing latency patterns and pinpointing potential problem areas along a network route. Whether you need a general overview of network health or need to dive into specific network conditions, understanding and utilizing the various options of pathping can significantly enhance your network troubleshooting effectiveness.

Related Posts

How to Use the Command 'prime-run' (with examples)

How to Use the Command 'prime-run' (with examples)

The prime-run command is a valuable tool for users who want to leverage the power of an alternative Nvidia graphics card on their systems, specifically in environments that use hybrid graphics setups like those found in many laptops.

Read More
How to Use the Command 'feroxbuster' (with examples)

How to Use the Command 'feroxbuster' (with examples)

Feroxbuster is a robust and efficient tool for discovering hidden web content.

Read More
How to Use the Command 'setfacl' (with Examples)

How to Use the Command 'setfacl' (with Examples)

The setfacl command is a powerful utility on Unix-like operating systems that allows users to set file access control lists (ACLs).

Read More