都知道内网延迟低,到底有多低呢?数量级是多少?多少毫秒呢?
我们来定量的看看内网的延迟。
测试设备如下:
测试路由器:小米 AX1800
测试PC1:联想 YOGA14s,使用 5G wifi连接到路由器,ip地址为 192.168.31.127
测试PC2:AMD 5700G平台,使用 6 类网线连接到路由器,ip地址为 192.168.31.245
(被)测试服务器:树莓派4B 4GB,使用 5 类线连接到路由器,ip地址为 192.168.31.203
使用无线网 ping 服务器
测试PC1:联想 YOGA14s ----------ping-------> (被)测试服务器:树莓派4B 4GB
csy@Yoga14S-yjc:~$ ping 192.168.31.203
PING 192.168.31.203 (192.168.31.203) 56(84) bytes of data.
64 bytes from 192.168.31.203: icmp_seq=1 ttl=63 time=5.40 ms
64 bytes from 192.168.31.203: icmp_seq=2 ttl=63 time=2.96 ms
64 bytes from 192.168.31.203: icmp_seq=3 ttl=63 time=2.80 ms
64 bytes from 192.168.31.203: icmp_seq=4 ttl=63 time=3.44 ms
64 bytes from 192.168.31.203: icmp_seq=5 ttl=63 time=3.38 ms
64 bytes from 192.168.31.203: icmp_seq=6 ttl=63 time=3.31 ms
^C
--- 192.168.31.203 ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5009ms
rtt min/avg/max/mdev = 2.804/3.547/5.395/0.857 ms
使用网线 ping 服务器
测试PC2:AMD 5700G平台 ----------ping-------> (被)测试服务器:树莓派4B 4GB
╭─bot@amd-5700G ~
╰─➤ ping 192.168.31.203
PING 192.168.31.203 (192.168.31.203) 56(84) bytes of data.
64 比特,来自 192.168.31.203: icmp_seq=1 ttl=64 时间=0.253 毫秒
64 比特,来自 192.168.31.203: icmp_seq=2 ttl=64 时间=0.669 毫秒
64 比特,来自 192.168.31.203: icmp_seq=3 ttl=64 时间=0.641 毫秒
64 比特,来自 192.168.31.203: icmp_seq=4 ttl=64 时间=0.235 毫秒
64 比特,来自 192.168.31.203: icmp_seq=5 ttl=64 时间=0.596 毫秒
64 比特,来自 192.168.31.203: icmp_seq=6 ttl=64 时间=0.210 毫秒
64 比特,来自 192.168.31.203: icmp_seq=7 ttl=64 时间=0.612 毫秒
^C
--- 192.168.31.203 ping 统计 ---
已发送 7 个包, 已接收 7 个包, 0% 包丢失, 耗时 6126 毫秒
rtt min/avg/max/mdev = 0.210/0.459/0.669/0.197 ms
结论:
内网通讯的延迟:
使用 wifi 的话,延迟在 1-10ms 的水平
使用 网线的话,延迟在 0.1-1ms 的水平,足足降低了一个数量级。
有此,如果对网络延迟比较敏感的话,例如一些网络IO密集的常见下,建议使用网线吧。
扩展:常见 DNS 延迟
引入一些参考,通过互联网访问常见的 DNS 服务器
本人坐标杭州
腾讯 DNS
IP:119.29.29.29
csy@Yoga14S-yjc:~$ ping 119.29.29.29
PING 119.29.29.29 (119.29.29.29) 56(84) bytes of data.
64 bytes from 119.29.29.29: icmp_seq=1 ttl=34 time=35.5 ms
64 bytes from 119.29.29.29: icmp_seq=2 ttl=34 time=35.6 ms
64 bytes from 119.29.29.29: icmp_seq=3 ttl=34 time=35.8 ms
64 bytes from 119.29.29.29: icmp_seq=4 ttl=34 time=35.7 ms
64 bytes from 119.29.29.29: icmp_seq=5 ttl=34 time=35.1 ms
64 bytes from 119.29.29.29: icmp_seq=6 ttl=34 time=35.5 ms
^C
--- 119.29.29.29 ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5008ms
rtt min/avg/max/mdev = 35.104/35.525/35.760/0.210 ms
备用:182.254.116.116
阿里DNS
IP:223.5.5.5
csy@Yoga14S-yjc:~$ ping 223.5.5.5
PING 223.5.5.5 (223.5.5.5) 56(84) bytes of data.
64 bytes from 223.5.5.5: icmp_seq=1 ttl=116 time=9.32 ms
64 bytes from 223.5.5.5: icmp_seq=2 ttl=116 time=9.73 ms
64 bytes from 223.5.5.5: icmp_seq=3 ttl=116 time=9.68 ms
64 bytes from 223.5.5.5: icmp_seq=4 ttl=116 time=9.60 ms
64 bytes from 223.5.5.5: icmp_seq=5 ttl=116 time=9.22 ms
64 bytes from 223.5.5.5: icmp_seq=6 ttl=116 time=9.42 ms
64 bytes from 223.5.5.5: icmp_seq=7 ttl=116 time=9.72 ms
64 bytes from 223.5.5.5: icmp_seq=8 ttl=116 time=8.39 ms
64 bytes from 223.5.5.5: icmp_seq=9 ttl=116 time=9.08 ms
64 bytes from 223.5.5.5: icmp_seq=10 ttl=116 time=9.98 ms
^C
--- 223.5.5.5 ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 9016ms
rtt min/avg/max/mdev = 8.393/9.414/9.976/0.425 ms
备用:223.6.6.6
百度DNS
IP:180.76.76.76
csy@Yoga14S-yjc:~$ ping 180.76.76.76
PING 180.76.76.76 (180.76.76.76) 56(84) bytes of data.
64 bytes from 180.76.76.76: icmp_seq=1 ttl=49 time=14.8 ms
64 bytes from 180.76.76.76: icmp_seq=2 ttl=49 time=14.1 ms
64 bytes from 180.76.76.76: icmp_seq=3 ttl=49 time=13.8 ms
64 bytes from 180.76.76.76: icmp_seq=4 ttl=49 time=13.8 ms
64 bytes from 180.76.76.76: icmp_seq=5 ttl=49 time=13.9 ms
64 bytes from 180.76.76.76: icmp_seq=6 ttl=49 time=12.7 ms
64 bytes from 180.76.76.76: icmp_seq=7 ttl=49 time=14.3 ms
^C
--- 180.76.76.76 ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 6011ms
rtt min/avg/max/mdev = 12.674/13.915/14.820/0.611 ms