我是 Linux 新手,我正在尝试 ping 一个服务器,我想知道如何获取或计算 Linux 中往返时间 (RTT) 的中位数?
Ping 或 Packet Internet Groper 是一种网络管理实用程序,用于检查 IP 网络上源计算机/设备与目标计算机/设备之间的连接状态。它还可以帮助您评估发送和接收网络响应所需的时间。
$ ping -c 5 127.0.0.1
答案1
往返时间(RTT)是信号发送所需的时间加上致谢接收信号的时间。因此,该时间由两个信号点之间的传播时间组成。在互联网上,最终用户可以确定往返于 IP 的 RTT(互联网协议) 地址。结果取决于多种因素:-
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"
RTT(url)
输出
Time in seconds :0.0579478740692