Operations 9 min read

How to Install and Use tcpping on Linux for Accurate TCP Latency Measurements

Learn how to install the tcpping utility on various Linux distributions, understand its TCP half‑open connection technique for measuring RTT, and master its command‑line options for probing network latency, even when ICMP ping is blocked by firewalls.

Open Source Linux
Open Source Linux
Open Source Linux
How to Install and Use tcpping on Linux for Accurate TCP Latency Measurements

How to Install tcpping on Linux

Measuring network latency to a remote host is commonly done with the ping utility, which relies on ICMP echo requests. When ICMP traffic is blocked by a firewall, ping becomes useless, so a TCP/UDP‑based tool is needed. tcpping is such a tool. It uses a half‑open TCP connection (the TCP three‑way handshake) by sending a SYN packet to a target port (default 80). If the port is listening, the remote host replies with ACK; otherwise it replies with RST. By timing the SYN‑ACK (or SYN‑RST) exchange, tcpping measures the round‑trip time (RTT).

Installing tcpping on Linux

tcpping

is implemented as a shell script that depends on a few external tools. Install the prerequisites first.

Install dependency tcptraceroute

On Ubuntu or Debian: $ sudo apt-get install tcptraceroute On CentOS or RHEL (after enabling RepoForge):

$ sudo yum install tcptraceroute

Install dependency bc

The GNU bc calculator is pre‑installed on most major Linux distributions, but minimal environments (e.g., Docker containers, minimal AWS AMIs) may lack it. Install it if necessary.

On Debian‑based systems: $ sudo apt-get install bc On Red Hat‑based systems:

$ sudo yum install bc

Install tcpping

After the required tools are present, download tcpping from the official source and place it in /usr/bin:

$ wget http://www.vdberg.org/~richard/tcpping
$ cp tcpping /usr/bin
$ chmod 755 tcpping

Using tcpping to Measure Latency

Run tcpping with the following syntax:

tcpping [-d] [-c] [-r sec] [-x count] ipaddress [port]
-d

: Print a timestamp before each result. -c: Output in column format for easier parsing. -r: Interval between probes in seconds (default 1). -x: Repeat n times (default unlimited). [port]: Destination port (default 80).

Root privileges are required because tcpping invokes the privileged tcptraceroute command.

Example measuring RTT to a web server with an open port 80:

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
seq 2: tcp response from 42.194.162.109 (42.194.162.109) <syn,ack> 32.010 ms
seq 3: tcp response from 42.194.162.109 (42.194.162.109) <syn,ack> 32.209 ms
seq 4: tcp response from 42.194.162.109 (42.194.162.109) <syn,ack> 30.866 ms
seq 5: tcp response from 42.194.162.109 (42.194.162.109) <syn,ack> 34.866 ms
seq 6: tcp response from 42.194.162.109 (42.194.162.109) <syn,ack> 32.604 ms
seq 7: tcp response from 42.194.162.109 (42.194.162.109) <syn,ack> 30.495 ms

To check whether a remote TCP port is open, you can use nc:

$ nc -vn <ip-address> <port-number>

Additional tcpping Options

-t

: Continuous TCP ping until stopped with Ctrl+C.

tcping -t 1.1.1.1 80
-n 5

: Stop after 5 pings.

tcping -i 5 1.1.1.1 80
-w 0.5

: Set timeout to 0.5 seconds.

tcping -w 0.5 1.1.1.1 80
-d

: Include timestamp in each line of output.

tcping -d 1.1.1.1 80
-s

: Stop automatically after a successful TCP response.

tcping -s 1.1.1.1 80
-4

: Prefer IPv4 when both A and AAAA records exist.

tcping -4 1.1.1.1 80
-6

: Prefer IPv6.

tcping -6 www.rumenz.com 80
--file

: Read a list of IPs or hostnames (one per line, optional port) from a file and ping each.

tcping --file rumenz.txt
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

TCPLinuxNetwork Latencycommand-linetcpping
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.