Python Program to calculate the Round Trip Time (RTT)

Here we will see how Python can be used to get the Round Trip Time (RTT). The RTT is the time which is taken by the entire trip of a signal. It means the time between the starting time when a signal is sent and the receiving time of the acknowledge signal.

The RTT results varies on different parameters like.

  • The data transfer rate of the sender’s side.
  • The nature of the transmission media.
  • The actual distance between the sender and receiver.
  • The number of nodes between sender and receiver.
  • The amount of traffic on LAN.
  • Number of requests handled by intermediate points.

Example Code

import time
import requests
import sys
      initial_time = time.time() #Store the time when request is sent
      request = requests.get(url)
      ending_time = time.time() #Time when acknowledged the request
      elapsed_time = str(ending_time - initial_time)
   print('The Round Trip Time for {} is {}'.format(url, elapsed_time))


$ python3
The Round Trip Time for is 0.8301455974578857

$ python3
The Round Trip Time for is 0.5217089653015137
karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know