forked from Willtl/ids-ldpi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_debug.py
50 lines (37 loc) · 1.38 KB
/
main_debug.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
48
49
50
import time
from typing import NoReturn
from ldpi import LightDeepPacketInspection
from options import SnifferOptions
from sniffer import SnifferPcap
def main() -> NoReturn:
"""
Main debugging function for packet sniffing from a .pcap file.
This function initializes the `SnifferPcap` class with command line arguments, sets the path to the .pcap file,
initializes `LightDeepPacketInspection`, and starts the packet sniffing from the .pcap file. It also contains
a loop that keeps the program running until interrupted.
TODO:
- Replace the while True loop with a decision engine loop.
"""
# Initialize command line arguments
args = SnifferOptions()
args.parse_options()
# Initialize SnifferPcap with the provided arguments
snf = SnifferPcap(args)
# Set the path to the .pcap file
snf.set_pcap_path('datasets/TII-SSRC-23/pcap/benign/video/rtp.pcap')
# Initialize LightDeepPacketInspection
ldpi = LightDeepPacketInspection()
# Register LDPI as a subscriber to the SnifferPcap
snf.add_subscriber(ldpi)
# Start the sniffer
snf.run()
# Decision engine loop (placeholder) - Keeps running until interrupted
try:
while True:
time.sleep(1.0)
except (KeyboardInterrupt, SystemExit):
print("Shutting down...")
snf.stop()
ldpi.stop()
if __name__ == '__main__':
main()