本文整理汇总了Python中mininet.util.macColonHex函数的典型用法代码示例。如果您正苦于以下问题:Python macColonHex函数的具体用法?Python macColonHex怎么用?Python macColonHex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了macColonHex函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _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
示例2: _install_proactive_path
def _install_proactive_path(self, src, dst):
"""Install entries on route between two hosts based on MAC addrs.
src and dst are unsigned ints.
"""
src_sw = self.t.up_nodes(self.t.id_gen(dpid = src).name_str())
assert len(src_sw) == 1
src_sw_name = src_sw[0]
dst_sw = self.t.up_nodes(self.t.id_gen(dpid = dst).name_str())
assert len(dst_sw) == 1
dst_sw_name = dst_sw[0]
hash_ = self._src_dst_hash(src, dst)
route = self.r.get_route(src_sw_name, dst_sw_name, hash_)
log.info("route: %s" % route)
# Form OF match
match = of.ofp_match()
match.dl_src = EthAddr(macColonHex(src)).toRaw()
match.dl_dst = EthAddr(macColonHex(dst)).toRaw()
dst_host_name = self.t.id_gen(dpid = dst).name_str()
final_out_port, ignore = self.t.port(route[-1], dst_host_name)
for i, node in enumerate(route):
node_dpid = self.t.id_gen(name = node).dpid
if i < len(route) - 1:
next_node = route[i + 1]
out_port, next_in_port = self.t.port(node, next_node)
else:
out_port = final_out_port
self.switches[node_dpid].install(out_port, match)
开发者ID:adk9,项目名称:riplpox,代码行数:30,代码来源:riplpox.py
示例3: addLink
def addLink(self, node1, node2, port1=None, port2=None, cls=None, **params):
""""Add a link from node1 to node2
node1: source node
node2: dest node
port1: source port
port2: dest port
returns: link object"""
mac1 = macColonHex(random.randint(1, 2 ** 48 - 1) & 0xFEFFFFFFFFFF | 0x020000000000)
mac2 = macColonHex(random.randint(1, 2 ** 48 - 1) & 0xFEFFFFFFFFFF | 0x020000000000)
defaults = {"port1": port1, "port2": port2, "addr1": mac1, "addr2": mac2, "intf": self.intf}
defaults.update(params)
if not cls:
cls = self.link
return cls(node1, node2, **defaults)
开发者ID:ruifcardoso,项目名称:mininet,代码行数:14,代码来源:net.py
示例4: addHost
def addHost( self, name, cls=None, **params ):
"""Add host.
name: name of host to add
cls: custom host class/constructor (optional)
params: parameters for host
returns: added host"""
defaults = {}
autoSetIp = params.get( 'autoSetIp', True )
if autoSetIp:
# Default IP and MAC addresses
defaults[ 'ip' ] = ipAdd( self.nextIP, ipBaseNum=self.ipBaseNum,
prefixLen=self.prefixLen) + '/%s' % (self.prefixLen,)
if self.autoSetMacs:
defaults[ 'mac' ] = macColonHex( self.nextIP )
self.nextIP += 1
if self.autoPinCpus:
defaults[ 'cores' ] = self.nextCore
self.nextCore = ( self.nextCore + 1 ) % self.numCores
defaults.update( params )
if not cls:
cls = self.host
h = cls( name, **defaults )
self.hosts.append( h )
self.nameToNode[ name ] = h
return h
开发者ID:backb1,项目名称:mininet,代码行数:27,代码来源:net.py
示例5: addHost
def addHost( self, name, cls=None, **params ):
"""Add host.
name: name of host to add
cls: custom host class/constructor (optional)
params: parameters for host
returns: added host"""
# Default IP and MAC addresses
defaults = { 'ip': ipAdd( self.nextIP,
ipBaseNum=self.ipBaseNum,
prefixLen=self.prefixLen ) +
'/%s' % self.prefixLen }
print defaults
IPS=[]
for lin in defaults.values():
IPS.append(lin[0:8])
print IPS
with open('my_dict.json','a')as f:
json.dump(defaults.values(),f)
f.write('\n')
if self.autoSetMacs:
defaults[ 'mac'] = macColonHex( self.nextIP )
if self.autoPinCpus:
defaults[ 'cores' ] = self.nextCore
self.nextCore = ( self.nextCore + 1 ) % self.numCores
self.nextIP += 1
defaults.update( params )
if not cls:
cls = self.host
h = cls( name, **defaults )
self.hosts.append( h )
self.nameToNode[ name ] = h
return h
开发者ID:enavacp,项目名称:mininet,代码行数:33,代码来源:net.py
示例6: addNode
def addNode( prefix, addMethod, nodeId ):
"Add a host or a switch."
name = prefix + topo.name( nodeId )
mac = macColonHex( nodeId ) if self.setMacs else None
ip = topo.ip( nodeId )
node = addMethod( name, mac=mac, ip=ip )
self.idToNode[ nodeId ] = node
info( name + ' ' )
开发者ID:meiyangbigswitch,项目名称:mininet,代码行数:8,代码来源:net.py
示例7: addLink
def addLink( self, node1, node2, port1=None, port2=None,
cls=None, **params ):
""""Add a link from node1 to node2
node1: source node
node2: dest node
port1: source port
port2: dest port
returns: link object"""
mac1 = macColonHex( random.randint(1, 2**48 - 1) & 0xfeffffffffff | 0x020000000000 )
mac2 = macColonHex( random.randint(1, 2**48 - 1) & 0xfeffffffffff | 0x020000000000 )
defaults = { 'port1': port1,
'port2': port2,
'addr1': mac1,
'addr2': mac2,
'intf': self.intf }
defaults.update( params )
if not cls:
cls = self.link
link = cls( node1, node2, **defaults )
self.links.append( link )
return link
开发者ID:Azmonkh,项目名称:mininet,代码行数:21,代码来源:net.py
示例8: addStation
def addStation( self, name, cls=None, **params ):
"""Add host.
name: name of host to add
cls: custom host class/constructor (optional)
params: parameters for host
returns: added host"""
#Default IP and MAC addresses
defaults = { 'ip': ipAdd( self.nextIP,
ipBaseNum=self.ipBaseNum,
prefixLen=self.prefixLen ) +
'/%s' % self.prefixLen }
if self.autoSetMacs:
defaults[ 'mac' ] = macColonHex( self.nextIP )
if self.autoPinCpus:
defaults[ 'cores' ] = self.nextCore
self.nextCore = ( self.nextCore + 1 ) % self.numCores
#self.nextIP += 1
defaults.update( params )
if not cls:
cls = self.host
h = cls( name, **defaults )
self.hosts.append( h )
self.nameToNode[ name ] = h
self.wirelessifaceControl.append(self.nextIface)
self.wirelessdeviceControl.append(name)
self.stationName.append(name)
os.system("iw phy phy%s set netns %s" % (self.nextIface, h.pid))
self.host.cmd(h,"ip link set dev wlan%s name %s-wlan0" % (self.nextIface, h))
self.host.cmd(h,"ifconfig %s-wlan0 up" % h)
self.host.cmd(h,"ifconfig %s-wlan0 10.1.1.%s/%s" % (h, self.nextIP, self.prefixLen))
#callfun="start"
#intf=self.nextIface
#src=name
#wlink(callfun, intf, src)
#self.host.cmd(h,"iw %s-wlan0 connect %s" % (h, "my_ssid"))
self.nextIP += 1
self.nextIface+=1
#os.system("iw dev wlan2 interface add mesh2 type station")
#os.system("sleep 2")
#os.system("sleep 2")
#os.system("iw dev mesh2 station join bazookaa")
return h
开发者ID:ruacon35,项目名称:mininet-wifi,代码行数:45,代码来源:net.py
示例9: addHost
def addHost(self, name, cls=None, **params):
"""Add host.
name: name of host to add
cls: custom host class/constructor (optional)
params: parameters for host
returns: added host"""
# Default IP and MAC addresses
defaults = {
"ip": ipAdd(self.nextIP, ipBaseNum=self.ipBaseNum, prefixLen=self.prefixLen) + "/%s" % self.prefixLen
}
if self.autoSetMacs:
defaults["mac"] = macColonHex(self.nextIP)
if self.autoPinCpus:
defaults["cores"] = self.nextCore
self.nextCore = (self.nextCore + 1) % self.numCores
self.nextIP += 1
defaults.update(params)
if not cls:
cls = self.host
h = cls(name, **defaults)
self.hosts.append(h)
self.nameToNode[name] = h
return h
开发者ID:ruifcardoso,项目名称:mininet,代码行数:23,代码来源:net.py
示例10: addTransitPortalRouter
def addTransitPortalRouter( self, name, cls=None, **params ):
"""Add transit portal router.
name: name of transit portal router to add
cls: custom router class/constructor (optional)
returns: added transit portal router ."""
# Default IP and MAC addresses
defaults = { 'ip': ipAdd( self.nextIP,
ipBaseNum=self.ipBaseNum,
prefixLen=self.prefixLen ) +
'/%s' % self.prefixLen }
if self.autoSetMacs:
defaults[ 'mac'] = macColonHex( self.nextIP )
if self.autoPinCpus:
defaults[ 'cores' ] = self.nextCore
self.nextCore = ( self.nextCore + 1 ) % self.numCores
self.nextIP += 1
defaults.update( params )
if not cls:
cls = self.transitPortalRouter
tpr = cls( name, **defaults )
self.transitPortalRouters.append( tpr )
self.nameToNode[ name ] = tpr
return tpr
开发者ID:aimonb,项目名称:miniNeXT,代码行数:24,代码来源:net.py
示例11: randMac
def randMac():
"Return a random, non-multicast MAC address"
return macColonHex( random.randint(1, 2**48 - 1) & 0xfeffffffffff |
0x020000000000 )
开发者ID:hackerenRG,项目名称:mininet,代码行数:4,代码来源:net.py
注:本文中的mininet.util.macColonHex函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论