Hi All,

I am trying to summarize tcp traffic statistics for each destination host
for every minute using the Timer module in an application written on top of
the POX controller. The number of destination hosts in my network is
limited say 10 and the stats is dumped as a record in a CSV file for each
destination host. When the traffic load is normal, thread works fine and I
am getting expected result. For example, if I collect the stats for 60
minutes I am getting 600 (60 * 10) records in the CSV file. However, when
the traffic load is very high, the number of records exceed too much
instead of 600. Can anyone explain why the number of records are too many
in the CSV file for a high traffic load? Following is the relevant code
snippet:

from pox.core import core
from pox.lib.util import str_to_bool
from pox.lib.recoco import Timer
from threading import Thread
from feature import *
from time import time

import pox.openflow.libopenflow_01 as of

log = core.getLogger()

pkts_tcp = []
dst_tcp = []

TIMER_TRIG = 60

class FeatureAggregation (Thread):
    def __init__(self, pkts_tcp, dst_tcp, tcpfls,tcpfld):
        Thread.__init__(self)
        self.pkts_tcp = pkts_tcp
        self.dst_tcp = dst_tcp

    def run(self):
        ftr_tcp = summarize('tcp',  self.dst_tcp, self.pkts_tcp)
        fw = open("out.csv","a")
        for i in self.dst_tcp:
            tftr = ftr_tcp.get(i)
            outstr = i+','
            for k in range(len(tftr)):
                outstr = outstr + str(tftr[k]) + ','

            outstr = outstr + '\n'
            fw.write(outstr)
    fw.close()

class MyDevice (object):

    def __init__ (self, connection, transparent):
        self.connection  = connection
        self.transparent = transparent
        self.macToPort   = {}
        connection.addListeners(self)

        def _timer_func():
            global pkts_tcp
            global dst_tcp
            featureStats = FeatureAggregation(pkts_tcp, dst_tcp)
            featureStats.start()
            pkts_tcp = []
            dst_tcp = []

        Timer(TIMER_TRIG, _timer_func, recurring=True)

pkts_tcp and dst_tcp lists are populated by different functions in the code
which I have not included here. The _timer_func() is invoked after every
60s and it creates a thread of FeatureAggregation module. I found that the
time taken inside summarize function is around 6s~10s in high traffic load
whereas in normal load it is less than 1s.

-- 
With regards,
Quamar Niyaz
_______________________________________________
openflow-discuss mailing list
openflow-discuss@lists.stanford.edu
https://mailman.stanford.edu/mailman/listinfo/openflow-discuss

Reply via email to