Search code examples
mininetryu

Destination host is unreachable in SDN mininet with RYU controller


I have created a mininet topology like below using mininet and RYU controller

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

but if i try to ping each other it says destination host unreachable. If i remove s1 or s2 switch it works fine.


Solution

  • You are defining a network with loops.

    In such a case, you need to define the Spanning Tree Protocol (STP) in order build a loop-free logical topology. Here a guide for the Ryu controller.