当前位置: 首页>>代码示例>>Python>>正文


Python Mininet.controllers方法代码示例

本文整理汇总了Python中mininet.net.Mininet.controllers方法的典型用法代码示例。如果您正苦于以下问题:Python Mininet.controllers方法的具体用法?Python Mininet.controllers怎么用?Python Mininet.controllers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mininet.net.Mininet的用法示例。


在下文中一共展示了Mininet.controllers方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: build

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import controllers [as 别名]
    def build( self ):
        print "Build network based on our topology."

        net = Mininet( topo=None, build=False, link=TCLink, ipBase=self.minieditIpBase )
 
        net.controllers = self.addControllers()
        
        # Make nodes
        print "Getting Hosts and Switches."
        for widget in self.widgetToItem:
            name = widget[ 'text' ]
            tags = self.canvas.gettags( self.widgetToItem[ widget ] )
            nodeNum = int( name[ 1: ] )
            if 'Switch' in tags:
                net.addSwitch( name )
            elif 'Host' in tags:
                ipBaseNum, prefixLen = netParse( self.minieditIpBase )
                ip = ipAdd(i=nodeNum, prefixLen=prefixLen, ipBaseNum=ipBaseNum)
                net.addHost( name, ip=ip )
            else:
                raise Exception( "Cannot create mystery node: " + name )

        # Make links
        print "Getting Links."
        for link in self.links.values():
            ( src, dst, linkopts ) = link
            srcName, dstName = src[ 'text' ], dst[ 'text' ]
            src, dst = net.nameToNode[ srcName ], net.nameToNode[ dstName ]
            net.addLink(src, dst, **linkopts)

        self.printInfo()
        # Build network (we have to do this separately at the moment )
        net.build()

        return net
开发者ID:Phi-Ho,项目名称:pyretic,代码行数:37,代码来源:miniedit-2.0.0.3.1.py

示例2: sdnnet

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import controllers [as 别名]
def sdnnet(opt):
    topo = SDNTopo()
    info( '*** Creating network\n' )
    #net = Mininet( topo=topo, controller=MyController, link=TCLink)
    net = Mininet( topo=topo, link=TCLink, build=False)
    controllers=[]
    for c in Controllers:
      rc = RemoteController('c%d' % Controllers.index(c), ip=c['ip'],port=c['port'])
      print "controller ip %s port %s" % (c['ip'], c['port'])
      controllers.append(rc)
  
    net.controllers=controllers
    net.build()

    host = []
    for i in range (NR_NODES):
      host.append(net.get( 'host%d' % i ))

    net.start()

    sw=net.get('sw03.00')
    print "center sw", sw
    sw.attach('tapc0')

    for i in range (NR_NODES):
        host[i].defaultIntf().setIP('192.168.%d.%d/16' % (NWID,i)) 
        host[i].defaultIntf().setMAC('00:00:00:00:%02x:%02x' % (NWID,i)) 

    for i in range (NR_NODES):
       for n in range (3):
         for h in range (10):
           host[i].setARP('192.168.%d.%d' % (n, h), '00:00:00:00:%02x:%02x' % (n,h)) 


    root = []
    for i in range (NR_NODES):
        root.append(net.get( 'root%d' % i ))

    for i in range (NR_NODES):
        host[i].intf('host%d-eth1' % i).setIP('1.1.%d.1/24' % i)
        root[i].intf('root%d-eth0' % i).setIP('1.1.%d.2/24' % i)

    stopsshd ()
    startsshds ( host )

    if opt=="cli":
        CLI(net)
        stopsshd()
        net.stop()
开发者ID:opennetworkinglab,项目名称:spring-open,代码行数:51,代码来源:net.sprint5.template.py

示例3: setup

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import controllers [as 别名]
def setup(argv):
    domains = []
    ctlsets = sys.argv[1:]

    # the controllers for the optical domain
    d0 = OpticalDomain()
    domains.append(d0)
    ctls = ctlsets[0].split(',')
    for i in range (len(ctls)):
        d0.addController('c0%s' % i, controller=RemoteController, ip=ctls[i])

    # the fabric domains - position 1 for domain 1, 2 for 2 ...
    for i in range (1,len(ctlsets)):
        f = FabricDomain(i)
        domains.append(f)
        ctls = ctlsets[i].split(',')
        for j in range (len(ctls)):
            f.addController('c%s%s' % (i,j), controller=RemoteController, ip=ctls[j])

    # make/setup Mininet object
    net = Mininet()
    for d in domains:
        d.build()
        d.injectInto(net)

    # connect COs to core - sort of hard-wired at this moment
    for i in range(1,len(domains)):
        an = { "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }
        net.addLink(domains[i].getTether(), d0.getSwitches('OE%s' % i),
                    port1=OVS_AP, port2=OE_AP, speed=10000, annotations=an, cls=LINCLink)

    # fire everything up
    net.build()
    map(lambda x: x.start(), domains)

    # create a minimal copy of the network for configuring LINC.
    cfgnet = Mininet()
    cfgnet.switches = net.switches
    cfgnet.links = net.links
    cfgnet.controllers = d0.getControllers()
    LINCSwitch.bootOE(cfgnet, d0.getSwitches())

    CLI(net)
    net.stop()
    LINCSwitch.shutdownOE()
开发者ID:Mohdrz,项目名称:Onos,代码行数:47,代码来源:metro.py

示例4: dict

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import controllers [as 别名]
leftTopSwitch  = net.addSwitch('s3')
rightTopSwitch = net.addSwitch('s4')

# Add links
# set link speeds to 10Mbit/s
linkopts = dict(bw=10)
net.addLink(leftHost1,  leftSwitch,    **linkopts )
net.addLink(leftHost2,  leftSwitch,    **linkopts )
net.addLink(rightHost1, rightSwitch,   **linkopts )
net.addLink(rightHost2, rightSwitch,   **linkopts )
net.addLink(leftSwitch, leftTopSwitch, **linkopts )
net.addLink(leftSwitch, rightTopSwitch,**linkopts )
net.addLink(rightSwitch,leftTopSwitch, **linkopts )
net.addLink(rightSwitch,rightTopSwitch,**linkopts )

# Start
net.controllers = [ c ]
net.build()
net.start()

# Enable sFlow
# 1-in-10 sampling rate for 10Mbit/s links is proportional to 1-in-1000 for 1G
# see http://blog.sflow.com/2013/02/sdn-and-large-flows.html
quietRun('ovs-vsctl -- [email protected] create sflow agent=eth0 target=127.0.0.1 sampling=10 polling=20 -- -- set bridge s1 [email protected] -- set bridge s2 [email protected] -- set bridge s3 [email protected] -- set bridge s4 [email protected]')

# CLI
CLI( net )

# Clean up
net.stop()
开发者ID:BenjaminUJun,项目名称:slick,代码行数:32,代码来源:multipath.py

示例5: setup

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import controllers [as 别名]
def setup(argv):
    domains = []
    ctlsets = sys.argv[1:]

    # the controllers for the optical domain
    d0 = OpticalDomain()
    domains.append(d0)
    ctls = ctlsets[0].split(',')
    for i in range (len(ctls)):
        d0.addController('c0%s' % i, controller=RemoteController, ip=ctls[i])

    # the fabric domains - position 1 for domain 1, 2 for 2 ...
    for i in range (1,len(ctlsets)):
        f = FabricDomain(i)
        domains.append(f)
        ctls = ctlsets[i].split(',')
        for j in range (len(ctls)):
            f.addController('c%s%s' % (i,j), controller=RemoteController, ip=ctls[j])

    # netcfg for each domains
    # Note: Separate netcfg for domain0 is created in opticalUtils
    domainCfgs = []
    for i in range (0,len(ctlsets)):
        cfg = {}
        cfg['devices'] = {}
        cfg['ports'] = {}
        cfg['links'] = {}
        domainCfgs.append(cfg)

    # make/setup Mininet object
    net = Mininet()
    for d in domains:
        d.build()
        d.injectInto(net)

    # connect COs to core - sort of hard-wired at this moment
    # adding cross-connect links
    for i in range(1,len(domains)):
        # add 10 cross-connect links between domains
        xcPortNo=2
        ochPortNo=10
        for j in range(0, 10):
            an = { "bandwidth": 10, "durable": "true" }
            net.addLink(domains[i].getTether(), d0.getSwitches('OE%s' % i),
                        port1=xcPortNo+j, port2=ochPortNo+j, speed=10000, annotations=an, cls=LINCLink)

            xcId = 'of:' + domains[i].getSwitches(name=domains[i].getTether()).dpid + '/' + str(xcPortNo+j)
            ochId = 'of:' + d0.getSwitches('OE%s' % i).dpid + '/' + str(ochPortNo+j)
            domainCfgs[i]['ports'][xcId] = {'cross-connect': {'remote': ochId}}

    # fire everything up
    net.build()
    map(lambda x: x.start(), domains)

    # create a minimal copy of the network for configuring LINC.
    cfgnet = Mininet()
    cfgnet.switches = net.switches
    cfgnet.links = net.links
    cfgnet.controllers = d0.getControllers()
    LINCSwitch.bootOE(cfgnet, d0.getSwitches())

    # send netcfg json to each CO-ONOS
    for i in range(1,len(domains)):
        info('*** Pushing Topology.json to CO-ONOS %d\n' % i)
        filename = 'Topology%d.json' % i
        with open(filename, 'w') as outfile:
            json.dump(domainCfgs[i], outfile, indent=4, separators=(',', ': '))

        output = quietRun('%s/tools/test/bin/onos-netcfg %s %s &'\
                           % (LINCSwitch.onosDir,
                              domains[i].getControllers()[0].ip,
                              filename), shell=True)
        # successful output contains the two characters '{}'
        # if there is more output than this, there is an issue
        if output.strip('{}'):
            warn('***WARNING: Could not push topology file to ONOS: %s\n' % output)

    CLI(net)
    net.stop()
    LINCSwitch.shutdownOE()
开发者ID:CrazyCooper,项目名称:onos,代码行数:82,代码来源:metro.py

示例6: info

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import controllers [as 别名]
info( '* Creating Control Network\n' )
ctopo = ControlNetwork( n=4, dataController=DataController )
cnet = Mininet( topo=ctopo, ipBase='192.168.123.0/24', build=False )
info( '* Adding Control Network Controller\n')
cnet.addController( 'cc0' )
info( '* Starting Control Network\n')
cnet.build()
cnet.start()
dataControllers = cnet.hosts[ : -1 ]  # ignore 'root' node

info( '* Creating Data Network\n' )
topo = TreeTopo( depth=2, fanout=2 )
# UserSwitch so we can easily test failover
net = Mininet( topo=topo, switch=UserSwitch, build=False )
info( '* Adding Controllers to Data Network\n' )
net.controllers = dataControllers
net.build()
info( '* Starting Data Network\n')
net.start()

CLI2( net, cnet=cnet )

info( '* Stopping Data Network\n' )
net.stop()

info( '* Stopping Control Network\n' )
cnet.stop()



开发者ID:bfarenaz,项目名称:mininet,代码行数:29,代码来源:controlnet.py

示例7: info

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import controllers [as 别名]
	"""
	info("****creating network****\n")
	net = Mininet(listenPort = 6633)

	mycontroller = RemoteController("muziController", ip = "127.0.0.1")

	switch_1 = net.addSwitch('s1')
	switch_2 = net.addSwitch('s2')
	switch_3 = net.addSwitch('s3')
	#switch_4 = net.addSwitch('s4')
	h1 = net.addHost('h1')
	h2 = net.addHost('h2')



	net.controllers = [mycontroller]

	#_intf_1 = Intf(intfName_1, node = switch_1, port = 1)

	net.addLink(switch_1, switch_2, 2, 1)# node1, node2, port1, port2
	net.addLink(switch_2, switch_3, 2, 1)
	#net.addLink(switch_1, switch_4, 3, 1)

	net.addLink(switch_1, h1, 1)
	net.addLink(switch_2, h2, 2)

	#_intf_3 = Intf(intfName_3, node = switch_3, port = 2)

	#net.addLink(switch_4, switch_3, 2, 3)

	#info("*****Adding hardware interface ", intfName_1, "to switch:" ,switch_1.name, '\n')
开发者ID:MatheMatrix,项目名称:Miracle,代码行数:33,代码来源:topo.py

示例8: Switch

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import controllers [as 别名]
#!/usr/bin/python

"""
Create a network where different switches are connected to
different controllers, by creating a custom Switch() subclass.
"""

from mininet.net import Mininet
from mininet.node import OVSSwitch, Controller
from mininet.topolib import TreeTopo
from mininet.cli import CLI

c0 = Controller( 'c0' )
c1 = Controller( 'c1', ip='127.0.0.2' )
cmap = { 's1': c0, 's2': c1, '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 )
net.controllers = [ c0, c1 ]
net.build()
net.start()
CLI( net )
net.stop()
开发者ID:Metaswitch,项目名称:mininet,代码行数:30,代码来源:controllers.py


注:本文中的mininet.net.Mininet.controllers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。