Hi,

On 2016年06月27日 14:36, tanvir.ulhu...@data61.csiro.au wrote:
>
> Hi
>
>
> I have three questions.
>
>
> Question 1: I want to add a data flow in a specific switch among available 
> switches in the network.
>
>
> I have used the following code with that intention that it will add a data 
> flow in the switch 4 (datapath=000000000004). Is this code ok, specifically 
> the matching field?
>
> .....
>
> ..........
>
> match = parser.OFPMatch(in_port=1, eth_dst='00:00:00:00:00:07', 
> eth_src='00:00:00:00:00:04', datapath=000000000004)
> actions = [parser.OFPActionOutput(ofp.OFPP_NORMAL, ofproto.OFPCML_NO_BUFFER)]
> inst = [parser.OFPInstructionActions(ofp.OFPIT_APPLY_ACTIONS,actions)]
> self.add_flow(datapath=datapath, command=ofp.OFPFC_ADD, priority=1, 
> out_port=3, match=match, instructions=inst)
>
> ........
>
> ....

The question is "before executing add_flow() method, to get datapath instance 
is required whose datapath id is 4, but how?", right?
# Note: OFPMatch does not have 'datapath' field.

To get the specific datapath instance, you can use ryu/app/ofctl/api.py.

e.g.)
$ git diff
diff --git a/ryu/app/simple_switch_13.py b/ryu/app/simple_switch_13.py
index b9cbad0..2480dc3 100644
--- a/ryu/app/simple_switch_13.py
+++ b/ryu/app/simple_switch_13.py
@@ -21,6 +21,8 @@ from ryu.ofproto import ofproto_v1_3
  from ryu.lib.packet import packet
  from ryu.lib.packet import ethernet
  
+from ryu.app.ofctl import api
+
  
  class SimpleSwitch13(app_manager.RyuApp):
      OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
@@ -62,6 +64,10 @@ class SimpleSwitch13(app_manager.RyuApp):
                                      match=match, instructions=inst)
          datapath.send_msg(mod)
  
+        # Send event to get datapath
+        dp = api.get_datapath(self, datapath.id)
+        self.logger.info('datapath=%s', dp)
+
      @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
      def _packet_in_handler(self, ev):
          # If you hit this you might want to increase


>
>
> Question 2: What will be happened to other switches if this matching becomes 
> partially true of them ?
>
>                          because in other switches first three fields 
> (in_port=1, eth_dst='00:00:00:00:00:07', eth_src='00:00:00:00:00:04')  will 
> be the same.

What does exactly 'partially true' mean?

OpenFlow Spec says:
   A packet matches a flow entry if ALL the match fields of the flow entry are 
matching the corresponding
   header fields and pipeline fields from the packet.

So, if the flow entry matches partially true, but partially false,
the flow entry does not match the packet.


>
>
> Question 3: How to verify that the switch is sending the flows or not ?
>
>                       I used "ovs-ofctl -O OpenFlow13 dump-flows s4", but it 
> does not show the continuous monitoring. I am expecting something which will 
> continuously show the updates of that switch.

AFAIK, OpenFlow 1.3 does not provide such features for monitoring the flows 
continuously.
So we need to send FlowStats messages or execute dump-flows commands 
periodically.
Or, how about using ovs-ofctl snoop or monitor command?

FYI,
OFPMP_FLOW_MONITOR (OpenFlow 1.4+) provides the feature for monitoring the 
updates of flow entries,
but please confirm your switch supports it.

Thanks,
Iwase

>
>
>
>
> Thanks
>
> -Tanvir
>
>
> For your kind info, here is the used code....  [there are 4 switches (0...04, 
> 0...05, 0...06, 0...07) in a SDN network. This code will add a flow from 
> 0...04 to 0...07]
>
>
> ​
> from operator import attrgetter
> from ryu.base import app_manager
> from ryu.controller import ofp_event
> from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER, 
> DEAD_DISPATCHER
> from ryu.controller.handler import set_ev_cls
> from ryu.ofproto import (ofproto_v1_3, ether)
> from ryu.lib import hub
> from ryu.topology import event
> from ryu.lib.packet import (packet, ethernet, arp, icmp, ipv4)
> from ryu.lib.packet import ether_types
> from ryu.app.wsgi import ControllerBase, WSGIApplication, route
> from webob import Response
>
> import time
>
> class SimpleSW(app_manager.RyuApp):
>          OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
>
>          def __init__(self, *args, **kwargs):
>                  super(SimpleSW, self).__init__(*args, **kwargs)
>
>
>          # a function that will send flows from switch to switch
> def add_flow(self, datapath, command, priority, out_port, match, 
> instructions):
> ofproto = datapath.ofproto
> ofp = datapath.ofproto
> parser = datapath.ofproto_parser
> flow_add = parser.OFPFlowMod(datapath=datapath, table_id=1, command=command, 
> buffer_id=ofp.OFP_NO_BUFFER, priority=priority, out_port=out_port,  
> match=match, instructions=instructions)
> datapath.send_msg(flow_add)
>
>
>         # a function that will delete flows from switch to switch
> def delete_flow(self, datapath, priority, match, out_port, out_group, 
> instructions ):
> ofproto = datapath.ofproto
> ofp = datapath.ofproto
> parser = datapath.ofproto_parser
> flow_del = parser.OFPFlowMod(datapath=datapath, priority=priority, 
> match=match, table_id=1, command=ofproto.OFPFC_DELETE, buffer_id= 
> ofp.OFP_NO_BUFFER, out_port=ofproto.OFPP_ANY, out_group=ofproto.OFPG_ANY, 
> instructions=instructions)
> datapath.send_msg(flow_del)
>
>
>
>          # the packet handled by the controller
> @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
> def _packet_in_handler(self, ev):
> msg = ev.msg
> datapath = msg.datapath
> ofproto = datapath.ofproto
> ofp = datapath.ofproto
> parser = datapath.ofproto_parser
> in_port = msg.match['in_port']
> #out_port = msg.match['out_port']
>
> pkt = packet.Packet(msg.data)
> eth = pkt.get_protocols(ethernet.ethernet)[0]
> dst = eth.dst
> src = eth.src
>
>
>
> @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
> def switch_features_handler(self, ev):
> datapath = ev.msg.datapath
> ofproto = datapath.ofproto
> ofp = datapath.ofproto
> parser = datapath.ofproto_parser
>
> mat00 = parser.OFPMatch(in_port=1, eth_dst='00:00:00:00:00:07', 
> eth_src='00:00:00:00:00:04', datapath=000000000004)
> actions = [parser.OFPActionOutput(ofp.OFPP_NORMAL, ofproto.OFPCML_NO_BUFFER)]
> inst = [parser.OFPInstructionActions(ofp.OFPIT_APPLY_ACTIONS,actions)]
> self.add_flow(datapath=datapath, command=ofp.OFPFC_ADD, priority=1, 
> out_port=3, match=mat00, instructions=inst)
> #hub.sleep(2)
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
> Francisco, CA to explore cutting-edge tech and listen to tech luminaries
> present their vision of the future. This family event has something for
> everyone, including kids. Get more information and register today.
> http://sdm.link/attshape
>
>
>
> _______________________________________________
> Ryu-devel mailing list
> Ryu-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
>

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to