我是 Mininet 和 ONOS 的新手,所以我在处理非常简单的事情时遇到了麻烦。在这种情况下,我在 Mininet 中创建了以下拓扑。
生成的脚本如下。
#!/usr/bin/python
from mininet.net import Mininet
from mininet.node import Controller, RemoteController, OVSController
from mininet.node import CPULimitedHost, Host, Node
from mininet.node import OVSKernelSwitch, UserSwitch
from mininet.node import IVSSwitch
from mininet.cli import CLI
from mininet.log import setLogLevel, info
from mininet.link import TCLink, Intf
from subprocess import call
def myNetwork():
net = Mininet( topo=None,
build=False,
ipBase='10.0.0.0/8')
info( '*** Adding controller\n' )
c0=net.addController(name='c0',
controller=RemoteController,
protocol='tcp',
port=6633)
info( '*** Add switches\n')
s2 = net.addSwitch('s2', cls=OVSKernelSwitch)
s3 = net.addSwitch('s3', cls=OVSKernelSwitch)
s4 = net.addSwitch('s4', cls=OVSKernelSwitch)
s1 = net.addSwitch('s1', cls=OVSKernelSwitch)
info( '*** Add hosts\n')
h15 = net.addHost('h15', cls=Host, ip='10.0.0.15', defaultRoute=None)
h8 = net.addHost('h8', cls=Host, ip='10.0.0.8', defaultRoute=None)
h9 = net.addHost('h9', cls=Host, ip='10.0.0.9', defaultRoute=None)
h10 = net.addHost('h10', cls=Host, ip='10.0.0.10', defaultRoute=None)
h11 = net.addHost('h11', cls=Host, ip='10.0.0.11', defaultRoute=None)
h16 = net.addHost('h16', cls=Host, ip='10.0.0.16', defaultRoute=None)
h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None)
h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None)
h4 = net.addHost('h4', cls=Host, ip='10.0.0.4', defaultRoute=None)
h12 = net.addHost('h12', cls=Host, ip='10.0.0.12', defaultRoute=None)
h5 = net.addHost('h5', cls=Host, ip='10.0.0.5', defaultRoute=None)
h13 = net.addHost('h13', cls=Host, ip='10.0.0.13', defaultRoute=None)
h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None)
h6 = net.addHost('h6', cls=Host, ip='10.0.0.6', defaultRoute=None)
h14 = net.addHost('h14', cls=Host, ip='10.0.0.14', defaultRoute=None)
h7 = net.addHost('h7', cls=Host, ip='10.0.0.7', defaultRoute=None)
info( '*** Add links\n')
net.addLink(h1, s1)
net.addLink(h2, s1)
net.addLink(h3, s1)
net.addLink(h4, s1)
net.addLink(h5, s1)
net.addLink(h6, s1)
net.addLink(h7, s1)
net.addLink(h8, s1)
net.addLink(h9, s1)
net.addLink(h10, s1)
net.addLink(h1, s2)
net.addLink(h2, s2)
net.addLink(h3, s2)
net.addLink(h4, s2)
net.addLink(h5, s2)
net.addLink(h6, s2)
net.addLink(h7, s2)
net.addLink(h8, s2)
net.addLink(h9, s2)
net.addLink(h10, s2)
net.addLink(h11, s3)
net.addLink(h12, s3)
net.addLink(h13, s3)
net.addLink(s4, h14)
net.addLink(s4, h15)
net.addLink(s4, h16)
net.addLink(s1, s3)
net.addLink(s2, s4)
info( '*** Starting network\n')
net.build()
info( '*** Starting controllers\n')
for controller in net.controllers:
controller.start()
info( '*** Starting switches\n')
net.get('s2').start([c0])
net.get('s3').start([c0])
net.get('s4').start([c0])
net.get('s1').start([c0])
info( '*** Post configure switches and hosts\n')
CLI(net)
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
myNetwork()
但是,ONOS 显示以下拓扑。
我不知道我是否必须更改脚本或 ONOS 中的某些内容。我将不胜感激一个简单而逐步的答案,因为正如我所说,我对这项技术真的很陌生。
非常感谢您的帮助。
已编辑 ************************************************* ****************************************************** ***********
我编辑了每台主机上的第二个接口,并为它们提供了一个 IP 地址ifconfig hx-eth1 10.0.0.x
,但这并没有解决问题。ONOS 中的拓扑看起来完全一样。这是我添加到 Python 脚本中的代码。
h1.cmd('ifconfig h1-eth1 10.0.0.17')
h2.cmd('ifconfig h2-eth1 10.0.0.18')
h3.cmd('ifconfig h3-eth1 10.0.0.19')
h4.cmd('ifconfig h4-eth1 10.0.0.20')
h5.cmd('ifconfig h5-eth1 10.0.0.21')
h6.cmd('ifconfig h6-eth1 10.0.0.22')
h7.cmd('ifconfig h7-eth1 10.0.0.23')
h8.cmd('ifconfig h8-eth1 10.0.0.24')
h9.cmd('ifconfig h9-eth1 10.0.0.25')
h10.cmd('ifconfig h10-eth1 10.0.0.26')