TCPing is a powerful utility designed for network diagnostics and performance monitoring, particularly useful for troubleshooting connectivity issues. Similar to the traditional ICMP-based ping, TCPing utilizes the TCP protocol to probe network services, providing a practical alternative when ICMP traffic is restricted or unavailable.
What is TCPing?
At its core, TCPing tests the reachability of a specific TCP port on a target host. By sending a TCP SYN packet to the designated port and waiting for a response, it determines whether the target service is available and responsive. This is particularly advantageous for verifying the status of application-layer services such as web servers, database servers, or other applications that rely on TCP-based communication.
Key Features and Advantages
- Port-Specific Testing: Unlike traditional ping, which only verifies host-level connectivity using ICMP, TCPing targets specific ports. This allows users to confirm whether a particular service (e.g., HTTP on port 80, HTTPS on port 443) is accessible.
- Compatibility: Since many networks restrict ICMP traffic for security reasons, TCPing provides a reliable alternative. It can operate effectively in environments where traditional ping is blocked.
- Response Time Measurement: TCPing measures the time it takes to establish a TCP connection, offering insights into network latency and performance.
- Flexible Usage: It supports various configuration options, such as adjusting the interval between probes, setting a timeout for responses, and specifying the number of attempts.
Typical Use Cases
- Service Availability Checks: Network administrators often use TCPing to ensure critical services like web servers, email servers, or databases are operational.
- Firewall and Port Testing: TCPing helps identify whether specific ports are open or blocked by firewalls.
- Troubleshooting Latency Issues: By measuring response times, TCPing can highlight potential bottlenecks or delays in network communication.
- Automation in Scripts: TCPing can be incorporated into scripts to perform periodic health checks and generate alerts when services become unresponsive.
How to Use TCPing
Using TCPing is straightforward. In a command-line interface, users can type commands such as:
TCPing <hostname> <port>
ShellScriptFor example:
TCPing www.example.com 443
ShellScriptPrefer IPv6:
TCPing -6 www.example.com 443
ShellScriptThis command checks the availability of the HTTPS service on www.example.com.
Usage:
Usage: tcping [-flags] server-address [server-port]
Usage (full): tcping [-t] [-d] [-i interval] [-n times] [-w ms] [-b n] [-r times] [-s] [-v] [-j] [-js size] [-4] [-6] [-c] [-g count] [-S source_address] [--file] [--tee filename] [-h] [-u] [--post] [--head] [--proxy-port port] [--proxy-server server] [--proxy-credentials username:password] [-f] server-address [server-port]
-t : ping continuously until stopped via control-c
-n 5 : for instance, send 5 pings
-i 5 : for instance, ping every 5 seconds
-w 0.5 : for instance, wait 0.5 seconds for a response
-d : include date and time on each line
-b 1 : enable beeps (1 for on-down, 2 for on-up,
3 for on-change, 4 for always)
-r 5 : for instance, relookup the hostname every 5 pings
-s : automatically exit on a successful ping
-v : print version and exit
-j : include jitter, using default rolling average
-js 5 : include jitter, with a rolling average size of (for instance) 5.
--tee : mirror output to a filename specified after '--tee'
--append : Append to the --tee filename rather than overwriting it
-4 : prefer ipv4
-6 : prefer ipv6
-c : only show an output line on changed state
--file : treat the "server-address" as a filename instead, loop through file line by line
Note: --file is incompatible with options such as -j and -c as it is looping through different targets
Optionally accepts server-port. For example, "example.org 443" is valid.
Alternately, use -p to force a port at command line for everything in the file.
-g 5 : for instance, give up if we fail 5 times in a row
-S _X_ : Specify source address _X_. Source must be a valid IP for the client computer.
-p _X_ : Alternate method to specify port
--fqdn : Print domain name on each line if available
--ansi : Use ANSI color sequences (cygwin)
--color: Use Windows color sequences
HTTP Options:
-h : HTTP mode (use url without http:// for server-address)
-u : include target URL on each line
--post : use POST rather than GET (may avoid caching)
--head : use HEAD rather than GET
--proxy-server : specify a proxy server
--proxy-port : specify a proxy port
--proxy-credentials : specify 'Proxy-Authorization: Basic' header in format username:password
Debug Options:
-f : force tcping to send at least one byte
--header : include a header with original args and date. Implied if using --tee.
--block : use a 'blocking' socket to connect. This prevents -w from working and uses the
default timeout (as long as 20 seconds in my case). However it can detect an actively
refused connection vs a timeout.
If you don't pass server-port, it defaults to 80.
ShellScriptTCPing is an invaluable tool for network professionals and enthusiasts alike. Its ability to test specific TCP ports, bypass ICMP restrictions, and measure response times makes it an essential component in any network diagnostic toolkit. Whether troubleshooting connectivity issues or ensuring service availability, TCPing provides a reliable and efficient solution for modern network environments.
Leave a Reply