HowTo: Speedup ping and traceroute Command Responses under Linux / Unix 2016

The following question was asked in the Unix networking exam:

     How do you speed up ping and traceroute command responses under Unix or Linux operating systems?
How can I speed up my ping or traceroute commands on a Linux?

The ping command line utility act as a computer network tool. It used to test whether a particular host is reachable across an IP network. The traceroute command also act as a computer network diagnostic tool for displaying the route (path) and measuring transit delays of packets across an Internet Protocol (IP) network.

Speedup ping command

The syntax is:
 
ping -n -W VALUE -i VALUE host
 
Where,
  1. -n : Disable DNS lookup to speed up queries.
  2. -W NUMBER : Time to wait for a response, in seconds. The option affects only timeout in absense of any responses, otherwise ping waits for two RTTs.
  3. -i SECONDS : Wait interval seconds between sending each packet. The default is to wait for one second between each packet normally, or not to wait in flood mode. Only super-user may set interval to values less 0.2 seconds.
The default command will produce output as follows:
$ ping -c 5 www.cyberciti.biz
Sample outputs:
PING www.cyberciti.biz (75.126.153.206) 56(84) bytes of data.
64 bytes from www.cyberciti.biz (75.126.153.206): icmp_req=1 ttl=55 time=293 ms
64 bytes from www.cyberciti.biz (75.126.153.206): icmp_req=2 ttl=55 time=295 ms
64 bytes from www.cyberciti.biz (75.126.153.206): icmp_req=3 ttl=55 time=293 ms
64 bytes from www.cyberciti.biz (75.126.153.206): icmp_req=4 ttl=55 time=294 ms
64 bytes from www.cyberciti.biz (75.126.153.206): icmp_req=5 ttl=55 time=294 ms
--- www.cyberciti.biz ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4005ms
rtt min/avg/max/mdev = 293.571/294.170/295.158/0.869 ms
Now optimize the ping command:
$ ping -c 5 -n -i 0.2 -W1 www.cyberciti.biz
Sample outputs:
PING www.cyberciti.biz (75.126.153.206) 56(84) bytes of data.
64 bytes from 75.126.153.206: icmp_req=1 ttl=55 time=293 ms
64 bytes from 75.126.153.206: icmp_req=2 ttl=55 time=294 ms
64 bytes from 75.126.153.206: icmp_req=3 ttl=55 time=293 ms
64 bytes from 75.126.153.206: icmp_req=4 ttl=55 time=293 ms
64 bytes from 75.126.153.206: icmp_req=5 ttl=55 time=294 ms
--- www.cyberciti.biz ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 810ms
rtt min/avg/max/mdev = 293.279/293.955/294.522/0.799 ms, pipe 2
Here is another output showing the difference between two command line options:


Fig.01: Unix and Linux speedup ping command

Speedup traceroute command

The syntax is:
 
traceroute -n -w SECONDS -q NUMBER host
 
Where,
  1. -n : Disable DNS lookup to speed up queries.
  2. -w seconds : Set the time (in seconds) to wait for a response to a probe (default 5.0 sec).
  3. -q NUMBER : Sets the number of probe packets per hop. The default is 3.
The following example will wailt 3 seconds (instead of 5), only send out 1 query to each hop (ineader of 3):
$ traceroute -n -w 3 -q 1 www.cyberciti.biz
The -N option specifies the number of probe packets sent out simultaneously. Sending several probes concurrently can speed up traceroute considerably. The default value is 16:
$ traceroute -n -w 3 -q 1 -N 32 www.cyberciti.biz
Please Note that some routers and hosts can use ICMP rate throttling. In such a situation specifying too large number can lead to loss of some responses. You can also limit the maximum number of hops to 16 before giving up (instead of default 30) using the -moption:
$ traceroute -n -w 3 -q 1 -N 32 -m 16 www.cyberciti.biz
Sample outputs:
The syntax is as follows to speed up the traceroute command to print the route packets trace to network host called www.google.com:

traceroute -n -w 3 -q 1 -N 32 www.google.com

Sample outputs:
traceroute to www.google.com (216.58.213.132), 30 hops max, 60 byte packets
 1  5.153.23.97  0.735 ms
 2  159.253.158.132  0.717 ms
 3  50.97.18.238  0.701 ms
 4  80.249.208.247  0.970 ms
 5  209.85.143.183  1.430 ms
 6  209.85.248.247  1.409 ms
 7  216.239.48.239  8.553 ms
 8  72.14.239.230  7.321 ms
 9  209.85.240.31  7.756 ms
10  209.85.252.173  7.543 ms
11  209.85.252.175  9.702 ms
12  216.58.213.132  7.127 ms

Fig.02: Unix and Linux speedup traceroute command