[pox-dev] Very low performance in a database backed controller.

Karthik Sharma karthik.sharma at gmail.com
Sun May 12 23:15:47 PDT 2013


I have a function called act_like_switch which uses a databased backed
architecture.If I come across a packet whose source address is not in the
database I insert the <src_packet,port_no> into the database.Then I do a
query of the destination address in the database and retrive the port_no
from the database and then send out the packet.

As you can see in the code below I measure the time taken for insert and
query.I also record the counts as well.Apparently the average number of
inserts is 30 per seconds and the average number of queries is 700 per
seconds.This is very low for my application.Are there any ways to improve
this numbers? Am I doing anything wrong?


 def act_like_switch (self, packet, packet_in):
    """
    Implement switch-like behavior.
    """
    # Learn the port for the source MAC
    #print "RECIEVED FROM PORT ",packet_in.in_port , "SOURCE ",packet.src
,"DEST" , packet.dst
    self.mac_to_port[packet.src]=packet_in.in_port
    start = time.time()
    r_res =
session.query(SourcetoPort).filter_by(src_address=str(packet.src)).first()
    if r_res is None:
        entry = SourcetoPort(src_address=str(packet.src) ,
port_no=packet_in.in_port)
        #print "inserting src
addr",str(packet.src),"port",str(packet_in.in_port)
        #add the record to the session object
        session.add(entry)
        #add the record to the session object
        session.commit()
        end = time.time()
        self.total_ins_time += (end - start)
        self.total_ins_count+=1;
    start = time.time()
    q_res =
session.query(SourcetoPort).filter_by(src_address=str(packet.dst)).first()
    self.total_query_count+=1;
    end = time.time()
    self.total_query_time += (end - start)
    if q_res is not None:
           #print "retrieve from
database",q_res.src_address,"port_no",q_res.port_no
           self.send_packet(packet_in.buffer_id,
packet_in.data,q_res.port_no, packet_in.in_port)
           #create a flow modification message
           #msg = of.ofp_flow_mod()
           #set the fields to match from the incoming packet
           #msg.match = of.ofp_match.from_packet(packet)
           #send the rule to the switch so that it does not query the
controller again.
           #msg.actions.append(of.ofp_action_output(port=q_res.port_no))
           #push the rule
           #self.connection.send(msg)
    else:
           #flood this packet out as we don't know about this node.
           self.send_packet(packet_in.buffer_id,
packet_in.data,of.OFPP_FLOOD, packet_in.in_port)
           #print "flooding src addr",str(packet.src),"dst
addr",str(packet.dst)


Regards,
Karthik.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.noxrepo.org/pipermail/pox-dev-noxrepo.org/attachments/20130513/6ec592af/attachment-0001.htm>


More information about the pox-dev mailing list