Page tree

Have questions? Stuck? Please check our FAQ for some common questions and answers.

This wiki documents the current development version of ONOS (master). Refer to the Wiki Archives for documentation for all previous versions of ONOS.

Skip to end of metadata
Go to start of metadata

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 behavior of a fixed-function switch. P4 Runtime is a protocol to control at runtime a P4-defined pipeline, for example, to install entries in a table defined in the P4 program. 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. If this is not the case, here's a list of pointers to get started:

Table of Contents

Overview

This section is still work in progress. For an overview of P4 and P4 Runtime support in ONOS please refer to this presentation:

P4 Support in ONOS (ONOS Build, September 2017)

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:

  • 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

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.

Click here to download the ONOS+P4 Developer VM (approx. 3.5 GB)

VM login credentials

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

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 recommend 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, named 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 localhost
  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. On third VM terminal shell, type: 

    $ sudo -E mn --custom $BMV2_MN_PY --switch onosbmv2 --controller remote

    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. $BMV2_MN_PY is used to point to the location of the Mininet custom file bmv2.py provided 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: simple_switch_grpc --device-id 1 -i 1@s1-eth1 -i 2@s1-eth2 --log-console -Lwarn --thrift-port 38148 --no-p4 -- --cpu-port 255 --grpc-server-addr 0.0.0.0:37346
    [1] 2370

    *** Starting CLI:
    mininet>

    bmv2.py custom Mininet script

    When using the bmv2.py custom Mininet script, files related to the execution of the BMv2 switch are stored under /tmp. The name of these files depends on the --device-id parameter used at BMv2 execution (see Mininet output). These files include:

    bmv2-1-grpc-port: contains the port used by the P4Runtime server executed by the BMv2 simple_switch_grpc target
    bmv2-1-log: contains the BMv2 log
    bmv2-1-netcfg.json: the netcfg blob pushed to ONOS to discover the BMv2 switch

  6. 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=device:bmv2:1, available=false, local-status=connected 9m33s ago, role=NONE, type=SWITCH, mfr=p4.org, hw=master, sw=master, serial=unknown, driver=bmv2:org.onosproject.pipelines.basic, locType=geo, name=device:bmv2:1, protocol=[p4runtime]

    From the output, we can see that the BMv2 switch is connected (available=true), along with information on the P4 program (pipeconf) deployed (driver=bmv2:org.onosproject.pipelines.basic) and on the protocol used to control the switch (protocol=[p4runtime]).

  7. Check that the 2 hosts can ping each other. On the Mininet command line, use the pingall command check the output:

    mininet> pingall
    *** Ping: testing ping reachability
    h1 -> h2
    h2 -> h1
    *** Results: 0% dropped (2/2 received)

Update P4 tools to latest version

Since P4Runtime is a work-in-progress effort, we frequently update ONOS to support the most recent capabilities. Similarly, we update the version of the P4 tools (BMv2, P4Runtime, and p4c) in the VM. Use the following commands to update ONOS and the P4 tools to the latest version:

$ cd ~/onos/
$ git pull origin master
$ onos-setup-p4-dev

The onos-setup-p4-dev command will download and build the most recent version of the P4 tools. In case of errors, please remove any build artifact from previous executions:

$ rm -rf ~/p4tools
$ onos-setup-p4-dev
  • No labels