Look here, install the bmv2 switch according to the link below.
There are also some information on how to populate the tables and compile your code using the p4c compiler.
then you can start your switch and attach it to physical interface using the command
sudo ./simple_switch -i 0@<iface0> -i 1@<iface1> <path to JSON file>
however, if you want to attach your interface to one of the switches in the mininet, one way to do it is to find the file p4_mininet.py and inside the start function you can add these lines:
""" This is to attach Switch S0 to a physical interface for
communication with external hosts """
if self.device_id == 0:
args.extend(['-i', str(10) + "@" + "eth100"])
replace 0 with the id of switch you are interested in and replace eth100 with the name of interface you want to attach.
this way every time you run the mininet the interface gets attached automatically.
another more dynamic way to do it is via the simple_switch_CLI.
start a CLI session by running
simple_switch_CLI --thrift-port 9090
replace 9090 with the thrift port of the switch which is usually 9090 + switch id
then you can run the command port_add
RuntimeCmd: help port_add
Add a port to the switch (behavior depends on device manager used): port_add <iface_name> <port_num> [pcap_path]