| name | cospas-sarsat-codec |
| description | Encode and decode COSPAS-SARSAT 406 MHz emergency beacon signals in audio WAV format. Supports EPIRB (maritime), ELT (aviation), and PLB (personal) distress beacons used in the international satellite search-and-rescue system. Encodes beacon registration, identification, position, and protocol type into BPSK- modulated audio. Decodes WAV recordings to extract beacon information. Use this skill whenever the user mentions COSPAS-SARSAT, EPIRB, ELT, PLB, 406 MHz beacon, distress beacon, emergency beacon, SAR beacon, LEOSAR, MEOSAR, or wants to create/analyze emergency beacon WAV files.
|
COSPAS-SARSAT 406 MHz Beacon Codec
Comprehensive codec for encoding and decoding emergency distress beacons used in the international search-and-rescue system.
What is COSPAS-SARSAT?
COSPAS-SARSAT is the satellite-based search and rescue system operated by an international consortium. When an emergency beacon is activated:
- The beacon transmits on 406.028 MHz (~0.5 second burst every 50 seconds)
- LEOSAR (low-earth orbit) and MEOSAR (medium-earth orbit) satellites detect the signal
- Satellites relay the signal to ground stations (LUTs — Local User Terminals)
- Rescue coordination centers decode the beacon information and dispatch help
Three types of beacons transmit on this frequency:
- EPIRB — Emergency Position Indicating Radio Beacon (maritime vessels)
- ELT — Emergency Locator Transmitter (aircraft)
- PLB — Personal Locator Beacon (land, personal use)
Signal Format
Transmission characteristics:
- Carrier frequency: 406.028 MHz
- Modulation: Phase modulation (effectively BPSK — binary phase shift keying)
- Data rate: 400 bits per second (2.5 ms per bit)
- Message length: 112 bits (short, no position) or 144 bits (long, with position)
- Burst duration: ~0.52 seconds
- Repetition: Every ~50 seconds until rescue or manual deactivation
Audio baseband representation (for SDR processing):
- Use 1000 Hz carrier frequency (instead of 406 MHz) in audio domain
- BPSK modulation: phase reversal (180°) encodes bit=1; no phase shift encodes bit=0
- Sample rate: 44100 Hz recommended (or 48 kHz)
- Output: WAV format (mono, 16-bit signed)
Message Structure
All beacon messages follow this 15-bit to 144-bit structure:
Fixed Preamble
- Bits 0-14 (15 bits): Bit synchronization pattern
000101111101100 — optimized for autocorrelation detection
- Bits 15-23 (9 bits): Frame synchronization
011010000 — identifies normal message (not self-test)
Message Type and Format
- Bit 24 (1 bit): Format flag — 0 = short message (112 bits), 1 = long message (144 bits)
- Bit 25 (1 bit): Protocol flag — 0 = user protocol, 1 = location protocol (with position)
Registration and Type
- Bits 26-35 (10 bits): Country code (ITU Maritime Identification Digits)
- Example: 338 = USA, 226 = France, 412 = Japan
- Bits 36-39 (4 bits): Protocol code — identifies beacon type:
0010 = Maritime EPIRB (user protocol) or Standard Location EPIRB
0011 = Standard Location ELT (aviation)
0100 = Standard Location PLB (personal) or Serial user protocol
0110 = Aviation ELT (user protocol) with ICAO address
1110 / 1100 = Test beacons
Beacon Identification (46-50 bits, content varies by type)
Maritime EPIRB (user protocol):
- 30-bit MMSI (Maritime Mobile Service Identity) — unique ship identifier
- 16 spare bits
Aviation ELT (user protocol):
- 24-bit ICAO aircraft address — unique aircraft identifier
- 22 spare bits
Personal Locator Beacon (PLB):
- 20-bit serial number or similar identifier
- 26 spare bits
Position Data (long format only, bits 86-132)
Coarse Position (20 bits):
- Latitude: 1 sign bit (0=North, 1=South) + 7 bits for degrees (0-90) + 2 bits for quarter-degrees
- Longitude: 1 sign bit (0=East, 1=West) + 8 bits for degrees (0-180) + 1 bit for half-degree
- Precision: ~0.25° (roughly 25 km)
Fine Position Offset (25 bits, optional):
- Supplementary latitude refinement (10 bits)
- Supplementary longitude refinement (10 bits)
- Additional identification or auxiliary data (5 bits)
Error Correction
Primary BCH Code (bits 26-85, 60 data bits):
- 21 parity bits (bits 86-106) protect the registration and identification fields
- Uses BCH(82,61) code — can correct up to 6-bit errors
- Generator polynomial: x^21 + x^19 + x^18 + x^17 + x^16 + x^15 + x^14 + x^10 + x^9 + x^8 + x^6 + x^5 + x^2 + x + 1
Secondary BCH Code (optional, long format):
- 12 parity bits protect the supplementary position data
How to Use This Codec
Encoding (Beacon Data → WAV File)
Create an audio WAV file containing an encoded beacon signal:
python3 sarsat_encode.py output.wav \
--country 338 \
--type epirb \
--mmsi 311000001 \
--lat 40.7 \
--lon -74.0 \
--long-format
Options:
--country CODE — 3-digit ITU country code (default: 338 = USA)
--type {epirb,elt,plb,test} — Beacon type (default: epirb)
--mmsi NNNNNNNNN — MMSI number for maritime beacons
--icao NNNNNN — ICAO hex address for aviation (e.g., A0B1C2)
--serial NNNN — Serial number for PLB/serial protocol
--lat DD.DDDD — Latitude (positive=North, negative=South)
--lon DD.DDDD — Longitude (positive=East, negative=West)
--long-format — Use 144-bit format with position (default)
--short-format — Use 112-bit format without position
--bursts N — Number of beacon bursts (default: 1)
--burst-interval N — Seconds between bursts (default: 50)
Decoding (WAV File → Beacon Information)
Extract beacon information from an audio WAV recording:
python3 sarsat_decode.py input.wav output.txt -v
Output includes:
- Beacon hex ID (15 hexadecimal digits used by SAR authorities)
- Country of registration
- Beacon type (EPIRB/ELT/PLB/test)
- Identification (MMSI, ICAO address, or serial number)
- Position if encoded
- BCH error correction status (valid/corrected/error)
Testing
Run the comprehensive test suite to verify correct implementation:
python3 sarsat_test.py
Tests cover:
- BPSK modulation/demodulation
- BCH error correction (encoding/decoding)
- Position encoding/decoding
- Message building (short/long formats)
- Message parsing
- Beacon type handling
- Country code lookup
- Sync pattern detection
- Full WAV encode/decode roundtrips
- Multi-burst recordings
Common Country Codes
| Code | Country | Code | Country |
|---|
| 201-299 | Europe | 301-399 | Americas |
| 226 | France | 303 | Canada |
| 230 | Finland | 338 | USA |
| 211 | Germany | 244 | Netherlands |
| 412 | Japan | 501 | Australia |
| 431 | China | 636 | South Africa |
File Structure
cospas-sarsat/
├── SKILL.md # This documentation
├── README.md # Extended usage guide
├── scripts/
│ ├── sarsat_common.py # Core codec library
│ ├── sarsat_encode.py # Beacon encoder CLI
│ ├── sarsat_decode.py # Beacon decoder CLI
│ └── sarsat_test.py # Comprehensive test suite
└── examples/
├── maritime_epirb.sh # Example: encode maritime EPIRB
├── aviation_elt.sh # Example: encode aviation ELT
└── plb_with_position.sh # Example: encode PLB with coordinates
Technical Notes for SDR Use
Recording beacon signals:
- Tune SDR to 406.028 MHz
- Use 200 kHz+ bandwidth (BPSK is narrow)
- Record as WAV (mono, 48 kHz or higher)
- Decode with
sarsat_decode.py
Generating test signals:
- Use
sarsat_encode.py to create synthetic beacon WAV files
- Useful for testing decoder workflows without actual beacons
- Can simulate multiple bursts for realistic recordings
Real-world beacon activation:
- Never activate emergency beacons unless in genuine distress
- Emergency beacon networks actively monitor 406 MHz
- False alarms trigger expensive search operations
- Penalties can include fines and legal liability
References
- COSPAS-SARSAT System: https://www.cospas-sarsat.int/
- 406 MHz Beacon Technical Standards: IMO, ICAO, and ITU specifications
- LEOSAR and MEOSAR satellite coverage
- Local User Terminal (LUT) networks worldwide