"DPDK" uses LIBPCAP-PMD to drive a delivery package

Source: Internet
Author: User

REF:DPDK Programmer ' s Guide

1. Overview

The DPDK not only provides a PMD drive for physical and virtual network cards (Poll Mode Drivers), but also provides two pure software PMD drives, Libpcap PMD is one of them. Libpcap PMD uses the Libpcap library to read and write messages, read and write the source can be a file, or the use of a Linux kernel-driven physical network card.

Using Libpcap PMD on a machine with no or no convenient configuration of the physical NIC can help DPDK application developers with functional testing or code debugging, and more importantly, EAL (Environment Abstart Layer) The DPDK application is transparent to its underlying use of real Nic PMD, or Libpcap PMD, and developers can use the convenience of Libpcap PMD without modifying the code.

2. Compilation and Configuration 2.1 compilation

DPDK Libpcap PMD Support is not open in the default configuration file. If you are compiling under Linux, you need to modify the <dpdk>/config/common_linuxapp.

Config_rte_librte_pmd_af_packet=n

Switch

config_rte_librte_pmd_af_packet=y .

Also, you need to install the LIBPCAP Development Kit, and the commands installed on Ubuntu are

sudo apt-get install Libpcap-dev

Then recompile the DPDK.

2.2 Use

All DPDK applications run on the EAL, and EAL provides the-VDEV option, which may be used to specify the use of Libpcap PMD. The format is as follows:

App-c f-n 4--vdev= ' eth_pcap0,stream_opt0=..,stream_opt1= ... '

--vdev= ' eth_pcap1,stream_opt0=. '

You can configure multiple pseudo-devices (pseudo-ethernet device), each with a name that starts with Eth_pcap and followed by numbers or letters. Each device can be configured with multiple streaming options (stream options), which are separated by commas and cannot have whitespace.

2.2.1 Streaming options

Flow options include:

    • rx_pcap sets a pcap file as the Rx stream with the parameter Pcap file path. The Libpcap PMD driver reads each packet in the file as if it were read from the actual network port. This pcap file must be present and valid. such as Rx_pcap=/home/dev/test.pcap
    • Tx_pcap To set a Pcap file as a TX stream. This file will be created and rewritten automatically.
    • The rx_iface sets a physical network port that is powered by the Linux kernel as the Rx stream. such as Rx_iface=eth0
    • tx_iface sets a physical network port that is driven by a Linux kernel to a TX stream.
    • Iface Maps A physical network port, the Libpcap PMD driver will read and write messages from this port. such as Iface=eth0

As can be seen from the above, Libpcap PMD not only supports the ability to simulate pcap files as RX/TX, but also supports common Linux-powered NICs. In use we can combine at will, for example Rx is set to Eth0, TX is set to Tx.pcap, or both are eth0 or pcap files.

2.2.2 Command Example

TESTPMD:

./TESTPMD- C 3-n 4--vdev= ' eth_pcap0,rx_pcap=/home/zzq/tcp.pcap,tx_pcap=/home/zzq/tx0.pcap '--vdev= ' Eth_pcap1, Rx_pcap=/home/zzq/tcp.pcap,tx_pcap=/home/zzq/tx1.pcap '----port-topology=chained--no-flush-rx-i--nb-ports=2

According to previous official documents, TESTPMD will receive 512 messages from each RX port and discard them before starting the message forwarding, while using Libpcap PMD, this feature can be disabled through the-NO-FLUSH-RX option. In addition, as far as I try,--nb-ports=2 will set the port number to 2, or there will be a number of ports between the impact, not conducive to testing.

After running, the ETH_PCAP1 TX corresponding file will save the message in the Eth_pcap0 Rx counterpart file, and the eth_pcap0 TX corresponding file will save the message in the ETH_PCAP1 Rx counterpart file. The RX corresponding file will only read one round.

L2FWD:

./L2FWD- C 3-n 4--vdev= ' eth_pcap0,rx_pcap=/home/zzq/tcp.pcap,tx_pcap=/home/zzq/tx0.pcap '--vdev= ' eth_pcap1,rx_ Pcap=/home/zzq/tcp.pcap,tx_pcap=/home/zzq/tx1.pcap '---P 3

"DPDK" uses LIBPCAP-PMD to drive a delivery package

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.