Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhinna Adhikari committed Mar 21, 2021
2 parents bab4852 + a16b8d7 commit e1fa3a5
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ __pycache__/
# Simulation Output
animationInstructions*.*
*.csv

*.svg
# Visual Studio
bin
Bin
Expand Down
52 changes: 51 additions & 1 deletion Python/filegenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import json

from . import connectionObject

import matplotlib.pyplot as plt

class filegenerator:
def __init__(self, make_log, make_summary,
Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand All @@ -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)
Expand Down Expand Up @@ -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()

0 comments on commit e1fa3a5

Please sign in to comment.