Compare commits

..

No commits in common. "b80a9d818b602ec0aff5a271078d930efe10c90d" and "a98a255147cf2cff662f7e31343f0e792adb8a85" have entirely different histories.

1 changed files with 13 additions and 46 deletions

View File

@ -80,35 +80,15 @@ iw dev "$INTERFACE" info | grep -E "(type|channel)" || echo "Could not verify"
# Check DLT with tshark (capture for 1 second)
echo ""
echo "Checking Data Link Type (1 second test capture)..."
echo "(This may take up to 2 seconds if no packets are present)"
# Use timeout with -c to limit packets and avoid hanging
# Capture both stdout and stderr
TEST_OUTPUT=$(timeout 2 tshark -i "$INTERFACE" -c 100 -T fields -e frame.number -e radiotap.present 2>&1 || true)
TEST_EXIT_CODE=${PIPESTATUS[0]}
# Show any warnings/errors from tshark (but not packet data)
echo "$TEST_OUTPUT" | grep -E "(Running as|tshark:|Warning|Error|Capturing)" || true
# Count packets (lines starting with a number, excluding error messages)
PACKET_LINES=$(echo "$TEST_OUTPUT" | grep -E '^[0-9]+' || true)
PACKET_COUNT=$(echo "$PACKET_LINES" | wc -l || echo "0")
# Count lines with both frame.number and radiotap.present (non-empty second field)
PLCP_COUNT=$(echo "$PACKET_LINES" | awk -F'\t' 'NF >= 2 && $1 != "" && $2 != "" && $2 != "0" && $2 != "-" {count++} END {print count+0}' || echo "0")
# Show sample output
if [ "$PACKET_COUNT" -gt 0 ]; then
echo "Sample packets:"
echo "$PACKET_LINES" | head -3
fi
echo ""
echo "Test capture results:"
echo " Packets captured: $PACKET_COUNT"
echo " PLCP headers: $PLCP_COUNT"
if [ "$PLCP_COUNT" -eq 0 ] && [ "$PACKET_COUNT" -gt 0 ]; then
echo " Note: Packets captured but no radiotap headers (may be using DLT_IEEE802_11 instead of DLT_IEEE802_11_RADIO)"
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")
PLCP_COUNT=$(echo "$TEST_OUTPUT" | grep -E '^[0-9]+.*[0-9]' | wc -l || echo "0")
echo "$TEST_OUTPUT" | tail -5 || true
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 ""
@ -117,7 +97,6 @@ echo "Press Ctrl+C to stop early"
echo ""
# Capture for specified duration and count packets
echo "Capturing packets for $DURATION seconds..."
CAPTURE_OUTPUT=$(timeout "$DURATION" tshark -i "$INTERFACE" -n -T fields \
-e frame.number \
-e frame.time \
@ -128,28 +107,16 @@ CAPTURE_OUTPUT=$(timeout "$DURATION" tshark -i "$INTERFACE" -n -T fields \
-e wlan.fc.type_subtype \
-e radiotap.present \
2>&1)
CAPTURE_EXIT_CODE=$?
# Show any warnings/errors
echo "$CAPTURE_OUTPUT" | grep -E "(tshark:|Warning|Error)" | head -5 || true
# Display first 50 lines of output
echo "$CAPTURE_OUTPUT" | head -50
# Display first 50 lines of packet output
PACKET_LINES=$(echo "$CAPTURE_OUTPUT" | grep -E '^[0-9]+' || true)
if [ -n "$PACKET_LINES" ]; then
echo ""
echo "Sample packets (first 20):"
echo "$PACKET_LINES" | head -20
else
echo ""
echo "(No packets captured)"
fi
# Count total packets captured (lines starting with a number)
# Count total packets captured
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 && $1 != "" && $8 != "" && $8 != "0" && $8 != "-" {count++} END {print count+0}' || echo "0")
PLCP_COUNT=$(echo "$CAPTURE_OUTPUT" | awk -F'\t' 'NF >= 8 && $8 != "" && $8 != "0" && $8 != "-" {count++} END {print count+0}' || echo "0")
echo ""
echo "=== Capture complete ==="