Lab 10 : Test  features request/reply

In this lab, I will show how to get the capabilities of a port for a specific switch.

[test_features_request.py: put this file under /pox/ext]

from pox.core import core

import pox.openflow.libopenflow_01 as of

from pox.lib.util import dpidToStr

 

log = core.getLogger()

 

def _handle_features_reply (event):

  print "got the features_reply"

  print event.connection.features.datapath_id, event.connection.features.n_buffers, event.connection.features.n_tables, event.connection.features.capabilities, event.connection.features.actions

  print “OFPPF_10GB_FD=”, of.OFPPF_10GB_FD

  print “OFPPF_COPPER=”, of.OFPPF_COPPER

 

  for m in event.connection.features.ports:

    print m.name,m.port_no,m.hw_addr,m.curr,m.advertised,m.supported,m.peer,m.config,m.state

 

def _handle_ConnectionUp (event):

  for m in event.connection.features.ports:

    if m.name == "s1-eth1":

      core.openflow.getConnection(event.connection.dpid).send(of.ofp_features_request())

  msg = of.ofp_flow_mod()

  msg.priority =1

  msg.idle_timeout = 0

  msg.hard_timeout = 0

  msg.match.in_port =1

  msg.actions.append(of.ofp_action_output(port = 2))

  event.connection.send(msg)

 

  msg = of.ofp_flow_mod()

  msg.priority =1

  msg.idle_timeout = 0

  msg.hard_timeout = 0

  msg.match.in_port =2

  msg.actions.append(of.ofp_action_output(port = 1))

  event.connection.send(msg)

 

def launch ():

  core.openflow.addListenerByName("ConnectionUp", _handle_ConnectionUp)

  core.openflow.addListenerByName("FeaturesReceived", _handle_features_reply)

 

 

[test]

Step 1

sudo mn –topo single,2 will create the following network scenario.

h1---s1---h2

  

Step 2

From the above feature, we can see that

a)      There are two ports for switch s1, i.e. s1-eth1 and s2-eth2.

b)       The current features for the port s1-eth1 and s2-eth2 are 192, which is equal to 128+64. 128 means COPPER and 64 means 10GB-FD.

 

Step 3

Use the above command to verify whether the current port feature of s1-eth1 and s2-eth2 is 10GB-FD COPPER.

 

Dr. Chih-Heng Ke (smallko@gmail.com)

Department of Computer Science and Information Engineering,

National Quemoy University, Kinmen, Taiwan.