diff --git a/.gitignore b/.gitignore index f212f86..317ada2 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ __pycache__/ # Simulation Output animationInstructions*.* *.csv - +*.svg # Visual Studio bin Bin diff --git a/Python/filegenerator.py b/Python/filegenerator.py index 9be9d00..f22c182 100644 --- a/Python/filegenerator.py +++ b/Python/filegenerator.py @@ -3,7 +3,7 @@ import json from . import connectionObject - +import matplotlib.pyplot as plt class filegenerator: def __init__(self, make_log, make_summary, @@ -23,6 +23,7 @@ def __init__(self, make_log, make_summary, # names of the output files self.logName = log_name self.summaryName = summary_name + self.sessionId = sessionId self.curTime = 0 # current time unit (same as the other classes) self.dddState = dddState @@ -492,6 +493,12 @@ def outputFile(self): if(self.makeSummary): self.summaryFile.close() + self.initalizePlot() + self.genPlot("Sent", 1) + self.genPlot("Received", 2) + self.genPlot("Dropped", 3) + self.genPlot("Dropped on Average", 4) + self.genPlot("Received on Average", 5) if (self.makeLog): # self.packetDictionary["Inputs: "] = ["DDD State " + str(self.dddState), "Send Rate: " + str("self.sendRate") + " MB/s", "Packet Size: " + str(self.packetSize) + " MB", "Resend Time for SYN-ACKs: " + str(self.resendSynAckTime) + " ms", "Max Queue Size for half open connections: " + str(self.MaxQueueSize) + '" MB"', "DDD Mapping Delay" + str(self.dddMappingDelay) + " ms", "Propagation Delay: " + str(self.PropDelay) + " ms", "Number of DDD ports open: " + str(self.NumbDDDPortsOpen), "Bandwidth of connections: " + str("N/A") + " MB/s", "Time until next DDD port change: " + str(self.timeUntilNextDDDChange) + " ms", "Overlap time for old DDD Ports: " + str(self.overlapTime) + " ms", " ", "Program Version 2", "Date and time: " + str(getTime("%c"))] # if (len(self.packetDictionary[ "Inputs: "]) > self.lengthLongestEntry): @@ -507,6 +514,9 @@ def outputFile(self): generator.writerows(zip(*[self.packetDictionary[key] for key in sortedKeys])) outputLogFile.close() + + + def sortHelper(self, string): if ("Input" in string) or ("Program" in string): return ("A", -1) @@ -549,3 +559,43 @@ def headerGen(self, file, LogFlag=""): file.write(line) self.header.close() + + def initalizePlot(self): + summary = open(self.summaryFileName) + self.masterLst = list() + for line in summary: + self.masterLst.append(line.split(",")) + summary.close() + + def genPlot(self, name, start): + + time = [float(self.masterLst[i][0]) for i in range(19, len(self.masterLst))] + aCol = [float(self.masterLst[i][start]) for i in range(19, len(self.masterLst))] + cCol = [float(self.masterLst[i][start+5]) for i in range(19, len(self.masterLst))] + rCol = [float(self.masterLst[i][start+10]) for i in range(19, len(self.masterLst))] + mCol = [float(self.masterLst[i][start+15]) for i in range(19, len(self.masterLst))] + nCol = [float(self.masterLst[i][start+20]) for i in range(19, len(self.masterLst))] + tCol = [float(self.masterLst[i][start+25]) for i in range(19, len(self.masterLst))] + + print("T: ", time) + print("A: ", aCol) + print("C: ", cCol) + print("R: ", rCol) + print("M: ", mCol) + print("N: ", nCol) + print("T: ", tCol) + + plt.plot(time, aCol, label="Attacker") + plt.plot(time, cCol, label="Client") + plt.plot(time, rCol, label="Router") + plt.plot(time, mCol, label="Amplifying Server") + plt.plot(time, nCol, label="Normal Server") + plt.plot(time, tCol, label="NAT") + + plt.xlabel("Time (ms)") + plt.ylabel("Packets " + name) + plt.title("Packets " + name + " vs. Time") + plt.legend() + + plt.savefig("plots\\"+name+"-{0}.svg".format(str(self.sessionId))) + plt.close()