ping和nping的RTT值有什么区别?
我正在使用ping
ping 10.0.0.1
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data.
64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.290 ms
64 bytes from 10.0.0.1: icmp_seq=2 ttl=64 time=0.369 ms
从host1 ping host2 ping 2当我使用nping时:
sudo nping --icmp 10.0.0.1
Starting Nping 0.7.60 ( https://nmap.org/nping ) at 2022-06-10 12:28 PDT
SENT (0.0372s) ICMP [10.0.0.2 > 10.0.0.1 Echo request (type=8/code=0) id=52987 seq=1] IP [ttl=64 id=5607 iplen=28 ]
RCVD (0.2196s) ICMP [10.0.0.1 > 10.0.0.2 Echo reply (type=0/code=0) id=52987 seq=1] IP [ttl=64 id=2449 iplen=28 ]
...
Max rtt: 202.001ms | Min rtt: 15.774ms | Avg rtt: 97.067ms
Raw packets sent: 5 (140B) | Rcvd: 5 (230B) | Lost: 0 (0.00%)
Nping done: 1 IP address pinged in 4.13 seconds
我的问题是:为什么我会在ping和nping中获得不同的rtts?
I am pinging host2 from host1 using ping
ping 10.0.0.1
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data.
64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.290 ms
64 bytes from 10.0.0.1: icmp_seq=2 ttl=64 time=0.369 ms
When I use nping :
sudo nping --icmp 10.0.0.1
Starting Nping 0.7.60 ( https://nmap.org/nping ) at 2022-06-10 12:28 PDT
SENT (0.0372s) ICMP [10.0.0.2 > 10.0.0.1 Echo request (type=8/code=0) id=52987 seq=1] IP [ttl=64 id=5607 iplen=28 ]
RCVD (0.2196s) ICMP [10.0.0.1 > 10.0.0.2 Echo reply (type=0/code=0) id=52987 seq=1] IP [ttl=64 id=2449 iplen=28 ]
...
Max rtt: 202.001ms | Min rtt: 15.774ms | Avg rtt: 97.067ms
Raw packets sent: 5 (140B) | Rcvd: 5 (230B) | Lost: 0 (0.00%)
Nping done: 1 IP address pinged in 4.13 seconds
My question is: Why am I getting different rtts for ping and nping?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
RTT(往返时间)取决于数据包的长度。数据包的时间越长,以相同的物理速度传输的时间越长。您使用的两个工具具有不同的默认数据包长度。
您可以使用Wireshark自己检查情况。观看长度列。
该图显示了三个ping及其使用
nping
(数据包147-156)和使用ping> ping
(数据包178--)做出的响应。 198)。在长度列中,您可以看到在第一种情况下,
echo请求
的长度为42 b,echo响应
是60 B.在第二种情况下,请求和响应均为98个字节。由于ping
发送的数据比nping
更长,因此其RTT更长。您可以通过
-s
(数据包大小)参数更改Linux中Ping数据包中数据的长度。要发送较短的ping数据包,请使用以下命令:在后一种情况下(当
-s
小于16时),有时不显示RTT值。您必须通过使用Wireshark捕获数据来找到它们。RTT (round trip time) depends, among other things, on the length of the packet. The longer the packet, the longer it takes to transfer it at the same physical speed of the media. The two tools you use have different default packet lengths.
You can check the situation yourself using Wireshark. Watch the Length column.
The figure shows three pings and their responses made using
nping
(packets 147-156) and another three pings made usingping
(packets 178-198).In the Length column, you can see that in the first case, the
Echo request
has a length of 42 B and theEcho response
is 60 B. In the second case, both request and response are 98 Bytes. Because theping
sends more data than thenping
, its RTT is longer.You can change the length of the data in the ping packet in Linux by the
-s
(packet size) parameter. To send shorter ping packets, use this command:In the latter case (when
-s
is less than 16), sometimes RTT values are not displayed. You have to find them by capturing data using Wireshark.