概述
网络性能测试主要测试DPU的Ethernet性能,由于现场都是bond模式,因此测试只针对两个物理口作bond之后的网络。
监测脚本
通过如下的监测脚本来分析每个物理网口(p0 / p1)的网络报文统计值(bps / pps):
cd eth_stat.sh
#!/bin/bash
IFG_PLUS_PREAMBLE=20 # IFG 12B + Preamble 8B
update_stats () { # $name $index
TS_LAST[ 2 ] = 2]= 2]={TS[$2]}
R_PKT_LAST[ 2 ] = 2]= 2]={R_PKT[$2]}
R_BYTE_LAST[ 2 ] = 2]= 2]={R_BYTE[$2]}
T_PKT_LAST[ 2 ] = 2]= 2]={T_PKT[$2]}
T_BYTE_LAST[ 2 ] = 2]= 2]={T_BYTE[$2]}
ETHTOOL=($(ethtool -S $1 | awk '/tx_packets_phy/{print $2} /rx_packets_phy/{print $2} /tx_bytes_phy/{print $2} /rx_bytes_phy/{print$2}'))
if [ -z "$ETHTOOL" ]; then
ETHTOOL=($(ethtool -S $1 | awk '/tx_packets/{print $2} /rx_packets/{print $2} /tx_bytes/{print $2} /rx_bytes/{print$2}'))
fi
TS[$2]=$(date +%s%6N) # in usec
T_PKT[$2]=${ETHTOOL[0]}
R_PKT[$2]=${ETHTOOL[1]}
T_BYTE[$2]=${ETHTOOL[2]}
R_BYTE[$2]=${ETHTOOL[3]}
}
NETIF=(“p0” “p1”)
length=${#NETIF[@]}
echo $length
for ((i=0; i<$length; i++)) do
printf “[%'9s Rx]: \n” KaTeX parse error: Expected '}', got 'EOF' at end of input: {NETIF[i]}
done
index=0
for ((i=0; i<$length; i++)) do
update_stats KaTeX parse error: Expected '}', got 'EOF' at end of input: {NETIF[i]} $index
((index++))
done
index=0
for ((i=0; i< l e n g t h ; i + + ) ) d o R P K T I N I T [ length; i++)) do R_PKT_INIT[ length;i++))doRPKTINIT[index]=KaTeX parse error: Expected '}', got 'EOF' at end of input: {R_PKT[index]}
T_PKT_INIT[ i n d e x ] = index]= index]={T_PKT[KaTeX parse error: Expected 'EOF', got '}' at position 7: index]}̲ R_BYTE_INI…index]=KaTeX parse error: Expected '}', got 'EOF' at end of input: {R_BYTE[index]}
T_BYTE_INIT[ i n d e x ] = index]= index]={T_BYTE[$index]}
((index++))
done
sleep 1
while true; do
index=0
for ((i=0; i<$length; i++)) do
update_stats ${NETIF[$i]} $index
TS_DIFF=$((${TS[$index]} - ${TS_LAST[$index]}))
R_PKT_DELTA=$((${R_PKT[$index]} - ${R_PKT_LAST[$index]}))
R_PKT_RATE=$(( $R_PKT_DELTA * 1000000 / $TS_DIFF))
R_BIT_DELTA=$(( (${R_BYTE[$index]} - ${R_BYTE_LAST[$index]} + $IFG_PLUS_PREAMBLE * $R_PKT_DELTA) * 8 ))
R_BIT_RATE=$(( $R_BIT_DELTA * 1000000 / $TS_DIFF))
T_PKT_DELTA=$(( ${T_PKT[$index]} - ${T_PKT_LAST[$index]} ))
T_PKT_RATE=$(( $T_PKT_DELTA * 1000000 / $TS_DIFF))
T_BIT_DELTA=$(( (${T_BYTE[$index]} - ${T_BYTE_LAST[$index]} + $IFG_PLUS_PREAMBLE * $T_PKT_DELTA) * 8 ))
T_BIT_RATE=$(( $T_BIT_DELTA * 1000000 / $TS_DIFF))
R_PKT_TOTAL=$(( ${R_PKT[$index]} - ${R_PKT_INIT[$index]} ))
T_PKT_TOTAL=$(( ${T_PKT[$index]} - ${T_PKT_INIT[$index]} ))
R_BYTE_TOTAL=$(( ${R_BYTE[$index]} - ${R_BYTE_INIT[$index]} ))
T_BYTE_TOTAL=$(( ${T_BYTE[$index]} - ${T_BYTE_INIT[$index]} ))
printf "[%'9s Rx]: %'16d pkts %'16d pps | %'20d bytes %'16d bps \n" ${NETIF[$i]} $R_PKT_TOTAL $R_PKT_RATE $R_BYTE_TOTAL $R_BIT_RATE
printf "[%'9s Tx]: %'16d pkts %'16d pps | %'20d bytes %'16d bps \n" ${NETIF[$i]} $T_PKT_TOTAL $T_PKT_RATE $T_BYTE_TOTAL $T_BIT_RATE
((index++))
done
printf "\n"
sleep 1
done
测试过程
按采用Pktgen软件进行网络性能的测试:
cd Pktgen-DPDK-pktgen-23.06.1/
vim ./app/pktgen-stats.c
/* Setup a few default values to prevent problems later. */
info->link.link_speed = 200000; //RTE_ETH_SPEED_NUM_10G;
make
umount /dev/hugepages
mkdir -p /mnt/huge_1GB
mount -t hugetlbfs -o pagesize=1G none /mnt/huge_1GB
echo 20 >/sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages
echo 0 >/proc/sys/kernel/randomize_va_space
./usr/local/bin/pktgen -c 0x1f -n 4 -a 0000:03:00.0 – -P -m “[1-4:1-4].0”
set 0 proto tcp
range 0 src mac start a0:88:c2:36:b7:20
range 0 src mac min a0:88:c2:36:b7:ff
range 0 src mac inc 00:00:00:00:00:01
range 0 dst mac start 8e:6a:eb:1f:6e:2a
range 0 dst mac min 8e:6a:eb:1f:6e:2a
range 0 dst mac inc 00:00:00:00:00:00
range 0 src port start 10000
range 0 src port min 10000
range 0 src port max 10000
range 0 src port inc 0
range 0 dst port start 2000
range 0 dst port min 2000
range 0 dst port max 3000
range 0 dst port inc 1
range 0 proto tcp
range 0 src ip start 10.0.2.245
range 0 src ip min 10.0.2.245
range 0 src ip max 10.0.2.255
range 0 src ip inc 0.0.0.1
range 0 size start 64
range 0 size min 64
range 0 size max 64
range 0 size inc 0
range 0 dst ip start 10.240.24.242
range 0 dst ip min 10.240.24.242
range 0 dst ip inc 0.0.0.0
enable all range
start 0
stop 0
range 0 size start 1540
range 0 size min 1540
range 0 size max 1540
start 0
目
编写服务测试开机启动dpvgw:
TX:::::::::::::::::::::::::::::::
Link State : —Total Rate—
Pkts/s Rx : 0 0
Tx : 15,600,128 15,600,128
MBits/s Rx/Tx : 0/191,944 0/191,944
Pkts/s Rx Max : 3 3
Tx Max : 107,244,736 107,244,736
RX:::::::::::::::::::::::::::::::
Link State : —Total Rate—
Pkts/s Rx : 15598477 15598477
Tx : 0 0
MBits/s Rx/Tx : 191923/0 191923/0
Pkts/s Rx Max : 92984446 92984446
Tx Max : 0 0
1core发送,4core接收:
TX:::::::::::::::::::::::::::::::
Link State : —Total Rate—
Pkts/s Rx : 0 0
Tx : 34,647,168 34,647,168
MBits/s Rx/Tx : 0/23,282 0/23,282
Pkts/s Rx Max : 2 2
Tx Max : 35,088,896 35,088,896
RX:::::::::::::::::::::::::::::::
Link State : —Total Rate—
Pkts/s Rx : 34793361 34793361
Tx : 0 0
MBits/s Rx/Tx : 23377/0 23377/0
Pkts/s Rx Max : 92984446 92984446
Tx Max : 0 0
2core发送,4core接收:
TX:::::::::::::::::::::::::::::::
Link State : —Total Rate—
Pkts/s Rx : 0 0
Tx : 65,837,440 65,837,440
MBits/s Rx/Tx : 0/44,242 0/44,242
Pkts/s Rx Max : 1 1
Tx Max : 66,824,704 66,824,704
RX:::::::::::::::::::::::::::::::
Link State : —Total Rate—
Pkts/s Rx : 65846567 65846567
Tx : 0 0
MBits/s Rx/Tx : 44247/0 44247/0
Pkts/s Rx Max : 92984446 92984446
Tx Max : 0 0
3core发送,4core接收:
TX:::::::::::::::::::::::::::::::
Link State : —Total Rate—
Pkts/s Rx : 0 0
Tx : 91,331,712 91,331,712
MBits/s Rx/Tx : 0/61,374 0/61,374
Pkts/s Rx Max : 2 2
Tx Max : 92,660,736 92,660,736
RX:::::::::::::::::::::::::::::::
Link State : —Total Rate—
Pkts/s Rx : 92874578 92874578
Tx : 0 0
MBits/s Rx/Tx : 62411/0 62411/0
Pkts/s Rx Max : 93528981 93528981
Tx Max : 0 0
4core发送,4core接收:
TX:::::::::::::::::::::::::::::::
Link State : —Total Rate—
Pkts/s Rx : 0 0
Tx : 103,238,848 103,238,848
MBits/s Rx/Tx : 0/69,376 0/69,376
Pkts/s Rx Max : 2 2
Tx Max : 103,669,824 103,669,824
RX:::::::::::::::::::::::::::::::
Link State : —Total Rate—
Pkts/s Rx : 92409275 92409275
Tx : 0 0
MBits/s Rx/Tx : 62099/0 62099/0
Pkts/s Rx Max : 93513697 93513697
Tx Max : 0 0