def main(): ######################################### # Parse the files. ########################################## pcapPar = pcapParser( tcpdump, tcpdump_list, timezone_offset=timezone_offset, max_packets=None, start_time=None, stop_time=None) #start and stop time are in unix time. tensors = pcapPar.tensors() labeledTensors = pcapPar.labeledTensors() ########################################## #Set up the SOM and train ########################################## som = SOM(n=10, m=10, dim=len(tensors[0]), n_iterations=2) som.train(tensors) som.label(labeledTensors) ########################################## # Get and print result ########################################## percentages = som.get_percentages() #Get accuracy matrix. # Note: Once the SOM is working, labeledTensors should belong to the test data opposed to the training data. matrix = som.get_accuracy_matrix(labeledTensors) print("attacks identified as attacks:" + str(matrix[0][0])) print("attacks identified as normal:" + str(matrix[0][1])) print("attacks identifed as other:" + str(matrix[0][2])) print("normal identified as attack:" + str(matrix[1][0])) print("normal identified as normal:" + str(matrix[1][1])) print("normal identified as other:" + str(matrix[1][2])) ########################################### # Plot ########################################## # Heat Map som.plot_heat_map() # Attack lines. som.plot_line_graph(labeledTensors, pcapPar.labler) plt.show()