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

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

The ‘psping’ command is a ping tool that includes TCP ping, latency, and bandwidth measurement. It can be used to test the connection between two hosts and measure the response time and throughput.

Use case 1: Ping a host using ICMP

Code:

psping hostname

Motivation: This use case is useful when you want to check if a host is reachable and measure the round-trip time using the ICMP protocol.

Explanation:

  • ‘psping’ is the command name.
  • ‘hostname’ is the IP address or hostname of the target host to ping.

Example output:

Ping statistics for 192.168.1.1:
    Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milliseconds:
    Minimum = 1ms, Maximum = 1ms, Average = 1ms

Use case 2: Ping a host over a TCP port

Code:

psping hostname:port

Motivation: This use case is useful when you want to check if a specific TCP port on a host is open and measure the round-trip time.

Explanation:

  • ‘psping’ is the command name.
  • ‘hostname’ is the IP address or hostname of the target host to ping.
  • ‘port’ is the TCP port number to use for the ping.

Example output:

Tcping to 192.168.1.1:80:
4 probes sent.
4 successful, 0 failed.
Minimum: 0ms, Maximum: 1ms, Average: 0ms

Use case 3: Specify the number of pings and perform it quietly

Code:

psping hostname -n pings -q

Motivation: This use case is useful when you want to specify the number of pings to be sent and receive a quiet output without unnecessary details.

Explanation:

  • ‘psping’ is the command name.
  • ‘hostname’ is the IP address or hostname of the target host to ping.
  • ‘-n pings’ is an optional argument to specify the number of pings to be sent.
  • ‘-q’ is an optional argument to enable quiet mode, which suppresses detailed output.

Example output:

Ping statistics for 192.168.1.1:
    Sent = 10, Received = 10, Lost = 0 (0% loss),

Use case 4: Ping the target over TCP 50 times and produce a histogram of the results

Code:

psping hostname:port -q -n 50 -h

Motivation: This use case is useful when you want to ping a host over a specific TCP port, send a specific number of pings, and generate a histogram of the results.

Explanation:

  • ‘psping’ is the command name.
  • ‘hostname’ is the IP address or hostname of the target host to ping.
  • ‘port’ is the TCP port number to use for the ping.
  • ‘-q’ is an optional argument to enable quiet mode, which suppresses detailed output.
  • ‘-n 50’ is an optional argument to specify the number of pings to be sent.
  • ‘-h’ is an optional argument to enable histogram mode, which shows a distribution of the results.

Example output:

Ping statistics for 192.168.1.1:80:
    Sent = 50, Received = 50, Lost = 0 (0% loss),
Ping response time (ms):
    0 - 1  :  41.82%  |****
    1 - 2  :  24.49%  |****
    2 - 3  :  10.20%  |**
    3 - 4  :   4.08%
    4 - 5  :   4.08%
    5 - 6  :   4.08%
    6 - 8  :   2.04%
    8 - 10  :   4.08%
   10 - 20  :   4.08%
   20 - 30  :   0.00%
   30 - 40  :   0.00%
   40 - 50  :   2.04%

Use case 5: Display usage information

Code:

psping /?

Motivation: This use case is useful when you want to quickly check the command’s syntax and available options.

Explanation:

  • ‘psping’ is the command name.
  • ‘/?’ is an argument used to display the usage information.

Example output:

Usage: psping [-n count] [-i interval] [-w timeout] [-q] [-r] [-h] [-b size] [-L size] [-t] [-4] [-6] target [ port]

-n count        Number of pings to send.
-i interval     Delay between pings in milliseconds.
-w timeout      Timeout in milliseconds to wait for each reply.
-q              Quiet: only display output at end (summary).
-r              Wait for reply from remote host indefinitely.
-h              Histogram of round-trip times.
-b size         TCP/UDP buffer size.
-L size         Location of test file.
-t              Ping the specified target until stopped.
-4              Force using IPv4.
-6              Force using IPv6.

Conclusion:

The ‘psping’ command is a versatile tool for testing connectivity and measuring network performance. It allows you to ping hosts using ICMP or TCP, specify the number of pings, quiet the output, and produce a histogram of the results. Use ‘psping /?’ for detailed usage information.

Related Posts

How to use the command dconf reset (with examples)

How to use the command dconf reset (with examples)

Description: The dconf reset command is used to reset key values in dconf databases.

Read More
How to use the command pacman --remove (with examples)

How to use the command pacman --remove (with examples)

Pacman is a package manager utility for Arch Linux. The pacman --remove command is used to remove packages from the system.

Read More
Using mdbook (with examples)

Using mdbook (with examples)

Use Case 1: Creating an mdbook project in the current directory To create an mdbook project in the current directory, you can use the following command:

Read More