博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
P4factory <Integration with Mininet>
阅读量:5890 次
发布时间:2019-06-19

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

在终端A进入simple_router目录,make bm之后,执行

./run_demo.bash

成功和Mininet进行协作:

*** Creating network*** Adding hosts:h1 h2 *** Adding switches:s1 *** Adding links:(h1, s1) (h2, s1) *** Configuring hostsh1 h2 *** Starting controller*** Starting 1 switchess1 Starting P4 switch s1/home/sdn/p4factory/targets/simple_router/behavioral-model --name s1 --dpid 0000000000000001 -i s1-eth1 -i s1-eth2 --listener 127.0.0.1:11111 --pd-server 127.0.0.1:22222 switch has been started**********h1default interface: eth0 10.0.0.10   00:04:00:00:00:00********************h2default interface: eth0 10.0.1.10   00:04:00:00:00:01**********Ready !*** Starting CLI:mininet>

同时,打开另外一个终端B,进入相同目录,安装下流表:

Inserted entry with handle 0Inserted entry with handle 1Inserted entry with handle 0Inserted entry with handle 1Inserted entry with handle 0Inserted entry with handle 1

在终端A下执行pingall命令及h1 ping h2命令:

mininet> pingall*** Ping: testing ping reachabilityh1 -> h2 h2 -> h1 *** Results: 0% dropped (2/2 received)mininet> h1 ping h2PING 10.0.1.10 (10.0.1.10) 56(84) bytes of data.64 bytes from 10.0.1.10: icmp_seq=1 ttl=63 time=0.361 ms64 bytes from 10.0.1.10: icmp_seq=2 ttl=63 time=0.577 ms64 bytes from 10.0.1.10: icmp_seq=3 ttl=63 time=0.488 ms64 bytes from 10.0.1.10: icmp_seq=4 ttl=63 time=0.321 ms64 bytes from 10.0.1.10: icmp_seq=5 ttl=63 time=0.481 ms^C--- 10.0.1.10 ping statistics ---5 packets transmitted, 5 received, 0% packet loss, time 4000msrtt min/avg/max/mdev = 0.321/0.445/0.577/0.095 msmininet>

成功!

附simple_router p4src内容:

simple_router.p4:

/*Copyright 2013-present Barefoot Networks, Inc. Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at    http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.*/#include "includes/headers.p4"#include "includes/parser.p4"action _drop() {    drop();}header_type routing_metadata_t {    fields {        nhop_ipv4 : 32;    }}metadata routing_metadata_t routing_metadata;action set_nhop(nhop_ipv4, port) {    modify_field(routing_metadata.nhop_ipv4, nhop_ipv4);    modify_field(standard_metadata.egress_spec, port);    add_to_field(ipv4.ttl, -1);}table ipv4_lpm {    reads {        ipv4.dstAddr : lpm;    }    actions {        set_nhop;        _drop;    }    size: 1024;}action set_dmac(dmac) {    modify_field(ethernet.dstAddr, dmac);}table forward {    reads {        routing_metadata.nhop_ipv4 : exact;    }    actions {        set_dmac;        _drop;    }    size: 512;}action rewrite_mac(smac) {    modify_field(ethernet.srcAddr, smac);}table send_frame {    reads {        standard_metadata.egress_port: exact;    }    actions {        rewrite_mac;        _drop;    }    size: 256;}control ingress {    apply(ipv4_lpm);    apply(forward);}control egress {    apply(send_frame);}

headers.p4:

/*Copyright 2013-present Barefoot Networks, Inc. Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at    http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.*/header_type ethernet_t {    fields {        dstAddr : 48;        srcAddr : 48;        etherType : 16;    }}header_type ipv4_t {    fields {        version : 4;        ihl : 4;        diffserv : 8;        totalLen : 16;        identification : 16;        flags : 3;        fragOffset : 13;        ttl : 8;        protocol : 8;        hdrChecksum : 16;        srcAddr : 32;        dstAddr: 32;    }}

parser.p4:

/*Copyright 2013-present Barefoot Networks, Inc. Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at    http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.*/parser start {    return parse_ethernet;}#define ETHERTYPE_IPV4 0x0800header ethernet_t ethernet;parser parse_ethernet {    extract(ethernet);    return select(latest.etherType) {        ETHERTYPE_IPV4 : parse_ipv4;        default: ingress;    }}header ipv4_t ipv4;field_list ipv4_checksum_list {        ipv4.version;        ipv4.ihl;        ipv4.diffserv;        ipv4.totalLen;        ipv4.identification;        ipv4.flags;        ipv4.fragOffset;        ipv4.ttl;        ipv4.protocol;        ipv4.srcAddr;        ipv4.dstAddr;}field_list_calculation ipv4_checksum {    input {        ipv4_checksum_list;    }    algorithm : csum16;    output_width : 16;}calculated_field ipv4.hdrChecksum  {    verify ipv4_checksum;    update ipv4_checksum;}parser parse_ipv4 {    extract(ipv4);    return ingress;}

2016/10/14

转载地址:http://hnfsx.baihongyu.com/

你可能感兴趣的文章
动态SQL实现与注意事项(有返回值与无返回值动态SQL 实现)
查看>>
java struts2 debug
查看>>
简单够用的设计
查看>>
Android图片圆角效果
查看>>
WeChat Official Account Admin Platform API Introduction
查看>>
C语言写单链表的创建、释放、追加(即总是在最后的位置增加节点)
查看>>
poj1635
查看>>
C# LINQ详解(一)
查看>>
视频直播点播nginx-rtmp开发手册中文版
查看>>
ruby学习总结04
查看>>
Binary Tree Paths
查看>>
Ueditor自定义ftp上传
查看>>
线程以及多线程
查看>>
PHP队列的实现
查看>>
单点登录加验证码例子
查看>>
[T-SQL]从变量与数据类型说起
查看>>
稀疏自动编码之反向传播算法(BP)
查看>>
二叉搜索树转换成双向链表
查看>>
WebLogic和Tomcat的区别
查看>>
java类中 获取服务器的IP 端口
查看>>