博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
P4factory ReadMe 剩余部分
阅读量:5292 次
发布时间:2019-06-14

本文共 2944 字,大约阅读时间需要 9 分钟。

Building and Running a Target

Each P4 program (called a 'target') is set up in a directory under targets/. Inside the target directory is a Makefile with the instructions on how to build the behavioral model for that P4 program.

cd targets/project_namemake bm

This should result in an executable in the same directory called "behavioral_model"

大概意思:P4程序 也叫‘Target’,是在 target/.目录下建立的;在这个target目录下,是一个Makefile文件,和一个介绍如何为P4程序build一个行为模型的文件。

做了个测试:

cd /home/wasdns/p4factory/targets/switchmake bm

Integration with Mininet 和 Mininet 一起运行

Integration with Mininet provides a way to instantiate a network of nodes each running a data plane described in P4.

We provide a Mininet integration for one of our existing targets: simple_router
To run it, do the following:

cd p4factory/targets/simple_router/make bm./run_demo.bash

To install some table entries, run the following (in a different terminal):

./run_add_demo_entries.bash

跑的时候出现了错误:

885822-20160925180358535-1067795582.png
好吧,解决方法说依赖关系重叠,我只好重新安装了下p4factory,解决问题。

You can then type commands in the Mininet CLI:

mininet> h1 ping h2

建立了一个简单拓扑,但是h1和h2并没有ping通。这让我很奇怪,h1 ping s1 还有 h2 ping s1 都没有问题。

Creating a New Target

To add a new target, cd to targets/ and run:

p4factory/tools/newtarget.py project_name

where project_name is the name of the P4 program (without the .p4 extension). This will create a new directory in targets/ called project_name/, set it up to build the behavioral model, and create a template for the P4 program there named project_name.p4. Then, edit that file or copy your P4 program to that file and make in that directory.

这个就是生成P4程序的命令了;可以用这个命令创建一个没有.p4后缀的P4程序,在targets/目录下,在该目录下创建一个文件 .p4,用vim编辑它或者直接把P4代码拷贝过去,make即可。

P4 Dependency Graph Generator

这个命令是用来辅助生成P4程序的依赖图表的:The relationships between tables of more complex P4 program can be difficult to comprehend. The p4-graphs utility parses through the the P4 program and generates a dependency graph using graphviz. The dependency graph can be generated with the following command:

p4-graphs 

The resulting files can be viewed using xdot or with a PNG viewer.

Towards a better behavioral model: bmv2

新的P4行为模型,如果你在一个P4程序里面看到bmv2目录的话,那么就意味着它支持bmv2.

We have released a new version of the behavioral model, written in C++. Some targets already support this new model -in addition to the original version, p4c-behavioral. If you see a target with a bmv2 directory, it means the new model is supported and you can try it out!

The new model splits the switch logic and the auto-generated PD API (drivers) into 2 different processes.

跑支持bmv2的程序,你可以这样做:
For example, the l2_switch target supports bmv2. To run the code, you can do the following:

cd targets/l2_switch/bmv2/make bm./run_bm.sh       # to start the data plane

然后新打开Terminal,执行下面这句,打开API:

sudo ./drivers    # in a second terminal, to start the PD APIs (RPC server)

打开第三个Terminal,跑这些例子:

sudo python run_tests.py --test-dir tests/ptf-tests/

2016/9/27

转载于:https://www.cnblogs.com/qq952693358/p/5903754.html

你可能感兴趣的文章
FUSE-用户空间文件系统
查看>>
将tiff文件转化为jpg文件并保存
查看>>
ubuntu 16.04 开机脚本
查看>>
 VS2012 C#调用C++ dll
查看>>
TCL:表格(xls)中写入数据
查看>>
SQL SERVER 2005中如何获取日期(一个月的最后一日、一年的第一日等等)
查看>>
django 学习笔记(转)
查看>>
控制台程序秒变Windows服务(Topshelf)
查看>>
字节流与字符流的区别详解
查看>>
20141026--娱乐-箱子
查看>>
自定义分页
查看>>
Oracle事务
查看>>
任意输入10个int类型数据,把这10个数据首先按照排序输出,挑出这些数据里面的素数...
查看>>
String类中的equals方法总结(转载)
查看>>
图片问题
查看>>
bash使用规则
查看>>
AVL数
查看>>
第二章练习
查看>>
ajax2.0
查看>>
C#时间截
查看>>