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

ONOS not detecting hosts with multiple links in network created using Mininet

我是 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')

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')