DPDK Pktgen和Testpmd验证试验

Ref: Version: DPDK 19.08 / Pktgen 3.7.2

+--------+---------------+               +-------------------+---------------+
|        | socket file 1 |   <------->   | vhost-user port 1 |               |
|        +---------------+               +-------------------+     Docker    |
| host   |     pktgen    |               |      testpmd      |   container   |
|        +---------------+               +-------------------+               |
|        | socket file 0 |   <------->   | vhost-user port 0 |               |
+--------+---------------+               +-------------------+---------------+

Compile DPDK and Pktgen

DPDK

export RTE_SDK=~/dpdk/dpdk-19.08
export RTE_TARGET=x86_64-native-linuxapp-gcc
sed -ri  's,(CONFIG_RTE_LIBRTE_VHOST).*,\1y' config/common_base
make config T=$RTE_TARGET
sed -ri 's,(PMD_PCAP).*,\1y' build/.config
make

Pktgen

export RTE_SDK=~/dpdk/dpdk-19.08
export RTE_TARGET=build
make

Build a Docker image

Create a dockerfile in the directory contains DPDK_SDK.

FROM ubuntu:16.04
WORKDIR /root/dpdk
COPY dpdk-19.08 /root/dpdk/.
ENV PATH "$PATH:/root/dpdk/$RTE_TARGET/app/"
RUN sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list && \
    apt update && apt install -y libnuma-dev libpcap-dev
ENTRYPOINT ["/bin/bash"]

Allocate HugePage

Modify /etc/default/grub.

GRUB_CMDLINE_LINUX_DEFAULT="default_hugepagesz=1GB hugepagesz=1G hugepages=8"

Update the grub file and reboot to take effect.

sudo update-grub
reboot
mkdir -p /dev/hugepages
sudo mount -t hugetlbfs none /dev/hugepages

Run the Testpmd container

sudo docker run -ti --rm --name=test \
-v /dev/hugepages:/dev/hugepages \
-v /tmp/virtio/:/tmp/virtio/ \
--privileged dpdk

Type the commands below inside the container shell

testpmd -l 0-1 -n 1 --socket-mem 1024,1024 \
--vdev 'eth_vhost0,iface=/tmp/virtio/sock0' --vdev 'eth_vhost1,iface=/tmp/virtio/sock1' \
--file-prefix=test --no-pci \
-- -i --forward-mode=io --auto-start

Some usefule runtime functions

show port stats all

Generate the packets

sudo pktgen -l 2,3,4 -n 2 --vdev=virtio_user0,path=/tmp/virtio/sock0 --vdev=virtio_user1,path=/tmp/virtio/sock1 -- -P -m "3.0,4.1"

Some useful runtime functions

set all rate 10 # set the sending rate at 10%
set 0 count 100 # request the channel 0 to send 100 packets in total
str # start

发表评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注