Search code examples
mininet

Mininet circular topology


Why can't mininet handle circular topologies? The following code works fine. However, if I uncomment the #net.addLink( s3, s1 ) then I get 100% CPU usage and 100% drop in the net.pingAll() test.

from mininet.net import Mininet
from mininet.node import OVSController
from mininet.log import setLogLevel, info

def test():
    net = Mininet( controller = OVSController)
    net.addController( 'c0' )

    s1 = net.addSwitch( 's1' )
    s2 = net.addSwitch( 's2' )
    s3 = net.addSwitch( 's3' )

    net.addLink( s1, s2 )
    net.addLink( s2, s3 )
    #net.addLink( s3, s1 )

    h1 = net.addHost( 'h1' )
    h2 = net.addHost( 'h2' )
    h3 = net.addHost( 'h3' )

    net.addLink( s1, h1 )
    net.addLink( s2, h2 )
    net.addLink( s3, h3 )

    net.start()
    net.pingAll()
    net.stop()

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

Solution

  • If you have circular topologies, then packets can circulate in the network without arriving at their destination, eventually flooding the network. This occurs if the network devices are not aware that there is a cycle in the topology.

    Your packets sending logic should take into account that there is a cycle in the topology and send packets with awareness of this. For example, the controller can use shortest path algorithm in order to set up the correct routing rules for the switches, so that packets will arrive at their destination.

    You can also set up your own routing algorithms for that, or install the forwarding rules at the switches so matching packets will be sent to a specific destination and not circulate in the network.