You should probably read the "Developing your own Components" section of the 
manual.

Short version:

Download the flow_stats.py example component to your POX's ext/ directory.

Add that component name to your POX commandline:

./pox.py samples.pretty_log forwarding.l2_learning flow_stats

-- Murphy

On Jun 26, 2013, at 3:05 PM, nibble nibble wrote:

> Thanks a lot.
> I have updated the pox, this version. But now I am having a bigger problem. 
> When I start controller(
> ./pox.py samples.pretty_log forwarding.l2_learning ) I cannot run any script, 
> it works and install rules into switches.
> But when I am trying to execute something(import myscript.py) it does not do 
> anything.
> 
> 
> Nibble.
> 
> 
> On Wed, Jun 26, 2013 at 4:55 PM, Peter Peresini <[email protected]> 
> wrote:
> Hi Murphy,
>  over the course of time I see a lot of "using old version/branch of POX" 
> replies. Maybe it could be solved by adding 
> log.warning("Using old git branch, for better support try updating to  xyz") 
> to the pox.core of all old branches. What do you thing?
> 
> 
> On Wed, Jun 26, 2013 at 1:33 PM, Murphy McCauley <[email protected]> 
> wrote:
> You're using a very old version/branch of POX.  See the manual for more info 
> on this.  You should really update to at least the current version of the 
> betta branch.
> 
> Sidenote: it should be a simple modification to remove the dependency on 
> of_json -- it's only used to print the stuff out in JSON instead of its usual 
> (more verbose) string formatting.
> 
> -- Murphy
> 
> On Jun 26, 2013, at 8:23 AM, nibble nibble wrote:
> 
>> Thanks, 
>> 
>> I want to query switches every few seconds. and I found the script to get 
>> the statics from here and because I did not have of_json.py, I got it from 
>> here.  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
>> 
> 
> 
> 

Reply via email to