ESP32/doc/THRESHOLD_QUICK_REF.md

130 lines
3.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# WiFi Monitor Threshold Tuning - Quick Reference
## GDB Commands
```gdb
# View current thresholds
show_thresholds
# Preset profiles
tune_sensitive # Catch more issues (stricter)
tune_normal # Default settings
tune_relaxed # Fewer false positives
# Individual thresholds
set_high_nav <us> # High NAV threshold (default: 5000)
set_mismatch_log <us> # Log when NAV exceeds (default: 10000)
set_rate_fallback <mbps> # Rate fallback threshold (default: 100)
set_multiplier <n> # Duration multiplier (default: 2)
set_log_rate <n> # Log every Nth mismatch (default: 1)
```
## Tunable Variables
| Variable | Default | Description |
|----------|---------|-------------|
| `threshold_high_nav_us` | 5000 | NAV above this = "high" |
| `threshold_duration_mismatch_us` | 10000 | Log mismatches above this NAV |
| `threshold_phy_rate_fallback_mbps` | 100 | PHY rate below this = fallback |
| `threshold_duration_multiplier` | 2 | NAV > expected × this = mismatch |
| `threshold_retry_rate_percent` | 20.0 | Retry % for collapse |
| `threshold_avg_nav_collapse_us` | 10000 | Avg NAV for collapse |
| `threshold_collision_percent` | 10.0 | Collision % for collapse |
| `threshold_mismatch_percent` | 5.0 | Mismatch % for collapse |
| `log_every_n_mismatches` | 1 | Log every Nth (1=all, 10=every 10th) |
## Quick Examples
### Too Much Logging
```gdb
(gdb) set_log_rate 10 # Log every 10th mismatch
(gdb) set_mismatch_log 20000 # Only log >20ms NAV
(gdb) continue
```
### Not Catching Issues
```gdb
(gdb) tune_sensitive # Use stricter thresholds
(gdb) continue
```
### 2.4GHz Network
```gdb
(gdb) tune_relaxed # More lenient
(gdb) set_rate_fallback 24 # 2.4GHz rates lower
(gdb) continue
```
### 5GHz High Performance
```gdb
(gdb) tune_sensitive
(gdb) set_rate_fallback 200 # Expect >200 Mbps
(gdb) continue
```
## Preset Profile Settings
| Threshold | Sensitive | Normal | Relaxed |
|-----------|-----------|--------|---------|
| High NAV | 3000 us | 5000 us | 10000 us |
| Mismatch log | 5000 us | 10000 us | 20000 us |
| Rate fallback | 150 Mbps | 100 Mbps | 50 Mbps |
| Multiplier | 1.5x | 2x | 3x |
| Retry rate | 15% | 20% | 30% |
## Installation
```bash
cd ~/Code/esp32/esp32-iperf
# Update files
cp wifi_monitor.c components/wifi_monitor/
cp .gdbinit .
# Build once
idf.py build
idf.py -p /dev/ttyACM0 flash
# Enable GDB auto-load (one-time)
mkdir -p ~/.config/gdb
echo "set auto-load safe-path /" >> ~/.config/gdb/gdbinit
```
## Typical Workflow
```gdb
# Start GDB
$ idf.py gdb
# Check defaults
(gdb) show_thresholds
# Start monitoring
(gdb) continue
# Adjust on the fly (Ctrl-C to pause)
(gdb) Ctrl-C
(gdb) set_log_rate 20
(gdb) continue
# Check effect, adjust again if needed
(gdb) Ctrl-C
(gdb) tune_sensitive
(gdb) continue
```
## Benefits
**No rebuild** - Adjust thresholds instantly
**Zero overhead** - Full C code performance
**Live tuning** - Change while running
**Experiment** - Try different settings easily
---
**For complete guide**: See GDB_THRESHOLD_TUNING_GUIDE.md