Hi,
Excuse me for jumping in.
How about sending OFPAggregateStatsRequest in synchronous way?
You can use "ryu.app.ofctl.api" to send an OpenFlow message synchronously.
http://ryu.readthedocs.io/en/latest/app/ofctl.html
$ git diff
diff --git a/ryu/app/simple_switch_13.py b/ryu/app/simple_switch_13.py
index 06a5d0e..04c0463 100644
--- a/ryu/app/simple_switch_13.py
+++ b/ryu/app/simple_switch_13.py
@@ -21,6 +21,7 @@ from ryu.ofproto import ofproto_v1_3
from ryu.lib.packet import packet
from ryu.lib.packet import ethernet
from ryu.lib.packet import ether_types
+from ryu.app.ofctl import api as ofctl_api
class SimpleSwitch13(app_manager.RyuApp):
@@ -74,6 +75,28 @@ class SimpleSwitch13(app_manager.RyuApp):
datapath = msg.datapath
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
+
+ flags = 0
+ cookie = 0
+ cookie_mask = 0
+ match = parser.OFPMatch()
+ req = parser.OFPAggregateStatsRequest(
+ datapath=datapath,
+ flags=flags,
+ table_id=ofproto.OFPTT_ALL,
+ out_port=ofproto.OFPP_ANY,
+ out_group=ofproto.OFPG_ANY,
+ cookie=cookie,
+ cookie_mask=cookie_mask,
+ match=match)
+ rep = ofctl_api.send_msg(
+ app=self,
+ msg=req,
+ reply_cls=parser.OFPAggregateStatsReply,
+ reply_multi=True)
+ if rep:
+ self.logger.info("*** flow_count=%d", rep[0].body.flow_count)
+
in_port = msg.match['in_port']
pkt = packet.Packet(msg.data)
$ ryu-manager ryu/app/simple_switch_13.py
loading app ryu/app/simple_switch_13.py
loading app ryu.controller.ofp_handler
loading app ryu.app.ofctl.service
loading app ryu.controller.ofp_handler
instantiating app ryu/app/simple_switch_13.py of SimpleSwitch13
instantiating app ryu.controller.ofp_handler of OFPHandler
instantiating app ryu.app.ofctl.service of OfctlService
*** flow_count=1
packet in 1 2e:89:11:b9:d8:15 ff:ff:ff:ff:ff:ff 1
*** flow_count=1
packet in 1 4e:4b:8e:90:6a:f8 2e:89:11:b9:d8:15 2
*** flow_count=2
packet in 1 2e:89:11:b9:d8:15 4e:4b:8e:90:6a:f8 1
Thanks,
Iwase
On 2018年03月01日 13:07, knet solutions wrote:
The counter has to be incremented when you add the flows add_flows(not
packet-in) and to be decremented flow-removed event message.
On Wed, Feb 28, 2018 at 7:39 PM, Eman Bany salameh <banysalam...@yahoo.com
<mailto:banysalam...@yahoo.com>> wrote:
Hi all,
Thanks for your replays.
Yes, I decrement the counter when the flow removed by idle_timeout and used
flow-removed_handler to know this. But the problem in this case is the
packet-in generated more than once for the same packet but the flow is added
once and this increments the counter more than one time for the same flow,
which is incorrect.
I can’t understand why there is multiple packet-in generated??
Regards,
Eman Bany Salameh
On Feb 28, 2018, at 2:56 PM, Vasu Dasari <vdas...@gmail.com
<mailto:vdas...@gmail.com>> wrote:
You could look for flow-removed messages from switch and use that to
adjust flows installed in your app accordingly.
In OpenFlow version >= 1.4 you could use flow monitoring as well. This
way you can keep a check on flows in the switch.
7.3.5.19 Flow Monitoring
https://www.opennetworking.org/images/stories/downloads/sdn-resources/onf-specifications/openflow/openflow-switch-v1.5.0.noipr.pdf#page149
<https://www.opennetworking.org/images/stories/downloads/sdn-resources/onf-specifications/openflow/openflow-switch-v1.5.0.noipr.pdf#page149>
On Feb 28, 2018, at 12:49 AM, knet solutions <knetsolutio...@gmail.com
<mailto:knetsolutio...@gmail.com>> wrote:
If we maintain the count in SDN controller, There is a possibility of
mismatch in the count between the switch and controller .
Each flow has a timeout(idle and hard), it will be flushed out after the
timeout period.
On Wed, Feb 28, 2018 at 1:59 PM, Moh'd Reza Abbasi <mr.mrabb...@gmail.com
<mailto:mr.mrabb...@gmail.com>> wrote:
I don't think OpenFlow v.1.3 has such a feature, but how about adding
a counter in your Ryu app to keep track of added/removed rules...
On Wed, Feb 28, 2018 at 11:53 AM, Eman Bany salameh via Ryu-devel
<ryu-devel@lists.sourceforge.net
<mailto:ryu-devel@lists.sourceforge.net>> wrote:
Hi,
I need to know the number of flows installed on the switch before
adding new one. What I did before is to request stat from the
switch then read the length of the list returned.
This way is not useful for me.
Is there any way to count them inside packet-in handler before
adding new flow? I want to limit the number of flows added to 1500.
Regards,
Eman Bany Salameh
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org <http://Slashdot.org>!
http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
<mailto:Ryu-devel@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/ryu-devel
<https://lists.sourceforge.net/lists/listinfo/ryu-devel>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org <http://Slashdot.org>!
http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net <mailto:Ryu-devel@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/ryu-devel
<https://lists.sourceforge.net/lists/listinfo/ryu-devel>
--
*/Regards,
/*
*/Knet solutions./*
https://github.com/knetsolutions/KNet
<https://github.com/knetsolutions/KNet>
http://knet-topology-builder.readthedocs.io/
<http://knet-topology-builder.readthedocs.io/>
http://knetsolutions.in/
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org <http://Slashdot.org>!
http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net <mailto:Ryu-devel@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/ryu-devel
<https://lists.sourceforge.net/lists/listinfo/ryu-devel>
--
*/Regards,
/*
*/Knet solutions./*
https://github.com/knetsolutions/KNet
http://knet-topology-builder.readthedocs.io/
http://knetsolutions.in/
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel