From 8c9487984ad3f3056c4e8823ee1d873c01988a09 Mon Sep 17 00:00:00 2001 From: Robert McMahon Date: Fri, 13 Feb 2026 14:37:41 -0800 Subject: [PATCH] Fix regression: use temp file for tshark output parsing - Write tshark output to temp file first to avoid pipe issues - Redirect stderr to /dev/null to suppress field errors - Filter to only keep lines starting with frame numbers - This should fix the issue where only 1 packet was parsed instead of 217 Co-authored-by: Cursor --- test_monitor_tshark.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test_monitor_tshark.sh b/test_monitor_tshark.sh index ff09336..efe77f4 100755 --- a/test_monitor_tshark.sh +++ b/test_monitor_tshark.sh @@ -196,11 +196,9 @@ fi # Now parse the pcap file to extract fields # Only extract 802.11 header fields - data payloads are encrypted # Include PHY rate and MCS for histograms -# Note: Some fields may not exist for all frames - tshark will output empty values -CAPTURE_OUTPUT=$(tshark -q -r "$TEMP_PCAP" -n -T fields \ - -E occurrence=f \ - -E separator='\t' \ - -E header=n \ +# Extract to temp file first to avoid pipe issues, then filter +TEMP_TSHARK_OUTPUT=$(mktemp /tmp/tshark_output_XXXXXX.txt) +tshark -q -r "$TEMP_PCAP" -n -T fields \ -e frame.number \ -e frame.time \ -e wlan.ra \ @@ -216,7 +214,11 @@ CAPTURE_OUTPUT=$(tshark -q -r "$TEMP_PCAP" -n -T fields \ -e radiotap.mcs.index \ -e wlan_radio.data_rate \ -e wlan_radio.mcs.index \ - 2>&1 | grep -E '^[0-9]' | head -1000000 || true) + 2>/dev/null > "$TEMP_TSHARK_OUTPUT" || true + +# Filter out non-packet lines (keep only lines starting with frame numbers) +CAPTURE_OUTPUT=$(grep -E '^[0-9]+\t' "$TEMP_TSHARK_OUTPUT" || true) +rm -f "$TEMP_TSHARK_OUTPUT" # Clean up temp file (unless KEEP_PCAP is set) if [ -z "$KEEP_PCAP" ]; then