本文整理汇总了Python中mininet.net.Mininet.addLinks方法的典型用法代码示例。如果您正苦于以下问题:Python Mininet.addLinks方法的具体用法?Python Mininet.addLinks怎么用?Python Mininet.addLinks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.net.Mininet
的用法示例。
在下文中一共展示了Mininet.addLinks方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: emptyNet
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import addLinks [as 别名]
def emptyNet():
"Create an empty network and add nodes to it."
args=(sys.argv)
no_of_hosts=int(args[1])
no_of_Switches=int(args[2])
print "no of hosts : "+no_of_hosts
print "no of swithes : "+no_of_switches
net = Mininet( controller=Controller )
info( '*** Adding controller\n' )
net.addController( 'c0' )
info( '*** Adding hosts\n' )
hosts=[]
for i in range(no_of_hosts):
hosts.append(net.addHost('h'+str(i+1)))
info( '*** Adding switch\n' )
switches=[]
for i in range(no_of_hosts):
switches.append(net.addSwitch('s'+str(i+1)))
info( '*** Creating links\n' )
for i in range(no_of_switches):
if i+2 < no_of_switches:
net.addLinks(switches[i],switches[i+2])
if i%2 == 0 :
t1=net.addLinks(switches[i],hosts[2*i])
t2=net.addLinks(switches[i],hosts[2*i+2])
t1.intf1.config(bw = 2)
t2.intf1.config(bw = 2)
else:
k1=net.addLinks(switches[i],hosts[2*i-1])
k2=net.addLinks(switches[i],hosts[2*i+1])
k1.intf1.config(bw = 1)
k2.intf1.config(bw = 1)
info( '*** Starting network\n')
net.start()
info( '*** Running CLI\n' )
CLI( net )
info( '*** Stopping network' )
net.stop()