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

(一)基本要求

1.利用Mininet平台搭建下图所示网络拓扑,并连接OpenDaylight控制器;


2.通过Postman工具调用OpenDaylight提供的API下发流表,实现拓扑内主机h1和h3网络中断10s

1)清除旧的流规则(标识为openflow:1的交换机)
动作:
DELETE
URL:
http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/

清除Mininet
sudo mn -c
2)使用Postman模拟http请求下发硬超时流规则
· idle timeout:软超时,如果值为非0,那么在对应的时间内如果没有数据包匹配,时间到
该流规则将被删除;值为0不设软超时机制。
·hard timeout:硬超时,如果值为非0,那么在对应的时间内不论是否有数据包匹配,时
间到流规则都会被删除;值为0不设硬超时机制。
SDNLAB文章:OpenFlow协议超时机制简介 https://www.sdnlab.com/22563.html
动作:
PUT
URL:
http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/flow-node-inventory:table/0/flow/1/

输入代码:

{
"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"
}
]
}

(二)进阶要求

查找资料,整理和记录ODL控制器主要的REST API文档,包括但不限于ODL提供的文档链接,获取拓扑的交换机、获取流表状态数量、获取特定交换机端口的状态、新增修改和删除流表等。
ODL的官方文档Rest API获取网址:http://127.0.0.1:8181/apidoc/explorer/index.html(账号密码均为admin
获取拓扑的交换机

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

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

获取拓扑结构

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

http://127.0.0.1:8181/apidoc/explorer/index.html#!/network-topology(2013-07-12)

流表信息(增删改查)

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

拓扑信息

http://127.0.0.1:8181/apidoc/explorer/index.html#!/network-topology(2013-07-12)

节点信息

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

拓扑链路信息

http://127.0.0.1:8181/apidoc/explorer/index.html#!/network-topology(2013-07-12)/GET_link_get_82


个人总结:
本次实验难度不大,在基本要求Mininet平台搭建网络拓扑时需要先进行pingall在ODL中才会显示拓扑
如果ping不通要sudo mn -c将拓扑清除再重新搭建拓扑,否则会一直ping不通
实验中对Postman的操作不太熟练,老师发的文件里有详细的操作流程
先在Mininet CLI中运行h1 ping h3,再在Postman处选择动作PUT
使用Postman模拟http请求下发硬超时流规则时要将流表修改成JSON模式,否则p1 ping p3无法间隔十秒

posted @ 2022-10-13 10:56  一坨奶酪  阅读(88)  评论(0)    收藏  举报