简体   繁体   English

Python visual studio 中的代码显示“引发异常('Could not find a default OpenFlow controller')”错误

[英]Python code in visual studio showing "raise Exception( 'Could not find a default OpenFlow controller' )" error

I have just started with the min.net and trying to build.networks using python. I have tried to run the code shown in the image and pasted here in the following.我刚刚开始使用 min.net 并尝试使用 python 构建网络。我尝试运行图中显示的代码并粘贴在下面的此处。 However, it is showing multiple errors.但是,它显示多个错误。 Can you please tell me where am I doing it wrong.你能告诉我我哪里做错了吗?

Code:代码:

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()

Terminal Output:终端Output:

*** Creating network
*** Adding controller
Traceback (most recent call last):
  File "def_in_python.py", line 31, in <module>
    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

enter image description here在此处输入图像描述

You must install openvswitch-testcontroller.您必须安装 openvswitch-testcontroller。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM