Add PLCP header counting to test_monitor_tshark.sh
- Add radiotap.present field to capture output - Count packets with PLCP headers (radiotap information) - Display PLCP count in both test capture and final summary - Show warning if no PLCP headers detected (may indicate wrong DLT) Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
5827518041
commit
a98a255147
|
|
@ -80,10 +80,16 @@ iw dev "$INTERFACE" info | grep -E "(type|channel)" || echo "Could not verify"
|
||||||
# Check DLT with tshark (capture for 1 second)
|
# Check DLT with tshark (capture for 1 second)
|
||||||
echo ""
|
echo ""
|
||||||
echo "Checking Data Link Type (1 second test capture)..."
|
echo "Checking Data Link Type (1 second test capture)..."
|
||||||
TEST_OUTPUT=$(timeout 1 tshark -i "$INTERFACE" -T fields -e frame.number 2>&1)
|
TEST_OUTPUT=$(timeout 1 tshark -i "$INTERFACE" -T fields -e frame.number -e radiotap.present 2>&1)
|
||||||
PACKET_COUNT=$(echo "$TEST_OUTPUT" | grep -E '^[0-9]+$' | wc -l || echo "0")
|
PACKET_COUNT=$(echo "$TEST_OUTPUT" | grep -E '^[0-9]+' | wc -l || echo "0")
|
||||||
|
PLCP_COUNT=$(echo "$TEST_OUTPUT" | grep -E '^[0-9]+.*[0-9]' | wc -l || echo "0")
|
||||||
echo "$TEST_OUTPUT" | tail -5 || true
|
echo "$TEST_OUTPUT" | tail -5 || true
|
||||||
echo "Captured $PACKET_COUNT packet(s) in 1 second"
|
echo "Captured $PACKET_COUNT packet(s) in 1 second"
|
||||||
|
if [ "$PLCP_COUNT" -gt 0 ]; then
|
||||||
|
echo "PLCP headers: $PLCP_COUNT (radiotap present)"
|
||||||
|
else
|
||||||
|
echo "PLCP headers: 0 (no radiotap headers detected)"
|
||||||
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "=== Starting tshark capture ($DURATION seconds) ==="
|
echo "=== Starting tshark capture ($DURATION seconds) ==="
|
||||||
|
|
@ -99,6 +105,7 @@ CAPTURE_OUTPUT=$(timeout "$DURATION" tshark -i "$INTERFACE" -n -T fields \
|
||||||
-e wlan.fc.type \
|
-e wlan.fc.type \
|
||||||
-e wlan.fc.subtype \
|
-e wlan.fc.subtype \
|
||||||
-e wlan.fc.type_subtype \
|
-e wlan.fc.type_subtype \
|
||||||
|
-e radiotap.present \
|
||||||
2>&1)
|
2>&1)
|
||||||
|
|
||||||
# Display first 50 lines of output
|
# Display first 50 lines of output
|
||||||
|
|
@ -107,12 +114,22 @@ echo "$CAPTURE_OUTPUT" | head -50
|
||||||
# Count total packets captured
|
# Count total packets captured
|
||||||
FINAL_COUNT=$(echo "$CAPTURE_OUTPUT" | grep -E '^[0-9]+' | wc -l || echo "0")
|
FINAL_COUNT=$(echo "$CAPTURE_OUTPUT" | grep -E '^[0-9]+' | wc -l || echo "0")
|
||||||
|
|
||||||
|
# Count packets with PLCP headers (radiotap present)
|
||||||
|
# radiotap.present field is the 8th field (after frame.number, frame.time, wlan.sa, wlan.da, wlan.fc.type, wlan.fc.subtype, wlan.fc.type_subtype)
|
||||||
|
PLCP_COUNT=$(echo "$CAPTURE_OUTPUT" | awk -F'\t' 'NF >= 8 && $8 != "" && $8 != "0" && $8 != "-" {count++} END {print count+0}' || echo "0")
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "=== Capture complete ==="
|
echo "=== Capture complete ==="
|
||||||
echo "Total packets captured: $FINAL_COUNT"
|
echo "Total packets captured: $FINAL_COUNT"
|
||||||
|
echo "PLCP headers: $PLCP_COUNT"
|
||||||
echo ""
|
echo ""
|
||||||
if [ "$FINAL_COUNT" -gt 0 ]; then
|
if [ "$FINAL_COUNT" -gt 0 ]; then
|
||||||
echo "✓ Monitor mode is working! Captured $FINAL_COUNT packet(s)"
|
echo "✓ Monitor mode is working! Captured $FINAL_COUNT packet(s)"
|
||||||
|
if [ "$PLCP_COUNT" -gt 0 ]; then
|
||||||
|
echo "✓ PLCP headers detected: $PLCP_COUNT packet(s) with radiotap information"
|
||||||
|
else
|
||||||
|
echo "⚠ No PLCP headers detected (may be using DLT_IEEE802_11 instead of DLT_IEEE802_11_RADIO)"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "✗ No packets captured. Check:"
|
echo "✗ No packets captured. Check:"
|
||||||
echo " 1. Is there WiFi traffic on channel $CHANNEL?"
|
echo " 1. Is there WiFi traffic on channel $CHANNEL?"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue