測試環境:ios
PC1:Windows10 iperf3性能
PC2:Ubuntu iperf3測試
都裝有千兆網卡,直連的iperf速度是935Mbps。spa
由於TXRX兩個方向的數據是差很少的,下面的測試數據只給出平均值。命令行
1.1 TPLINK 841N
1.1.1 Switch測試
TPLIN841N使用了Marvell的88E6060芯片,使用了dsa技術,在Openwrt下面,全部的包都是軟件網橋處理的。日誌
l 內核大量打印到終端orm
默認在內核裏面的網橋代碼加入了很多的打印,測試的時候會吐出大量的日誌。測試結果是1Mbps。blog
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
dns |
|
Mem: 22572K used, 38140K free, 72K shrd, 2612K buff, 6752K cached CPU: 0% usr 0% sys 0% nic 7% idle 0% io 0% irq 92% sirq Load average: 1.61 0.97 0.95 7/33 1459 ^[[7m PID PPID USER STAT VSZ %VSZ %CPU COMMAND^[[0m 1000 1 root R 1184 2% 29% /usr/sbin/ntpd -n -S /usr/sbin/ntpd-h 1422 1 root R 1636 3% 20% /usr/sbin/hostapd -P /var/run/wifi-ph 1339 1 root R 1168 2% 5% /sbin/logd -S 16 1173 1 dnsmasq R 1040 2% 5% /usr/sbin/dnsmasq -C /var/etc/dnsmasq 1459 513 root R 1188 2% 5% top -d 1 3 2 root RW 0 0% 0% [ksoftirqd/0] 879 1 root S 1620 3% 0% /sbin/netifd 100 2 root SW 0 0% 0% [kworker/0:1] 1 0 root S 1520 2% 0% /sbin/procd 960 1 root S 1504 2% 0% /usr/sbin/uhttpd -f -h /www -r OpenWr 844 1 root S 1432 2% 0% /sbin/rpcd 893 1 root S 1272 2% 0% /usr/sbin/odhcpd 513 1 root S 1188 2% 0% /bin/ash --login 512 1 root S 1168 2% 0% /cnblogs/tanhangbo 943 1 root S 1052 2% 0% /usr/sbin/dropbear -F -P /var/run/dro 6 2 root SW 0 0% 0% [kworker/u2:0] 8 2 root SW 0 0% 0% [kworker/u2:1] 172 2 root SW 0 0% 0% [spi0] 99 2 root SW 0 0% 0% [kswapd0] 340 2 root SW< 0 0% 0% [kworker/0:1H]
crontab |
能夠看到CPU負載很高(Load average),CPU已經沒有資源了。主要的消耗在內核的Softirq部分(92%)。
l 關閉內核的打印
使用dmesg -n 1關閉內核的打印,發現速率接近理想情況但不是最完美的。
觀察到CPU資源沒有被消耗完。
TP=83Mbps
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
|
Mem: 21380K used, 39332K free, 68K shrd, 2612K buff, 6744K cached CPU: 21% usr 0% sys 0% nic 8% idle 0% io 0% irq 70% sirq Load average: 0.55 0.74 0.91 4/33 1440 PID PPID USER STAT VSZ %VSZ %CPU COMMAND 1339 1 root R 1168 2% 38% /sbin/logd -S 16 1422 1 root R 1636 3% 21% /usr/sbin/hostapd -P /var/run/wifi-ph 3 2 root RW 0 0% 18% [ksoftirqd/0] 1440 513 root R 1188 2% 7% top -d 1 100 2 root SW 0 0% 6% [kworker/0:1] 879 1 root S 1620 3% 0% /sbin/netifd 1 0 root S 1520 2% 0% /sbin/procd 960 1 root S 1504 2% 0% /usr/sbin/uhttpd -f -h /www -r OpenWr 844 1 root S 1432 2% 0% /sbin/rpcd 893 1 root S 1272 2% 0% /usr/sbin/odhcpd 1000 1 root S 1184 2% 0% /usr/sbin/ntpd -n -S /usr/sbin/ntpd-h 513 1 root S 1184 2% 0% /bin/ash --login 512 1 root S 1168 2% 0% /sbin/ubusd 943 1 root S 1052 2% 0% /usr/sbin/dropbear -F -P /var/run/dro 1173 1 dnsmasq S 1040 2% 0% /usr/sbin/dnsmasq -C /var/etc/dnsmasq 6 2 root SW 0 0% 0% [kworker/u2:0] 8 2 root SW 0 0% 0% [kworker/u2:1] 172 2 root SW 0 0% 0% [spi0] 99 2 root SW 0 0% 0% [kswapd0] 340 2 root SW< 0 0% 0% [kworker/0:1H]
|
l 完全關閉內核的打印
將代碼內核打印的代碼去掉,發現CPU空閒的資源變多了。
TP=92Mbps,已經能夠知足要求
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
|
Mem: 18376K used, 42336K free, 68K shrd, 1788K buff, 5540K cached CPU: 0% usr 0% sys 0% nic 60% idle 0% io 0% irq 37% sirq Load average: 0.46 0.38 0.16 1/31 1284 PID PPID USER STAT VSZ %VSZ %CPU COMMAND 1109 1 root S 1636 3% 1% /usr/sbin/hostapd -P /var/run/wifi-ph 3 2 root SW 0 0% 1% [ksoftirqd/0] 1284 448 root R 1176 2% 0% top 1148 1 dnsmasq S 1040 2% 0% /usr/sbin/dnsmasq -C /var/etc/dnsmasq 99 2 root SW 0 0% 0% [kworker/0:1] 861 1 root S 1620 3% 0% /sbin/netifd 1 0 root S 1516 2% 0% /sbin/procd 882 1 root S 1272 2% 0% /usr/sbin/odhcpd 448 1 root S 1172 2% 0% /bin/ash --login 965 1 root S 1172 2% 0% /usr/sbin/ntpd -n -S /usr/sbin/ntpd-h 826 1 root S 1168 2% 0% /sbin/logd -S 16 447 1 root S 1168 2% 0% /sbin/ubusd 920 1 root S 1052 2% 0% /usr/sbin/dropbear -F -P /var/run/dro 171 2 root SW 0 0% 0% [spi0] 8 2 root SW 0 0% 0% [kworker/u2:1] 6 2 root SW 0 0% 0% [kworker/u2:0] 98 2 root SW 0 0% 0% [kswapd0] 66 2 root SW< 0 0% 0% [bioset] 65 2 root SW< 0 0% 0% [crypto] ^C339 2 root SW< 0 0% 0% [kworker/0:1H]
|
1.1.2 NAT測試
設置方法:PC1固定IP,鏈接到WAN口,PC2鏈接到LAN口。而後進路由器的命令行固定WAN口的IP。
測試結果:
LAN-WAN Result = 92Mbps
WAN-LAN Result = 88Mbps
能夠看到CPU資源被佔用了大部分,可是仍是有16%的idle。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
|
Mem: 18656K used, 42056K free, 76K shrd, 1788K buff, 5608K cached CPU: 0% usr 0% sys 0% nic 16% idle 0% io 0% irq 82% sirq Load average: 0.00 0.03 0.06 2/33 1535 PID PPID USER STAT VSZ %VSZ %CPU COMMAND 1109 1 root S 1636 3% 5% /usr/sbin/hostapd -P /var/run/wifi-ph 3 2 root RW 0 0% 4% [ksoftirqd/0] 1535 448 root R 1176 2% 3% top 99 2 root SW 0 0% 1% [kworker/0:1] 861 1 root S 1688 3% 0% /sbin/netifd 1 0 root S 1516 2% 0% /sbin/procd 882 1 root S 1272 2% 0% /usr/sbin/odhcpd 965 1 root S 1172 2% 0% /usr/sbin/ntpd -n -S /usr/sbin/ntpd-h 448 1 root S 1172 2% 0% /bin/ash --login 1425 861 root S 1172 2% 0% udhcpc -p /var/run/udhcpc-wan.pid -s 826 1 root S 1168 2% 0% /sbin/logd -S 16 447 1 root S 1168 2% 0% /sbin/ubusd 920 1 root S 1052 2% 0% /usr/sbin/dropbear -F -P /var/run/dro 1379 1 dnsmasq S 1040 2% 0% /usr/sbin/dnsmasq -C /var/etc/dnsmasq 1428 861 root S 912 1% 0% odhcp6c -s /lib/netifd/dhcpv6.script 171 2 root SW 0 0% 0% [spi0] 8 2 root SW 0 0% 0% [kworker/u2:1] 6 2 root SW 0 0% 0% [kworker/u2:0] 98 2 root SW 0 0% 0% [kswapd0] ^C339 2 root SW< 0 0% 0% [kworker/0:1H]
|
1.2 XIAOMI MINI
1.2.1 Switch測試
小米MINI的switch轉發路徑是在硬件裏面的,因此LAN轉發的路徑對CPU幾乎沒有佔用。
測試結果: 94.7Mbps
能夠看到CPU佔用幾乎沒有。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
|
Mem: 20860K used, 105092K free, 560K shrd, 2060K buff, 7016K cached CPU: 0% usr 3% sys 0% nic 94% idle 0% io 0% irq 1% sirq Load average: 0.10 0.08 0.05 1/45 1536 PID PPID USER STAT VSZ %VSZ %CPU COMMAND 1164 1 dnsmasq S 1044 1% 3% /usr/sbin/dnsmasq -C /var/etc/dnsmasq 1530 1235 root R 1180 1% 1% top -d 1 1234 1147 root S 1124 1% 1% /usr/sbin/dropbear -F -P /var/run/dro 908 1 root S 1628 1% 0% /sbin/netifd 973 1 root S 1540 1% 0% /usr/sbin/uhttpd -f -h /www -r OpenWr 1 0 root S 1536 1% 0% /sbin/procd 872 1 root S 1440 1% 0% /sbin/rpcd 931 1 root S 1280 1% 0% /usr/sbin/odhcpd 1235 1234 root S 1180 1% 0% -ash 410 1 root S 1176 1% 0% /sbin/ubusd 863 1 root S 1176 1% 0% /sbin/logd -S 16 1089 908 root S 1176 1% 0% udhcpc -p /var/run/udhcpc-eth0.2.pid 1022 1 root S 1176 1% 0% /usr/sbin/ntpd -n -S /usr/sbin/ntpd-h 1147 1 root S 1056 1% 0% /usr/sbin/dropbear -F -P /var/run/dro 1091 908 root S 916 1% 0% odhcp6c -s /lib/netifd/dhcpv6.script 411 1 root S 892 1% 0% /sbin/askfirst /usr/libexec/login.sh 118 2 root SW 0 0% 0% [kworker/0:1] 175 2 root SW 0 0% 0% [spi0] 3 2 root SW 0 0% 0% [ksoftirqd/0] ^C 6 2 root SW 0 0% 0% [kworker/u2:0]
|
1.2.2 NAT測試
小米使用的硬件平臺是MediaTek MT7620A ver:2 eco:6 ,帶有NAT硬件加速,簡稱HNAT。
Openwrt不支持硬件NAT,測試結果以下:
Result= 94.7Mbps
在這個測試中,幾乎佔用了全部的CPU。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
|
Mem: 23308K used, 102644K free, 560K shrd, 2060K buff, 7024K cached CPU: 1% usr 14% sys 0% nic 0% idle 0% io 0% irq 83% sirq Load average: 0.29 0.16 0.08 2/47 1669 PID PPID USER STAT VSZ %VSZ %CPU COMMAND 1089 908 root R 1176 1% 92% udhcpc -p /var/run/udhcpc-eth0.2.pid 3 2 root RW 0 0% 3% [ksoftirqd/0] 1164 1 dnsmasq S 1044 1% 2% /usr/sbin/dnsmasq -C /var/etc/dnsmasq 1669 1659 root R 1180 1% 1% top 1658 1147 root S 1124 1% 1% /usr/sbin/dropbear -F -P /var/run/dro 118 2 root SW 0 0% 1% [kworker/0:1] 908 1 root S 1628 1% 0% /sbin/netifd 6 2 root SW 0 0% 0% [kworker/u2:0] 973 1 root S 1540 1% 0% /usr/sbin/uhttpd -f -h /www -r OpenWr 1 0 root S 1536 1% 0% /sbin/procd 872 1 root S 1440 1% 0% /sbin/rpcd 931 1 root S 1280 1% 0% /usr/sbin/odhcpd 1235 1234 root S 1180 1% 0% -ash 1659 1658 root S 1180 1% 0% -ash 410 1 root S 1176 1% 0% /sbin/ubusd 863 1 root S 1176 1% 0% /sbin/logd -S 16 1022 1 root S 1176 1% 0% /usr/sbin/ntpd -n -S /usr/sbin/ntpd-h 1234 1147 root S 1124 1% 0% /usr/sbin/dropbear -F -P /var/run/dro 1147 1 root S 1056 1% 0% /usr/sbin/dropbear -F -P /var/run/dro ^C091 908 root S 916 1% 0% odhcp6c -s /lib/netifd/dhcpv6.script
|
使用PandoraBox的固件能夠挽救這一局面。它集成了私有的HNAT代碼。
1
|
|
PandoraBox-ralink-mt7620-xiaomi-mini-squashfs-sysupgrade-r1024-20150608.bin
|
若要打開這個功能,須要在網頁中設置,相關的腳本在/etc/init.d/下面,他會加載HNAT的驅動。
測試的結果是94.7Mbps
能夠看到幾乎沒有CPU的佔用。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
|
Mem: 48232K used, 78160K free, 0K shrd, 0K buff, 2146650668K cached CPU: 0% usr 0% sys 0% nic 98% idle 0% io 0% irq 0% sirq Load average: 0.00 0.09 0.12 1/42 2685 PID PPID USER STAT VSZ %VSZ %CPU COMMAND 2685 2625 root R 1376 1% 1% top -d 1 2124 1 root S 2576 2% 0% /usr/sbin/nmbd -D 2117 1 root S 2496 2% 0% /usr/sbin/smbd -D 2399 1 nobody S 1936 2% 0% /usr/sbin/dnsmasq -C /var/etc/dnsmasq 1784 1 root S 1548 1% 0% /usr/sbin/uhttpd -f -h /www -r Pandor 1650 1 root S 1472 1% 0% /sbin/netifd 1 0 root S 1404 1% 0% /sbin/procd 1769 1 root S 1376 1% 0% /usr/sbin/telnetd -F -l /bin/login.sh 2625 1769 root S 1376 1% 0% -ash 2354 1 root S 1376 1% 0% /usr/sbin/crond -f -c /etc/crontabs - 1722 1 root S 1372 1% 0% /usr/sbin/ntpd -n -l -p 0.pool.ntp.or 1851 1650 root S 1372 1% 0% udhcpc -p /var/run/udhcpc-eth0.2.pid 1685 1 root S 1160 1% 0% /usr/sbin/odhcpd 2157 1 root S 1148 1% 0% /usr/sbin/dropbear -F -P /var/run/dro 1614 1 root S 1040 1% 0% /sbin/logd -S 16 1801 1 root S 984 1% 0% /usr/sbin/vsftpd 480 1 root S 884 1% 0% /sbin/ubusd 1864 1650 root S 828 1% 0% odhcp6c -s /lib/netifd/dhcpv6.script 558 1 root S 768 1% 0% /sbin/askfirst /bin/login ^C559 1 root S 768 1% 0% /sbin/askfirst /bin/login
|
1.3 總結
1. 對於Switch和NAT功能,硬件能夠實現offload功能,減輕CPU的負擔
2. 對於滿速的Throughput測試,CPU基本能夠知足需求,可是會吃光CPU的資源。
3. 加入大量的打印會影響性能,若是將打印輸出到串口會讓性能降到幾乎爲0
l 打印和速率的關係(打印影響性能)
l 硬件Switch和軟件網橋比較
能夠看出來,硬件Switch的優點明顯。
l 硬件NAT和軟件NAT比較
能夠看出來,實現硬件NAT會下降不少系統的負擔。可是硬件NAT不夠靈活,沒有集成一些軟件能夠添加的高級功能。