使用 RYU 控制器在 SDN mininet 中无法访问目标主机

Destination host is unreachable in SDN mininet with RYU controller

我使用 mininet 和 RYU 控制器创建了如下所示的 mininet 拓扑

from mininet.topo import Topo
from mininet.net import Mininet
from mininet.log import setLogLevel
from mininet.node import OVSSwitch, Controller, RemoteController
from mininet.cli import CLI
from time import sleep

class ResearchTopo(Topo):
    def build(self):
        s1 = self.addSwitch('s1')
        s2 = self.addSwitch('s2')
        s3 = self.addSwitch('s3')
        s4 = self.addSwitch('s4')
        s5 = self.addSwitch('s5')

        h1 = self.addHost('h1')
        h2 = self.addHost('h2')
        h3 = self.addHost('h3')
        h4 = self.addHost('h4')
        h5 = self.addHost('h5')
        h6 = self.addHost('h6')
    

        self.addLink(h1,s3)
        self.addLink(h2,s3)
        self.addLink(h3,s4)
        self.addLink(h4,s4)
        self.addLink(h5,s5)
        self.addLink(h6,s5)

        self.addLink(s1,s3)     
        self.addLink(s1,s4)     
        self.addLink(s1,s5)
        self.addLink(s2,s3)     
        self.addLink(s2,s4)
        self.addLink(s2,s5)

if __name__ == '__main__':
    setLogLevel('info')
    topo = ResearchTopo()
    c1 = RemoteController('c1', ip='127.0.0.1')
    net = Mininet(topo = topo, controller = c1)
    net.start()
    CLI(net)
    net.stop()

但是如果我尝试互相 ping 对方,它说目标主机无法访问。如果我删除 s1 或 s2 开关它工作正常。

您正在定义一个带环路的网络。

在这种情况下,您需要定义生成树协议 (STP) 以构建无环逻辑拓扑。这里是 Ryu 控制器的 guide