From 62cdafb5b5f61a3f4f10b8f578b8386463474343 Mon Sep 17 00:00:00 2001 From: Private Island Networks Date: Sat, 29 Aug 2026 21:23:14 -0400 Subject: create shark, rm lmmi --- shark.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 shark.py (limited to 'shark.py') diff --git a/shark.py b/shark.py new file mode 100644 index 0000000..e1950c0 --- /dev/null +++ b/shark.py @@ -0,0 +1,56 @@ +""" + shark.py +""" + +import pyshark + +from constants import * + +def _run_shark(q_cont, q_mle, ife, df, mode, ns, time): + + num_pkts = 0 + ts = time[0] + tf = time[1] + + cap_live = pyshark.LiveCapture(interface=ife, display_filter=df) + + while True: + + if mode.value == MODE_IDLE: + continue + + # mode is a global set during initialization by the browser + elif mode.value == MODE_LIVE: + cap_live.reset() + for pkt in cap_live.sniff_continuously(): + num_pkts = num_pkts + 1 + try: + msg_type = int(pkt.data.data[0:2],16) + if msg_type < MSG_TYPE_NOTIFY_MLE: + q_cont.put(pkt) + print ('put in Cont Q: ', num_pkts) + elif msg_type == MSG_TYPE_NOTIFY_MLE: + q_mle.put(pkt) + print ('put in MLE Q: ', num_pkts) + except Exception as e: + print(str(e)) + pass + + if mode.value == MODE_IDLE: + break + + + elif mode.value == MODE_FILE: + cap_file = pyshark.FileCapture(input_file=LOG_PATH + ns.filename, display_filter=df) + for pkt in cap_file: + num_pkts = num_pkts + 1 + time = float(pkt.frame_info.get_field("frame.time_relative").__str__()[0:9]) + if time >= ts and time < tf: + q_cont.put(pkt) + if DEBUG: + print ('put in Q: ', num_pkts) + if DEBUG: + print("file replay finished") + + cap_file.close() + mode.value = MODE_IDLE \ No newline at end of file -- cgit v1.2.3-70-g09d2