单向网络传输速度极慢

单向网络传输速度极慢

从我的家庭服务器(运行 Ubuntu 12.04 Server)到我的 LAN 上的任何其他 PC(全部运行 Windows 7)的文件传输非常慢,但另一个方向(上传到服务器)的文件传输很快。

我在 Samba 和 SFTP 传输中都观察到了这一点,因此决定使用 iperf 进行验证,并得到了相同的结果。服务器上的输出如下所示:

iperf -s
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[  4] local 192.168.1.95 port 5001 connected with 192.168.1.82 port 1309
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0-10.0 sec   416 MBytes   349 Mbits/sec
------------------------------------------------------------
Client connecting to 192.168.1.82, TCP port 5001
TCP window size: 46.1 KByte (default)
------------------------------------------------------------
[  4] local 192.168.1.95 port 59704 connected with 192.168.1.82 port 5001
[  4]  0.0-12.2 sec  1.50 MBytes  1.03 Mbits/sec

客户端(我的 Win 7 PC)在相同运行中产生了以下输出:

iperf.exe -c 192.168.1.95 -r
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 64.0 KByte (default)
------------------------------------------------------------
------------------------------------------------------------
Client connecting to 192.168.1.95, TCP port 5001
TCP window size: 64.0 KByte (default)
------------------------------------------------------------
[  4] local 192.168.1.82 port 1309 connected with 192.168.1.95 port 5001
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0-10.0 sec   416 MBytes   349 Mbits/sec
[  4] local 192.168.1.82 port 5001 connected with 192.168.1.95 port 59704
[  4]  0.0-12.2 sec  1.50 MBytes  1.03 Mbits/sec

其他客户端也观察到了类似的结果。所有计算机都连接到同一个千兆有线交换机。交换它们之间的端口和电缆也会产生相同的结果。

运行服务器上设置的 ramdisk 之间的传输也不会改变传输速度;我不相信硬盘是造成问题的原因。

我尽力在 Google 上搜索类似的问题,但尚未找到任何相关解决方案。有人有什么想法吗?


以下是一些相关调试命令的转储,以防它们对比我更有知识的人有用。

服务器上以太网卡的 ethtool 输出:

ethtool eth0
Settings for eth0:
        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Half 1000baseT/Full
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Half 1000baseT/Full
        Advertised pause frame use: Symmetric Receive-only
        Advertised auto-negotiation: Yes
        Link partner advertised link modes:  10baseT/Half 10baseT/Full
                                             100baseT/Half 100baseT/Full
                                             1000baseT/Half 1000baseT/Full
        Link partner advertised pause frame use: Symmetric Receive-only
        Link partner advertised auto-negotiation: Yes
        Speed: 1000Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: pumbg
        Wake-on: g
        Current message level: 0x00000033 (51)
                               drv probe ifdown ifup
        Link detected: yes

Mii-tool 输出:

sudo mii-tool
eth0: negotiated 1000baseT-HD flow-control, link ok

lspci 返回的硬件列表:

sudo lspci
00:00.0 Host bridge: VIA Technologies, Inc. CN700/VN800/P4M800CE/Pro Host Bridge
00:00.1 Host bridge: VIA Technologies, Inc. CN700/VN800/P4M800CE/Pro Host Bridge
00:00.2 Host bridge: VIA Technologies, Inc. CN700/VN800/P4M800CE/Pro Host Bridge
00:00.3 Host bridge: VIA Technologies, Inc. PT890 Host Bridge
00:00.4 Host bridge: VIA Technologies, Inc. CN700/VN800/P4M800CE/Pro Host Bridge
00:00.7 Host bridge: VIA Technologies, Inc. CN700/VN800/P4M800CE/Pro Host Bridge
00:01.0 PCI bridge: VIA Technologies, Inc. VT8237/VX700 PCI Bridge
00:08.0 Network controller: Broadcom Corporation BCM4306 802.11b/g Wireless LAN Controller (rev 03)
00:09.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8110SC/8169SC Gigabit Ethernet (rev 10)
00:0b.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8110SC/8169SC Gigabit Ethernet (rev 10)
00:0f.0 IDE interface: VIA Technologies, Inc. VIA VT6420 SATA RAID Controller (rev 80)
00:0f.1 IDE interface: VIA Technologies, Inc. VT82C586A/B/VT82C686/A/B/VT823x/A/C PIPC Bus Master IDE (rev 06)
00:10.0 USB controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 81)
00:10.1 USB controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 81)
00:10.2 USB controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 81)
00:10.3 USB controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 81)
00:10.4 USB controller: VIA Technologies, Inc. USB 2.0 (rev 86)
00:11.0 ISA bridge: VIA Technologies, Inc. VT8237 ISA bridge [KT600/K8T800/K8T890 South]
00:11.5 Multimedia audio controller: VIA Technologies, Inc. VT8233/A/8235/8237 AC97 Audio Controller (rev 60)
01:00.0 VGA compatible controller: VIA Technologies, Inc. CN700/P4M800 Pro/P4M800 CE/VN800 Graphics [S3 UniChrome Pro] (rev 01)

lsmod 返回的已加载驱动程序列表:

sudo lsmod
Module                  Size  Used by
usb_storage            39646  0
vesafb                 13516  1
ppdev                  12849  0
arc4                   12473  2
snd_via82xx            24718  0
gameport               15060  1 snd_via82xx
snd_ac97_codec        110213  1 snd_via82xx
b43                   342801  0
ac97_bus               12642  1 snd_ac97_codec
snd_pcm                80916  2 snd_via82xx,snd_ac97_codec
snd_timer              28931  1 snd_pcm
snd_page_alloc         14108  2 snd_via82xx,snd_pcm
snd_mpu401_uart        13865  1 snd_via82xx
snd_rawmidi            25424  1 snd_mpu401_uart
snd_seq_device         14172  1 snd_rawmidi
snd                    62218  7 snd_via82xx,snd_ac97_codec,snd_pcm,snd_timer,snd_mpu401_uart,snd_rawmidi,snd_seq_device
mac80211              436493  1 b43
soundcore              14635  1 snd
serio_raw              13027  0
i2c_viapro             12969  0
cfg80211              178877  2 b43,mac80211
bcma                   25651  1 b43
parport_pc             32114  1
shpchp                 32265  0
mac_hid                13077  0
via_cputemp            13031  0
hwmon_vid              12723  1 via_cputemp
lp                     17455  0
parport                40930  3 ppdev,parport_pc,lp
pata_via               13428  0
ssb                    50691  1 b43
r8169                  56396  0
sata_via               13495  2

千兆卡的驱动信息:

sudo modinfo r8169
filename:       /lib/modules/3.2.0-51-generic-pae/kernel/drivers/net/ethernet/realtek/r8169.ko
version:        6.017.00-NAPI
license:        GPL
description:    RealTek RTL-8169 Gigabit Ethernet driver
author:         Realtek and the Linux r8169 crew <[email protected]>
srcversion:     231149B837AF2B63F7C0271
alias:          pci:v00001186d00004300sv00001186sd00004C00bc*sc*i*
alias:          pci:v000010ECd00008169sv*sd*bc*sc*i*
alias:          pci:v000010ECd00008167sv*sd*bc*sc*i*
depends:
vermagic:       3.2.0-51-generic-pae SMP mod_unload modversions 686
parm:           speed:force phy operation. Deprecated by ethtool (8). (array of int)
parm:           duplex:force phy operation. Deprecated by ethtool (8). (array of int)
parm:           autoneg:force phy operation. Deprecated by ethtool (8). (array of int)
parm:           rx_copybreak:Copy breakpoint for copy-only-tiny-frames (int)
parm:           use_dac:Enable PCI DAC. Unsafe on 32 bit PCI slot. (int)
parm:           debug:Debug verbosity level (0=none, ..., 16=all) (int)

...并使用 uname -a 进行测量:

uname -a
Linux hotblack 3.2.0-51-generic-pae #77-Ubuntu SMP Wed Jul 24 20:40:32 UTC 2013 i686 i686 i386 GNU/Linux

如果有人认为任何其他调试输出会有帮助,请随时询问。


更新

由于想要更好的方法来测试不同的驱动程序,我还尝试在启动时退回到旧内核,将 r8169 返回到 v2.3LK-NAPI,但问题仍然存在。

然而,我发现了一个有趣的现象。如果我使用 ethtool 将网卡强制恢复到 100Mb...

sudo ethtool -s eth0 speed 100 autoneg on duplex full
sudo ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
        Advertised pause frame use: Symmetric Receive-only
        Advertised auto-negotiation: Yes
        Speed: 100Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        MDI-X: Unknown
        Supports Wake-on: pumbg
        Wake-on: g
        Current message level: 0x00000033 (51)
                               drv probe ifdown ifup
        Link detected: yes

...然后 iperf 显示连接在两个方向上都运行正常:

------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[  4] local 192.168.1.95 port 5001 connected with 192.168.1.82 port 2437
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0-10.0 sec   105 MBytes  87.7 Mbits/sec
------------------------------------------------------------
Client connecting to 192.168.1.82, TCP port 5001
TCP window size: 83.9 KByte (default)
------------------------------------------------------------
[  4] local 192.168.1.95 port 40844 connected with 192.168.1.82 port 5001
[  4]  0.0-10.0 sec   113 MBytes  94.4 Mbits/sec

我不确定从中可以得出什么结论,但这至少进一步证明上传速度没有受到硬件的限制……

答案1

我以前见过这种情况,是由双工不匹配引起的。千兆以太网的规范要求双方都使用自动协商,因此请确保服务器和客户端上的 NIC 设置为自动协商,交换机端口也设置为自动协商。明确将其设置为 1000/Full 不会实现此目的。

我从你的一个输出中看到:

协商 1000baseT-HD 流量控制,链接正常

这看起来像是半双工。当双方都没有设置为自动时,两个连接之间的自动协商阶段会正确检测到 1000mbps 速度,但无法发现双工模式,因此它使用默认的半双工。因此,您有 2 个设备尝试通信,一个是全双工,另一个是半双工。最终结果是来自一侧的流量导致大量数据包错误,迫使数据包重新发送并降低该方向的传输速率。

我通过这种方式解决了服务器和 NAS 盒之间的问题,一张卡已设置为自动,另一张卡明确设置为 1000/Full。

答案2

我的机器也遇到过类似的问题。下载到机器的速度是 2MB/s,而从机器上传的速度只有 55kB/s。我尝试了上述所有技巧,检查了交换机、电缆等,但都不起作用。最后,解决我问题的方法是将以太网卡从网络管理器中取出(在 /etc/NetworkManager/NetworkManager.conf 中设置 managed=false),然后在 /etc/network/interfaces 中手动设置设备

auto eth0
iface eth0 inet dhcp

现在我在两个方向上都可以获得 1MB/s。

相关内容