在设置rsync
远程计算机时,我意识到从我的笔记本电脑同步远程计算机很快,但相反的速度很慢。经过一些调试和iperf3
,我发现这只会在 SSH 隧道下发生,如 iperf 所示:我打开了端口 7500,这样我就可以运行 iperf3,中间有或没有 SSH:
使用 SSH 隧道从远程端口 7500 到本地端口 9901
enrico@debian-asus1215b:~$ iperf3 -R -c localhost -p 9901
Connecting to host localhost, port 9901
Reverse mode, remote host localhost is sending
[ 5] local ::1 port 52818 connected to ::1 port 9901
[ ID] Interval Transfer Bitrate
[ 5] 0.00-1.00 sec 32.0 KBytes 262 Kbits/sec
[ 5] 1.00-2.00 sec 0.00 Bytes 0.00 bits/sec
[ 5] 2.00-3.00 sec 32.0 KBytes 262 Kbits/sec
[ 5] 3.00-4.00 sec 32.0 KBytes 262 Kbits/sec
[ 5] 4.00-5.00 sec 32.0 KBytes 262 Kbits/sec
[ 5] 5.00-6.00 sec 32.0 KBytes 262 Kbits/sec
[ 5] 6.00-7.00 sec 0.00 Bytes 0.00 bits/sec
[ 5] 7.00-8.00 sec 32.0 KBytes 262 Kbits/sec
[ 5] 8.00-9.00 sec 32.0 KBytes 262 Kbits/sec
[ 5] 9.00-10.00 sec 32.0 KBytes 262 Kbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.06 sec 9.75 MBytes 8.13 Mbits/sec 1 sender
[ 5] 0.00-10.00 sec 256 KBytes 210 Kbits/sec receiver
iperf Done.
直接使用端口 7500
enrico@debian-asus1215b:~$ iperf3 -R -c HOST -p 7500
Connecting to host HOST, port 7500
Reverse mode, remote host HOST is sending
[ 5] local 192.168.0.144 port 42074 connected to XXXX port 7500
[ ID] Interval Transfer Bitrate
[ 5] 0.00-1.00 sec 1.22 MBytes 10.3 Mbits/sec
[ 5] 1.00-2.00 sec 1.52 MBytes 12.7 Mbits/sec
[ 5] 2.00-3.00 sec 1.39 MBytes 11.6 Mbits/sec
[ 5] 3.00-4.00 sec 1.38 MBytes 11.6 Mbits/sec
[ 5] 4.00-5.00 sec 1.38 MBytes 11.6 Mbits/sec
[ 5] 5.00-6.00 sec 1.38 MBytes 11.5 Mbits/sec
[ 5] 6.00-7.00 sec 1.39 MBytes 11.6 Mbits/sec
[ 5] 7.00-8.00 sec 1.37 MBytes 11.5 Mbits/sec
[ 5] 8.00-9.00 sec 1.31 MBytes 11.0 Mbits/sec
[ 5] 9.00-10.00 sec 1.45 MBytes 12.2 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.02 sec 14.3 MBytes 12.0 Mbits/sec 10 sender
[ 5] 0.00-10.00 sec 13.8 MBytes 11.6 Mbits/sec receiver
iperf Done.
发送速度不受影响:
使用 SSH
enrico@debian-asus1215b:~$ iperf3 -c HOST -p 9901
^C- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
iperf3: interrupt - the client has terminated
enrico@debian-asus1215b:~$ iperf3 -c localhost -p 9901
Connecting to host localhost, port 9901
[ 5] local ::1 port 59482 connected to ::1 port 9901
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 12.5 MBytes 105 Mbits/sec 2 639 KBytes
[ 5] 1.00-2.00 sec 3.75 MBytes 31.4 Mbits/sec 2 639 KBytes
[ 5] 2.00-3.00 sec 5.00 MBytes 42.0 Mbits/sec 2 639 KBytes
[ 5] 3.00-4.00 sec 2.50 MBytes 21.0 Mbits/sec 1 639 KBytes
[ 5] 4.00-5.00 sec 5.00 MBytes 41.9 Mbits/sec 0 639 KBytes
[ 5] 5.00-6.00 sec 2.50 MBytes 21.0 Mbits/sec 0 639 KBytes
[ 5] 6.00-7.00 sec 3.75 MBytes 31.4 Mbits/sec 0 639 KBytes
[ 5] 7.00-8.00 sec 3.75 MBytes 31.5 Mbits/sec 1 639 KBytes
[ 5] 8.00-9.00 sec 2.50 MBytes 21.0 Mbits/sec 0 639 KBytes
[ 5] 9.00-10.00 sec 3.75 MBytes 31.5 Mbits/sec 0 639 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.00 sec 45.0 MBytes 37.7 Mbits/sec 8 sender
[ 5] 0.00-10.09 sec 36.6 MBytes 30.4 Mbits/sec receiver
无需 SSH
enrico@debian-asus1215b:~$ iperf3 -c HOST -p 7500
Connecting to host HOST, port 7500
[ 5] local 192.168.0.144 port 47376 connected to XXXX port 7500
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 5.82 MBytes 48.8 Mbits/sec 0 318 KBytes
[ 5] 1.00-2.00 sec 4.45 MBytes 37.3 Mbits/sec 0 366 KBytes
[ 5] 2.00-3.00 sec 4.08 MBytes 34.2 Mbits/sec 0 397 KBytes
[ 5] 3.00-4.00 sec 4.26 MBytes 35.8 Mbits/sec 0 439 KBytes
[ 5] 4.00-5.00 sec 4.45 MBytes 37.3 Mbits/sec 0 439 KBytes
[ 5] 5.00-6.00 sec 5.44 MBytes 45.6 Mbits/sec 0 439 KBytes
[ 5] 6.00-7.00 sec 4.57 MBytes 38.4 Mbits/sec 0 439 KBytes
[ 5] 7.00-8.00 sec 3.58 MBytes 30.1 Mbits/sec 0 439 KBytes
[ 5] 8.00-9.00 sec 4.51 MBytes 37.8 Mbits/sec 0 439 KBytes
[ 5] 9.00-10.00 sec 4.51 MBytes 37.8 Mbits/sec 0 439 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.00 sec 45.7 MBytes 38.3 Mbits/sec 0 sender
[ 5] 0.00-10.03 sec 43.8 MBytes 36.7 Mbits/sec receiver
iperf Done.
我使用我自己的 VPS 测试了场景,两种情况下都没有问题,这让我想到我的远程电脑上存在 sshd 问题。
远程电脑位于家庭路由器后面。mtr
给出以下报告:
Start: 2024-03-05T13:43:54+0100
HOST: debian-asus1215b Loss% Snt Last Avg Best Wrst StDev
1.|-- _gateway 0.0% 10 5.6 3.0 1.8 5.6 1.5
2.|-- 192.168.1.1 0.0% 10 4.6 3.5 2.0 5.5 1.4
3.|-- 151.7.195.10 0.0% 10 6.7 8.2 4.6 18.6 4.7
4.|-- 151.7.12.154 0.0% 10 4.9 6.0 4.6 11.1 2.0
5.|-- 151.6.6.130 0.0% 10 10.8 9.6 8.1 11.0 1.1
6.|-- 151.6.7.181 0.0% 10 15.4 11.5 9.3 15.4 2.5
7.|-- 151.6.0.162 0.0% 10 10.2 49.4 9.7 230.6 82.7
8.|-- 10.254.20.42 0.0% 10 19.4 16.5 14.7 19.5 1.9
9.|-- ??? 100.0 10 0.0 0.0 0.0 0.0 0.0
10.|-- HOST 0.0% 10 23.5 21.4 19.4 23.5 1.6
目前的情况是,从我的远程 PC 向 VPS 进行 rsync,然后从 VPS 同步回来,比尝试直接从 PC 使用 rsync 要快。不幸的是,我想使用 X11 Forwarding 和 waypipe,但它们也受到这个问题的影响,因为它们非常滞后。
我不知道该如何调试这个问题。远程电脑上的 sshd_config 几乎没有被触及。令人费解的是,在我看来,这似乎不是网络速度问题。