Linux
即使伺服器有足夠的頻寬,Ping 也很慢
您好 stackoverflow 社區,我想獲得幫助以了解導致 ping 緩慢的原因
(這是從 Stackoverflow 複製到我那裡的建議)
語境
我有兩個 linux 伺服器。
- 樹莓派 4
- 核心是
5.4.0-1042-raspi
- 聯想 n75q tiny gen2
- 核心是
5.4.0-89-generic
他們有一個相同的
/etc/netplan/99_config.yaml
文件,屬於同一個wifi網路他們都與網際網路相連,他們可以從外世界檢索內容。(我的意思是 curl 在兩台伺服器上都有效)
他們的 cpu 不忙,而且他們有足夠的記憶體。
問題
當通過 ssh 訪問第二台伺服器(聯想)時,它的響應非常滯後。(每一個打字都是滯後的)
- 但是,它比 rasberry pi 具有更好的頻寬。
- 我發現對此進行調查的唯一奇怪的事實是,ping 到 lenovo 比到 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
如果
iw dev wlan0 get power_save
返回,則將其設置為關閉iw dev wlan0 set power_save off
並重試。我不知道如何將其設置為預設值,因為每次重新啟動時,它都會回到省電模式。