TCPing: Monitor TCP Ports & Test Service Performance

TCPING is a powerful cross-platform utility designed to ping TCP ports, offering network administrators and developers an alternative to traditional ICMP-based ping tools. This utility provides valuable insights into network connectivity, latency, and service availability. The TCPING source code is available on GitHub.

TCPING is not the first tool to perform basic TCP port checks. Alternatives include the telnet command for a basic TCP port test, or using nping or hping3 for continuous testing. The advantages of TCPING include a command output that resembles that of the regular ping test, and additional features that regular ping is missing such as the JSON formatted output. 

Key Features and Uses

TCPING stands out from other TCP port testing solutions for its ability to:

  1. Test connectivity to specific TCP ports
  2. Monitor network uptime and performance
  3. Analyze latency and packet loss
  4. Work with both IPv4 and IPv6 addresses
  5. Provide detailed statistics on connection quality
  6. Windows/Linux/MacOS support

These features make TCPING particularly useful in environments where ICMP traffic is blocked or when testing specific services running on TCP ports. You can download it and install it on Windows/Linux/MacOS following the instructions here.

Common Use Cases

If you are familiar with the ICMP ping, the options of TCPING are very similar:

> tcping --help

TCPING version 2.6.0

Try running C:\Users\Panos T14s\Downloads\tcping_Windows\tcping.exe like:C:\Users\Panos T14s\Downloads\tcping_Windows\tcping.exe <hostname/ip> <port number>. For example:C:\Users\Panos T14s\Downloads\tcping_Windows\tcping.exe www.example.com 443

[optional flags]

  -4 : only use IPv4.
  -6 : only use IPv6.
  -D : show timestamp in output.
  -I : interface name or address.
  -c : stop after <n> probes, regardless of the result. By default, no limit will be applied.
  --db : path and file name to store tcping output to sqlite database.
  -h : show help message.
  -i : interval between sending probes. Real number allowed with dot as a decimal separator. The default is one second
  -j : output in JSON format.
  --pretty : use indentation when using json output format. No effect without the '-j' flag.
  -r : retry resolving target's hostname after <n> number of failed probes. e.g. -r 10 to retry after 10 failed probes.
  --show-failures-only : Show only the failed probes.
  -t : time to wait for a response, in seconds. Real number allowed. 0 means infinite timeout.
  -u : check for updates and exit.
  -v : show version.

Some TCPING options that are not available in traditional ICMP ping tests are:

  • SQLite database and json output format (e.g. -j –pretty)
  • Option to set the interval to fractions of a second (e.g. -i 0.1)
  • Retry to resolve the target’s hostname (e.g.  -r 10)

Monitoring Service Availability

TCPING can regularly check if a service is responding on its designated port. For example, to monitor a web server

> tcping www.example.com 443

TCPinging www.example.com on port 443
Reply from www.example.com (93.184.215.14) on port 443 TCP_conn=1 time=6.943 ms
Reply from www.example.com (93.184.215.14) on port 443 TCP_conn=2 time=6.431 ms
Reply from www.example.com (93.184.215.14) on port 443 TCP_conn=3 time=6.823 ms
Reply from www.example.com (93.184.215.14) on port 443 TCP_conn=4 time=6.473 ms

--- www.example.com (93.184.215.14) TCPing statistics ---

10 probes transmitted on port 443 | 10 received, 0.00% packet loss

successful probes:   10
unsuccessful probes: 0
last successful probe:   2024-10-21 14:13:26
last unsuccessful probe: Never failed
total uptime:   10 seconds
total downtime: 0 second

longest consecutive uptime:   9 seconds from 2024-10-21 14:13:17 to 2024-10-21 14:13:27

retried to resolve hostname 0 times
rtt min/avg/max: 5.737/6.662/8.251 ms

--------------------------------------

TCPing started at: 2024-10-21 14:13:17
TCPing ended at:   2024-10-21 14:13:27
duration (HH:MM:SS): 00:00:10

Load Balancing Testing

TCPING’s hostname resolution retry feature is valuable for testing DNS-based load balancing. This command retries hostname resolution every three failed probes, helping to verify if requests are being distributed across multiple servers:

> tcping  -r 3 baidu.com 90

TCPinging baidu.com on port 90
No reply from baidu.com (39.156.66.10) on port 90 TCP_conn=1
No reply from baidu.com (39.156.66.10) on port 90 TCP_conn=2
No reply from baidu.com (39.156.66.10) on port 90 TCP_conn=3
retrying to resolve baidu.com
No reply from baidu.com (110.242.68.66) on port 90 TCP_conn=1
No reply from baidu.com (110.242.68.66) on port 90 TCP_conn=2
No reply from baidu.com (110.242.68.66) on port 90 TCP_conn=3
retrying to resolve baidu.com

--- baidu.com (110.242.68.66) TCPing statistics ---

6 probes transmitted on port 90 | 0 received, 100.00% packet loss

successful probes:   0
unsuccessful probes: 6
last successful probe:   Never succeeded
last unsuccessful probe: 2024-10-21 14:36:50
total uptime:   0 second
total downtime: 6 seconds

longest consecutive downtime: 6 seconds from 2024-10-21 14:36:45 to 2024-10-21 14:36:51

retried to resolve hostname 2 times

IP address changes:

  from 39.156.66.10 to 110.242.68.66 at 2024-10-21 14:36:48

--------------------------------------

TCPing started at: 2024-10-21 14:36:45
TCPing ended at:   2024-10-21 14:36:51

duration (HH:MM:SS): 00:00:06

JSON Output for Integration

TCPING can output results in JSON format, making it easy to integrate with other tools or scripts. The following shows a prettified JSON output with a final summary:

> tcping -j --pretty www.example.com 80

{
        "type": "start",
        "message": "TCPinging www.example.com on port 80",
        "timestamp": "2024-10-21T14:39:52.2569831-07:00",
        "hostname": "www.example.com",
        "port": 80
}

{

        "type": "probe",
        "message": "Reply from www.example.com (93.184.215.14) on port 80 time=5.573",
        "timestamp": "2024-10-21T14:39:52.2636497-07:00",
        "addr": "93.184.215.14",
        "hostname": "www.example.com",
        "dst_is_ip": false,
        "port": 80,
        "time": 5.5734,
        "success": true,
        "total_successful_probes": 1

}

…

{
        "type": "statistics",
        "message": "stats for www.example.com",
        "timestamp": "2024-10-21T14:39:58.6544451-07:00",
        "addr": "93.184.215.14",
        "hostname": "www.example.com",
        "latency_min": "5.573",
        "latency_avg": "6.455",
        "latency_max": "8.321",
        "total_duration": "7",
        "start_timestamp": "2024-10-21T14:39:52.2569831-07:00",
        "end_timestamp": "2024-10-21T14:39:58.6544451-07:00",
        "last_successful_probe": "2024-10-21T14:39:58.2575611-07:00",
        "longest_uptime": "6",
        "longest_uptime_end": "2024-10-21T14:39:58.6544451-07:00",
        "longest_uptime_start": "2024-10-21T14:39:52.2580763-07:00",
        "total_packet_loss": "0.00",
        "total_packets": 7,
        "total_successful_probes": 7,
        "total_uptime": 7
}

Conclusion

TCPING is an invaluable tool for network administrators, developers, and IT professionals. Its ability to test specific TCP ports provides a more nuanced view of network and service health compared to traditional ping tools. Whether you’re troubleshooting connectivity issues, monitoring service uptime, or analyzing network performance, TCPING offers a flexible and powerful solution.

By incorporating TCPING into your network diagnostic toolkit, you can gain deeper insights into your infrastructure’s performance and reliability. As networks become increasingly complex, tools like TCPING that offer granular control and detailed analysis become essential for maintaining optimal system operations.

Testing tcp ports as well as availability with ICMP ping are a staple in every network engineer’s troubleshooting toolbox. They are great and nifty tools for ad hoc troubleshooting. However, when it comes to continuous availability monitoring you either have to rely on scripting or look into tools like NetBeez. NetBeez can do network monitoring and test availability with TCP/ICMP ping, DNS resolution, traceroute, HTTP response time and other utilities. It can collect data over days or months, create statistics and keep historical data that can be used to recreate reports and baselines:

To learn more, request a demo here.

decoration image

Get your free trial now

Monitor your network from the user perspective

You can share

Twitter Linkedin Facebook

Let's keep in touch

decoration image