{"id":42821535,"url":"https://github.com/ktauchathuranga/adsb","last_synced_at":"2026-01-30T06:57:55.861Z","repository":{"id":333813509,"uuid":"1131016081","full_name":"ktauchathuranga/adsb","owner":"ktauchathuranga","description":"Mode S / ADS-B decoder for RTL-SDR and HackRF One. Track aircraft in real-time.","archived":false,"fork":false,"pushed_at":"2026-01-24T11:14:21.000Z","size":824,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-29T21:35:21.087Z","etag":null,"topics":["1090mhz","adsb","aircraft-tracking","hackrf","mode-s","rtl-sdr","sdr"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ktauchathuranga.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"ktauchathuranga"}},"created_at":"2026-01-09T10:50:29.000Z","updated_at":"2026-01-24T22:30:48.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ktauchathuranga/adsb","commit_stats":null,"previous_names":["ktauchathuranga/adsb"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/ktauchathuranga/adsb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktauchathuranga%2Fadsb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktauchathuranga%2Fadsb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktauchathuranga%2Fadsb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktauchathuranga%2Fadsb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ktauchathuranga","download_url":"https://codeload.github.com/ktauchathuranga/adsb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktauchathuranga%2Fadsb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28907069,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T06:42:00.998Z","status":"ssl_error","status_checked_at":"2026-01-30T06:41:58.659Z","response_time":66,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["1090mhz","adsb","aircraft-tracking","hackrf","mode-s","rtl-sdr","sdr"],"created_at":"2026-01-30T06:57:55.145Z","updated_at":"2026-01-30T06:57:55.854Z","avatar_url":"https://github.com/ktauchathuranga.png","language":"Rust","funding_links":["https://github.com/sponsors/ktauchathuranga"],"categories":[],"sub_categories":[],"readme":"# ADS-B Decoder\n\nA complete Rust implementation of a Mode S / ADS-B decoder for **RTL-SDR** and **HackRF One** devices. This project is a faithful port of the popular [dump1090](https://github.com/antirez/dump1090) with additional features and improvements.\n\n[![Rust](https://img.shields.io/badge/rust-1.70%2B-orange.svg)](https://www.rust-lang.org/)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n[![RTL-SDR](https://img.shields.io/badge/RTL--SDR-supported-green.svg)]()\n[![HackRF](https://img.shields.io/badge/HackRF-supported-green.svg)]()\n\n![ADS-B Decoder Screenshot](screenshots/a.png)\n\n## Table of Contents\n\n- [Overview](#overview)\n- [Features](#features)\n- [Installation](#installation)\n- [Usage](#usage)\n- [ADS-B Protocol Deep Dive](#ads-b-protocol-deep-dive)\n  - [What is ADS-B?](#what-is-ads-b)\n  - [Radio Frequency Characteristics](#radio-frequency-characteristics)\n  - [Mode S Overview](#mode-s-overview)\n  - [Signal Structure](#signal-structure)\n  - [Message Structure](#message-structure)\n  - [Downlink Formats (DF)](#downlink-formats-df)\n  - [CRC and Error Detection](#crc-and-error-detection)\n  - [ICAO Address Recovery](#icao-address-recovery)\n  - [Extended Squitter (ADS-B)](#extended-squitter-ads-b)\n  - [Position Encoding (CPR)](#position-encoding-cpr)\n  - [Altitude Encoding](#altitude-encoding)\n  - [Velocity Encoding](#velocity-encoding)\n  - [Aircraft Identification](#aircraft-identification)\n  - [BDS (Comm-B Data Selector)](#bds-comm-b-data-selector)\n- [Architecture](#architecture)\n- [Network Services](#network-services)\n- [Contributing](#contributing)\n- [References](#references)\n- [License](#license)\n\n---\n\n## Overview\n\nADS-B (Automatic Dependent Surveillance-Broadcast) is a surveillance technology where aircraft broadcast their position, altitude, speed, and identification. This project decodes these transmissions using inexpensive SDR devices like **RTL-SDR** or **HackRF One**. \n\n```\n┌─────────────┐     1090 MHz      ┌─────────────┐     USB      ┌─────────────┐\n│  Aircraft   │ ───────────────►  │  RTL-SDR    │ ──────────►  │    adsb     │\n│  Transponder│    RF Signal      │  Dongle     │   I/Q Data   │             │\n└─────────────┘                   └─────────────┘              └─────────────┘\n                                                                     │\n                                                                     ▼\n                                                         ┌─────────────────────┐\n                                                         │ • Aircraft Position │\n                                                         │ • Altitude          │\n                                                         │ • Speed \u0026 Heading   │\n                                                         │ • Flight Number     │\n                                                         │ • ICAO Address      │\n                                                         └─────────────────────┘\n```\n\n## Features\n\n- **Complete Mode S Decoding**: Supports all major Downlink Formats (DF0, DF4, DF5, DF11, DF16, DF17, DF20, DF21)\n- **ADS-B Extended Squitter**: Full DF17 message decoding including position, velocity, and identification\n- **CPR Position Decoding**: Compact Position Reporting with global and local decoding\n- **Error Correction**: Single-bit and two-bit error correction using CRC syndrome\n- **Ghost Aircraft Filtering**: Persistent ICAO tracking with minimum message threshold to eliminate phantom aircraft\n- **BDS Decoding**: Comm-B Data Selector registers (BDS 1,0 through 6,0) with CLI display of IAS, Mach, vertical rate\n- **Emergency Squawk Alerts**: Color-coded highlighting for 7500 (hijack), 7600 (radio failure), 7700 (emergency)\n- **Distance \u0026 Bearing**: Calculate distance and bearing from your receiver position to aircraft\n- **Multiple Input Sources**: RTL-SDR devices, file input, network input\n- **Network Output**: Raw, SBS/BaseStation, and HTTP/JSON formats\n- **Interactive Display**: Real-time terminal display with BDS data, color-coded alerts, and position info\n- **Web Interface**: Browser-based aircraft map visualization\n\n## Installation\n\n### Prerequisites\n\n```bash\n# Fedora/RHEL - RTL-SDR\nsudo dnf install rtl-sdr rtl-sdr-devel\n\n# Fedora/RHEL - HackRF\nsudo dnf install hackrf\n\n# Ubuntu/Debian - RTL-SDR\nsudo apt install rtl-sdr librtlsdr-dev\n\n# Ubuntu/Debian - HackRF\nsudo apt install hackrf\n\n# macOS\nbrew install librtlsdr hackrf\n```\n\n### Building\n\n```bash\ngit clone https://github.com/ktauchathuranga/adsb.git\ncd adsb\ncargo build --release\n```\n\n### Running\n\n```bash\n# Live reception from RTL-SDR (default)\n./target/release/adsb --interactive\n\n# Live reception from HackRF One\n./target/release/adsb --hackrf --interactive\n\n# From a recorded file\n./target/release/adsb --ifile recording.bin --interactive\n\n# With network output\n./target/release/adsb --net --interactive\n\n# With your receiver position (shows distance/bearing to aircraft)\n./target/release/adsb --interactive --lat 6.9271 --lon 79.8612\n\n# Stricter ghost filtering (require 3+ messages before showing aircraft)\n./target/release/adsb --interactive --min-messages 3\n```\n\n## Usage\n\n```\nadsb - Mode S decoder for RTL-SDR devices\n\nUSAGE:\n    adsb [OPTIONS]\n\nOPTIONS:\n    --device-index \u003cN\u003e     Select RTL device (default: 0)\n    --gain \u003cdb\u003e            Set gain (default: max. Use -10 for auto-gain)\n    --enable-agc           Enable Automatic Gain Control\n    --freq \u003chz\u003e            Set frequency (default: 1090 MHz)\n    --ifile \u003cfilename\u003e     Read data from file (use '-' for stdin)\n    --loop                 With --ifile, read the same file in a loop\n    --interactive          Interactive mode refreshing data on screen\n    --interactive-rows \u003cN\u003e Max rows in interactive mode (default: 15)\n    --interactive-ttl \u003cs\u003e  Remove aircraft if idle for \u003cs\u003e seconds (default: 60)\n    --min-messages \u003cN\u003e     Minimum messages before showing aircraft (default: 2)\n    --lat \u003cdegrees\u003e        Receiver latitude for distance/bearing calculation\n    --lon \u003cdegrees\u003e        Receiver longitude for distance/bearing calculation\n    --raw                  Show only messages hex values\n    --net                  Enable networking\n    --net-only             Enable just networking, no RTL device\n    --net-ro-port \u003cport\u003e   TCP port for raw output (default: 30002)\n    --net-ri-port \u003cport\u003e   TCP port for raw input (default: 30001)\n    --net-http-port \u003cport\u003e HTTP server port (default: 8080)\n    --net-sbs-port \u003cport\u003e  TCP port for SBS output (default: 30003)\n    --no-fix               Disable single-bit error correction\n    --no-crc-check         Disable CRC check\n    --aggressive           More CPU for more messages (two-bit error correction)\n    --metric               Use metric units - meters, km/h (default)\n    --imperial             Use imperial units - feet, knots\n    --help                 Show help\n```\n\n---\n\n# ADS-B Protocol Deep Dive\n\n## What is ADS-B?\n\n**ADS-B** stands for **Automatic Dependent Surveillance-Broadcast**: \n\n| Term | Meaning |\n|------|---------|\n| **Automatic** | No pilot or external input required |\n| **Dependent** | Depends on aircraft navigation systems (GPS) |\n| **Surveillance** | Provides aircraft surveillance data |\n| **Broadcast** | Transmitted to all receivers in range |\n\nADS-B is part of the **Mode S** (Mode Select) transponder system, which is an evolution of the older Mode A/C systems used for air traffic control.\n\n### ADS-B vs Traditional Radar\n\n```\nTraditional Radar (Primary + Secondary):\n┌─────────┐  Interrogation  ┌──────────┐\n│  Radar  │ ──────────────► │ Aircraft │\n│ Station │ ◄────────────── │          │\n└─────────┘     Reply       └──────────┘\n   (Active interrogation required)\n\nADS-B: \n┌──────────┐     Broadcast      ┌──────────────┐\n│ Aircraft │ ──────────────────►│ Any Receiver │\n└──────────┘  (No interrogation)└──────────────┘\n   (Continuous autonomous broadcast)\n```\n\n## Radio Frequency Characteristics\n\n### Frequency and Modulation\n\n| Parameter | Value |\n|-----------|-------|\n| **Frequency** | 1090 MHz (1090ES - Extended Squitter) |\n| **Modulation** | PPM (Pulse Position Modulation) |\n| **Data Rate** | 1 Mbit/s |\n| **Pulse Width** | 0.5 µs |\n| **Bit Period** | 1.0 µs |\n| **Transmission Power** | 125-500 Watts (aircraft) |\n| **Range** | Up to 250+ nautical miles (line of sight) |\n\n### Signal Characteristics\n\n```\nFrequency Spectrum:\n                    │\n        Amplitude   │      ████\n                    │    ██    ██\n                    │  ██        ██\n                    │ █            █\n                    │█              █\n                    ├───────────────────► Frequency\n                   1089    1090    1091 MHz\n                              Center Freq\n```\n\n## Mode S Overview\n\nMode S is a secondary surveillance radar (SSR) system that supports:\n\n1. **Selective Addressing**: Each aircraft has a unique 24-bit ICAO address\n2. **Data Link**:  Two-way communication between ground and aircraft\n3. **Extended Squitter**: Autonomous broadcasts (ADS-B)\n\n### Mode S Message Types\n\n```\nMode S Transponder Capabilities: \n┌─────────────────────────────────────────────────────────────┐\n│                      Mode S Transponder                     │\n├─────────────────────┬───────────────────────────────────────┤\n│   Short Messages    │         Long Messages                 │\n│   (56 bits)         │         (112 bits)                    │\n├─────────────────────┼───────────────────────────────────────┤\n│ • DF0  (ACAS)       │ • DF16 (Long ACAS)                    │\n│ • DF4  (Altitude)   │ • DF17 (Extended Squitter/ADS-B)      │\n│ • DF5  (Identity)   │ • DF18 (Extended Squitter/TIS-B)      │\n│ • DF11 (All-Call)   │ • DF20 (Comm-B Altitude)              │\n│                     │ • DF21 (Comm-B Identity)              │\n│                     │ • DF24 (Comm-D ELM)                   │\n└─────────────────────┴───────────────────────────────────────┘\n```\n\n## Signal Structure\n\n### Preamble\n\nEvery Mode S message begins with an **8 microsecond preamble** consisting of four pulses:\n\n```\nPreamble (8 µs):\n     ▲\n   1 │    █   █         █   █\n     │    █   █         █   █\n     │    █   █         █   █\n   0 └──────────────────────────────────►\n          0   1   2   3   4   5   6   7 µs\n          │   │         │   │\n          └───┴─────────┴───┘\n      Pulse positions: 0, 1, 3.5, 4.5 µs\n```\n\n**Preamble Pattern (at 2 MHz sampling = 16 samples):**\n\n| Sample | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10| 11| 12| 13| 14| 15|\n|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|\n| Level  | H | L | H | L | L | L | L | H | L | H | L | L | L | L | L | L |\n\n### Data Bits (PPM Encoding)\n\nEach data bit occupies **1 microsecond** and uses Pulse Position Modulation: \n\n```\nBit = 1:                    Bit = 0:\n    ▲                           ▲\n  1 │██▌                      1 │   ██▌\n    │██▌                        │   ██▌\n  0 │   ███                   0 │█████▌\n    └──────► t                  └──────► t\n    0   0.5  1 µs               0  0.5  1 µs\n    \n    HIGH then LOW              LOW then HIGH\n```\n\nAt 2 MHz sampling rate: \n- **Bit '1'**: First sample HIGH, second sample LOW\n- **Bit '0'**: First sample LOW, second sample HIGH\n\n### Complete Message Structure\n\n```\nShort Message (56 bits = 56 µs data):\n├──────────┼────────────────────────────────────────────────────┤\n│ Preamble │                    Data (56 bits)                  │\n│  8 µs    │                       56 µs                        │\n├──────────┼────────────────────────────────────────────────────┤\n                            Total: 64 µs\n\nLong Message (112 bits = 112 µs data):\n├──────────┼────────────────────────────────────────────────────────────────────────────┤\n│ Preamble │                              Data (112 bits)                               │\n│  8 µs    │                                 112 µs                                     │\n├──────────┼────────────────────────────────────────────────────────────────────────────┤\n                                      Total: 120 µs\n```\n\n## Message Structure\n\n### Short Message Format (56 bits)\n\n```\n DF      Other Fields                               Parity/ICAO\n├──┼──────────────────────────────────────────────┼────────────┤\n│5 │                    27 bits                   │   24 bits  │\n├──┼──────────────────────────────────────────────┼────────────┤\n└──┴──────────────────────────────────────────────┴────────────┘\n  Bit 1-5:  Downlink Format\n  Bit 6-32: Message content (depends on DF)\n  Bit 33-56: Parity (PI) or ICAO address XOR parity\n```\n\n### Long Message Format (112 bits)\n\n```\n DF  CA        ICAO            ME (Message/Extended Squitter)        PI\n├──┼──┼──────────────┼────────────────────────────────────────┼────────────┤\n│5 │3 │    24 bits   │               56 bits                  │  24 bits   │\n├──┼──┼──────────────┼────────────────────────────────────────┼────────────┤\n└──┴──┴──────────────┴────────────────────────────────────────┴────────────┘\n  Bit 1-5:    Downlink Format (DF)\n  Bit 6-8:   Capability (CA)\n  Bit 9-32:  ICAO Aircraft Address (AA)\n  Bit 33-88:  Message Extended (ME) / Comm-B Message (MB)\n  Bit 89-112: Parity/Interrogator ID (PI)\n```\n\n### Byte Layout\n\n```\nLong Message (14 bytes):\nByte:    │  0  │  1  │  2  │  3  │  4  │  5  │  6  │  7  │  8  │  9  │ 10  │ 11  │ 12  │ 13  │\n         ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤\nContent: │DF+CA│────── ICAO ─────│─────────────── ME (56 bits) ──────────────────│──── PI ───│\n         │     │ AA1 │ AA2 │ AA3 │     │     │     │     │     │     │     │     │     │     │\n\nShort Message (7 bytes):\nByte:    │  0  │  1  │  2  │  3  │  4  │  5  │  6  │\n         ├─────┼─────┼─────┼─────┼─────┼─────┼─────┤\nContent: │DF+  │──── Message ────│──── PI/ICAO ────│\n         │     │                 │                 │\n```\n\n## Downlink Formats (DF)\n\n### Overview\n\n| DF | Name | Bits | Description | ICAO Location |\n|----|------|------|-------------|---------------|\n| 0 | Short Air-Air Surveillance (ACAS) | 56 | TCAS/ACAS coordination | In PI (XOR) |\n| 4 | Surveillance Altitude Reply | 56 | Response to altitude interrogation | In PI (XOR) |\n| 5 | Surveillance Identity Reply | 56 | Response to identity interrogation | In PI (XOR) |\n| 11 | All-Call Reply | 56 | Response to all-call interrogation | In message |\n| 16 | Long Air-Air Surveillance (ACAS) | 112 | Extended TCAS/ACAS | In PI (XOR) |\n| 17 | Extended Squitter (ADS-B) | 112 | Automatic broadcast | In message |\n| 18 | Extended Squitter (TIS-B/ADS-R) | 112 | Ground/rebroadcast | In message |\n| 19 | Military Extended Squitter | 112 | Military use | In message |\n| 20 | Comm-B Altitude Reply | 112 | Altitude with Comm-B data | In PI (XOR) |\n| 21 | Comm-B Identity Reply | 112 | Identity with Comm-B data | In PI (XOR) |\n| 24 | Comm-D (ELM) | 112 | Extended Length Message | In PI (XOR) |\n\n### DF11:  All-Call Reply\n\nSent in response to all-call interrogations.  Contains the aircraft's ICAO address directly.\n\n```\nDF11 Structure (56 bits):\n┌─────────┬─────┬────────────────────────┬────────────────────────┐\n│  DF=11  │ CA  │      ICAO Address      │       PI (Parity)      │\n│ 5 bits  │3 bit│       24 bits          │        24 bits         │\n└─────────┴─────┴────────────────────────┴────────────────────────┘\n    │        │            │                        │\n    │        │            │                        └── CRC checksum\n    │        │            └── Unique aircraft address\n    │        └── Capability (transponder level)\n    └── Binary:  01011\n\nCA (Capability) Values: \n┌────┬─────────────────────────────────────────────────┐\n│ CA │ Description                                     │\n├────┼─────────────────────────────────────────────────┤\n│ 0  │ Level 1 - Surveillance only                     │\n│ 1  │ Level 2 - Comm-A/B capable                      │\n│ 2  │ Level 3 - Comm-A/B/C capable                    │\n│ 3  │ Level 4 - Comm-A/B/C/D capable                  │\n│ 4  │ Level 2/3/4 - On ground                         │\n│ 5  │ Level 2/3/4 - Airborne                          │\n│ 6  │ Level 2/3/4 - Status unknown                    │\n│ 7  │ Level 7 - DR≠0 or FS=2,3,4,5                    │\n└────┴─────────────────────────────────────────────────┘\n```\n\n**Example:**\n```\nMessage: 5D 4D 20 23 7A 55 A6\n         │  └──────┘  └─────┘\n         │    ICAO     Parity\n         └── DF=11, CA=5\n\nICAO Address: 4D2023 (Malta registration)\nCapability: 5 (Airborne)\n```\n\n### DF17: Extended Squitter (ADS-B)\n\nThe primary ADS-B message format. Contains position, velocity, identification, and other data.\n\n```\nDF17 Structure (112 bits):\n┌─────────┬─────┬────────────────────────┬─────────────────────────────────────────────────────┬────────────────────────┐\n│  DF=17  │ CA  │      ICAO Address      │                    ME (Extended Squitter)           │       PI (Parity)      │\n│ 5 bits  │3 bit│       24 bits          │                      56 bits                        │        24 bits         │\n└─────────┴─────┴────────────────────────┴─────────────────────────────────────────────────────┴────────────────────────┘\n                                         │\n                                         ▼\n                         ┌───────────────────────────────────────────────────┐\n                         │  TC  │ Subtype│          Message Data             │\n                         │5 bits│ 3 bits │           48 bits                 │\n                         └──────┴────────┴───────────────────────────────────┘\n```\n\n### DF4/DF20: Altitude Reply\n\nSent in response to altitude interrogations. \n\n```\nDF4 Structure (56 bits):\n┌─────────┬─────┬─────┬─────┬───────────────────┬────────────────────────┐\n│  DF=4   │ FS  │ DR  │ UM  │  Altitude Code    │      PI/ICAO XOR       │\n│ 5 bits  │3 bit│5 bit│6 bit│     13 bits       │        24 bits         │\n└─────────┴─────┴─────┴─────┴───────────────────┴────────────────────────┘\n\nDF20 Structure (112 bits) - adds 56-bit Comm-B message:\n┌─────────┬─────┬─────┬─────┬───────────────────┬───────────────────────────────────────┬────────────────────────┐\n│  DF=20  │ FS  │ DR  │ UM  │  Altitude Code    │            MB (Comm-B)                │      PI/ICAO XOR       │\n│ 5 bits  │3 bit│5 bit│6 bit│     13 bits       │              56 bits                  │        24 bits         │\n└─────────┴─────┴─────┴─────┴───────────────────┴───────────────────────────────────────┴────────────────────────┘\n\nFS (Flight Status):\n┌────┬─────────────────────────────────────────────────┐\n│ FS │ Description                                     │\n├────┼─────────────────────────────────────────────────┤\n│ 0  │ No alert, no SPI, airborne                      │\n│ 1  │ No alert, no SPI, on ground                     │\n│ 2  │ Alert, no SPI, airborne                         │\n│ 3  │ Alert, no SPI, on ground                        │\n│ 4  │ Alert, SPI, airborne or ground                  │\n│ 5  │ No alert, SPI, airborne or ground               │\n│ 6  │ Reserved                                        │\n│ 7  │ Not assigned                                    │\n└────┴─────────────────────────────────────────────────┘\n```\n\n### DF5/DF21: Identity Reply\n\nSent in response to identity interrogations.  Contains the squawk code.\n\n```\nDF5 Structure (56 bits):\n┌─────────┬─────┬─────┬─────┬───────────────────┬────────────────────────┐\n│  DF=5   │ FS  │ DR  │ UM  │   Identity Code   │      PI/ICAO XOR       │\n│ 5 bits  │3 bit│5 bit│6 bit│     13 bits       │        24 bits         │\n└─────────┴─────┴─────┴─────┴───────────────────┴────────────────────────┘\n\nIdentity (Squawk) Encoding:\nThe 13-bit identity field encodes a 4-digit octal squawk code (0000-7777).\n\nBit arrangement (Gillham code):\n┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐\n│C1 │A1 │C2 │A2 │C4 │A4 │ 0 │B1 │D1 │B2 │D2 │B4 │D4 │\n└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘\n\nSquawk digit reconstruction:\nA = A4×4 + A2×2 + A1\nB = B4×4 + B2×2 + B1\nC = C4×4 + C2×2 + C1\nD = D4×4 + D2×2 + D1\nSquawk = A×1000 + B×100 + C×10 + D\n\nSpecial Squawk Codes: \n┌───────┬─────────────────────────────────────────┐\n│ Code  │ Meaning                                 │\n├───────┼─────────────────────────────────────────┤\n│ 7500  │ Hijacking                               │\n│ 7600  │ Radio failure                           │\n│ 7700  │ Emergency                               │\n│ 1200  │ VFR (Visual Flight Rules) - US          │\n│ 2000  │ Default/Unassigned                      │\n│ 7000  │ VFR - Europe                            │\n└───────┴─────────────────────────────────────────┘\n```\n\n## CRC and Error Detection\n\n### CRC-24 Algorithm\n\nMode S uses a 24-bit CRC (Cyclic Redundancy Check) for error detection. \n\n**Generator Polynomial:**\n```\nG(x) = x²⁴ + x²³ + x²² + x²¹ + x²⁰ + x¹⁹ + x¹⁸ + x¹⁷ + \n       x¹⁶ + x¹⁵ + x¹⁴ + x¹³ + x¹² + x¹⁰ + x³ + 1\n\nHexadecimal: 0x1FFF409\nBinary:  1 1111 1111 1111 0100 0000 1001\n```\n\n### CRC Calculation\n\n```rust\n// Precomputed CRC table for each bit position\nconst MODES_CHECKSUM_TABLE: [u32; 112] = [\n    0x3935ea, 0x1c9af5, 0xf1b77e, 0x78dbbf, // bits 0-3\n    0xc397db, 0x9e31e9, 0xb0e2f0, 0x587178, // bits 4-7\n    // ... (112 entries total)\n];\n\nfn modes_checksum(msg: \u0026[u8], bits: usize) -\u003e u32 {\n    let mut crc:  u32 = 0;\n    let offset = if bits == 112 { 0 } else { 112 - 56 };\n    \n    for j in 0..bits {\n        let byte = j / 8;\n        let bit = j % 8;\n        let bitmask = 1 \u003c\u003c (7 - bit);\n        \n        if msg[byte] \u0026 bitmask != 0 {\n            crc ^= MODES_CHECKSUM_TABLE[j + offset];\n        }\n    }\n    crc\n}\n```\n\n### Error Correction\n\nThe CRC can be used to correct single-bit errors: \n\n```\nFor each bit position i: \n    1. Flip bit i in the message\n    2. Calculate CRC\n    3. If CRC matches the received checksum, error was at position i\n    4. Keep the corrected message\n\nFor aggressive mode (two-bit errors):\n    For each pair of bit positions (i, j):\n        1. Flip bits i and j\n        2. Calculate CRC\n        3. If CRC matches, errors were at positions i and j\n```\n\n## ICAO Address Recovery\n\n### Messages with ICAO in CRC\n\nFor DF0, DF4, DF5, DF16, DF20, and DF21, the ICAO address is XORed with the CRC: \n\n```\nTransmitted PI field = CRC ⊕ ICAO Address\n\nTo recover ICAO: \n    1. Compute CRC over the message (excluding PI field)\n    2. XOR computed CRC with received PI field\n    3. Result is the ICAO address\n\n    ICAO = ComputedCRC ⊕ ReceivedPI\n```\n\n**Validation:**\nSince any 24-bit value could be a valid ICAO, we must validate by:\n1. Checking if the recovered ICAO has been seen in DF11/DF17 messages\n2. Maintaining a cache of known ICAO addresses\n3. Only accepting messages with previously-seen ICAOs\n\n```\nKnown ICAO Cache:\n┌─────────────────────────────────────────────────────────────┐\n│ From DF11/DF17:    ICAO directly in message → Add to cach   │\n│ From DF4/DF5/etc:   Recover ICAO → Check against cache      │\n└─────────────────────────────────────────────────────────────┘\n```\n\n## Extended Squitter (ADS-B)\n\n### Type Codes (TC)\n\nThe ME field in DF17 begins with a 5-bit Type Code:\n\n```\nME Field Structure: \n┌────────────────────────────────────────────────────────────┐\n│  TC   │  Subtype  │              Data                      │\n│ 5 bits│  varies   │             varies                     │\n└───────┴───────────┴────────────────────────────────────────┘\n\nType Code Assignments:\n┌─────────┬─────────────────────────────────────────────────────────┐\n│   TC    │ Message Type                                            │\n├─────────┼─────────────────────────────────────────────────────────┤\n│  1 - 4  │ Aircraft Identification and Category                    │\n│  5 - 8  │ Surface Position                                        │\n│  9 - 18 │ Airborne Position (Barometric Altitude)                 │\n│   19    │ Airborne Velocity                                       │\n│ 20 - 22 │ Airborne Position (GNSS Height)                         │\n│   23    │ Reserved for Testing                                    │\n│   24    │ Reserved for Surface System Status                      │\n│ 25 - 27 │ Reserved                                                │\n│   28    │ Aircraft Status (Emergency/Priority/TCAS RA)            │\n│   29    │ Target State and Status                                 │\n│   30    │ Reserved                                                │\n│   31    │ Aircraft Operational Status                             │\n└─────────┴─────────────────────────────────────────────────────────┘\n```\n\n### Aircraft Identification (TC 1-4)\n\nContains the aircraft's callsign (flight number or registration).\n\n```\nStructure:\n┌───────┬─────────┬──────────────────────────────────────────────────┐\n│  TC   │   EC    │              Callsign (48 bits = 8 chars)        │\n│ 5 bits│  3 bits │    C1    C2    C3    C4    C5    C6    C7    C8  │\n│       │         │   6b    6b    6b    6b    6b    6b    6b    6b   │\n└───────┴─────────┴──────────────────────────────────────────────────┘\n\nCharacter Encoding (6 bits each, ICAO alphabet):\n┌───────┬────────────────────────────────────────────────────────────┐\n│ Index │ 0    1-26   27-36   37-63                                  │\n│ Char  │ ' '  A-Z    0-9     (reserved)                             │\n└───────┴────────────────────────────────────────────────────────────┘\n\nAircraft Category (EC for TC=1-4):\nTC=1: Reserved\nTC=2: Surface Emergency Vehicle, Service Vehicle\nTC=3: A0-A7 (Light to Heavy aircraft)\nTC=4: B0-B7 (Glider to UAV)\n```\n\n**Example:**\n```\nMessage: 8D 4D 20 23 20 04 D0 F4 CB 18 20 B0 EF D4\n                     └─ TC=4\n                        \nME = 20 04 D0 F4 CB 18 20\n   = 0010 0000 | 0000 0100 | 1101 0000 | 1111 0100 | 1100 1011 | 0001 1000 | 0010 0000\n\nTC = 00100 = 4\nCharacter extraction:\nC1 = 000000 = 0  → ' '\nC2 = 001000 = 8  → 'A'+'7' = 'M'\nC3 = 000011 = 3  → 'A'+'2' = 'C'\n...  (continues)\n\nDecoded: \"AMC421  \" (Air Malta flight 421)\n```\n\n### Airborne Position (TC 9-18)\n\nContains latitude, longitude, and barometric altitude using CPR encoding.\n\n```\nStructure:\n┌───────┬─────┬─────┬─────────────────┬───────┬───────────────────┬───────────────────┐\n│  TC   │ SS  │ SAF │    Altitude     │   T   │   CPR Latitude    │   CPR Longitude   │\n│ 5 bits│2 bit│1 bit│    12 bits      │ 1 bit │     17 bits       │     17 bits       │\n└───────┴─────┴─────┴─────────────────┴───────┴───────────────────┴───────────────────┘\n         │     │          │               │           │                   │\n         │     │          │               │           │                   └── CPR-encoded longitude\n         │     │          │               │           └── CPR-encoded latitude\n         │     │          │               └── Time bit (0=even, 1=odd)\n         │     │          └── Encoded altitude\n         │     └── Single Antenna Flag\n         └── Surveillance Status\n\nSurveillance Status (SS):\n┌────┬─────────────────────────────────────────────────┐\n│ SS │ Description                                     │\n├────┼─────────────────────────────────────────────────┤\n│ 0  │ No condition information                        │\n│ 1  │ Permanent alert (emergency condition)           │\n│ 2  │ Temporary alert (changed mode A identity code)  │\n│ 3  │ SPI condition                                   │\n└────┴─────────────────────────────────────────────────┘\n```\n\n### Airborne Velocity (TC 19)\n\nContains ground speed, airspeed, vertical rate, and heading.\n\n```\nTC 19 Subtypes:\n┌──────────┬───────────────────────────────────────────────────────┐\n│ Subtype  │ Description                                           │\n├──────────┼───────────────────────────────────────────────────────┤\n│    1     │ Ground speed (subsonic)                               │\n│    2     │ Ground speed (supersonic)                             │\n│    3     │ Airspeed (subsonic)                                   │\n│    4     │ Airspeed (supersonic)                                 │\n└──────────┴───────────────────────────────────────────────────────┘\n\nSubtype 1/2 (Ground Speed):\n┌───────┬─────┬─────┬─────┬─────┬─────────────┬─────────────┬─────┬─────┬───────────┬────────────┐\n│  TC   │ ST  │ IC  │ IFR │ NUC │    EW Vel   │    NS Vel   │VrSrc│VrSgn│  Vert Rate│  Reserved  │\n│ 5 bits│3 bit│1 bit│1 bit│3 bit│   11 bits   │   11 bits   │1 bit│1 bit│   9 bits  │   2 bits   │\n└───────┴─────┴─────┴─────┴─────┴─────────────┴─────────────┴─────┴─────┴───────────┴────────────┘\n\nGround Speed Calculation:\n- EW Direction: 1 = West, 0 = East\n- NS Direction: 1 = South, 0 = North\n- Velocity = sqrt(EW² + NS²) in knots\n- Subtype 1: 1 knot resolution\n- Subtype 2: 4 knot resolution (supersonic)\n\nHeading Calculation:\nheading = atan2(EW_velocity, NS_velocity)\n(adjust for direction signs)\n\nVertical Rate: \n- VrSrc: 0 = Barometric, 1 = Geometric (GNSS)\n- VrSgn: 0 = Up, 1 = Down\n- Rate = (value - 1) × 64 ft/min\n```\n\n## Position Encoding (CPR)\n\n### Compact Position Reporting\n\nCPR is an ingenious encoding that represents global positions in only 17 bits for latitude and 17 bits for longitude.\n\n```\nTraditional coordinates:\n  Latitude:   -90° to +90°   needs ~27 bits for 1m precision\n  Longitude: -180° to +180° needs ~28 bits for 1m precision\n  Total:  ~55 bits\n\nCPR encoding:\n  Latitude:   17 bits\n  Longitude: 17 bits\n  Total: 34 bits (38% less!)\n```\n\n### How CPR Works\n\nCPR divides the Earth into zones and encodes position relative to zone boundaries:\n\n```\nLatitude Zones (NZ = 15 for airborne):\n┌─────────────────────────────────────────────────────────────────┐\n│  90°N ├─────────────────────────────────────────────────────────│\n│       │  Zone 0                                                 │\n│       ├─────────────────────────────────────────────────────────│\n│       │  Zone 1                                                 │\n│       ├─────────────────────────────────────────────────────────│\n│       │  ...                                                    │\n│       ├─────────────────────────────────────────────────────────│\n│       │  Zone 59 (even) / Zone 58 (odd)                         │\n│ -90°S ├─────────────────────────────────────────────────────────│\n└─────────────────────────────────────────────────────────────────┘\n\nEven message:  60 latitude zones (Dlat₀ = 360°/60 = 6°)\nOdd message:   59 latitude zones (Dlat₁ = 360°/59 ≈ 6.1°)\n```\n\n### Decoding Algorithm\n\n```python\n# Constants\nNZ = 15  # Number of geographic latitude zones\nDlat0 = 360.0 / 60  # Even message latitude zone size\nDlat1 = 360.0 / 59  # Odd message latitude zone size\n\ndef decode_cpr(lat0, lon0, lat1, lon1, most_recent_is_odd):\n    \"\"\"\n    Decode CPR position from even (0) and odd (1) messages.\n    lat0, lon0: Even message CPR values (0-131071)\n    lat1, lon1: Odd message CPR values (0-131071)\n    \"\"\"\n    # Normalize to 0-1 range\n    lat0 /= 131072.0  # 2^17\n    lon0 /= 131072.0\n    lat1 /= 131072.0\n    lon1 /= 131072.0\n    \n    # Calculate latitude index\n    j = floor(59 * lat0 - 60 * lat1 + 0.5)\n    \n    # Calculate latitudes\n    rlat0 = Dlat0 * (mod(j, 60) + lat0)\n    rlat1 = Dlat1 * (mod(j, 59) + lat1)\n    \n    # Adjust for southern hemisphere\n    if rlat0 \u003e= 270:  rlat0 -= 360\n    if rlat1 \u003e= 270: rlat1 -= 360\n    \n    # Check latitude zone consistency\n    if NL(rlat0) != NL(rlat1):\n        return None  # Position crosses zone boundary, wait for new pair\n    \n    # Calculate longitude\n    if most_recent_is_odd: \n        ni = max(NL(rlat1) - 1, 1)\n        m = floor(lon0 * (NL(rlat1) - 1) - lon1 * NL(rlat1) + 0.5)\n        rlon = (360.0 / ni) * (mod(m, ni) + lon1)\n        rlat = rlat1\n    else: \n        ni = max(NL(rlat0), 1)\n        m = floor(lon0 * (NL(rlat0) - 1) - lon1 * NL(rlat0) + 0.5)\n        rlon = (360.0 / ni) * (mod(m, ni) + lon0)\n        rlat = rlat0\n    \n    # Normalize longitude\n    if rlon \u003e 180: rlon -= 360\n    \n    return (rlat, rlon)\n\ndef NL(lat):\n    \"\"\"Number of longitude zones at given latitude.\"\"\"\n    if abs(lat) \u003e= 87.0: return 1\n    return floor(2 * pi / acos(1 - (1-cos(pi/2/NZ)) / cos(pi/180*lat)**2))\n```\n\n### NL (Number of Longitude Zones) Lookup Table\n\n```\n┌──────────────────┬─────┐\n│ Latitude Range   │ NL  │\n├──────────────────┼─────┤\n│ 0° - 10. 47°     │ 59  │\n│ 10.47° - 14.83°  │ 58  │\n│ 14.83° - 18.19°  │ 57  │\n│ 18.19° - 21.03°  │ 56  │\n│ ...              │ ... │\n│ 84.89° - 85.76°  │ 4   │\n│ 85.76° - 86.54°  │ 3   │\n│ 86.54° - 87.00°  │ 2   │\n│ \u003e 87.00°         │ 1   │\n└──────────────────┴─────┘\n```\n\n## Altitude Encoding\n\n### Q-bit Encoding (25-foot resolution)\n\nWhen the Q-bit is set, altitude uses simple 25-foot increments:\n\n```\n13-bit Altitude Field:\n┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐\n│M  │Q  │A1 │A2 │A4 │B1 │B2 │B4 │C1 │C2 │C4 │D2 │D4 │\n└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘\n │   │\n │   └── Q=1: 25-foot resolution\n └── M=0: Feet, M=1: Meters\n\nWhen Q=1:\n  N = (all bits except M and Q)\n  Altitude = N × 25 - 1000 feet\n  Range:  -1000 to 50,175 feet\n```\n\n### Gillham (Gray Code) Encoding (100-foot resolution)\n\nWhen Q-bit is 0, altitude uses Gray code (for compatibility with Mode C):\n\n```\nGillham Code Structure:\nD2 D4 A1 A2 A4 B1 B2 B4 C1 C2 C4\n\nThe bits encode altitude in a Gray code pattern where:\n- 500-foot increments encoded in D and C bits\n- 100-foot increments encoded in A and B bits\n\nGray Code to Binary Conversion:\nbinary[0] = gray[0]\nbinary[i] = binary[i-1] XOR gray[i]\n\nExample:\n  Gray: 0011 → Binary: 0010 (decimal 2)\n  Gray: 0110 → Binary: 0100 (decimal 4)\n```\n\n## Velocity Encoding\n\n### Ground Speed (Subtype 1/2)\n\n```\nEast-West Velocity:\n┌─────────────────┬───────────────────────────────────────────┐\n│ Direction (1b)  │ Speed (10b)                               │\n├─────────────────┼───────────────────────────────────────────┤\n│ 0 = East        │ 0 = no info                               │\n│ 1 = West        │ 1-1023 = speed in knots + 1               │\n└─────────────────┴───────────────────────────────────────────┘\n\nNorth-South Velocity: \n┌─────────────────┬───────────────────────────────────────────┐\n│ Direction (1b)  │ Speed (10b)                               │\n├─────────────────┼───────────────────────────────────────────┤\n│ 0 = North       │ 0 = no info                               │\n│ 1 = South       │ 1-1023 = speed in knots + 1               │\n└─────────────────┴───────────────────────────────────────────┘\n\nGround Speed and Track Calculation:\n  Vew = (EW_value - 1) × (direction ?  -1 : 1)\n  Vns = (NS_value - 1) × (direction ? -1 : 1)\n  \n  Ground Speed = √(Vew² + Vns²) knots\n  Track Angle = atan2(Vew, Vns) degrees\n\nVertical Rate: \n┌─────────────────┬─────────────────┬────────────────────────────┐\n│ Source (1b)     │ Sign (1b)       │ Rate (9b)                  │\n├─────────────────┼─────────────────┼────────────────────────────┤\n│ 0 = Barometric  │ 0 = Up          │ 0 = no info                │\n│ 1 = Geometric   │ 1 = Down        │ 1-511 = (value-1)×64 ft/min│\n└─────────────────┴─────────────────┴────────────────────────────┘\n```\n\n### Heading and Airspeed (Subtype 3/4)\n\n```\n┌───────┬─────┬─────────────────┬─────────────────┬───────────────────┐\n│Status │ Hdg │    Heading      │   AS Type       │    Airspeed       │\n│ 1 bit │1 bit│    10 bits      │    1 bit        │    10 bits        │\n└───────┴─────┴─────────────────┴─────────────────┴───────────────────┘\n\nHeading = value × (360/1024) degrees\nAS Type:  0 = IAS, 1 = TAS\nAirspeed = value knots (subtype 3) or value × 4 knots (subtype 4)\n```\n\n## Aircraft Identification\n\n### Callsign Encoding\n\nAircraft identification uses a 64-character alphabet encoded in 6 bits per character:\n\n```\nICAO Character Set:\nIndex:   0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15\nChar:  ' ' 'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M' 'N' 'O'\n\nIndex:  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31\nChar:   'P' 'Q' 'R' 'S' 'T' 'U' 'V' 'W' 'X' 'Y' 'Z'  ?    ?   ?   ?   ? \n\nIndex: 32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47\nChar:  ' '  ?    ?   ?   ?   ?   ?   ?   ?   ?   ?   ?   ?   ?   ?   ?\n\nIndex: 48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63\nChar:  '0' '1' '2' '3' '4' '5' '6' '7' '8' '9'  ?   ?   ?   ?    ?   ? \n\nDecoding 8 characters from 48 bits: \n┌────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┐\n│  Char1 │  Char2 │  Char3 │  Char4 │  Char5 │  Char6 │  Char7 │  Char8 │\n│ 6 bits │ 6 bits │ 6 bits │ 6 bits │ 6 bits │ 6 bits │ 6 bits │ 6 bits │\n└────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┘\n```\n\n## BDS (Comm-B Data Selector)\n\nBDS registers contain additional aircraft data in DF20/DF21 messages. \n\n### BDS Overview\n\n```\n┌────────┬─────────────────────────────────────────────────────────────┐\n│  BDS   │ Content                                                     │\n├────────┼─────────────────────────────────────────────────────────────┤\n│  1,0   │ Data Link Capability Report                                 │\n│  2,0   │ Aircraft Identification                                     │\n│  3,0   │ ACAS Active Resolution Advisory                             │\n│  4,0   │ Selected Vertical Intention                                 │\n│  5,0   │ Track and Turn Report                                       │\n│  6,0   │ Heading and Speed Report                                    │\n└────────┴─────────────────────────────────────────────────────────────┘\n```\n\n### BDS 4,0 - Selected Vertical Intention\n\n```\n┌───────────────────────────────────────────────────────────────────────────────┐\n│ MCP/FCU Selected Altitude │ FMS Selected Altitude │ Baro Pressure │ Mode Bits │\n│        13 bits            │       13 bits         │    12 bits    │   8 bits  │\n└───────────────────────────────────────────────────────────────────────────────┘\n\nMCP Altitude = value × 16 feet\nFMS Altitude = value × 16 feet  \nBaro Pressure = 800 + value × 0.1 mb\n```\n\n### BDS 5,0 - Track and Turn Report\n\n```\n┌───────────────────────────────────────────────────────────────────────────────────────┐\n│ Roll Angle │ True Track │ Ground Speed │ Track Rate │ True Airspeed │\n│  11 bits   │  12 bits   │   11 bits    │  11 bits   │    11 bits    │\n└───────────────────────────────────────────────────────────────────────────────────────┘\n\nRoll Angle:  ±45°/256 per LSB (signed)\nTrue Track: 90°/512 per LSB\nGround Speed:  2 knots per LSB\nTrack Rate: 8°/256 per second per LSB (signed)\nTrue Airspeed: 2 knots per LSB\n```\n\n### BDS 6,0 - Heading and Speed Report\n\n```\n┌─────────────────────────────────────────────────────────────────────────────────────────────────┐\n│ Mag Heading │ Indicated Airspeed │ Mach Number │ Baro Alt Rate │ Inertial Alt Rate │\n│   12 bits   │      11 bits       │   11 bits   │    11 bits    │      11 bits      │\n└─────────────────────────────────────────────────────────────────────────────────────────────────┘\n\nMagnetic Heading: 90°/512 per LSB\nIndicated Airspeed: 1 knot per LSB\nMach:  0.008 per LSB (2. 048 max)\nAltitude Rate: 32 ft/min per LSB (signed)\n```\n\n---\n\n## Architecture\n\n```\n┌─────────────────────────────────────────────────────────────────────────────────┐\n│                              adsb Architecture                           │\n├─────────────────────────────────────────────────────────────────────────────────┤\n│                                                                                 │\n│   ┌─────────────┐     ┌─────────────┐     ┌─────────────┐     ┌─────────────┐   │\n│   │   RTL-SDR   │     │ Demodulator │     │   Decoder   │     │  Aircraft   │   │\n│   │   Input     │────►│             │────►│             │────►│   Tracker   │   │\n│   │             │     │ • Preamble  │     │ • CRC Check │     │             │   │\n│   │ • 2 MHz     │     │ • PPM Decode│     │ • DF Parse  │     │ • Position  │   │\n│   │ • 8-bit I/Q │     │ • Magnitude │     │ • CPR Decode│     │ • History   │   │\n│   └─────────────┘     └─────────────┘     └─────────────┘     └─────────────┘   │\n│         │                                                            │          │\n│         │           ┌─────────────────────────────────────────┐      │          │\n│         │           │           Network Services              │      │          │\n│         │           │  ┌───────┐ ┌───────┐ ┌───────┐ ┌──────┐ │      │          │\n│         │           │  │ Raw   │ │  SBS  │ │ HTTP  │ │ JSON │ │◄─────┘          │\n│         │           │  │:30002 │ │:30003 │ │:8080  │ │ API  │ │                 │\n│         │           │  └───────┘ └───────┘ └───────┘ └──────┘ │                 │\n│         ▼           └─────────────────────────────────────────┘                 │\n│   ┌─────────────┐                                                               │\n│   │  File Input │     ┌─────────────────────────────────────────┐               │\n│   │             │────►│          Interactive Display            │               │\n│   │ • Binary    │     │                                         │               │\n│   │ • stdin     │     │  Hex    Flight   Alt    Speed   Lat     │               │\n│   └─────────────┘     │  ────── ──────── ────── ─────── ─────   │               │\n│                       │  89645A UAE80T   35000  465     5.89    │               │\n│                       │  4D2023 AMC421   22000  385     37.07   │               │\n│                       └─────────────────────────────────────────┘               │\n│                                                                                 │\n└─────────────────────────────────────────────────────────────────────────────────┘\n```\n\n### Module Overview\n\n| Module | Description |\n|--------|-------------|\n| `main.rs` | Entry point, runtime management, CLI |\n| `config.rs` | Configuration and argument parsing |\n| `magnitude.rs` | I/Q to magnitude conversion with LUT |\n| `demodulator.rs` | Signal detection and bit extraction |\n| `decoder.rs` | Message parsing and field extraction |\n| `crc.rs` | CRC-24 calculation and error correction |\n| `aircraft.rs` | Aircraft tracking and CPR position decoding |\n| `network.rs` | TCP/HTTP servers for data output |\n\n---\n\n## Network Services\n\n### Port Overview\n\n| Port | Protocol | Format | Description |\n|------|----------|--------|-------------|\n| 30001 | TCP | Raw | Raw message input |\n| 30002 | TCP | Raw | Raw message output |\n| 30003 | TCP | SBS | BaseStation format output |\n| 8080 | HTTP | HTML/JSON | Web interface and API |\n\n### Raw Format\n\n```\n*[HEX_MESSAGE];\n\nExample:\n*8D4D2023587F345E35837E2218B2;\n```\n\n### SBS/BaseStation Format\n\n```\nMSG,\u003ctype\u003e,,,\u003cicao\u003e,,,,,,\u003ccallsign\u003e,\u003caltitude\u003e,\u003cspeed\u003e,\u003ctrack\u003e,\u003clat\u003e,\u003clon\u003e,... \n\nTypes:\n  MSG,1 - Identification\n  MSG,3 - Position\n  MSG,4 - Velocity\n  MSG,5 - Altitude\n  MSG,6 - Squawk\n  MSG,8 - All-Call Reply\n\nExample:\nMSG,3,,,4D2023,,,,,,,35000,,37.0740,13.7990,,,0,0,0,0\n```\n\n### JSON API\n\n```\nGET http://localhost:8080/data.json\n\nResponse:\n[\n  {\n    \"hex\": \"4D2023\",\n    \"flight\":  \"AMC421\",\n    \"lat\": 37.074,\n    \"lon\": 13.799,\n    \"altitude\":  35000,\n    \"track\": 157,\n    \"speed\": 385\n  }\n]\n```\n\n---\n\n## Contributing\n\nContributions are welcome! Please feel free to submit pull requests. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fktauchathuranga%2Fadsb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fktauchathuranga%2Fadsb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fktauchathuranga%2Fadsb/lists"}