김홍규
김홍규

Reputation: 21

How to add controller on mininet

Hi :) I'm a newbie on openflow & mininet.

I experiment my network. And I established my virtual network using mininet.

sudo mn

And on this existing network, I want to add one more controller. I heard

mininet> py net.addController('c1')

above code make my wish come true. But it is failed

'list' object is not callable

Other similar method is working well like py net.addHost('h3').

Is there solution to solve my problem or any other method to add controller dynamically on existing mininet?

Upvotes: 2

Views: 10061

Answers (1)

Dimitrios Mavrommatis
Dimitrios Mavrommatis

Reputation: 321

You should define the controller when you run the mn command. Try this

sudo mn --controller remote,ip=127.0.0.1

The commands that you write are for custom topologies written in python. For example you have topo.py file

from mininet.cli import CLI
from mininet.log import setLogLevel
from mininet.net import Mininet
from mininet.topo import Topo
from mininet.node import RemoteController, OVSSwitch

class MinimalTopo( Topo ):
    "Minimal topology with a single switch and two hosts"

    def build( self ):
        # Create two hosts.
        h1 = self.addHost( 'h1' )
        h2 = self.addHost( 'h2' )

        # Create a switch
        s1 = self.addSwitch( 's1' )

        # Add links between the switch and each host
        self.addLink( s1, h1 )
        self.addLink( s1, h2 )

def runMinimalTopo():
    "Bootstrap a Mininet network using the Minimal Topology"

    # Create an instance of our topology
    topo = MinimalTopo()

    # Create a network based on the topology using OVS and controlled by
    # a remote controller.
    net = Mininet(
        topo=topo,
        controller=lambda name: RemoteController( name, ip='127.0.0.1' ),
        switch=OVSSwitch,
        autoSetMacs=True )

    # Actually start the network
    net.start()

    # Drop the user in to a CLI so user can run commands.
    CLI( net )

    # After the user exits the CLI, shutdown the network.
    net.stop()

if __name__ == '__main__':
    # This runs if this file is executed directly
    setLogLevel( 'info' )
    runMinimalTopo()

# Allows the file to be imported using `mn --custom <filename> --topo minimal`
topos = {
    'minimal': MinimalTopo
}

and you run it like this

sudo mn --custom topo.py --topo minimal

Upvotes: 3

Related Questions