Get DPID Ryu controller

Skip to first unread message


May 5, 2021, 10:23:04 AM5/5/21
to sFlow-RT
Hello, I am developing a project using sFlow, Ryu and mininet, to classify traffic and trigger some actions in the controller according to certain parameters.
One of the actions is deleting a flow entry when some information is received via Sflow, the problem I´m facing is that I need the DPID in order to delete the flow. 
I have seen that in the Ryu DDos example the DPID is obtained using: topologyInterfaceToPort(evt.agent,evt.dataSource). Is there any similar function but in python, not js?
The other solution I was thinking is giving each switch Subagent ID the same value as the DPID, but cant find the way of doing so via the ovs-vsclt commands.

thank you in advance

Peter Phaal

May 5, 2021, 3:25:58 PM5/5/21
to sFlow-RT
You can extend the sFlow-RT API with JavaScript, e.g. create a script called api.js in the sflow-rt home directory:

setHttpHandler(function(req) {
  return topologyInterfaceToPort(req.query.agent,req.query.dataSource);

Run sFlow-RT with the script:

./ -Dscript.file=api.js

Now start Mininet:

sudo mn --custom sflow-rt/extras/

You can now query for the DPID using the REST API:

 "node": "s1",
 "ofport": "1",
 "port": "s1-eth1",
 "dpid": "0000000000000001"

This example just contains a single helper function, but you could add additional methods to simplify your Python controller.

See Writing Applications for more information on sFlow-RT's scripting API.
Reply all
Reply to author
0 new messages