---
title: "VARA HF: Protocol Specification for Implementers"
subtitle: "Everything needed to build an interoperable VARA HF modem"
date: "2026-11-27"
---

# 1. Scope

This document specifies the VARA HF protocol (version 4.9.x; checked against 4.9.0) completely enough to build an
interoperable modem from scratch: the shared pseudo-random tables, control frames, data frames, forward error
correction, the three waveform families, text compression, the ARQ session protocol, CQ frames and the host TCP
interface.

Numbers in `code` are exact constants. "Rnd" and "Randomize" refer to the generator of §3. Values marked
*(unconfirmed)* are believed correct but not yet confirmed.

# 2. Signal basics

- **Audio**: real, 48 000 samples/s. All three bandwidths are centred on **1500 Hz** in the SSB passband
  (USB/DIGU). In LSB the tones arrive mirrored, so neither codewords nor data match (a consequence, not a mode).
- **Bandwidths**: 500 Hz (13 levels), 2300 Hz (16 levels), 2750 Hz (17 levels). ("Narrow", "standard" and
  "tactical" are informal names only.)
- **Control-frame tone grid**: 48000 / 2048 = **23.4375 Hz** per bin; bin 64 is 1500 Hz.
- **Data waveforms** are defined at a **3000 Hz reference rate** (FSK samples per symbol, PSK 32 samples
  per symbol, OFDM 64 bins) and produced at 48 kHz (×16).
- **Transmit level**:
  - back-off for a waveform of peak figure *u* dB: `backoff(u) = u + 2 + (10 - u) / 5`
  - linear gain at drive *d* dB: `gain = 10^((d - backoff(u)) / 20)`
  - control frames use *u* = the format's *k* (3 dB, or 6 dB for format 2); data frames use the level's
    PAPR figure; data audio is first divided by the level's amplitude normaliser ("Amp norm" in §7).
  - after the gain every sample is clipped to ±1.0.
  - the drive is a whole number of dB from **-30** to **0**; the default is **-5 dB**.
  - worked values: `backoff(3) = 6.4` dB and `backoff(6) = 8.8` dB; at -5 dB the control gains are `0.2692`
    (F0, F1) and `0.2042` (F2), so a control frame peaks at 0.381 (one tone) or at most 0.408 (two tones) of
    full scale; at 0 dB, 0.677 and 0.726. At -5 dB the highest-peak data level (2300 L16) peaks at about
    0.76 of full scale *(unconfirmed)*.

# 3. The pseudo-random generator

Every table and codebook comes from one generator that behaves exactly like Visual Basic 6's `Rnd` and
`Randomize`. Single precision matters: several states round differently in double precision.

- State: 24 bits. Program-start state `0x050000`.
- Step: `state = (state × 0xFD43FD + 0xC39EC3) mod 2^24`.
- Value: `state / 2^24`, computed and returned as a 32-bit float.
- `Rnd(x)`, *x* < 0: `bits = float32_bits(x)`; `state = (bits + (bits >> 24)) & 0xFFFFFF`; then step.
  *x* > 0 steps. (*x* = 0 would return the last value without stepping; the protocol never uses it.)
  `Rnd(-1)` always leaves the state at `0x395886`.
- `Randomize(d)`: `hi` = the upper 32 bits of the IEEE double *d*;
  `mix = ((hi & 0xFFFF) XOR (hi >> 16)) & 0xFFFF`; `state = (state & 0xFF0000FF) | (mix << 8)`.
- `draw(m)` = `floor(Rnd() × m)` with the product rounded to float32 before the floor; `rand_int(n)` = `draw(n + 1)`.
- **Seeded stream** `seeded(s)`: `Rnd(-1)` then `Randomize(s)`.
- **Per-use reseed** `seed_rnd(x)`: `Rnd(-1)`; `Randomize(x mod 32768)`; then step `floor(x / 32768) + 1`
  times.

# 4. Shared tables built at start-up

Both stations use identical tables. Each is defined below by the generator stream that produces it. (The
reference implementation computes the whitening, PSK phase and lead-in tables at start-up and ships the data
table and the per-level record tables as data files; their contents are exactly the streams defined here.)

## 4.1 Whitening

`seeded(292)`; 150 000 values `rand_int(1)` (0 or 1). XORed onto the frame bits from index 0 for every frame.

## 4.2 Phase tables

A phase index counts 128ths of a turn; the phasor is `e^(j·2π·idx/128)` (2π taken as `6.28318530717958`). An
index of 128 gives the same phasor as 0, so a table of indices may store either.

- **PSK** (13 carriers × 471 symbols): own `seeded(292)` stream; for the symbol span 0..411 then 411..471:
  for each carrier, for each symbol in the span: `rand_int(128)`.
- **Data table**: own `seeded(292)` stream; 65 000 values `rand_int(128)` (0..128, 128 kept).
- **OFDM** (128 bins × 469 symbols): consumed in order from the data table; for the span 0..409 then
  409..469: for each bin, for each symbol: the next value.

## 4.3 Per-level record tables

One `seeded(43)` stream per bandwidth, consumed level by level for all 17 rows of the bandwidth's table
(rows past the ladder included, so the streams line up). Per level, in order:

1. **Channel interleaver** (N entries) and 2. **turbo interleaver** (K entries): permutations by
   rejection: repeat `v = draw(n)`, keep *v* if not seen, until all *n* values are taken.
3. **"Other" table**:
   - **FSK**: hop base per data symbol (`symbols - 1` entries):
     `first + (1 if step > 1 and i even) + step × draw(choices)`, with
     `choices = bins/step + 1` if step > 1 else `bins` (`bins = last - first + 1`). Then 24 **pilot rows**:
     `inc = float32((symbols - 2) / 24)`, `acc = 1.0f`; per pilot `acc += inc; row = int(acc)`. Then a pilot
     value per pilot, in row order: `(2^bps / 8) × draw(8)`, placed at symbol `row - 2`. Stored as: hop
     bases, the 24 rows, then a (flag, value) pair per data symbol.
   - **PSK and OFDM**: per carrier, `markers` distinct symbol positions: non-QAM `5 + draw(spf - 8)`; QAM
     `3 + (first + c) mod 2 + 8 × draw((spf - 3) / 8)` (on the carrier's pilot parity). Stored as all
     positions, then per carrier a 0/1 map of `spf - 1` symbols (position *v* sets index `v - 2`).

Stored form, where an implementation keeps the tables in a file: every value as a 16-bit big-endian word,
levels in order, followed by the CRC of §5 computed over all table bytes except the last one. The stored CRCs
are `0x1B72` (500 Hz), `0xFBAC` (2300 Hz) and `0x3DB1` (2750 Hz).

# 5. Callsigns and CRC

- **CRC-16 "GENIBUS"**: polynomial `0x1021`, initial `0xFFFF`, MSB first, result inverted. Check
  value `"123456789"` → `0xD64E`. Frames carry it big-endian.
- **Accepted callsigns**: a station upper-cases every callsign it is given and refuses it unless the base (the
  text before `-`) is 1–7 characters of A–Z and 0–9, and the suffix is absent, `-` plus one or two digits
  (value 1–19), or `-T`, `-R`, `-X` or `-L`. Before checking, an 8-character callsign without `-` that ends in
  T, R, X or L is rewritten with that letter as its SSID (`N0CALLXR` becomes `N0CALLX-R`; for the station's own
  callsigns and the called station). A station has up to five callsigns.
- **Station hash** (24 bits): low 16 bits = CRC of the whole stored callsign text (upper case, with SSID);
  high 8 bits = high byte of the CRC of its last three characters (of the whole text if shorter). Case as typed
  does not matter. The empty callsign hashes to 0.
- **Packed callsign** (6 bytes = eight 6-bit codes, MSB first): A–Z → 1–26, 0–9 → 27–36.
  Codes 1–7: the base callsign, padded with 0. Code 8: the SSID: 1–15 as numbers, `T` 16, `R` 17, `X` 18,
  `L` 19; numeric SSIDs 16–19 pack as the same codes as T, R, X, L. No other character or SSID can occur,
  because such callsigns are refused.
- **Unpacking**: codes 1–36 of the first seven map back to characters, other codes give nothing, trailing
  padding is removed; the SSID is the last byte `& 0x1F`: 0 none, 16–19 `-T/-R/-X/-L`, otherwise `-` and the
  number. A leading-zero SSID (`-05`) packs as 5 but hashes differently from `-5` *(effect on a session
  unconfirmed)*.

# 6. Control frames

Control frames carry all session signalling: connect requests and replies, acknowledgements, turn changes,
disconnects, CQ and KISS announcements.

## 6.1 Symbols and audio

- A symbol is **2048 samples** and plays one tone (formats 0 and 1) or two (format 2) on bins *k* of the
  23.4375 Hz grid: `sample[n] = (2 / norm) × Σ_tones sin(2π·k·n/2048)` (norm = √2 for one tone, 2 for two),
  *n* restarting at 0 every symbol; then the gain of §2 and the ±1.0 clip.
- The transmission is **lead-in symbols, then the codeword** (`nsym - 1` symbols), then **25 silent symbols**
  and one further silent block as the transmission ends.

## 6.2 Formats

Lead-in length: `ceil(lead_ms / (2048/48 ms)) + extra`. The long lead is used for GO AHEAD, NO TRAFFIC,
BREAK and IDLE, the short one otherwise. `extra` applies only to the first transmission after a session reset
(performed at the end of a session and when a call is started): 9 when calling (the first connect request), 7 when answering (the
first connect reply) unless chat mode or the tuning-tone option is on, else 0.

| Fmt | Symbols (incl. lead slot) | Tones/symbol | Lead long ms | Lead short ms | Min hits | Decode SNR dB | k dB | Lead-in symbols (long / short) |
|---|---|---|---|---|---|---|---|---|
| F0 | 32 | 1 | 40 | 40 | 19 | -15.5 | 3 | 1 / 1 |
| F1 | 16 | 1 | 80 | 40 | 13 | -7.5 | 3 | 2 / 1 |
| F2 | 8 | 2 | 160 | 40 | 12 | -3.5 | 6 | 4 / 1 |

The minimum hits are out of a maximum of 31, 15 and 14 (format 2 counts each of its 14 tones). Receivers also
use a second threshold of `Decode SNR - (9.4 - k)` dB (informative).

Lead-in tones: a generator in its program-start state (not seeded) produces, for F0, F1, F2 in that order,
100 lead-in symbols each: per symbol `ntones` distinct bins `rand_int(34) + 50` (bins 50–84; a repeated bin
is drawn again). A frame uses the first *L* symbols of its format's grid.

## 6.3 Control codes

| Code | Meaning |
|---|---|
| 1 | ACK, stay at level |
| 2 | NACK (frame lost) |
| 3 | QRT (disconnect, CW ID follows) |
| 4 | unused |
| 5 | ACK, up 2 levels |
| 6 | ACK, down 1 level (stays at level 1) |
| 7 | ACK, up 1 level |
| 8 | ACK, up 3 levels |
| 9 | ACK, up 4 levels |
| 10 | ACK of the second frame only (first lost) |
| 11 | ACK of the first frame only (second lost) |
| 12 | ACK REQUEST (alternating bit 0) |
| 13 | ACK REQUEST (alternating bit 1) |
| 14 | GO AHEAD (turn granted) |
| 15 | CONNECT REPLY, 2300 Hz, first level 1 |
| 16 | CONNECT REPLY, 2300 Hz, first level 2 |
| 17 | CONNECT REPLY, 2300 Hz, first level 3 |
| 18 | CONNECT REPLY, 2300 Hz, first level 4 |
| 19 | NACK, transmission missed (ACK request received) |
| 20 | unused |
| 21 | NO TRAFFIC (answer to IDLE: nothing queued) |
| 22 | CONNECT REPLY, 500 Hz, first level 1 |
| 23 | CONNECT REPLY, 500 Hz, first level 2 |
| 24 | CONNECT REPLY, 500 Hz, first level 3 |
| 25 | CONNECT REPLY, 500 Hz, first level 4 |
| 26 | CONNECT REQUEST, 2300 Hz, alias 0 |
| 27 | CONNECT REQUEST, 2300 Hz, alias 1 |
| 28 | CONNECT REQUEST, 2300 Hz, alias 2 |
| 29 | CONNECT REQUEST, 2300 Hz, alias 3 |
| 30 | CONNECT REQUEST, 2300 Hz, alias 4 |
| 31 | CONNECT REQUEST, 500 Hz, alias 0 |
| 32 | CONNECT REQUEST, 500 Hz, alias 1 |
| 33 | CONNECT REQUEST, 500 Hz, alias 2 |
| 34 | CONNECT REQUEST, 500 Hz, alias 3 |
| 35 | CONNECT REQUEST, 500 Hz, alias 4 |
| 36 | CONNECT REQUEST, 2750 Hz, alias 0 |
| 37 | CONNECT REQUEST, 2750 Hz, alias 1 |
| 38 | CONNECT REQUEST, 2750 Hz, alias 2 |
| 39 | CONNECT REQUEST, 2750 Hz, alias 3 |
| 40 | CONNECT REQUEST, 2750 Hz, alias 4 |
| 41 | CONNECT REPLY, 2750 Hz, first level 1 |
| 42 | CONNECT REPLY, 2750 Hz, first level 2 |
| 43 | CONNECT REPLY, 2750 Hz, first level 3 |
| 44 | CONNECT REPLY, 2750 Hz, first level 4 |
| 45 | KISS / unproto announcement, level 1 |
| 46 | QRT without CW ID |
| 47 | KISS / unproto announcement, level 2 |
| 48 | CQ (callsign frame follows) |
| 49 | BREAK (request the turn / end of received turn) |
| 50 | IDLE (nothing to send) |
| 51 | START LEVEL 1 (BREAK reply: offered level) |
| 52 | START LEVEL 2 (BREAK reply: offered level) |
| 53 | START LEVEL 3 (BREAK reply: offered level) |
| 54 | START LEVEL 4 (BREAK reply: offered level) |
| 55 | START LEVEL 5 (BREAK reply: offered level) |
| 56 | START LEVEL 6 (BREAK reply: offered level) |
| 57 | START LEVEL 7 (BREAK reply: offered level) |
| 58 | KISS / unproto announcement, level 4 |

Code 43 doubles as REJECT and as "2750 Hz connect reply, level 3" (2750 replies are `40 + level`); the
receiving state tells them apart.

Code blocks: connect requests `base + alias` (500: 31, 2300: 26, 2750: 36; aliases 0–4 = the callee's
callsigns 1–5); connect replies `base + level - 1` (500: 22, 2300: 15, 2750: 41; level 1–4); start levels
`50 + level` (1–7).

While waiting for the acknowledgement of data it has sent, a station also takes BREAK and IDLE as
acknowledging that data (at the current level).

KISS announcements (45, 47, 58) always use the 500 Hz level table, whatever the session bandwidth.

**Which decoded codes a station acts on.** Besides the codes expected in its current state:

- KISS codes only when KISS is enabled; CQ only in chat mode;
- START LEVEL only on the answering side, while it holds the turn after the connect, and not in chat mode;
- connect requests only while listening, and only for an alias the station has;
- a station set to 500 Hz ignores 2300 Hz and 2750 Hz requests; a station set to 2300 or 2750 Hz ignores
  500 Hz requests unless its compatibility option is on;
- connect replies: a 500 Hz station takes 22–25, a 2300 Hz station 15–18, a 2750 Hz station 15–18 and 41–44.

## 6.4 Codebooks

The tones of every code's codeword come from a codebook drawn per session, so a station only recognises
frames meant for it (except the unproto codes 45, 47, 48 and 58, which use fixed seeds).

**Tone families**: family 1 (500 Hz layout): comb bases {50, 64}; family 2 (2300): {29, 43, 57, 71, 85};
family 3 (2750): {22, 36, 50, 64, 78, 92} (bases 14 bins apart from the first). A code's family: connect
replies use their own bandwidth's family; connect requests too, except that 2750 requests use family 2;
codes 47, 48 and 58 family 1; all others, including code 45 in the main pass, the session bandwidth's family.
Code 45's final codeword is redrawn with family 1 (step 3 below).

**Drawing one codeword** (format with `nsym` symbols and `ntones` tones): for *s* = 2..nsym: first pick
`ntones` distinct bases by repeating `base = rand_int(nbases - 1) × 14 + first`; then, for each tone in order,
tone = `base + odd + 2 × rand_int(6)`, where `odd = 1` if *s* is even and the family is not 1, else 0.

**A codebook** has two sides: what we expect to receive and what we send. Side offsets: answerer `278`,
caller `50`; the receive side uses the peer's offset, the send side our own. For each side and each format
*f* (0, 1, 2), with `off = f + side_offset`:

1. `seed_rnd(link_seed + 10 + off)`.
2. For codes 1..58 in order, reseed first where listed, then draw the codeword:
   - connect request (bandwidth *b*, alias *a*): `seed_rnd(callee + off + R(b))`, R = 7 (500), 0 (2300),
     8 (2750); `callee` = the link seed on our sending side for alias 0, else our alias *a*'s hash;
   - code 41: `seed_rnd(link_seed + 300 + off)`;
   - code 47 (KISS L2): `seed_rnd(0xCD80A4 + off)`; code 48 (CQ): `seed_rnd(0xA3CE37 + off)`;
     code 58 (KISS L4): `seed_rnd(0x49E730 + off)`;
   - code 51 (start level 1): `seed_rnd(link_seed + 1500 + off)`.
3. `seed_rnd(0x2D277B0 + off)` and draw code 45 (KISS L1) again with family 1; this replaces the codeword
   drawn for it in step 2. (The step-2 draw still advances the stream that code 46 continues from.)

**Link seed and keys by state**:

| State | Link seed | Our hashes | Role | Connect codes |
|---|---|---|---|---|
| Listening | 0 | our 1–5 callsigns | answerer | none |
| Calling | hash(callee) | our callsigns | caller | from hash(our call), drawn when the call starts |
| Linked, caller | hash(peer) | our callsigns | caller | from hash(our call) |
| Linked or answering, answerer | hash of our callsign the caller addressed | our callsigns | answerer | from hash(peer) once known |

**Connect codes**: once the peer is known, BREAK and IDLE are redrawn: offsets answerer `1078`, caller
`850`; per side and format, `seed_rnd(f + connect_seed + offset)`, then draw BREAK, then IDLE, both with the
session bandwidth's family.

**Unproto codebook** (CQ and KISS, decodable by anyone): any codebook with link seed 0 on the caller side.
The unproto codes (45, 47, 48, 58) depend only on their fixed seeds, the side offset and family 1, so the
callsign hashes and the bandwidth make no difference to them.

**Tuning tone**: 70 symbols of bin 64 at half the amplitude of a control tone (`sin(2π·64·n/2048) / norm`,
then the current format's control gain), then 24 silent symbols. When the tuning-tone option is on it replaces
the first transmission in the answering state *(circumstances otherwise unconfirmed)*.

# 7. Data levels

Each level is a waveform, a bit depth, a turbo code rate and an information length *K* in bits. The rate
index *r* selects the code rate num/den: 2 → 1/3, 3 → 1/2, 4 → 2/3, 6 → 4/5, 7 → 5/6 (index 5 → 3/4 is used
by no level). With *N* coded bits per frame, `K = floor((N - 12) / den) × num` (12 = the four tail bits of
each of the three tail steps), and the frame is `floor(K / 8)` bytes, including 3 bytes of overhead
(control byte and CRC). When *K* is not a multiple of 8, the last `K mod 8` information bits are zero.

Every table has 17 rows and all 17 are fully derived by both stations. Rows marked `*` are special rows past
the ladder: at 500 Hz, row 15 is the CQ callsign frame (it has no control byte, so its payload is
frame − 2 = 6 bytes); row 14 (a PSK row) and rows 16–17, and row 17 at 2300 Hz, have no known use.

"Step thr" = `snr_thr - (9.4 - papr)`, computed in double and stored as float32; it is the threshold used
by the speed rules (§10). "Ctrl fmt" = the control format replies use at that level (§10.6): the last of
F0, F1, F2 whose control threshold does not exceed the level's step threshold (float32 comparison; at
2300 and 2750 Hz L5 the two are exactly equal, giving F2).

Derived columns:
- coded bits N = data cells × bps, with data cells per frame: FSK `symbols - 1 - 24`; PSK and non-QAM OFDM
  `carriers × (symbols - 2 - markers)`; QAM OFDM `carriers × (symbols - 1 - markers) - pilots`, where
  pilots counts the pilot cells of §9.3 on the level's subcarriers for symbols 2 .. symbols;
- pad = N minus the punctured length (§8.3);
- lead-in = `ceil(80 ms / symbol)`, or `ceil(120 ms / symbol)` when bps ≥ 4 (this includes the 16-tone
  FSK levels, not only the QAM depths);
- symbol time: FSK and PSK `sps / 3000` s; OFDM `1.125 × 64 / 3000` s (24 ms);
- Airtime is nominal: `(lead-in + symbols - 1 + flush) × symbol time`, with flush = `round(2 × pulse span)`
  for PSK and 0 otherwise. The real PSK burst is a little longer (§9.2).
- Net bit/s = `8 × frame bytes / ((symbols - 1) × symbol time)`, rounded.
- Amp norm is the float32 value of the decimal constant shown.

### 500 Hz (13 levels; QAM limit L15; start maximum L7)

| L | Waveform | Layout | bps | Rate idx (punct. p) | K bits | Frame B | Payload B | N coded | Pad | Lead-in sym | Symbol ms | Airtime s | Net bit/s | SNR thr dB | PAPR dB | Step thr | Skip↓ | Amp norm | Ctrl fmt |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | FSK | 125 sym, sps 128@3k, bins 54..74 step 2 | 3 | 2 (1) | 96 | 12 | 9 | 300 | 0 | 2 | 42.67 | 5.376 | 18 | -13.6 | 3 | -20.0 |  | 1.41 | F0 |
| 2 | FSK | 229 sym, sps 64@3k, bins 27..37 step 1 | 3 | 2 (1) | 200 | 25 | 22 | 612 | 0 | 4 | 21.33 | 4.949 | 41 | -11.2 | 3 | -17.6 | yes | 1.41 | F0 |
| 3 | FSK | 227 sym, sps 64@3k, bins 27..37 step 1 | 3 | 3 (2) | 297 | 37 | 34 | 606 | 0 | 4 | 21.33 | 4.907 | 61 | -10.4 | 3 | -16.8 |  | 1.41 | F0 |
| 4 | PSK | 394 sym, 2 carriers [1350, 1650] Hz, RC , 18 markers | 1 | 3 (2) | 368 | 46 | 43 | 748 | 0 | 8 | 10.67 | 4.288 | 88 | -8.4 | 4.4 | -13.4 |  | 0.61 | F1 |
| 5 | PSK | 395 sym, 2 carriers [1350, 1650] Hz, RC , 18 markers | 2 | 3 (2) | 744 | 93 | 90 | 1500 | 0 | 8 | 10.67 | 4.299 | 177 | -5.4 | 4.4 | -10.4 |  | 0.61 | F1 |
| 6 | PSK | 376 sym, 3 carriers [1320, 1500, 1680] Hz, RRC span 2 , 12 markers | 2 | 3 (2) | 1080 | 135 | 132 | 2172 | 0 | 8 | 10.67 | 4.128 | 270 | -3.8 | 7.2 | -6.0 |  | 1.22 | F2 |
| 7 | OFDM | 150 sym, 11 subcarriers from bin 27, 4 markers | 2 | 3 (2) | 1578 | 197 | 194 | 3168 | 0 | 4 | 24.00 | 3.672 | 441 | -1.2 | 8.3 | -2.3 |  | 4.9678 | F2 |
| 8 | OFDM | 150 sym, 11 subcarriers from bin 27, 4 markers | 2 | 4 (4) | 2104 | 263 | 260 | 3168 | 0 | 4 | 24.00 | 3.672 | 588 | 0.6 | 8.3 | -0.5 |  | 4.9678 | F2 |
| 9 | OFDM | 150 sym, 11 subcarriers from bin 27, 4 markers | 2 | 6 (8) | 2524 | 315 | 312 | 3168 | 1 | 4 | 24.00 | 3.672 | 705 | 2.6 | 8.3 | 1.5 |  | 4.9678 | F2 |
| 10 | OFDM | 150 sym, 11 subcarriers from bin 27, 4 markers | 3 | 4 (4) | 3160 | 395 | 392 | 4752 | 0 | 4 | 24.00 | 3.672 | 884 | 5 | 8.2 | 3.8 | yes | 4.9678 | F2 |
| 11 | OFDM | 150 sym, 11 subcarriers from bin 27, 4 markers | 3 | 6 (8) | 3792 | 474 | 471 | 4752 | 0 | 4 | 24.00 | 3.672 | 1060 | 6.4 | 8.2 | 5.2 |  | 4.9678 | F2 |
| 12 | OFDM | 155 sym, 11 subcarriers from bin 27, 4 markers, QAM pilots | 4 | 7 (10) | 4755 | 594 | 591 | 5720 | 2 | 5 | 24.00 | 3.816 | 1286 | 8 | 8.2 | 6.8 |  | 4.21 | F2 |
| 13 | OFDM | 155 sym, 11 subcarriers from bin 27, 4 markers, QAM pilots | 5 | 6 (8) | 5708 | 713 | 710 | 7150 | 3 | 5 | 24.00 | 3.816 | 1543 | 10.6 | 8.2 | 9.4 |  | 4.67 | F2 |
| 14* | PSK | 451 sym, 2 carriers [1350, 1650] Hz, RC , 18 markers | 2 | 3 (2) | 856 | 107 | 104 | 1724 | 0 | 8 | 10.67 | 4.896 | 178 | -5.4 | 4.4 | -10.4 |  | 0.61 | - |
| 15* | FSK | 93 sym, sps 128@3k, bins 54..74 step 2 | 3 | 2 (1) | 64 | 8 | 6 | 204 | 0 | 2 | 42.67 | 4.011 | 16 | -13.6 | 3 | -20.0 |  | 1.41 | - |
| 16* | OFDM | 51 sym, 11 subcarriers from bin 27, 4 markers, QAM pilots | 5 | 6 (8) | 1704 | 213 | 210 | 2145 | 3 | 5 | 24.00 | 1.320 | 1420 | 5.4 | 8.7 | 4.7 |  | 4.67 | - |
| 17* | OFDM | 51 sym, 11 subcarriers from bin 27, 4 markers, QAM pilots | 5 | 6 (8) | 1704 | 213 | 210 | 2145 | 3 | 5 | 24.00 | 1.320 | 1420 | 5.4 | 8.7 | 4.7 |  | 4.67 | - |

Decode allowance (ticks of 64 samples) by level: [168, 135, 154, 142, 150, 150, 199, 204, 204, 212, 230, 236, 259]

### 2300 Hz (16 levels; QAM limit L14; start maximum L6)

| L | Waveform | Layout | bps | Rate idx (punct. p) | K bits | Frame B | Payload B | N coded | Pad | Lead-in sym | Symbol ms | Airtime s | Net bit/s | SNR thr dB | PAPR dB | Step thr | Skip↓ | Amp norm | Ctrl fmt |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | FSK | 125 sym, sps 128@3k, bins 33..96 step 2 | 3 | 2 (1) | 96 | 12 | 9 | 300 | 0 | 2 | 42.67 | 5.376 | 18 | -13.6 | 3 | -20.0 |  | 1.41 | F0 |
| 2 | FSK | 229 sym, sps 64@3k, bins 17..48 step 2 | 3 | 2 (1) | 200 | 25 | 22 | 612 | 0 | 4 | 21.33 | 4.949 | 41 | -11.2 | 3 | -17.6 |  | 1.41 | F0 |
| 3 | FSK | 229 sym, sps 64@3k, bins 17..48 step 2 | 4 | 3 (2) | 402 | 50 | 47 | 816 | 0 | 6 | 21.33 | 4.992 | 82 | -9.4 | 3 | -15.8 |  | 1.41 | F0 |
| 4 | FSK | 396 sym, sps 32@3k, bins 9..24 step 1 | 4 | 3 (2) | 736 | 92 | 89 | 1484 | 0 | 12 | 10.67 | 4.341 | 175 | -6.6 | 3 | -13.0 |  | 1.41 | F1 |
| 5 | PSK | 376 sym, 3 carriers [900, 1500, 2100] Hz, RC , 12 markers | 2 | 3 (2) | 1080 | 135 | 132 | 2172 | 0 | 8 | 10.67 | 4.096 | 270 | -3.6 | 6.1 | -6.9 |  | 0.75 | F2 |
| 6 | PSK | 365 sym, 4 carriers [750, 1250, 1750, 2250] Hz, RC , 9 markers | 2 | 3 (2) | 1410 | 176 | 173 | 2832 | 0 | 8 | 10.67 | 3.979 | 363 | -2.4 | 7.1 | -4.7 |  | 0.86 | F2 |
| 7 | PSK | 355 sym, 6 carriers [700, 1020, 1340, 1660, 1980, 2300] Hz, RRC span 2 , 6 markers | 2 | 3 (2) | 2076 | 259 | 256 | 4164 | 0 | 8 | 10.67 | 3.904 | 549 | -0.6 | 8.5 | -1.5 | yes | 1.73 | F2 |
| 8 | PSK | 352 sym, 8 carriers [702, 930, 1158, 1386, 1614, 1842, 2070, 2298] Hz, RRC span 2 , 5 markers | 2 | 3 (2) | 2754 | 344 | 341 | 5520 | 0 | 8 | 10.67 | 3.872 | 735 | 0.4 | 8.6 | -0.4 | yes | 2 | F2 |
| 9 | PSK | 349 sym, 10 carriers [555, 765, 975, 1185, 1395, 1605, 1815, 2025, 2235, 2445] Hz, RRC span 1 , 4 markers | 2 | 3 (2) | 3424 | 428 | 425 | 6860 | 0 | 8 | 10.67 | 3.819 | 922 | 1.3 | 8.9 | 0.8 |  | 2.23 | F2 |
| 10 | OFDM | 150 sym, 49 subcarriers from bin 8, 1 markers | 2 | 3 (2) | 7197 | 899 | 896 | 14406 | 0 | 4 | 24.00 | 3.672 | 2011 | 5.4 | 9.4 | 5.4 |  | 10.44435 | F2 |
| 11 | OFDM | 150 sym, 49 subcarriers from bin 8, 1 markers | 2 | 4 (4) | 9596 | 1199 | 1196 | 14406 | 0 | 4 | 24.00 | 3.672 | 2682 | 7.2 | 9.4 | 7.2 | yes | 10.44435 | F2 |
| 12 | OFDM | 150 sym, 49 subcarriers from bin 8, 1 markers | 2 | 6 (8) | 11512 | 1439 | 1436 | 14406 | 4 | 4 | 24.00 | 3.672 | 3219 | 8.5 | 9.4 | 8.5 |  | 10.44435 | F2 |
| 13 | OFDM | 150 sym, 49 subcarriers from bin 8, 1 markers | 3 | 4 (4) | 14398 | 1799 | 1796 | 21609 | 0 | 4 | 24.00 | 3.672 | 4025 | 11.2 | 9.4 | 11.2 |  | 10.44435 | F2 |
| 14 | OFDM | 150 sym, 49 subcarriers from bin 8, 1 markers | 3 | 6 (8) | 17276 | 2159 | 2156 | 21609 | 2 | 4 | 24.00 | 3.672 | 4830 | 13.2 | 9.4 | 13.2 | yes | 10.44435 | F2 |
| 15 | OFDM | 155 sym, 49 subcarriers from bin 8, 1 markers, QAM pilots | 4 | 7 (10) | 21710 | 2713 | 2710 | 26068 | 4 | 5 | 24.00 | 3.816 | 5872 | 14.2 | 9.3 | 14.1 |  | 8.82035 | F2 |
| 16 | OFDM | 155 sym, 49 subcarriers from bin 8, 1 markers, QAM pilots | 5 | 6 (8) | 26056 | 3257 | 3254 | 32585 | 3 | 5 | 24.00 | 3.816 | 7050 | 17.2 | 9.3 | 17.1 |  | 10.01805 | F2 |
| 17* | OFDM | 51 sym, 11 subcarriers from bin 27, 4 markers, QAM pilots | 5 | 6 (8) | 1704 | 213 | 210 | 2145 | 3 | 5 | 24.00 | 1.320 | 1420 | 5.4 | 8.7 | 4.7 |  | 4.67 | - |

Decode allowance (ticks of 64 samples) by level: [162, 140, 148, 148, 150, 164, 172, 176, 190, 263, 303, 319, 365, 415, 480, 556]

### 2750 Hz (17 levels; QAM limit L15; start maximum L6)

| L | Waveform | Layout | bps | Rate idx (punct. p) | K bits | Frame B | Payload B | N coded | Pad | Lead-in sym | Symbol ms | Airtime s | Net bit/s | SNR thr dB | PAPR dB | Step thr | Skip↓ | Amp norm | Ctrl fmt |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | FSK | 125 sym, sps 128@3k, bins 24..103 step 2 | 3 | 2 (1) | 96 | 12 | 9 | 300 | 0 | 2 | 42.67 | 5.376 | 18 | -13.6 | 3 | -20.0 |  | 1.41 | F0 |
| 2 | FSK | 229 sym, sps 64@3k, bins 12..51 step 2 | 3 | 2 (1) | 200 | 25 | 22 | 612 | 0 | 4 | 21.33 | 4.949 | 41 | -11.2 | 3 | -17.6 |  | 1.41 | F0 |
| 3 | FSK | 229 sym, sps 64@3k, bins 12..51 step 2 | 4 | 3 (2) | 402 | 50 | 47 | 816 | 0 | 6 | 21.33 | 4.992 | 82 | -9.4 | 3 | -15.8 |  | 1.41 | F0 |
| 4 | FSK | 396 sym, sps 32@3k, bins 6..25 step 1 | 4 | 3 (2) | 736 | 92 | 89 | 1484 | 0 | 12 | 10.67 | 4.341 | 175 | -6.6 | 3 | -13.0 |  | 1.41 | F1 |
| 5 | PSK | 376 sym, 3 carriers [600, 1500, 2400] Hz, RC , 12 markers | 2 | 3 (2) | 1080 | 135 | 132 | 2172 | 0 | 8 | 10.67 | 4.096 | 270 | -3.6 | 6.1 | -6.9 |  | 0.75 | F2 |
| 6 | PSK | 365 sym, 4 carriers [510, 1170, 1830, 2490] Hz, RC , 9 markers | 2 | 3 (2) | 1410 | 176 | 173 | 2832 | 0 | 8 | 10.67 | 3.979 | 363 | -2.4 | 7.1 | -4.7 |  | 0.86 | F2 |
| 7 | PSK | 355 sym, 6 carriers [450, 870, 1290, 1710, 2130, 2550] Hz, RRC span 2 , 6 markers | 2 | 3 (2) | 2076 | 259 | 256 | 4164 | 0 | 8 | 10.67 | 3.904 | 549 | -0.6 | 8.4 | -1.6 | yes | 1.73 | F2 |
| 8 | PSK | 352 sym, 8 carriers [380, 700, 1020, 1340, 1660, 1980, 2300, 2620] Hz, RRC span 2 , 5 markers | 2 | 3 (2) | 2754 | 344 | 341 | 5520 | 0 | 8 | 10.67 | 3.872 | 735 | 0.4 | 8.7 | -0.3 | yes | 2 | F2 |
| 9 | PSK | 349 sym, 10 carriers [375, 625, 875, 1125, 1375, 1625, 1875, 2125, 2375, 2625] Hz, RRC span 1 , 4 markers | 2 | 3 (2) | 3424 | 428 | 425 | 6860 | 0 | 8 | 10.67 | 3.819 | 922 | 1.3 | 8.8 | 0.7 | yes | 2.23 | F2 |
| 10 | PSK | 349 sym, 13 carriers [240, 450, 660, 870, 1080, 1290, 1500, 1710, 1920, 2130, 2340, 2550, 2760] Hz, RRC span 1 , 3 markers | 2 | 3 (2) | 4466 | 558 | 555 | 8944 | 0 | 8 | 10.67 | 3.819 | 1203 | 2.3 | 8.8 | 1.7 |  | 2.5422 | F2 |
| 11 | OFDM | 150 sym, 59 subcarriers from bin 3, 1 markers | 2 | 3 (2) | 8667 | 1083 | 1080 | 17346 | 0 | 4 | 24.00 | 3.672 | 2423 | 6 | 9.3 | 5.9 |  | 11.4219 | F2 |
| 12 | OFDM | 150 sym, 59 subcarriers from bin 3, 1 markers | 2 | 4 (4) | 11556 | 1444 | 1441 | 17346 | 0 | 4 | 24.00 | 3.672 | 3230 | 8 | 9.3 | 7.9 | yes | 11.4219 | F2 |
| 13 | OFDM | 150 sym, 59 subcarriers from bin 3, 1 markers | 2 | 6 (8) | 13864 | 1733 | 1730 | 17346 | 4 | 4 | 24.00 | 3.672 | 3877 | 9.3 | 9.4 | 9.3 |  | 11.4219 | F2 |
| 14 | OFDM | 150 sym, 59 subcarriers from bin 3, 1 markers | 3 | 4 (4) | 17338 | 2167 | 2164 | 26019 | 0 | 4 | 24.00 | 3.672 | 4848 | 11.8 | 9.5 | 11.9 |  | 11.4219 | F2 |
| 15 | OFDM | 150 sym, 59 subcarriers from bin 3, 1 markers | 3 | 6 (8) | 20804 | 2600 | 2597 | 26019 | 2 | 4 | 24.00 | 3.672 | 5817 | 14 | 9.5 | 14.1 | yes | 11.4219 | F2 |
| 16 | OFDM | 155 sym, 59 subcarriers from bin 3, 1 markers, QAM pilots | 4 | 7 (10) | 26145 | 3268 | 3265 | 31388 | 2 | 5 | 24.00 | 3.816 | 7074 | 15 | 9.3 | 14.9 |  | 9.6459 | F2 |
| 17 | OFDM | 155 sym, 59 subcarriers from bin 3, 1 markers, QAM pilots | 5 | 6 (8) | 31376 | 3922 | 3919 | 39235 | 3 | 5 | 24.00 | 3.816 | 8489 | 18 | 9.3 | 17.9 |  | 10.9557 | F2 |

Decode allowance (ticks of 64 samples) by level: [150, 118, 140, 136, 136, 144, 152, 164, 172, 180, 276, 315, 340, 415, 450, 535, 636]

The QAM limit is the last of all 17 rows that has no QAM pilots. At 500 Hz the special rows 14 (PSK) and
15 (FSK) count, so the limit there is row 15, above the 13-level ladder; it does not stop climbs into
L12–L13. Decode allowances of the special rows: 500 Hz row 14 → 180, row 15 → 192, rows 16–17 → 391;
2300 Hz row 17 → 391.

# 8. Data frames

## 8.1 Frame layout

```
| payload | [0x14, marker, 0, 0, ...] | [next level] | control | CRC-16 (big-endian) |
```

- Capacity for payload = `frame bytes - 3`, minus 1 more when the "next level" byte is present. (The
  500 Hz CQ row 15 is the exception: 6 payload bytes, no control byte, §12.)
- If the payload does not fill the capacity, it is followed by the terminator `0x14`, then (if room) the
  **marker**, then zeros up to the capacity. A frame whose payload exactly fills the capacity is "full":
  it has no terminator and sets F. With text compression the payload is the compressed bytes.
- **Marker**: the high byte of the CRC-16 of the **calling** station's callsign text (with SSID); `0x00`
  and `0x14` become `0x01`. Both directions use the caller's marker. The caller computes it from its own
  callsign as configured; the answerer from the callsign text it unpacks from the header frame (§5), so the
  two agree only for callsigns that pack and unpack to the same text *(an SSID written `-0` or with a
  leading zero does not; consequence unconfirmed)*.
- **Receiving**: in a frame without F, the receiver takes the **last** `0x14` in the payload field
  (capacity, less the next-level byte when L is set). It rejects the frame only when the byte after that
  `0x14` is neither the marker nor `0x00` (a `0x14` in the field's final position is accepted). With no
  `0x14` at all the frame is not rejected but delivers nothing. A frame with F delivers the whole field.
  The payload is the bytes before the terminator. **At 500 Hz this check (and the header check of §8.2)
  is not made at all**; frames are accepted on the CRC alone.
- **Next level** byte: the level the sender offers the peer for its next turn (§10.6). It is present
  when the rest of the sender's queued data fits in this frame with the byte reserved (uncompressed:
  remaining ≤ capacity − 1; compressed: every queued byte consumed and the compressed length
  ≤ capacity − 1), i.e. in the last frame of the turn. The first frame of a two-frame transmission never
  carries it; the second carries it when the remainder fits (an empty second frame then carries just the
  terminator, marker and this byte).
- **Control byte**: `RR C HHH L F` (MSB first): RR = control format the receiver should reply in (0–2);
  C = payload is text-compressed (only ever set on the first or only frame of a transmission; the second
  frame of a pair always has C = 0); HHH = queue bucket "hint" 0–6 (§10.5); L = next-level byte present;
  F = frame full.
- **CRC** covers every byte before it.
- A last frame (L set, C clear) whose payload is exactly `FQ\r` is a B2F end-of-session request (§10.9).

## 8.2 Header frame

The caller's first data frame carries no payload but identifies it. Its 8-byte payload is
`packed callsign (6) | 0x00 | flags`; it is sent with the next-level byte (the offered level), so the
frame is `payload (8) | [0x14 marker 0 ...] | offered level | control | CRC`. At a level whose capacity is
exactly 8 bytes (every bandwidth's L1, 12-byte frames) the header fills the frame: no terminator, F set.

flags = `0x80 | encryption << 4 | compression << 1 | registered`:
- bit 7 is always 1; a receiver refuses a header without it *(refusal code unconfirmed)*;
- bits 4–5: the sender's encryption setting, sent only when its callsign passes a fixed eligibility test,
  else 0. A non-zero value changes how payloads are handled; that transform is not covered here;
- bits 1–2: compression 0 off, 1 text, 2 files. An unregistered station always sends 0, whatever its
  setting; the receiver adopts the value for the session;
- bit 0: registered.

A receiver requires L set, C clear, byte 6 = 0 and a payload of exactly 8 bytes (terminator at byte 8,
or a full frame of capacity 8) — except at 500 Hz, where these checks are skipped (§8.1). The
**registered** bit matters: a peer limits an unregistered station to level 4.

## 8.3 Forward error correction

1. Frame bytes to bits, MSB first, zero-padded to *K*.
2. XOR with the whitening sequence from index 0 (the same sequence for every frame).
3. **Turbo code**: two identical 8-state recursive systematic encoders, the second fed `info[perm[i]]`
   (turbo interleaver). Encoder registers r0, r1, r2 start at 0; per input bit *u*:
   `fb = u ⊕ r0 ⊕ r1`, systematic = *u*, parity = `fb ⊕ r2 ⊕ r0`, then `(r0, r1, r2) = (r1, r2, fb)`.
   Three tail bits per encoder drive it to zero (`u = r0 ⊕ r1`).
4. **Puncturing** with period *p* from the rate index (2→1, 3→2, 4→4, 6→8, 7→10; index 5 would be 6 but no
   level uses it *(unconfirmed)*): for each data step *t*, emit systematic, then encoder-1 parity if `p = 1`
   or `t mod p = 0`, then encoder-2 parity if `p = 1` or `t mod p = p/2`. Then for each of the 3 tail steps
   emit sys1, par1, sys2, par2 (unpunctured). Pad with zeros to N (0–4 bits).
5. **Channel interleave**: output bit *i* = coded bit `chan[i]`.

## 8.4 Bursts

A transmission is the lead-in followed by one frame, or two frames back to back (two-frame mode, §10.4),
without a second lead-in: the second frame's symbols follow the first frame's last symbol directly, and
each frame keeps its own per-frame structure (reference symbols, pilots, marker positions, phase-table
indices restarting at 0). Lead-in content is random and need not be reproduced by the receiver.

# 9. Waveforms

All data audio is divided by the level's amplitude normaliser, multiplied by the drive gain of §2 (each
product stored as float32), then clipped to ±1.0.

## 9.1 FSK (levels 1–3 at 500 Hz, 1–4 at 2300/2750; 500 Hz row 15)

- Tone bins are at `3000 / sps` Hz spacing (48 kHz symbols of `16 × sps` samples, no prefix).
- Data symbol *i* (of `symbols - 1`): offset *t* = the pilot value if the symbol is a pilot, else
  `GRAY[next bps bits]` with `GRAY = [0,1,3,2,7,6,4,5,15,14,12,13,8,9,11,10]` (its first 2^bps entries);
  bin = `first + (hop[i] + step × t - first) mod nbins`, with the level's tone step (1 or 2, "step" in §7).
- Lead-in: `lead_in` symbols with random offsets `draw(2^bps)` (not Gray-mapped) on hop bases `hop[1..]`.
  In a two-frame burst a lead-in is drawn for each frame and only the last one is sent.
- Audio: each symbol `2·sin(2π·bin·n / (16·sps))`, *n* restarting every symbol; symbols are not
  cross-faded; the last `16·sps/32` samples of the burst are tapered by a falling half-cosine.

## 9.2 PSK (levels 4–6 at 500 Hz, 5–9 at 2300, 5–10 at 2750; 500 Hz row 14)

- 93.75 baud: 32 samples per symbol at 3000 Hz. Constellations: BPSK `{1, -1}`; QPSK `{1, j, -j, -1}`;
  8PSK `{1, e^jπ/4, e^j3π/4, j, e^-jπ/4, -j, -1, e^-j3π/4}`, indexed MSB first.
- **Differential**, per carrier *c*: symbol 0 is a random reference *d* (`draw(2^bps)`); for
  *s* = 1 .. spf-2: if it is a marker position, *d* repeats (no data); otherwise `d ×= point(next bps bits)`
  (marker positions are never below 5). Each transmitted symbol is `d × conj(phasor_PSK[c][s]) × 178`.
- Lead-in symbols: random points `× conj(phasor[c][k]) × 178`. Draw order: one reference per frame per
  carrier, then the lead-in (per symbol, per carrier).
- **Pulse shaping** at 3000 Hz, all taps used. A level with pulse span 0.5 uses the raised cosine, spans 1
  and 2 the root-raised cosine:
  - raised cosine, *n* = -16..16, *T* = 16: `h(0) = 1`; `h(±8) = 0.5`; otherwise with `x = n/16`:
    `h = sin(πx)·cos(πx) / (πx·(1 - 4x²))`, numerator and denominator each rounded to float32 before
    the division, the result stored as float32;
  - root-raised cosine, span *S* (1 or 2), *T* = 32, *n* = -32S..32S: `h(0) = 4/π`;
    `h(±8) = (1/√2)·((1 + 2/π)·sin(π/4) + (1 - 2/π)·cos(π/4))`; otherwise with `x = n/32`:
    `h = 4x·cos(2πx) / (πx·(1 - 16x²))`, rounded the same way.
- **Interpolation taps** (48 kHz), *i* = 0..31, `m = i - 16`, `f = float32(125/48000)`:
  `h = 2f` if *m* = 0 else `sin(2πf·m)/(π·m)`; `w = float32(0.54 - 0.46·cos(2π·i/32))`; tap =
  `float32(h·w)`. (The window is symmetric about *i* = 16, so the same filter can be written with
  *i* = 1..32 and a one-sample shift.)
- Interpolate ×16 (zero-stuffing) and filter with these 32 taps; carrier start delays at 3000 Hz:
  3 carriers 0, 11, 21 samples (`round(32·c/3 + 1) - 1`); otherwise odd carriers 16, even carriers 0.
  Mix up with a float32 phase accumulator (step `2π·fc/48000`, added before each sample, wrapped when
  above 2π): `Re{v·e^jφ}`. Sum the carriers.
- One zero symbol and the filter tails close the burst: per carrier, `(lead-in + frames × (spf - 1) + 1)
  × 32 + delay + taps - 1` samples at 3000 Hz, then ×16 plus 31 interpolation-tail samples at 48 kHz.

## 9.3 OFDM (500 Hz L7–L13, 2300 Hz L10–L16, 2750 Hz L11–L17; special rows 16–17)

- 1024-point FFT at 48 kHz (46.875 Hz bins), 128-sample cyclic prefix: 1152 samples (24 ms) per symbol.
  Subcarriers occupy bins `first .. first + nc - 1` (500: 11 from 27; 2300: 49 from 8; 2750: 59 from 3).
- Cells for rows *r* = 0 .. spf-2 (symbol *s* = r + 2):
  - **PSK depths** (bps ≤ 3), differential: the row for *s* = 2 is the reference `1`; afterwards a marker
    keeps the previous cell (normalised to unit magnitude), otherwise `cell ×= point(bits)`.
  - **QAM depths** (bps 4–5), absolute: pilots are `1` (even bins when `s mod 8 = 2`, odd bins when
    `s mod 8 = 3`; bin parity is that of the absolute FFT bin); a pilot takes precedence over a marker; a
    marker repeats the previous cell normalised; otherwise `point(bits)`.
    16QAM point *v* = `(L[v >> 2], L[v & 3])` with `L = [-0.7778175, -0.2592725, 0.7778175, 0.2592725]`;
    32QAM is a cross built from the magnitudes `A = [0.2121320, 0.6363961, 1.0606602]`: points 0–7 are
    `(A[i], A[q])` for (i, q) = (0,0), (1,0), (1,2), (2,0), (0,1), (1,1), (0,2), (2,1); points 8–15 are
    their complex conjugates, 16–23 the negated conjugates, 24–31 the negations.
  - Every cell is multiplied by `conj(phasor_OFDM[bin][r])`.
- Lead-in rows: random points `draw(2^bps)` per subcarrier (for each subcarrier, all lead-in rows); for
  two-frame bursts three lead-in sets are drawn and the middle one is used.
- Synthesis: unnormalised inverse FFT, sample = `2·Re`; prefix = the last 128 samples. The first 32
  samples of each symbol are cross-faded (falling half-cosine on the old, rising on the new) with the 32
  samples that followed the previous symbol's prefix; before the first symbol those are zero, so the
  burst fades in. The final 32 samples of the burst are tapered.

# 10. ARQ session protocol

Half duplex. Times are in **ticks of 64 samples** (750 per second) unless stated.

## 10.1 States

| State | Meaning |
|---|---|
| Listen | idle, listening for connect requests to our callsigns |
| Answering | sent a connect reply, waiting for the caller's header |
| Receiving | the peer is sending data to us |
| Break | we asked for the turn (BREAK) |
| HeaderSent | caller: header sent, waiting for BREAK/IDLE |
| Sending | we are sending data |
| Qrt | disconnect sent; the station closes as soon as the QRT has been transmitted |
| Calling | caller: sending connect requests |
| IdleSent | sent IDLE, waiting for NO TRAFFIC or BREAK |
| Idle | link up, nothing to send either way |
| FqWait | after receiving a B2F `FQ`, waiting for the peer's QRT |

Each state listens only for some codes; anything else is not decoded:

| State | Codes heard |
|---|---|
| Listen | 26–40 (connect requests); 45, 47, 58 when KISS is enabled |
| Answering | 3, 12, 13, 26–40, 46 |
| Calling | the connect replies |
| HeaderSent, Sending | 1, 2, 3, 5–11, 19, 46, 49, 50 |
| Receiving | 3, 12, 13, 46, 49, 50 |
| Break | 3, 12, 13, 14, 46, 50, 51–57; in chat mode 3, 12, 13, 14, 46, 49, 50 |
| IdleSent | 3, 12, 13, 21, 46, 49 |
| Idle | 3, 46, 49, 50 |
| FqWait | 3, 12, 13, 46 |

## 10.2 Connect

1. **Caller** (Calling): sends the connect request for its bandwidth, alias 0, format F0, with 9 extra
   lead-in symbols on the first attempt only (`round(400 ms / symbol)`). Retries when no reply has ended
   within `codeword(F1) + 32 + allowance` ticks, until the configured retry count is used up, then reports
   UNABLE TO CONNECT.
2. **Listener** (Listen): accepts connect requests to its callsigns on **all three bandwidths** and adopts
   the request's: 500 → 500, 2300 → 2300, 2750 keeps the current one. It replies with the
   connect reply for that bandwidth at its **first level** (§10.6), format F1, 7 extra lead-in symbols
   (`round(300 ms / symbol)`; none in chat mode), and enters Answering. Connect requests are handled in any
   state that hears them: an answerer that hears the request again (its reply was missed) answers again.
3. **Caller** on the reply: switches to the reply's bandwidth, offers a level (§10.6) and sends the
   **header** (§8.2) at the reply's level. Enters HeaderSent. If no answer arrives within the ACK window
   (§10.8) it sends the alternating ACK REQUEST (§10.3) and stays in HeaderSent.
4. **Answerer** on the header: CRC bad → NACK (one level down, skipping skip rows), still Answering; a new
   ACK REQUEST is treated the same way. `valid` clear → REJECT and Qrt. Otherwise **connected**: chat mode
   sends IDLE (→ IdleSent); otherwise BREAK (→ Break) and the answerer may **hold** the turn for its host
   (§10.7).
5. **Caller** in HeaderSent: BREAK → connected, recomputes its offer (§10.6, from this BREAK's SNR) and
   replies with START LEVEL *offered* in the format for its level, enters Receiving; IDLE → connected,
   answers as for any IDLE (§10.7); NACK → resends the header one level down (skipping skip rows).

## 10.3 Data transfer

- **Sender** (Sending) transmits one or two frames at its level; the last frame of the turn carries the
  next-level byte.
- **Receiver** (Receiving): nothing decoded → NACK, step down by the NACK count (§10.5); last frame received
  completely → ends the turn: BREAK (→ Break, or FqWait after a lone `FQ\r`: last frame, not full, single
  frame, payload exactly `FQ\r`), or IDLE in chat mode with an empty queue (→ IdleSent); otherwise
  acknowledges with the code from the step decision (§10.5).
- Receivers deliver payload in order; when the first frame of a pair is lost and the second decodes, the
  second is held behind a hole until the retransmission fills it.
- A BREAK heard while Receiving is answered by repeating the last code in F0; an IDLE by BREAK if data is
  queued, else NO TRAFFIC (→ Idle).
- **No reply**: the sender re-asks with ACK REQUEST, alternating codes 12/13 (an alternating bit, so a
  repeated request is recognised). The first re-ask uses the default control format of one level lower, each
  further one a format more robust; there is no retry limit other than the watchdog. The receiver answers a
  new request with NACK MISSED in a format one step more robust than requested and steps down by the NACK
  MISSED count (§10.5); a repeated request is answered by repeating its last code in F0. Replies to an ACK
  REQUEST are not used for ACK timing.

## 10.4 Two-frame transmissions

A counter counts good uncompressed frames in a row at one level; a failure, a level change or a hint of 2
resets it. When it reaches **6**, the next transmission carries two frames; both ends latch this when they
send (receiver when it replies, sender when it transmits) so they switch together. The first transmission
of a turn is always a single frame. Text-compressed turns never use pairs. Partial results: second frame
lost → ACK FIRST ONLY; first lost → ACK SECOND ONLY; both step down one level (the sender only above
level 1). If the first frame of the pair already ended the turn, a lost second frame is answered with BREAK.

## 10.5 Speed decisions

- **Queue bucket** (control byte hint): with the bytes still queued after this frame, first for
  one frame then for two: 0 if they would fit one level down; 2 (one frame) or 1 (two frames) if they fit at
  this level; 3–6 if they need 1–4 levels up; 6 otherwise. "Fits": `queued ≤ frames × capacity - 1`; with
  text compression, by actually compressing (input window `3 × capacity + 39` bytes).
- **Hint overrides** (one frame only, set at the start of a turn, §10.7): *maximum* sends 6; *table minimum*
  sends at least the first step *s* = −1..3 for which `capacity(L) + capacity(L + s)` reaches the capacity
  of the start maximum (one lower with compression), coded 0 for *s* = −1 and `s + 2` otherwise, else 6.
- **Receive history** (losses counted in states Answering and Receiving only): margin starts at 2 dB, decay
  `0.5/15`. Good frame: run += 1, `margin = max(margin - decay, 1.5)`, QAM frame → "QAM seen", climbing
  (level above the previous frame's) clears the failed-climb count. Lost frame at or above the last good
  level, above level 1 and with a run of at least one: `margin += 1`; climbing adds
  `4 × failed climbs`; a run under 15 adds `3 × (15 - run) / 15`; decay becomes `(new - old) / 15`; first
  QAM loss before any QAM success sets "QAM lost first". Every lost frame then sets run = 0, and climbing
  counts a failed climb. All in float32.
- **Step decision**: margins for staying (0) and climbing *d* = 1..4:
  `m_d = snr - step_thr(level + d) - margin - max(d - 1, 0)`, disabled when beyond the top, or (*d* ≥ 2)
  above the QAM limit or after any failed climb, or (*d* = 1) above the QAM limit after a QAM-first loss.
  QAM limit = last of all 17 rows without QAM pilots (§7): **500: row 15, 2300: L14, 2750: L15**; at 500 Hz
  it lies above the ladder, so these two tests never disable a climb there. Then, from *d* = 4 down
  to 1: climb by *d* if `level + d ≤ ceiling`, `m_d > 0` and `hint ≥ d + 2` (codes UP1 7, UP2 5, UP3 8,
  UP4 9). Otherwise ACK DOWN if level > 1 and (`m_0 < 0` or hint = 0); otherwise ACK STAY (hint 2 also
  resets the pair counter). **Ceiling**: the top level for a registered peer, **level 4 otherwise**.
- **Upward steps**: the number of levels climbed since the last ACK STAY or the start of the state.
- **Sender on ACK**: UP *d* / DOWN / STAY move the level (clamped 1..top). NACK and NACK MISSED step down by
  3 after six or more upward steps, 2 after four or five, 2 for NACK MISSED above level 1, else 1;
  then if the new level is a skip row, one more down. The receiver applies the same counts when it sends
  NACK (nothing decoded) or NACK MISSED. NACK MISSED is sent in a more robust format, so the sender's next
  request (§10.6) follows the new control-frame SNR.

## 10.6 Levels at connect and per turn

- **Answerer's first level**: from the request's normalised SNR, try levels 2, 3, 4 in order and keep the
  last with `snr - step_thr > max(margin, 6)` (strict, float32), stopping at the first that fails; else 1.
- **Offered level**: try levels from 2 upwards up to the start cap and keep the last with
  `snr - step_thr > max(margin, 3) + penalty`, stopping at the first that fails. Penalty `+1 / +2 / +3 dB`
  for offering 2 / 3 / 4+ levels above the last good one. In HeaderSent (the header's offer and the START
  LEVEL reply) there is no penalty and *snr* is the last control frame's; otherwise *snr* is the data-frame
  SNR trend once data has been received. Start cap: 4 if unregistered; the QAM limit while a B2F `FS`
  proposal is pending (a host write that starts `FS ` and ends `\r`, until the turn carrying it is
  acknowledged); otherwise the bandwidth's start maximum (500: L7, others L6), one lower with text
  compression. The search has no ladder clamp: at 500 Hz with `FS` pending the cap is row 15, and rows 14
  and 15 have step thresholds of -10.4 and -20 dB, so whenever L13 qualifies the offer becomes 15 (not observed on the air).
- **Reply format** for control frames: the receiver uses the format the last data frame's control byte
  requests. The sender requests a format from the control frames it heard: it takes the lower of the last
  two control-frame SNRs and the larger of their missed-symbol counts, and walks F0, F1, F2, keeping the last
  format whose threshold the SNR exceeds and whose miss limit (F0 any, F1 1, F2 0, scaled by the tone-count
  ratio) is not exceeded. The default format for a level is the **least robust** format whose threshold
  `snr - (9.4 - k)` does not exceed the level's step threshold ("Ctrl fmt" in §7).

## 10.7 Turn changes

- **BREAK** asks for the turn. The holder answers GO AHEAD; only the caller in HeaderSent answers START LEVEL
  *n* (its offer for the answerer's first turn). Otherwise the offer for the next turn travels in the
  next-level byte of the last data frame.
- **Both ask at once**: outside chat mode a station in Break does not hear BREAK, so the random back-off
  (§10.8) separates the two. In chat mode the **answerer yields** with GO AHEAD and the caller ignores it.
- **Answerer turn hold**: after the header a non-chat answerer keeps the turn with BREAK while its host
  prepares the first message: up to **3300 ms** with nothing queued (then IDLE), **4500 ms** while the host
  is mid-line, timed from the header. A B2F prompt (`>\r`) or a queue too big for one frame ends the hold.
  When the hold ends with data, the first frame carries the *table minimum* hint unless it ended on a
  prompt. The hold stays armed until the answerer first sends data or IDLE.
- **Small-queue hold**: a station granted the turn whose whole queue fits one frame at the offered level,
  while the offered level is above the start maximum (one lower with compression), answers BREAK again
  instead of sending, once per distinct queue length. When it does send with the offer above that cap, the
  first frame carries the *maximum* hint.
- **IDLE** (nothing to send): the peer answers NO TRAFFIC (→ Idle) or, with data queued, BREAK. In Idle,
  queued host data makes a station take the turn once it has been in Idle for more than 200 ticks; a
  pending disconnect takes it at once. The station that sent IDLE and received NO TRAFFIC polls: every
  10 s without a decoded control it sends IDLE again (→ IdleSent); outside chat mode the 7th poll is a QRT
  instead. The count restarts whenever a turn start or a chat receiver sends IDLE.

## 10.8 Timing

- **Elapsed** for a received control frame: ticks from the end of our transmission to the end of the frame,
  minus the frame's own length (codeword + lead-in).
- **Control allowance**: base 438 (850 in chat/P2P mode); a negative elapsed counts as 548. The value
  measured in Calling (the connect reply) is taken as is; every later measurement (BREAK replies, NO
  TRAFFIC) goes into a running mean (rounded half to even) that excludes it; `allowance = delay + 150`.
  On the first measurement every unmeasured level gets `ack_delay = decode_allow(level) + delay - 100`.
- **ACK windows**: per level, the mean measured ACK delay (a negative elapsed is ignored); unmeasured higher
  levels follow, offset by their decode allowance, up to the first measured one; window = `ack_delay + 400`,
  plus `0.45 × (ack_delay - ctrl_delay)` when positive, computed exactly: the product uses the double
  constant 0.45 (slightly above 0.45), so exact halves round up.
- Decode allowances per level are listed under each table in §7.
- **Reply windows** (no reply after this many ticks → resend): Calling `codeword(F1) + 32 + allowance`;
  HeaderSent and Sending `ACK window(level) + long lead-in + codeword` of the expected reply format, or
  `F0 frame + allowance` after an ACK REQUEST; Break the BREAK back-off; IdleSent `F0 frame + allowance`
  (F0 frame = 1024 ticks).
- **Watchdog**: 30 s unlinked, 60 s linked, restarted by every decoded control frame except CQ/KISS and by
  every data frame; expiry closes the link without a frame.
- **Retries** (connect requests): configurable.
- **BREAK back-off**: `(1..3) × 1024 + 1.5 × base allowance` ticks (rounded to even), drawn anew for every
  BREAK. **FQ wait**: `9 × (1024 + allowance)` ticks, then the link closes without a frame.
- **Disconnect timeouts**: with a disconnect pending, the third reply-window expiry in Break, HeaderSent,
  Sending or IdleSent sends QRT.

## 10.9 Disconnect

QRT (3) or QRT without CW ID (46); the peer closes on receipt. A requested disconnect waits until queued data
is acknowledged; with nothing queued it is sent at the next opportunity: in reply to the next control or data
frame, at once from Idle (via BREAK), and from Receiving if no frame arrives within the expected frames plus
`1.25 × base allowance`. A CW identification follows QRT when the station's own base callsign is a United
States callsign or its own CW-ID option is set, provided the session had connected; the host's `CWID ON/OFF`
does not change this.
B2F: a received lone `FQ\r` makes the receiver wait for the sender's QRT (FqWait); `FS ...\r` from the host
raises the start cap (§10.6).

# 11. Text compression

`COMPRESSION TEXT`: a phrase-Huffman coder with **8 states** (code tables in Appendix A). Each state has
a 3-bit start code (its number − 1), phrase entries (phrase, bit code, next state; 0 = stay) and either an
escape code (switch state without output) or a single-byte entry for every byte value (state 3). All codes
of a state, escape included, form a prefix-free set of at most 10 bits.

**Encoding** one frame of capacity *c* bytes (the full payload capacity, without the next-level
reservation):
- The input is at most `3c + 39` queued bytes.
- Output starts with the 3-bit code of the **current** state. The state is reset to 1 when a turn starts;
  later frames of the turn start in the state the previous frame ended in (a resent frame restarts from
  the state its first transmission started in).
- Then codes are matched **greedily in table order**: the first entry whose whole phrase matches at the
  current position, not the longest; if none matches, the escape code (no input consumed).
- A code that would not fit in `8c` bits is not written and encoding stops, but its state change still
  happens (the next frame starts in that state).
- Padding: the complement of the last bit, repeated to the byte boundary; if the output is already
  aligned, a whole byte. If that byte does not fit, the last code (and its state change) is removed and
  the output is padded again.

**Per turn**: the compressor is tried on the first `min(queued, 150)` bytes from state 1 with capacity
equal to that length; the turn is compressed only if this consumes more bytes than it writes. Compression
is used only when the session's compression is text, and not for a final frame whose rest fits
uncompressed with the next-level byte; such a frame is sent uncompressed with C clear. Only single-frame
transmissions are compressed (§10.4).

**Decoding** a frame with C set (only when the session's compression is text): strip the final run of
equal bits (the padding), read the 3-bit start state, then repeatedly follow escape codes and take the
first entry whose code matches, until the bits run out. The decoder never carries state between frames.
Output is limited to `3 × (payload length + 39) + 1` bytes; on overflow the raw compressed bytes are
delivered instead and a compression error is logged, without ending the session; when no code matches,
the text decoded so far is delivered *(unconfirmed)*. The first frame of a two-frame transmission is not
inflated even if C were set *(unconfirmed)*.

# 12. CQ frames and unproto broadcasts

## 12.1 CQ frames

A CQ is the CQ control frame (code 48, unproto codebook, F0), **1920 samples** of silence *(unconfirmed)*,
then one 8-byte frame on the **500 Hz table's row 15** (FSK, K = 64): the callsign packed in 6 bytes (base
padded to 7 characters, 6 bits each in the alphabet `" A-Z0-9"`, then `bandwidth_code × 16 + ssid`,
bandwidth code 1 = 500, 2 = 2300, 3 = 2750), then CRC-16. Receivers that hear the control frame look for the
callsign frame within 4 lead-ins plus one frame airtime. The CQ control frame is decoded **only in chat
mode** (`CHAT ON` or `LISTEN CQ`); the station then reports `SN x` and `CQFRAME <call> <bw>`. Sending a CQ
does not need chat mode.

## 12.2 Unproto broadcasts (KISS)

*Status of this section: taken from the receive side of a transcription of the reference implementation and
confirmed by decoding 26 broadcast objects received off the air (23 single-block command-2 objects and three
two-block AX.25 messages, at levels 1, 2 and 4). It has not had the claim-by-claim check the other sections
had, and the transmit side (how a sender chooses the packing) is not covered.*

A broadcast is connectionless: no connect, no acknowledgement. A host hands the modem a KISS frame on the
KISS TCP port (§13); the modem packs it into an **object**, cuts the object into **blocks** and sends an
announcement control frame followed by one data frame per block. A receiving modem rebuilds the object and
hands its own KISS client the equivalent KISS frame. The KISS framing itself is never sent.

**On the air.** The announcement is control code 45, 47 or 58 (unproto codebook, §6.4), meaning the blocks
follow at level 1, 2 or 4 of the **500 Hz** table, whatever bandwidth the stations otherwise use. Each block
is an ordinary data frame of that level (§8.1). The block is the payload field when the frame is full (F
set), otherwise the bytes before the **last** `0x14` in the field. An empty block is ignored. A receiver
only takes blocks while a KISS client is connected.

**Block byte 0 (flags):**

| Bits | Meaning |
|---|---|
| 7 (`0x80`) | more blocks of this object follow |
| 6 (`0x40`) | commands 0/1: the AX.25 control and PID bytes `03 F0` follow the addresses |
| 5–4 (`0x30`) | command: 0 = AX.25 with 6-character addresses, 1 = AX.25 with 7-character addresses, 2 = raw payload, 3 = same command as the previous object |
| 3 (`0x08`) | commands 0/1: digipeaters present |
| 2–0 | commands 0/1: digipeater count − 1 (when bit 3 is set); command 2: bit 0 set = 7-bit packing, clear = 8-bit |

**Objects of more than one block.** In the first block, byte 1 is `checksum nibble << 4 | (blocks − 2)`.
The object is byte 0, then the first block from byte 2 on, then every later block from its byte 1 on (each
later block's byte 0 is its own flags byte). When the last block (bit 7 clear) arrives, object byte 0 is
replaced by that block's byte 0, and the object is accepted only if the top four bits of its CRC-16 (§5)
equal the checksum nibble; otherwise nothing is delivered. The announced block count is recorded but not
checked. A one-block object has no check beyond the data frame's own CRC. An object holds at most 5000
bytes. The receiver's assembly is cleared **only by the next announcement control frame**, not by a
delivery or a failed check, so a block whose announcement was missed is appended to whatever was left.

**Object body.** Everything after object byte 0 is one bit string, most significant bit first.

*Command 2 (raw).* The body is cut into 7-bit or 8-bit values (flag bit 0) and delivered as bytes. With
7-bit packing the trailing run of equal bits (the padding) is removed first, as in text compression (§11).

*Commands 0 and 1 (AX.25).* In order:

1. one bit per digipeater: set = "has been repeated";
2. the destination address, then the source address (compact addresses, below);
3. the digipeaters: if there are any, the destination begins with `AP` and the next bit is 1, a 3-bit region
   1–7 follows and digipeater *i* (from 1) is `<REGION><i>-1` with regions `WIDE`, `PNW`, `MW`, `OR`, `WA`
   (regions 6 and 7 have an empty root, giving `<i>-1`; region 0 is an error); otherwise one compact
   address each;
4. a kind selector, 3 bits when the destination begins with `AP`, otherwise 1 bit;
5. the information field, by kind:

| Kind | Information field |
|---|---|
| 0 (and 7) | 7-bit characters (trailing padding run removed) |
| 1 | 8-bit bytes |
| 2 | APRS position: `!` then the position fields and text (below) |
| 3 | APRS position with time: `@`, a 20-bit time as 6 digits, `h`, then as kind 2 |
| 4 | APRS message: `:`, a compact address padded with spaces to 9 characters, `:`, then text |
| 5 | nothing is delivered |
| 6 | third-party: `}`, address, `>`, address, `,TCPIP,`, address, `*:`, then a 2-bit selector *k* (3 → plain text, otherwise kind *k* + 2) and that kind's fields |

The delivered AX.25 frame has each address as 6 (command 0) or 7 (command 1) characters, space padded,
each shifted left one bit, followed by the SSID byte `0x60 | ssid << 1`; the last address has bit 0 set and
a repeated digipeater has `0x80` set in its SSID byte. `03 F0` follows when flag bit 6 is set, then the
information field.

**Compact address.** A 6-bit code selects from `" A-Z0-9!:#$%&'()*+,-./;"` (53 entries):

| First code | Address |
|---|---|
| space, letter or digit | that character, then 6-bit codes from `" A-Z0-9"` until the address width (6 or 7) is reached or a space is read; then a 4-bit SSID, written `-n` when not zero |
| `!` `:` `#` `$` `%` | `WIDE`, `PNW`, `MW`, `OR`, `WA`; then 1 bit (digit − 1) and a suffix: 1 bit, except `WIDE` which reads two bits as two decimal digits; written `<ROOT><digit>` or `<ROOT><digit>-<suffix>` |
| `&` | `ALL` |
| `'` | `CQ` |
| `(` `)` `*` | `APIN` + (4-bit value + 20), `APWW` + (3-bit value + 11), `APDR` + (5-bit value + 16), the number as two digits |
| `+` `,` `-` `.` `/` | the fixed names `APBPQ1`, `APJYC1`, `APOPYT`, `APU25N`, `APVARA` |
| `;` | `AP`, then 6-bit codes as in the first row up to the address width; no SSID |

**Position fields (kinds 2 and 3).** Latitude: 20 bits written as 6 digits with `.` after the fourth, then
1 bit (1 = `N`, 0 = `S`). Symbol table: 1 bit; if set a 3-bit index into `/\IRVTDS`, otherwise a 7-bit
character. Longitude: 21 bits written as 7 digits with `.` after the fifth, then 1 bit (1 = `W`, 0 = `E`).
Symbol: a 7-bit character. Text follows.

**Text (after kinds 2, 3, 4 and 6).** 7-bit codes until fewer than 7 bits remain. Codes 32 and above are
characters. Codes 0–9 are phrases: 0 nothing, 1 `/A=00`, 2 `VARA`, 3 `PinPoint`, 4 `HF ` (with the space),
5 `ack`, 6 `APRS`, 7 `ping{`, 8 `Digi`, 9 `Gate`; codes 10–31 produce nothing. In kinds 2 and 3, phrase 1 is
followed by a 14-bit altitude written as 4 digits (giving `/A=00dddd`).

**Delivery to the host.** The receiver writes `C0 <command> <payload> C0` to its KISS client, command 0, 1
or 2 as above, with `C0` in the payload sent as `DB DC` and `DB` as `DB DD`. On the host side a frame is
accepted when it starts and ends with `C0`, its command byte is at most 2, and for commands 0 and 1 it is at
least 19 bytes long. The station reports `SN x` after a broadcast reception (§13).

What programs put inside command 2 (fixed-layout text records, for example) is their own convention and is
not part of this protocol.

# 13. Host interface (TCP)

Command port 8300 (configurable), data port = command port + 1 (raw bytes both ways). A separate KISS port
(8100 by default) carries unproto broadcasts as KISS frames in both directions (§12.2). One client per port;
a new connection replaces the old one. Lines end in `\r` (a `\n` is ignored); commands are case-sensitive and
their arguments are separated by single spaces. Most commands are answered `OK` or `WRONG`; `VERSION`,
`TUNE ?` and `CLEANTXBUFFER` answer with their own line instead. For LISTEN, DISCONNECT, ABORT, CONNECT,
CQFRAME and COMPRESSION the `OK` comes before the action.

| Command | Effect |
|---|---|
| `MYCALL c1 [c2..c5]` | our callsigns (connect-request aliases 0–4); each must be a valid callsign; while not in Listen it is answered `WRONG` and applied after the next `DISCONNECTED` |
| `LISTEN ON` / `LISTEN OFF` | accept incoming connects (default **off**; also switched off whenever either TCP port is not connected); outside Listen the session is dropped to Listen without a QRT or `DISCONNECTED` |
| `LISTEN CQ` | same as `CHAT ON` |
| `CONNECT src dst` | call `dst`; only in Listen (or Answering) |
| `ABORT` | disconnect at the next opportunity (QRT); before any reply, just stop retrying |
| `DISCONNECT` | QRT once the queued data has been acknowledged; with nothing queued, as `ABORT` |
| `BW500` / `BW2300` / `BW2750` | bandwidth (default 2300); only in Listen |
| `COMPRESSION OFF / TEXT / FILES` (`ON` = `TEXT`) | default TEXT; only the caller's setting is used, and only if it is registered |
| `CHAT ON` / `CHAT OFF` | chat mode: control allowance base 850, no QRT after idle polls, IDLE instead of BREAK when the answerer connects or a received turn ends with nothing queued, CQ reception; ON implies LISTEN ON; only in Listen |
| `CQFRAME src bw` | send a CQ (only in Listen; chat mode not needed) |
| `WINLINK SESSION` / `P2P SESSION` | control allowance base 438 / 850 ticks (default WINLINK) |
| `RETRIES n` | connect-request retry count (0 restores the configured value) |
| `CLEANTXBUFFER` | empty the transmit queue while receiving; answers `CLEANTXBUFFER OK`, `BUFFEREMPTY` or `FAILED` |
| `TUNE n`, `TUNE OFF`, `TUNE ?`, `DRIVELEVEL n` | transmit drive level (−30..0 dB) and tune signal |
| `CWID ON/OFF`, `PUBLIC ON/OFF`, `GATEWAY x`, `GATEWAY OFF` | accepted, no effect |
| `IGNOREKISSDCD ON/OFF` | KISS option |
| `VERSION` | answers `VERSION VARA HF v<version>` |

Asynchronous lines: `CONNECTED src dst bw` (bw `500`/`2300`/`2750`), `DISCONNECTED` (only after a session
that connected or a call that was started; a failed incoming request ends with `CANCELPENDING`), `PTT ON/OFF`,
`BUFFER n` (when acknowledgements retire queued data), `PENDING` (incoming request for our callsign, or a CQ
or KISS send starting), `CANCELPENDING`, `BUSY ON/OFF`, `REGISTERED[ call ...]` and then `ENCRYPTION READY`
or `ENCRYPTION DISABLED` 5 s after MYCALL, `LINK REGISTERED/UNREGISTERED` (answering side, the caller's
status, after CONNECTED), `ENCRYPTED LINK` / `UNENCRYPTED LINK`, `BITRATE (...) n bps`, `IAMALIVE` (every
60 s), `CQFRAME src bw` (chat mode), `SN value` (one decimal; after every good data frame except the first of
a pair, and after KISS and CQ receptions, in every mode), `MISSING SOUNDCARD`.

# 14. Not covered

- "Files" compression (header compression value 2): host data is cut into chunks of up to 32 500 bytes, each
  raw-DEFLATE compressed and sent with a 2-byte length whose top bit marks a compressed chunk; the bitstream
  details are not specified here.
- KISS/unproto broadcasts, transmit side: how a sender chooses the command, the packing and the block
  split for a given host frame. Receiving broadcasts is specified in §12.2.

# Appendix A. Text-compression code tables

Format: `S <state> <start code> <escape code | -> [escape next state]` opens a state; each following
`E <phrase as hex | -> <code bits> <next state>` line is one entry (next state 0 = stay). Codes are written
MSB first.

```
S 1 000 10101101 2
E 3b574c324b2d526164696f2f496e7465726e65745f4e6574776f726b0d 101010 0
E 5b524d5320457870726573732d 010 5
E 524d53205472696d6f646520 0010 5
E 5b524d532052656c61792d 100010 5
E 434d532076696120 1101 8
E 7b534649203d20 0011 4
E 5b574c324b2d 1110 5
E 464320454d20 10010 6
E 3b46573a20 000 8
E 3b50513a20 1011 7
E 3b50523a20 1100 7
E 3b504d3a20 10100 8
E 3b46523a0d 1000111 0
E 5b4250512d 1010111 5
E 2a2a2a20 1000110 8
E 46460d 1111 0
E 463e20 10011 6
E 646520 10101100 8
E 3b20 011 8
E 0a 10000 0
S 2 001 1011101100 3
E 666f7277617264656420746f2074686520726563697069656e742076696120484620726164696f 111010011 0
E 206d696e757465732072656d61696e696e67207769746820 01010001 8
E 207468726f7567682074686520496e7465726e657420 110111000 0
E 20436f6e6e656374656420746f20434d530d 101101101 1
E 57656c636f6d6520746f2074686520 10000110 0
E 20524d53205472696d6f6465 01010010 0
E 20524d532052656c6179 101101111 0
E 202f2f574c324b20 1011110010 0
E 2068617320 01010011 0
E 2056415241 101101001 0
E 203e0d 010100000 1
E 2620 1110100000 0
E 20 011 0
E 69 0001 0
E 72 0010 0
E 61 0100 0
E 65 1001 0
E 75 00000 0
E 63 01011 0
E 6c 10001 0
E 73 10100 0
E 6e 11100 0
E 74 11110 0
E 6f 11111 0
E 66 000010 0
E 62 001100 0
E 0d 001101 1
E 2c 001110 0
E 40 001111 0
E 2e 010101 0
E 67 100000 0
E 6d 101011 0
E 68 101100 0
E 70 110101 0
E 64 111011 0
E 76 0000110 0
E 2d 0000111 0
E 6b 1000010 0
E 77 1010100 0
E 79 1110101 0
E 49 10101010 0
E 52 10101011 0
E 42 10110101 0
E 5a 10111000 0
E 4f 10111001 0
E 4a 10111010 0
E 32 10111101 0
E 35 10111110 0
E 36 10111111 0
E 47 11000000 0
E 44 11000001 0
E 37 11000010 0
E 38 11000011 0
E 4d 11000100 0
E 4c 11000101 0
E 45 11000110 0
E 50 11000111 0
E 33 11001000 0
E 59 11001001 0
E 54 11001010 0
E 57 11001011 0
E 51 11001100 0
E 34 11001101 0
E 53 11001110 0
E 31 11001111 0
E 46 11010000 0
E 55 11010001 0
E 39 11010010 0
E 4e 11010011 0
E 43 11011000 0
E 4b 11011001 0
E 41 11011010 0
E 48 11011011 0
E 30 11011101 0
E 56 11011110 0
E 58 11011111 0
E 3a 010100001 0
E 2a 110111001 0
E 3c 1000011100 0
E 3d 1000011101 0
E 23 1000011110 0
E 24 1000011111 0
E 5b 1011010000 0
E 5c 1011010001 0
E 5d 1011011000 0
E 5f 1011011001 0
E 21 1011011100 0
E 22 1011011101 0
E 3b 1011101101 0
E 3e 1011101110 0
E 3f 1011101111 0
E 28 1011110000 0
E 29 1011110001 0
E 2f 1011110011 0
E 27 1110100001 0
E 6a 1110100010 0
E 71 1110100011 0
E 78 1110100100 0
E 7a 1110100101 0
S 3 010 - 0
E 00 00000000 0
E 01 00000001 0
E 02 00000010 0
E 03 00000011 0
E 04 00000100 0
E 05 00000101 0
E 06 00000110 0
E 07 00000111 0
E 08 00001000 0
E 09 00001001 0
E 0a 00001010 0
E 0b 00001011 0
E 0c 00001100 0
E 0d 00001101 1
E 0e 00001110 0
E 0f 00001111 0
E 10 00010000 0
E 11 00010001 0
E 12 00010010 0
E 13 00010011 0
E 14 00010100 0
E 15 00010101 0
E 16 00010110 0
E 17 00010111 0
E 18 00011000 0
E 19 00011001 0
E 1a 00011010 0
E 1b 00011011 0
E 1c 00011100 0
E 1d 00011101 0
E 1e 00011110 0
E 1f 00011111 0
E 20 00100000 2
E 21 00100001 2
E 22 00100010 2
E 23 00100011 2
E 24 00100100 2
E 25 00100101 0
E 26 00100110 0
E 27 00100111 2
E 28 00101000 2
E 29 00101001 2
E 2a 00101010 2
E 2b 00101011 0
E 2c 00101100 2
E 2d 00101101 2
E 2e 00101110 2
E 2f 00101111 2
E 30 00110000 2
E 31 00110001 2
E 32 00110010 2
E 33 00110011 2
E 34 00110100 2
E 35 00110101 2
E 36 00110110 2
E 37 00110111 2
E 38 00111000 2
E 39 00111001 2
E 3a 00111010 2
E 3b 00111011 2
E 3c 00111100 2
E 3d 00111101 2
E 3e 00111110 2
E 3f 00111111 2
E 40 01000000 2
E 41 01000001 2
E 42 01000010 2
E 43 01000011 2
E 44 01000100 2
E 45 01000101 2
E 46 01000110 2
E 47 01000111 2
E 48 01001000 2
E 49 01001001 2
E 4a 01001010 2
E 4b 01001011 2
E 4c 01001100 2
E 4d 01001101 2
E 4e 01001110 2
E 4f 01001111 2
E 50 01010000 2
E 51 01010001 2
E 52 01010010 2
E 53 01010011 2
E 54 01010100 2
E 55 01010101 2
E 56 01010110 2
E 57 01010111 2
E 58 01011000 2
E 59 01011001 2
E 5a 01011010 2
E 5b 01011011 2
E 5c 01011100 2
E 5d 01011101 2
E 5e 01011110 0
E 5f 01011111 2
E 60 01100000 0
E 61 01100001 2
E 62 01100010 2
E 63 01100011 2
E 64 01100100 2
E 65 01100101 2
E 66 01100110 2
E 67 01100111 2
E 68 01101000 2
E 69 01101001 2
E 6a 01101010 2
E 6b 01101011 2
E 6c 01101100 2
E 6d 01101101 2
E 6e 01101110 2
E 6f 01101111 2
E 70 01110000 2
E 71 01110001 2
E 72 01110010 2
E 73 01110011 2
E 74 01110100 2
E 75 01110101 2
E 76 01110110 2
E 77 01110111 2
E 78 01111000 2
E 79 01111001 2
E 7a 01111010 2
E 7b 01111011 0
E 7c 01111100 0
E 7d 01111101 0
E 7e 01111110 0
E 7f 01111111 0
E 80 10000000 0
E 81 10000001 0
E 82 10000010 0
E 83 10000011 0
E 84 10000100 0
E 85 10000101 0
E 86 10000110 0
E 87 10000111 0
E 88 10001000 0
E 89 10001001 0
E 8a 10001010 0
E 8b 10001011 0
E 8c 10001100 0
E 8d 10001101 0
E 8e 10001110 0
E 8f 10001111 0
E 90 10010000 0
E 91 10010001 0
E 92 10010010 0
E 93 10010011 0
E 94 10010100 0
E 95 10010101 0
E 96 10010110 0
E 97 10010111 0
E 98 10011000 0
E 99 10011001 0
E 9a 10011010 0
E 9b 10011011 0
E 9c 10011100 0
E 9d 10011101 0
E 9e 10011110 0
E 9f 10011111 0
E a0 10100000 0
E a1 10100001 0
E a2 10100010 0
E a3 10100011 0
E a4 10100100 0
E a5 10100101 0
E a6 10100110 0
E a7 10100111 0
E a8 10101000 0
E a9 10101001 0
E aa 10101010 0
E ab 10101011 0
E ac 10101100 0
E ad 10101101 0
E ae 10101110 0
E af 10101111 0
E b0 10110000 0
E b1 10110001 0
E b2 10110010 0
E b3 10110011 0
E b4 10110100 0
E b5 10110101 0
E b6 10110110 0
E b7 10110111 0
E b8 10111000 0
E b9 10111001 0
E ba 10111010 0
E bb 10111011 0
E bc 10111100 0
E bd 10111101 0
E be 10111110 0
E bf 10111111 0
E c0 11000000 0
E c1 11000001 0
E c2 11000010 0
E c3 11000011 0
E c4 11000100 0
E c5 11000101 0
E c6 11000110 0
E c7 11000111 0
E c8 11001000 0
E c9 11001001 0
E ca 11001010 0
E cb 11001011 0
E cc 11001100 0
E cd 11001101 0
E ce 11001110 0
E cf 11001111 0
E d0 11010000 0
E d1 11010001 0
E d2 11010010 0
E d3 11010011 0
E d4 11010100 0
E d5 11010101 0
E d6 11010110 0
E d7 11010111 0
E d8 11011000 0
E d9 11011001 0
E da 11011010 0
E db 11011011 0
E dc 11011100 0
E dd 11011101 0
E de 11011110 0
E df 11011111 0
E e0 11100000 0
E e1 11100001 0
E e2 11100010 0
E e3 11100011 0
E e4 11100100 0
E e5 11100101 0
E e6 11100110 0
E e7 11100111 0
E e8 11101000 0
E e9 11101001 0
E ea 11101010 0
E eb 11101011 0
E ec 11101100 0
E ed 11101101 0
E ee 11101110 0
E ef 11101111 0
E f0 11110000 0
E f1 11110001 0
E f2 11110010 0
E f3 11110011 0
E f4 11110100 0
E f5 11110101 0
E f6 11110110 0
E f7 11110111 0
E f8 11111000 0
E f9 11111001 0
E fa 11111010 0
E fb 11111011 0
E fc 11111100 0
E fd 11111101 0
E fe 11111110 0
E ff 11111111 0
S 4 011 01000 2
E 5554437d0d0a 0111 1
E 204f6e203230 1001 0
E 30 00 0
E 2d 101 0
E 32 0101 0
E 31 0110 0
E 3a 1000 0
E 20 1100 0
E 35 01001 0
E 37 11010 0
E 38 11011 0
E 36 11100 0
E 39 11101 0
E 33 11110 0
E 34 11111 0
S 5 100 1011001 8
E 2d4232465749484a4d245d0d 000 0
E 2d42324649484a4d245d0d 101110 0
E 2d4232465749484d245d0d 1011011 0
E 2d423246484d245d0d 010 0
E 3b50513a20 0010 7
E 3b50523a20 0011 7
E 3b20 1000 8
E 2e 11 0
E 31 011 0
E 0a 1010 0
E 35 101111 0
E 0d 1001000 1
E 37 1001001 0
E 34 1001010 0
E 39 1001011 0
E 30 1001100 0
E 32 1001101 0
E 20 1001110 2
E 33 1001111 0
E 38 1011000 0
E 36 1011010 0
S 6 101 100110 2
E 20 1010 7
E 0d 1011 1
E 45 00000 0
E 4c 00001 0
E 51 00010 0
E 53 00011 0
E 43 00100 0
E 47 00101 0
E 46 00110 0
E 4e 00111 0
E 44 01000 0
E 4a 01001 0
E 4f 01010 0
E 41 01011 0
E 49 01100 0
E 48 01101 0
E 42 01110 0
E 50 01111 0
E 52 10000 0
E 4b 10001 0
E 4d 10010 0
E 39 100111 0
E 59 110000 0
E 56 110001 0
E 5a 110010 0
E 54 110011 0
E 58 110100 0
E 32 110101 0
E 57 110110 0
E 38 110111 0
E 34 111000 0
E 31 111001 0
E 35 111010 0
E 36 111011 0
E 33 111100 0
E 37 111101 0
E 30 111110 0
E 55 111111 0
S 7 110 1110 2
E 20300d 110 1
E 31 00 0
E 20 10 0
E 0d 011 1
E 34 01000 0
E 39 01001 0
E 36 01010 0
E 32 010110 0
E 35 010111 0
E 37 111100 0
E 38 111101 0
E 30 111110 0
E 33 111111 0
S 8 111 01100101 2
E 495330475242 01100100 0
E 20444520 01001 0
E 574c324b 10010000 0
E 203e0d 110010 1
E 290d 101111 1
E 2028 110011 0
E 2d 0111 0
E 4b 1101 0
E 4d 00000 0
E 32 00001 0
E 36 00010 0
E 33 00011 0
E 39 00100 0
E 35 00101 0
E 44 00111 0
E 45 01011 0
E 37 01101 0
E 42 10000 0
E 34 10011 0
E 57 10100 0
E 41 10101 0
E 4e 11101 0
E 58 001100 0
E 30 001101 0
E 53 010000 0
E 5a 010001 0
E 50 011000 0
E 48 100010 0
E 4f 100011 0
E 49 100101 0
E 38 101101 0
E 4c 101110 0
E 56 110000 0
E 4a 110001 0
E 47 111000 0
E 43 111001 0
E 31 111100 0
E 46 111101 0
E 54 111110 0
E 52 111111 0
E 20 0110011 6
E 55 1001001 0
E 59 1011000 0
E 51 1011001 0
E 0d 10010001 1
E 0d 01010 1
```
