-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraphics.py
47 lines (40 loc) · 1.21 KB
/
graphics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import matplotlib.pyplot as plt
def draw_statistics(data, xlabel, ylabel, title, position):
'''
Draw statistics with the given parameters
'''
labels = [str(item[0]) for item in data]
values = [item[1] for item in data]
ax = plt.subplot(position)
ax.bar(labels, values)
ax.set_xlabel(xlabel)
ax.set_ylabel(ylabel)
ax.set_title(title)
def show_statistics(sniffing_stat):
'''
Displays a window with statistics graphs
'''
plt.figure(num='Packet Inspector statistics', figsize=(10, 6))
draw_statistics(
sniffing_stat.get_top_activity(sniffing_stat.connection_activity, 6),
'Connection',
'Amount of packets',
'Connections activity statistics',
211
)
draw_statistics(
sniffing_stat.get_top_activity(sniffing_stat.ip_activity, 4),
'IP Address',
'Amount of packets',
'IP Address statistics',
223
)
draw_statistics(
sniffing_stat.get_top_activity(sniffing_stat.packets_statistics, 4),
'Protocol',
'Amount of packets',
'Protocol statistics',
224
)
plt.tight_layout()
plt.show()