2019 SDN上机第4次作业
1. 解压安装OpenDayLight控制器(本次实验统一使用Beryllium版本)
OpenDayLight是java实现的,因此需要先配置java环境
解压相关文件,运行下列命令,进行环境配置
sudo gedit ~/.bashrc
将下列路径加到所打开得文件内
export JAVA_HOME=/usr/local/java/jdk1.8.0_201
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
2. 启动并安装插件
将压缩文件解压
进入解压文件的bin文件下
运行下列命令
./karaf
安装插件
opendaylight-user@root>feature:install odl-restconf
opendaylight-user@root>feature:install odl-l2switch-switch-ui
opendaylight-user@root>feature:install odl-openflowplugin-all
opendaylight-user@root>feature:install odl-mdsal-apidocs
opendaylight-user@root>feature:install odl-dlux-core
opendaylight-user@root>feature:install odl-dlux-node
opendaylight-user@root>feature:install odl-dlux-yangui
在浏览器中输入开启ui界面
http://127.0.0.1:8181/index.html
用户名和密码均为admin
3. 用Python脚本搭建如下拓扑,连接OpenDayLight控制器
python代码
from mininet.topo import Topo
class MyTopo( Topo ):
"Simple topology example."
def __init__( self ):
Topo.__init__(self)
sw1 = self.addSwitch('s1')
h1 = self.addHost('h1')
h2 = self.addHost('h2')
h3 = self.addHost('h3')
self.addLink(h1,sw1,1,1)
self.addLink(h2,sw1,1,2)
self.addLink(h3,sw1,1,3)
topos = { 'mytopo': ( lambda: MyTopo() ) }
执行下列命令,建立拓扑
sudo mn --custom 1.py --topo mytopo --controller=remote,ip=127.0.0.1,port=6633 --switch ovsk,protocols=OpenFlow13
使用pingall查看连接情况
控制器端的拓扑图
4. 在控制器提供的WEB UI中下发流表使h2 20s内ping不通h3,20s后恢复
使用links查找端口
进入ODL修改下发流表
修改后运行h2 ping h3,发送流表
5. 借助Postman通过OpenDayLight的北向接口下发流表,再利用OpenDayLight北向接口查看已下发的流表。
解压文件
进入文件打开终端运行下列命令
./Postman
在ODL显示下发流表
http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/flow-node-inventory:table/0/flow/100
{
"flow": [
{
"id": "100",
"match": {
"in-port": "2",
"ethernet-match": {
"ethernet-type": {
"type": "0x0800"
}
},
"ipv4-destination": "10.0.0.3/32"
},
"instructions": {
"instruction": [
{
"order": "0",
"apply-actions": {
"action": [
{
"order": "0",
"drop-action": {}
}
]
}
}
]
},
"priority": "65535",
"hard-timeout": "20",
"table_id": "0"
}
]
}
设置Postmam
使用put下发流表
使用get的到下发的流表