An introduction to Telemetry in DPDK

Introduction

In this article, I have explained about a basic DPDK application which reads the packets from NIC interface. In this article we will learn about telemetry in DPDK library. If you are passionate about fast packet processing using DPDK then this article is for you.

Telemetry in DPDK applications

Telemetry means fetching different types of statistics and sending them to a monitoring client. In DPDK applications, we have a lot of different kinds of statistics available. Some of the example statistics are: Number of received packets, Number of transmitted packets, Number of missed packets, Total number of NICs detected, Total number of receive and transmit queues etc. We can also generate user customized statistics based on the user requirements.

DPDK library has a built in telemetry module. When the DPDK applications starts, the telemetry module is also initialized. The telemetry module in DPDK library works as a client-server model i.e. a telemetry server is initialized in the DPDK application and telemetry client is provided by the DPDK library which connects to the telemetry server to send the telemetry commands and receive the replies from the server. Below image shows the telemetry module in DPDK library.

The telemetry client (dpdk-telemetry.py) is present in the usertools folder of the DPDK library home folder. The telemetry client connects to the server over a socket of type AF_UNIX. The AF_UNIX (also known as AF_LOCAL) socket family is used to communicate between processes on the same machine. The telemetry client is a sperate process which connects with our DPDK application which is another process.

The DPDK application upon starting, initializes the telemetry module and performs the following steps:

  1. Creates a socket of type AF_UNIX.

  2. Creates a thread which starts listening on the socket for any incoming connections. The name of this thread is set as "dpdk-telemet-v2".

  3. When a telemetry client tries to connect, the listening thread in the server receives the request and spawns a new thread against this client. The new thread will now serve the connected telemetry client.

  4. DPDK telemetry module allows up to 10 telemetry clients to connect with the DPDK application. For each client, it spawns a dedicated thread to serve the requests coming from the particular client.

  5. The serving thread receives the requests from their respective telemetry client, performs the requested action and sends the reply back to the client.

The telemetry client (dpdk-telemetry.py) when starts, performs the following steps:

  1. Detects the running DPDK application and tries to connect with it. It will show an error if there are no DPDK applications running.

  2. Once successfully connected, it will prompt the user to enter the desired telemetry command to be sent to the DPDK application.

Writing DPDK application

Finally, we can write our DPDK application in C++ to demonstrate the concept of telemetry in DPDK. The written DPDK application is present at: github.com/awaiskhalidawan/dpdk-tutorials

Below are the steps to build and run the application:

git clone https://github.com/awaiskhalidawan/dpdk-tutorials.git
cd dpdk-tutorials/
mkdir build
cd build
cmake ..
make

The application binaries will be generated in dpdk-tutorials/bin folder after the successful execution of above steps.

To run the DPDK application:

cd dpdk-tutorials/bin
sudo ./telemetry-in-dpdk --lcores=0 -n 4 --

To run the telemetry client:

cd dpdk-23.11/usertools/
sudo ./dpdk-telemetry.py

Once the client is successfully connected, it will prompt you to enter the command. Run the following command:

/dpdk_app/packet_info

/dpdk_app/packet_info telemetry command is defined in our DPDK application. There is an extensive explanations of application code showing how to register a telemetry command. Don't forget to go through the code while you run the DPDK application.

There are other default telemetry commands available as well. For example: /ethdev/stats,0 will show you the statistics of NIC 0 in the system. To see the list of all available commands enter the command "/".

Note: A DPDK application must be run with sudo for now as DPDK abstraction layer requires sudo privileges. I will write a detailed article later on about how to run DPDK applications without sudo privileges.

Summary

In this article, we have implemented a DPDK application which shows the concept of telemetry in DPDK library. The application registers a custom telemetry command which will be sent from the telemetry client. The article also explains about the telemetry client (dpdk-telemetry.py) in DPDK library.

Feel free to write me in the comments if you are unable to perform the steps successfully, mentioned in this article.