ONOS未检测到使用Mininet创建的网络中具有多个链接的主机

时间:2017-06-08 19:14:43

标签: mininet openflow openvswitch onos

我是Mininet和ONOS的新手,所以我遇到了很简单的事情。在这种情况下,我在Mininet中创建了以下拓扑。

Mininet topology

生成的脚本如下。

#!/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 topology

我不知道是否必须在脚本或ONOS中更改某些内容。我希望得到一个简单而循序渐进的答案,因为正如我所说,我对这项技术非常陌生。

非常感谢你的帮助。

已编辑********************************************** ************************************************** **************

我在每台主机上编辑了第二个接口,并为其提供了ifconfig hx-eth1 10.0.0.x的IP地址,但这并没有解决问题。 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')

1 个答案:

答案 0 :(得分:0)

ONOS具有检测主机的应用程序,此应用程序基于ARP和DHCP数据包工作,因此您需要执行诸如ping这些主机之间的操作,然后这些主机出现在ONOS拓扑中(以显示拓扑面板上的主机使用shift + H)。

默认情况下,mininet在每个主机上选择一个接口并分配一个IP地址,这样如果一个主机有多个接口,那么mininet只会自动为其中一个接口分配一个接口。您必须使用ifconfig等命令手动配置其他接口。

h1 = net.addHost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/24' )
s4 = net.addSwitch( 's4', listenPort=6673, mac='00:00:00:00:00:04' )
s5 = net.addSwitch( 's5', listenPort=6674, mac='00:00:00:00:00:05' )
Link(h1, s4, intfName1='h1-eth0')
Link(h1, s5, intfName1='h1-eth1')
h1.cmd('ifconfig h1-eth1 10.0.10.1 netmask 255.255.255.0')