P4+ONOS SRv6 Tutorial

Welcome to the P4+ONOS SRv6 tutorial! The goal of this tutorial is to teach you how to use ONOS as the control plane of a network of P4-capable devices, controlled using P4Runtime. The tutorial is organized around a sequence of hands-on exercises that show how to build a leaf-spine data center fabric based on a simplified version of Segment Routing over IPv6 (SRv6). Exercises will include activities such as:

Slides

Tutorial slides are available online. These slides provide an introduction to each exercise as well as the software tools used. We suggest you look at it before starting to work on the exercises.

P4 Cheat Sheet

A P4 language cheat sheet is also available online. It contains various P4 code examples that you can refer to.

Tutorial VM

To complete the exercises, you will need to download and run this tutorial VM (5.3 GB):

To run the VM you can use any modern x86 virtualization system. The VM has been tested with VirtualBox v6.0.6. To download VirtualBox and import the VM use the following links:

Recommended system requirements

The VM is configured with 4 GB of RAM and 4 CPU cores, while the disk has size of approx. 8 GB. These are the recommended minimum requirements to be able to run Ubuntu along with a Mininet network of 1-10 BMv2 devices controlled by 1 ONOS instance. For a flawless experience, we recommend running the VM on a host system that has at least the double of resources.

VM user credentials

Use the following credentials to log in the Ubuntu system:

Get this tutorial repo

To work on the exercises you will need to clone this repo inside the VM:

cd ~
git clone https://github.com/opennetworkinglab/onos-p4-tutorial tutorial

If the tutorial directory is already present, make sure to update its content:

cd ~/tutorial
git pull origin master

Generate SSH keys

ONOS uses SSH key-based authentication to access its command line interface (CLI). Before starting ONOS, generate public/private rsa key pair using the following command inside the VM:

ssh-keygen -t rsa -f ~/.ssh/id_rsa -P '' -q

Upgrade ONOS to the latest version used in the tutorial

The VM may have shipped with an older version of ONOS than we would like to use for the exercises. You can upgrade to the latest version used for the tutorial using the following command:

make onos-upgrade

Using an IDE to work on the exercises

During the exercises you will need to write code in multiple languages such as P4, Python and Java. While the exercises do not prescribe the use of any specific IDE or code editor, the tutorial VM comes with Java IDE IntelliJ IDEA Community Edition, already pre-loaded with plugins for P4 syntax highlighting and Python development. We suggest using IntelliJ IDEA especially when working on the ONOS app, as it provides code completion for all ONOS APIs.

Repo structure

This repo is structured as follows:

Tutorial commands

To facilitate working on the exercises, we provide a set of make-based commands to control the different aspects of the tutorial. Commands will be introduced in the exercises, here's a quick reference:

Make command Description
make p4 Builds the P4 program
make onos-run Runs ONOS on the current terminal window
make onos-cli Access the ONOS command line interface (CLI)
make app-build Builds the tutorial app and pipeconf
make app-reload Load the app in ONOS
make topo Starts the Mininet topology
make netcfg Pushes netcfg.json file (network config) to ONOS
make reset Resets the tutorial environment
make onos-upgrade Upgrades the ONOS version

Exercises

Click on the exercise name to see the instructions:

  1. Software tools basics and packet I/O
  2. L2 bridging
  3. IPv6 routing
  4. Segment Routing v6

Solutions

You can find solutions for each exercise in the solution directory. Feel free to compare your implementation to the reference one whenever you feel stuck. To use the solution code that is provided, simply use the same make commands in the solution directory.