文档章节

Run P4 without P4factory - A Simple Example In Tutorials.

wangxuwei
 wangxuwei
发布于 2017/05/23 00:12
字数 670
阅读 88
收藏 0

一、安装bmv2 和 p4c-bm(我把他们安装在~/prg/mypython)

安装p4c-bm很顺利只需依次执行如下命令:

cd ~/prg/mypython
git clone https://github.com/p4lang/p4c-bm.git
cd p4c-bm/
sudo pip install -r requirements.txt
sudo pip install -r requirements_v1_1.txt
sudo python setup.py install

bmv2:

先安装依赖包

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

在执行以下命令:

cd ~/prg/mypython
git clone https://github.com/p4lang/behavioral-model.git bmv2
cd bmv2/
./autogen.sh 
./install_deps.sh

这时会出现下面错误:

Processing /home/mymotif/prg/mypython/bmv2/tmp.7ri1dMUJMg/nnpy
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-ptrGc8-build/setup.py", line 4, in <module>
        generate.run()
      File "generate.py", line 60, in run
        f.write(symbols(headers))
      File "generate.py", line 37, in symbols
        ffi = FFI()
      File "/usr/local/lib/python2.7/dist-packages/cffi/api.py", line 54, in __init__
        backend.__version__, backend.__file__))
    Exception: Version mismatch: this is the 'cffi' package version 1.10.0, located in '/usr/local/lib/python2.7/dist-packages/cffi/api.pyc'.  When we import the top-level '_cffi_backend' extension module, we get version 1.5.2, located in '/usr/lib/python2.7/dist-packages/_cffi_backend.x86_64-linux-gnu.so'.  The two versions should be equal; check your installation.

查看install_deps.sh脚本,发现最后安装的是nnpy模块,提示说和cffi版本不匹配造成的,多次尝试解决此问题未果后决定忽略次错误。

编译安装:

./configure
make
sudo make install

二、安装其它工具
 

sudo pip install scapy thrift networkx

mininet参见:https://my.oschina.net/u/2245781/blog/889820

添加python模块p4_mininet的搜索路径:

$ cat /usr/local/lib/python2.7/dist-packages/p4_mininet.pth 
~/prg/mypython/bmv2/mininet

建议改为实际的路径(因为~会随着登录用户不同而改变)

三、下载教程并准备运行前的设置

cd ~/prg/mypython
git clone https://github.com/p4lang/tutorials.git
cd tutorials/

修改env.sh为如下内容

THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

# ---------------- EDIT THIS ------------------
BMV2_PATH=~/prg/mypython/bmv2
# e.g. BMV2_PATH=$THIS_DIR/../bmv2
P4C_BM_PATH=~/prg/mypython/p4c-bm
# e.g P4C_BM_PATH=$THIS_DIR/../p4c-bm

执行:

cd SIGCOMM_2015/source_routing/
~/prg/mypython/tutorials/SIGCOMM_2015/source_routing$ tar zxvf solution.tar.gz
~/prg/mypython/tutorials/SIGCOMM_2015/source_routing$ cp -f  solution/p4src/source_routing.p4 p4src/source_routing.p4
~/prg/mypython/tutorials/SIGCOMM_2015/source_routing$ cp  ../../env.sh .

修改run_demo.sh

source $THIS_DIR/../../env.sh
改为:
source $THIS_DIR/env.sh

修改command.txt,内容如下:

table_set_default route_pkt route

四、运行

启动虚拟接口:

sudo ~/prg/mypython/bmv2/tools/veth_setup.sh 
停止用
sudo ~/prg/mypython/bmv2/tools/veth_teardown.sh

可用ifconfig来验证是否启动/停止成功

运行脚本:

./run_demo.sh

在启动的mininet中打开h1和h3的终端:

mininet>xterm h1
mininet>xterm h3

13.分别在h1和h3终端上运行脚本:

先执行h3终端上的脚本:

./receive.py

再执行h1终端上的脚本:

./send.py h1 h3

实验结果:

在h1的xterm上输入文本信息,在h3的xterm上能够接收。但是在mininet中执行h1 ping h3是没有办法ping通的,由此可以证实P4交换机在处理数据报的过程中,进行了协议匹配:当easyroute_port与valid相匹配时,执行route()动作。

© 著作权归作者所有

wangxuwei
粉丝 25
博文 335
码字总数 117394
作品 0
杭州
其他
私信 提问
OpenDaylight Controller:MD-SAL:Startup Project Archetype

OpenDaylight Controller:MD-SAL:Startup Project Archetype Contents [hide] 1 Introduction 2 Setup 3 Part 1 - Build with a simple 'Example' module 3.1 Ok it's all downloaded....now......

LeBlancs
2016/11/25
90
0
First Steps With Vert.x and Infinispan - Part 2: PUSH API

Welcome to the second in a multi-part series of blog posts about creating Eclipse Vert.x applications with Infinispan. In the previous blog post, we have seen how to create a RE......

Katia Aresti
2017/12/18
0
0
分布式MySQL集群Vitess-Kubernetes部署

Vitess is a database solution for deploying, scaling and managing large clusters of MySQL instances. It’s architected to run as effectively in a public or private cloud archit......

openthings
02/12
0
0
MPI中可能会出现的错误

转自: http://hi.baidu.com/linzch/blog/item/7e7d750e18329ec07acbe14f.html 1. p1_xxxxx: p4_error: interrupt SIGSEGV: 11 这个错误可能是因为某个进程中出现了段错误引起的,自己编程中曾...

晨曦之光
2012/04/24
341
0
maven 打包独立可运行jar

Creating a .jar Deployment Package Using Maven and Eclipse IDE (Java) This section shows how to package your Java code into a deployment package using Eclipse IDE and Maven plug......

Oscarfff
2016/02/13
88
0

没有更多内容

加载失败,请刷新页面

加载更多

android ------ AAPT2 error: check logs for details解决方法

AAPT 是全称是 Android Asset Packaging Tool,它是构建 App,甚至是构建 Android 系统都必不可少的一个工具。它的作用是将所有资源文件压缩打包到Android APK 当中。我们在 Android SDK 目录...

切切歆语
今天
1
0
今天的学习

今天学到了<select></select>标签: <label for="unittype">Select unit type: </label><select id="unittype" name="unittype" autofocus > <option value="1"> Miner </option> ......

墨冥
今天
1
0
程序员随想-关于分享

最早的时候,文字是贵族这些上层人士才会学习的,底层人士没有资格和渠道去学习,同样用文字、图像等其他载体承载的知识大部分也只有贵族阶层才能享受的。后来有了造纸术、印刷术,成本降低,...

Lubby
今天
2
0
聊聊hibernate的session-level repeatable reads

序 本文主要研究一下hibernate的session-level repeatable reads 实例 doInTransaction(session -> { Product product = new Product(); product.setId(1L); product.setQuanti......

go4it
今天
1
0
ubuntu或ubuntu kylin优麒麟中安装QQ、wechat微信、百度网盘

从中国国内的地址下载deepin wine,码云上的。这样网速比较快。然后,按照说明向下安装。 https://gitee.com/wszqkzqk/deepin-wine-for-ubuntu...

gugudu
今天
2
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部