美文网首页
mininet自定义多控制器网络

mininet自定义多控制器网络

作者: 铛铛铛铛铛_9003 | 来源:发表于2018-03-12 15:28 被阅读0次

    以下是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()

    相关文章

      网友评论

          本文标题:mininet自定义多控制器网络

          本文链接:https://www.haomeiwen.com/subject/wgkufftx.html