1.解压安装OpenDayLight控制器(本次实验统一使用Beryllium版本)
①配置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
下载安装该版本
注:当时配置环境没有修改相应路径,之后的实验中发现没有安装相应jdk环境,故之后的实验在虚拟机镜像中完成
2.启动并安装插件
安装代码
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
(安装图片)
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() ) }
命令运行sudo mn --custom (名称要记得改).py --topo mytopo --controller=remote,ip=127.0.0.1,port=6633 --switch ovsk,protocols=OpenFlow13
(运行截图)
用pingall测试主机之间的连通性
(连通性截图)
打开ODL,reload
(控制器端的拓扑图)
4.在控制器提供的WEB UI中下发流表使h2 20s内ping不通h3,20s后恢复
下发流表设置过程
(图)
查询链路连接情况
(运行links截图)
h1 ping h3,发生延时
(图)
5.借助Postman通过OpenDayLight的北向接口下发流表,再利用OpenDayLight北向接口查看已下发的流表
安装运行postman,下发流表json格式
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" }, "priority": "65535", "hard-timeout": "25", "cookie": "2", "table_id": "0" } ] }
将preview的url复制到地址栏,输入odl的默认账号和密码admin
(图)
将preview的消息粘贴在文本框中,修改id和url里的flow为2,防止与之前的流表重合,点击send后下发成功,然后改为GET并send查看刚下发的流表
(图)
get查看下发流表
(图)