Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何为EasyRoute协议编写P4程序?_Python_Json - Fatal编程技术网

Python 如何为EasyRoute协议编写P4程序?

Python 如何为EasyRoute协议编写P4程序?,python,json,Python,Json,我正在尝试实现一个Easyroute协议。上面的github repo中给出了一个框架程序。但由于我是P4语言的新手,我需要帮助在github存储库上编写这个框架程序 任何人谁已经编写和实施上述任务可以帮助我张贴所需的P4计划 骨架程序如下所示: /* Copyright 2013-present Barefoot Networks, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may n

我正在尝试实现一个Easyroute协议。上面的github repo中给出了一个框架程序。但由于我是P4语言的新手,我需要帮助在github存储库上编写这个框架程序

任何人谁已经编写和实施上述任务可以帮助我张贴所需的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.0

Unless required by applicable law or agreed to in writing, software
distributed 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 and
limitations under the License.
*/

// TODO: define headers & header instances

parser start {
    // TODO
    return ingress;
}

// TODO: define parser states

action _drop() {
    drop();
}

action route() {
    modify_field(standard_metadata.egress_spec, /* TODO: port field from your header */);
    // TODO: update your header
}

control ingress {
    // TODO
}

control egress {
    // leave empty
}
可以使用3台交换机和3台主机创建Mininet环境进行测试。 [将自己放在源路由目录中../run_demo.sh将编译代码并创建上述Mininet网络。它还将使用commands.txt配置每个交换机。一旦网络启动并运行,您应在Mininet CLI中键入以下内容:

xterm h1 xterm h3 这将在h1和h3上为您打开一个终端

h3运行时:./receive.py

在h1运行时:./send.py h1 h3

然后,您应该能够在h1上键入消息并在h3上接收它们。send.py程序使用Dijkstra查找h1和h3之间的最短路径,然后通过s1和s3将格式正确的数据包发送到h3]

在处给出的代码在action route()方法中缺少“port”参数。下面给出了正确的代码。只需在p4代码文件中进行此小更改,然后执行在中给出的教程中提到的步骤


所有来自赤脚网络、普林斯顿大学、布拉德福德大学和任何热心P4程序员的优秀人士都希望能回答这个问题。到底为什么有人要花时间在你的任务上?给我们展示一些努力。否则请人来做这项工作……哈哈。。。。。所以这不是一个培训/教学网站。堆栈溢出不是一个我们为您做作业的服务。自己尝试一些东西,如果你有一个特定的问题,你可以问它。请阅读和。而不是添加URL和说“代码给出在”请添加代码在这里你的问题本身。
//this code is available to use under Apache License on github
    header_type easyroute_head_t {
        fields {
            preamble: 64;
                //preambe is always set to zero, that is used 
                //to identify easyrout packets from other packets.
            num_valid: 32;
    //indicates the number of valid ports in header
        }
    }
    header easyroute_head_t easyroute_head;
    header_type easyroute_port_t
     {
        fields {
            port: 8;
        }
    }
    header easyroute_port_t easyroute_port;
    parser start
     {
        return select(current(0, 64))
           //call to current is used to examine the 1st 64 bits
     {
            0: parse_head;
            default: ingress;
        }
    }
    parser parse_head 
    {
        extract(easyroute_head);
        return select(latest.num_valid)
     {
            0: ingress;
            default: parse_port;
        }

    }

    parser parse_port {
        extract(easyroute_port);
        return ingress;
    }
    action _drop()
     {
        drop();
    }
    action route()
     {
        modify_field(standard_metadata.egress_spec, easyroute_port.port);
        add_to_field(easyroute_head.num_valid, -1);
        remove_header(easyroute_port);
                //update header, call to remove header for removing header
    }
    table route_pkt
     {
        reads
     {
            easyroute_port: valid;
        }
        actions
     {
            _drop;
            route;
        }
        size: 1;
    }
    control ingress 
    {
        apply(route_pkt);
          //route_pkt is the table
    }
    control egress
     {
    }
 /*
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.0

Unless required by applicable law or agreed to in writing, software
distributed 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 and
limitations under the License.
*/

// TODO: define headers & header instances

parser start {
    // TODO
    return ingress;
}

// TODO: define parser states

action _drop() {
    drop();
}

action route(port) {
    modify_field(standard_metadata.egress_spec, port);
    // TODO: update your header
}

control ingress {
    // TODO
}

control egress {
    // leave empty
}