问题描述
我正在开发一个项目,在该项目中我必须制作一个圆形拓扑,但这在运行拓扑时给我一个错误。
from mininet.net import Mininet
from mininet.node import OVSSwitch,Controller
from mininet.topo import Topo
from mininet.log import setLogLevel
from mininet.cli import CLI
setLogLevel( 'info' )
# Two remote controllers
c1 = Controller( 'c1',port=6634 )
c2 = Controller( 'c2',port=6633 )
# You dont need the links between the controller and the switches,# You can connect with the personalized mapping
cmap = { 's1': c1,'s2': c1,'s3': c2,'s4': c2}
class NatTopo( Topo ):
def build( self,natIP='10.0.0.254' ):
self.hopts = { 'defaultRoute': 'via ' + natIP }
hosts = [ self.addHost( h ) for h in 'h1','h2','h3','h4' ]
s1 = self.addSwitch( 's1' )
s2 = self.addSwitch( 's2' )
s3 = self.addSwitch( 's3' )
s4 = self.addSwitch( 's4' )
for h in hosts:
self.addLink( s1,h )
self.addLink( s2,h )
self.addLink( s3,h )
self.addLink( s4,h )
nat1 = self.addNode( 'nat1',cls=NAT,ip=natIP,inNamespace=False )
self.addLink( nat1,s1 )
self.addLink( nat1,s2 )
self.addLink( nat1,s3 )
self.addLink( nat1,s4 )
class MultiSwitch( OVSSwitch ):
"Custom Switch() subclass that connects to different controllers"
def start( self,controllers ):
return OVSSwitch.start( self,[ cmap[ self.name ] ] )
class MyTopo(Topo):
def __init__( self ):
"Create custom topo."
topo = MyTopo()
net = Mininet( topo=topo,switch=MultiSwitch,build=False )
net.addNAT().configDefault()
for c in [ c1,c2 ]:
net.addController(c)
net.build()
net.start()
CLI( net )
net.stop()
topos = { 'mytopo': ( lambda: MyTopo() ) }
当我尝试启动拓扑时,出现以下错误:
mininet@mininet-vm:~/mininet/custom$ sudo python custom-topo-proj.py
Traceback (most recent call last):
File "custom-topo-proj.py",line 60,in <module>
net.addNAT().configDefault()
File "build/bdist.linux-x86_64/egg/mininet/net.py",line 282,in addNAT
IndexError:列表索引超出范围
如果有任何感冒可以帮助我解决该问题,请立即启动nat并连接所有链接
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)