以下是我要运行的代码:
#!/usr/bin/python
"""
This example shows how to create an empty Mininet object
(without a topology object) and add nodes to it manually.
"""
from mininet.net import Mininet
from mininet.node import Controller
from mininet.cli import CLI
from mininet.log import setLogLevel, info
from mininet.link import TCLink
def emptyNet():
"Create an empty network and add nodes to it."
net = Mininet( controller=Controller )
info( '*** Adding controller\n' )
net.addController( 'c0' )
info( '*** Adding hosts\n' )
h1 = net.addHost( 'h1', ip='10.0.0.1' )
h2 = net.addHost( 'h2', ip='10.0.0.2' )
info( '*** Adding switch\n' )
s3 = net.addSwitch( 's3' )
info( '*** Creating links\n' )
net.addLink( h1, s3 )
net.addLink( h2, s3 )
# MY CODE ######################
# Remove link and add new link with delay and lower bandwidth
net.delLinkBetween(h1, s3)
net.delLinkBetween(h2, s3)
net.addLink(h1, s3, cls=TCLink, bw=50,delay=5)
net.addLink(h2, s3, cls=TCLink, bw=50,delay=5)
################################
info( '*** Starting network\n')
net.start()
info( '*** Running CLI\n' )
CLI( net )
info( '*** Stopping network' )
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
emptyNet()
这是来自Mininet的~/mininet/examples/emptynet.py
。我只是添加了delLinkBetween
函数以删除先前的链接,以便我可以再次链接它们,但是会延迟并且带宽较低。但是我得到一个错误,提示'Mininet' object has no attribute 'delLinkBetween'
然而,函数delLinkBetween
是在Mininet的Python API参考手册:http://mininet.org/api/classmininet_1_1net_1_1Mininet.html中定义的。
我尝试重新安装Mininet的最新版本,而我目前的版本是2.2.2。 Mininet随附的Python是版本2.7.6。原始的~/mininet/examples/emptynet.py
可以正常工作,因此很可能正确安装并设置了Mininet。我也尝试过在其他主机上运行该程序无济于事。