Per-call voice diagnostics

When a call is granted and the recording comes out empty, short or garbled, the cause can be in any of four places: the grant (wrong frequency, wrong timeslot), the IQ the voice chain received (nothing, a stall, dropped chunks, a weak signal), the decode (no frame sync, every burst on the other slot, no descramble seed), or the call’s end (hangtime, the no-voice startup window, the engine). Until now the evidence was spread across several log lines, some only at debug, with no shared key.

log.voice_diagnostics puts it in one record per voice call, written when the call ends (issue #1438).

log:
  voice_diagnostics: true

It is off by default. When it is off, no record is built and no extra line is logged. It is applied on a config reload and takes effect from the next call, so it can be turned on while a symptom is live and off again afterwards, without a restart.

Where the record appears

The log. One INFO line per call at its end, composer: voice call diagnostics. In the text format the record’s five parts are prefixed grant., tap., sdr., decode. and outcome.; in the JSON format (log.format: json) they are nested objects. Like the other composer: lines, it goes to stderr and log.file, not to message_log or event_log.

The REST API. The daemon keeps the last 256 records in memory. They are not saved, so a restart clears them.

  • GET /api/v1/diag/voice returns {"enabled": …, "records": [ … ]}, newest first. Optional filters: serial=, system=, protocol=, tg=, and limit= (default 50, 0 = all kept).
  • GET /api/v1/diag/voice/{call_id} returns one record. It answers 404 when that call is not kept (diagnostics were off when it started, or it is older than the last 256 calls).

call_id is the number the voice pool gives a call when it binds a voice source to it. It is not the call-history row id, and it starts again from 1 after a restart. A call the engine starts without the voice pool (a conventional scan-list call) has call_id 0, so those are found through the list (serial=, tg=), and GET /api/v1/diag/voice/0 answers 400. To find a history row’s record, match on serial (the voice source) and started_at.

The fields

Identity

call_id, system, protocol, tg, src (the grant’s source radio, when it named one), serial (the voice source the call was bound to), started_at, ended_at.

grant: what the control channel asked for

Field Meaning
freq_hz the voice frequency the grant resolved to
channel_id, channel_num the raw identifiers it was resolved from (P25 band-plan id and channel number, DMR LCN): a wrong frequency can be traced back to the parse
timeslot the grant’s 1-based TDMA timeslot; 0 when the protocol has none or the grant named none
nac P25 NAC, when the grant carried one
encrypted, data_call the grant’s service options
p25_demod_mode P25 Phase 1 voice demodulator
p25p2_seed the P25 Phase 2 descramble seed the grant carried; absent means the chain had to wait for the site’s identity
dmr_interleaved_voice, tetra_usage_marker, individual, conventional protocol-specific, present when set

tap: what the voice chain received

Field Meaning
serial, rate_hz the source and the sample rate the chain was built for
shared a same-carrier TETRA call: its IQ is the control carrier’s stream, shared with the other calls on it, and the counts are that stream’s during this call
ddc (physical_serial, physical_center_hz, target_hz, offset_hz, in_rate_hz, out_rate_hz) for a wideband voice tap: the SDR it is carved from, that SDR’s centre, the channel, the down-converter offset between them, and the rates either side
chunks, samples, seconds the IQ that reached the chain
dropped_chunks chunks lost on the way (a lagging subscriber, or the SDR driver); unknown / null when the source cannot say
rms_dbfs, peak_dbfs mean power and strongest sample over the whole call
first_chunk_ms, last_chunk_ms when the first and last chunk arrived, from the call’s start
max_gap_ms the longest wait between two chunks: a stalled stream shows here even when the totals look plausible

sdr: the SDR and how far off frequency the carrier was

An SDR whose clock is a few ppm off moves every channel it receives by the same few ppm. The receivers’ carrier loops remove it before anything is logged, so it does not show anywhere else, and past a limit a voice chain stops decoding while the control channel still locks (issue #1438).

Field Meaning
serial the physical SDR the call’s IQ came from: the parent SDR of a wideband voice tap, otherwise the voice source
ppm_configured the sdr.ppm that SDR was opened with; unknown / null when the daemon does not hold it (a same-carrier TETRA tap)
carrier_offset_hz the received carrier’s offset from the grant frequency, positive above it, as the voice chain’s receiver measured it; null when it measured none
carrier_offset_ppm the same in ppm of the grant frequency

The offset is measured by the P25 Phase 1, P25 Phase 2, NXDN and dPMR voice chains. P25 Phase 1 reports the autotune correction already applied plus what its demodulator tracks (the C4FM AFC, or the CQPSK carrier loop). The other voice chains leave it null.

decode: the voice chain’s own counters

This is the chain’s existing end-of-call line, copied into the record (the serial and system keys are left out because the record already has them). Which counters appear depends on the protocol:

  • P25 Phase 2: the composer: p25p2 call census line. air_bursts, voice_bursts (on the recorded channel), other_slot_voice_bursts, voice_bursts_by_lch (voice bursts on logical channels 0 and 1, for example 0/115), grant_timeslot, logical_channel, descramble_seed_known, mac_bursts, mac_pdus, iq_seconds, dibits, first_burst_ms, last_burst_ms, the carrier measurement and the per-DUID counts. The carrier measurement is carrier_seed: measured (with carrier_seed_hz, the coarse estimate, carrier_seed_ms, when in the call it was made, and carrier_offset_hz, where the receiver ended up), none (no window in the first 3 s held a carrier, so the receiver had only its fine loop, which pulls in ±750 Hz), or measuring (the call ended first).
  • P25 Phase 1: ldus, uncorrectable_ldus, gated_ldus, corrected_bit_errs, short_ldus, missing_symbols and the RS failure counts.
  • DMR: the quality counters, plus unrouted_superframes (superframes the slot router gave to the other timeslot) and the slot the chain bound.
  • TETRA, NXDN, dPMR, YSF, D-STAR, TETRA DMO, analog FM / AM: the chain’s own end-of-call line.

outcome: how the call ended

Field Meaning
reason the engine’s end reason (normal, timeout, preempted, …)
ended_by which part of the daemon ended it: voice_hangtime (voice stopped for voice_hangtime_ms), no_voice_window (no voice decoded within the startup window), foreign_talkgroup (the channel carried another talkgroup), or engine (anything else; reason says what)
duration_ms start to end
voice_seen, first_voice_ms, last_voice_ms whether the chain decoded any voice, and when
voice_frames the voice frames the chain accepted (on analog FM, the audio blocks written while the channel carried voice)
no_voice_window_ms the no-voice startup window the call ran under (2 × voice_hangtime_ms)

A call ended by the no-voice window also logs, whether diagnostics are on or not, composer: no voice decoded within the no-voice startup window; ending the call with the window, the elapsed time, and the sdr fields above: sdr, ppm_configured, and carrier_offset_hz with carrier_offset_ppm, or carrier_offset="not measured".

The P25 control channel locked line also prints carrier_offset_hz and carrier_offset_ppm, the offset the control channel locked with, on both the single-channel and the wideband decoders.

The SDR clock warning

An SDR whose reference clock is off receives every carrier off frequency by the same parts per million. The daemon says so on its own, with log.voice_diagnostics on or off, once the evidence is in:

level=WARN msg="composer: this SDR's clock looks off: its recent calls' carriers all sat about the same ppm off frequency, past what the receivers' fine carrier loops pull in, so decoding depends on each call's coarse acquisition"
  sdr=0123456789ABCDEF calls=3 carrier_offset_ppm=4.4 carrier_offset_hz=3397
  freqs_mhz=771.20625,771.50625,771.95625 ppm_configured=0 driver=airspy
  remedy="sdr.ppm has no effect on this driver: write the correction into the unit with airspy_calibrate (about 4400 ppb, sign opposite to the offset), power-cycle it, and check that the offset reads near 0"

It is written when all of these hold for one physical SDR (the parent of a wideband tap, as in the sdr part above):

  • at least three of its last five voice calls measured a carrier offset;
  • they agree: each is within 1 ppm of their median (or within 300 Hz of it, where that is more, as on VHF);
  • the median is 1 kHz or more. Below that every receiver’s fine carrier loop pulls the carrier in by itself;
  • the calls were granted by a control channel, or they span two frequencies. A site’s repeaters are held far tighter than any SDR, so trunked calls that agree are the SDR’s clock. Calls of one scan-list channel may all be one handheld that is itself off frequency, so those count only across two channels.

remedy follows the driver. sdr.ppm is applied by the RTL-SDR, rtl_tcp and SoapyRemote drivers; for those the line gives the size of the value to set (the sign that brings the offset to 0 is the right one). Airspy, HydraSDR, Airspy HF+, HackRF, ka9q-radio and the sidecar driver ignore sdr.ppm, and the line says what works instead.

One other fault reads the same way: grants that resolve to the wrong frequency (a band plan with the wrong base or spacing) put every voice call the same distance off. If the control channel’s own carrier_offset_hz on its lock line is near 0 while the voice calls all sit kilohertz off, look at the band plan before the clock.

The warning is given once per SDR. It is repeated after six hours if nothing changed, sooner if the error moved by more than the agreement tolerance, and again if the SDR came back on frequency and then went off. It is fed by the voice chains that measure a carrier (P25 Phase 1 and Phase 2, NXDN, dPMR), so an SDR that only ever carries DMR or TETRA voice gets none, and neither does an SDR so far off that no call’s receiver finds its carrier: the no-voice line’s carrier_offset="not measured" is the sign of that.

Reading a record

Some patterns:

  • tap.chunks 0, or first_chunk_ms long after the start. The chain was never fed, or was fed late. Look at the source (tap.serial, tap.ddc), not the decoder.
  • tap.max_gap_ms large, or dropped_chunks above 0. The IQ stalled or lost chunks. Look for driver overrun or decode can't keep up WARNs around the same time.
  • IQ arrived, rms_dbfs far below the control channel’s level. The tap is on the wrong frequency (compare grant.freq_hz with tap.ddc.target_hz), or the signal really is weak there.
  • P25 Phase 2, voice_bursts_by_lch 0/115 with grant_timeslot 1. Every voice burst was on the other logical channel: the grant named one slot and the voice was on the other.
  • P25 Phase 2, air_bursts 0 with IQ present. The TDMA framer never locked. Check grant.freq_hz and the signal level.
  • descramble_seed_known false. The chain had no descramble seed, so it could not decode the voice or the scrambled MAC.
  • ended_by no_voice_window with voice-like decode counters. Voice arrived, but none of it was accepted in time. Compare first_voice_ms (if any) with no_voice_window_ms.
  • sdr.carrier_offset_ppm of several ppm, on every call through one SDR. That SDR’s clock is off, and from 1 kHz up the clock warning says so by itself. One transmitter can be off frequency itself, so look for the same ppm across calls and on the control channel’s lock line before correcting anything the warning has not named. The correction is roughly ppm_configured minus carrier_offset_ppm, set as sdr.ppm. sdr.ppm is applied by the RTL-SDR, rtl_tcp and SoapyRemote drivers only: Airspy, Airspy HF+, HackRF, ka9q-radio and the sidecar driver ignore it, and on a PlutoSDR (iio) it logs a warning and does nothing. An Airspy keeps its correction in its own flash, written with airspy_calibrate from the Airspy host tools. In issue #1438 a Mini whose calibration had never been written was +4.4 ppm off, and after airspy_calibrate -w -4300 and a power cycle it decoded the Phase 2 calls it had been missing.
  • P25 Phase 2, carrier_seed none. No window in the first 3 s of the call held a carrier. Either the transmitter never keyed up on this frequency, or the signal was too weak to measure, and the receiver could only pull in ±750 Hz.

Replaying a voice-channel capture

A narrow IQ recording of a P25 Phase 2 voice channel can be run through the voice chain’s receiver offline, which answers “would this call have decoded” without waiting for live traffic. It needs a source checkout and Go:

GT_P25P2_IQ=before-voice.cs16 GT_P25P2_RATE=25000 GT_P25P2_FREQ_HZ=771956250 \
GT_P25P2_WACN=BEE00 GT_P25P2_SYSID=164 GT_P25P2_NAC=164 \
  go test ./internal/radio/p25/phase2/receiver -run TestP25Phase2SliceReplay -v

GT_P25P2_IQ takes one file or a comma list; .cs16 is 16-bit interleaved I/Q and .cfile / .cf32 / .f32 are 32-bit float. GT_P25P2_RATE is the file’s sample rate (default 25000), and the file should be centred on the channel. The three identity values are hexadecimal, as the p25 site configuration log line prints them; without them the scrambled MAC bursts cannot be checked, and the rest still runs.

For each file it prints the level and the share of samples at the ADC rail, the carrier the receiver measured (in Hz, and in ppm when GT_P25P2_FREQ_HZ is given) and when in the file it found it, the S-ISCH sync words, the bursts framed (voice and signalling), and the MAC PDUs that passed their CRC. A VERDICT line then says which case it is: voice bursts were framed; the carrier was found but it held no voice (an idle channel); no carrier was found in the first 3 s; or a carrier was measured and no sync word followed. The recording should start before the key-up, as a voice chain does, and not more than 3 s before it.

Not built

  • Records are kept in memory only (the last 256), not in the call-history database.
  • The DDC geometry is reported for wideband voice taps (wbvoice virtual tuners). Other sources report rate and counts only.
  • A call whose IQ stream failed to open gets no record. The existing StreamIQ failed WARN covers it.
  • The control channel’s grant handling (grants dropped as data, encrypted, or for a talkgroup that is not scanned) is not part of the record, which starts when a call is bound to a voice source.
  • The carrier offset is reported by the P25, NXDN and dPMR voice chains only, and on the control channel only by the P25 Phase 1 lock line.
  • The clock warning counts voice calls only. A control channel’s lock offset does not feed it, so an SDR that only ever hosts a control channel is not judged.
  • In testing a P25 Phase 2 voice chain decoded with the carrier 3.4 kHz off and not at 4 kHz. An SDR that far off decodes nothing, measures nothing, and so gets no clock warning either.
  • The residual after the receiver’s carrier loop, a symbol-timing error in ppm, and a frequency error per slot or per burst are not reported.