Monday, October 28, 2013

Install Floodlight controller on ubuntu 12.04 +

Prerequisites

Ubuntu 10.04 (Natty) or higher.
Install JDK and Ant by running “sudo apt-get install build-essential default-jdk ant python-dev eclipse”

Download and build

$ git clone git://github.com/floodlight/floodlight.git
$ cd floodlight
$ git checkout stable
$ ant;


Running Floodlight

Assuming java is in your path, directly run the floodlight.jar file produced by ant.

 $ java -jar target/floodlight.jar

Additionl stuff on how to set Java path

$sudo su
$vim .bashrc


Include following lines at the end of the file

export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_25
export JAVA_HOME
PATH=$PATH:$JAVA_HOME
export PATH


Then go to /etc/environment
add this line:

JAVA_HOME=/usr/lib/jvm/jdk1.7.0_25

Then go to /etc/profile.d/java.sh (create it if necessary)

export JDK_HOME=/usr/lib/jvm/jdk1.7.0_25
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_25


Then in a terminal run:

sudo chmod +x /etc/profile.d/java.sh
source /etc/profile.d/java.sh


Check the path

echo $JAVA_HOME


Prerequisites

Linux

  • Ubuntu 10.04 (Natty) or higher.  (Has been run with Ubuntu 10.04 with Ant versions 1.8.1 or lower).
  • Install JDK and Ant by running “sudo apt-get install build-essential default-jdk ant python-dev eclipse”
- See more at: http://www.projectfloodlight.org/getting-started/#sthash.vgwXGTWY.dpuf

Prerequisites

Linux

  • Ubuntu 10.04 (Natty) or higher.  (Has been run with Ubuntu 10.04 with Ant versions 1.8.1 or lower).
  • Install JDK and Ant by running “sudo apt-get install build-essential default-jdk ant python-dev eclipse”
- See more at: http://www.projectfloodlight.org/getting-started/#sthash.vgwXGTWY.dpuf

Friday, October 25, 2013

Change the role of the POX controller (Master / Slave)

Use the openflow.nicira

Go inside the POX folder
$sudo python ./pox.py py openflow.nicira forwarding.l2_learning


POX> import pox.openflow.nicira as nx
POX> for connection in core.openflow.connections:
 ...            connection.send(nx.nx_role_request(master="true"))

Example 

Two controllers are running in PC1 and PC2
PC1 controller requesting the Master role






Mininet script for multiple controllers

Controller 1 is running on 192.168.200.22
Controller 2 is running on the same machine that mininet is running

============================================

#!/usr/bin/python

from mininet.net import Mininet
from mininet.node import Controller, OVSKernelSwitch, RemoteController
from mininet.cli import CLI
from mininet.log import setLogLevel, info

def emptyNet():

    net = Mininet(controller=RemoteController, switch=OVSKernelSwitch)

    c1 = net.addController('c1', controller=RemoteController, ip="192.168.200.22", port=6633)
    c2 = net.addController('c2', controller=RemoteController, ip="127.0.0.1", port=6633)

    h1 = net.addHost( 'h1', ip='10.0.0.1' )
    h2 = net.addHost( 'h2', ip='10.0.0.2' )
    h3 = net.addHost( 'h3', ip='10.0.0.3' )
    h4 = net.addHost( 'h4', ip='10.0.0.4' )

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

    s1.linkTo( h1 )
    s1.linkTo( h2 )
    s1.linkTo( s2 )
    s2.linkTo( h3 )
    s2.linkTo( h4 )

    net.build()
    c1.start()
    c2.start()
    s1.start([c1,c2])
    s2.start([c1,c2])

    net.start()
    net.staticArp()
    CLI( net )
    net.stop()

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

In band controller


SDN Can be deployed in two ways..

Out Band Control : All the switches are directly connected to controller. So controller traffic go via the directly connected links.

s1 ---  s2 --- s3
 l         l       l
 l ----- c1----- l

In Band Control : A switch is connected to the controller via another switch

s1 --- s2
 l
c1


#!/usr/bin/python

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

class InbandController( RemoteController ):

    def checkListening( self ):
        "Overridden to do nothing."
        return

def emptyNet():

    "Create an empty network and add nodes to it."

    net = Mininet( topo=None, build=False)

    net.addController('c0', controller=InbandController, ip='10.0.0.1')

    h1 = net.addHost( 'h1', ip='10.0.0.1' )
    h2 = net.addHost( 'h2', ip='10.0.0.2' )
    h3 = net.addHost( 'h3', ip='10.0.0.3' )

    s1 = net.addSwitch( 's1', cls=OVSSwitch )

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

    net.start()
    s1.cmd('ifconfig s1 10.0.0.10')

    CLI( net )
    net.stop()

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


xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

We start the controller in h1..

So start the controller.  First open an xterm to h1, which is where we said the controller would be.

mininet> xterm h1

When the xterm opens, start the controller. For this quick test, we will just start the OpenFlow Reference controller.

root@mininet-vm:~# controller -v ptcp:6633

This means that the controller and switch are successfully talking to each other.  And if you do a pingall now.

mininet> pingall
*** Ping: testing ping reachability
h1 -> h2 h3
h2 -> h1 h3
h3 -> h1 h2
*** Results: 0% dropped (6/6 received)

Switch / Link go down and come up on the fly

It is detected by openflow.discovery

s1 goes down and comes up

mininet > py s1.stop

mininet > py s1.start([c1,c2])





Add components to mininet on fly

Add a new controller, switch, two hosts

mininet> py net.addController('c2', IP="127.0.0.2", port=6633)

mininet> py net.addSwitch('s2')
mininet> py s2.start([c2])

mininet> py net.addHost('h4')
mininet> py net.addLink(s2, net.get('h4'))
mininet> py s2.attach('s2-eth1')
mininet> py net.get('h4').cmd('ifconfig h4-eth0 10.4')

mininet> py net.addHost('h5')
mininet> py net.addLink(s2, net.get('h5'))
mininet> py s2.attach('s2-eth2')
mininet> py net.get('h5').cmd('ifconfig h5-eth0 10.5')

Thursday, October 3, 2013

Multiple controllers and Mininet on the same VM

1) Mininet Script

c1 = net.addController('c1', controller=RemoteController, ip="127.0.0.2", port=6633)
c2 = net.addController('c2', controller=RemoteController, ip="127.0.0.1", port=6634)

2) Start POX controllers

./pox.py --port=6633 MyScript.py
./pox.py --port=6634 MyScript.py