即使服务器有足够的带宽,Ping 也很慢

即使服务器有足够的带宽,Ping 也很慢

您好 stackoverflow 社区,我想获得帮助以了解导致 ping 缓慢的原因

(这是根据我在那里得到的建议从 Stackoverflow 复制的)

语境

  • 我有两台Linux服务器。
    1. 树莓派4
    • 内核是5.4.0-1042-raspi
    1. 联想 n75q 微型 gen2
    • 内核是5.4.0-89-generic
  • 他们有一个相同的/etc/netplan/99_config.yaml文件,并且属于同一个wifi网络
  • 它们都与互联网相连,并且可以从外部世界检索内容。 (我的意思是curl在两台服务器上都有效)
  • 他们的CPU不忙,并且有足够的内存。

问题

  • 当通过ssh访问第二台服务器(Lenovo)时,其响应非常滞后。 (每次打字都很慢)
    • 然而,它的带宽比树莓派更好。
    • 我对此进行调查时发现的唯一奇怪的事实是,对 lenovo 的 ping 操作比对 rasberry pi 的操作慢。
  • rasberry pi 工作/响应非常顺利。

问题

  • 通过 ssh 访问 lenovo 时出现延迟的原因可能是什么?
  • (如果原因与 ping 慢的原因相同,)我该如何解决此问题?

iperf 的结果

# rasberry pi
[ ID] Interval       Transfer     Bandwidth
[  4] local 192.168.3.13 port 5001 connected with 192.168.3.2 port 52172
[  4]  0.0-12.8 sec   100 MBytes  65.6 Mbits/sec
[  4] local 192.168.3.13 port 5001 connected with 192.168.3.2 port 52248
[  4]  0.0-153.3 sec  1000 MBytes  54.7 Mbits/sec

# lenovo
[ ID] Interval       Transfer     Bandwidth
[  4] local 192.168.3.11 port 5001 connected with 192.168.3.2 port 52163
[  4]  0.0-12.4 sec   100 MBytes  67.6 Mbits/sec
[  4] local 192.168.3.11 port 5001 connected with 192.168.3.2 port 52180
[  4]  0.0-64.8 sec  1000 MBytes   129 Mbits/sec
[  4] local 192.168.3.11 port 5001 connected with 192.168.3.2 port 52312
[  4]  0.0-68.4 sec  1000 MBytes   123 Mbits/sec

速度测试结果

# rasberry pi
$ speedtest
Retrieving speedtest.net configuration...
Testing from Softbank BB ...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by denpa893 (Tokyo) [4.11 km]: 18.09 ms
Testing download speed................................................................................
Download: 53.25 Mbit/s
Testing upload speed......................................................................................................
Upload: 58.68 Mbit/s

# lenovo
$ speedtest
Retrieving speedtest.net configuration...
Testing from Softbank BB ...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by NEVERLOSS LLC. (Tokyo) [4.11 km]: 12.093 ms
Testing download speed................................................................................
Download: 189.07 Mbit/s
Testing upload speed......................................................................................................
Upload: 74.77 Mbit/s

ping 的结果

# rasberry pi
$ ping -s 1000 192.168.3.13
PING 192.168.3.13 (192.168.3.13): 1000 data bytes
1008 bytes from 192.168.3.13: icmp_seq=0 ttl=64 time=79.925 ms
1008 bytes from 192.168.3.13: icmp_seq=1 ttl=64 time=10.203 ms
1008 bytes from 192.168.3.13: icmp_seq=2 ttl=64 time=13.297 ms
1008 bytes from 192.168.3.13: icmp_seq=3 ttl=64 time=9.976 ms
1008 bytes from 192.168.3.13: icmp_seq=4 ttl=64 time=2.932 ms
1008 bytes from 192.168.3.13: icmp_seq=5 ttl=64 time=9.611 ms
1008 bytes from 192.168.3.13: icmp_seq=6 ttl=64 time=2.983 ms
1008 bytes from 192.168.3.13: icmp_seq=7 ttl=64 time=12.698 ms
1008 bytes from 192.168.3.13: icmp_seq=8 ttl=64 time=3.286 ms
1008 bytes from 192.168.3.13: icmp_seq=9 ttl=64 time=3.937 ms
1008 bytes from 192.168.3.13: icmp_seq=10 ttl=64 time=2.689 ms

# lenovo
$ ping -s 1000 192.168.3.11
PING 192.168.3.11 (192.168.3.11): 1000 data bytes
1008 bytes from 192.168.3.11: icmp_seq=0 ttl=64 time=211.042 ms <--- much slower than rasberry pi
1008 bytes from 192.168.3.11: icmp_seq=1 ttl=64 time=26.955 ms
1008 bytes from 192.168.3.11: icmp_seq=2 ttl=64 time=47.657 ms
1008 bytes from 192.168.3.11: icmp_seq=3 ttl=64 time=172.856 ms
1008 bytes from 192.168.3.11: icmp_seq=4 ttl=64 time=194.496 ms
1008 bytes from 192.168.3.11: icmp_seq=5 ttl=64 time=216.379 ms
1008 bytes from 192.168.3.11: icmp_seq=6 ttl=64 time=134.123 ms
1008 bytes from 192.168.3.11: icmp_seq=7 ttl=64 time=155.828 ms

路由跟踪结果

# rasberry pi
$ traceroute 192.168.3.11
traceroute to 192.168.3.11 (192.168.3.11), 64 hops max, 52 byte packets
 1  ${rasberry pi} (192.168.3.11)  4.122 ms  2.568 ms  2.109 ms

# lenovo
$ traceroute 192.168.3.13
traceroute to 192.168.3.13 (192.168.3.13), 64 hops max, 52 byte packets
 1  * ${lenovo} (192.168.3.13)  105.194 ms  3.069 ms

顶部的结果

# rasberry pi
top - 04:03:38 up  3:30,  1 user,  load average: 0.00, 0.00, 0.00
Tasks: 166 total,   1 running, 165 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.2 us,  0.2 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :   7811.3 total,   6909.1 free,    284.0 used,    618.2 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.   7394.4 avail Mem

# lenovo
top - 04:03:54 up  1:45,  1 user,  load average: 0.07, 0.02, 0.00
Tasks: 197 total,   1 running, 196 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  0.5 sy,  0.0 ni, 99.5 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :  31587.8 total,  30665.4 free,    426.2 used,    496.3 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.  30758.7 avail Mem

答案1

如果iw dev wlan0 get power_save返回,则将其关闭iw dev wlan0 set power_save off并重试。我不知道如何将其设置为默认值,因为每次重新启动时,它都会回到省电模式。

相关内容