Framework to easily create topologies with Tofino-models (and many other node types)

Hi ICRP Community,

A bit inspired by a previous post I just read (https://community.intel.com/t5/Intel-Connectivity-Research/Setting-up-Tofino-virtual-switch-with-Network-Namespaces-Linux/m-p/1348411/thread-id/3037) and also by some questions I have seen in the last months I thought that it might be useful (I hope so) for some of you if I share a P4 prototyping library we have developed at ETH Zürich.

The tool is called p4-utils and It is basically an extension to Mininet but with many many additions to help you with your P4 development. The library was originally developed as an internal tool to make P4 development easier, however we have also been using it during the last 4 years in an advanced networking lecture where we teach P4. For both exercises and final project.  Its main intend is to help prototyping networks with the bmv2 switches, however (and here is where it might be useful for you) we have recently added some basic support for Tofino-model switches!

You can find a very basic example of how to use the tool to create topologies with tofino switches here:  p4-utils/examples/tofino at master · nsg-ethz/p4-utils · GitHub.

You can find a very basic network description here: p4-utils/examples/tofino/network.py at master · nsg-ethz/p4-utils · GitHub

In the example we start the controllers and traffic senders manually (for the sake of simplicity) however there are ways to completely automate everything from the main python script.

Furthermore, you can find more information about the library in its documentation: https://nsg-ethz.github.io/p4-utils/index.html Also, you can find many examples of how to use it in the following repository: https://github.com/nsg-ethz/p4-learning . All the examples are using the bmv2 (simple_switch/grpc) however there are many resources to learn how to use the library and well also it might be a good resource to learn P4 (as a complement to the main tutorials).

Installation:
Since the library was mainly designed to be used with the normal p4 suite, it has an installation section https://github.com/nsg-ethz/p4-utils/tree/master/install-tools that focuses on installing all the needed things for bmv2, p4c, etc which I believe is not needed if you intend to use it with the tofino-model only. Of course,  for tofino development you still need to have the corresponding SDE installed in your machine/VM.

Thus, to install the library just for tofino prototyping you can simply do the following:

1. Install mininet if you don’t have it.

git clone g<span>it://github.com/mininet/mininet mininet<br></span>cd mininet <br><span>sudo PYTHON=python3 ./util/install.sh -nwv<br></span>

2. Install p4-utils

git clone https://github.com/nsg-ethz/p4-utils.git
<span class="pl-c1">cd</span> p4-utils
sudo ./install.sh

I hope this can make your life a bit easier and can help you with your P4 and Tofino development. If any question I can try to help.

Kind regards,
Edgar

Thanks, @ecost5 , for your team’s efforts.
I am glad you like my posts.
This mininet contribution is of great value to the community.
This will surely save a lot of hours of virtual connection setup while testing dataplane behavior.

Thanks a lot for sharing this work here.
:=)