From 4154578c4e5436dd7070e6a09848df841fb505db Mon Sep 17 00:00:00 2001 From: Yaro Kasear Date: Tue, 15 Apr 2025 11:16:35 -0500 Subject: [PATCH] Refactor analyze_pcap to remove congestion score placeholder and update return values for clarity --- enrich.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/enrich.py b/enrich.py index 6b32a3a..db8f364 100755 --- a/enrich.py +++ b/enrich.py @@ -294,7 +294,6 @@ def analyze_pcap(pcapng_path, start_ts, end_ts, ap_bssid, ap_channel): aps_on_channel = 0 avg_ap_signal = 0 max_ap_signal = 0 - unlinked_devices = 0 try: @@ -311,18 +310,13 @@ def analyze_pcap(pcapng_path, start_ts, end_ts, ap_bssid, ap_channel): clients_on_ap = get_clients_on_ap(filtered_packets, ap_bssid) clients_on_channel = get_clients_on_channel(filtered_packets, ap_channel, ap_bssid) aps_on_channel = get_aps_on_channel(filtered_packets, ap_channel) - - # Placeholder: Logic will be added for: - # - CongestionScore - avg_ap_signal, max_ap_signal = calculate_signal_strength_stats(filtered_packets, ap_channel) - unlinked_devices = get_unlinked_devices(filtered_packets, ap_channel) finally: cap.close() - return clients_on_ap, clients_on_channel, aps_on_channel, None, avg_ap_signal, max_ap_signal, unlinked_devices + return clients_on_ap, clients_on_channel, aps_on_channel, avg_ap_signal, max_ap_signal, unlinked_devices def main(): args = parse_args() @@ -349,7 +343,7 @@ def main(): with open(args.csv, newline='') as infile, open(args.output, 'w', newline='', encoding='utf-8') as outfile: reader = csv.DictReader(infile) fieldnames = reader.fieldnames + [ - 'ClientsOnAP', 'ClientsOnChannel', 'APsOnChannel', 'CongestionScore', + 'ClientsOnAP', 'ClientsOnChannel', 'APsOnChannel', 'AvgAPSignal', 'StrongestAPSignal', 'UnlinkedDevices' ] writer = csv.DictWriter(outfile, fieldnames=fieldnames) @@ -365,13 +359,12 @@ def main(): writer.writerow(row) continue - clients_ap, clients_chan, aps_chan, congestion, avg_signal, strongest_signal, unlinked = analyze_pcap(args.pcapng, tstart, tend, ap_bssid, ap_channel) + clients_ap, clients_chan, aps_chan, avg_signal, strongest_signal, unlinked = analyze_pcap(args.pcapng, tstart, tend, ap_bssid, ap_channel) row.update({ 'ClientsOnAP': clients_ap, 'ClientsOnChannel': clients_chan, 'APsOnChannel': aps_chan, - 'CongestionScore': congestion, 'AvgAPSignal': avg_signal, 'StrongestAPSignal': strongest_signal, 'UnlinkedDevices': unlinked