A common way to measure network latency to a remote host is by using ping utility which uses ICMP echo request and reply packets. In some cases, however, ICMP traffic is blocked by firewalls, which renders ping utility useless with hosts behind restrictive firewalls. In such case, you will need to rely on layer-3 measurement tools that use TCP/UDP packets since these layer-3 packets are more likely to bypass common firewall rules.
One such layer-3 measurement tool is tcpping. To measure latency, tcpping takes advantage of so-called half-open connection technique, based on TCP three-way handshake. That is, it sends a TCP SYN packet to a remote host on a port number (80 by default). If the remote host is listening on the port, it will respond with TCP ACK packet. Otherwise, it will respond with TCP RST packet. Either way, tcpping can measure round-trip-time (RTT) delay of a remote host, by timing outgoing SYN packet and incoming ACK (or RST) packet.
The same half-open connection technique is already implemented by tcptraceroute tool. So tcpping simply relies on tcptraceroute to perform latency measurement.
In order to install tcpping on Linux, you first need to install tcptraceroute, and then download tcpping script from the web.
To install tcptraceroute on Debian/Ubuntu:
To install tcptraceroute on CentOS/REHL, first set up RepoForge on your system, and then:
Finally, download tcpping from the web.
To measure network latency by using tcpping, simply run it as follows.