mininet自定义多控制器网络

2018-03-12  本文已影响0人  铛铛铛铛铛_9003

以下是mininet多控制器网络运行脚本,是根据mininet提供的example中controllers.py改写的。

from mininet.net import Mininet

from mininet.node import OVSSwitch, Controller, RemoteController

from mininet.topolib import TreeTopo

from mininet.log import setLogLevel

from mininet.cli import CLI        

setLogLevel( 'info' )

# Two local and one "external" controller (which is actually c0)

# Ignore the warning message that the remote isn't (yet) running

c0 = RemoteController( 'c0', ip='10.108.48.160')

c1 = RemoteController( 'c1', ip='10.108.50.78')

c2 = RemoteController( 'c2', ip='10.108.48.240' )

cmap = { 's1': c0, 's2': c1, 's1': c2, 's3':c1 }

class MultiSwitch( OVSSwitch ):

    "Custom Switch() subclass that connects to different controllers"

    def start( self, controllers ):

        return OVSSwitch.start( self, [ cmap[ self.name ] ] )

topo = TreeTopo( depth=2, fanout=2 )

net = Mininet( topo=topo, switch=MultiSwitch, build=False )

for c in [ c1, c2  ]:

    net.addController(c)

net.build()

net.start()

CLI( net )

net.stop()

上一篇下一篇

猜你喜欢

热点阅读