We have an OVS enabled switch, which is directly connected to multiple
nodes. These nodes are running a distributed application, with cause many
communication between them. I am using RYU controller, and I have changed
how packets get matched against rules. Here you can see what properties I'm
considering to get the packet get matched( This is the code, nw is IP
header,  tp is TCP header):

from ryu.base import app_manager

from ryu.controller import ofp_event

from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER

from ryu.controller.handler import set_ev_cls

from ryu.ofproto import ofproto_v1_3

from ryu.lib.packet import packet

from ryu.lib.packet import ethernet

from ryu.lib.packet import tcp

from ryu.lib.packet import ipv4

from time import sleep

from ryu.lib.ovs import bridge

from SimpleXMLRPCServer import SimpleXMLRPCServer

from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler

import logging

import os

import subprocess


class SimpleSwitch13(app_manager.RyuApp):

    OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]


    def __init__(self, *args, **kwargs):

        super(SimpleSwitch13, self).__init__(*args, **kwargs)

        self.mac_to_port = {}


    @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)

    def switch_features_handler(self, ev):

        datapath = ev.msg.datapath

        ofproto = datapath.ofproto

        parser = datapath.ofproto_parser

        match = parser.OFPMatch()

        actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER,

                                          ofproto.OFPCML_NO_BUFFER)]

        self.add_flow(datapath, 0, match, actions)


    def add_flow(self, datapath, priority, match, actions):

        ofproto = datapath.ofproto

        parser = datapath.ofproto_parser


        inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS,

                                             actions)]


        #actions.insert(0, parser.OFPActionSetQueue(3))


        mod = parser.OFPFlowMod(datapath=datapath, priority=priority,

                                match=match, instructions=inst)

        datapath.send_msg(mod)


    @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)

    def _packet_in_handler(self, ev):

        msg = ev.msg

        datapath = msg.datapath

        ofproto = datapath.ofproto

        parser = datapath.ofproto_parser

        in_port = msg.match['in_port']


        pkt = packet.Packet(msg.data)

        eth = pkt.get_protocols(ethernet.ethernet)[0]

        nw = pkt.get_protocol(ipv4.ipv4)

        tp = None

        if nw is not None:

            tp = pkt.get_protocol(tcp.tcp)


        dpid = datapath.id

        self.mac_to_port.setdefault(dpid, {})


        #self.logger.info("packet in %s %s %s %s", dpid, src, dst, in_port)


        # learn a mac address to avoid FLOOD next time.

        self.mac_to_port[dpid][eth.src] = in_port


        if eth.dst in self.mac_to_port[dpid]:

            out_port = self.mac_to_port[dpid][eth.dst]

        else:

            out_port = ofproto.OFPP_FLOOD


        actions = [parser.OFPActionOutput(out_port)]

        #actions.append( parser.OFPActionSetQueue(7) )


        # install a flow to avoid packet_in next time

        if out_port != ofproto.OFPP_FLOOD:

            if nw is not None:

                match = parser.OFPMatch(

                    ipv4_src=nw.src,

                    ipv4_dst=nw.dst,

                    ip_proto=nw.proto,

                    eth_type=eth.ethertype,

                    tcp_src=tp.src_port,

                    tcp_dst=tp.dst_port)

                self.add_flow(datapath, 1, match, actions)


        data = None

        if msg.buffer_id == ofproto.OFP_NO_BUFFER:

            data = msg.data


        out = parser.OFPPacketOut(datapath=datapath,
buffer_id=msg.buffer_id,

                                  in_port=in_port, actions=actions,
data=data)

        datapath.send_msg(out)

Now, with the new code, I could see that hundred rules are getting created
inside the switch. This causes my application to have really slow progress,
and it's because I barely see data communication inside the switch, when
I'm monitoring it using the STAT request. Now my question is, the
performance reduction is because the switch cannot match this high number
of rules, or because I didn't wrote the controller correctly?

Thanks
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to