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


Python Mininet.addLink方法代码示例

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


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

示例1: myNetwork

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

    net = Mininet( topo=None,
                   build=False,
                   ipBase='10.0.0.0/8')

    info( '*** Adding controller\n' )
    info( '*** Add switches\n')
    s1 = net.addSwitch('s1', cls=OVSKernelSwitch, failMode='standalone')

    info( '*** Add hosts\n')
    h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None)
    h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None)

    info( '*** Add links\n')
    net.addLink(s1, h1)
    net.addLink(s1, h2)

    info( '*** Starting network\n')
    net.build()
    info( '*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info( '*** Starting switches\n')
    net.get('s1').start([])

    info( '*** Post configure switches and hosts\n')

    CLI(net)
    net.stop()
开发者ID:Sirozha1337,项目名称:mininet-python,代码行数:33,代码来源:savedtopo.py

示例2: topology

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

    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8', position='10,20,0' )
    sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8', position='10,30,0' )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='15,30,0' )
    c1 = net.addController( 'c1', controller=Controller )

    """uncomment to plot graph"""
    #net.plotGraph(max_x=60, max_y=60)

    print "*** Creating links"
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start( [c1] )

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
开发者ID:HerrOber,项目名称:mininet-wifi,代码行数:30,代码来源:wifiPosition.py

示例3: topology

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

    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8' )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='50,50,0' )
    c1 = net.addController( 'c1', controller=Controller )

    print "*** adding Link"
    net.addLink(sta1, ap1)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start( [c1] )

    """uncomment to plot graph"""
    net.plotGraph(max_x=100, max_y=100)

    getTrace(sta1, 'examples/replaying/replayingBandwidth/throughputData.dat')

    replayingBandwidth()

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
开发者ID:EliseuTorres,项目名称:mininet-wifi-1,代码行数:32,代码来源:replayingBandwidth.py

示例4: emptyNet

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

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

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

    net.addController( 'c0',
                       controller=RemoteController,
                       ip='0.0.0.0'  )

    h1 = net.addHost( 'h1', ip='10.0.0.1' )
    h2 = net.addHost( 'h2', ip='10.0.0.2' )
    h3 = net.addHost( 'h3', ip='10.0.0.3' )

    s1 = net.addSwitch( 's1', cls=OVSSwitch )

    net.addLink( h1, s1 )
    net.addLink( h2, s1 )
    net.addLink( h3, s1 )

    net.start()
    s1.cmd('ifconfig s1 inet 10.0.0.10')

    CLI( net )
    net.stop()
开发者ID:VishrutMehta,项目名称:OpenFlow-Table-Transfer-Optimization,代码行数:28,代码来源:version_1.2.py

示例5: build

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

示例6: testRemoteNet

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

示例7: createEmptyNet

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addLink [as 别名]
def createEmptyNet():
    final_hosts=[]
    final_switches=[]
    net = Mininet(controller=OVSController,link=TCLink)
    net.addController('c0')
    evenflag=1
    oddflag=1
    evenflagip='11.0.0.'
    oddflagip='11.0.1.'
    for x in range(0,B*A):
        if x%2==0:
            final_hosts.append(net.addHost('h'+str(x+1), ip=evenflagip+str(evenflag)+'/24'))
            evenflag+=1
        else:
            final_hosts.append(net.addHost('h'+str(x+1), ip=oddflagip+str(oddflag)+'/24'))
            oddflag+=1
    for x in range(0,A):
        final_switches.append(net.addSwitch('s'+str(x+1)))
    
    bwidth=0
    for x in range(0,A):
        for y in range(0,B):
            net.addLink( final_hosts[B*x+y], final_switches[x] , bw=bwidth+1)
            bwidth=(bwidth+1)%2
    for x in range(0,A-1):
        net.addLink(final_switches[x],final_switches[x+1],bw=2)

    net.start()
    CLI( net )
    net.stop()
开发者ID:aayushsaxena15,项目名称:201201021_cloud_assignments,代码行数:32,代码来源:main.py

示例8: DeltaNetwork

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addLink [as 别名]
def DeltaNetwork():
#Make topology
	net = Mininet(topo=None, controller=None, build=False)

#Add switch
	s0 = net.addSwitch('s0', dpid='00:00:00:00:00:01')
	s1 = net.addSwitch('s1') # for connection with DELTA

#Add hosts
	h1 = net.addHost('h1', ip='10.0.0.1', mac='00:00:00:00:00:11')
	h2 = net.addHost('h2', ip='10.0.0.2', mac='00:00:00:00:00:22')

#Add links
	net.addLink(s0, h1)
	net.addLink(s0, h2)

	net.addLink(s1, h1, intfName2='eth0')
	
#	net.build()
	net.start()

#Add hardware interface to switch1 
	s1.attach('eth0')

#Set ip
	h1.cmd("ifconfig eth0 10.0.2.13 netmask 255.255.255.0")
	
#connect a controller
	os.system("sudo ovs-vsctl set-controller s0 tcp:"+sys.argv[1]+":"+sys.argv[2])

	CLI(net)
	net.stop()
开发者ID:flyawaytang,项目名称:DELTA,代码行数:34,代码来源:test-switch-topo.py

示例9: myNetwork

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addLink [as 别名]
def myNetwork():
    net = Mininet()
    
    host_1 = net.addHost('host_1', ip='192.168.0.10/24')
    router_1 = net.addHost('router_1')
    
    net.addLink(host_1, router_1)

    # Interface binding with the SDN_hub's eth1 
    Intf( 'eth0', node=router_1)

    # Print information
    info( '*** Starting network\n')

    net.start()

    router_1.cmd('ifconfig router-eth0 0')
    router_1.cmd('ifconfig router-eth1 0')
    
    # Get ip from NAT's DHCP
    router_1.cmd("dhclient eth0")
    
    router_1.cmd("ip addr add 192.168.0.1/24 brd + dev router_1-eth0")
    router_1.cmd("echo 1 > /proc/sys/net/ipv4/ip_forward")
    
    # Change the Intranet IP to NAT IP
    router_1.cmd("iptables -t nat -A POSTROUTING -o eth0 -s 192.168.0.0/24 -j MASQUERADE")

    host_1.cmd("ip route add default via 192.168.0.1")

    CLI(net)
    net.stop()
开发者ID:Linnic,项目名称:Course_SDN_Network,代码行数:34,代码来源:test_9.py

示例10: server2

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

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

    net = Mininet( controller=None )

    info( '*** Adding hosts\n' )
    h3 = net.addHost( 'h3', ip='10.0.0.3', mac='00:00:00:00:00:03')
    h4 = net.addHost( 'h4', ip='10.0.0.4', mac='00:00:00:00:00:04')

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

    info( '*** Creating links\n' )
    net.addLink( h3, s2 )
    net.addLink( h4, s2 )

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

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

    info( '*** Stopping network' )
    net.stop()
开发者ID:chicm,项目名称:ovs-vxlan,代码行数:27,代码来源:server2.py

示例11: topology

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addLink [as 别名]
def topology():
    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', wlans=3 ) # 3 wlan added
    sta2 = net.addStation( 'sta2' ) # 1 wlan added
    ap1 = net.addBaseStation( 'ap1', ssid="ssid_1", mode="g", channel=5 ) # 1 wlan added
    c0 = net.addController('c0', controller=Controller)

    print "*** Associating..."
    net.addLink(ap1, sta1)

    net.addHoc(sta1, ssid='adhoc1', mode='g')
    net.addHoc(sta2, ssid='adhoc1', mode='g')

    print "*** Starting network"
    net.build()
    c0.start()
    ap1.start( [c0] )

    print "***Addressing..."
    sta1.setIP('192.168.10.1/24', intf="sta1-wlan1")
    sta2.setIP('192.168.10.2/24', intf="sta2-wlan0")

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
开发者ID:alitalpur99,项目名称:mininet-wifi,代码行数:32,代码来源:multipleWlan.py

示例12: emptyNet

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

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

    net = Mininet( controller=RemoteController )

    info( '*** Adding controller\n' )
    net.addController( 'c1',controller=RemoteController,ip="192.168.1.38",port=6653 )

    info( '*** Adding hosts\n' )
    h3 = net.addHost( 'h3', ip = "10.0.0.3" )
    h4 = net.addHost( 'h4', ip = "10.0.0.4" )
    info( '*** Adding switch\n' )
    s2 = net.addSwitch( 's2' ,mac="00:00:00:00:00:02" )

    info( '*** Creating links\n' )
    net.addLink( h3, s2 )
    net.addLink( h4, s2 )

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

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

    info( '*** Stopping network' )
    net.stop()
开发者ID:khantee,项目名称:Customtopo,代码行数:29,代码来源:test2_topo.py

示例13: net

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addLink [as 别名]
def net():
    '''Create a simulated network'''

    net = Mininet(controller=lambda a: RemoteController(a,ip='127.0.0.1'))

    info('*** Adding controller\n')
    # currently, we do not add a controller to this network.
    net.addController('c0')

    info('*** Adding hosts\n')
    # this is a host that is in the external network
    h1 = net.addHost('h1', ip='10.0.0.1')
    h2 = net.addHost('h2', ip='10.0.0.1')

    info('*** Adding switches\n')
    inst1 = net.addSwitch('inst1', dpid=int2dpid(11))
    inst2 = net.addSwitch('inst2', dpid=int2dpid(12))
    lb = net.addSwitch('lb', dpid=int2dpid(1))

    info('*** Creating links\n')
    net.addLink(h1, inst1)
    net.addLink(h2, inst2)
    net.addLink(inst1, lb)
    net.addLink(inst2, lb)

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

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

    info('*** Stopping network\n')
    net.stop()
开发者ID:bjlee72,项目名称:ryu-test-project,代码行数:35,代码来源:topo.py

示例14: QoSFlowNet

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

    info('*** Creating host links\n')
    #h2.linkTo(s2)
    net.addLink(s1, h1, 1, 1)
    net.addLink(s1, h2, 2, 1)

    #info('*** Creating swicth links\n')
    #s1.linkTo(s2)
    #net.addLink(s1, s2, 2, 2) #, bw=10, delay='5ms', jitter='2ms', loss=10, max_queue_size=1000, use_htb=True)

    print s1.intfNames()
    #print s2.intfNames()

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

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

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

示例15: main

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addLink [as 别名]
def main():
    net = Mininet()
    # create hosts
    h1 = net.addHost('h1')
    h2 = net.addHost('h2')

    # create switch
    s1 = net.addSwitch('S1')

    # create controller
    c1 = net.addController('c1')

    # create links
    net.addLink(h1, s1)
    net.addLink(h2, s1)

    net.start()

    # start web server on h2
    print('starting web server...')
    h2.cmd('python -m SimpleHTTPServer 80 &')
    sleep(2)

    # use h1 as a web client
    print('accessing web server..')
    h1.cmd('curl', h2.IP())

    # CLI(net)
    print('kill web server..')
    h2.cmd('kill %python')

    print('finish.')
    net.stop()
开发者ID:wicaksana,项目名称:sdn-playing-with,代码行数:35,代码来源:simple02.py


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