Search code examples
clinuxnetwork-programminglinux-kerneldpdk

Pktgen setting up environment and running not working as header files are missing


I'm trying to setup Pktgen according to the Getting started with Pktgen guide in my VirtualBox which is running Ubuntu 22.04.1, Pktgen 22.04.01 and DPDK 22.11.1. But for some reason I don't understand, the command in the guide - ./app/pktgen -l 0-4 -n 3 -- -P -m "[1:3].0, [2:4].1 (which is suppose to start pktgen), does not work for me as I have nothing called pktgen in the app folder. And when I try to run gcc -o pktgen pktgen.c I get several errors as header files cannot be found, for example there is no directory or file for pg_delay.h.

To give some further clarification I will describe what I have done so far so if there is something glaringly wrong, it will perhaps be easier to point out.

First of I have hugepages support added.

The instructions says to run ./run.py -s default to setup the environment. So, I have setup so that I have one network device using a DPDK-compatible driver:

dpdk-compatible

Then I have configured the default.cfg to run with my device and driver:

default.cfg

Then I run ./tools/run.py -s default and get this output.

/tools/run.py -s default 
>>> sdk 'None', target 'None' 
<module 'cfg' from 'cfg/default.cfg'> 
Setup DPDK to run 'pktgen' application from cfg/default.cfg file 

Not sure if this is how it is suppose to look after your run it, as it does not seem to confirm that it worked.

I then add the environment variables:

export RTE_SDK=home/.../mypathtodpdk
export RTE_TARGET=x86_64-native-linux-gcc

Finally I run sudo -E ./app/pktgen -l 0-4 -n 3 -- -P -m "[1:3].0, [2:4].1", but then run into the error as described above, that is that there are header files missing and pktgen does not exist in the app folder.


Solution

  • Look under the build directory. There will be another 'app' folder inside there. In future cases like this, you can use the find command to find the pktgen executable, e.g. find -name "pktgen" I think you can also install pktgen and then use it from anywhere (without ./app preceding it). In fact, this config file appears to list pktgen as being in either /usr/local/bin or ./usr/local/bin. You can either change that to match where it is or install it.

    A couple other things to note:

    • it looks like you should be using "vfio-pci" in your default.cfg, since that is what is listed in your dpdk-devbind.py -s output.
    • In the 'map' section, those core listings that end in .0, .1, .2, etc. are assigning cores those cores to those devices. Since you only have one device listed under 'devices', only the ones mapped from .0 will apply, so you could delete the others from 'map' and 'cores' if you run into trouble. The other core listings may be very high, unless you 32 cores in your VM.