By Toradex胡珊逢
Verdin iMX8M Plus?是?Toradex?采用?NXP?最新的?i.MX 8M Plus?處理器的計(jì)算機(jī)模塊击喂,其具有?4x Cortex-A53?和?Cortex-M7?核心,支持神經(jīng)網(wǎng)絡(luò)加速運(yùn)算的?NPU碰辅,H.265?硬件編碼懂昂,CAN FD?,以及雙路千兆以太網(wǎng)没宾。配合?Verdin?開發(fā)板凌彬,用戶可以直接測試兩路以太網(wǎng)。文章將對網(wǎng)絡(luò)性能做簡要的測試循衰。
使用?Toradex Easy Installer?安裝?Linux BSP v5.3.0铲敛,?默認(rèn)的配置已經(jīng)支持兩路千兆以太網(wǎng)。因此安裝完成重啟后即可看到兩個(gè)網(wǎng)絡(luò)接口会钝。
----------------------------------
root@verdin-imx8mp:~# ifconfig
eth0 ?????Link encap:Ethernet ?HWaddr 00:14:2D:78:82:04 ?
??????????inet addr:192.168.20.120 ?Bcast:192.168.20.255 ?Mask:255.255.255.0
??????????inet6 addr: fe80::214:2dff:fe78:8204/64 Scope:Link
??????????UP BROADCAST RUNNING MULTICAST ?MTU:1500 ?Metric:1
??????????RX packets:5105505 errors:0 dropped:0 overruns:0 frame:0
??????????TX packets:5988237 errors:0 dropped:0 overruns:0 carrier:0
??????????collisions:0 txqueuelen:1000
??????????RX bytes:7344324802 (6.8 GiB) ?TX bytes:8611102924 (8.0 GiB)
??????????Interrupt:48
eth1 ?????Link encap:Ethernet ?HWaddr 00:14:2D:68:82:04 ?
??????????inet addr:192.168.200.150 ?Bcast:192.168.200.255 ?Mask:255.255.255.0
??????????inet6 addr: fe80::214:2dff:fe68:8204/64 Scope:Link
??????????UP BROADCAST RUNNING MULTICAST ?MTU:1500 ?Metric:1
??????????RX packets:6686311 errors:0 dropped:0 overruns:0 frame:0
??????????TX packets:247321 errors:0 dropped:0 overruns:0 carrier:0
??????????collisions:0 txqueuelen:1000
??????????RX bytes:6234153398 (5.8 GiB) ?TX bytes:8180651220 (7.6 GiB)
----------------------------------
Verdin?開發(fā)板分別和兩臺(tái)電腦相連伐蒋,鏈路速度為?1000Mbps。
IP?地址設(shè)置如下迁酸。
PC1:192.168.200.1
PC2:192.168.20.132
Eth0: 192.168.200.150
Eth1:192.168.20.120
測試場景為
l?Eth0和?Eth1?單獨(dú)向?PC1?和?PC2?發(fā)送數(shù)據(jù)
l?Eth0和?Eth1同時(shí)向?PC1?和?PC2?發(fā)送數(shù)據(jù)
l?Eth0和?Eth1?單獨(dú)接收來自?PC1?和?PC2?的數(shù)據(jù)
l?Eth0和?Eth1?同時(shí)接收來自?PC1?和?PC2?的數(shù)據(jù)
l?Eth0?上的數(shù)據(jù)轉(zhuǎn)發(fā)到?Eth1
期間測試模塊?Eth0和?Eth1?的最大帶寬以及?CPU?占用率先鱼。
Eth0和?Eth1?單獨(dú)向?PC1?和?PC2?發(fā)送數(shù)據(jù)
在?PC1?和?PC2?上運(yùn)行?iperf3?服務(wù)器。
----------------------------------
$ iperf3 -s
----------------------------------
在?Verdin iMX8M Plus?運(yùn)行?iperf3?向?PC?發(fā)送數(shù)據(jù)奸鬓。Eth0?和?Eth1?的測試數(shù)據(jù)如下焙畔。
Eth0:
----------------------------------
root@verdin-imx8mp:~# iperf3 -c 192.168.20.132
Connecting to host 192.168.20.132, port 5201
[ ?5] local 192.168.20.120 port 34982 connected to 192.168.20.132 port 5201
[ ID] Interval ??????????Transfer ????Bitrate ????????Retr ?Cwnd
[ ?5] ??0.00-1.00 ??sec ??114 MBytes ??957 Mbits/sec ???0 ???373 KBytes ??????
[ ?5] ??1.00-2.00 ??sec ??112 MBytes ??942 Mbits/sec ???0 ???373 KBytes ??????
[ ?5] ??2.00-3.00 ??sec ??112 MBytes ??937 Mbits/sec ???0 ???410 KBytes ??????
[ ?5] ??3.00-4.00 ??sec ??112 MBytes ??942 Mbits/sec ???0 ???410 KBytes ??????
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval ??????????Transfer ????Bitrate ????????Retr
[ ?5] ??0.00-10.00 ?sec ?1.10 GBytes ??942 Mbits/sec ???0 ????????????sender
[ ?5] ??0.00-10.00 ?sec ?1.10 GBytes ??941 Mbits/sec ?????????????????receiver
iperf Done.
----------------------------------
Eth1:
----------------------------------
root@verdin-imx8mp:~# iperf3 -c 192.168.200.1
Connecting to host 192.168.200.1, port 5201
[ ?5] local 192.168.200.150 port 59206 connected to 192.168.200.1 port 5201
[ ID] Interval ??????????Transfer ????Bitrate ????????Retr ?Cwnd
[ ?5] ??0.00-1.00 ??sec ??111 MBytes ??934 Mbits/sec ???0 ??1.14 MBytes ??????
[ ?5] ??1.00-2.00 ??sec ??112 MBytes ??944 Mbits/sec ???0 ??1.23 MBytes ??????
[ ?5] ??2.00-3.00 ??sec ??111 MBytes ??933 Mbits/sec ???0 ??1.23 MBytes ??????
[ ?5] ??3.00-4.00 ??sec ??112 MBytes ??943 Mbits/sec ???0 ??1.23 MBytes ??????
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval ??????????Transfer ????Bitrate ????????Retr
[ ?5] ??0.00-10.00 ?sec ?1.09 GBytes ??940 Mbits/sec ???0 ????????????sender
[ ?5] ??0.00-10.00 ?sec ?1.09 GBytes ??937 Mbits/sec ?????????????????receiver
iperf Done.
----------------------------------
Verdin iMX8M Plus CPU?占用率:
Eth0和?Eth1同時(shí)向?PC1?和?PC2?發(fā)送數(shù)據(jù)
Eth0:
----------------------------------
root@verdin-imx8mp:~# iperf3 -c 192.168.20.132
Connecting to host 192.168.20.132, port 5201
[ ?5] local 192.168.20.120 port 34994 connected to 192.168.20.132 port 5201
[ ID] Interval ??????????Transfer ????Bitrate ????????Retr ?Cwnd
[ ?5] ??0.00-1.00 ??sec ??113 MBytes ??949 Mbits/sec ???0 ???438 KBytes ??????
[ ?5] ??1.00-2.00 ??sec ??112 MBytes ??937 Mbits/sec ???0 ???464 KBytes ??????
[ ?5] ??2.00-3.00 ??sec ??112 MBytes ??943 Mbits/sec ???0 ???464 KBytes ??????
[ ?5] ??3.00-4.00 ??sec ??111 MBytes ??935 Mbits/sec ???0 ???464 KBytes ??????
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval ??????????Transfer ????Bitrate ????????Retr
[ ?5] ??0.00-10.00 ?sec ?1.09 GBytes ??940 Mbits/sec ???0 ????????????sender
[ ?5] ??0.00-10.00 ?sec ?1.09 GBytes ??939 Mbits/sec ?????????????????receiver
iperf Done.
----------------------------------
Eth1:
----------------------------------
root@verdin-imx8mp:~# iperf3 -c 192.168.200.1
Connecting to host 192.168.200.1, port 5201
[ ?5] local 192.168.200.150 port 59210 connected to 192.168.200.1 port 5201
[ ID] Interval ??????????Transfer ????Bitrate ????????Retr ?Cwnd
[ ?5] ??0.00-1.00 ??sec ??111 MBytes ??929 Mbits/sec ???0 ??1.14 MBytes ??????
[ ?5] ??1.00-2.00 ??sec ??112 MBytes ??944 Mbits/sec ???0 ??1.14 MBytes ??????
[ ?5] ??2.00-3.00 ??sec ??111 MBytes ??933 Mbits/sec ???0 ??1.14 MBytes ??????
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval ??????????Transfer ????Bitrate ????????Retr
[ ?5] ??0.00-10.00 ?sec ?1.09 GBytes ??936 Mbits/sec ???0 ????????????sender
[ ?5] ??0.00-10.00 ?sec ?1.09 GBytes ??933 Mbits/sec ?????????????????receiver
iperf Done.
----------------------------------
Verdin iMX8M Plus CPU?占用率:
Eth0和?Eth1?單獨(dú)接收來自?PC1?和?PC2?的數(shù)據(jù)
在?Verdin iMX8M Plus?分別運(yùn)行?iperf3?服務(wù)器,針對?Eth0?和?Eth1?使用不同的端口全蝶。
----------------------------------
root@verdin-imx8mp:~# iperf3 -B 192.168.20.120 -s
root@verdin-imx8mp:~# iperf3 -B 192.168.200.150 -p 5202 -s
----------------------------------
Eth0:
----------------------------------
root@verdin-imx8mp:~# iperf3 -B 192.168.20.120 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 192.168.20.132, port 48674
[ ?5] local 192.168.20.120 port 5201 connected to 192.168.20.132 port 48676
[ ID] Interval ??????????Transfer ????Bitrate
[ ?5] ??0.00-1.00 ??sec ??111 MBytes ??933 Mbits/sec ?????????????????
[ ?5] ??1.00-2.00 ??sec ??111 MBytes ??935 Mbits/sec ?????????????????
[ ?5] ??2.00-3.00 ??sec ??111 MBytes ??934 Mbits/sec ?????????????????
[ ?5] ??3.00-4.00 ??sec ??111 MBytes ??935 Mbits/sec ?????????????????
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval ??????????Transfer ????Bitrate
[ ?5] ??0.00-10.00 ?sec ?1.09 GBytes ??934 Mbits/sec ?????????????????receiver
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
----------------------------------
Eth1:
----------------------------------
root@verdin-imx8mp:~# iperf3 -B 192.168.200.150 -p 5202 -s
-----------------------------------------------------------
Server listening on 5202
-----------------------------------------------------------
Accepted connection from 192.168.200.1, port 47290
[ ?5] local 192.168.200.150 port 5202 connected to 192.168.200.1 port 47292
[ ID] Interval ??????????Transfer ????Bitrate
[ ?5] ??0.00-1.00 ??sec ??110 MBytes ??919 Mbits/sec ?????????????????
[ ?5] ??1.00-2.00 ??sec ??112 MBytes ??939 Mbits/sec ?????????????????
[ ?5] ??2.00-3.00 ??sec ??112 MBytes ??941 Mbits/sec ?????????????????
[ ?5] ??3.00-4.00 ??sec ??112 MBytes ??941 Mbits/sec ?????????????????
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval ??????????Transfer ????Bitrate
[ ?5] ??0.00-10.00 ?sec ?1.09 GBytes ??938 Mbits/sec ?????????????????receiver
----------------------------------
Verdin iMX8M Plus CPU?占用率:
Eth0和?Eth1?同時(shí)接收來自?PC1?和?PC2?的數(shù)據(jù)
Eth0:
----------------------------------
root@verdin-imx8mp:~# iperf3 -B 192.168.20.120 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 192.168.20.132, port 48712
[ ?5] local 192.168.20.120 port 5201 connected to 192.168.20.132 port 48714
[ ID] Interval ??????????Transfer ????Bitrate
[ ?5] ??0.00-1.00 ??sec ??111 MBytes ??931 Mbits/sec ?????????????????
[ ?5] ??1.00-2.00 ??sec ??111 MBytes ??934 Mbits/sec ?????????????????
[ ?5] ??2.00-3.00 ??sec ??111 MBytes ??934 Mbits/sec ?????????????????
[ ?5] ??3.00-4.00 ??sec ??111 MBytes ??935 Mbits/sec ?????????????????
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval ??????????Transfer ????Bitrate
[ ?5] ??0.00-10.00 ?sec ?1.09 GBytes ??934 Mbits/sec ?????????????????receiver
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
----------------------------------
Eth1:
----------------------------------
root@verdin-imx8mp:~# iperf3 -B 192.168.200.150 -p 5202 -s
-----------------------------------------------------------
Server listening on 5202
-----------------------------------------------------------
Accepted connection from 192.168.200.1, port 47308
[ ?5] local 192.168.200.150 port 5202 connected to 192.168.200.1 port 47310
[ ID] Interval ??????????Transfer ????Bitrate
[ ?5] ??0.00-1.00 ??sec ??110 MBytes ??919 Mbits/sec ?????????????????
[ ?5] ??1.00-2.00 ??sec ??112 MBytes ??941 Mbits/sec ?????????????????
[ ?5] ??2.00-3.00 ??sec ??112 MBytes ??941 Mbits/sec ?????????????????
[ ?5] ??3.00-4.00 ??sec ??112 MBytes ??941 Mbits/sec ?????????????????
[ ?5] ??4.00-5.00 ??sec ??112 MBytes ??941 Mbits/sec ?????????????????
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval ??????????Transfer ????Bitrate
[ ?5] ??0.00-10.00 ?sec ?1.08 GBytes ??928 Mbits/sec ?????????????????receiver
-----------------------------------------------------------
Server listening on 5202
-----------------------------------------------------------
----------------------------------
Verdin iMX8M Plus CPU?占用率:
Eth0?上的數(shù)據(jù)轉(zhuǎn)發(fā)到?Eth1
為了將?Eth0?的數(shù)據(jù)轉(zhuǎn)發(fā)到?Eth1闹蒜,需要設(shè)置?/etc/sysctl.conf?寺枉。
----------------------------------
# needed for routing, including masquerading or NAT
net/ipv4/ip_forward=1 ?
----------------------------------
然后運(yùn)行sysctl?另設(shè)置生效,當(dāng)然重啟系統(tǒng)也可以绷落。
----------------------------------
root@verdin-imx8mp:~# sysctl -p
----------------------------------
設(shè)置轉(zhuǎn)發(fā)規(guī)則姥闪。
----------------------------------
root@verdin-imx8mp:~# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
root@verdin-imx8mp:~# iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
root@verdin-imx8mp:~# iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
----------------------------------
在?PC2?上啟動(dòng)?iperf3?服務(wù)器,PC 1?運(yùn)行?iper3?客戶端發(fā)送數(shù)據(jù)砌烁,所有的數(shù)據(jù)由?Verdin iMX8M Plus?負(fù)責(zé)從?Eth0?轉(zhuǎn)發(fā)到?Eth1?上筐喳。
PC2 Server:
----------------------------------
$ iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 192.168.20.120, port 55360
[ ?5] local 192.168.20.132 port 5201 connected to 192.168.20.120 port 55362
[ ID] Interval ??????????Transfer ????Bitrate
[ ?5] ??0.00-1.00 ??sec ??105 MBytes ??881 Mbits/sec ?????????????????
[ ?5] ??1.00-2.00 ??sec ??111 MBytes ??928 Mbits/sec ?????????????????
[ ?5] ??2.00-3.00 ??sec ??110 MBytes ??921 Mbits/sec ?????????????????
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval ??????????Transfer ????Bitrate
[ ?5] ??0.00-10.00 ?sec ?1.08 GBytes ??931 Mbits/sec ?????????????????receiver
----------------------------------
PC1 Client:
----------------------------------
$ iperf3 -c 192.168.20.132
Connecting to host 192.168.20.132, port 5201
[ ?5] local 192.168.200.1 port 55362 connected to 192.168.20.132 port 5201
[ ID] Interval ??????????Transfer ????Bitrate ????????Retr ?Cwnd
[ ?5] ??0.00-1.00 ??sec ??108 MBytes ??904 Mbits/sec ???0 ???471 KBytes ??????
[ ?5] ??1.00-2.00 ??sec ??110 MBytes ??926 Mbits/sec ???0 ???492 KBytes ??????
[ ?5] ??2.00-3.00 ??sec ??109 MBytes ??916 Mbits/sec ???0 ???492 KBytes ??????
[ ?5] ??3.00-4.00 ??sec ??112 MBytes ??938 Mbits/sec ???0 ???492 KBytes ??????
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval ??????????Transfer ????Bitrate ????????Retr
[ ?5] ??0.00-10.00 ?sec ?1.09 GBytes ??934 Mbits/sec ???0 ????????????sender
[ ?5] ??0.00-10.00 ?sec ?1.08 GBytes ??931 Mbits/sec ?????????????????receiver
----------------------------------
Verdin iMX8M Plus CPU?占用率:
數(shù)據(jù)匯總?cè)缦隆?/p>
兩個(gè)千兆網(wǎng)口無論是在單獨(dú)還是同時(shí)收發(fā)數(shù)據(jù)時(shí)都達(dá)到920Mbps?以上,包括網(wǎng)口之間的數(shù)據(jù)轉(zhuǎn)發(fā)函喉,基本接近滿帶寬避归。在?CPU?占用方面,當(dāng)兩個(gè)千兆網(wǎng)口以接近滿帶寬速率同時(shí)工作時(shí)管呵,其中一個(gè)核心站占用率會(huì)超過?70%梳毙。
總結(jié)
Verdin iMX8M Plus?的雙網(wǎng)口設(shè)計(jì)為多網(wǎng)口需求的應(yīng)用提供了理想的選擇,例如在工業(yè)自動(dòng)化中捐下,一個(gè)網(wǎng)口運(yùn)行實(shí)時(shí)性要求高的應(yīng)用如?EtherCAT账锹,而另外一個(gè)則可以用于一般的網(wǎng)絡(luò)通信】澜螅或者另一個(gè)網(wǎng)口可以用作冗余接口奸柬,或者連接兩個(gè)不同的網(wǎng)絡(luò)。Verdin iMX8M Plus?還有許多其他實(shí)用的功能婴程,我們會(huì)在后續(xù)的文章進(jìn)行介紹