Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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 behavior 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.

...

  • Device discovery

  • 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

  • Counter reads

Overview

Image Removed

Image Removed

Developers Environment

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:

Info
titlepre-built VM username and password

Username: p4-mininet

Password: p4-mininet

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.

...

titleRecommended minimum system requirements

In order to successfully build and  execute the required tools, we recommend the following minimum system configuration:

ONOS+P4 Developer VM

We have created a special VM with all you need to test P4Runtime support in ONOS.

You can use the following link to download an Open Virtual Appliance (OVA) package to be imported using VirtualBox or any other x86 virtualization system that supports this format.

Pre-built OVA package (approx. 3.5 GB):

http://onlab.vicci.org/onos/onos-p4-dev.ova

Info
titleVM login credentials

The VM comes with one user with sudo privileges. Use these credentials to log:

Username: sdn

Password: rocks

VM Contents

The VM is based on Ubuntu 16.04 (server) and contains the following software pre-installed:

  • ONOS
  • BMv2 (P4 software switch with P4Runtime support)
  • p4c (P4 compiler)
  • Mininet (network emulator)

Recommended system requirements

The VM is configured with 4 GB of RAM and 2 CPU cores, while the disk has size of approx. 8 GB. For a flawless experience, we recommend running the VM on a host system that has at least the double of resources.

These are the recommended minimum requirements to be able to run a Mininet network with 1-10 BMv2 devices controlled by 1 ONOS instance. To emulate larger networks with multiple instances of ONOS (for example using onos.py), we recommend configuring the VM to use at least 4 CPU cores.

VM connectivity

The VM comes with two network interfaces: a NATed interface that provides access to internet (eth0), and a host-only one (eth1). Once you are able to access the VM, use ifconfig (or your command of choice) to get the IP address of the host-only interface. You will need that later to access the ONOS GUI from your host system.

Important: interface naming inside the VM is not guaranteed, please use your linux/networking/VirtualBox skills to figure out which interface is the host-only one. It should be the one named eth1, but that's not guaranteed. Similarly, make sure that VirtualBox is configured correctly such that the host-only interface can ping your host system.

Important 2: Without trying to tell you how to live your life, we do reccomend for your convenience to set up SSH access to the VM (e.g. copying SSH keys for faster access), as you will need to use multiple terminal shells at the same time. The Ubuntu system in the VM comes already equipped with an SSH server on port 22.

...

Walkthrough

This walkthrough demonstrates the necessary steps and commands to run a network of BMv2 devices in Mininet, controlled by ONOS using P4Runtime.

In this example the BMv2 devices will be configured with a sample P4 program that is provided by ONOS and is called basic.p4.

If not differently specified, the following commands have to be executed in a terminal shell of the VM.

  1. Build ONOS master

    cd ~/onos

    git pull origin master

    buck build onos

  2. Run ONOS

    export ONOS_APPS=drivers.bmv2,proxyarp,lldpprovider,hostprovider,fwd

    buck run onos-local -- clean

    The variable ONOS_APPS indicates which ONOS applications to execute at ONOS boot. The list includes the BMv2 drivers (based on P4Runtime), the Proxy ARP application, the LLDP Link Provider, the Host Location Provider, and the Reactive Forwarding application. These applications combined together provide ONOS with capabilities to discover the topology (via injection of LLDP packets), the hosts (by intercepting and handling ARP requests) and to provide basic point-to-point connectivity.

  3. On a second terminal shell, access the ONOS command line:

    onos losalhost

  4. Check that all applications have been loaded successfully. On the ONOS command line type

    onos> apps -s -a

    You should see an output similar to this (depending on your startup apps defined in $ONOS_APPS)

    * 10 org.onosproject.drivers 1.13.0.SNAPSHOT Default Drivers
    * 35 org.onosproject.generaldeviceprovider 1.13.0.SNAPSHOT General Device Provider
    * 36 org.onosproject.protocols.grpc 1.13.0.SNAPSHOT gRPC Protocol Subsystem
    * 37 org.onosproject.protocols.p4runtime 1.13.0.SNAPSHOT P4Runtime Protocol Subsystem
    * 38 org.onosproject.p4runtime 1.13.0.SNAPSHOT P4Runtime Provider
    * 39 org.onosproject.drivers.p4runtime 1.13.0.SNAPSHOT P4Runtime Drivers
    * 42 org.onosproject.proxyarp 1.13.0.SNAPSHOT Proxy ARP/NDP
    * 44 org.onosproject.hostprovider 1.13.0.SNAPSHOT Host Location Provider
    * 45 org.onosproject.lldpprovider 1.13.0.SNAPSHOT LLDP Link Provider
    * 73 org.onosproject.pipelines.basic 1.13.0.SNAPSHOT Basic Pipelines
    * 119 org.onosproject.drivers.bmv2 1.13.0.SNAPSHOT BMv2 Drivers
    * 146 org.onosproject.fwd 1.13.0.SNAPSHOT Reactive Forwarding

  5. Start Mininet using the custom file bmv2.py included in onos-p4-dev. On your Mininet VM (the same where you have cloned onos-p4-dev) shell, type: 

    sudo-E mn --custom $BMV2_PY --switch onosbmv2 --controller remote,ip=192.168.57.1,port=40123

    This will run a simple Mininet topology with 2 hosts connected to a BMv2 switch, to use a different topology please refer to the Mininet guide. The -E argument in sudo ensures that all environment variables are exported to the root user, including $BMV2_EXE and $BMV2_JSON$BMV2_PY is used to point to the location of the Mininet custom file bmv2.py. All these variables are exported automatically by the onos-p4-dev shell configuration script. In our case, ONOS is running on a machine reachable from the Mininet VM at the IP address 192.168.57.1. Be sure to use the correct IP address of your ONOS instance. 40123 is the default listening port of the BMv2 controller in ONOS. If successful, the output of the previous command should be similar to this:

    *** Creating network
    *** Adding controller
    *** Adding hosts:
    h1 h2
    *** Adding switches:
    s1
    *** Adding links:
    (h1, s1) (h2, s1)
    *** Configuring hosts
    h1 h2
    *** Starting controller
    c0
    *** Starting 1 switches
    s1
    Starting BMv2 target: /home/mininet/p4/onos-bmv2/targets/simple_switch/simple_switch --device-id 1 -i 1@s1-eth1 -i 2@s1-eth2 --thrift-port 38400 --log-console -Lwarn /home/mininet/p4/p4src/build/empty.json -- --controller-ip 192.168.57.1 --controller-port 40123
    *** Starting CLI:
    mininet>

  6. Check that the BMv2 switch is running. On the Mininet VM shell, type:

    $ p4log 1
    Calling target program-options parser
    Adding interface s1-eth1 as port 1
    Adding interface s1-eth2 as port 2

    This command shows the log of the BMv2 instance with device ID 1 (look for --device-id in the Mininet startup output).

    Running BMv2 for the first time

    Be aware that when running BMv2 for the first time after building it, it may take a while (up to 30 seconds) before the software switch process is executed and the log file written.


    Another way to check if the switch is running is by using the native BMv2 runtime CLI. In this case, you can use the p4cli command to print some switch information:

    $ echo "switch_info" | p4cli 1
    Obtaining JSON from switch...
    Done
    Control utility for runtime P4 table manipulation
    RuntimeCmd:
    device_id                : 1
    thrift_port              : 38400
    notifications_socket     : ipc:///tmp/bmv2-1-notifications.ipc
    elogger_socket           : None
    debugger_socket          : None

  7. Check that the BMv2 switch has successfully connected to ONOS. On the ONOS command line, check the output of the following command.

    onos> devices
    id=bmv2:192.168.57.100:45674#1, available=true, role=NONE, type=SWITCH, mfr=p4.org, hw=bmv2, sw=1.0.0, serial=n/a, driver=bmv2-thrift, bmv2JsonConfigMd5=aefbfbd1543efbfbdefbfbdefbfbd121defbfbdefbfbd3468efbfbd76, bmv2ProcessInstanceId=-1811218096, protocol=bmv2-thrift

    From the output, we can see that our BMv2 switch is connected (available=true), along with the MD5 sum of the JSON configuration currently deployed (bmv2JsonConfigMd5) and a unique ID of the BMv2 process instance (bmv2ProcessInstanceId). The latter is assigned automatically at switch boot and is used by ONOS to distinguish between different executions of similar BMv2 instances (i.e. with the same device ID and MD5 sum) and to detect a potential state change of a device (e.g. a reboot after a crash of the BMv2 process), in which case ONOS will promptly re-establish network state (e.g. re-install flow rules).

    The MD5 sum you see here is the one of the default.json configuration that is deployed on each BMv2 switch when they first connect to ONOS.

    You can also use the ONOS web GUI to explore your network. Point your browser to http://localhost:8181/onos/ui/login.html and authenticate yourself using username karaf and password karaf. You should be able to see something similar to this (click to zoom):

  8. Clone ONOS repository. On your Mininet VM shell, type:

    Code Block
    languagebash
    cd ~
    git clone https://github.com/opennetworkinglab/onos.git
  9. Source ONOS's bash_profile. On your Mininet VM shell, type:

    Code Block
    languagebash
    echo "source ~/onos/tools/dev/bash_profile" > ~/.bashrc
    source ~/.bashrc

    Important: replace .bashrc with your shell configuration profile (.bash_aliases.profile, etc.)

  10. Build and install P4 tools. We have prepared a special command to install everything in one shot! On your Mininet VM shell, simply type:

    Code Block
    languagebash
    onos-setup-p4-dev

    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:

    Code Block
    languagebash
    cd ~/p4tools

    then go in one of the local directories, e.g. p4rutnime

    Code Block
    languagebash
    cd p4runtime

    and clean the make artifacts with

    Code Block
    languagebash
    make clean
  11. Build the example P4 programs. On your Mininet VM shell, type:

    Code Block
    languagebash
    cd ~/onos/tools/test/p4src/p4-16/
    make all
  12. TBC


Update P4Tools to latest version

...