Note: The version of DPDK is 21.11 LTS
In order to be able to simulate the environment of multiple different machines, we need to create two different virtual machines using the Virtual Machine tool. We will set up N+1 NICs on the first virtual machine (Machine No.1) to simulate N different endpoint machines and N+1 NICs on the second virtual machine (Machine No.2) to simulate an N port L3 router. The extra port is used to interact with the test program.
For each NIC of the N NICs on Machine No.1 and the network port on Machine No.2, you need to create N virtual networks, each containing one NIC on Machine No.1 and one NIC on Machine No.2.
For the NIC used to emulate N machines on Machine No.1, its IP would be set in the 10.1.1.0/24 IP domain by test program automatically. (You should not use any address from this region and N should not exceed 255) Set the IP of the NIC used to test program interactions to 10.1.0.1. On Machine No.2, set the IP of the NIC used to test program interactions to 10.1.0.2.
The N NICs on Machine No.1 and N NICs on Machine No.2 should be set to use for DPDK
You should implement your code in yourcode.cpp
or yourcode.c
.
We support both C and C++.
We will use yourcode.cpp
as defualt option, if you want to use C, you should just create a yourcode.c
and delete the file named yourcode.cpp
In this section we will tell you how to compile your code and the test program.
This step may consume time.
Because we will get gtest framework from Github
automatically.
git clone git@github.com:N2-Sys/Lab-DPDK-l3-forward.git
cd Lab-DPDK-l3-forward
mkdir build
cd build
cmake .. -G "Unix Makefiles" -DCONTROLLER=YES
make
git clone git@github.com:N2-Sys/Lab-DPDK-l3-forward.git
cd Lab-DPDK-l3-forward
mkdir build
cd build
cmake .. -G "Unix Makefiles" -DUSER=YES
make
In order to run the test, you need to start a process on each of the two machines. Note that the processes start in a strict order of precedence.
First you need to start the test program on Machine No.1.
cd build
./test testcase
Then start the router program on Machine No.2 to execute your code.
cd build
./client <PARAMETERS TO DPDK>
The results and error messages will be displayed in the terminal on Machine No.1. If the error is caused by your code causing the program to crash, then we will not be able to detect the cause of the error and you will need to check it yourself on Machine No.2.
You just need to connect the connected N peer ports of Machine No.2 to different virtual machines instead of Machine No.1. And then start the router process on Machine No.2.
Execute the following command on Machine No.1 to start the interactive mode of the controller. In this mode, the test program will only assume the existence of a network port used to interact with the router.
cd build
./test interactive
The following command is available:
add_rule
:add_rule 10.0.0.0 24 1
addsforward 10.0.0.0/24 to port 1
to route tabledel_rule
:del_rule 10.0.0.0 24
deletes entry in route table that matchesforward 10.0.0.0/24 to port *
After adding the correct route entries, you can test the connectivity by pinging or by running iperf on different machines and other tools.
Enjoy our lab