SDN第二次上机作业
1、安装floodlight
参考链接:http://www.sdnlab.com/19189.html
2、生成拓扑并连接控制器floodlight,利用控制器floodlight查看图形拓扑
拓扑如图所示
mininet-floodnight控制器生成截图:
#!/usr/bin/python
"""Custom topology example
Adding the 'topos' dict with a key/value pair to generate our newly defined
topology enables one to pass in '--topo=mytopo' from the command line.
"""
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 ):
"Simple topology example."
def __init__( self ):
"Create custom topo."
# Initialize topology
Topo.__init__( self )
L1 = 1
L2 = L1 * 3
c = []
e = []
# add core ovs
for i in range( L1 ):
sw = self.addSwitch( 'c{}'.format( i + 1 ) )
c.append( sw )
# add edge ovs
for i in range( L2 ):
sw = self.addSwitch( 'e{}'.format( L1 + i + 1 ) )
e.append( sw )
# add links between core and aggregation ovs
for i in range( L1 ):
sw1 = c[i]
for sw2 in e:
# self.addLink(sw2, sw1, bw=10, delay='5ms', loss=10, max_queue_size=1000, use_htb=True)
self.addLink( sw2, sw1 )
#add hosts and its links with edge ovs
count = 1
for sw1 in e:
host = self.addHost( 'h{}'.format( count ) )
self.addLink( sw1, host )
count += 1
topos = { 'mytopo': ( lambda: MyTopo() ) }
测试连通性:
步骤:
-
启动floodnight
在floodnight目录下
java -jar target/floodlight.jar
-
编写自定义拓扑python脚本,用mininet生成并连接远程控制器floodnight,ip为控制器所在主机的ip地址。
sudo mn --custom ~/mininet/demo.py --topo mytopo --controller=remote,ip=192.168.188.129,port=6653 --switch ovsk,protocols=OpenFlow10
3、利用字符界面下发流表,使得‘h1’和‘h2’ ping 不通
参考链接:http://www.sdnlab.com/19394.html
拓扑连通性
流表截图
4、利用字符界面下发流表,通过测试‘h1’和‘h3’的联通性,来验证openflow的hardtime机制
流表项的删除既可以通过交换机的超时删除,也可以通过控制器发送删除请求实现。交换机的流超时机制通过在流表项中设置idle_time(空闲超时)和hard_timeout(硬超时)。
Idle_time如果设置为非零值,那么当该流表在idle_time中设置的时间内没有数据包与之匹配,则该流表项超时被交换机删除;hard_time如果设置为非0值,那么当该条流表交换机中
的时间超过hard_time中设置的值,则该流表超时被交换机删除。
初始连通性
下发具有hardtime的流表,设置60S后h1和h3才能通
测试结果