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)]

 

转载于:https://www.cnblogs.com/heimafeitian/p/9644242.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值