wiki:p4-bmv2

Version 1 (modified by tpfeiff, 5 years ago) (diff)

--

BEHAVIORAL MODEL

https://github.com/p4lang/behavioral-model
http://p4.org/wp-content/uploads/2015/12/Nov-2015-P4-Bootcamp-Labs-Guide.pdf

Linux virtuelles Interface
http://unix.stackexchange.com/questions/152331/how-can-i-create-a-virtual-ethernet-interface-on-a-machine-without-a-physical-ad


Setup läuft aug 192.168.40.119

Setup

Ubuntu 14.04.4 LTS

sudo apt-get install automake cmake libjudy-dev libgmp-dev libpcap-dev libboost-dev libboost-test-dev libboost-program-options-dev libboost-system-dev libboost-filesystem-dev libboost-thread-dev libevent-dev libtool flex bison pkg-config g++ libssl-dev git ant

sudo apt-get install automake bison flex g++ git libevent-dev libssl-dev libtool make pkg-config libboost-all-dev python python-pip python-dev 

sudo apt-get install libffi*



sudo echo "deb http://us.archive.ubuntu.com/ubuntu vivid main universe" >> /etc/apt/sources.list
sudo apt-get update
sudo apt-get install libnanomsg-dev libnanomsg0


sudo pip install Thrift



sudo apt-get install python-software-properties
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update

sudo apt-get install oracle-java8-installer

export JAVA_HOME=/usr/lib/jvm/java-8-oracle



cd ~
curl http://archive.apache.org/dist/thrift/0.9.3/thrift-0.9.3.tar.gz | tar zx
cd thrift-0.9.3/

./configure
make
sudo make install



cd ~
git clone https://github.com/p4lang/behavioral-model.git
cd behavioral-model

./autogen.sh
./configure
make
sudo make install



cd ~
git clone https://github.com/p4lang/p4c-bm.git
cd p4c-bm

sudo pip install -r requirements.txt
sudo python setup.py install

Start bmv2

p4c-bmv2 --json sw_programm.json test.p4

/root/behavioral-model/targets/simple_switch/simple_switch --log-console -i 0@p3p1 -i 1@p2p1 /root/sw_programm.json


Run L2 Switch

cd ~/behavioral-model/targets/l2_switch

vi run.sh
   ./l2_switch --log-console -i 1@p2p1 -i 2@p3p1  ./l2_switch.json


./run.sh



#IN NEUEM FENSTER
#------------------
cd ~/behavioral-model/tools

./runtime_CLI.py

table_set_default smac mac_learn
table_set_default dmac broadcast
mc_mgrp_create 1
mc_node_create 0 1
mc_node_create 1 2
mc_node_associate 1 0
mc_node_associate 1 1



# Live Logs
./nanomsg_client.py


Run L3 Simple Router

cd ~/behavioral-model/targets/simple_router

vi run.sh
    sudo ./simple_router --log-console --nanolog ipc:///tmp/bm-1-log.ipc -i 1@p2p1 -i 2@p3p1 ./simple_router.json

./run.sh



#IN NEUEM FENSTER
#------------------
cd ~/behavioral-model/tools

./runtime_CLI.py

table_set_default send_frame _drop
table_set_default forward _drop
table_set_default ipv4_lpm _drop
table_add send_frame rewrite_mac 1 => 00:aa:bb:00:00:00
table_add send_frame rewrite_mac 2 => 00:aa:bb:00:00:01
table_add forward set_dmac 10.0.0.10 => 00:04:75:c7:8c:5b
table_add forward set_dmac 10.0.1.10 => 00:13:3b:10:3e:85
table_add ipv4_lpm set_nhop 10.0.0.10/24 => 10.0.0.10 1
table_add ipv4_lpm set_nhop 10.0.1.10/24 => 10.0.1.10 2


# Live Logs
./nanomsg_client.py


Run L3 Mininet

cd ~/behavioral-model/mininet

python ./1sw_demo.py --num-hosts 2 --mode l3 --behavioral-exe /root/behavioral-model/targets/simple_router/simple_router --json  /root/behavioral-model/targets/simple_router/simple_router.json



#IN NEUEM FENSTER
#------------------
cd ~/behavioral-model/tools

./runtime_CLI.py

table_set_default send_frame _drop
table_set_default forward _drop
table_set_default ipv4_lpm _drop
table_add send_frame rewrite_mac 1 => 00:aa:bb:00:00:00
table_add send_frame rewrite_mac 2 => 00:aa:bb:00:00:01
table_add forward set_dmac 10.0.0.10 => 00:04:00:00:00:00
table_add forward set_dmac 10.0.1.10 => 00:04:00:00:00:01
table_add ipv4_lpm set_nhop 10.0.0.10/32 => 10.0.0.10 1
table_add ipv4_lpm set_nhop 10.0.1.10/32 => 10.0.1.10 2



# Live Logs
./nanomsg_client.py