run p4 in mininet

https://github.com/p4lang/behavioral-model

1、安装工具

install_deps.sh 

 

2、编译behavioral-model

 ./autogen.sh
 ./configure
make
[sudo] make install # if you need to install bmv2   //没意义

 

3、测试

make check

 

4、安装p4c-bm

git下载代码:https://github.com/p4lang/p4c-bm

sudo pip install -r requirements.txt
sudo pip install -r requirements_v1_1.txt if you are interested in compiling P4 v1.1 programs
sudo python setup.py install

derek@ubox16:~$ p4c-bmv2 --version
1.11.0-e389bd34

 

5、在mininet上运行

1)编译json

cd target/simple_router
p4c-bmv2 --json simple_router.json simple_router.p4

2)运行

cd mininet
sudo python 1sw_demo.py --behavioral-exe ../targets/simple_router/simple_router --json ../targets/simple_router/simple_router.json

mininet>pingall  //不通

3)配置table

再开一个终端:

- cd targets/simple_router
- ./runtime_CLI < commands.txt

 

mininet> pingall
*** Ping: testing ping reachability
h1 -> h2 
h2 -> h1 
*** Results: 0% dropped (2/2 received)

 

4)读写表项

开一个终端:

cd tools

./runtime_CLI.py --thrift-port 9090


RuntimeCmd: show_tables
forward [implementation=None, mk=routing_metadata.nhop_ipv4(exact, 32)]
ipv4_lpm [implementation=None, mk=ipv4.dstAddr(lpm, 32)]
send_frame [implementation=None, mk=standard_metadata.egress_port(exact, 9)]
RuntimeCmd: table_info forward
forward [implementation=None, mk=routing_metadata.nhop_ipv4(exact, 32)]
********************************************************************************
_drop []
set_dmac [dmac(48)]
RuntimeCmd: 
forward [implementation=None, mk=routing_metadata.nhop_ipv4(exact, 32)]
********************************************************************************
_drop []
set_dmac [dmac(48)]
RuntimeCmd: 
forward [implementation=None, mk=routing_metadata.nhop_ipv4(exact, 32)]
********************************************************************************
_drop []
set_dmac [dmac(48)]

 

posted @ 2018-09-14 00:51  heimafeitian  阅读(168)  评论(0编辑  收藏  举报