本文整理汇总了Python中mininet.link.Link.setMAC方法的典型用法代码示例。如果您正苦于以下问题:Python Link.setMAC方法的具体用法?Python Link.setMAC怎么用?Python Link.setMAC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.link.Link
的用法示例。
在下文中一共展示了Link.setMAC方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connectToRootNS
# 需要导入模块: from mininet.link import Link [as 别名]
# 或者: from mininet.link.Link import setMAC [as 别名]
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