Thanks,
I want to query switches every few seconds. and I found the script to get
the statics from
here<https://github.com/hip2b2/poxstuff/blob/master/flow_stats.py> and
because I did not have of_json.py, I got it from
here<https://github.com/CPqD/RouteFlow/blob/master/pox/pox/openflow/of_json.py>.
Now I am getting the error:
from pox.openflow.of_json import *
File "/home/mininet/pox/pox/openflow/of_json.py", line 25, in <module>
from pox.lib.util import fields_of,is_scalar
ImportError: cannot import name fields_of
Which I do not have any idea what is wrong with pox?
Thanks,
Nibble
On Tue, Jun 25, 2013 at 6:54 PM, Murphy McCauley
<[email protected]>wrote:
>
> On Jun 25, 2013, at 3:28 PM, nibble nibble wrote:
>
> Hi,
>
> I want to send a message from Pox controller to all the switches and ask
> them to send back their flow table's Statics. I found a script to do it.
>
> from pox.core import core
>>
>> #from pox.lib.util import dpid_to_str
>>
>> log = core.getLogger()
>>
>> class MyComponent (object):
>> def __init__ (self):
>> core.openflow.addListeners(self)
>>
>> def _handle_ConnectionUp (self, event):
>> log.debug("Switch %s has come up.", dpid_to_str(event.dpid))
>>
>> def launch ():
>> core.registerNew(MyComponent)
>> # core.registerNew(openlow_connections)
>>
>
> What's the point of the MyComponent class here? It doesn't do anything
> but print out when switches connect (which the OpenFlow component already
> does).
>
> launch()
>>
>
> You shouldn't call launch() directly. It will be called automatically
> when POX loads the component.
>
> # Listen for flow stats
>> core.openflow.addListenerByName("FlowStatsReceived", handle_flow_stats)
>>
>> # Now actually request flow stats from all switches
>> core.registerNew(core.openflow._connections.values())
>> for con in core.openflow._connections.keys(): # make this
>> _connections.keys() for pre-betta
>> con.send(of.ofp_stats_request(body=of.ofp_flow_stats_request()))
>>
>
> The example you found from the POX manual wiki is for running at the
> interactive prompt (with the "py" component), not for direct inclusion in a
> component. The way you have it here will try to execute it when the module
> is loaded. Even if this worked (which I won't swear to), it would be
> useless because no switches will have connected yet. When do you want to
> query switches? When they connect? Every few seconds? At some other
> time? You need to figure that out and run this code at the correct time
> (e.g., in response to some event).
>
> But I am getting the following error:
>
> core.registerNew(core.openflow._connections.values())
>>
>
> It appears you or someone else added this line to the example code from
> the wiki. It's causing an exception because it doesn't make any sense.
> core.registerNew() creates a new instance of a class and registers it on
> core. core.openflow._connections.values() isn't a class, and you wouldn't
> want to register it on core.
>
>
> Try looking at the "Statistics Collector Example" on the POX wiki in the
> "Third-Party" section. It queries connected switches every few seconds.
>
> -- Murphy
>