forked from neyney10/PCAPFeatureExtractor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsessions_processor.py
31 lines (24 loc) · 946 Bytes
/
sessions_processor.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
class SessionsProcessor:
def __init__(self) -> None:
pass
def process(self, df):
grouped_by_session = df.groupby(lambda f: self._five_tuple(df.iloc[f]))
print('Finished processing sessions')
def _five_tuple(self, flow):
return '-'.join(
sorted([
flow.src_ip,
str(flow.src_port),
flow.dst_ip,
str(flow.dst_port),
str(flow.protocol)
])
)
def _fill_empty_timed_windows(self, time_windowed_flows):
'''
W.I.P
'''
previous_window = time_windowed_flows[0]
for i in range(1, len(time_windowed_flows)):
current_window = time_windowed_flows[1]
time_diff = current_window.bidirectional_first_seen_ms - previous_window.bidirectional_last_seen_ms + (1 - previous_window.bidirectional_duration_ms)