Mininet-wifi 无法使用 Python 导入名称 OVSKernelAP

问题描述 投票:0回答:2

我正在使用 Mininet-Wifi 构建 SDN 网络,我有这个小型网络作为测试,只是为了了解有关 Python 的更多信息,所以我运行这段代码

!/usr/bin/python

from mininet.net import Mininet
from mininet.node import Controller, RemoteController, OVSKernelAP
from mininet.link import TCLink
from mininet.cli import CLI
from mininet.log import setLogLevel

def topology():

"Create a network."
net = Mininet( controller=Controller, link=TCLink, accessPoint=OVSKernelAP )

print "*** Creating nodes"
h1 = net.addHost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8' )
h2 = net.addHost( 'h2', mac='00:00:00:00:00:11', ip='10.0.1.1/8' )

sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8', position='50,50,0' )
sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8', position='40,50,0')
sta3 = net.addStation( 'sta3', mac='00:00:00:00:00:04', ip='10.0.0.4/8', position='20,50,0' )

ap1 = net.addAccessPoint( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '5', 
position='25,50,0', range='35' )
ap2 = net.addAccessPoint( 'ap2', ssid= 'new-ssid', mode= 'g', channel= '5', 
position='75,50,0', range='35' )

c1 = net.addController( 'c1' )

s1 = net.addSwitch('s1')

#net.runAlternativeModule('../module/mac80211_hwsim.ko')

print "*** Configuring wifi nodes"
net.configureWifiNodes()

print "*** Associating and Creating links"

net.addLink(ap1, s1)
net.addLink(ap2, s1)
net.addLink(s1, c1)
#net.addLink(ap1, ap2)

net.addLink(s1, h1)
net.addLink(s1, h2)

net.addLink(ap1, sta1)
net.addLink(ap1, sta2)
net.addLink(ap1, sta3)

print "*** Starting network"
net.build()
c1.start()
ap1.start( [c1] )
ap2.start( [c1] )

"""uncomment to plot graph"""
net.plotGraph(max_x=100, max_y=100)

net.startMobility(startTime=0)
net.mobility(sta1, 'start', time=1, position='0.0,50.0,0.0')
net.mobility(sta1, 'stop', time=30, position='100.0,50.0,0.0')
net.stopMobility(stopTime=31)

print "*** Running CLI"
CLI( net )

print "*** Stopping network"
net.stop()

if __name__ == '__main__':
setLogLevel( 'info' )
topology()

运行“sudo mn --custom test.py”(我的文件名是 test.py )后出现错误。

捕获异常。正在清理...导入错误:无法导入名称 OVSKernelAP

我能做什么?我已经安装了 mininet 和 mininet-wifi。

python sdn mininet
2个回答
1
投票

错误的主要来源在第 3 至 7 行。使用 Mininet-wifi,您只需导入以下内容:

from mininet.log import setLogLevel, info
from mn_wifi import CLI
from mn_wifi import Mininet_wifi

这就是您需要导入的全部内容。您可能还会遇到一些错误,例如您的接入点的最小范围应为 116m,并且 s1 和 ap1 将具有相同的 DPID,因此您应该将 s1 更改为 s3


0
投票

问题解决了吗?

我有类似的问题,如下所示:我正在使用 https://github.com/ramonfontes/reproducible-research/blob/master/mininet-wifi/IEEE-Access-2017/README.md 来源而不是你的来源,但我们我想也有类似的问题。

mininet-wifi/reproducible-research/mininet-wifi/IEEE-Access-2017/vanet.py”,第 15 行,在 从 mininet.node 导入控制器、OVSKernelSwitch、OVSKernelAP、汽车 ImportError:无法从“mininet.node”(/usr/lib/python3/dist-packages/mininet/node.py)导入名称“OVSKernelAP”

© www.soinside.com 2019 - 2024. All rights reserved.