Setting up Virtual Machines for DPDK

Muhammad Bilal
Emumba
Published in
10 min readJul 28, 2020

--

Virtual Machine is a solution designed to provide all of the functionality of a physical computer in a totally software-based (virtual) environment.

Virtual machines have a lot of advantages including:

  • Multiple operating system environments can exist simultaneously on the same machine, isolated from each other;
  • VM can offer an instruction set architecture that differs from host machine;

There are a lot of reasons why someone might want to use Intel DPDK. Generally, it enables us to build applications, that we can use to process packets faster! This is done by enabling packets to follow ‘fastpath’(Kernel Bypass) instead of normal route of Network layers and Context switching. For more details, visit dpdk website.

There are many network interface cards which are supported by DPDK, and most of them are quite expensive. So its quite useful to have a option to develop and run DPDK applications without any physical constrains. Running DPDK in virtual machines allow anyone to play with it and to overcome any physical constrains.

In this article we are going to see, how to install Ubuntu 20.04 LTS on Virtual box and setup it for DPDK. After that we will setup the internal network connection on virtual machines by configuring the DHCP server on host machine. In last we are going to see the connectivity of internal connection between two VM’s.

Installing Ubuntu 20.04 LTS on Virtual Box

1. Download Oracle VirtualBox from the official website or you can download it using your Ubuntu app store.

2. Download the latest Ubuntu Image file from its official website.

3. Open Oracle Virtual Box and click on “New” at the top bar.

4. Enter the Name for your VM. Then select Type as Linux and Version as Ubuntu (64-bit). Then click “Next”.

5. Allocate RAM as per your usage. (2GB is the recommended RAM for running DPDK). Then click “Next”.

6. Select “Create a virtual hard disk now” if you are installing Ubuntu on Virtual Box for the first time. Then click “Next”. Also you can use the existing virtual hard disk file of your previous VM’s (if you have created VM’s previously).

7. Select “VDI (Virtual Box Disk Image)” as the type for your Virtual Hard Disk file. Then click “Next”.

8. Select “Dynamically Allocated” as you may not want to keep restriction on the virtual hard disk file size (A dynamically allocated hard disk file will only use space on your physical hard disk as it fills up). Then click “Next”.

9. Enter the name(If you want to have other then default) and Size for the Virtual Hard Disk file. (30GB is the recommended RAM for running DPDK). Then click “Create”.

10. Your VM will now be created with the above configuration. (Visible on the left panel of Virtual Box).

11. Select the VM and click on “Start”.

12. Now click on the browse icon, as pointed by the cursor below.

13. Now click on the “Add” icon, as pointed by the cursor below.

14. Go to the path of your Ubuntu .iso image(Which you download in step 2) and select it. Then click on “Open”.

15. Next, select the your Ubuntu .iso image and click on “Choose”

16. Now, click on the “Start”.

17. Ubuntu 20.04 will boot up and ask for Installation details. Select your language and click on Install Ubuntu”.

18. Now select your keyboard layout. i.e. English (US)”. Then click on “Continue”.

19. You can select Minimal Installation If you only require basic utilities and also uncheck the other options(if you don’t want to update now, to save time). Then click on “Continue”.

20. Here you should select the 1st option Erase disk and install Ubuntu As you just created the new Ubuntu VM. Then click on “Install Now”.

21. Click on “Continue”, if asked for “Write the changes to disk?”

22. Then select your location for the time zone.

23. Now it’s time to choose the name, username and password. Click on “Continue”.

24. Wait for installation to be completed. It may take some time.

25. Then click on “Restart Now”. In order to use the newly installed Ubuntu 20.04

26. Now click on Devices→Optical Drives, then check the Ubuntu.iso file by selecting it and then click the “Remove disk from virtual drive”, as pointed below by cursor. ( Sometime this is removed automatically on VM’s restart)

27. Next, click on “Force Unmount” and then press Enter. If login window still does not appear, just restart the Machine.

28. Enter your password to login into the Ubuntu 20.04

Cloning Virtual Machines

We need two VM’s for running and testing DPDK application. To create a second VM with the same operating system and specifications, we can clone the previously created VM, by doing following steps.

1. Shutdown/Power Off the 1st VM, created previously. First click on cross, on right top, and then click on “OK” after selecting “Power off the machine”.

2. Now go to the Virtual Box and After right clicking on your VM(on the left panel), select clone.

3. After Entering Name, click on Next.

4. Make sure, Full clone is selected and then click on Clone.

5. Cloning may take some time.

6. After cloning is completed, new VM will be created with same specifications and credentials(Password will be same, as of your previous VM)

Using Internet in Virtual Machines

By default Virtual Machine is connected to your host system’s internet. If facing some issues, go through the following steps.

  • Turn OFF your virtual Machine.
  • Right click on VM and Select Settings.
  • Now click on the Network tab from the left panel.
  • Then make sure NAT is selected(in Attached to:) and then click on Advanced and make sure cable connected is enabled.
  • Now start your machine, Your Internet will be working in VM.

Network Address Translation (NAT) is the default mode for new vm’s and works great in most situations when the guest is used as a “client” type. Guest VM’s sit on their own private LAN, VirtualBox acts as a DHCP Server and VirtualBox NAT engine translates addresses. Destination servers can see the traffic originating from VirtualBox host, no configuration needed on host or guest and it works great when guests are clients. It can’t be used for cases where guest VM’s act as servers.

Also we can’t communicate between two guest virtual machines using NAT connection. Configuration looks like this:

Reference: oracle.com

Internal Network between Virtual Machines

When you configure one or more VM’s to sit on an Internal network, VirtualBox ensures that all traffic on that network stays within the host and is only visible to VM’s on that virtual network. Configuration looks like this:

Reference: oracle.com

The internal network is a totally isolated network and so is very “quiet”. This is good for testing when you need a separate, clean network environment. Note that Host is not a member of the internal network and this mode allows vm’s to communicate with each other even when the Host is disconnected.

In this mode, VirtualBox does not provide support for the DHCP server. We can run DHCP server on our host system. Multiple internal networks are possible and you can configure VM’s to have multiple NICs to sit across internal and other network modes and thereby provide routes if needed.

In an internal network guests can see other guests on the same internal network, but host system cannot see this network. Manual network configuration of DHCP server is needed to configure this network.

This internal setting is very useful for running and testing the DPDK applications. Specially we will use internal network for forwarding packets between two virtual machines, using DPDK l2fwd application , as shown in figure below.

Reference: dpdk.org

DHCP server

Here we are going to create 2 internal network namely intnet1 and intnet2, between two VM’s. The two internal networks will be used to receive and forward the packets, separately. For this, you need to run the following commands in your host terminal.

vboxmanage dhcpserver add — netname intnet1 — ip 10.10.10.1 — netmask 255.255.255.0 — lowerip 10.10.10.2 — upperip 10.10.10.212 — enable

netname intnet1: The internal network will be named intnet1.

ip 10.10.0.1: The IP address of your DHCP server inside the internal network.

netmask 255.255.255.0: The subnet mask.

lowerip 10.10.10.2: The lower bound of the IP addresses that can be assigned to network members.

upperip 10.10.10.212: The upper bound of the IP addresses that can be assigned to network members.

enable: Enable the DHCP server.

Similarly you can create the other internal network with similar command. You need to change the network IP address. Here is the example of creating a 2nd internal network, intnet2.

vboxmanage dhcpserver add — netname intnet2 — ip 10.10.11.1 — netmask 255.255.255.0 — lowerip 10.10.11.2 — upperip 10.10.11.212 — enable

After that open the setting of VM, by right clicking on it, then go to Network setting(from left panel). After that click on Adapter 2 and select the Internal Network(in Attached to:), then choose the network name as intnet1. if there’s no intnet1 just manually type intnet1.

Similarly, to add 2nd Internal Network click on Adapter 3 tab and follow the same procedure for intnet2.

Testing connection between two VM’s

Now we will open the both VM’s and will check the connectivity between them using ping command.

First we need to check the network interface IP and for that we need to install ifconfig using following command

sudo apt install net-tools

Now if you run ifconfig command you will get the following output.

Here the enp0s8 interface of both machines are on intnet1 and can ping each other.

Similarly the enp0s9 interface of both machines are on intnet2 and can ping each other.

Now by using ping command check that both machines are connected.

Increasing Core in VM’s

Some DPDK applications need more than 1 core to run. So you need to allocate 2 cores to the VM by doing the following steps.

  • Turn OFF your virtual Machine.
  • Right click on VM and Select Settings.
  • Now click on the System tab from the left panel and then go to Processor tab.
  • After that, enter 2(or more if your system has more cores) in the box in front of processors as shown in figure below.

In next part, we will download and compile DPDK(using make and meson). Also we will be running the testpmd and l2fwd sample applications of DPDK, for forwarding packets between two separate virtual machines. Here is the Link(coming soon) for second part of article.

--

--