Setting up DPDK’s Pktgen packet generator on Ubuntu 15.10

Following on from the earlier post, it seemed like a good idea to get DPDK’s Pktgen program running to work with the l2fwd example that was previously built. More details after the jump…

First off, download the Pktgen source from here. I used the 2.9.18 version (I could not get the later versions to compile). Expand the file to somewhere convenient.

Assuming that DPDK has been compiled successfully, only a couple more dependencies need to be satisfied:

sudo apt-get install libpcap-dev liblua5.3-dev
sudo ldconfig

Then, to compile:

export RTE_SDK=<dpdkdir>
export RTE_TARGET=x86_64-native-linuxapp-gcc
cd <pktgendir>
make -j8

As usual, the “-j8” bit should be adjusted to reflect the number of cores to be used for the compilation. At this point, everything is ready to run the program:

cd <pktgendir>
sudo -E app/app/x86_64-native-linuxapp-gcc/pktgen -c 0x1f -n 3 -- -P -m "[1:3].0, [2:4].1"

Note that the working directory has to be <pktgendir> as it needs to have the required .lua files. The string following the -m map cores to interface ports. In this case, core 1 handles port 0 receive, core 3 handles port 0 transmit, core 2 handles port 1 receive and core 3 handles port 1 transmit. It’s important to note that these are logical core numbers – hyperthreaded physical cores count as two logical cores. After some experimentation with an i7-5820K, best performance seemed to be obtained when each physical core is only used once. However, I am sure there are a lot of variables that affect this.

It’s a good idea to set the terminal window to 132 x 43 so that the displays work properly. I had l2fwd running at the other end of the cable connected to port 0 so I just started generating packets by entering:

start 0

at the Pktgen prompt. The l2fwd display on the other machine displayed the packets being received. It’s pretty easy to modify packet size and other parameters – just enter help at the Pktgen prompt for instructions.

Alternatively, just run Pktgen on both machines and fire packets in both directions.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s