实验4:开源控制器实践——OpenDaylight

实验4:开源控制器实践——OpenDaylight

搭建拓扑

sudo mn --topo=single,3 --mac --controller=remote,ip=127.0.0.1,port=6633 --switch ovsk,protocols=OpenFlow13

执行pingall,后在ODL中查看拓扑,截图如下

image-20210929200849402

Postman下发流表

通过Postman请求Restful API,进行流表下发

url:http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/flow-node-inventory:table/0/flow/1

json:

{
    "flow": [
        {
            "id": "1",
            "match": {
                "in-port": "1",
                "ethernet-match": {
                    "ethernet-type": {
                        "type": "0x0800"
                    }
                },
                "ipv4-destination": "10.0.0.3/32"
            },
            "instructions": {
                "instruction": [
                    {
                        "order": "0",
                        "apply-actions": {
                            "action": [
                                {
                                    "order": "0",
                                    "drop-action": {}
                                }
                            ]
                        }
                    }
                ]
            },
            "flow-name": "flow1",
            "priority": "65535",
            "hard-timeout": "10",
            "cookie": "2",
            "table_id": "0"
        }
    ]
}

检查h1和h3连通性,截图如下:

image-20210929201959665

整理和记录主要API文档

获取拓扑的交换机

url:http://127.0.0.1:8181/apidoc/explorer/index.html#!/network-topology(2013-10-21)/GET_network_topology_get_183

image-20210929204348319

流表 增删改查

url:http://127.0.0.1:8181/apidoc/explorer/index.html#!/opendaylight-inventory(2013-08-19)/GET_flow_get_204

image-20210929205441366

获取特定交换机端口的状态

url:http://127.0.0.1:8181/apidoc/explorer/index.html#!/opendaylight-port-statistics(2013-12-14)/get_node_connector_statistics_post_0

image-20210929204824999

获取指定交换机信息

url:http://127.0.0.1:8181/apidoc/explorer/index.html#!/opendaylight-inventory(2013-08-19)/GET_node_get_5

image-20210929205952549

总结

这次实验的难度主要在于Java和ODL的环境安装,遇到一些bug,如直接粘贴老师的命令,被吞掉一个空格而不能成功安装;pip使用国外源网络断开导致安装失败,修改使用清华镜像源,最后安装Ryu成功。在实验中,通过总结以往解决问题的经验,加上搜索一些资料,做到较快的问题的定位,提高自己解决问题的能力。经过实验观察到ODL十分消耗CPU的资源,在虚拟机运行ODL时,主机变得十分卡顿,所以实验宜快速完成,避免因为操作不畅而导致效率降低。在之后的实验,要考虑如何使用Java进行编程。通过ODL实现网络的可编程。

原文地址:https://www.cnblogs.com/JoshuaYu/p/15354480.html