CSD NT modes: transmit properly aligned RLP frames on DL

There are two levels of alignment inside clearmode RTP packets
carrying CSData per TS 48.103 section 5.6:

1) Alignment of 2 or 4 V.110 (T) or pseudo-V.110 (NT) frames within
   one RTP packet of 160 octets of an imaginary ISDN B channel;

2) For NT modes only, alignment of 4 pseudo-V.110 frames to form
   a single 240-bit RLP frame.

Per previous patch, alignment 1 is to be treated as mandatory for
RTP transport inside an Osmocom network.  Alignment 2 _could_ be
made mandatory for TCH/F9.6 NT, but the same is not possible for
TCH/[FH]4.8 NT: in the best case of half-alignment, alternating
RTP packets will carry alternating halves of RLP frames.

Implemented solution: allow arbitrary state of alignment 2
(aligned or misaligned) in the incoming RTP stream for all CSD NT
modes, and perform the necessary alignment internally.

This approach is consistent with the world of E1 BTS: a TRAU in
data mode is responsible for alignment 1 (with 20 ms TRAU frames
taking the place of our clearmode RTP packets), but only the BTS can
perform alignment 2, as the TRAU is agnostic to T vs NT distinction.

Related: OS#6579
Change-Id: Idaebfce6da13b23ba265a197502712d83991873e
This commit is contained in:
Mychaela N. Falconia
2024-10-27 23:34:46 +00:00
parent 02951e4af3
commit 0a34af1530
4 changed files with 301 additions and 29 deletions

View File

@@ -11,6 +11,26 @@
#include <osmocom/gsm/l1sap.h>
#include <osmo-bts/lchan.h>
extern const uint8_t csd_tchf48_nt_e2_map[26];
/* Per TS 48.020 section 15.1, the cadence of E2+E3 bits in a properly
* aligned sequence of pseudo-V.110 frames forming a single RLP frame
* is 00-01-10-11. The following constant captures this bit sequence
* in hex, for comparison against align_bits output from
* csd_v110_rtp_decode() or against rlpdl_align_bits accumulator
* in CSD NT lchan state.
*/
#define NTCSD_ALIGNED_EBITS 0x1B
void ntcsd_dl_reset(struct gsm_lchan *lchan);
void ntcsd_dl_input_48(struct gsm_lchan *lchan, const ubit_t *data_bits,
uint8_t align_bits);
void ntcsd_dl_input_96(struct gsm_lchan *lchan, const ubit_t *data_bits,
uint8_t align_bits);
bool ntcsd_dl_output(struct gsm_lchan *lchan, ubit_t *rlp_frame_out);
void gsmtap_csd_rlp_process(struct gsm_lchan *lchan, bool is_uplink,
const struct ph_tch_param *tch_ind,
const ubit_t *data, unsigned int data_len);
void gsmtap_csd_rlp_dl(struct gsm_lchan *lchan, uint32_t fn,
const ubit_t *data, unsigned int data_len);

View File

@@ -4,6 +4,7 @@
#include <stdint.h>
#include <netinet/in.h>
#include <osmocom/core/bits.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/logging.h>
@@ -295,9 +296,14 @@ struct gsm_lchan {
uint8_t last_cmr;
uint32_t last_fn;
struct {
/* buffers to re-combine RLP frame from multiple Um blocks */
/* RLP GSMTAP mechanism */
uint8_t rlp_buf_ul[576/8]; /* maximum size of RLP frame */
uint8_t rlp_buf_dl[576/8]; /* maximum size of RLP frame */
/* alignment of RLP frames in DL for NT modes */
ubit_t rlpdl_data_bits[60 * 7];
uint16_t rlpdl_align_bits;
uint8_t rlpdl_fill_level;
ubit_t tchf48_nt_2ndhalf[120];
} csd;
} tch;