P25
P25 Phase 1 conventional voice (TIA-102.BAAA-A, the FDMA common air interface), on the air interface
(air-interface.md). Switch: CONFIG_P25, which also builds the air interface, the voice
decoder and the MBE core (build-config.md). Which radios can carry it: feature-matrix.md.
Clause numbers below are the standard's.
State:
| Part | State |
|---|---|
| Data units and their FEC, receive, the call layer, the engine | written, host tested |
| Voice decoder (IMBE) and the voice path | written, host tested |
| The radio core: a P25 channel, receive, PTT (7) | written, host tested; a stored P25 channel, the VFO's mode tile or the debug link sets it |
| On air | receive and transmit checked on radios against the SDR bench (feature-matrix.md, 9); not against a radio of another make |
| Voice encoder (5.1) and the microphone path | written, host tested; on a radio its frames decode off air with no bad frame, how it sounds is not judged |
| Channels in the codeplug (p25-codeplug.md 2) | written, host tested: loaded, saved from the radio, shared in a zone; a stored channel written over CPS runs on a radio (test_p25_stored_channel). The VFO's P25 settings are RAM only (7.2) |
| Scan (7.1) | written, host tested: a zone scan stops on a stored P25 conventional channel and holds on a call that plays; checked on a radio against the SDR bench (test_p25_scan_from_bench). Trunked channels are skipped |
| Dual watch | written, host tested: a stored or VFO P25 channel on either side, the receiver alternating onto it (radio-features.md 2.1); checked on a radio against the SDR bench (test_p25_scan_from_bench). Trunked channels are refused |
| UI | Home: the mode, what PTT calls, the NAC received, the call coming in (7.3). The channel editor: NAC, talk group, unit ID, talkaround (ui.md 2.1), host tested |
Trunking (CONFIG_P25_TRUNK) |
written, host tested: control channel signaling, hunting, following voice grants (p25-trunking.md); the radio core runs it on a P25 trunked channel, host tested, and on a radio against a control channel the SDR bench plays (p25-trunking.md 8), not on a live system |
Trunked transmit (CONFIG_P25_TRUNK) |
written, host tested against a fake site: registration, affiliation, the group voice request, transmit on the granted channel and return (p25-trunking.md 5); run on a radio against the bench's control channel (test_p25_trunk_tx), its requests decoded off air; message layouts not confirmed by a capture of a live system |
| Packets (PDU), encryption | not written. Their units are refused (a trunked channel takes the header of a multi-block trunking packet), encrypted voice is not played |
| Phase 2 (TDMA) | not planned: the RF transceiver components these radios carry can't send or receive its modulation (H-CPM, H-DQPSK). A grant to a TDMA channel is recognized and reported, its voice not followed (p25-codeplug.md) |
1. On air
| Item | Value |
|---|---|
| Modulation | C4FM, 4800 symbols/s, 2 bits a symbol (9.3, 9.4) |
| Deviation | 1800 Hz for the outer symbols, 600 Hz for the inner (table 9-1) |
| Frame sync | 24 symbols, 5575F5FF77FF (8.3), at the start of every data unit |
| NID | 64 bits behind the sync: NAC (12 bits), data unit ID (4), BCH(63,16) parity and one parity bit (8.5.2) |
| Status symbols | one after every 35 symbols of a unit, the frame sync included (8.4) |
Data units of a voice call (8.2):
| Unit | DUID | Symbols | Carries |
|---|---|---|---|
| Header (HDU) | 0x0 | 396 | message indicator, MFID, ALGID, KID, talk group |
| LDU1 | 0x5 | 864 | nine voice frames, link control, low speed data |
| LDU2 | 0xA | 864 | nine voice frames, encryption sync, low speed data |
| Terminator (TDU) | 0x3 | 72 | nothing |
| Terminator with link control (TDULC) | 0xF | 216 | link control |
A transmission is a header, LDU1 and LDU2 in turn (180 ms each), and a terminator.
2. FEC (core/p25/p25_unit.c, core/fec/)
| Field | Code |
|---|---|
| NID | BCH(63,16,23) and a parity bit |
| Header word | RS(36,20,17) over GF(64), each symbol in a Golay(18,6,8) word |
| Link control (LDU1) | RS(24,12,13), each symbol in a Hamming(10,6,3) word |
| Encryption sync (LDU2) | RS(24,16,9), each symbol in a Hamming(10,6,3) word |
| Link control (TDULC) | RS(24,12,13), each pair of symbols in a Golay(24,12,8) word |
| Low speed data | a (16,8,5) cyclic code per octet |
| Voice frame, 88 bits in 144 | four Golay(23,12,7) words, three Hamming(15,11,3) words, seven bits bare; all but the first word scrambled with a sequence seeded by it (5.3) |
Inner code words that fail are given to the Reed-Solomon decoder as erasures, as long as they are no more than half its parity symbols.
3. Receive (core/p25/p25_rx.c)
The framer finds the frame sync; the head hook reads the NID behind it.
| Case | Result |
|---|---|
NID decodes, NAC is ours (or the receiver takes any: 0xF7E) |
the unit is taken, its length from the data unit ID |
| NID decodes, another NAC | refused: another system on the channel |
| NID undecodable inside a voice call | up to two LDUs in a row are placed by the call's order (LDU1 and LDU2 alternate), so a fade over the NID does not cost the voice behind it |
| A packet or an unknown unit | refused |
4. The call layer (core/p25/p25_call.c)
Receive:
| Unit | Effect |
|---|---|
| Header | a call starts; algorithm, key ID and talk group are known |
| LDU without a call | a call starts as a late entry; its fields fill in with the LDUs |
| LDU1 | link control: group call (talk group, source, emergency) or unit to unit call (destination, source) |
| LDU2 | encryption sync: algorithm and key ID |
| Either LDU | nine voice frames in air order, each with the count of bits its codes corrected (9 or more: not to be trusted) |
| Terminator, or the signal lost | the call ends |
Voice of a call whose algorithm is not clear (0x80) is not handed on. A late entry's LDU1 before its first LDU2
is taken as clear.
Transmit: the units are built and released symbol by symbol. An LDU's link control or encryption sync and its low speed data are in the unit from its start; each voice frame releases the symbols up to where the next one begins (the first releases the LDU's start too). The air runs one voice frame behind the encoder, not one LDU. When the transmission ends, the LDU on air is filled with silence frames and a terminator (TDU) follows. An end that comes before an LDU's first voice frame sends the terminator right after the LDU before: no LDU of silence.
5. Voice
A voice frame is 88 bits (11 bytes): the IMBE vocoder's words u0 to u7 after the frame's FEC.
The voice path (core/p25/p25Voice.c) sits between the engine and the board's PCM stream (hal_audio_t):
| Direction | What |
|---|---|
| Receive | the engine's rx_voice hook queues each frame (32 frames, two LDUs and jitter). The audio block callback takes one per 20 ms block and decodes it (core/mbe). Playback starts once one LDU is queued and two more blocks have passed, so the next LDU arrives with that margin |
| Bad frames | the engine hands over, with each frame, what its codes corrected: the bits in all seven code words, in the first (the others are descrambled with its word) and in the fifth. A frame with two or more in the first word and eleven or more in all, a frame with a pitch code that is not used, and a block with nothing queued during a call are not used: the decoder repeats the last good frame, four times at most, then mutes |
| Channel errors | the decoder keeps a running rate of corrected bits (0.95 of the rate before plus 0.000356 per bit, per frame). Over 8.5 % the output is muted. Over 0.5 %, or with more than four bits in the frame, a harmonic louder than a level set by the running frame energy is played voiced whatever its bit says; over 0.5 %, or with more than six bits, the sum of the frame's amplitudes is held to a limit. On a clean channel neither changes a frame. The rate starts over with each call |
| Transmit | from the start of a transmission (p25VoiceTx) the audio block callback encodes each microphone block (5.1) and queues the frame (8 frames); the engine's tx_voice hook takes them one at a time. With none ready the hook says so and the engine sends a silence frame (p25.tx_filler). The microphone gain step scales the samples first when the board has no gain of its own. The speaker is silent meanwhile. Frames still queued at the end are not sent |
The decoder (the full-rate decoder on the MBE synthesis core, core/mbe; built with CONFIG_P25) runs in integers.
A radio transmits or receives, so the encoder uses the decoder's prediction state and scratch memory; after a
transmission the decoder starts over. The encoder keeps 516 bytes of its own (the estimator's history).
5.1 The encoder (core/mbe/mbe_est.c, core/mbe/imbe_enc.c)
One 20 ms block of speech to a frame's 88 bits, in integers, in two parts.
The estimator (mbe_est, shared by every vocoder of this family) finds the model's parameters:
| Step | What |
|---|---|
| Input | a DC-blocking high-pass, then a 221-sample Hamming window centered on the block, transformed at 512 points |
| Pitch | the normalized autocorrelation of the signal low-passed to about 1 kHz, over periods of 18 to 124 samples. Of peaks nearly as good as the best, the shortest period wins; a period near the last frame's wins unless another is clearly better |
| Refinement | pitch codes around the estimate are tried against the spectrum below about 3 kHz; the one whose harmonics leave the least energy unexplained is kept. Half the period is tried the same way and wins when it fits as well: a period and its double fit a periodic signal alike in the autocorrelation, but in the spectrum the double leaves every second band empty only if it is wrong |
| Pitch or none | a frame has a pitch when the autocorrelation at it is at least 0.4, and at least 0.64 when the last frame had no voiced band: noise and hum reach the lower mark now and then, speech passes the higher one from its first frame. Without a pitch no band is voiced |
| Voicing | bands of three harmonics. A band is voiced when the window's transform at each harmonic explains its bins to within a threshold, which is stricter toward high frequencies and looser for a band voiced in the last frame |
| Amplitudes | per harmonic: the fit's amplitude in a voiced band, the bins' mean power in an unvoiced one, as base 2 logarithms |
The quantizer (imbe_pack) is the dequantizer's inverse with the same tables and the same prediction, run on what
the receiver will reconstruct: pitch code, voicing bits, the gain vector, the block DCT coefficients with the
standard's bit allocation. imbe_unpack(imbe_pack(x)) gives back every frame's bits.
The gain code sets the mean of a frame's log amplitudes, and its lowest value is a floor. A quiet frame with a few harmonics far above the rest (hum, rumble) has a mean under it. The quantizer then raises the weak harmonics to a common level, the lowest that brings the mean up to the floor, and leaves the strong ones as they are (coded as it was, every harmonic would rise by the difference, 18 dB in the test).
Only input that is all zeros gives the silence frame; quiet sound is coded as sound. The high-pass runs out to zero after its input does. The thresholds, the window and the search are this project's design; the frame format, the bit allocation and the quantizer tables are the standard's (TIA-102.BABA).
6. The engine (core/p25/p25_engine.c)
p25_engine is P25 on a channel: the call layer on an air interface session.
Settings:
| Setting | Meaning |
|---|---|
rx_nac |
calls of this NAC are taken; 0xF7E takes every NAC |
tx_nac |
the NAC sent |
rx_tgid |
0: every call of the NAC is played (the normal squelch of a conventional channel). Otherwise only group calls to this talk group or to everyone (65535) and unit to unit calls to unit_id (selective squelch) |
unit_id |
the radio's own ID, the source of what it sends |
tx_lc |
what a transmission calls: a talk group or a unit |
talkaround |
status symbols say direct; otherwise unknown, as to a repeater |
silence |
a voice frame of silence, from the vocoder |
A call that is not played is still tracked: the view says a call is on the channel, from whom and to whom.
Transmit sequence (the radio core's task unless noted):
| Step | What |
|---|---|
| 1 | p25_engine_tx_prepare: the header is queued at the provider |
| 2 | hal_radio_t.tx(): the core's checks, the transmitter on |
| 3 | p25_engine_tx_go: the provider modulates |
| 4 | (provider's task) voice frames are pulled from the encoder as the queue drains. A frame that is not ready is waited for while the queue holds more than the provider's lead plus one chunk; then a silence frame goes instead. The air never runs dry |
| 5 | p25_engine_tx_stop: the LDU on air is finished, a terminator sent |
| 6 | state AIR_TX_DONE: hal_radio_t.tx_off(), then p25_engine_tx_clear |
7. The radio core (core/radio/radio_p25.c, core/radio/radio_sm.c)
RADIO_MODE_P25 is a channel mode. The board runs in its digital mode (RADIO_MODE_DMR, 12.5 kHz) with the DMR
call stack stopped, and the engine on the board's air interface provider (board.air).
| Event | What the radio core does |
|---|---|
| Tune to a P25 channel | the DMR stack stops, the board is set to its digital mode and tuned, the engine starts with the channel's parameters (7.2). A retune starts it over |
| Leave P25 (another channel, mode or the bench) | the engine closes (a transmission is cut, the transmitter goes off) before anything else takes the modem |
| No provider, the provider can't fit P25, or no memory | the engine does not start: nothing is received, PTT is refused (TXDENY_REFUSED) |
| A call on the channel's NAC | the state is RX. The speaker opens and the LED is green only for a call that passes the squelch (rx_tgid) and is clear |
| PTT | the core's transmit checks (as FM and DMR), the header queued, the transmitter keyed at the channel's power, then the provider starts |
| Release, time-out | the engine ends the LDU on air and sends a terminator; at AIR_TX_DONE the transmitter goes off. The time-out cuts at once |
Memory: the engine and the voice path run in memory the DMR vocoder lends while it is idle
(hal_vocoder_t.lend, on platforms that define HAL_VOCODER_LEND_BYTES), else in their own static block.
Not P25: the listen-only bands (the mode change is refused there).
7.1 Setting a channel to P25
A stored P25 conventional channel (kind 2, p25-codeplug.md 2) runs P25 where the board does
(radio_p25_fits, below) and its receive frequency is outside the listen-only bands: the radio core takes it as
RADIO_MODE_P25 when it reads it. Elsewhere it is parked (channel-modes.md 6). Its mode can't be
changed for now (the mode request is refused on a channel of any kind). Dual watch takes a conventional P25 channel on
either side and a trunked one on neither.
A zone scan (or a VFO scan in P25) stops on a P25 conventional channel as on any other: the tune starts the engine, which a stop on another mode closes again (radio-features.md 2). What the stop hears:
| Heard | The stop |
|---|---|
| Nothing (the noise reading and the signal strength, as on DMR) | moves on after the dwell |
| A carrier, no call of the channel's NAC yet | probes up to 700 ms (a voice frame and its NID come every 180 ms) |
| A call of the NAC whose squelch waits for its link control (a late entry on a selective channel) | probes up to 1.5 s (LDU1 comes every 360 ms) |
| A call that plays | holds, then resumes as the scan's resume mode says |
| A call that doesn't play (another talk group, encrypted) | moves on |
Not scanned: a trunked channel (it follows its system's control channel; a stop can't judge it), and a P25 channel where the board can't receive P25 (parked).
The debug link's mode request (debuglink.md 3.8, op 31, mode 2) makes a plain channel on view P25 as a temporary
change, or the VFO's mode. rfoundry_debug.py radio mode p25. Saving that channel, or storing the VFO as a channel,
writes a P25 channel from the settings (p25-codeplug.md 2.3).
In the VFO the mode tile (quick settings, 4) goes FM, DMR, P25, FM. It offers P25 where the UI's UI_FEAT_P25 is set:
a build with P25 on a board whose air interface can receive it (radio_p25_fits). The radio core refuses the mode
request otherwise, and in a listen-only band. The settings store keeps a P25 VFO (vfo_mode, settings-store.md); a
build or board without P25 reads it as its default mode.
7.2 Parameters
radio_p25_params is the one place P25 parameters come from. On a stored P25 channel: its tag and record
(p25-codeplug.md 2), with selective squelch as there (2.1, rx_tgid the channel's talk group, or
65535 on a channel that calls a unit or everyone). Otherwise (the VFO, a mode changed for now): the P25 settings, RAM
only, reset at start-up, set by the debug link (op 42). The engine takes either at once, or after a transmission
ends. The settings' unit_id, when set, also overrides a stored channel's for the session.
| Setting | Default | Meaning |
|---|---|---|
rx_nac |
0x293 |
as 6; 0xF7E takes every NAC |
tx_nac |
0x293 |
|
rx_tgid |
0 | 0 plays every call of the NAC; else selective squelch |
talkaround |
auto | auto: on when TX = RX (or no TX frequency), off otherwise; or on, off |
unit_call, tx_dst |
group 1 | what PTT calls: talk group tx_dst, or unit tx_dst |
unit_id |
0 | ours; 0 takes the radio-wide P25 one (p25-codeplug.md 1), else the DMR ID |
7.3 Home
radio_p25_view_t carries what the screen needs: the call heard (flags, src, dst) and, from the parameters in
force (the settings while the engine is off), rx_nac and talk (tx_dst, RADIO_P25_TALK_UNIT for a unit call).
| Where | What |
|---|---|
| Talk line | what PTT calls: "TG 1", or the unit's ID |
| Chips | the power, then "NAC 293" (F7E: any), where it fits |
| Activity, a call coming in | "ID 3101234 > TG 7" or "ID … > Private to 5678" (the ID drops first when too wide, and is missing until the link control is read); "Encrypted: not played", "Other TG: not played". On a one-line activity area it takes the meter's place |
7.4 What the debug link shows
The p25 view section (debuglink.md 3.7): the call heard now or last (p25.on rx played enc unit late nac src dst tx), the settings, the parameters the engine runs on (p25.run.*), and the counters of the engine, the call layer and the voice path (p25v.*).
8. Tests
| Test | Covers |
|---|---|
tests/host/p25Test.c |
the NID against the standard's parity table, status symbol places, every field clean and through bit errors, the voice code word, a call through a noisy channel and the framer, the call layer both ways, late entry, an encrypted call |
tests/host/p25EngineTest.c |
two engines: a call heard with its fields and voice in order, an encoder that stalls, no encoder, the selective squelch, an abort |
tests/host/imbeEncTest.c |
the quantizer against the dequantizer (random frames, bit for bit); the estimator on made-up signals: pitch, harmonic amplitudes, voicing of tones and noise, level through the encoder and the decoder; a voice that starts at twice its period; quiet noise, zeros and a quiet hum; hum under noise |
tests/host/p25VoiceTest.c |
the voice path: playback timing, bad frames, overflow, a transmission (the stream starts, frames reach the hook, a full queue, the end, the microphone gain, reception after it) |
tests/host/airSoftmodemTest.c |
a call from discriminator samples to units |
tests/host/radioCoreTest.c (radioCoreTestP25) |
the radio core with a fake provider and a far engine: a call heard and its squelch, PTT through to the terminator and the transmitter off, refusals (inhibit, receive only, the board refusing to key, no fit, no lent memory), leaving P25 for DMR and FM, the VFO, the bench hook; a stored P25 channel: its parameters, selective squelch, a unit call, the session's unit ID, parked without a fit, the feature list; a zone scan over a stored P25 channel: stops there with nothing on air, holds on a late entry to its talk group until the call ends and the resume delay passes, moves on from another talk group and another NAC, never stops on it without a fit or as a trunked channel (test_p25_scan); dual watch with it as B: the engine at each look, a hold on its talk group's call, back to A after the delay, refused without a fit or as a trunked channel (test_p25_dual) |
tests/host/radioCoreTest.c (radioCoreTestP25T) |
the radio core on a P25 trunked channel against a trunked site on the fake provider, receive and transmit (p25-trunking.md 7) |
tests/host/uiFlowTest.c |
the mode on the home screen, the bandwidth quick action refused, the VFO mode tile, the talk line, NAC and call line (built with CONFIG_P25; p25rx: in the simulator) |
tests/hil/test_p25.py |
on the radio: the switch to P25 and back, the view and the receive load at idle; test_p25_tx_off_air (--allow-rf --p25-mhz): a 3 s over at the lowest power recorded by the SDR bench and decoded by tools/bench/p25tool.py: header, LDUs in turn 180 ms apart with the radio's NAC, talk group and ID, terminator, NID and voice errors, outer deviation. One HR_C7000 radio: 19 units, 153 voice frames, 0 bad, 0.06-0.13 % of the voice bits corrected, outer deviation 98-99 % of 1800 Hz (opt-in; modem-hrc7000.md 10.3); one HR_C6000 radio: 19 units, 153 voice frames, 0 bad, no voice bit corrected, outer deviation 99-99.6 % of 1800 Hz (modem-hrc6000.md 10.3); test_p25_rx_from_bench (--allow-rf --p25-mhz): a call the bench's 4FSK transmitter plays is received, its source and talk group shown, its voice frames counted and played (one HR_C6000 radio at -117 dBm: 72 of 72 voice frames, 1 bad); test_p25_stored_channel (--allow-codeplug-write, nothing sent): the channel in use written over CPS as a receive-only stored P25 channel runs P25 on its own NACs, squelch and talkaround, and is plain again after the restore; test_p25_stored_channel_tx (--allow-rf --allow-codeplug-write --p25-mhz): the same channel with transmit allowed, keyed and decoded off air, carries the channel's NAC, talk group and unit ID (one HR_C6000 radio: 153 voice frames, 0 bad); `test_p25_scan_from_bench[zone |