Hi,

On 2015年12月30日 02:30, Zahi Gradstein wrote:
> Hi,
> I hope this is where I should send this E-Mail J
> 
>  
> 
> I’m having an issue with port stats reply handler at RYU Controller.
> 
>  
> 
> My code is as following:
> 
>  
> 
> *def send_port_stats_request(datapath, port_num):*
> 
>     ofp = datapath.ofproto
> 
>     ofp_parser = datapath.ofproto_parser
> 
>  
> 
>     req = ofp_parser.OFPPortStatsRequest(datapath, 0, port_num)
> 
>     return datapath.send_msg(req)
> 
>  
> 
>  
> 
>     @set_ev_cls(ofp_event.EventOFPPortStatsReply, MAIN_DISPATCHER)
> 
> *    def port_stats_reply_handler(self, ev):*
> 
>         ports = []
> 
>         for stat in ev.msg.body:
> 
>             print(' \nStatistics of port_no: %d \n'
> 
>                   ' rx_packets:    %d \n tx_packets:    %d \n'
> 
>                   ' rx_bytes:      %d \n tx_bytes:      %d \n'
> 
>                   ' rx_dropped:    %d \n tx_dropped:    %d \n'
> 
>                   ' rx_errors:     %d \n tx_errors:     %d \n'
> 
>                   ' rx_frame_err:  %d \n rx_over_err:   %d \n rx_crc_err:    
> %d \n'
> 
>                   ' collisions:    %d \n duration_sec:  %d \n duration_nsec: 
> %d \n'
> 
>                   ' --- End of statistics --- \n' %
> 
>                   (stat.port_no,
> 
>                    stat.rx_packets, stat.tx_packets,
> 
>                    stat.rx_bytes, stat.tx_bytes,
> 
>                    stat.rx_dropped, stat.tx_dropped,
> 
>                    stat.rx_errors, stat.tx_errors,
> 
>                    stat.rx_frame_err, stat.rx_over_err,
> 
>                    stat.rx_crc_err, stat.collisions,
> 
>                    stat.duration_sec, stat.duration_nsec))
> 
>  
> 
>         self.logger.debug('PortStats: %s', ports)
> 
>  
> 
> once I sent several messages from the controller:
> 
> *send_port_stats_request(dp1,0)*
> 
> *send_port_stats_request(dp1,1)*
> 
> *send_port_stats_request(dp1,2)*
> 
> *send_port_stats_request(dp1,3)*
> 
> *send_port_stats_request(dp1,4)*
> 
> *send_port_stats_request(dp1,5)*
> 
> *send_port_stats_request(dp1,6)*
> 
> *send_port_stats_request(dp1,7)*
> 
> *send_port_stats_request(dp1,8)*
> 
> *send_port_stats_request(dp1,9)*
> 
> * *
> 
> some of the packets seems to arrive to reply handler and some don’t (I see 
> they are all sent from the switch (using indigo).
> 
> What can be the problem?

First, please confirm that your switch sends the port stats reply messages by 
using wireshark, tcpdump or so.

Or,
How about setting "ofp.OFPP_ANY" as port_num in OFPPortStatsRequest?
It is the default value of OFPPortStatsRequest.


> 
>  
> 
> In addition, I saw get_port_stats at ofctl – but could not understand what is 
> waiters.

ryu.lib.ofctl_v1_* are libraries for ryu.app.ofctl_rest and "waiters" are
a dictionary for observing the OpenFlow event from switches.
  https://github.com/iwaseyusuke/ryu/blob/master/ryu/app/ofctl_rest.py

If you want to use ryu.lib.ofctl_v1_* as the utilities of your apps,
you need to implement event handlers like following.
It may be complicated and not easy to use though.
  https://github.com/iwaseyusuke/ryu/blob/master/ryu/app/ofctl_rest.py#L936


Thanks,
Iwase

> 
>  
> 
> If you don’t know, can you direct me?
> 
>  
> 
> Thanks,
> 
> Zahi
> 
> 
> 
> ------------------------------------------------------------------------------
> 
> 
> 
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
> 

------------------------------------------------------------------------------
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to