Hi
I have tried with OFPP_CONTROLLER but its not giving me statistic of that
port.
I don't know whats wrong with my code. its only giving me a blank list
instead of port statistic.
I have attached my code.
Thanks for helping.
On Fri, Aug 26, 2016 at 3:31 AM, Iwase Yusuke <[email protected]>
wrote:
> Hi,
>
> How about monitoring the switch's port which port number is
> OFPP_CONTROLLER?
> You can get this port statistics with OFPPortStatsRequest messages:
> e.g.)
> req = ofp_parser.OFPPortStatsRequest(datapath, 0, ofp.OFPP_CONTROLLER)
>
> Thanks,
> Iwase
>
>
> On 2016年08月25日 23:22, Osman Titu wrote:
>
>> Hi
>>
>> I am using RYU. For my project I need to monitor control packets,
>> specifically control packet loss between switches and controller. Is there
>> any way to monitor control packet losses?
>>
>> Any suggestion would highly be appreciated.
>>
>> Thanks
>>
>>
>>
>> ------------------------------------------------------------
>> ------------------
>>
>>
>>
>> _______________________________________________
>> Ryu-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/ryu-devel
>>
>>
from operator import attrgetter
from ryu.app import MyRyuApp
from ryu.controller import ofp_event
from ryu.controller.handler import MAIN_DISPATCHER, DEAD_DISPATCHER
from ryu.controller.handler import set_ev_cls
from ryu.lib import hub
class SimpleMonitor(MyRyuApp.ProjectController):
def __init__(self, *args, **kwargs):
super(SimpleMonitor, self).__init__(*args, **kwargs)
self.datapaths = {}
self.monitor_thread = hub.spawn(self._monitor)
@set_ev_cls(ofp_event.EventOFPStateChange,
[MAIN_DISPATCHER, DEAD_DISPATCHER])
def _state_change_handler(self, ev):
datapath = ev.datapath
if ev.state == MAIN_DISPATCHER:
if not datapath.id in self.datapaths:
self.logger.debug('register datapath: %016x', datapath.id)
self.datapaths[datapath.id] = datapath
elif ev.state == DEAD_DISPATCHER:
if datapath.id in self.datapaths:
self.logger.debug('unregister datapath: %016x', datapath.id)
del self.datapaths[datapath.id]
def _monitor(self):
while True:
for dp in self.datapaths.values():
self._request_stats(dp)
hub.sleep(10)
def _request_stats(self, datapath):
self.logger.debug('send stats request: %016x', datapath.id)
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
req = parser.OFPPortStatsRequest(datapath, 0, ofproto.OFPP_CONTROLLER)
datapath.send_msg(req)
#req = parser.OFPPortStatsRequest(datapath, 0, ofproto.OFPP_ANY)
#datapath.send_msg(req)
@set_ev_cls(ofp_event.EventOFPPortStatsReply, MAIN_DISPATCHER)
def _port_stats_reply_handler(self, ev):
body = ev.msg.body
ports = []
for stat in body:
ports.append('port_no = %d '
'rx_packets =%d rx_dropped=%d '
'tx_packets=%d tx_dropped=%d ' %
(stat.port_no,
stat.rx_packets, stat.rx_dropped,
stat.tx_packets, stat.tx_dropped))
self.logger.info('PortStats: %s', ports)
------------------------------------------------------------------------------
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel