Search code examples
mininetopenflowopenvswitchonos

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


I am new with Mininet and ONOS, so I have trouble with really simple things. In this case, I have created the following topology in Mininet.

Mininet topology

The script that is generated is the following.

#!/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()

But then, ONOS displays the following topology.

ONOS topology

I don't know if I have to change something in the script or in ONOS. I would appreciate a simple and step by step answer, because, as I said, I am really new with this technology.

Thank you very much for your help.

EDITED **************************************************************************************************************

I edited the second interface on each host and gave them an IP address with ifconfig hx-eth1 10.0.0.x, but this didn't solve the problem. The topology in ONOS looks exactly the same. Here's the code that I added to the Python script.

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

Solution

  • ONOS has application for detecting hosts and this application works based on ARP and DHCP packets so you need to do things like ping these hosts with each other and then these hosts appear on your ONOS topology (to show hosts on your topology panel use shift + H).

    By default, mininet chooses a single interface on each host and assigns an IP address so if a host has multiple interfaces, then mininet will only auto assign an interface to one of them. You must configure the other interface manually with commands like 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')