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)

........

....


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.


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.





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

Reply via email to