MiniP4 is a python utility to quickly create a Mininet network using P4 switches.
git clone https://github.com/joncastro/minip4
cd minip4
sudo python setup.py install
The dependencies to run MiniP4 are
git clone https://github.com/mininet/mininet.git
cd mininet
sudo python setup.py install
git checkout tags/2.2.1
cd ..
sed -i 's/git:\/\/openflowswitch.org\/openflow.git/https:\/\/github.com\/mininet\/openflow.git/g' mininet/util/install.sh
sed -i 's/git:\/\/gitosis.stanford.edu\/oflops.git/https:\/\/github.com\/mininet\/oflops.git/g' mininet/util/install.sh
# Mininet is installed with -n to avoid installing unnecessary openflow dependencies
mininet/util/install.sh -n
git clone https://github.com/p4lang/p4c-bm.git
cd p4c-bm
sudo pip install -r requirements.txt
sudo python setup.py install
cd ..
git clone https://github.com/p4lang/behavioral-model.git
cd behavioral-model
./install_deps.sh
./autogen.sh
aclocal && automake --add-missing && autoconf && autoreconf -fi
./configure --with-pdfixed
#./configure
make
sudo ln -s ${PWD}/targets/simple_switch/simple_switch /usr/local/bin/simple_switch
sudo ln -s ${PWD}/tools/runtime_CLI.py /usr/local/bin/runtime_CLI.py
cd ..
MiniP4 requires a topology file based in YAML to create a Mininet network using P4 switches. The topology file mainly contains the list of hots, switches and the links that connect them.
MiniP4 can be started executing mnp4
command. By default p4-topo.yml
topology file will be used if not provided.
The YAML file is composed on following sections.
Defaults parameters to be used by default for host and switches.
hosts default parameters:
gw
: default gatewaycommand
: a list of default commands to be executed
switches default parameters:
p4src
: p4 source filedump
: dump packets into a pcap file per interfaceport
: default port start number for thriftcommands
: default switch commandsverbose
: log level (trace
,debug
,info
,warn
,error
,off
). Default,info
sw_path
: switch behavioral executable. Default,simple_switch
cli
: p4 cli path. Default,runtime_CLI.py
compiler
: p4 compiler path. Default,p4c-bmv2
List of host
Mandatory parameters:
name
: host nameip
: ip address
Optional parameters:
All default host parameters and following ones:
mac
: if not provided and the name contains a digits, the mac will use the number of concatenating all digits and converted to mac address. For example, if name ish101c1
then mac address is00:00:00:00:03:F3
. Notice0x03:F3
is the hex representation of1011
. If not, a random mac address will be calculated.
List of switch
Mandatory parameters:
name
: switch name (mandatory)
Optional parameters if provided on defaults:
All default switch parameters and following ones:
id
: if not provided and the name contains a digits, the id will be the number of concatenating all digits. For example, if name iss101c2
, 1012 will be used asid
. If not, a random id will be calculated.port
: thrift port
List of link
source
: source host or switch namedestination
: destination host or switch name
Example,
defaults:
host:
gw: 10.0.0.1
command:
- route add 8.8.8.0 dev eth0
switch:
sw_path: simple_switch
compiler: p4c-bmv2
cli: runtime_CLI.py
p4src : p4src/vpc.p4
dump: true
port: 22222
commands: commands.txt
host:
- ip: 10.0.1.1/16
name: h101
- ip: 10.0.1.2/16
name: h102
- ip: 10.0.1.3/16
name: h103
switch:
- name: s101
- name: s102
- name: s103
link:
- source: h101
destination: s101
- source: h102
destination: s102
- source: h103
destination: s103
- source: s101
destination: s102
- source: s101
destination: s103
- source: s102
destination: s103