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


Python link.Link类代码示例

本文整理汇总了Python中mininet.link.Link的典型用法代码示例。如果您正苦于以下问题:Python Link类的具体用法?Python Link怎么用?Python Link使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __init__

 def __init__( self, node1, node2, port1=None, port2=None, allowed=True,
               intfName1=None, intfName2=None, linkType='OPTICAL',
               annotations={}, speed1=0, speed2=0, **params ):
     "Creates a dummy link without a virtual ethernet pair."
     self.allowed = allowed
     self.annotations = annotations
     self.linkType = linkType
     params1 = { 'speed': speed1 }
     params2 = { 'speed': speed2 }
     
     if isinstance( node1, OpticalSwitch ):
         cls1 = OpticalIntf
     else:
         cls1 = Intf
         # bad hack to stop error message from appearing when we try to set up intf in a packet switch, 
         # and there is no interface there( because we do not run makeIntfPair ). This way, we just set lo up
         intfName1 = 'lo'
     if isinstance( node2, OpticalSwitch ):
         cls2 = OpticalIntf
     else:
         cls2 = Intf
         intfName2 = 'lo'
     Link.__init__( self, node1, node2, port1=port1, port2=port2,
                    intfName1=intfName1, intfName2=intfName2, cls1=cls1,
                    cls2=cls2, params1=params1, params2=params2 )
开发者ID:Ehsan70,项目名称:Mininet_LINC_script,代码行数:25,代码来源:opticalUtils.py

示例2: __init__

    def __init__(
        self,
        node1,
        node2,
        port1=None,
        port2=None,
        intfName1=None,
        intfName2=None,
        addr1=None,
        addr2=None,
        ip1=None,
        ip2=None,
        **params
    ):
        Link.__init__(
            self,
            node1,
            node2,
            port1=port1,
            port2=port2,
            intfName1=intfName1,
            intfName2=intfName2,
            cls1=TCIntf,
            cls2=TCIntf,
            addr1=addr1,
            addr2=addr2,
            params1=params,
            params2=params,
        )
        if ip1 is not None:
            self.intf1.setIP(ip1)

        if ip2 is not None:
            self.intf2.setIP(ip2)
开发者ID:jglara,项目名称:mininet_networking,代码行数:34,代码来源:linuxrouter.py

示例3: __init__

 def __init__(self, node1, node2, port1=None, port2=None, allowed=True,
               intfName1=None, intfName2=None, linkType='OPTICAL',
               annotations={}, speed1=0, speed2=0, **params):
     "Creates a dummy link without a virtual ethernet pair."
     self.allowed = allowed
     self.annotations = annotations
     self.linkType = linkType
     self.port1 = port1
     self.port2 = port2
     params1 = { 'speed': speed1 }
     params2 = { 'speed': speed2 }
     # self.isCrossConnect = True if self.annotations.get('optical.type') == 'cross-connect' else False
     if isinstance(node1, LINCSwitch) and isinstance(node2, LINCSwitch):
         self.isCrossConnect = False
     else:
         self.isCrossConnect = True
     if isinstance(node1, LINCSwitch):
         cls1 = LINCIntf
         if self.isCrossConnect:
             node1.crossConnects.append(self)
     else:
         cls1 = Intf
         # bad hack to stop error message from appearing when we try to set up intf in a packet switch, 
         # and there is no interface there( because we do not run makeIntfPair ). This way, we just set lo up
         intfName1 = 'lo'
     if isinstance(node2, LINCSwitch):
         cls2 = LINCIntf
         if self.isCrossConnect:
             node2.crossConnects.append(self)
     else:
         cls2 = Intf
         intfName2 = 'lo'
     Link.__init__(self, node1, node2, port1=port1, port2=port2,
                    intfName1=intfName1, intfName2=intfName2, cls1=cls1,
                    cls2=cls2, params1=params1, params2=params2)
开发者ID:java66liu,项目名称:onos,代码行数:35,代码来源:opticalUtils.py

示例4: stop

 def stop( self ):
     "Stop this link"
     if self.tunnel:
         self.intf1.delete()
         self.intf2.delete()
     else:
         Link.stop( self )
     self.tunnel = None
开发者ID:xiaozhou,项目名称:mininet,代码行数:8,代码来源:cluster.py

示例5: __init__

 def __init__(self, node1, node2, port1=None, port2=None,
              intfName1=None, intfName2=None, **params):
     Link.__init__(self, node1, node2, port1=port1, port2=port2,
                   intfName1=intfName1, intfName2=intfName2,
                   cls1=SdnIntf,
                   cls2=SdnIntf,
                   params1=params,
                   params2=params)
     self._connected = True
开发者ID:UdS-TelecommunicationsLab,项目名称:VirtualTestbed,代码行数:9,代码来源:sdn.py

示例6: __init__

 def __init__( self, node1, node2, **kwargs ):
     """Initialize a RemoteLink
        see Link() for parameters"""
     # Create links on remote node
     self.node1 = node1
     self.node2 = node2
     self.tunnel = None
     kwargs.setdefault( 'params1', {} )
     kwargs.setdefault( 'params2', {} )
     Link.__init__( self, node1, node2, **kwargs )
开发者ID:awfeequdng,项目名称:SDN-TEST,代码行数:10,代码来源:cluster.py

示例7: __init__

 def __init__( self, node1, node2, **kwargs ):
     "See Link.__init__() for options"
     self.isPatchLink = False
     if ( isinstance( node1, OVSSwitch ) and
          isinstance( node2, OVSSwitch ) and
          getattr( node1, 'ovsdb', None ) ==
          getattr( node2, 'ovsdb', None ) ):
         self.isPatchLink = True
         kwargs.update( cls1=OVSIntf, cls2=OVSIntf )
     Link.__init__( self, node1, node2, **kwargs )
开发者ID:AntonySilvester,项目名称:OnosSystemTest,代码行数:10,代码来源:multiovs.py

示例8: __init__

 def __init__(self, node1, node2, port1=None, port2=None,
              intf_name1=None, intf_name2=None,
              addr1=None, addr2=None, **params):
     Link.__init__(self, node1, node2, port1=port1, port2=port2,
                   intfName1=intf_name1, intfName2=intf_name2,
                   cls1=ECNIntf,
                   cls2=ECNIntf,
                   addr1=addr1, addr2=addr2,
                   params1=params,
                   params2=params)
开发者ID:chenzheng128,项目名称:ArsenalPython,代码行数:10,代码来源:ecn_util.py

示例9: _create_links

    def _create_links(self, links):

        def is_remote(node):
            return isinstance(node, RemoteSwitch)

        def is_local(node):
            return not is_remote(node)

        self._info('**** Create %d link(s)' % len(links))
        for id, link in links.iteritems():
            self._debug('\tCreate link %s with params: %s' % (id, link))
            node1 = self.net.get(link['node1'])
            node2 = self.net.get(link['node2'])
            name_to_node = {'node1': node1, 'node2': node2}
            link.update(name_to_node)

            remote = filter(is_remote, [node1, node2])
            local = filter(is_local, [node1, node2])
            if not remote:
                self.net.addLink(**link)
            else:
                sw = local[0]
                r = remote[0]
                intfName = r.params['local_intf_name']
                r_mac = None # unknown, r.params['remote_mac']
                r_port = r.params['remote_port']
                self._debug('\tadd hw interface (%s) to node (%s)' % (intfName, sw.name))

                # This hack avoids calling __init__ which always makeIntfPair()
                link = Link.__new__(Link)
                i1 = Intf(intfName, node=sw, link=link)
                i2 = Intf(intfName, node=r, mac=r_mac, port=r_port, link=link)
                i2.mac = r_mac # mn runs 'ifconfig', which resets mac to None
                #
                link.intf1, link.intf2 = i1, i2
开发者ID:fredericoschardong,项目名称:escape,代码行数:35,代码来源:NetworkManager.py

示例10: _auto_config_intf

 def _auto_config_intf(self, node_name, intf_name, **param):
     node = self.nodemap[node_name]
     if 'port' not in param:
         param['port'] = node.newPort()
     if intf_name == 'auto':
         intf_name = Link.intfName(node, param['port'])
     if intf_name in node.nameToIntf:
         error("Node %s already has interface %s." % (node, name))
         return False
     net = self.mn
     if 'ip' not in param:
         ip = net.nextIP
         net.nextIP += 1
         sufix = ipAdd(ip, ipBaseNum=net.ipBaseNum, prefixLen=net.prefixLen)
         prefix = '/%s' % net.prefixLen
         param['ip'] =  sufix + prefix 
         if 'mac' not in param:
             param['mac'] = macColonHex(ip)
     elif 'mac' not in param:
         ip, prefix = netParse(param['ip'])
         param['mac'] = macColonHex(ip)
     if 'cores' not in param and net.autoPinCpus:
         param['cores'] = self.nextCore
         net.nextCore = (net.nextCore + 1) % net.numCores
     return True
开发者ID:pantuza,项目名称:mininet,代码行数:25,代码来源:dynamicnet.py

示例11: status

 def status( self ):
     "Detailed representation of link"
     if self.tunnel:
         if self.tunnel.poll() is not None:
             status = "Tunnel EXITED %s" % self.tunnel.returncode
         else:
             status = "Tunnel Running (%s: %s)" % (
                 self.tunnel.pid, self.cmd )
     else:
         status = "OK"
     result = "%s %s" % ( Link.status( self ), status )
     return result
开发者ID:xiaozhou,项目名称:mininet,代码行数:12,代码来源:cluster.py

示例12: makeIntfPair

 def makeIntfPair( self, intfname1, intfname2, addr1=None, addr2=None,
                   node1=None, node2=None, deleteIntfs=True   ):
     """Create pair of interfaces
         intfname1: name of interface 1
         intfname2: name of interface 2
         (override this method [and possibly delete()]
         to change link type)"""
     node1 = self.node1 if node1 is None else node1
     node2 = self.node2 if node2 is None else node2
     server1 = getattr( node1, 'server', 'localhost' )
     server2 = getattr( node2, 'server', 'localhost' )
     if server1 == server2:
         # Link within same server
         Link.makeIntfPair( intfname1, intfname2, addr1, addr2,
                            node1, node2, deleteIntfs=deleteIntfs )
         # Need to reduce the MTU of all emulated hosts to 1450 for GRE
         # tunneling, otherwise packets larger than 1400 bytes cannot be
         # successfully transmitted through the tunnel.
         node1.cmd('ip link set dev %s mtu 1450' % intfname1)
         node2.cmd('ip link set dev %s mtu 1450' % intfname2)
     else:
         # Otherwise, make a tunnel
         self.makeTunnel( node1, node2, intfname1, intfname2, addr1, addr2 )
         self.tunnel = 1
开发者ID:xiaozhou,项目名称:mininet,代码行数:24,代码来源:cluster.py

示例13: connectToRootNS

def connectToRootNS( net, ip='10.123.123.1', mac='00123456789A', prefixLen=8, routes=['10.0.0.0/8']):
	print "*** Creating controller"
	c0 = net.addController( 'c0', ip='127.0.0.1', port=6633 )
	rootswitch = net.addSwitch('roots1',)
	rootswitch.dpid = 'FFFFFFFFFFFFFFFF'
	# Connect hosts to root namespace via switch. Starts network.
	# network: Mininet() network object
	# ip: IP address for root namespace node
	# prefixLen: IP address prefix length (e.g. 8, 16, 24)
	# routes: host networks to route to"
	# Create a node in root namespace and link to switch 0
	root = Node( 'root', inNamespace=False )
	intf = Link( root, rootswitch ).intf1
	intf.setMAC(mac)
	root.setIP( ip, prefixLen, intf )
	print "*** Added Interface", str(intf), "Connected To Root-NameSpace"
	fixNetworkManager(str(intf))
	for host in net.hosts:
	    net.addLink(host,rootswitch)
	# Add routes from root ns to hosts
	for route in routes:
         root.cmd( 'route add -net ' + route + ' dev ' + str( intf ) )
	root.cmd('service network-manager restart')
	return rootswitch
开发者ID:StefanoSalsano,项目名称:alien-ofelia-conet-ccnx,代码行数:24,代码来源:start_mininet.py

示例14: add

 def add( self, node, port=None, intfName=None ):
     if hasattr( node, 'nsNode' ) and node.nsNode is not None:
         pass
     else:
         node.nsNode = ns.network.Node()
         allNodes.append( node )
     device = ns.network.SimpleNetDevice()
     device.SetChannel(self.channel)
     device.SetAddress (ns.network.Mac48Address.Allocate ())
     node.nsNode.AddDevice(device)
     if port is None:
         port = node.newPort()
     if intfName is None:
         intfName = Link.intfName( node, port ) # classmethod
     tb = TBIntf( intfName, node, port, node.nsNode, device )
     return tb
开发者ID:rascov,项目名称:OpenNet,代码行数:16,代码来源:ns3.py

示例15: Host

h0 = Host( 'h0' )
h1 = Host( 'h1' )
h2 = Host( 'h2' )
h3 = Host( 'h3' )

s0 = OVSKernelSwitch( 's0' ,inNamespace=False )
s1 = OVSKernelSwitch( 's1' ,inNamespace=False )
s2 = OVSKernelSwitch( 's2', inNamespace=False  )
s3 = OVSKernelSwitch( 's3' ,inNamespace=False ) 

c0 = RemoteController( 'c0', ip = '10.108.100.195' ) 
c1 = RemoteController( 'c1', ip = '10.108.100.248' ) 
c2 = RemoteController( 'c2', ip = '10.108.102.176' ) 
c3 = RemoteController( 'c3', ip = '10.108.101.48' )

l1 = Link( h0, s1 )
Link( h1, s1 ) 
Link( h2, s2 )
Link( h3, s3 )
Link( s0, s1 )
Link( s0, s2 )
Link( s0, s3 )

h0.setIP( '10.1.0.1/16' )
h1.setIP( '10.1.0.2/16' )
h2.setIP( '10.2.0.1/16' )
h3.setIP( '10.3.0.1/16' )

print h0.cmd('ifconfig')
c0.start()
c1.start()
开发者ID:13811271524,项目名称:sdn-mobility-management,代码行数:31,代码来源:mininet-topo-2.py


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