<div>Hi, William,</div><div> </div><div>Thanks very much. But I still have some questions about getting statistics.</div><div> </div><div>As mentioned in POX wiki, We can use different statistics event to get different types of statistics. What I want to get from a switch is (1) it's switch ID (DPID) (2) all packet counts on each port </div>
<div> </div><div>If I only use <strong>"core.openflow.addListenerByName("FlowStatsReceived", statsreceived)",</strong> the things I can get is that the total packet counts from all ports, but no DPID or inport number. Thus I guess I may need use </div>
<div><strong>"of.ofp_port_stats_request()" and core.openflow.addListenerByName("PortStatsReceived", stat</strong><strong>sreceived)</strong></div><div>But here I meet with a problem. I tried similar things as <strong>ofp_flow_stats_request()</strong> as follows:</div>
<div> </div><div><strong>def countrequest ():<br> swnum = 0<br> for connection in core.openflow._connections.values():</strong> </div><div> <strong>req1 = of.ofp_port_stats_request()<br> re1 = of.ofp_stats_request(body = req1)</strong></div>
<div><strong> connection.send(re1)</strong></div><div> </div><div>-----------------------------------</div><div>In the launch() function, I do the following:</div><div><strong>Timer(5, countrequest, recurring = True)</strong></div>
<div>It reports an error which will not happend to ofp_flow_stats_request()</div><div><br>Traceback (most recent call last):<br>
File "/home/openflow/pox/pox/lib/recoco/recoco.py", line 276, in cycle<br> rv = t.execute()<br> File "/home/openflow/pox/pox/lib/recoco/recoco.py", line 94, in execute<br> return self.gen.send(v)<br>
File "/home/openflow/pox/pox/lib/recoco/recoco.py", line 751, in run<br> rv = self._callback(*self._args,**self._kw)<br> File "/home/openflow/pox/ext/test1stat.py", line 270, in countrequest<br>
connection.send(re1)<br>
File "/home/openflow/pox/pox/openflow/of_01.py", line 573, in send<br> data = data.pack()<br> File "/home/openflow/pox/pox/openflow/libopenflow_01.py", line 2136, in pack<br> packed += struct.pack("!HH", self.type, self.flags)<br>
error: cannot convert argument to integer<br></div><div> </div><div>Is there anything that I don't do correctly?</div><div> </div><div>And my another question is that even assuming I can add portstatlistener and flowstatlistener as :</div>
<div> </div><div> core.openflow.addListenerByName("PortStatsReceived", statsreceived)<br> core.openflow.addListenerByName("FlowStatsReceived", statsreceived)</div><div> </div><div>Can I distinguish through statsreceived which event is which? Or can I combine these two listeners together?<br>
</div><div>Thanks very much.</div><div> </div><div>Weiyang<br><br><br><br></div><div><br> </div><div><code></code> </div><div><code></code> </div>
<div><code></code> </div><div><code></code> </div><code></code><div><code></code><div>
</div><div> </div></div><div class="gmail_quote">2012/9/19 William Emmanuel Yu <span dir="ltr"><<a href="mailto:wyu@ateneo.edu" target="_blank">wyu@ateneo.edu</a>></span><br><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">
Hi,<br>
<br>
Attached is a flow_stats.py file that contains a sample for getting<br>
stats from all switches connected to the controller (flow_stats.py).<br>
Attached is also a file of_json.py (from Murphy) which is a helper<br>
library to convert the output into JSON format (which is much more<br>
readable than the current classes).<br>
<br>
Good luck!<br>
<div><div><br>
On Wed, 2012-09-19 at 10:41 -0700, Weiyang Mo wrote:<br>
> Hi, Seungwon,<br>
><br>
> Thanks very much.<br>
><br>
> Now it works and I can make some logical programming to do my routing<br>
> algorithm.<br>
><br>
> Best<br>
><br>
> Weiyang<br>
><br>
><br>
> 2012/9/19 Seungwon Shin <<a href="mailto:seungwon.shin@gmail.com" target="_blank">seungwon.shin@gmail.com</a>><br>
> Hi, Weiyang<br>
><br>
><br>
> In the case of collecting the statistical information for a<br>
> flow table<br>
> You can register your listener like<br>
> --> core.openflow.addListenerByName("TableStatsReceived",<br>
> <your handler>)<br>
><br>
><br>
> and your handler can parse..<br>
><br>
><br>
> def <your handler>(event):<br>
> for item in event.stats<br>
> print item.wildcards<br>
><br>
><br>
><br>
><br>
> You can find more information by looking at the following<br>
> classes in POX source code (libopenflow_01.py)<br>
><br>
><br>
> class ofp_flow_stats<br>
><br>
><br>
> class ofp_table_stats<br>
><br>
><br>
> ….<br>
><br>
><br>
> Each class has its __init__ function, and you will find all<br>
> variables for stats in the function.<br>
> The variables that you are looking for should be one of them.<br>
> (E.g., wildcards is an initial variable of ofp_table_stats<br>
> class).<br>
><br>
><br>
> Best,<br>
> Seungwon<br>
><br>
><br>
><br>
> On Sep 19, 2012, at 11:49 AM, Weiyang Mo<br>
> <<a href="mailto:moweiyang1988@gmail.com" target="_blank">moweiyang1988@gmail.com</a>> wrote:<br>
><br>
> > Hi,William,<br>
> ><br>
> > Thanks for your advice and that's what I already did. What I<br>
> > meant is that although I sent such request, I don't have<br>
> > ideas how to get the reply back. I do modifications as<br>
> > follows in forwarding.l2_learning, which sends request right<br>
> > after sending flow entry request.<br>
> ><br>
> > msg = of.ofp_flow_mod()<br>
> > msg.match = of.ofp_match.from_packet(packet)<br>
> > msg.match.in_port = packet_in.in_port<br>
> > msg.idle_timeout = 30<br>
> > msg.hard_timeout = 30<br>
> > msg.actions.append(of.ofp_action_output(port =<br>
> > out_port))<br>
> > self.connection.send(msg)<br>
> ><br>
> > "-----------------------------------------------------"<br>
> > req = of.ofp_flow_stats_request()<br>
> > re = of.ofp_stats_request(body = req)<br>
> > self.connection.send(re)<br>
> ><br>
> > When I try pinging between hosts, it works correctly and the<br>
> > statistics request has been sent. The question is that the<br>
> > switches sent "stats reply back" to controller ( I detect<br>
> > them through wireshark) however from controller side, I<br>
> > don't now how to catch the reply packet and parse it as I<br>
> > want.<br>
> ><br>
> > Any advice?<br>
> ><br>
> > Thanks very much.<br>
> ><br>
> > Weiyang<br>
> ><br>
> ><br>
> > 2012/9/19 William Emmanuel Yu <<a href="mailto:wyu@ateneo.edu" target="_blank">wyu@ateneo.edu</a>><br>
> > Hi Weiyang,<br>
> ><br>
> > Did you check out ofp_flow_stats_request()?<br>
> ><br>
> > import pox.openflow.libopenflow_01 as of<br>
> > fsr = of.ofp_flow_stats_request()<br>
> > sr = of.ofp_stats_request(body = fsr)<br>
> > switch.send(sr)<br>
> ><br>
> > Check out:<br>
> > <a href="https://groups.google.com/forum/?fromgroups=#" target="_blank">https://groups.google.com/forum/?fromgroups=#</a>!<br>
> > topic/pox_dev/sSlfqm5Okls<br>
> ><br>
> > Good luck!<br>
> ><br>
> > On Tue, 2012-09-18 at 08:21 -0700, Weiyang Mo wrote:<br>
> > > Hi,All,<br>
> > ><br>
> > > I try to use packet counts from switches within a<br>
> > time period (e.g<br>
> > > 10secs) to do some routing. In the documentation<br>
> > > <a href="https://openflow.stanford.edu/display/ONL/POX" target="_blank">https://openflow.stanford.edu/display/ONL/POX</a><br>
> ><br>
> > > +Wiki#POXWiki-StatisticEvent it mentions that it's<br>
> > possible to do this<br>
> > > using a timer. I guess using 'time to wake' to<br>
> > call a counting<br>
> > > function may help.<br>
> > ><br>
> > > However I'm not famiiar with getting statistics<br>
> > from a switch. More<br>
> > > than one flow, I want to get total packet counts<br>
> > within 10 seconds<br>
> > > from all flow entries. Could you please help to<br>
> > give me a simple<br>
> > > examples about this?<br>
> > ><br>
> > > Thanks very much.<br>
> > ><br>
> > > Best<br>
> > ><br>
> > > Weiyang<br>
> > ><br>
> > ><br>
> ><br>
> ><br>
> > --<br>
> > -------------------------------------------------------<br>
> > William Emmanuel S. Yu, Ph.D. (ÑÒå)<br>
> > Department of Information Systems and Computer<br>
> > Science<br>
> > Ateneo de Manila University<br>
> > email : wyu at ateneo dot edu<br>
> > blog : <a href="http://hip2b2.yutivo.org/" target="_blank">http://hip2b2.yutivo.org/</a><br>
> > web : <a href="http://CNG.ateneo.edu/cng/wyu/" target="_blank">http://CNG.ateneo.edu/cng/wyu/</a><br>
> > phone : <a href="tel:%2B63%282%294266001" target="_blank" value="+6324266001">+63(2)4266001</a> loc. 4186<br>
> > GPG : <a href="http://CNG.ateneo.net/cng/wyu/wyy.pgp" target="_blank">http://CNG.ateneo.net/cng/wyu/wyy.pgp</a><br>
> ><br>
> > Confidentiality Issue: This message is intended<br>
> > only for the use of the<br>
> > addressee and may contain information that is<br>
> > privileged and<br>
> > confidential. If you are not the intended recipient,<br>
> > you are hereby<br>
> > notified that any use or dissemination of this<br>
> > communication is strictly<br>
> > prohibited. If you have received this communication<br>
> > in error, please<br>
> > notify us immediately by reply and delete this<br>
> > message from your system.<br>
> ><br>
> ><br>
><br>
><br>
><br>
<br>
--<br>
-------------------------------------------------------<br>
William Emmanuel S. Yu, Ph.D. (ÑÒå)<br>
Department of Information Systems and Computer Science<br>
Ateneo de Manila University<br>
email : wyu at ateneo dot edu<br>
blog : <a href="http://hip2b2.yutivo.org/" target="_blank">http://hip2b2.yutivo.org/</a><br>
web : <a href="http://CNG.ateneo.edu/cng/wyu/" target="_blank">http://CNG.ateneo.edu/cng/wyu/</a><br>
phone : <a href="tel:%2B63%282%294266001" target="_blank" value="+6324266001">+63(2)4266001</a> loc. 4186<br>
GPG : <a href="http://CNG.ateneo.net/cng/wyu/wyy.pgp" target="_blank">http://CNG.ateneo.net/cng/wyu/wyy.pgp</a><br>
<br>
Confidentiality Issue: This message is intended only for the use of the<br>
addressee and may contain information that is privileged and<br>
confidential. If you are not the intended recipient, you are hereby<br>
notified that any use or dissemination of this communication is strictly<br>
prohibited. If you have received this communication in error, please<br>
notify us immediately by reply and delete this message from your system.<br>
</div></div></blockquote></div><br>