https://github.com/dscano/basic-tna
This application allows ONOS to control the basic P4 pipeline, deployed for Tofino switch, via the ONOS application reactive forwarding and/or installation of custom flow rules via ONOS REST API .
https://github.com/dscano/basic-tna
network-programmability networking onos onos-app p4 p4runtime sdn sdn-controller sdn-network stratum tofino tofino-switch
Last synced: 4 months ago
JSON representation
This application allows ONOS to control the basic P4 pipeline, deployed for Tofino switch, via the ONOS application reactive forwarding and/or installation of custom flow rules via ONOS REST API .
- Host: GitHub
- URL: https://github.com/dscano/basic-tna
- Owner: Dscano
- Created: 2022-07-27T15:56:56.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-27T16:38:02.000Z (about 3 years ago)
- Last Synced: 2024-05-23T05:04:22.275Z (over 1 year ago)
- Topics: network-programmability, networking, onos, onos-app, p4, p4runtime, sdn, sdn-controller, sdn-network, stratum, tofino, tofino-switch
- Language: Java
- Homepage:
- Size: 75.2 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Basic-TNA
`basic-tna` is a simple P4 program that realise the basic pipeline, SDN-enabled programmable network capable to provide a simple forwarding. More in details, this application allows ONOS to control a P4 pipeline, deployed for Tofino switch, via the ONOS application reactive forwarding and installation of custom flow rules via ONOS REST API .
`basic-tna.p4` follows a similar design to `basic.p4`.
## Disclaimer
The repository is inspired by [SD-Fabric] project and provides a simple forwarding pipelines. The goal is provide a full stack deployment (data plane + control pane) in order to help the beginner to work in the SDN and P4 environment.## Content
### P4 Program
The directory `p4src/tna` contains the P4 program for the TNA architecture.
`p4src/v1model` contains an equivalent version of the same program based on the
V1Model architecture, to be used for development and testing together with the
BMv2 software switch.### ONOS Pipeconf
`src/` contains the Java implementation and tests for the ONOS pipeconf, which
is essentially a set of drivers enabling ONOS to control different aspects of
the switch pipeline defined by the P4 program.## Requirements
To build and test this project you will need the following software:
* Barefoot SDE (a.k.a. Intel P4 Studio) = 9.7.0
* ONOS = 3.0.0
* Docker (to run the build scripts without worrying about dependencies)
* cURL (to interact with the ONOS REST APIs)### Intel P4 Studio (SDE) Docker Image
To facilitate managing different versions of the Intel P4 Studio (SDE), the build
scripts expect the Barefoot SDE to be provided as a Docker image. We do not provide
such image, but one can be easily generated by:* executing the regular SDE install instructions inside a Dockerfile
* making sure executables such as `bf-p4c` and `tofino-model` are on `$PATH`Once you obtain such Docker image, set the following environment variables:
```bash
export SDE_VERSION=9.7.0
export SDE_DOCKER_IMG=my-docker-repo/bf-sde:9.7.0
```## Quick steps
To compile the P4 program with a given ``:
```bash
make basic
```To build the ONOS pipeconf `.oar` package which includes the compiled P4
artifacts for the previously built profile(s):```bash
make pipeconf
```To learn more about pipeconfs, keep reading.
## Detailed steps to build the basic-tna pipeconf
ONOS uses "pipeconfs" to deploy and manage a given P4 program on a device.
Pipeconfs include mainly two things:1. the P4 compiled artifacts (e.g., `tofino.bin`, `context.json`, etc.) to
deploy on devices.
2. Java classes implementing ONOS driver behaviors to control capabilities of
the particular P4 program.Pipeconfs are distributed as ONOS applications, hence using the `.oar`
packaging. The following steps provide instructions on how to generate an oar
package that includes one or more profiles.To build `basic-tna.p4` using the Barefoot compiler and to create the pipeconf
`.oar` package in one command:```bash
make basic
```The P4 compiler outputs to include in the `.oar` package will be placed under
`src/main/resources/p4c-out`.When done, the pipeconf `.oar` package can be found in
`target/basic-tna-.oar`## Steps to use the fabric-tna pipeconf with ONOS
### 1 - Get and run ONOS
You can either build from sources or run one the released versions:
Pre-built ONOS Docker images are available here:
For more information on how to get and run ONOS:
### 2 - Start Stratum on your switch
To run Stratum on a Tofino-based switch, please follow instructions in this document:
Note that `basic-tna` uses the `@p4runtime_translation` annotation for certain
P4 tables, you must enable P4Runtime translation with the following flags when starting
Stratum:```text
-experimental_enable_p4runtime_translation
-incompatible_enable_bfrt_legacy_bytestring_responses
```### 3 - Install pipeconf app in ONOS
To install the pipeconf app built in the previous step, assuming ONOS is
running on the local machine:```bash
make pipeconf-install ONOS_HOST=localhost
```Use the `ONOS_HOST` argument to specify the hostname/IP address of the machine
where ONOS is running.This command is a wrapper to a `curl` command that uses the ONOS REST API to
upload and activate the `.oar` package previously built.You should see the ONOS log updating with messages notifying the registration of
new pipeconfs in the system, depending on the profiles compiled before, and the
Barefoot SDE version:```text
New pipeconf registered: org.stratumproject.basic.mavericks_sde_9_7_0 (fingerprint=...)
New pipeconf registered: org.stratumproject.basic.montara_sde_9_7_0 (fingerprint=...)
...
```**NOTE: it might take up to one minute for the pipeconfs to be registered.**
To check all pipeconfs registered in the system, use the ONOS CLI:
```text
onos> pipeconfs
```### 4 - Connect ONOS to a Stratum switch
Activate the Barefoot drivers in ONOS:
```text
onos> app activate org.onosproject.drivers.barefoot
```This command will register a new driver named `stratum-tofino`. As the name
suggests, this driver allows ONOS to control Tofino switches running Stratum.For ONOS to be able to discover your switch, you need to push a JSON file,
usually referred to as the "netcfg" file. We provide an example of such
`tofino-netcfg.json` file in this repository. Make sure to modify the following
values:* `managementAddress` is expected to contain a valid URI with host and port of
the Stratum gRPC server running on the switch;
* The `device_id` URI query parameter is the P4Runtime-internal `device_id`,
also known as the Stratum "Node ID". Usually, you can leave this value set to
`1`;
* Use the `pipeconf` field to specify which pipeconf/fabric profile to deploy on
the switch.Push the `tofino-netcfg.json` to ONOS using the command:
```bash
make netcfg ONOS_HOST=localhost
```Like before, this command is a wrapper to a `curl` command that uses the ONOS
REST API to push the `tofino-netcfg.json` file.Check the ONOS log for potential errors.
## Examples
The video shows how to install the basic-tna application and the devices and links discovery
The video presents the Tofino+Stratum device and the flow rules installed, the forwarding flow rules contains all the match criteria avaiable in table0.
## Acknowledge
Check the official SD-Fabric project here:
Check the official Stratum project here:
[ONOS]: https://opennetworking.org/onos/
[Stratum]: https://github.com/stratum/stratum
[Basic]: https://github.com/opennetworkinglab/onos/tree/master/pipelines/basic/src/main/java/org/onosproject/pipelines/basic
[SD-Fabric]: https://opennetworking.org/sd-fabric/
[basic.p4]: https://github.com/opennetworkinglab/onos/blob/master/pipelines/basic/src/main/resources/basic.p4