Networking example with DPDK

Deploy

1. Create the AMI with Packer

  1. export AWS_ACCESS_KEY_ID=<your access key id> and export AWS_SECRET_ACCESS_KEY=<your access key> in your shell.
  2. packer init . only necessary once, but it also doesn't hurt to execute it again.
  3. packer build . to actually create the AMI.

2. Create the EC2 and ENI instances with Terraform

  1. export AWS_ACCESS_KEY_ID=<your access key id> and export AWS_SECRET_ACCESS_KEY=<your access key> in your shell.
  2. terraform init only necessary once, but it also doesn't hurt to execute it again.
  3. terraform apply builds the infrastructure described int the configuration files.
  4. terraform destroy destroys the infrastructure that was created with terraform apply.

For more information, please consult the great tutorials for Packer and Terraform (both are specifically for AWS) and consult the documentation for Packer and Terraform.

Connect to AWS and copy files

terraform already copies the src directory to the instances.

It is planned that the code is built on the EC2 instances by terraform soon.

In order to connect to the AWS instances, you can use utils/awsconnect tx or utils/awsconnect tx, instead of manually copying the URL from the terraform output.

Similarly, you can use utils/awscp tx and utils/awscp tx to copy the src directory to the instances if you made any changes to it.

Build

  1. meson setup build
  2. ninja -C build

Run

Execute sudo ./build/rx. This will print the MAC address of rx, which you can then use in sudo ./build/tx -- <tx IP address> <rx IP address> <rx MAC address>.

MAC address

Sending Ethernet frames requires the MAC address of the sender and the recipient. It could be acquired

Code Explanation

rte_cpu_to_be_16(x) is a macro that changes the byte order of x.

End-of-options marker --

DPDK uses everything before the -- as options for the initialization of the EAL and everything after the -- for the DPDK application. The Keep Alive sample application for example uses ./<build_dir>/examples/dpdk-l2fwd-keepalive [EAL options] -- -p PORTMASK [-q NQ] [-K PERIOD] [-T PERIOD]. The initialization function rte_eal_init(argc,argv) is passed the command line parameter array, parses it and returns how many of them it parsed before encountering --. Then argv is incremented by this amount and parsed by l2fd_parse_args.

This is similar to the convention for unix command line tools, where -- often (but not to always) acts as end-of-options marker. Options are passed with a flag. An example could be touch -r <other-file> <new-file>, that uses the option -r <other-file> to use the creation time of other-file as creation time for new-file. Everything that follows after the -- is treated as positional argument, i.e. arguments identified by their position. In cp <src> <dst>, src is the source and dst the destination, based on their position. With touch -- -r, a file can be created that has the name -r, which would not be possible without --. With rm -- -r, it can be deleted again.

Ethernet Frames

To understand DPDK, we start with a simple example which sends packets from one host to another via DPDK. The received Ethernet frames are explained in more detail here.