zoukankan      html  css  js  c++  java
  • P4factory ReadMe 剩余部分

    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_name
    make 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/switch
    
    make 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
    

    跑的时候出现了错误:

    好吧,解决方法说依赖关系重叠,我只好重新安装了下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 <p4 code>
    

    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

  • 相关阅读:
    轻量级Spring定时任务(Spring-task)
    Mysql语句优化建议
    python时间日期处理
    subprocess
    Tkinter初体验
    java基础
    java JVM
    NFV
    java加载properties文件的六种方法总结
    悲观锁和乐观锁的区别
  • 原文地址:https://www.cnblogs.com/qq952693358/p/5903754.html
Copyright © 2011-2022 走看看