2019 SDN上机第4次作业
1. 解压安装OpenDayLight控制器(本次实验统一使用Beryllium版本)
2. 启动并安装插件
3. 用Python脚本搭建如下拓扑,连接OpenDayLight控制器
Python代码:
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import RemoteController,CPULimitedHost
from mininet.link import TCLink
from mininet.util import dumpNodeConnections
class MyTopo( Topo ):
def __init__( self ):
Topo.__init__( self )
s1=self.addSwitch('s1')
for i in range(1,4):
hw = self.addHost( 'h{}'.format( i ) )
self.addLink(hw,s1)
topos = { 'mytopo': ( lambda: MyTopo() ) }
运行结果:
pingall:
拓扑图
4. 在控制器提供的WEB UI中下发流表使h2 20s内ping不通h3,20s后恢复
结果:
5. 借助Postman通过OpenDayLight的北向接口下发流表,再利用OpenDayLight北向接口查看已下发的流表。
通过preview查看刚才下发的流表
http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/1/flow-node-inventory:table/0/flow/1
{
"flow": [
{
"id": "1",
"match": {
"in-port": "2",
"ipv4-destination": "10.0.0.3/32"
},
"instructions": {
"instruction": [
{
"order": "0",
"apply-actions": {
"action": [
{
"order": "0",
"drop-action": {}
}
]
}
}
]
},
"flow-name": "flow3",
"priority": "65535",
"hard-timeout": "20",
"cookie": "4",
"table_id": "0"
}
]
}
将preview里的url复制到地址栏,消息方式选PUT
IP为控制器所在的PC的IP
type选择Basic Auth
Body中将消息格式设置成json,上传方式设置为raw
更改id
点击send后下发
将消息方式改为get