您好 stackoverflow 社區,我想獲得幫助以了解導致 ping 緩慢的原因
(這是根據我在那裡得到的建議從 Stackoverflow 複製的)
情境
- 我有兩台Linux伺服器。
- 樹莓派4
- 內核是
5.4.0-1042-raspi
- 聯想 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
並重試。我不知道如何將其設為預設值,因為每次重新啟動時,它都會回到省電模式。