本文整理汇总了Python中mininet.net.Mininet.keys方法的典型用法代码示例。如果您正苦于以下问题:Python Mininet.keys方法的具体用法?Python Mininet.keys怎么用?Python Mininet.keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.net.Mininet
的用法示例。
在下文中一共展示了Mininet.keys方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: open
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import keys [as 别名]
# supress output of "sudo mn -c" command which cleans mininet
with open(os.devnull, 'wb') as devnull:
subprocess.check_call(['sudo', 'mn', '-c'], stdout=devnull,
stderr=subprocess.STDOUT)
tree = TreeTopo(depth=m, fanout=n)
try:
net = Mininet(topo=tree)
except:
cleanup()
net = Mininet(topo=tree)
print('Starting tree network')
net.start()
print('\nTree network started. Press ctrl+d to close CLI.\n')
print('--Nodes--\n' + ' '.join(net.keys()))
print('--Links--')
for link in net.links:
print('(%s,%s)' % (link.intf1.name.split('-')[0], link.intf2.name.split('-')[0])),
print('\n')
# Ping other hosts in parallel
h1 = net.get('h1')
print(h1.cmd('cat ips.txt | xargs -n 1 -I ^ -P 50 ping -c 4 ^'))
CLI(net)
print('Stopping network')
net.stop()
cleanup()