{"id":25711621,"url":"https://github.com/dscano/basic-tna","last_synced_at":"2025-06-21T05:35:08.793Z","repository":{"id":241239158,"uuid":"518523521","full_name":"Dscano/Basic-tna","owner":"Dscano","description":"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 . ","archived":false,"fork":false,"pushed_at":"2022-07-27T16:38:02.000Z","size":77,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-23T05:04:22.275Z","etag":null,"topics":["network-programmability","networking","onos","onos-app","p4","p4runtime","sdn","sdn-controller","sdn-network","stratum","tofino","tofino-switch"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Dscano.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-27T15:56:56.000Z","updated_at":"2024-05-23T05:04:30.722Z","dependencies_parsed_at":"2024-05-23T05:04:28.809Z","dependency_job_id":"730118fa-38e3-4338-a3f3-462cda2929f2","html_url":"https://github.com/Dscano/Basic-tna","commit_stats":null,"previous_names":["dscano/basic-tna"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dscano%2FBasic-tna","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dscano%2FBasic-tna/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dscano%2FBasic-tna/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dscano%2FBasic-tna/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dscano","download_url":"https://codeload.github.com/Dscano/Basic-tna/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240654186,"owners_count":19835857,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["network-programmability","networking","onos","onos-app","p4","p4runtime","sdn","sdn-controller","sdn-network","stratum","tofino","tofino-switch"],"created_at":"2025-02-25T10:54:39.525Z","updated_at":"2025-02-25T10:54:40.361Z","avatar_url":"https://github.com/Dscano.png","language":"Java","readme":"# Basic-TNA\n\n`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 .\n\n`basic-tna.p4` follows a similar design to `basic.p4`.\n\n## Disclaimer\nThe 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.\n\n## Content\n\n### P4 Program\n\nThe directory `p4src/tna` contains the P4 program for the TNA architecture.\n`p4src/v1model` contains an equivalent version of the same program based on the\nV1Model architecture, to be used for development and testing together with the\nBMv2 software switch.\n\n### ONOS Pipeconf\n\n`src/` contains the Java implementation and tests for the ONOS pipeconf, which\nis essentially a set of drivers enabling ONOS to control different aspects of\nthe switch pipeline defined by the P4 program.\n\n## Requirements\n\nTo build and test this project you will need the following software:\n\n* Barefoot SDE (a.k.a. Intel P4 Studio) = 9.7.0\n* ONOS = 3.0.0\n* Docker (to run the build scripts without worrying about dependencies)\n* cURL (to interact with the ONOS REST APIs)\n\n### Intel P4 Studio (SDE) Docker Image\n\nTo facilitate managing different versions of the Intel P4 Studio (SDE), the build\nscripts expect the Barefoot SDE to be provided as a Docker image. We do not provide\nsuch image, but one can be easily generated by:\n\n* executing the regular SDE install instructions inside a Dockerfile\n* making sure executables such as `bf-p4c` and `tofino-model` are on `$PATH`\n\nOnce you obtain such Docker image, set the following environment variables:\n\n```bash\nexport SDE_VERSION=9.7.0\nexport SDE_DOCKER_IMG=my-docker-repo/bf-sde:9.7.0\n```\n\n## Quick steps\n\nTo compile the P4 program with a given `\u003cprofile\u003e`:\n\n```bash\nmake basic\n```\n\nTo build the ONOS pipeconf `.oar` package which includes the compiled P4\nartifacts for the previously built profile(s):\n\n```bash\nmake pipeconf\n```\n\nTo learn more about pipeconfs, keep reading.\n\n## Detailed steps to build the basic-tna pipeconf\n\nONOS uses \"pipeconfs\" to deploy and manage a given P4 program on a device.\nPipeconfs include mainly two things:\n\n1. the P4 compiled artifacts (e.g., `tofino.bin`, `context.json`, etc.) to\ndeploy on devices.\n2. Java classes implementing ONOS driver behaviors to control capabilities of\nthe particular P4 program.\n\nPipeconfs are distributed as ONOS applications, hence using the `.oar`\npackaging. The following steps provide instructions on how to generate an oar\npackage that includes one or more profiles.\n\nTo build `basic-tna.p4` using the Barefoot compiler and to create the pipeconf\n`.oar` package in one command:\n\n```bash\nmake basic\n```\n\nThe P4 compiler outputs to include in the `.oar` package will be placed under\n`src/main/resources/p4c-out`.\n\nWhen done, the pipeconf `.oar` package can be found in\n`target/basic-tna-\u003cVERSION\u003e.oar`\n\n## Steps to use the fabric-tna pipeconf with ONOS\n\n### 1 - Get and run ONOS\n\nYou can either build from sources or run one the released versions:\n\u003chttps://wiki.onosproject.org/display/ONOS/Downloads\u003e\n\nPre-built ONOS Docker images are available here:\n\u003chttps://hub.docker.com/r/onosproject/onos/tags\u003e\n\nFor more information on how to get and run ONOS:\n\u003chttps://wiki.onosproject.org/display/ONOS/Guides\u003e\n\n### 2 - Start Stratum on your switch\n\nTo run Stratum on a Tofino-based switch, please follow instructions in this document:\n\u003chttps://github.com/stratum/stratum/blob/main/stratum/hal/bin/barefoot/README.run.md\u003e\n\nNote that `basic-tna` uses the `@p4runtime_translation` annotation for certain\nP4 tables, you must enable P4Runtime translation with the following flags when starting\nStratum:\n\n```text\n-experimental_enable_p4runtime_translation\n-incompatible_enable_bfrt_legacy_bytestring_responses\n```\n\n### 3 - Install pipeconf app in ONOS\n\nTo install the pipeconf app built in the previous step, assuming ONOS is\nrunning on the local machine:\n\n```bash\nmake pipeconf-install ONOS_HOST=localhost\n```\n\nUse the `ONOS_HOST` argument to specify the hostname/IP address of the machine\nwhere ONOS is running.\n\nThis command is a wrapper to a `curl` command that uses the ONOS REST API to\nupload and activate the `.oar` package previously built.\n\nYou should see the ONOS log updating with messages notifying the registration of\nnew pipeconfs in the system, depending on the profiles compiled before, and the\nBarefoot SDE version:\n\n```text\nNew pipeconf registered: org.stratumproject.basic.mavericks_sde_9_7_0 (fingerprint=...)\nNew pipeconf registered: org.stratumproject.basic.montara_sde_9_7_0 (fingerprint=...)\n...\n```\n\n**NOTE: it might take up to one minute for the pipeconfs to be registered.**\n\nTo check all pipeconfs registered in the system, use the ONOS CLI:\n\n```text\nonos\u003e pipeconfs\n```\n\n### 4 - Connect ONOS to a Stratum switch\n\nActivate the Barefoot drivers in ONOS:\n\n```text\nonos\u003e app activate org.onosproject.drivers.barefoot\n```\n\nThis command will register a new driver named `stratum-tofino`. As the name\nsuggests, this driver allows ONOS to control Tofino switches running Stratum.\n\nFor ONOS to be able to discover your switch, you need to push a JSON file,\nusually referred to as the \"netcfg\" file. We provide an example of such\n`tofino-netcfg.json` file in this repository. Make sure to modify the following\nvalues:\n\n* `managementAddress` is expected to contain a valid URI with host and port of\n  the Stratum gRPC server running on the switch;\n* The `device_id` URI query parameter is the P4Runtime-internal `device_id`,\n  also known as the Stratum \"Node ID\". Usually, you can leave this value set to\n  `1`;\n* Use the `pipeconf` field to specify which pipeconf/fabric profile to deploy on\n  the switch.\n\nPush the `tofino-netcfg.json` to ONOS using the command:\n\n```bash\nmake netcfg ONOS_HOST=localhost\n```\n\nLike before, this command is a wrapper to a `curl` command that uses the ONOS\nREST API to push the `tofino-netcfg.json` file.\n\nCheck the ONOS log for potential errors.\n\n## Examples\nThe video shows how to install the basic-tna application and the devices and links discovery \n![set_up_and_discovery](https://user-images.githubusercontent.com/25779169/179993679-872dea37-9441-45cc-b760-96d14d5ca4a9.gif)\n\nThe video presents the Tofino+Stratum device and the flow rules installed, the forwarding flow rules contains all the match criteria avaiable in table0.\n![device](https://user-images.githubusercontent.com/25779169/179994151-9f28bcd0-fd78-4788-af0f-2cb75c3fec50.gif)\n\n## Acknowledge\n\nCheck the official SD-Fabric project here:\n\u003chttps://docs.sd-fabric.org\u003e\n\nCheck the official Stratum project here:\n\u003chttps://github.com/stratum/stratum\u003e\n\n[ONOS]: https://opennetworking.org/onos/\n[Stratum]: https://github.com/stratum/stratum\n[Basic]: https://github.com/opennetworkinglab/onos/tree/master/pipelines/basic/src/main/java/org/onosproject/pipelines/basic\n[SD-Fabric]: https://opennetworking.org/sd-fabric/\n[basic.p4]: https://github.com/opennetworkinglab/onos/blob/master/pipelines/basic/src/main/resources/basic.p4\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdscano%2Fbasic-tna","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdscano%2Fbasic-tna","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdscano%2Fbasic-tna/lists"}