mininet自定义多控制器网络

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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • *面试心声:其实这些题本人都没怎么背,但是在上海 两周半 面了大约10家 收到差不多3个offer,总结起来就是把...
    Dove_iOS阅读 27,217评论 30 472
  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,452评论 0 10
  • 听音乐看视频阅读 184评论 0 0
  • 1.做过项目里面印象最深或对自己帮助最大的是哪个?具体成长是什么? 2.最近在看什么书? 3.api是如何工作的?...
    我在太行山下阅读 251评论 0 0
  • 这是一个神奇的故事,纯属大脑破洞! 这天,我照样打开《王者荣耀》app开黑,看着刺客阿珂一次又一次斩...
    菜包pangkai阅读 186评论 0 0