I am new to Linux and i am trying to ping a server and i wonder How to get or calculate median of Round Trip Time (RTT) n Linux ?

Ping or Packet Internet Groper is a network administration utility used to check the connectivity status between a source and a destination computer/device over an IP network. It also helps you assess the time it takes to send and receive a response from the network.

$ ping -c 5

Round trip time(RTT) is the length of time it takes for a signal to be sent plus the length of time it takes for an acknowledgement of that signal to be received. This time therefore consists of the propagation times between the two point of signal. On the Internet, an end user can determine the RTT to and from an IP(Internet Protocol) address by pinging that address. The result depends on various factors :-

1. The data rate transfer of the source’s internet connection.
2. The nature of transmission medium.
3. The physical distance between source and destination.
4. The number of nodes between source and destination.
5. The amount of traffic on the LAN(Local Area Network) to which end user is connected.
6. The number of other requests being handled by intermediate nodes and the remote server.
7. The speed with which intermediate node and the remote server function.
8.The presence of Interference in the circuit.
# This program is used to calculate RTT 

import time 
import requests 

# Function to calculate the RTT 
def RTT(url): 

    # time period when the signal is sent 
    t1 = time.time() 

    r = requests.get(url) 

    # time  period when acknowledgement of signal 
    # is received 
    t2 = time.time() 

    # total time taken during this process 
    tim = str(t2-t1) 

    print("Time in seconds :" + tim) 

# Pilot program 
# url address to hit
url = "http://www.google.com"


Time in seconds :0.0579478740692
  • I was asking about the median of rtt and not how to get the rtt. However, your answer helped me to better understand rtt and that is why i will accept you answer – CSS Sep 16 '19 at 11:11
  • Thanks for your acceptance will share the answer of this question as soon as possible – Sunny Sharma Sep 16 '19 at 14:16

The iputils implementation of ping only summarizes RTT with minimum, average, maximum and moving standard deviation. Not percentile or median, useful as that would be.

Install a network monitoring system to measure TCP and ICMP RTT, and maybe even get more insight into the user response times you actually care about.

Although of the many ping implemenations, it seems mping has a percentile summary option. Maybe others do too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.