BA-PKT-GEN.txt

    科技2025-09-24  73

    ################################################################################ # HOST 配置 ################################################################################ 

    #vim /etc/grub2.cfg #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #linux16 /vmlinuz-3.10.0-1127.19.1.el7.x86_64 root=/dev/mapper/centos-root ro rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/root crashkernel=auto  vconsole.keymap=us rhgb LANG=en_US.UTF-8 console=tty0 console=ttyS0,115200n8 iommu=pt intel_iommu=on default_hugepagesz=1G hugepagesz=1G hugepages=6 #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< # #vim ~/.bash_profile #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #MYTOOLS=/home/liufeng/workspace/tools #export MYTOOLS # #DPDK_SDK=/home/liufeng/workspace/src/ovs-dpdk/dpdk/sdk #export DPDK_SDK # #PATH=$MYTOOLS/bin:$MYTOOLS/sbin:$MYTOOLS/libexec:$PATH:$HOME/.local/bin:$HOME/bin #export PATH # #C_INCLUDE_PATH=$MYTOOLS/include:$C_INCLUDE_PATH #export C_INCLUDE_PATH # #LD_LIBRARY_PATH=$DPDK_SDK/lib:$MYTOOLS/lib:$MYTOOLS/libexec:$LD_LIBRARY_PATH #export LD_LIBRARY_PATH #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #source ~/.bash_profile # # #su #vim ~/.bash_profile #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #MYTOOLS=/home/liufeng/workspace/tools #export MYTOOLS # #DPDK_SDK=/home/liufeng/workspace/src/ovs-dpdk/dpdk/sdk #export DPDK_SDK # #PATH=$MYTOOLS/bin:$MYTOOLS/sbin:$MYTOOLS/libexec:$PATH:$HOME/bin #export PATH # #C_INCLUDE_PATH=$MYTOOLS/include:$C_INCLUDE_PATH #export C_INCLUDE_PATH # #LD_LIBRARY_PATH=$DPDK_SDK/lib:$MYTOOLS/lib:$MYTOOLS/libexec:$LD_LIBRARY_PATH #export LD_LIBRARY_PATH #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #source ~/.bash_profile # #sudo yum install kernel-devel.x86_64 #yum provides '*/applydeltarpm' #yum install deltarpm #sudo yum install meson.noarch #yum install ninja-build.x86_64 #yum install cmake.x86_64 #yum install cmake3.x86_64 #yum install -y numactl-devel gcc  readline-devel lua-devel libpcap-devel gcc-g++ net-tools numactl-devel readline epel-release

    ################################################################################ # 编译DPDK ################################################################################ 

    ##  #git clone git@github.com:DPDK/dpdk.git #cd dpdk ##git checkout v19.11 -b v19.11 #git checkout v18.08 -b v18.08 #make config T=x86_64-native-linuxapp-gcc #sed -ri 's,(PMD_PCAP=).*,\1y,' build/.config #mkdir /home/liufeng/workspace/src/ovs-dpdk/dpdk/sdk #make install T=x86_64-native-linuxapp-gcc DESTDIR=/home/liufeng/workspace/src/ovs-dpdk/dpdk/sdk #sudo make install T=x86_64-native-linuxapp-gcc DESTDIR=/home/liufeng/workspace/tools/

    su 

    modprobe vfio modprobe vfio-pci chmod a+x /dev/vfio chmod 0666 /dev/vfio/*

    modprobe uio_pci_generic

    pushd /home/liufeng/workspace/src/ovs-dpdk/dpdk insmod x86_64-native-linuxapp-gcc/kmod/igb_uio.ko insmod x86_64-native-linuxapp-gcc/kmod/rte_kni.ko popd

    dpdk-devbind --status ifconfig enp4s0f0 down ifconfig enp4s0f1 down ifconfig enp4s0f2 down ifconfig enp4s0f3 down

    dpdk-devbind --bind=vfio-pci enp4s0f0 dpdk-devbind --bind=vfio-pci enp4s0f1 dpdk-devbind --bind=vfio-pci enp4s0f2 dpdk-devbind --bind=vfio-pci enp4s0f3

    dpdk-devbind --status

    ################################################################################ # 编译 LUA ################################################################################ #tar xvf lua-5.4.0.tar.gz #cd lua-5.4.0 #make linux #sudo make install  #make local

    ################################################################################ # 编译 PKTGEN-DPDK ################################################################################ 

    git clone git://dpdk.org/apps/pktgen-dpdk  cd /home/liufeng/workspace/src/ovs-dpdk/pktgen-dpdk #git checkout pktgen-3.7.2 -b pktgen-3.7.2 #export RTE_SDK=/home/liufeng/workspace/src/ovs-dpdk/dpdk/ #export RTE_TARGET=x86_64-native-linuxapp-gcc #make

    ################################################################ # USAGE ################################################################ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Usage: ./app/x86_64-native-linuxapp-gcc/pktgen [EAL options] -- [-h] [-v] [-P] [-G] [-T] [-f cmd_file] [-l log_file] [-s P:PCAP_file] [-m <string>]   -s P:file    PCAP packet stream file, 'P' is the port number   -s P:file0,file1,... list of PCAP packet stream files per queue, 'P' is the port number   -f filename  Command file (.pkt) to execute or a Lua script (.lua) file   -l filename  Write log to filename   -P           Enable PROMISCUOUS mode on all ports   -g address   Optional IP address and port number default is (localhost:0x5606)                If -g is used that enable socket support as a server application   -G           Enable socket support using default server values localhost:0x5606   -N           Enable NUMA support   -T           Enable the color output   -v           Verbose output   --no-crc-strip  Do not strip CRC on all ports, (Default is to strip crc)   -m <string>  matrix for mapping ports to logical cores       BNF: (or kind of BNF)       <matrix-string>   := """ <lcore-port> { "," <lcore-port>} """       <lcore-port>      := <lcore-list> "." <port-list>       <lcore-list>      := "[" <rx-list> ":" <tx-list> "]"       <port-list>       := "[" <rx-list> ":" <tx-list>"]"       <rx-list>         := <num> { "/" (<num> | <list>) }       <tx-list>         := <num> { "/" (<num> | <list>) }       <list>            := <num> { "/" (<range> | <list>) }       <range>           := <num> "-" <num> { "/" <range> }       <num>             := <digit>+       <digit>           := 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9       1.0, 2.1, 3.2                 - core 1 handles port 0 rx/tx,                                       core 2 handles port 1 rx/tx                                       core 3 handles port 2 rx/tx       1.[0-2], 2.3, ...             - core 1 handle ports 0,1,2 rx/tx,                                       core 2 handle port 3 rx/tx       [0-1].0, [2/4-5].1, ...       - cores 0-1 handle port 0 rx/tx,                                       cores 2,4,5 handle port 1 rx/tx       [1:2].0, [4:6].1, ...         - core 1 handles port 0 rx,                                       core 2 handles port 0 tx,       [1:2].[0-1], [4:6].[2/3], ... - core 1 handles port 0 & 1 rx,                                       core 2 handles port  0 & 1 tx       [1:2-3].0, [4:5-6].1, ...     - core 1 handles port 0 rx, cores 2,3 handle port 0 tx                                       core 4 handles port 1 rx & core 5,6 handles port 1 tx       [1-2:3].0, [4-5:6].1, ...     - core 1,2 handles port 0 rx, core 3 handles port 0 tx                                       core 4,5 handles port 1 rx & core 6 handles port 1 tx       [1-2:3-5].0, [4-5:6/8].1, ... - core 1,2 handles port 0 rx, core 3,4,5 handles port 0 tx                                       core 4,5 handles port 1 rx & core 6,8 handles port 1 tx       [1:2].[0:0-7], [3:4].[1:0-7], - core 1 handles port 0 rx, core 2 handles ports 0-7 tx                                       core 3 handles port 1 rx & core 4 handles port 0-7 tx       BTW: you can use "{}" instead of "[]" as it does not matter to the syntax.   -h           Display the help information <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    ./app/x86_64-native-linuxapp-gcc/pktgen -l 1-3 -n 1 -- -P -m "[2].0,[3].1"

    start 0,1 stop 0,1 quit

    ################################################################################ # Test PMD ################################################################################ 

    su sudo modprobe vfio sudo modprobe vfio-pci chmod a+x /dev/vfio chmod 0666 /dev/vfio/*

    modprobe uio_pci_generic

    dpdk-devbind --status sudo ifconfig enp1s0f0 down sudo ifconfig enp1s0f1 down sudo ifconfig enp1s0f2 down sudo ifconfig enp1s0f3 down

    sudo dpdk-devbind --bind=vfio-pci enp1s0f0 sudo dpdk-devbind --bind=vfio-pci enp1s0f1 sudo dpdk-devbind --bind=vfio-pci enp1s0f2 sudo dpdk-devbind --bind=vfio-pci enp1s0f3

    dpdk-devbind --status

    # 进入交互模式 # 测试的前提是port0和port1是联通的 testpmd -l 1,2,3 --socket-mem 1024 -n 4 --log-level=8 -- -i >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> set nbcore 2 show config fwd #set fwd txonly show port stats all start show port stats all stop quit <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    Processed: 0.009, SQL: 8