WORK IN PROGRESS
P4 is a programming language to define the behavior of the data plane, it can be used to program targets such as software switches, reconfigurable ASICs or FPGA-based NICs, or it can be used to formally specify the beahviour of a fixed-function switch. P4 Runtime is a protocol to control at runtime the behavior of a P4-enabled data plane device. This page presents the support for P4 and P4 Runtime in ONOS, moreover we provide steps to set up an environment to try ONOS with the Behavioral Model v2 (BMv2) (the reference P4 software switch). Support for P4 Runtime has been included in ONOS starting from the 1.11 (Loon) release.
This document assumes you are already familiar with ONOS, P4, P4 Runtime and BMv2. In other words, we assume you already know how to build and run ONOS, write a P4 program, build and run BMv2 with P4 Runtime support. If this is not the case, here's a list of pointers to get started:
- What's ONOS?
- ONOS Administrator Guide
- ONOS Developer Guide
- P4 white paper
- P4 language specification
- BMv2 slides at 2016 P4 workshop
- P4Runtime resources
Table of Contents
Features at a Glance
By using ONOS, you'll be able to program and control a network of comprising P4Runtime-enabled devices with all the benefits of a logically centralized SDN platform. The following features are currently supported:
P4 pipeline provisioning (ad device connection)
- Match-action table operations (via existing ONOS APIs such as FlowRule, FlowObjective, or Intent)
- Action profile group operations (via Group ONOS API)
Packet-ins and packet-outs
To have a working simulator to use with the p4Runtime integration in ONOS you have two options:
- download a prebuilt image of the machine
- build your own machine
Download Pre-Built VM
Please download the VM provided here (mininet-p4.ova) and import it into VirtualBox by double clicking on the mininet-p4.ova file. The file is 3.55 gb so it might take some time to download depending on the speed of your network.
The current machine hw spec is:
- 8 GB of RAM
- 4 cores
You can downsize the requirements on both cores and RAM to a minimum of
- 4 GB of RAM
- 2 cores
The machine username and password are:
pre-built VM username and password
Build Your own VM
The following steps will help you set up a development environment with Mininet, ONOS and BMv2 with P4Runtime support.
Before starting you need to download and set up a virtual machine with Mininet. The following instructions have been tested on the official Mininet 2.2.2 VM 64 Bit (Ubuntu 14.04), which you can find here.
Recommended minimum system requirements
In order to successfully build and execute the required tools, we recommend the following minimum system configuration:
- 4 GB of RAM
- 2 cores
- 8 GB free hard drive space (~4GB required to build P4 tools)
This walkthrough demonstrates the necessary steps and commands to run a network of BMv2 devices in Mininet, controlled by ONOS using P4Runtime.
Clone ONOS repository. On your Mininet VM shell, type:
cd ~ git clone https://github.com/opennetworkinglab/onos.git
Source ONOS's bash_profile. On your Mininet VM shell, type:
echo "source ~/onos/tools/dev/bash_profile" > ~/.bashrc source ~/.bashrc
Important: replace .bashrc with your shell configuration profile (.bash_aliases, .profile, etc.)
Build and install P4 tools. We have prepared a special command to install everything in one shot! On your Mininet VM shell, simply type:
This command will download, build and install BMv2 (with the simple_switch_grpc target), P4Runtime libraries, the P4 compiler p4c, the old BMv2 compiler p4c-bmv2, and all required dependencies (including protobuf and gRPC). This command takes approx. 20 minutes to complete with the minimum system configuration described before.
if you run out of space on you mininet machine you can go inside the p4tools folder in the home directory:
then go in one of the local directories, e.g. p4rutnime
and clean the make artifacts with
Build the example P4 programs. On your Mininet VM shell, type:
cd ~/onos/tools/test/p4src/p4-16/ make all
Update P4Tools to latest version
It might be needed to update the P4Tools to the latest version. Please run these commands one at a time in the same terminal window inside you machine. This process is the same for both the pre-built VM and any machine built from scratch.
cd ~/onos/ git pull cd ~ onos-setup-p4-dev
Run the Developer Environment
Start Mininet, using BMv2 simple_switch_grpc target.
Go in the home directory:
On your Mininet VM shell, type:
sudo -E mn --custom $BMV2_MN_PY --switch onosbmv2 --controller remote,ip=192.168.56.1
Be sure to use the correct IP address of your ONOS instance.