Commit ff6a55aa authored by Michael König's avatar Michael König

dynamic detection of new flows

parent 0ca7ef2e
This diff is collapsed.
...@@ -79,11 +79,14 @@ class TcpLivePlot(): ...@@ -79,11 +79,14 @@ class TcpLivePlot():
if(len(tmpData) == len(LOG_FORMAT)): if(len(tmpData) == len(LOG_FORMAT)):
data = dict(zip(LOG_FORMAT, tmpData)) data = dict(zip(LOG_FORMAT, tmpData))
# print(data) # print(data)
port = int(data['dstPort']) srcPort = int(data['srcPort'])
if(port not in self.connectionBuffer): dstPort = int(data['dstPort'])
self.connectionBuffer[port] = deque() if(dstPort in self.options.filterPorts):
self.connectionBuffer[port].append(data) flowIdentifier = str(srcPort) + "-" + str(dstPort)
# self.incomeBuffer.append(sample) if(flowIdentifier not in self.connectionBuffer):
self.connectionBuffer[flowIdentifier] = deque()
self.connectionBuffer[flowIdentifier].append(data)
# self.incomeBuffer.append(sample)
def processGui(self): def processGui(self):
# while(not self.__stopped.wait(THREAD_STOPFLAG_WAIT)): # while(not self.__stopped.wait(THREAD_STOPFLAG_WAIT)):
...@@ -97,47 +100,50 @@ class TcpLivePlot(): ...@@ -97,47 +100,50 @@ class TcpLivePlot():
# plt.show() # plt.show()
def processInputFiltering(self): # def processInputFiltering(self):
""" # """
Filters retrieved data by selected port. Drops malformed data. # Filters retrieved data by selected port. Drops malformed data.
""" # """
return # return
#
lastTimestamp = 0 # lastTimestamp = 0
while(True): # while(True):
try: # try:
line = self.incomeBuffer.popleft() # line = self.incomeBuffer.popleft()
except IndexError: # except IndexError:
time.sleep(0.00001) # time.sleep(0.00001)
else: # else:
tmpData = line.split(" ") # tmpData = line.split(" ")
if(len(tmpData) is NUMBER_OF_VALUES): # if(len(tmpData) is NUMBER_OF_VALUES):
data = dict(zip(LOG_FORMAT, tmpData)) # data = dict(zip(LOG_FORMAT, tmpData))
else: # else:
continue # continue
#
try: # try:
timestamp = float(data['time']) # timestamp = float(data['time'])
port = int(data['dstPort']) # srcPort = int(data['srcPort'])
except ValueError: # dstPort = int(data['dstPort'])
continue # flowIdentifier = str(srcPort) + "-" + str(dstPort)
else: # except ValueError:
if(port not in self.options.filterPorts): # continue
continue # else:
# if(dstPort in self.options.filterPorts):
filteredData = {} # print("bar")
try: # filteredData = {}
for val in VALUES_TO_PROCESS: # try:
filteredData[val] = float(data[val]) # for val in VALUES_TO_PROCESS:
except ValueError: # filteredData[val] = float(data[val])
continue # except ValueError:
else: # continue
timestampDelta = lastTimestamp - timestamp # else:
if(timestampDelta > self.options.plotResolution): # timestampDelta = lastTimestamp - timestamp
lastTimestamp = timestamp # if(timestampDelta > self.options.plotResolution):
continue # lastTimestamp = timestamp
self.connectionBuffer[port].append(filteredData) # continue
lastTimestamp = timestamp # self.connectionBuffer[flowIdentifier].append(filteredData)
# lastTimestamp = timestamp
# else:
# print("bar")
def handleSignals(self, signal, frame): def handleSignals(self, signal, frame):
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment