Saturday, January 10, 2015

Collecting SDN forwarder port status at SDN Controller

This is to gather the port status of every switch or forwarder at SDN controller.

Register the port_stats_in function:

def install(self):
# Handler
        ...
self.register_for_port_stats_in(self.handle_portstats_in)
        ...


def handle_portstats_in(self, dpid, stats):
    """
    Parameters in stats: port_no, rx_packets, tx_packets, rx_bytes, tx_bytes, rx_dropped, tx_dropped,       rx_errors, tx_errors, rx_frame_err, rx_over_err, rx_crc_err, collisions
    """
    print "Port Stats received...."
    print "Port stats in from datapath", longlong_to_octstr(dpid)[6:]
    for item in stats:
print '\t',item['port_no'],':',item['tx_packets'],':',item['rx_packets']
   
   ...

No comments:

Post a Comment