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


Python Mininet.addSwitch方法代码示例

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


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

示例1: main

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addSwitch [as 别名]
def main():
    net = Mininet( controller = None )

    # add hosts
    h1 = net.addHost( 'h1', ip = '172.16.10.1/24' )
    h2 = net.addHost( 'h2', ip = '172.16.10.2/24' )

    # add switch 1
    sw1 = net.addSwitch( 'sw1', target_name = "p4dockerswitch",
            cls = P4DockerSwitch, pcap_dump = False )

    # add switch 2
    sw2 = net.addSwitch('sw2')

    # add links
    if StrictVersion(VERSION) <= StrictVersion('2.2.0') :
        net.addLink( sw1, h1, port1 = 1 )
        net.addLink( sw1, sw2, port1 = 2, port2 = 2 )
        net.addLink( sw2, h2, port1 = 1 )
    else:
        net.addLink( sw1, h1, port1 = 1, fast=False )
        net.addLink( sw1, sw2, port1 = 2, port2 = 2, fast=False )
        net.addLink( sw2, h2, port1 = 1, fast=False )

    net.start()
    CLI( net )
    net.stop()
开发者ID:TakeshiTseng,项目名称:SDN-Work,代码行数:29,代码来源:p4_and_ovs.py

示例2: main

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addSwitch [as 别名]
def main():
    net = Mininet(controller=None)

    # add hosts
    h1 = net.addHost("h1", ip="172.16.10.1/24")
    h2 = net.addHost("h2", ip="172.16.10.2/24")

    # add switch 1
    sw1 = net.addSwitch("sw1", target_name="p4dockerswitch", cls=P4DockerSwitch, sai_port=25000, pcap_dump=True)

    # add switch 2
    sw2 = net.addSwitch("sw2", target_name="p4dockerswitch", cls=P4DockerSwitch, sai_port=25001, pcap_dump=True)

    # add links
    if StrictVersion(VERSION) <= StrictVersion("2.2.0"):
        net.addLink(sw1, h1, port1=1)
        net.addLink(sw1, sw2, port1=2, port2=2)
        net.addLink(sw2, h2, port1=1)
    else:
        net.addLink(sw1, h1, port1=1, fast=False)
        net.addLink(sw1, sw2, port1=2, port2=2, fast=False)
        net.addLink(sw2, h2, port1=1, fast=False)

    net.start()

    print "Waiting 10 seconds for switches to intialize..."
    time.sleep(10)

    cfg_switch1()
    cfg_switch2()

    CLI(net)

    net.stop()
开发者ID:XianliangJ,项目名称:p4factory,代码行数:36,代码来源:sai_l2.py

示例3: topology

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addSwitch [as 别名]
def topology():
    "Create a network."
    net = Mininet( controller=RemoteController, link=TCLink, switch=OVSKernelSwitch )
 
    print "*** Creating nodes"
    s1 = net.addSwitch( 's1', listenPort=6634, mac='00:00:00:00:00:01' )
    s4 = net.addSwitch( 's4', listenPort=6635, mac='00:00:00:00:00:04' )
    s6 = net.addSwitch( 's6', listenPort=6636, mac='00:00:00:00:00:06' )
    h2 = net.addHost( 'h2', mac='00:00:00:00:00:02', ip='10.0.0.2/8' )
    h3 = net.addHost( 'h3', mac='00:00:00:00:00:03', ip='10.0.0.3/8' )
    h4 = net.addHost( 'h4', mac='00:00:00:00:00:04', ip='10.0.0.4/8' )
    #c7 = net.addController( 'c5', controller=RemoteController, ip='127.0.0.1', port=6633 )
    c7 = net.addController( 'c5', controller=RemoteController, ip='192.168.59.105', port=6633 )
         
 
    print "*** Creating links"
    net.addLink(s1, h2, 1, 0)
    net.addLink(s1, s4, 2, 1)
    net.addLink(s4, h4, 3, 0)
    net.addLink(s4, s6, 2, 1)
    net.addLink(s6, h3, 2, 0)    
 
    print "*** Starting network"
    net.build()
    s1.start( [c7] )
    s4.start( [c7] )
    s6.start( [c7] )
    c7.start()
 
    print "*** Running CLI"
    CLI( net )
 
    print "*** Stopping network"
    net.stop()
开发者ID:sohaibnaseem,项目名称:summer-project,代码行数:36,代码来源:3H_3SW_SNw_Topo.py

示例4: createTreeTopo

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addSwitch [as 别名]
def createTreeTopo():


    net = Mininet( controller=RemoteController)

    info( '*** Adding controller\n' )
    net.addController( 'c0', controller=RemoteController,ip="127.0.0.1",port=6633 )
    # Add hosts and switches
    host1 = net.addHost( 'h1' )
    host2 = net.addHost( 'h2' )

    edgeSwitch1 = net.addSwitch( 's3' )
    edgeSwitch2 = net.addSwitch( 's4' )
    aggrSwitch1 = net.addSwitch( 's5' )
    aggrSwitch2 = net.addSwitch( 's6' )
    coreSwitch = net.addSwitch( 's7' )

    # Add links
    net.addLink( host1, edgeSwitch1 )
    net.addLink( edgeSwitch1, aggrSwitch1 )
    net.addLink( aggrSwitch1, coreSwitch )
    net.addLink( coreSwitch, aggrSwitch2 )
    net.addLink( aggrSwitch2, edgeSwitch2 )
    net.addLink( edgeSwitch2, host2 )


    info( '*** Starting network\n')
    net.start()

    info( '*** Running CLI\n' )
    CLI( net )

    info( '*** Stopping network' )
    net.stop()
开发者ID:SriniNa,项目名称:hadev,代码行数:36,代码来源:test-haqos-tree.py

示例5: simpleTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addSwitch [as 别名]
def simpleTest():
    "Create and test a simple network"
    net = Mininet()
    #c0 = net.addController('c0',POXBridge)
    c0 = net.addController('c0',RemoteController)
    s1 = net.addSwitch('s1')
    s2 = net.addSwitch('s2',dpid='0000000000000012')
    s3 = net.addSwitch('s3')
    s4 = net.addSwitch('s4')
    h1 = net.addHost('h1')
    h2 = net.addHost('h2')
    h3 =net.addHost('h3')
    h4 = net.addHost('h4')
    l11= net.addLink(h1,s1)
    l22= net.addLink(h2,s2)
    l33= net.addLink(h3,s3)
    l44= net.addLink(h4,s4)

    l12= net.addLink(s1,s2)
    l23= net.addLink(s2,s3)
    l2f= net.addLink(s2,s4)
    net.start()
    h1.intfList()[0].setIP('10.43.21.1/24')
    h2.intfList()[0].setIP('10.43.21.2/24')
    h3.intfList()[0].setIP('10.43.21.3/24')
    h4.intfList()[0].setIP('10.43.21.4/24')
    print "Dumping host connections"
    dumpNodeConnections(net.hosts)
    print "Testing network connectivity"
    CLI(net)
    net.stop()
开发者ID:EliseuTorres,项目名称:pox_firewall_setup,代码行数:33,代码来源:createSimple.py

示例6: emptyNet

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addSwitch [as 别名]
def emptyNet():

    "Create an empty network and add nodes to it."

    #net = Mininet( controller=Controller )
    net = Mininet( controller=RemoteController )

    info( '*** Adding controller\n' )
    net.addController( 'c0' )

    info( '*** Adding hosts\n' )
    h1 = net.addHost( 'h1', ip='10.0.0.1' )
    h2 = net.addHost( 'h2', ip='10.0.0.2' )

    info( '*** Adding switch\n' )
    s3 = net.addSwitch( 's3' )
    s4 = net.addSwitch( 's4' )
    s5 = net.addSwitch( 's5' )
    s6 = net.addSwitch( 's6' )

    info( '*** Creating links\n' )
    net.addLink( h1, s3 )
    net.addLink( s3, s4 )
    net.addLink( s3, s5 )
    net.addLink( s4, s6 )
    net.addLink( s5, s6 )
    net.addLink( h2, s6 )

    print "Stopping of " + 's5'
    net.configLinkStatus('s5', 's3', 'down')
    #net.configLinkStatus('s5', 's6', 'down')
    #net.hosts[0].cmd("ping -w 15 10.0.0.2")
    #net.pingAll()

    return net
开发者ID:stefanos1316,项目名称:BigData,代码行数:37,代码来源:test_net.py

示例7: myNet

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addSwitch [as 别名]
def myNet():

    net = Mininet(topo=None, build=False, link=TCLink)

    linkopt = dict(bw=1000)
    # Add hosts and switches
    h1 = net.addHost("h1", ip="10.0.0.1", mac="00:00:00:00:00:01")
    h2 = net.addHost("h2", ip="10.0.0.2", mac="00:00:00:00:00:02")
    s1 = net.addSwitch("s1", cls=UserSwitch)  # tora
    s2 = net.addSwitch("s2", cls=UserSwitch)  # ingress a
    s3 = net.addSwitch("s3", cls=UserSwitch)  # eopa
    s4 = net.addSwitch("s4", cls=UserSwitch)  # nwa
    s5 = net.addSwitch("s5", cls=UserSwitch)  # eopb
    s6 = net.addSwitch("s6", cls=UserSwitch)  # ingress b
    s7 = net.addSwitch("s7", cls=UserSwitch)  # torb

    # Add links
    net.addLink(h1, s1, bw=1000)
    net.addLink(s1, s2, bw=1000)
    net.addLink(s2, s3, bw=1000)
    net.addLink(s3, s4, bw=1000)
    net.addLink(s4, s5, bw=1000)
    net.addLink(s5, s6, bw=1000)
    net.addLink(s6, s7, bw=1000)
    net.addLink(s7, h2, bw=1000)

    net.build()

    CLI(net)
    net.stop()
开发者ID:0xdyu,项目名称:NetEx,代码行数:32,代码来源:test-topo.py

示例8: config_net

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addSwitch [as 别名]
    def config_net(self):
        net = Mininet(switch=OVSKernelSwitch,controller=RemoteController)

        print '*** Adding controller'
        net.addController('c0',ip=self.controller_ip)

        print '*** Adding hosts'
        h1 = net.addHost( 'h1', mac='00:00:00:00:00:01')
        h2 = net.addHost( 'h2', mac='00:00:00:00:00:02')
        h3 = net.addHost( 'h3', mac='00:00:00:00:00:03')
        h4 = net.addHost( 'h4', mac='00:00:00:00:00:04')

        print '*** Adding switch'
        s1 = net.addSwitch( 's1' )
        s2 = net.addSwitch( 's2' )
        s3 = net.addSwitch( 's3' )

        print '*** Creating links'
        net.addLink(h1,s2)
        net.addLink(h2,s2)
        net.addLink(h3,s3)
        net.addLink(h4,s3)
        net.addLink(s1,s2)
        net.addLink(s1,s3)

        self.net = net
开发者ID:Cygnus-Labs,项目名称:opendaylight-integration,代码行数:28,代码来源:MininetHandler.py

示例9: myTopo

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addSwitch [as 别名]
def myTopo():
    net = Mininet(switch=OVSKernelSwitch)
    net.addController('controller01',controller=RemoteController,ip=ofc_ip, port=ofc_port)

    spine1 = net.addSwitch(spine1_name, dpid=spine1_dpid)
    leaf1  = net.addSwitch(leaf1_name,  dpid=leaf1_dpid)
    leaf2  = net.addSwitch(leaf2_name,  dpid=leaf2_dpid)

    host1 = net.addHost(host1_name, ip=host1_ip)
    host2 = net.addHost(host2_name, ip=host2_ip)
    host3 = net.addHost(host3_name, ip=host3_ip)
    host4 = net.addHost(host4_name, ip=host4_ip)

    net.addLink(spine1, leaf1)
    net.addLink(spine1, leaf2)

    net.addLink(leaf1, host1)
    net.addLink(leaf1, host2)

    net.addLink(leaf2, host3)
    net.addLink(leaf2, host4)

    net.start()
    print "Dumping node connections"
    dumpNodeConnections(net.switches)
    dumpNodeConnections(net.hosts)

    ofp_version(spine1, ['OpenFlow13'])
    ofp_version(leaf1,  ['OpenFlow13'])
    ofp_version(leaf2,  ['OpenFlow13'])

    CLI(net)
    net.stop()
开发者ID:ool-hirahara,项目名称:of-patch-openflow-controller,代码行数:35,代码来源:mininet_3sw4host_topo.py

示例10: testRemoteNet

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addSwitch [as 别名]
def testRemoteNet( remote='ubuntu2', link=RemoteGRELink ):
    "Test remote Node classes"
    print( '*** Remote Node Test' )
    net = Mininet( host=RemoteHost, switch=RemoteOVSSwitch, link=link )
    c0 = net.addController( 'c0' )
    # Make sure controller knows its non-loopback address
    Intf( 'eth0', node=c0 ).updateIP()
    print( "*** Creating local h1" )
    h1 = net.addHost( 'h1' )
    print( "*** Creating remote h2" )
    h2 = net.addHost( 'h2', server=remote )
    print( "*** Creating local s1" )
    s1 = net.addSwitch( 's1' )
    print( "*** Creating remote s2" )
    s2 = net.addSwitch( 's2', server=remote )
    print( "*** Adding links" )
    net.addLink( h1, s1 )
    net.addLink( s1, s2 )
    net.addLink( h2, s2 )
    net.start()
    print( 'Mininet is running on', quietRun( 'hostname' ).strip() )
    for node in c0, h1, h2, s1, s2:
        print( 'Node', node, 'is running on', node.cmd( 'hostname' ).strip() )
    net.pingAll()
    CLI( net )
    net.stop()
开发者ID:xiaozhou,项目名称:mininet,代码行数:28,代码来源:cluster.py

示例11: QoSFlowNet

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addSwitch [as 别名]
def QoSFlowNet():
    "Create network by using QoSFlow user switch."
    
    net = Mininet(controller=RemoteController, switch=QoSFlowUserSwitch, link=TCLink) 
    
    info('*** Adding controller\n')
    net.addController('c0')
    
    info('*** Adding hosts\n')
    h1 = net.addHost('h1')
    h2 = net.addHost('h2')

    info('*** Adding switch\n')
    I1 = net.addSwitch('I1')
    s2 = net.addSwitch('s2')
    s3 = net.addSwitch('s3')
    s4 = net.addSwitch('s4')
    s5 = net.addSwitch('s5')
    s6 = net.addSwitch('s6')
    s7 = net.addSwitch('s7')
    s8 = net.addSwitch('s8')
    s9 = net.addSwitch('s9')
    E2 = net.addSwitch('E2')

    info('*** Creating host links\n')
    #h2.linkTo(s2)
    net.addLink(I1, h1)#, 2, 1, intfName1 = 'eth0-h1')
    net.addLink(E2, h2)#, 2, 1, intfName1 = 'eth0-h2')

    info('*** Creating swicth links\n')
    #s1.linkTo(s2)
    net.addLink(I1, s2)
    net.addLink(s2, s3)
    net.addLink(s3, s4)
    net.addLink(s4, s5)
    net.addLink(s5, s6)
    net.addLink(s6, s7)
    net.addLink(s7, s8)
    net.addLink(s8, s9)
    net.addLink(s9, E2)
    
    print I1.intfNames()
    print s2.intfNames()
    print s3.intfNames()
    print s4.intfNames()
    print s5.intfNames()
    print s6.intfNames()
    print s7.intfNames()
    print s8.intfNames()
    print s9.intfNames()
    print E2.intfNames()

    info('*** Starting network\n')
    net.start()
    
    info('*** Running CLI\n')
    CLI(net)

    info('*** Stopping network')
    net.stop()
开发者ID:josecastillolema,项目名称:smart-OF-controller,代码行数:62,代码来源:criaLinearQoSFlow.py

示例12: build

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addSwitch [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

示例13: main

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addSwitch [as 别名]
def main():
    net = Mininet(controller = None, autoSetMacs=True, autoStaticArp=True)

    h1 = net.addHost('h1', cls=P4Host)
    h2 = net.addHost('h2', cls=P4Host)
    h3 = net.addHost('h3', cls=P4Host)
    h4 = net.addHost('h4', cls=P4Host)

    s1 = net.addSwitch('s1', cls = P4Switch, sw_path=SW_PATH, json_path=JSON_PATH, thrift_port=9091)
    s2 = net.addSwitch('s2', cls = P4Switch, sw_path=SW_PATH, json_path=JSON_PATH, thrift_port=9092)
    s3 = net.addSwitch('s3', cls = P4Switch, sw_path=SW_PATH, json_path=JSON_PATH, thrift_port=9093)
    s4 = net.addSwitch('s4', cls = P4Switch, sw_path=SW_PATH, json_path=JSON_PATH, thrift_port=9094)

    net.addLink(s1, h1, port1=0, port2=0)
    net.addLink(s1, s3, port1=1, port2=1)
    net.addLink(s1, s2, port1=2, port2=0)

    net.addLink(s2, s4, port1=1, port2=1)
    net.addLink(s2, h2, port1=2, port2=0)

    net.addLink(s3, h3, port1=0, port2=0)
    net.addLink(s3, s4, port1=2, port2=0)

    net.addLink(s4, h4, port1=2, port2=0)


    net.start()
    CLI(net)
    net.stop()
开发者ID:TakeshiTseng,项目名称:2016-nctu-p4-workshop,代码行数:31,代码来源:topology.py

示例14: build

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

        net = Mininet(controller=RemoteController, topo=None )

        # Make controller
        net.addController( 'c0' )
        # Make nodes
        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:
                net.addHost( name, ip=ipStr( nodeNum ) )
            else:
                raise Exception( "Cannot create mystery node: " + name )
        # Make links
        for link in self.links.values():
            ( src, dst ) = link
            srcName, dstName = src[ 'text' ], dst[ 'text' ]
            src, dst = net.nameToNode[ srcName ], net.nameToNode[ dstName ]
            src.linkTo( dst )

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

        return net
开发者ID:adityagawade27,项目名称:LoadBalancer,代码行数:31,代码来源:myminiedit.py

示例15: emptyNet

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addSwitch [as 别名]
def emptyNet():

    "Create an empty network and add nodes to it."

    net = Mininet( controller=Controller )

    info( '*** Adding controller\n' )
    net.addController( 'c0', controller=RemoteController, ip='127.0.0.1', port=6633 )

    info( '*** Adding hosts\n' )
    h1 = net.addHost( 'h1' )
    h2 = net.addHost( 'h2' )

    info( '*** Adding switch\n' )
    s1 = net.addSwitch( 's1' )
    s2 = net.addSwitch( 's2' )
    s3 = net.addSwitch( 's3' )
    s4 = net.addSwitch( 's4' )

    info( '*** Creating links\n' )
    net.addLink( h1, s1 )
    net.addLink( h2, s3 )
    net.addLink( s1, s2 )
    net.addLink( s2, s3 )
    net.addLink( s3, s4 )
    net.addLink( s4, s1 )

    info( '*** Starting network\n')
    net.start()

    info( '*** Running CLI\n' )
    CLI( net )

    info( '*** Stopping network' )
    net.stop()
开发者ID:hegdenagaraj4,项目名称:myHacks,代码行数:37,代码来源:resilient.py


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