diff options
| author | Arthur Pavlov <arthur.pavlovs@mail.utoronto.ca> | 2018-11-22 17:38:41 +0000 |
|---|---|---|
| committer | Arthur Pavlov <arthur.pavlovs@mail.utoronto.ca> | 2018-11-22 17:38:41 +0000 |
| commit | 3d310c7630d241688172f915151cee58646ff399 (patch) | |
| tree | 976b7a396076735b7d73dc4d99b6b15d55b12551 /code/perpacket | |
| parent | a4dee6254663b66e990464ca998fd1e2a1c7964b (diff) | |
inter arrival time data
Diffstat (limited to 'code/perpacket')
| -rw-r--r-- | code/perpacket/parser.py | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/code/perpacket/parser.py b/code/perpacket/parser.py deleted file mode 100644 index 37e7a8a..0000000 --- a/code/perpacket/parser.py +++ /dev/null @@ -1,53 +0,0 @@ -import csv -import numpy as np -import matplotlib.pyplot as plt - -with open('packetdata.csv', mode='r') as csv_file: - csv_reader = csv.DictReader(csv_file) - line_count = 0 - flowsTCP = [] - flowsUDP = [] - for row in csv_reader: - if row["Protocol"] == 'TCP': - flowExists = False - src = row["Source"] - dest = row["Destination"] - srcPort = row["Info"].split(' > ')[0].split(' ')[0] - destPort = row["Info"].split(' > ')[1].split(' ')[1] - timeElapsed = float(row["Time delta from previous captured frame"]) - for flow in flowsTCP: - if src in flow and dest in flow and srcPort in flow and destPort in flow: - flowExists = True - flow[4] += timeElapsed - flow[5] += 1 - break - if not flowExists: - flowsTCP.append([src, dest, srcPort, destPort, timeElapsed, 1]) - # if row["Protocol"] == 'UDP': - # flowExists = False - # src = row["Source"] - # dest = row["Destination"] - # srcPort = row["Info"].split(' > ')[0].split(' ')[0] - # destPort = row["Info"].split(' > ')[1].split(' ')[1] - # for flow in flowsUDP: - # if src in flow and dest in flow and srcPort in flow and destPort in flow: - # flowExists = True - # break - # if not flowExists: - # flowsUDP.append([src, dest, srcPort, destPort]) - flowsTCPTimeAverages = [] - for flow in flowsTCP: - flowsTCPTimeAverages.append(flow[4] / flow[5]) - with open('tcp_arrivel_time.csv', mode='w', newline='') as tcpArrival: - fieldnames = ['time'] - writer = csv.DictWriter(tcpArrival, fieldnames=fieldnames) - writer.writeheader() - for flow in flowsTCPTimeAverages: - writer.writerow({'time': flow}) - # num_bins = 20 - # counts, bin_edges = np.histogram (flowsTCPTimeAverages, bins=num_bins, normed=True) - # cdf = np.cumsum (counts) - # plt.plot (bin_edges[1:], cdf/cdf[-1]) - # plt.show() - # print(flowsTCPTimeAverages) - # print('UDP Length ' + str(len(flowsUDP))) |
