Learning POX OpenFlow controller : hub implementation

The idea behind this and future posts is to describe one of the popular OpenFlow controllers while learning SDN concepts. openflow In a few words the SDN concept may be summarized as a separation of the control and data planes that previously resided on the one device, i.e. a managed switch or a router. In present days a control plane, named controller, usually communicates with a data plane using OpenFlow protocol. In our case the controller is presented by POX and the data plane is implemented by OpenVSwitch. POX a python based SDN controller developed in Berkeley by James “Murphy” McCauley. pox_large_shadow The OpenFlow concept is to treat all the data flowing through a data plane as flows and control it behavior using rules that match a chosen traffic pattern. A controller can work in a reactive and proactive modes. First one means that flows are installed after controller is notified on a packet received in data path while the second one means that flows are installed in advance. To run POX I have used Linux VM where Mininet environment was installed. POX package is provided with a number of test applications that are created to showcase the controller capabilities and SDN use cases. The idea is to describe one application in each post.

A basic hub implementation

The application name is hub.py. The idea behind this app is to show reactive and proactive modes. hub A proactive behavior is represented by the following function that is hooked to the ConnectionUp event that represents a moment when connection between the controller and switch was established after a handshake process. From the code below it is obvious that a rule is installed to flood all received packets.

def _handle_ConnectionUp (event):
  msg = of.ofp_flow_mod()
  msg.actions.append(of.ofp_action_output(port = of.OFPP_FLOOD))
  event.connection.send(msg)

proactive1 A reactive behaviour is achieved by forwarding each and every packet from a data plane, i.e. switch, to controller. Then the controller requests the switch to egress this packet from all ports except the port where it was received. The code responsible for a mentioned action is presented below. It generates OpenFlow OFPT_PACKET_OUT message on each received PacketIn event.

def _handle_PacketIn (event):
  msg = of.ofp_packet_out()
  msg.data = event.ofp
  msg.actions.append(of.ofp_action_output(port = of.OFPP_FLOOD))
  event.connection.send(msg)

Flowchart

Hub

References

Hub description in POX Wiki

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s