<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">On Nov 6, 2013, at 9:39 AM, Sulabh Bista <<a href="mailto:sul4bh@gmail.com">sul4bh@gmail.com</a>> wrote:<br><div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">I don't think there are flow and port status events. I guess these are not 'events' at all and you should fetch them when you require them.</div></blockquote><div><br></div><div>There are, in fact (mentioned in the Statistics Events section of the manual). Though you may need to send requests to get them to fire. :)</div><div><br></div><blockquote type="cite"><div class="gmail_extra"><div class="gmail_quote">On Wed, Nov 6, 2013 at 12:30 PM, Sulabh Bista <span dir="ltr"><<a href="mailto:sul4bh@gmail.com" target="_blank">sul4bh@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto;"><div dir="ltr"><div><font face="arial, sans-serif">Use the event name with proper case as:</font></div><span style="font-family:arial,sans-serif;font-size:13px">self.addListenersByname("</span><font face="arial, sans-serif">FlowStatsReceived", self._handle_flowstate_</font><span style="font-family:arial,sans-serif;font-size:13px">received)</span><br></div></blockquote></div></div></blockquote><div><br></div><div>This is good advice. Also use the correct name, as done here (the original had "flow*state*received" which I think would have raised an exception...). Adding by name is sometimes convenient, but it's fairly "unstructured". A safer bet is to actually use the event class itself (addListener(of.FlowStatsReceived, ...)).</div><div><br></div><div>But there's a bigger problem here. Events are raised by specific objects. Does "self" raise the <span style="font-family: arial, sans-serif;">FlowStatsReceived event? Considering it wants to *handle* that event, probably not. (Continued below.)</span></div><br><blockquote type="cite"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto;"><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><div class="gmail_quote">On Wed, Nov 6, 2013 at 9:01 AM, Amer <span dir="ltr"><<a href="mailto:amer7777@hotmail.com" target="_blank">amer7777@hotmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto;">Hello,<br>
<br>
I would like to add listeners to flow and port status in <a href="http://l3.learning.py/" target="_blank">l3.learning.py</a>.<br>
There is a command<br>
Self.listento(core)<br></blockquote></div></div></div></div></blockquote></div></div></blockquote><div><br></div><div>Sidenote: .listenTo() isn't used much anymore (the version of l3_learning in dart doesn't, for example). Use .addListenersByName().</div><div><br></div><blockquote type="cite"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto;"><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto;">
But it is not calling flow or port status function<br></blockquote></div></div></div></div></blockquote></div></div></blockquote><div><br></div><div>It wouldn't. You're telling it to listen to events on the core object. Take a look at the events raised by the core object:</div><div><a href="https://github.com/noxrepo/pox/blob/carp/pox/core.py#L177">https://github.com/noxrepo/pox/blob/carp/pox/core.py#L177</a></div><div><br></div><div>None of them have anything to do with OpenFlow.</div><br><blockquote type="cite"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto;"><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto;">
I tried with self.addListenersByname("flowstatereceived", self._handle_flowstate_received)<br>
and without self<br>
<br>
But it is not work<br></blockquote></div></div></div></div></blockquote></div></div></blockquote><div><br></div></div>Coming back to this, your event source here is "self", but this object probably doesn't raise the flow stats event (neither does the core object as mentioned just above). POX raises OpenFlow events on the OpenFlow nexus (core.openflow) and on individual Connection objects, so you need to listen to those objects. See:<div><a href="https://github.com/noxrepo/pox/blob/carp/pox/openflow/__init__.py#L306">https://github.com/noxrepo/pox/blob/carp/pox/openflow/__init__.py#L306</a></div><div><a href="https://github.com/noxrepo/pox/blob/carp/pox/openflow/of_01.py#L571">https://github.com/noxrepo/pox/blob/carp/pox/openflow/of_01.py#L571</a></div><div><div><br></div><div>You might want to skim through the "The Event System" and "OpenFlow Events" section of the manual.</div></div><div><br></div><div><br></div><div>TLDR:</div><div>Examples...</div><div><br></div><div>If you want to listen to all OpenFlow events, name your methods correctly and then use:</div><div>core.openflow.addListeners(self)</div><div><br></div><div>If you want to listen to a specific event on a specific connection with a specific method, try:</div><div>some_connection.addListenerByName("FlowStatsReceived", self._handle_flowstate_received)<br><br></div><div>Examples in code (there are many, but here are three at random):</div><div><div><a href="https://github.com/noxrepo/pox/blob/carp/pox/forwarding/l2_learning.py#L182">https://github.com/noxrepo/pox/blob/carp/pox/forwarding/l2_learning.py#L182</a></div></div><div><a href="https://github.com/noxrepo/pox/blob/carp/pox/forwarding/l2_learning.py#L86">https://github.com/noxrepo/pox/blob/carp/pox/forwarding/l2_learning.py#L86</a></div><div><a href="https://github.com/noxrepo/pox/blob/carp/pox/forwarding/l2_pairs.py#L85">https://github.com/noxrepo/pox/blob/carp/pox/forwarding/l2_pairs.py#L85</a></div><div><br></div><div><br></div><div>Hope that's helpful.</div><div><br></div><div>-- Murphy</div></body></html>