Commit
a9f3c01ece6fb59b07cd251ce93b342b1772eaed
by falcon
TCH UL path: add out-of-band BFI flag
In original OsmoBTS architecture prior to Themyscira patches, BFI (Bad Frame Indication) condition was signaled internally by zero-length payload passed from BTS model to l1sap, and externally by absence of RTP output (intentional gap) or a zero-length RTP payload emitted in 'rtp continuous-streaming' mode. However, this paradigm is contrary to classic GSM BSS architecture in which BFI is an out-of-band metadata flag that travels alongside with frame payload bits, whether the latter are valid or invalid.
Since 2024 OsmoBTS supports the option of TW-TS-001 output for FR and EFR codecs, which allows the possibility of BFI-with-data in RTP. OsmoBTS can already emit such BFI-with-data packets when the BTS model delivered a deemed-good traffic frame, but that frame was subsequently deemed bad by the link quality check in l1sap - but there is still no explicit out-of-band BFI flag inside OsmoBTS TCH UL path.
By introducing an out-of-band BFI flag, we make it possible for BTS model PHYs to deliver marked-bad traffic frames: when CRC fails in GSM 05.03 channel decoding step, a PHY that permits modification (libosmocoding or future FOSS DSP PHY) can be enhanced to preserve channel-decoded bits while conveying BFI.
The link quality check in l1sap is reworked to use the new OOB BFI flag. Follow-on patches will introduce further logic that can also assert BFI at high level, above BTS model PHYs.
While reworking the link quality check in l1sap, restrict it to speech modes only: per GSM specs, BFI does not exist in CSD.
Commit
d9b456ce6d7c55b139f78e5c5474a3ad3fdcb5ac
by falcon
FR/HR/EFR: centralize TCH UL SID classification
In any environment where GSM MS may exercise DTXu on TCH/FS, TCH/HS or TCH/EFS, the BTS receiving this TCH UL has to classify each received traffic frame as valid SID, invalid SID or non-SID speech. For E1 BTS this SID classification requirement is explicit as there are dedicated bits in TRAU-UL frames carrying the SID code. For an IP BTS the need for this classification is less obvious as most RTP payload formats omit SID indicator bits - however:
* For HR codec, RTP output in RFC 5993 and TW-TS-002 formats does include explicit SID classification;
* Also for HR output in both TS 101 318 and RFC 5993 formats (but not TW-TS-002), SID classification must be considered in order to turn valid SID with some bit errors into perfect SID codeword;
* OsmoBTS already had logic for all 3 of FR/HR/EFR whereby if a frame is received that is an accepted SID frame in GSM 06.31/06.41/06.81 definition, a flag is set so that the next good speech frame will be emitted in RTP with marker bit set. This logic implies SID classification in TCH UL path.
Prior to this patch, OsmoBTS performed limited, non-consolidated SID classification:
* For FR and EFR, the only SID classification in TCH UL path was done for RTP marker purposes by way of osmo_{fr,efr}_is_any_sid() Boolean result fed to lchan_set_marker();
* For the same RTP marker logic with HR codec, only perfect, error-free SID frames were detected;
* The same limitation applied to SID classification for RFC 5993 output.
Centralize this SID classification by moving it from BTS model to common l1sap code and unifying it across all 3 codecs. Immediate functional effects from this change are:
* On TCH/HS we now detect imperfect (partially corrupted) SID frames and classify them as valid or invalid SID as intended by ETSI, like we already did for TCH/FS and TCH/EFS;
* When emitting TS 101 318 or RFC 5993, we apply the inherent limitations of those RTP formats to valid and invalid SID;
* With all 3 codecs, the check for a good speech frame as exit criterion from DTXu state now happens after the link quality check in l1sap, rather than before.
AMR speech mode is not affected at all by these changes: AMR DTX model is completely different from that of FR/HR/EFR.
Commit
cb5b10e7b7fea20842b789feca50208a4e2094b9
by falcon
FR/HR/EFR: implement SID filter in TCH UL path
As a result of how FR/HR/EFR DTX interacts with block diagonal interleaving, at the beginning and end of each DTX pause a correctly functioning TCH receiver will always pick up an artifact consisting of 4 received bursts (2 for TCH/HS) and same number of omitted bursts. Standard channel decoding of this Rx artifact will produce a "half-block" in which half of the bits prior to convolutional decoding will come from a SID repetition whose Tx was notionally suppressed, while the other half will be garbage. As a result of convolutional decoding, the result will often appear as valid SID per classification rules - but passing it as such to the Rx DTX handler is wrong. Classic E1 BTS and GSM MS implementations include a kind of SID filter at this point, setting BFI on these received half-blocks, so that the Rx DTX handler will see an invalid SID condition. Invalid SID means that comfort noise generation is to be continued, but no updated CN parameters are available - which is the truth in half-block Rx situations. Implement the same filter.
Commit
8d116715398e6160e3ae122d2277baadd1dc0519
by falcon
HRv1 codec: add support for TW-TS-002
OsmoBTS supports TW-TS-001 enhanced RTP format for FR and EFR codecs since 2024, providing functional equivalent of GSM 08.60 TRAU-UL output over IP physical transport. Now do the same with TW-TS-002, IP equivalent of GSM 08.61 for HRv1 codec.
Only TCH UL path is affected; no changes are needed to TCH DL path because existing RTP Rx handling for RFC 5993 also covers TW-TS-002.