Python 自定义拓扑迷你网

Python 自定义拓扑迷你网,python,networking,sdn,mininet,topology,Python,Networking,Sdn,Mininet,Topology,我正在开发一个项目,在这个项目中,我必须创建一个圆形拓扑,但是当我运行拓扑时,这会给我一个错误 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 set

我正在开发一个项目,在这个项目中,我必须创建一个圆形拓扑,但是当我运行拓扑时,这会给我一个错误

 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
mininet@mininet-vm:~/mininet/custom$sudo python custom-topo-proj.py
回溯(最近一次呼叫最后一次):
文件“custom topo proj.py”,第60行,输入
net.addNAT().configDefault()
addNAT中第282行的文件“build/bdist.linux-x86_64/egg/mininet/net.py”
索引器:列表索引超出范围

如果有人帮我解决这个问题,我会启动nat并连接所有链接