POX is invoked by running pox.py and has a couple of optional command line arguments than can be used at the start of the command line
Eg : ./pox.py log.level --DEBUG samples.pretty_log openflow.keepalive --interval=15 forwarding.l2_pairs
POX functionality is provided by components(python modules) which are specified on the command line. In the above example forwarding.l2_pairs is the functionality of the openflow controller. We can invoke more then one component, especially when one component is dependent on the other
There are some of the components whcih come along with pox, but the main focus is to write our own component. Write your modules and place them where pox can find it(eg. PYTHONPATH) or in the "ext" directory ~/pox/ext/
POX has a core object to which components will register on the core object and other components will query the core object.The POX OpenFlow component by default registers an instance of OpenFlowNexus as core.openflow, and other applications can then access a lot of the OpenFlow functionality from there.
#This component just monitors the connection up and down events
#when any switch connects and disconnections"
core.openflow.addListeners():
Registers MyComponent class to listen for multiple events defined in openflow object. Which means for any method in openflow defined as _handle_EventName is replaced by the same method defined under MyComponent class and set as the listner.
_handle_ConnectionUp():
Event raised when the connection to an OpenFlow switch has been established
_handle_ConnectionDown():
Event raised when the connection to an OpenFlow switch has been lost.
Each pox component should contain the launch() function via which pox initializes the component. Mainly used to pass the command line parameters for the component.
core.registerNew() registers a new component with the core object
Eg : ./pox.py log.level --DEBUG samples.pretty_log openflow.keepalive --interval=15 forwarding.l2_pairs
POX functionality is provided by components(python modules) which are specified on the command line. In the above example forwarding.l2_pairs is the functionality of the openflow controller. We can invoke more then one component, especially when one component is dependent on the other
There are some of the components whcih come along with pox, but the main focus is to write our own component. Write your modules and place them where pox can find it(eg. PYTHONPATH) or in the "ext" directory ~/pox/ext/
POX has a core object to which components will register on the core object and other components will query the core object.The POX OpenFlow component by default registers an instance of OpenFlowNexus as core.openflow, and other applications can then access a lot of the OpenFlow functionality from there.
#This component just monitors the connection up and down events
#when any switch connects and disconnections"
core.openflow.addListeners():
Registers MyComponent class to listen for multiple events defined in openflow object. Which means for any method in openflow defined as _handle_EventName is replaced by the same method defined under MyComponent class and set as the listner.
_handle_ConnectionUp():
Event raised when the connection to an OpenFlow switch has been established
_handle_ConnectionDown():
Event raised when the connection to an OpenFlow switch has been lost.
class MyComponent(object):
def __init__ (self):
core.openflow.addListeners(self)
log.debug("Hi starting the controller")
def _handle_ConnectionUp (self, event):
log.debug("Switch %s has come up", dpid_to_str(event.dpid))
def _handle_ConnectionDown(self, event):
log.debug("Swtich %s is down", dpid_to_str(event.dpid))
def __init__ (self):
core.openflow.addListeners(self)
log.debug("Hi starting the controller")
def _handle_ConnectionUp (self, event):
log.debug("Switch %s has come up", dpid_to_str(event.dpid))
def _handle_ConnectionDown(self, event):
log.debug("Swtich %s is down", dpid_to_str(event.dpid))
Each pox component should contain the launch() function via which pox initializes the component. Mainly used to pass the command line parameters for the component.
core.registerNew() registers a new component with the core object
def launch():
core.registerNew(MyComponent)
core.registerNew(MyComponent)
from pox.lib.util import dpid_to_str
log = core.getLogger()