Testing network latency using TCP instead of ICMP

This configuration was built using CentOS 6.5. Sometimes I am unable to test network latency because ICMP is blocked. Under those circumstances Hping2, is useful because it uses TCP to measure network latency. However, one capability that hping lacks is a time stamp associated with each measurement. Using BASH scripting we are able to add a time stamp.

STEP 1. Install hping2

yum install hping2

STEP 2. create script which adds a time stamp to each measurement

while true; do \
    hping2 www.google.com -S -p 443 -i 1 -c 1 | grep "len=" \
    | sed -e "s/^/`date` /g"; \
    sleep 1; \
done

Script output

--- www.google.com hping statistic ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 15.9/15.9/15.9 ms
Mon Mar  9 07:08:15 CDT 2015 len=46 ip=216.58.216.228 ttl=50 id=50666 sport=443 flags=SA seq=0 win=42900 rtt=15.9 ms

--- www.google.com hping statistic ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 18.5/18.5/18.5 ms
Mon Mar  9 07:08:16 CDT 2015 len=46 ip=216.58.216.228 ttl=50 id=1590 sport=443 flags=SA seq=0 win=42900 rtt=18.5 ms
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s