[pox-dev] How can POX get packet counts (or beta transferred) from a switch within a timeline.

Murphy McCauley murphy.mccauley at gmail.com
Thu Sep 20 20:46:32 PDT 2012


Glad you got it working.  Can you submit your patch as a pull request against betta on github? (I want to at least make a comment on it)

-- Murphy

On Sep 20, 2012, at 8:38 PM, William Emmanuel Yu wrote:

> Hi Murphy,
> 
> Yes. Flows show up fine. However, no port statistics are visible. I also
> did a Wireshark as suggested. After installing flows and successfully
> seeing them flow statistics, I requested for port statistics (OF Type 16
> Stats Type 4 - PORT Port #0). I get a proper reply (OF Type 17 Stats
> Type 4 - PORT) but it has no payload.
> 
> I looked at the class ofp_port_stats_request (object) in
> libopenflow_01.py and found out port_no is set to 0 by default. In the
> openflow 1.0 specification, this should be set to OFPP_NONE to return
> all port statistics. 
> 
> https://github.com/hip2b2/poxstuff/blob/master/libopenflow_01.py.ANY_PORT.patch
> 
> After this, it now works!
> 
> On Thu, 2012-09-20 at 18:57 -0700, Murphy McCauley wrote:
>> Are you sure there's anything wrong here?  Are you actually installing flows?
>> 
>> Port 65534 is OFPP_LOCAL; this flow is apparently permanently installed.  I don't offhand know exactly why, but it's probably to enable communication with the controller or something.
>> 
>> If I actually install flows, they show up just fine for me.  Run flow_stats and forwarding.l2_learning at the same time, and then do a ping between hosts on your switches.  No problem here -- flows show up just fine.
>> 
>> -- Murphy
>> 
>> On Sep 20, 2012, at 5:43 PM, William Emmanuel Yu wrote:
>> 
>>> Here is the code I used to test:
>>> https://github.com/hip2b2/poxstuff/blob/master/flow_stats.py
>>> 
>>> I still don't know how to attach debugging into Pox to dig deeper. Is
>>> there documentation on how to do that? Worst case, I will just have to
>>> put debugging stuff in the pox code itself. 
>>> 
>>> Thanks.
>>> 
>>> On Thu, 2012-09-20 at 17:02 -0700, Murphy McCauley wrote:
>>>> can one or both of you post code to test?
>>>> 
>>>> On Sep 20, 2012 3:00 PM, "William Emmanuel S. Yu" <wyu at ateneo.edu>
>>>> wrote:
>>>>       Same here. Still trying to find out what is wrong. 
>>>>       "Sent on the move."
>>>> 
>>>>       ______________________________________________________________
>>>>       From: Weiyang Mo <moweiyang1988 at gmail.com>
>>>>       Date: Thu, 20 Sep 2012 14:53:44 -0700
>>>>       To: William Emmanuel Yu<wyu at ateneo.edu>; Murphy
>>>>       McCauley<murphy.mccauley at gmail.com>
>>>>       Cc: <pox-dev at lists.noxrepo.org>
>>>>       Subject: Re: [pox-dev] How can POX get packet counts (or beta
>>>>       transferred) from a switch within a timeline.
>>>> 
>>>> 
>>>>       Hi,William
>>>> 
>>>>       I got the same problems on my side.  I already tried both on
>>>>       "betta" and Murphy fork.
>>>> 
>>>>       It seems that whatever the traffic goes through switches, the
>>>>       returned switch port number is always "65534" and bytes_rx
>>>>       always 0 thus I cannot get packet counts from a specific port
>>>>       correctly.
>>>> 
>>>>       Any advice?
>>>> 
>>>>       Thanks very much.
>>>> 
>>>>       Weiyang
>>>> 
>>>> 
>>>>       2012/9/19 William Emmanuel Yu <wyu at ateneo.edu>
>>>>               Hi Weiyang,
>>>> 
>>>>               Yes. You should be using port stats for that. So I
>>>>               tried it myself but
>>>>               now I do not get any port stats data. Here is my code.
>>>>               It's empty. I am
>>>>               using the Murphy fork.
>>>> 
>>>>               On the multiple listeners, yes you can specify various
>>>>               actions within
>>>>               the callback function. In my emailed sample, I just
>>>>               log.debug() the
>>>>               output but you can do anything you like such as write
>>>>               to a database and
>>>>               the like.
>>>> 
>>>>               Good luck!
>>>> 
>>>>               On Thu, 2012-09-20 at 15:10 +1200, Sam Russell wrote:
>>>>> What would it take to get your mods back into
>>>>               mainstream? Is there any
>>>>> tidying or the like that we can help with?
>>>>> 
>>>>> Sent from my iPhone
>>>>> 
>>>>> On Sep 20, 2012, at 3:07 PM, Murphy McCauley
>>>>> <murphy.mccauley at gmail.com> wrote:
>>>>> 
>>>>> 
>>>>> 
>>>>>> I think that's a known problem.
>>>>>> 
>>>>>> 
>>>>>> The official noxrepo fork currently has a number
>>>>               of known bugs which
>>>>>> are addressed in my fork (MurphyMc/pox), and my
>>>>               fork has a number of
>>>>>> other improvements.  One of these days, the
>>>>               changes in my fork will
>>>>>> be upstreamed, but for the moment, you should
>>>>               really just pull POX
>>>>>> from me instead of noxrepo.
>>>>>> 
>>>>>> 
>>>>>> -- Murphy
>>>>>> 
>>>>>> 
>>>>>> On Sep 19, 2012, at 7:33 PM, Weiyang Mo wrote:
>>>>>> 
>>>>>>> Hi, William,
>>>>>>> 
>>>>>>> Thanks very much. But I still have some
>>>>               questions about getting
>>>>>>> statistics.
>>>>>>> 
>>>>>>> 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
>>>>>>> 
>>>>>>> If I only use
>>>>>>> 
>>>>               "core.openflow.addListenerByName("FlowStatsReceived",
>>>>>>> statsreceived)", 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
>>>>>>> "of.ofp_port_stats_request()" and
>>>>>>> 
>>>>               core.openflow.addListenerByName("PortStatsReceived",
>>>>>>> statsreceived)
>>>>>>> But here I meet with a problem. I tried similar
>>>>               things as
>>>>>>> ofp_flow_stats_request() as follows:
>>>>>>> 
>>>>>>> def countrequest ():
>>>>>>> swnum = 0
>>>>>>> for connection in
>>>>               core.openflow._connections.values():
>>>>>>>   req1 = of.ofp_port_stats_request()
>>>>>>>   re1 = of.ofp_stats_request(body = req1)
>>>>>>>   connection.send(re1)
>>>>>>> 
>>>>>>> -----------------------------------
>>>>>>> In the launch() function, I do the following:
>>>>>>> Timer(5, countrequest, recurring = True)
>>>>>>> It reports an error which will not happend to
>>>>>>> ofp_flow_stats_request()
>>>>>>> 
>>>>>>> Traceback (most recent call last):
>>>>>>> File
>>>>               "/home/openflow/pox/pox/lib/recoco/recoco.py", line
>>>>               276, in
>>>>>>> cycle
>>>>>>>   rv = t.execute()
>>>>>>> File
>>>>               "/home/openflow/pox/pox/lib/recoco/recoco.py", line
>>>>               94, in
>>>>>>> execute
>>>>>>>   return self.gen.send(v)
>>>>>>> File
>>>>               "/home/openflow/pox/pox/lib/recoco/recoco.py", line
>>>>               751, in
>>>>>>> run
>>>>>>>   rv = self._callback(*self._args,**self._kw)
>>>>>>> File "/home/openflow/pox/ext/test1stat.py",
>>>>               line 270, in
>>>>>>> countrequest
>>>>>>>   connection.send(re1)
>>>>>>> File
>>>>               "/home/openflow/pox/pox/openflow/of_01.py", line 573,
>>>>               in
>>>>>>> send
>>>>>>>   data = data.pack()
>>>>>>> File
>>>>               "/home/openflow/pox/pox/openflow/libopenflow_01.py",
>>>>               line
>>>>>>> 2136, in pack
>>>>>>>   packed += struct.pack("!HH", self.type,
>>>>               self.flags)
>>>>>>> error: cannot convert argument to integer
>>>>>>> 
>>>>>>> 
>>>>>>> Is there anything that I don't do correctly?
>>>>>>> 
>>>>>>> And my another question is that even assuming I
>>>>               can add
>>>>>>> portstatlistener and flowstatlistener as :
>>>>>>> 
>>>>>>> 
>>>>                core.openflow.addListenerByName("PortStatsReceived",
>>>>>>> statsreceived)
>>>>>>> 
>>>>                core.openflow.addListenerByName("FlowStatsReceived",
>>>>>>> statsreceived)
>>>>>>> 
>>>>>>> Can I distinguish through statsreceived which
>>>>               event is which? Or
>>>>>>> can I combine these two listeners together?
>>>>>>> 
>>>>>>> Thanks very much.
>>>>>>> 
>>>>>>> Weiyang
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 2012/9/19 William Emmanuel Yu <wyu at ateneo.edu>
>>>>>>>       Hi,
>>>>>>> 
>>>>>>>       Attached is a flow_stats.py file that
>>>>               contains a sample
>>>>>>>       for getting
>>>>>>>       stats from all switches connected to the
>>>>               controller
>>>>>>>       (flow_stats.py).
>>>>>>>       Attached is also a file of_json.py (from
>>>>               Murphy) which is
>>>>>>>       a helper
>>>>>>>       library to convert the output into JSON
>>>>               format (which is
>>>>>>>       much more
>>>>>>>       readable than the current classes).
>>>>>>> 
>>>>>>>       Good luck!
>>>>>>> 
>>>>>>>       On Wed, 2012-09-19 at 10:41 -0700,
>>>>               Weiyang Mo wrote:
>>>>>>>> Hi, Seungwon,
>>>>>>>> 
>>>>>>>> Thanks very much.
>>>>>>>> 
>>>>>>>> Now it works and I can make some
>>>>               logical programming to
>>>>>>>       do my routing
>>>>>>>> algorithm.
>>>>>>>> 
>>>>>>>> Best
>>>>>>>> 
>>>>>>>> Weiyang
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 2012/9/19 Seungwon Shin
>>>>               <seungwon.shin at gmail.com>
>>>>>>>>       Hi, Weiyang
>>>>>>>> 
>>>>>>>> 
>>>>>>>>       In the case of collecting the
>>>>               statistical
>>>>>>>       information for a
>>>>>>>>       flow table
>>>>>>>>       You can register your listener
>>>>               like
>>>>>>>>       -->
>>>>>>> 
>>>>               core.openflow.addListenerByName("TableStatsReceived",
>>>>>>>>       <your handler>)
>>>>>>>> 
>>>>>>>> 
>>>>>>>>       and your handler can parse..
>>>>>>>> 
>>>>>>>> 
>>>>>>>>       def <your handler>(event):
>>>>>>>>          for item in event.stats
>>>>>>>>              print item.wildcards
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>>       You can find more information
>>>>               by looking at the
>>>>>>>       following
>>>>>>>>       classes in POX source code
>>>>               (libopenflow_01.py)
>>>>>>>> 
>>>>>>>> 
>>>>>>>>       class ofp_flow_stats
>>>>>>>> 
>>>>>>>> 
>>>>>>>>       class ofp_table_stats
>>>>>>>> 
>>>>>>>> 
>>>>>>>>       ….
>>>>>>>> 
>>>>>>>> 
>>>>>>>>       Each class has its __init__
>>>>               function, and you
>>>>>>>       will find all
>>>>>>>>       variables for stats in the
>>>>               function.
>>>>>>>>       The variables that you are
>>>>               looking for should be
>>>>>>>       one of them.
>>>>>>>>       (E.g., wildcards is an initial
>>>>               variable of
>>>>>>>       ofp_table_stats
>>>>>>>>       class).
>>>>>>>> 
>>>>>>>> 
>>>>>>>>       Best,
>>>>>>>>       Seungwon
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>>       On Sep 19, 2012, at 11:49 AM,
>>>>               Weiyang Mo
>>>>>>>>       <moweiyang1988 at gmail.com>
>>>>               wrote:
>>>>>>>> 
>>>>>>>>> Hi,William,
>>>>>>>>> 
>>>>>>>>> Thanks for your advice and
>>>>               that's what I
>>>>>>>       already did. What I
>>>>>>>>> meant is that although I
>>>>               sent such request, I
>>>>>>>       don't have
>>>>>>>>> ideas how to get the reply
>>>>               back. I do
>>>>>>>       modifications as
>>>>>>>>> follows in
>>>>               forwarding.l2_learning, which sends
>>>>>>>       request right
>>>>>>>>> after sending flow entry
>>>>               request.
>>>>>>>>> 
>>>>>>>>>          msg =
>>>>               of.ofp_flow_mod()
>>>>>>>>>           msg.match =
>>>>>>>       of.ofp_match.from_packet(packet)
>>>>>>>>> 
>>>>               msg.match.in_port =
>>>>>>>       packet_in.in_port
>>>>>>>>>           msg.idle_timeout
>>>>               = 30
>>>>>>>>>           msg.hard_timeout
>>>>               = 30
>>>>>>>>> 
>>>>>>> 
>>>>               msg.actions.append(of.ofp_action_output(port =
>>>>>>>>> out_port))
>>>>>>>>> 
>>>>               self.connection.send(msg)
>>>>>>>>> 
>>>>>>>>> 
>>>>>>> 
>>>>               "-----------------------------------------------------"
>>>>>>>>>          req =
>>>>               of.ofp_flow_stats_request()
>>>>>>>>>          re =
>>>>               of.ofp_stats_request(body =
>>>>>>>       req)
>>>>>>>>> 
>>>>                self.connection.send(re)
>>>>>>>>> 
>>>>>>>>> When I try pinging between
>>>>               hosts, it works
>>>>>>>       correctly and the
>>>>>>>>> statistics request has been
>>>>               sent. The question
>>>>>>>       is  that the
>>>>>>>>> switches sent "stats  reply
>>>>               back" to
>>>>>>>       controller ( I detect
>>>>>>>>> them through wireshark)
>>>>               however from
>>>>>>>       controller side, I
>>>>>>>>> don't now how to catch the
>>>>               reply packet and
>>>>>>>       parse it as I
>>>>>>>>> want.
>>>>>>>>> 
>>>>>>>>> Any advice?
>>>>>>>>> 
>>>>>>>>> Thanks very much.
>>>>>>>>> 
>>>>>>>>> Weiyang
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 2012/9/19 William Emmanuel
>>>>               Yu <wyu at ateneo.edu>
>>>>>>>>>       Hi Weiyang,
>>>>>>>>> 
>>>>>>>>>       Did you check out
>>>>>>>       ofp_flow_stats_request()?
>>>>>>>>> 
>>>>>>>>>       import
>>>>               pox.openflow.libopenflow_01 as
>>>>>>>       of
>>>>>>>>>       fsr =
>>>>               of.ofp_flow_stats_request()
>>>>>>>>>       sr =
>>>>               of.ofp_stats_request(body = fsr)
>>>>>>>>>       switch.send(sr)
>>>>>>>>> 
>>>>>>>>>       Check out:
>>>>>>>>> 
>>>>>>> 
>>>>               https://groups.google.com/forum/?fromgroups=#!
>>>>>>>>> 
>>>>               topic/pox_dev/sSlfqm5Okls
>>>>>>>>> 
>>>>>>>>>       Good luck!
>>>>>>>>> 
>>>>>>>>>       On Tue, 2012-09-18
>>>>               at 08:21 -0700,
>>>>>>>       Weiyang Mo wrote:
>>>>>>>>>> Hi,All,
>>>>>>>>>> 
>>>>>>>>>> I try to use
>>>>               packet counts from
>>>>>>>       switches within a
>>>>>>>>>       time period (e.g
>>>>>>>>>> 10secs) to do some
>>>>               routing.  In the
>>>>>>>       documentation
>>>>>>>>>> 
>>>>>>> 
>>>>               https://openflow.stanford.edu/display/ONL/POX
>>>>>>>>> 
>>>>>>>>>> 
>>>>               +Wiki#POXWiki-StatisticEvent it
>>>>>>>       mentions that it's
>>>>>>>>>       possible to do this
>>>>>>>>>> using a timer. I
>>>>               guess using 'time
>>>>>>>       to wake' to
>>>>>>>>>       call a counting
>>>>>>>>>> function may help.
>>>>>>>>>> 
>>>>>>>>>> However I'm not
>>>>               famiiar with getting
>>>>>>>       statistics
>>>>>>>>>       from a switch. More
>>>>>>>>>> than one flow, I
>>>>               want to get total
>>>>>>>       packet counts
>>>>>>>>>       within 10 seconds
>>>>>>>>>> from all flow
>>>>               entries. Could you
>>>>>>>       please help to
>>>>>>>>>       give me a simple
>>>>>>>>>> examples about
>>>>               this?
>>>>>>>>>> 
>>>>>>>>>> Thanks very much.
>>>>>>>>>> 
>>>>>>>>>> Best
>>>>>>>>>> 
>>>>>>>>>> Weiyang
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>>       --
>>>>>>>>> 
>>>>>>> 
>>>>               -------------------------------------------------------
>>>>>>>>>       William Emmanuel S.
>>>>               Yu, Ph.D. (杨怀义)
>>>>>>>>>       Department of
>>>>               Information Systems and
>>>>>>>       Computer
>>>>>>>>>       Science
>>>>>>>>>       Ateneo de Manila
>>>>               University
>>>>>>>>>       email  :  wyu at
>>>>               ateneo dot edu
>>>>>>>>>       blog   :
>>>>                http://hip2b2.yutivo.org/
>>>>>>>>>       web    :
>>>>>>>        http://CNG.ateneo.edu/cng/wyu/
>>>>>>>>>       phone  :
>>>>                +63(2)4266001 loc. 4186
>>>>>>>>>       GPG    :
>>>>>>>        http://CNG.ateneo.net/cng/wyu/wyy.pgp
>>>>>>>>> 
>>>>>>>>>       Confidentiality
>>>>               Issue:  This message
>>>>>>>       is intended
>>>>>>>>>       only for the use of
>>>>               the
>>>>>>>>>       addressee and may
>>>>               contain information
>>>>>>>       that is
>>>>>>>>>       privileged and
>>>>>>>>>       confidential. If you
>>>>               are not the
>>>>>>>       intended recipient,
>>>>>>>>>       you are hereby
>>>>>>>>>       notified that any
>>>>               use or dissemination
>>>>>>>       of this
>>>>>>>>>       communication is
>>>>               strictly
>>>>>>>>>       prohibited.  If you
>>>>               have received this
>>>>>>>       communication
>>>>>>>>>       in error, please
>>>>>>>>>       notify us
>>>>               immediately by reply and
>>>>>>>       delete this
>>>>>>>>>       message from your
>>>>               system.
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>>>>>       --
>>>>>>> 
>>>>               -------------------------------------------------------
>>>>>>>       William Emmanuel S. Yu, Ph.D. (杨怀义)
>>>>>>>       Department of Information Systems and
>>>>               Computer Science
>>>>>>>       Ateneo de Manila University
>>>>>>>       email  :  wyu at ateneo dot edu
>>>>>>>       blog   :  http://hip2b2.yutivo.org/
>>>>>>>       web    :  http://CNG.ateneo.edu/cng/wyu/
>>>>>>>       phone  :  +63(2)4266001 loc. 4186
>>>>>>>       GPG    :
>>>>                http://CNG.ateneo.net/cng/wyu/wyy.pgp
>>>>>>> 
>>>>>>>       Confidentiality Issue:  This message is
>>>>               intended only for
>>>>>>>       the use of the
>>>>>>>       addressee and may contain information
>>>>               that is privileged
>>>>>>>       and
>>>>>>>       confidential. If you are not the
>>>>               intended recipient, you
>>>>>>>       are hereby
>>>>>>>       notified that any use or dissemination
>>>>               of this
>>>>>>>       communication is strictly
>>>>>>>       prohibited.  If you have received this
>>>>               communication in
>>>>>>>       error, please
>>>>>>>       notify us immediately by reply and
>>>>               delete this message
>>>>>>>       from your system.
>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>>> 
>>>> 
>>>>               --
>>>>               -------------------------------------------------------
>>>>               William Emmanuel S. Yu, Ph.D. (杨怀义)
>>>>               Department of Information Systems and Computer Science
>>>>               Ateneo de Manila University
>>>>               email  :  wyu at ateneo dot edu
>>>>               blog   :  http://hip2b2.yutivo.org/
>>>>               web    :  http://CNG.ateneo.edu/cng/wyu/
>>>>               phone  :  +63(2)4266001 loc. 4186
>>>>               GPG    :  http://CNG.ateneo.net/cng/wyu/wyy.pgp
>>>> 
>>>>               Confidentiality Issue:  This message is intended only
>>>>               for the use of the
>>>>               addressee and may contain information that is
>>>>               privileged and
>>>>               confidential. If you are not the intended recipient,
>>>>               you are hereby
>>>>               notified that any use or dissemination of this
>>>>               communication is strictly
>>>>               prohibited.  If you have received this communication
>>>>               in error, please
>>>>               notify us immediately by reply and delete this message
>>>>               from your system.
>>>> 
>>>> 
>>>> 
>>> 
>>> -- 
>>> -------------------------------------------------------
>>> William Emmanuel S. Yu, Ph.D. (杨怀义)
>>> Department of Information Systems and Computer Science
>>> Ateneo de Manila University
>>> email  :  wyu at ateneo dot edu
>>> blog   :  http://hip2b2.yutivo.org/
>>> web    :  http://CNG.ateneo.edu/cng/wyu/
>>> phone  :  +63(2)4266001 loc. 4186
>>> GPG    :  http://CNG.ateneo.net/cng/wyu/wyy.pgp
>>> 
>>> Confidentiality Issue:  This message is intended only for the use of the
>>> addressee and may contain information that is privileged and
>>> confidential. If you are not the intended recipient, you are hereby
>>> notified that any use or dissemination of this communication is strictly
>>> prohibited.  If you have received this communication in error, please
>>> notify us immediately by reply and delete this message from your system.
>>> 
>> 
> 
> -- 
> -------------------------------------------------------
> William Emmanuel S. Yu, Ph.D. (杨怀义)
> Department of Information Systems and Computer Science
> Ateneo de Manila University
> email  :  wyu at ateneo dot edu
> blog   :  http://hip2b2.yutivo.org/
> web    :  http://CNG.ateneo.edu/cng/wyu/
> phone  :  +63(2)4266001 loc. 4186
> GPG    :  http://CNG.ateneo.net/cng/wyu/wyy.pgp
> 
> Confidentiality Issue:  This message is intended only for the use of the
> addressee and may contain information that is privileged and
> confidential. If you are not the intended recipient, you are hereby
> notified that any use or dissemination of this communication is strictly
> prohibited.  If you have received this communication in error, please
> notify us immediately by reply and delete this message from your system.
> 




More information about the pox-dev mailing list