Programmable Data Plane Tools – Setup

This post documents the necessary steps to install some important tools related to programmable data plane research concerning the P4 language. Additionally, some common errors and their solutions are also recorded for future references.

Tested on server (PowerEdge R730) with the following specs –

  • OS – Ubuntu 18.04.6 LTS x86_64
  • Kernel – 4.15.0-208-generic
  • CPU – Intel Xeon E5-2640 v4 (40) @ 3.400GHz
  • RAM – 64GB

Note – Installing most of the tools using docker is preferred as they have lot of dependencies ranging from linux libraries to third-party packages.

P4C – The P4 Compiler

In my experience installing the p4c compiler with the official docker container [LINK] is the best and most efficient method.

Compiler tested – P4c Compiler - p4c (SHA:  BUILD: RELEASE)

  • Docker Hub link to the container – [LINK]
  • $ docker pull p4lang/p4c
  • $ docker run -v HOST_DIR:/p4c/ -it p4lang/p4c – Mount HOST_DIR as a shared volume from the host OS containing the P4 source code files for compilation. This command would insert you as the root user inside the container.
  • $ p4c --target bmv2 --arch v1model --std p4-16 main.p4 --output . – Compile a P4 program (main.p4) for the bmv2 model targeting the v1model architecture and output the files in the current directory.
  • $ p4c-graphs --target bmv2 --arch v1model --std p4-16 main.p4 --toJSON main.json --fullGraph --jsonOut – This command generates graphs in dot and json (with --jsonOut flag) formats for further analysis. --fullGraph instructs the compiler to generate the graphs for all the control block together.
  • $ p4c --help – Great place to explore all the available options.

BMV2 – Behavioral model – Software Switch

ONOS – Controller