402*_*026 6 server performance networking 12.04
从我的家庭服务器(运行 Ubuntu 12.04 服务器)到我局域网上的任何其他 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
Run Code Online (Sandbox Code Playgroud)
客户端(我的 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
Run Code Online (Sandbox Code Playgroud)
从其他客户端观察到类似的结果。这些计算机都连接到同一个千兆有线交换机。在它们之间交换端口和电缆会产生相同的结果。
运行与服务器上设置的 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
Run Code Online (Sandbox Code Playgroud)
Mii工具输出:
sudo mii-tool
eth0: negotiated 1000baseT-HD flow-control, link ok
Run Code Online (Sandbox Code Playgroud)
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)
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
千兆网卡驱动信息:
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 <netdev@vger.kernel.org>
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)
Run Code Online (Sandbox Code Playgroud)
...和 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
Run Code Online (Sandbox Code Playgroud)
如果有人认为任何其他调试输出会有所帮助,请不要犹豫询问。
由于需要更好的方法来测试不同的驱动程序,我还尝试在启动时回退到较旧的内核,它将 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
Run Code Online (Sandbox Code Playgroud)
...然后 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
Run Code Online (Sandbox Code Playgroud)
我不确定从中得出什么结论,但至少进一步证明上传速度不受硬件限制......
我以前见过这种情况,是由双工不匹配引起的。千兆位以太网规范要求双方都使用自动协商,因此请确保服务器和客户端上的 NIC 设置为自动协商,并且交换机端口也设置为自动协商。明确将其设置为 1000/Full 是行不通的。
我从你的输出之一看到:
协商 1000baseT-HD 流量控制,链路正常
看起来像半双工。当双方都没有设置为自动时,会发生的情况是两个连接之间的自动协商阶段正确检测到 1000mbps 速度,但无法发现双工模式,因此它使用默认的半双工模式。因此,您有 2 台设备尝试进行通信,一台采用全双工,另一台采用半双工。最终结果是,来自一侧的流量会导致大量数据包错误,迫使数据包重新发送,并降低该方向的传输速率。
我通过这种方式解决了服务器和 NAS 盒之间的问题,一张卡已设置为自动,另一张卡明确设置为 1000/Full。
小智 0
我的机器也遇到过类似的问题。下载到机器的速度为 2MB/s,而从机器上传的速度仅为 55kB/s。我尝试了上述所有技巧,检查了开关、电缆等,但没有任何效果。最后解决我的问题的方法是将以太网卡从网络管理器上取下(在 /etc/NetworkManager/NetworkManager.conf 中设置 Managed=false )并在 /etc/network/interfaces 中手动设置设备
auto eth0
iface eth0 inet dhcp
Run Code Online (Sandbox Code Playgroud)
现在我的两个方向的速度都是 1MB/s。
| 归档时间: |
|
| 查看次数: |
21050 次 |
| 最近记录: |