Showing posts with label POX. Show all posts
Showing posts with label POX. Show all posts

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

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





Thursday, October 3, 2013

Configure openVswitch with POX controller

Configure openVswitch in openVswitch in PC1

PC1 eth0.10 interface IP is 192.168.10.100

#We attach  PC1 eth0.10 interface to the bridge connection between openVswitch in PC1 and controller

$sudo ovs-vsctl add-br br0
$sudo ovs-vsctl add-port br0 eth0.10
$sudo ifconfig br0 192.168.10.100 netmask 255.255.255.0

#Attach OpenvSwitch to the Controller which is in 192.168.100.30

$ovs-vsctl set-controller br0 tcp:192.168.100.30:6633

To remove openVswitch bridge connection

$sudo ovs-vsctl del-br br-0
$sudo ovs-vsctl del-port br-0 eth0.10

To remove the Controller

$sudo ovs-vsctl del-controller br-0


Monday, September 16, 2013

Add and delete flow paths from POX controller

POX>from pox.core import core
POX>import pox.openflow.libopenflow_01 as of
POX>from pox.lib.addresses import IPAddr

Add flows

POX>for connection in core.openflow.connections:
                connection.send(of.ofp_flow_mod(action=of.ofp_action_output(port=2),priority=32,
 match=of.ofp_match(dl_type=0x800,nw_src="10.0.0.1",nw_dst="10.0.0.2")))

Delete flows

POX>for connection in core.openflow.connections:    
                connection.send(of.ofp_flow_mod(command=of.OFPFC_DELETE_STRICT,
 action=of.ofp_action_output(port=3),priority=32,
 match=of.ofp_match(dl_type=0x800,nw_src="10.0.0.1",nw_dst="10.0.0.3")))

Dont forget to add
net.staticArp() after net.build() in mininet code

*make sure in for loops, intendent is there
     For connection....
              connection.send......

Friday, September 13, 2013

Start and stop POX controller

1) To start POX, go inside the POX folder

$sudo python ./pox.py py

         or

$sudo python ./pox.py py openflow.discovery forwarding.l2_learning

2) If it says address already in use

Find what application/process is using the pro, type:

$sudo netstat -lpn |grep :6633

You will get an output similar to this one

tcp6       0      0 :::6633                 :::*                    LISTEN      6782/java

I have got the process Id, which is 6782, now this is the process that is using port 6633. To Kill the process, type

$sudo kill 6782

3) Stop POX

POX > exit ()

If you forget it, then next time

$sudo killall controller



Wednesday, September 11, 2013

Install POX controller

POX is a platform for the rapid development and prototyping of network control software using Python.  It’s one of a growing number of frameworks (including NOX, Floodlight, Trema, etc.,) for helping to write an OpenFlow controller.

POX as well as being a framework for interacting with OpenFlow switches, it can be used as the basis for some of our ongoing work to help build the emerging discipline of Software Defined Networking.  It can be used to explore and prototype distribution, SDN debugging, network virtualization, controller design, and programming models.

Installing POX

$ git clone http://github.com/noxrepo/pox

$ cd pox