Amirreza alibeygi
Amirreza alibeygi

Reputation: 19

How should I implement a ryu controller to balance load between switches?

I should create complete mesh topology in mininet and create a load balancer on it, I can easily create that mesh topology but I cannot even ping from one host to another how should I do it? also consider that I should do it with OpenFlow. I would appreciate any guidance to me, thanks.

from mininet.net import Mininet
from mininet.node import RemoteController
from mininet.cli import CLI
from mininet.log import setLogLevel, info
from mininet.link import TCLink

def simpleNet():
    # Set log level to info
    setLogLevel('info')

    # Create the Mininet object
    net = Mininet(controller=RemoteController, link=TCLink)

    # Add a remote controller
    info('*** Adding controller\n')
    c0 = net.addController('c0', controller=RemoteController, ip='127.0.0.1', port=6633)

    # Add hosts
    info('*** Adding hosts\n')
    h1 = net.addHost('h1', ip='10.0.0.1/24')
    h2 = net.addHost('h2', ip='10.0.0.2/24')
    h3 = net.addHost('h3', ip='10.0.0.3/24')
    h4 = net.addHost('h4', ip='10.0.0.4/24')

    # Add switches
    info('*** Adding switches\n')
    s1 = net.addSwitch('s1')
    s2 = net.addSwitch('s2')
    s3 = net.addSwitch('s3')
    s4 = net.addSwitch('s4')

    # Add links between hosts and switches
    info('*** Creating links\n')
    net.addLink(h1, s1)
    net.addLink(h2, s2)
    net.addLink(h3,s3)
    net.addLink(h4,s4)

    # Add link between the switches
    net.addLink(s1, s2)
    net.addLink(s1,s3)
    net.addLink(s1,s4)
    net.addLink(s2,s4)
    net.addLink(s3,s4)
    net.addLink(s2,s3)

    # Start the network
    info('*** Starting network\n')
    net.start()

    # Test network connectivity
    info('*** Testing network connectivity\n')
    net.pingAll()

    # Start the CLI
    CLI(net)

    # Stop the network
    info('*** Stopping network\n')
    net.stop()

if __name__ == '__main__':
    simpleNet()

Upvotes: 0

Views: 53

Answers (0)

Related Questions