VARAHF.com Draft
Protocol reference · VARA HF 4.9.x

Inside the VARA HF protocol

An implementer's reference to what a VARA HF modem actually puts on the air: the shared tables, control frames, data frames, error correction, three waveform families and the ARQ session, specified exactly enough to build a modem that talks to the real thing.

The control frames of a call to N0CALL at 2300 Hz: real tone sequences, drawn by the same code as the transmitter below. Faint symbols are the lead-in.

The speed ladder

FSKPSKOFDMQAM OFDM
Every data level of the three bandwidths. Point at a bar, or tab to it, for its numbers.

Bar height is net bit/s on a log scale, from 18 bit/s at level 1 to 8489 bit/s at 2750 Hz level 17. Figures are from §7 of the specification.

500 · 2300 · 2750 Hzthree bandwidths, with 13, 16 and 17 levels
1500 Hzcentre of every bandwidth in the SSB passband
48 000 S/sreal audio; data waveforms defined at a 3000 Hz reference rate
23.4375 Hzcontrol-frame tone grid, 2048 samples per symbol
1/3 … 5/6turbo code rates, two 8-state encoders
CRC-16GENIBUS, on every frame and inside every callsign hash
Paywall · bad form

There is a paywall bit in the protocol.

Flags byte of the caller's first frame, text compression requested

1000000
always 1encryptencryptcompresscompressregistered

byte 0x80 · not registered · compression forced off

Press the orange bit to flip it

Fastest level the other station will allow

500 Hz
2300 Hz
2750 Hz

The same message at 2300 Hz, time on the frequency

Registered
Not registered

The bit says whether the caller's software is paid for. It rides in the header frame, on the air.

Clear, and a clean path still crawls: about forty times longer on a shared frequency than the link needs.

Charging for software is fair. Wiring the till into the on-air protocol is bad form for a ham mode.

Specification §8.2 (the bit, and compression), §10.5 and §10.6 (the level 4 ceiling and start cap). Speeds are net bit/s from §7.

How it works

A connection, frame by frame

Half duplex: one station talks, the other answers. Short control frames carry the signalling, data frames carry the bytes.

Caller starts the call
Answerer was listening for its callsign

    control framedata frame

    The opening of a session as §10.2 describes it. In chat mode the answerer sends IDLE instead of BREAK.

    Waveforms

    Three ways to fill the passband

    As the path improves the modem climbs from one tone at a time to dozens of subcarriers. These are the 2300 Hz versions.

    Levels 1–4

    FSK

    One tone at a time. Level 1 holds each for 42.7 ms between 773 and 2250 Hz. 18 to 175 bit/s, with SNR thresholds from −13.6 dB.

    Levels 5–9

    PSK

    Three to ten carriers, each carrying its bits in phase, 10.7 ms per symbol. Level 9 shown. 270 to 922 bit/s.

    Levels 10–16

    OFDM

    49 subcarriers from 375 to 2625 Hz, 24 ms per symbol; the top two levels add QAM. 2011 to 7050 bit/s.

    Schematic. Carrier positions, symbol times and rates are from §7 and §9; the data drawn is random and slowed down.

    Data frame

    What is inside a data frame

    Every data frame has the same shape, whatever waveform carries it. Three bytes are overhead; the rest is yours.

    payload up to frame bytes − 3; compressed text if compression is on
    0x14 terminator, only when the payload does not fill the frame
    marker high byte of the CRC of the caller's callsign
    next level only in the last frame of a turn: the level offered to the peer
    control one byte, below
    CRC-16 over everything before it, big-endian

    The control byte, most significant bit first

    RRCHHHLF
    RR control format to reply in C payload is compressed HHH how much is queued, 0–6 L next-level byte present F frame is full

    From §8.1. Widths are not to scale.

    Documents

    Four documents, one protocol

    The specification is the reference. The other three go deeper on the parts people get wrong. Values the specification marks (unconfirmed) are believed correct but not yet confirmed.

    Try it

    Generate a frame and listen to it

    These run the routines from the specification in your browser. Nothing is recorded or sent anywhere, and nothing goes on the air unless you feed your speakers to a radio.

    Control-frame transmitter

    Pick a station and a frame. The page hashes the callsign, seeds the generator, draws the tones and synthesises the audio exactly as §6 describes: 2048 samples per symbol at 48 kHz, at the default −5 dB drive.

    What a callsign becomes

    The same callsign as above, in the forms §5 and §12 define.

    The generator

    Reseed with seed_rnd(x), then take sixteen rand_int(34) draws. Played as tones on bins 50 + value, which is how lead-in symbols are drawn.

    Pseudocode

    The parts you have to get bit-exact

    Five routines that everything else rests on. They follow the specification section named on each; where the two differ, the specification is right.

    The pseudo-random generator §3

    Every table and codebook comes from this one 24-bit generator. Single precision matters: several states round differently in double precision.

    # 24-bit state; at program start it is 0x050000
    step():
        state ← (state × 0xFD43FD + 0xC39EC3) mod 2^24
        return float32(state / 2^24)
    
    rnd(x):                                  # x < 0 reseeds first; x > 0 just steps
        if x < 0:
            bits  ← float32_bits(x)
            state ← (bits + (bits >> 24)) & 0xFFFFFF
        return step()                         # rnd(-1) always leaves state = 0x395886
    
    randomize(d):                            # d is an IEEE double
        hi    ← upper 32 bits of d
        mix   ← ((hi & 0xFFFF) xor (hi >> 16)) & 0xFFFF
        state ← (state & 0xFF0000FF) | (mix << 8)
    
    draw(m):      return floor(float32(rnd(1) × m))
    rand_int(n):  return draw(n + 1)           # 0 .. n inclusive
    
    seeded(s):                               # start of a table stream
        rnd(-1); randomize(s)
    
    seed_rnd(x):                             # per-use reseed, used for codebooks
        rnd(-1); randomize(x mod 32768)
        repeat floor(x / 32768) + 1 times: step()

    CRC, station hash and packed callsign §5

    The hash is never sent; it only seeds the tone choice. The packed form is what the caller's header frame carries.

    crc16(bytes):                            # CRC-16 "GENIBUS"; "123456789" → 0xD64E
        crc ← 0xFFFF
        for b in bytes:
            crc ← crc xor (b << 8)
            repeat 8 times:
                if crc & 0x8000: crc ← ((crc << 1) xor 0x1021) & 0xFFFF
                else:            crc ←  (crc << 1) & 0xFFFF
        return crc xor 0xFFFF                 # carried big-endian in frames
    
    station_hash(call):                      # 24 bits
        text ← upper(call)                    # whole stored text, SSID included
        tail ← last 3 characters of text      # all of it if shorter
        return ((crc16(tail) >> 8) << 16) | crc16(text)
    
    pack_callsign(base, ssid):               # 6 bytes = eight 6-bit codes, MSB first
        codes ← []
        for ch in base:                       # 1 to 7 characters of A–Z, 0–9
            codes.append(ch - 'A' + 1  if ch is a letter  else ch - '0' + 27)
        pad codes with 0 to 7 entries
        codes.append(0 if no ssid
                     else 16, 17, 18, 19 for T, R, X, L
                     else the number 1 .. 19)
        return the 48 bits of codes as 6 bytes

    Drawing a control codeword §6.4

    Control frames carry no callsign. The tones of each code are drawn from the generator after a reseed that depends on the station hashes, so a station only recognises frames meant for it.

    # tone families, comb bases 14 bins apart on the 23.4375 Hz grid
    #   1 (500 Hz):  first 50, 2 bases      2 (2300 Hz): first 29, 5 bases
    #   3 (2750 Hz): first 22, 6 bases
    
    draw_codeword(family, nsym, ntones):     # F0: 32, 1   F1: 16, 1   F2: 8, 2
        for s in 2 .. nsym:
            bases ← []
            while len(bases) < ntones:        # distinct bases; a repeat is drawn again
                base ← rand_int(nbases - 1) × 14 + first
                if base not in bases: bases.append(base)
            odd ← 1 if s is even and family ≠ 1 else 0
            for base in bases:
                emit base + odd + 2 × rand_int(6)
    
    build_side(link_seed, side_offset):      # answerer 278, caller 50
        for f in 0, 1, 2:
            off ← f + side_offset
            seed_rnd(link_seed + 10 + off)
            for code in 1 .. 58:
                reseed first where §6.4 lists one  # connect requests, 41, 47, 48, 51, 58
                book[f][code] ← draw_codeword(family of code, nsym[f], ntones[f])
            seed_rnd(0x2D277B0 + off)
            book[f][45] ← draw_codeword(1, nsym[f], ntones[f])

    Building a data frame §8.1

    Payload, an optional terminator and marker, an optional next-level byte, one control byte and the CRC.

    # | payload | [0x14, marker, 0, 0, ...] | [next level] | control | CRC-16 |
    
    marker(caller_call):                     # both directions use the caller's
        m ← crc16(caller_call) >> 8
        return 0x01 if m in (0x00, 0x14) else m
    
    build_frame(payload, frame_bytes, next_level, reply_fmt, compressed, hint):
        L        ← next_level is present
        capacity ← frame_bytes - 3 - (1 if L else 0)
        F        ← len(payload) = capacity     # a full frame has no terminator
        field    ← payload
        if not F:
            field ← field + [0x14]
            if len(field) < capacity: field ← field + [marker]
            pad field with 0x00 to capacity
    
        control ← reply_fmt << 6               # RR   format to reply in, 0–2
                | compressed << 5              # C    payload is text-compressed
                | hint << 2                    # HHH  queue bucket, 0–6
                | L << 1 | F
    
        body ← field + ([next_level] if L) + [control]
        return body + big_endian(crc16(body))

    Whitening, turbo code, puncturing, interleave §8.3

    From frame bytes to the N coded bits a waveform carries. K, N and the puncturing period p come from the level's row in §7.

    # K = floor((N - 12) / den) × num        frame bytes = floor(K / 8)
    # rate index → num/den and period p:  2 → 1/3, 1    3 → 1/2, 2    4 → 2/3, 4
    #                                     6 → 4/5, 8    7 → 5/6, 10
    
    rsc(bits):                               # 8-state recursive systematic encoder
        r0, r1, r2 ← 0, 0, 0
        for u in bits, then 3 tail steps with u ← r0 xor r1:
            fb     ← u xor r0 xor r1
            parity ← fb xor r2 xor r0
            r0, r1, r2 ← r1, r2, fb
            yield (u, parity)
    
    encode(frame, K, N, p, turbo_perm, chan_perm):
        info ← bits of frame, MSB first, zero-padded to K
        info ← info xor whitening[0 .. K-1]    # same sequence for every frame
        a ← rsc(info)
        b ← rsc(info[turbo_perm[i]] for i in 0 .. K-1)
    
        out ← []
        for t in 0 .. K-1:
            out.append(info[t])
            if p = 1 or t mod p = 0:    out.append(a[t].parity)
            if p = 1 or t mod p = p/2:  out.append(b[t].parity)
        for t in the 3 tail steps:              # unpunctured
            out.append(a[t].u, a[t].parity, b[t].u, b[t].parity)
        pad out with zeros to N                # 0 to 4 bits
    
        return [ out[chan_perm[i]] for i in 0 .. N-1 ]
    Diagrams

    See the whole thing at once

    Two diagrams that open full size, in light or dark.