Visual Studio 中的 Python 代码显示“引发异常('找不到默认的 OpenFlow 控制器')”错误
发布时间:2022-04-21 02:39:56 330
相关标签:
我刚刚开始使用mininet,并尝试使用python构建网络。我试着运行图中所示的代码,并将其粘贴到下面的图片中。然而,它显示出多个错误,你能告诉我哪里做错了吗。
代码:
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.util import dumpNodeConnections
from mininet.log import setLogLevel
class SingleSwitchTopo(Topo):
"Single switch connected to n hosts."
def build(self, n=2):
switch = self.addSwitch('s1')
# Python's range(N) generates 0..N-1
for h in range(n):
host = self.addHost('h%s' % (h + 1))
self.addLink(host, switch)
def simpleTest():
"Create and test a simple network"
topo = SingleSwitchTopo(n=4)
net = Mininet(topo)
net.start()
print( "Dumping host connections" )
dumpNodeConnections(net.hosts)
print( "Testing network connectivity" )
net.pingAll()
net.stop()
if __name__ == '__main__':
# Tell mininet to print useful information
setLogLevel('info')
simpleTest()
终端输出:
*** Creating network
*** Adding controller
Traceback (most recent call last):
File "def_in_python.py", line 31, in
simpleTest()
File "def_in_python.py", line 19, in simpleTest
net = Mininet(topo)
File "/usr/lib/python2.7/dist-packages/mininet/net.py", line 172, in __init__
self.build()
File "/usr/lib/python2.7/dist-packages/mininet/net.py", line 444, in build
self.buildFromTopo( self.topo )
File "/usr/lib/python2.7/dist-packages/mininet/net.py", line 411, in buildFromTopo
self.addController( 'c%d' % i, cls )
File "/usr/lib/python2.7/dist-packages/mininet/net.py", line 261, in addController
controller_new = controller( name, **params )
File "/usr/lib/python2.7/dist-packages/mininet/node.py", line 1544, in DefaultController
raise Exception( 'Could not find a default OpenFlow controller' )
Exception: Could not find a default OpenFlow controller
在此处输入图像描述
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报