How to Install and Use tcpping on Linux for Accurate TCP Latency Measurements
This guide explains why tcpping is needed when ICMP ping is blocked, walks through installing its dependencies (tcptraceroute and bc) on various Linux distributions, shows how to download and set up tcpping, and details its command‑line options for measuring TCP RTT.
Why Use tcpping on Linux
Traditional ping relies on ICMP echo requests, which many firewalls block, making it useless for hosts behind restrictive firewalls. tcpping measures latency using TCP SYN packets (a half‑open connection) that are more likely to pass through such firewalls, allowing you to obtain round‑trip time (RTT) information.
Installing tcpping on Linux
tcppingis a shell script that depends on a few utilities. Install the prerequisites first.
Install tcptraceroute
On Ubuntu/Debian: $ sudo apt-get install tcptraceroute On CentOS/RHEL:
$ sudo yum install tcptracerouteInstall bc
The GNU bc calculator is pre‑installed on most Linux distributions, but minimal environments (Docker, minimal AMIs) may lack it. Install it if needed.
On Debian/Ubuntu: $ sudo apt-get install bc On Red Hat/CentOS:
$ sudo yum install bcInstall tcpping
After the dependencies are in place, download the script from the official site, copy it to a directory in your PATH, and make it executable.
$ wget http://www.vdberg.org/~richard/tcpping
$ cp tcpping /usr/bin
$ chmod 755 tcppingUsing tcpping to Measure Latency
The basic syntax is:
tcpping [-d] [-c] [-r sec] [-x count] ipaddress [port] -d: prepend a timestamp to each line of output. -c: produce column‑aligned output for easier parsing. -r: set the interval between probes in seconds (default 1 s). -x: repeat the test n times (default unlimited). [port]: target port, default 80.
Root privileges are required because tcpping invokes tcptraceroute.
Example measuring RTT of a web server on port 80: tcpping www.rumenz.com Sample output shows the TCP SYN/ACK round‑trip times for each probe.
Checking Remote TCP Ports
To verify whether a remote TCP port is open, combine tcpping with nc:
$ nc -vn <ip-address> <port-number>Additional tcpping Options
-t: continuous ping until interrupted with Ctrl+C. -n 5: stop after 5 probes. -w 0.5: set timeout to 0.5 seconds. -d: include timestamps in each line. -s: stop automatically after a successful response. -4: force IPv4. -6: force IPv6. --file: read a list of IP/host entries from a file (one per line, optional port). tcping --file rumenz.txt These options let you tailor tcpping for various monitoring and troubleshooting scenarios.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
