Object references in sFlow-RT

448 views
Skip to first unread message

Tony Law

unread,
Jan 18, 2015, 10:03:30 PM1/18/15
to sflo...@googlegroups.com
Hi all,
I am a student from Hong Kong doing a project about monitoring network flows in a SDN using mininet.
sFlow-RT gives me a very good platform to visualize flows passed through.

But I have a question about scripting the analyzer. I know the API in javascript from the web portal. But I don't know what is inside the returned object.
For now I am very confused about the object returned and what can I do with the returned object.

If there are any references about the returning object, please let me know or give me guides to retrieve the object references.

Regards,
Tony

Peter Phaal

unread,
Jan 19, 2015, 12:25:42 AM1/19/15
to sflo...@googlegroups.com
The easiest way to see the contents of objects returned in the API is to use logging statements to print them, e.g.

logInfo(JSON.stringify(obj));

If there is a specific function or object you would like to understand, please ask questions on this list.

Tony Law

unread,
Jan 19, 2015, 2:06:39 AM1/19/15
to sflo...@googlegroups.com
Thank you for your replay and I will try this during scripting.

Tony Law

unread,
Jan 19, 2015, 3:46:26 AM1/19/15
to sflo...@googlegroups.com
Now I face another problem. I try to use the Javascript function ofInterfaceToPort() (in the demo on blog.sflow.com). But I could only get "null" value.
Also, when I try to use JSON query about of, it just replies me Page not found.

I use Pox as the controller as I need the ECMP function. (I am writing ECMP function on a RYU controller by now I have no success.)
What should I do in order to let sFlow accesses information about OpenFlow switches?
Using
OpenFlow vSwitch 2.3.0
Mininet 2.1 on Ubuntu 14.04 LTS

Peter Phaal

unread,
Jan 19, 2015, 12:43:27 PM1/19/15
to Tony Law, sflo...@googlegroups.com
The APIs have changed over time. You should check the documentation
supplied with sFlow-RT:

http://localhost:8008/html/api.html
http://localhost:8008/html/script.html

The ofInterfaceToPort function has the following description:

obj = ofInterfaceToPort(agent,ifIndex) Returns OpenFlow datapath
(obj.dpid) and port (obj.port) for an sFlow agent and ifIndex, or null
if not found.

In order to perform this mapping, sFlow-RT needs to know the
relationship between (agent,ifindex) and (dpid,ofport). The OVS trunk
contains implements a new extension that will send the data with the
sFlow feed:

http://blog.sflow.com/2015/01/openflow-integration.html

Alternatively, you can post a topology into sFlow-RT that contains the mapping:

http://blog.sflow.com/2015/01/hybrid-openflow-ecmp-testbed.html

You could modify your Mininet / RYU scripts to export a topology JSON
file for sFlow-RT, similar to the way that the leafandspine.py script
does in the above example.
> --
> You received this message because you are subscribed to the Google Groups
> "sFlow-RT" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sflow-rt+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Tony Law

unread,
Jan 20, 2015, 9:19:43 PM1/20/15
to sflo...@googlegroups.com
Thank you for your information.
So I need to check whether my Open vSwitch support the sflow extension?
Will the choice of controller affect the support of sFlow? (Now I am using Pox which is an old controller.)

Regards,
Tony

Peter Phaal

unread,
Jan 20, 2015, 9:51:11 PM1/20/15
to Tony Law, sflo...@googlegroups.com
sFlow has been a part of Open vSwitch since OVS version 0.99.1 so your
OVS will have sFlow support.

sFlow operates completely independently from OpenFlow, so you should
be able to choose any controller and enable sFlow using the ovs-vsctl
command, e.g.

ovs-vsctl -- --id=@sflow create sflow agent=eth0
target=\"10.0.0.1:6343\" sampling=1000 polling=20 -- -- set bridge br0
sflow=@sflow

Tony Law

unread,
Jan 20, 2015, 10:28:37 PM1/20/15
to sflo...@googlegroups.com, tonyl...@gmail.com
I have prompt this command when I build the topology. But it is strange that it returns me an null object when I trigger ofInterfaceToPort function.
What's wrong with the analyzer?

Peter Phaal

unread,
Jan 20, 2015, 11:37:43 PM1/20/15
to Tony Law, sflo...@googlegroups.com
You need to provide a topology with the information, e.g.

http://blog.sflow.com/2015/01/hybrid-openflow-ecmp-testbed.html

Tony Law

unread,
Jan 21, 2015, 1:44:55 AM1/21/15
to sflo...@googlegroups.com
I have already dump the topology in json from and set by sFlow. I can use topologyInterfaceToLink function.
But I discover that the json file doesn't include links between hosts and edge switches (only switch-to-switch links are recorded).
Will this affect the functionality of sFlow?

Peter Phaal

unread,
Jan 21, 2015, 12:35:05 PM1/21/15
to Tony Law, sflo...@googlegroups.com
In the topology JSON structure, the links: object contains only the
inter-switch connections. However, the nodes: object contains the
information needed to map between sFlow agent,ifindex pairs and
OpenFlow dpid,port pairs. e.g.

"nodes": {
"s3": {
"agent": "10.0.0.30",
"dpid": "0000000000000003",
"ports": {
"s3-eth1": {"ifindex": "219"},
"s3-eth2": {"ifindex": "223"},
"s3-eth3": {"ifindex": "211"},
"s3-eth4": {"ifindex": "213"}
},

See http://blog.sflow.com/2014/04/mininet-integrated-hybrid-openflow.html

This information is sufficient if sFlow-RT is also acting as the
OpenFlow controller since the initial OpenFlow exchange with OVS will
provide the mapping between interface names and OpenFlow port numbers.
If you are using an external OpenFlow controller, then you can pass
the OpenFlow port numbers in the sFlow-RT topology using the ofport
token.

e.g. "s3-eth1": {"ifindex":"219", "ofport":"123"}

If the sFlow agent supports the new OpenFlow extension
(http://sflow.org/sflow_openflow.txt), then you could omit the nodes
object from the topology since the information in the nodes structure
is included in the sFlow feed. An alternative method of populating the
nodes information with OVS is to make a ovs-vsctl query, see
http://blog.sflow.com/2013/08/northbound-apis-for-traffic-engineering.html

Once sFlow-RT is able to map from sFlow to OpenFlow ports, then it can
access RESTful API's in external OpenFlow controllers and push flow
rules, e.g.

Open Daylight:
http://blog.sflow.com/2014/01/opendaylight.html

Floodlight:
http://blog.sflow.com/2013/12/integrated-hybrid-openflow.html

Tony Law

unread,
Jan 21, 2015, 11:06:06 PM1/21/15
to sflo...@googlegroups.com
After modifying the script of dumping topology, the ofInterfaceToLink works like a charm.
But I face another problem. When I use setOfRule, it gives me NullPointerException and the script stops.
I have check the API, setOFRule takes in 3 argurements, dpid, name and rule. I think the problem appears in the second arguement. What is the meaning of name here?

Anyway, thanks for your guidance!

Tony Law

unread,
Jan 21, 2015, 11:35:24 PM1/21/15
to sflo...@googlegroups.com

Or I need to use controller with RESTful API in order to modify flows using the javascript function?

Peter Phaal

unread,
Jan 22, 2015, 1:30:27 AM1/22/15
to Tony Law, sflo...@googlegroups.com
The name is a string identifier used to reference the the rule. The
following article provides an example:

http://blog.sflow.com/2015/01/hybrid-openflow-ecmp-testbed.html

sFlow-RT's built-in OpenFlow controller is designed specifically for
hybrid OpenFlow use cases (i.e. there is a default NORMAL forwarding
action and OpenFlow is only used to override the normal behavior)

http://blog.sflow.com/2014/10/super-normal.html

If you want to use OpenFlow for forwarding then you will need an
external controller. sFlow-RT can access REST APIs (using the http()
function), or call scripts (using the runCmd() function).

The OpenDaylight and Floodlight links I sent provide examples of REST
API calls. The following Frenetic example uses the runCmd() function:

http://blog.sflow.com/2013/10/embedding-sdn-applications.html

Tony Law

unread,
Jan 22, 2015, 3:47:56 AM1/22/15
to sflo...@googlegroups.com
But the problem I face now is should I use another controller such as OpenDayLight or Ryu(I try to write ECMP routing on this) in order to use the RESTful API.
I know POX is a very old and dumb controller, but the ECMP routing is very useful for me.

Peter Phaal

unread,
Jan 22, 2015, 9:51:23 AM1/22/15
to Tony Law, sflo...@googlegroups.com
The leafandspine.py script that comes with sFlow-RT builds leaf and
spine topologies and programs the Mininet Open vSwitch bridges with
ECMP forwarding rules. You can then use sFlow-RT's hybrid OpenFlow
controller to override default forwarding.

http://blog.sflow.com/2015/01/hybrid-openflow-ecmp-testbed.html

Tony Law

unread,
Jan 23, 2015, 4:22:46 AM1/23/15
to sflo...@googlegroups.com
After I play around the leaf-and-spine example, I can trigger FLOW_MOD to the switch. (But some entries cannot be modified by sFlow function and some entries cannot be provisioned by sFlow too.)
I want to ask one more. Do I need to tell sFlow explictly that my controller is an external one? As I know Ryu can do something on sFlow.
If I first set the routing rules for the network, then I start a Ryu controller (which is an empty one)(I don't use the one sFlow provided). Can this make sFlow work?

Peter Phaal

unread,
Jan 23, 2015, 9:43:29 AM1/23/15
to Tony Law, sflo...@googlegroups.com
"some entries cannot be modified by sFlow function and some entries
cannot be provisioned by sFlow too." Can you elaborate? What entries
couldn't you modify or provision? The leafandspine.py script should
have created a leaf and spine fabric with ECMP forwarding rules that
can be overridden using setOfRule(). sFlow should be enabled on every
switch port, and OpenFlow rules can be applied to any switch or port
to override the default behavior.

I am not familiar with Ryu's sFlow support, but you should be able to
run Mininet with any configuration and any controller and still enable
sFlow using ovs-vsctl.

http://openvswitch.org/support/config-cookbooks/sflow/
Reply all
Reply to author
Forward
0 new messages