Refactor analyze_pcap to remove congestion score placeholder and update return values for clarity
This commit is contained in:
parent
ff55e1746c
commit
4154578c4e
1 changed files with 3 additions and 10 deletions
13
enrich.py
13
enrich.py
|
@ -294,7 +294,6 @@ def analyze_pcap(pcapng_path, start_ts, end_ts, ap_bssid, ap_channel):
|
||||||
aps_on_channel = 0
|
aps_on_channel = 0
|
||||||
avg_ap_signal = 0
|
avg_ap_signal = 0
|
||||||
max_ap_signal = 0
|
max_ap_signal = 0
|
||||||
|
|
||||||
unlinked_devices = 0
|
unlinked_devices = 0
|
||||||
|
|
||||||
try:
|
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_ap = get_clients_on_ap(filtered_packets, ap_bssid)
|
||||||
clients_on_channel = get_clients_on_channel(filtered_packets, ap_channel, 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)
|
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)
|
avg_ap_signal, max_ap_signal = calculate_signal_strength_stats(filtered_packets, ap_channel)
|
||||||
|
|
||||||
unlinked_devices = get_unlinked_devices(filtered_packets, ap_channel)
|
unlinked_devices = get_unlinked_devices(filtered_packets, ap_channel)
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
cap.close()
|
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():
|
def main():
|
||||||
args = parse_args()
|
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:
|
with open(args.csv, newline='') as infile, open(args.output, 'w', newline='', encoding='utf-8') as outfile:
|
||||||
reader = csv.DictReader(infile)
|
reader = csv.DictReader(infile)
|
||||||
fieldnames = reader.fieldnames + [
|
fieldnames = reader.fieldnames + [
|
||||||
'ClientsOnAP', 'ClientsOnChannel', 'APsOnChannel', 'CongestionScore',
|
'ClientsOnAP', 'ClientsOnChannel', 'APsOnChannel',
|
||||||
'AvgAPSignal', 'StrongestAPSignal', 'UnlinkedDevices'
|
'AvgAPSignal', 'StrongestAPSignal', 'UnlinkedDevices'
|
||||||
]
|
]
|
||||||
writer = csv.DictWriter(outfile, fieldnames=fieldnames)
|
writer = csv.DictWriter(outfile, fieldnames=fieldnames)
|
||||||
|
@ -365,13 +359,12 @@ def main():
|
||||||
writer.writerow(row)
|
writer.writerow(row)
|
||||||
continue
|
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({
|
row.update({
|
||||||
'ClientsOnAP': clients_ap,
|
'ClientsOnAP': clients_ap,
|
||||||
'ClientsOnChannel': clients_chan,
|
'ClientsOnChannel': clients_chan,
|
||||||
'APsOnChannel': aps_chan,
|
'APsOnChannel': aps_chan,
|
||||||
'CongestionScore': congestion,
|
|
||||||
'AvgAPSignal': avg_signal,
|
'AvgAPSignal': avg_signal,
|
||||||
'StrongestAPSignal': strongest_signal,
|
'StrongestAPSignal': strongest_signal,
|
||||||
'UnlinkedDevices': unlinked
|
'UnlinkedDevices': unlinked
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue