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

dynamic detection of new flows

parent 0ca7ef2e
This diff is collapsed.
......@@ -79,10 +79,13 @@ class TcpLivePlot():
if(len(tmpData) == len(LOG_FORMAT)):
data = dict(zip(LOG_FORMAT, tmpData))
# print(data)
port = int(data['dstPort'])
if(port not in self.connectionBuffer):
self.connectionBuffer[port] = deque()
self.connectionBuffer[port].append(data)
srcPort = int(data['srcPort'])
dstPort = int(data['dstPort'])
if(dstPort in self.options.filterPorts):
flowIdentifier = str(srcPort) + "-" + str(dstPort)
if(flowIdentifier not in self.connectionBuffer):
self.connectionBuffer[flowIdentifier] = deque()
self.connectionBuffer[flowIdentifier].append(data)
# self.incomeBuffer.append(sample)
def processGui(self):
......@@ -97,47 +100,50 @@ class TcpLivePlot():
# plt.show()
def processInputFiltering(self):
"""
Filters retrieved data by selected port. Drops malformed data.
"""
return
lastTimestamp = 0
while(True):
try:
line = self.incomeBuffer.popleft()
except IndexError:
time.sleep(0.00001)
else:
tmpData = line.split(" ")
if(len(tmpData) is NUMBER_OF_VALUES):
data = dict(zip(LOG_FORMAT, tmpData))
else:
continue
try:
timestamp = float(data['time'])
port = int(data['dstPort'])
except ValueError:
continue
else:
if(port not in self.options.filterPorts):
continue
filteredData = {}
try:
for val in VALUES_TO_PROCESS:
filteredData[val] = float(data[val])
except ValueError:
continue
else:
timestampDelta = lastTimestamp - timestamp
if(timestampDelta > self.options.plotResolution):
lastTimestamp = timestamp
continue
self.connectionBuffer[port].append(filteredData)
lastTimestamp = timestamp
# def processInputFiltering(self):
# """
# Filters retrieved data by selected port. Drops malformed data.
# """
# return
#
# lastTimestamp = 0
# while(True):
# try:
# line = self.incomeBuffer.popleft()
# except IndexError:
# time.sleep(0.00001)
# else:
# tmpData = line.split(" ")
# if(len(tmpData) is NUMBER_OF_VALUES):
# data = dict(zip(LOG_FORMAT, tmpData))
# else:
# continue
#
# try:
# timestamp = float(data['time'])
# srcPort = int(data['srcPort'])
# dstPort = int(data['dstPort'])
# flowIdentifier = str(srcPort) + "-" + str(dstPort)
# except ValueError:
# continue
# else:
# if(dstPort in self.options.filterPorts):
# print("bar")
# filteredData = {}
# try:
# for val in VALUES_TO_PROCESS:
# filteredData[val] = float(data[val])
# except ValueError:
# continue
# else:
# timestampDelta = lastTimestamp - timestamp
# if(timestampDelta > self.options.plotResolution):
# lastTimestamp = timestamp
# continue
# self.connectionBuffer[flowIdentifier].append(filteredData)
# lastTimestamp = timestamp
# else:
# print("bar")
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