- Overview
- Supported Targets and Data Plane APIs
- Installation & Start Instructions
- Working with UniCorn-P4
- Changelog
- Preview
This repository contains the source code for a universal P4 controller for rapid prototyping of P4 programs in data plane programming.
UniCorn-P4
- provides a web-based GUI for configuration and visualization of P4 switches
- implements a control plane communicating with switches via the data plane API
- automatically derives available MATs and their structure from compiled P4 files
- allows manual manipulation of MAT entries or loading them from configuration files
- includes a Mininet extension for emulating large network topologies to test P4 programs
Currently any P4 target that implementes the P4 Runtime API is supported, e.g., the BMv2 software-based target with the simple_switch_grpc
architecture.
UniCorn-P4 can be started via docker-compose up
in the docker folder. The initial build may take a few minutes.
This docker-compose file starts up the frontend, the backend, and the Mininet container.
UniCorn-P4 requires the generated P4 runtime file and the intermediate representation file from the compilation command. Compile your P4 program like following:
p4c /path/to/p4_folder/basic.p4 --target bmv2 --arch v1model --p4runtime-files /path/to/p4_folder/basic.p4info.txt -o /path/to/p4_folder/
Place the basic.p4info.txt
and basic.json
file into the /p4-files/
directory of this repository.
You may create subfolders for distinct projects there containing your compiled P4 files.
Note: The path of the /p4-files/
directory can be changed in the docker-compose file.
Head to http://localhost:3000
for the UniCorn-P4 GUI in your browser.
Put a topology file into the netsim/
directory, e.g.,
{
"hosts": [
"h1",
"h2"
],
"switches": {
"s1": { },
"s2": { }
},
"links": [
["h1", "s1"], ["h2", "s1"], ["s1", "s2"]
]
}
Select the topology file in the GUI and click on "Load Topology". The Mininet container will now create your virtual testbed in the background.
Click on "New Switch Connection".
If you are using the Mininet Extension, the switches loaded from the topology are automatically discovered and can be selected in the drop down menu.
Otherwise, enter the name, address, port, switch_id, and a log file path to connect to a switch in the network.
Select a Switch in the navigation bar and click on "Edit Initialization".
Select the P4 Info file and the corresponding json file from the list of discovered files and click on "Initialize".
The P4 program is now loaded onto the switch.
After the switch is initialized, the available MATs in the P4 program are automatically discovered and can be found under "Tables".
New entries can be added, and existing entries can be modified or deleted.
The current state of the switch can be saved as a snapshot into your history.