ubuntu16.04中如何启用floodlight的其中一种方式

时间:2021-07-29 13:25:18

1. 提前一台安装好mininet,另一台安装好floodlight

2. 在mininet里面的custom文件夹下自定义文件ProjectGroup10_Topology.py

from mininet.node import CPULimitedHost, Host, Node
from mininet.node import OVSKernelSwitch
from mininet.topo import Topo class fatTreeTopo(Topo): "Fat Tree Topology" def __init__(self):
"Create Fat tree Topology" Topo.__init__(self) #Add hosts
h7 = self.addHost('h7', cls=Host, ip='10.0.0.7', defaultRoute=None)
h8 = self.addHost('h8', cls=Host, ip='10.0.0.8', defaultRoute=None)
h1 = self.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None)
h2 = self.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None)
h4 = self.addHost('h4', cls=Host, ip='10.0.0.4', defaultRoute=None)
h3 = self.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None)
h5 = self.addHost('h5', cls=Host, ip='10.0.0.5', defaultRoute=None)
h6 = self.addHost('h6', cls=Host, ip='10.0.0.6', defaultRoute=None)
h9 = self.addHost('h9', cls=Host, ip='10.0.0.9', defaultRoute=None)
h10 = self.addHost('h10', cls=Host, ip='10.0.0.10', defaultRoute=None)
h11 = self.addHost('h11', cls=Host, ip='10.0.0.11', defaultRoute=None)
h12 = self.addHost('h12', cls=Host, ip='10.0.0.12', defaultRoute=None) #Add switches
s10 = self.addSwitch('s10', cls=OVSKernelSwitch)
s3 = self.addSwitch('s3', cls=OVSKernelSwitch)
s17 = self.addSwitch('s17', cls=OVSKernelSwitch)
s4 = self.addSwitch('s4', cls=OVSKernelSwitch)
s18 = self.addSwitch('s18', cls=OVSKernelSwitch) s1 = self.addSwitch('s1', cls=OVSKernelSwitch)
s11 = self.addSwitch('s11', cls=OVSKernelSwitch)
s21 = self.addSwitch('s21', cls=OVSKernelSwitch)
s22 = self.addSwitch('s22', cls=OVSKernelSwitch)
s2 = self.addSwitch('s2', cls=OVSKernelSwitch)
s5 = self.addSwitch('s5', cls=OVSKernelSwitch)
s6 = self.addSwitch('s6', cls=OVSKernelSwitch)
s7 = self.addSwitch('s7', cls=OVSKernelSwitch)
s8 = self.addSwitch('s8', cls=OVSKernelSwitch) #Add links
self.addLink(h1, s1)
self.addLink(h2, s1)
self.addLink(h3, s2)
self.addLink(h4, s2)
self.addLink(h5, s3)
self.addLink(h6, s3)
self.addLink(h7, s4)
self.addLink(h8, s4)
self.addLink(s1, s21)
self.addLink(s21, s2)
self.addLink(s1, s10)
self.addLink(s2, s10)
self.addLink(s3, s11)
self.addLink(s4, s22)
self.addLink(s11, s4)
self.addLink(s3, s22)
self.addLink(s21, s17)
self.addLink(s11, s17)
self.addLink(s10, s18)
self.addLink(s22, s18)
self.addLink(s5, s22)
self.addLink(s5, s18)
self.addLink(s6, s11)
self.addLink(s6, s17)
self.addLink(h9, s5)
self.addLink(h10, s6)
self.addLink(s3, s7)
self.addLink(s18, s7)
self.addLink(s8, s4)
self.addLink(s8, s17)
self.addLink(h11, s7)
self.addLink(h12, s8) topos = { 'mytopo': (lambda: fatTreeTopo() ) }

3. 进入装好floodlight的虚拟机界面

4. 进入floodlight文件夹下,启动floodlight

sudo java -jar target/floodlight.jar

5. 在浏览器打开http://localhost:8080/ui/index.html

6. 进入装mininet的custom文件夹下,执行 sudo su  进入root下,再执行

mn --custom ProjectGroup10_Topology.py --topo mytopo --controller=remote,ip=192.168.72.135,port= --switch ovsk,protocols=OpenFlow10

ubuntu16.04中如何启用floodlight的其中一种方式

看到 Adding controller,就确定已经连接上floodlight控制器了

ps:ip是你装floodlight那台虚拟机的ip地址,用 ifconfig 命令可以查到

ubuntu16.04中如何启用floodlight的其中一种方式

7. 执行完此命令在安装floodlight的虚拟机的浏览器上输入 ,看看实际效果

http://localhost:8080/ui/index.html

ubuntu16.04中如何启用floodlight的其中一种方式

8. 进入switch,看看有没有交换机接入

ubuntu16.04中如何启用floodlight的其中一种方式