How to Install and Use tcpping for TCP‑Based Latency Measurements on Linux
This guide explains why the traditional ping tool may fail behind firewalls, introduces the TCP‑based tcpping utility, details its installation prerequisites (tcptraceroute and bc), shows how to download and set up the script, and provides comprehensive usage options and examples for measuring network RTT.
Installing tcpping on Linux
tcpping is a shell‑script that sends TCP SYN packets and measures round‑trip time (RTT) using the TCP three‑way handshake. It requires tcptraceroute and bc as prerequisites.
Install prerequisites
Ubuntu/Debian:
sudo apt-get update
sudo apt-get install tcptraceroute bcCentOS/RHEL:
sudo yum install tcptraceroute bcDownload and install tcpping
wget http://www.vdberg.org/~richard/tcpping
sudo cp tcpping /usr/local/bin/
sudo chmod 755 /usr/local/bin/tcppingUsing tcpping
Basic syntax:
tcpping [-d] [-c] [-r sec] [-x count] ipaddress [port] -d: prepend a timestamp to each line. -c: column‑oriented output for easier parsing. -r: interval between probes in seconds (default 1). -x: repeat count times (default unlimited). port: destination TCP port (default 80).
Root privileges are required because the script invokes the privileged tcptraceroute binary.
Example – measuring RTT of a web server
tcpping www.rumenz.com
seq 0: tcp response from 42.194.162.109 (42.194.162.109) <syn,ack> 33.822 ms
seq 1: tcp response from 42.194.162.109 (42.194.162.109) <syn,ack> 33.975 ms
...Additional utilities
To test whether a remote TCP port is open, you can use nc (netcat):
nc -vn <ip-address> <port-number>Advanced options
-t: continuous probing until interrupted (Ctrl+C). -n 5: stop after 5 probes. -w 0.5: set timeout to 0.5 seconds. -4: prefer IPv4 when both A and AAAA records exist. -6: prefer IPv6. --file: read a list of hosts (one per line, optional port) and probe each, e.g.
tcpping --file hosts.txtSigned-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.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
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.
