测量 SSH 的 RTT

测量 SSH 的 RTT

我正在尝试找出一种方法来测量 SSH 连接的 RTT,但是我的 google-fu 太弱了(也许我问错了问题?)。

类似于 ping ,适用于 SSH 可以工作但 ICMP 不工作的情况。

答案1

HPing 是一种执行与 ping 等效操作的工具,但是通过 TCP 执行,因此可以在 ICMP 被阻止的网络中使用。

http://backdrift.org/tcp-ping-ping-tcp-porthttp://www.hping.org/更详细地描述它。

从前者来说:

$ hping -S -p 80 google.com
HPING google.com (eth0 66.249.92.104): S set, 40 headers + 0 data bytes
len=44 ip=66.249.92.104 ttl=47 id=10442 sport=80 flags=SA seq=0 win=5720 rtt=97.7 ms
len=44 ip=66.249.92.104 ttl=47 id=40838 sport=80 flags=SA seq=1 win=5720 rtt=97.7 ms
len=44 ip=66.249.92.104 ttl=47 id=64607 sport=80 flags=SA seq=2 win=5720 rtt=97.7 ms
len=44 ip=66.249.92.104 ttl=47 id=10443 sport=80 flags=SA seq=3 win=5720 rtt=97.7 ms

在您的情况下,您可以使用 -p 22 来定位 SSH。

答案2

您可以使用npingnmap 包中的工具。它允许您发送 TCP SYN 段来测量往返时间(以及其他模式,见下文)

$ nping -c 3 --tcp -p 443 google.com

Starting Nping 0.7.80 ( https://nmap.org/nping ) at 2023-03-15 07:40 CET
SENT (0.0640s) TCP 192.168.178.60:12321 > 142.250.181.238:443 S ttl=64 id=21385 iplen=40  seq=2979354139 win=1480 
RCVD (0.0695s) TCP 142.250.181.238:443 > 192.168.178.60:12321 SA ttl=60 id=0 iplen=44  seq=1443175162 win=65535 <mss 1412>
SENT (1.0648s) TCP 192.168.178.60:12321 > 142.250.181.238:443 S ttl=64 id=21385 iplen=40  seq=2979354139 win=1480 
RCVD (1.0699s) TCP 142.250.181.238:443 > 192.168.178.60:12321 SA ttl=60 id=0 iplen=44  seq=1458808251 win=65535 <mss 1412>
SENT (2.0671s) TCP 192.168.178.60:12321 > 142.250.181.238:443 S ttl=64 id=21385 iplen=40  seq=2979354139 win=1480 
RCVD (2.0725s) TCP 142.250.181.238:443 > 192.168.178.60:12321 SA ttl=60 id=0 iplen=44  seq=1474469141 win=65535 <mss 1412>
 
Max rtt: 5.325ms | Min rtt: 4.991ms | Avg rtt: 5.193ms
Raw packets sent: 3 (120B) | Rcvd: 3 (138B) | Lost: 0 (0.00%)
Nping done: 1 IP address pinged in 2.11 seconds

测量 RTT 的其他探测模式是 UDP、ICMP、ARP(当然,这需要本地链接上存在 IP)

相关内容