Rename calculate_avg_ap_signal_strength to calculate_signal_strength_stats and update return values to include max signal strength
This commit is contained in:
parent
5c87c2dc43
commit
45bba2e988
1 changed files with 9 additions and 3 deletions
12
enrich.py
12
enrich.py
|
@ -198,7 +198,7 @@ def get_aps_on_channel(capture, ap_channel):
|
|||
|
||||
return len(aps)
|
||||
|
||||
def calculate_avg_ap_signal_strength(capture, ap_channel):
|
||||
def calculate_signal_strength_stats(capture, ap_channel):
|
||||
try:
|
||||
ap_channel = int(ap_channel)
|
||||
except ValueError:
|
||||
|
@ -241,6 +241,11 @@ def calculate_avg_ap_signal_strength(capture, ap_channel):
|
|||
print(f"[DEBUG] Signal strength parse error: {e}")
|
||||
continue
|
||||
|
||||
if ap_signals:
|
||||
return mean(ap_signals), max(ap_signals)
|
||||
else:
|
||||
return 0, 0
|
||||
|
||||
def analyze_pcap(pcapng_path, start_ts, end_ts, ap_bssid, ap_channel):
|
||||
cap = pyshark.FileCapture(
|
||||
pcapng_path,
|
||||
|
@ -254,6 +259,7 @@ def analyze_pcap(pcapng_path, start_ts, end_ts, ap_bssid, ap_channel):
|
|||
clients_on_channel = 0
|
||||
aps_on_channel = 0
|
||||
avg_ap_signal = 0
|
||||
max_ap_signal = 0
|
||||
|
||||
try:
|
||||
# Filter packets manually by timestamp
|
||||
|
@ -274,7 +280,7 @@ def analyze_pcap(pcapng_path, start_ts, end_ts, ap_bssid, ap_channel):
|
|||
# - CongestionScore
|
||||
# - AvgAPSignal
|
||||
|
||||
avg_ap_signal = calculate_avg_ap_signal_strength(filtered_packets, ap_channel)
|
||||
avg_ap_signal, max_ap_signal = calculate_signal_strength_stats(filtered_packets, ap_channel)
|
||||
|
||||
# - StrongestAPSignal
|
||||
# - UnlinkedDevices
|
||||
|
@ -282,7 +288,7 @@ def analyze_pcap(pcapng_path, start_ts, end_ts, ap_bssid, ap_channel):
|
|||
finally:
|
||||
cap.close()
|
||||
|
||||
return clients_on_ap, clients_on_channel, aps_on_channel, None, None, None, 0
|
||||
return clients_on_ap, clients_on_channel, aps_on_channel, avg_ap_signal, max_ap_signal, None, 0
|
||||
|
||||
|
||||
def main():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue