laforge has submitted this change. (
https://gerrit.osmocom.org/c/osmo-bts/+/38554?usp=email )
(
3 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: csd_v110: set E2 bit correctly for TCH/[FH]4.8 NT
......................................................................
csd_v110: set E2 bit correctly for TCH/[FH]4.8 NT
In all classic NT modes below 14.5 kbit/s, V.110 frame bits E2 and E3
are repurposed to indicate the alignment whereby a single 240-bit RLP
frame is composed of 4 pseudo-V.110 frames in switching transport.
(TS 48.020 section 15.1.) In the case of TCH/F9.6, setting both E2
and E3 is easy because all 4 pseudo-V.110 frames go out in the same
clearmode RTP packet as a result of a single channel decoding
operation. However, in the case of TCH/F4.8 there are two separate
channel decoding operations producing two separate RTP packets
20 ms apart. Furthermore, GSM 05.03 section 3.4.1 specifies which
TDMA frame positions hold which half of the RLP frame - therefore,
the correct emission of bit E2 needs to be based on the TDMA frame
number at which the block was received.
A similar situation occurs with TCH/H4.8 NT: we receive a single
block from the 05.03 decoder every 40 ms, containing a full RLP frame,
but we emit it as two separate RTP packets, each carrying 20 ms worth
of bits. These RTP packets also require correct setting of E2 bit.
Related: OS#6579
Change-Id: I485af5e01ea87c1721a298a486cd344a17884200
---
M include/osmo-bts/csd_v110.h
M src/common/csd_v110.c
M src/common/l1sap.c
M tests/csd/csd_test.c
4 files changed, 30 insertions(+), 10 deletions(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, approved
pespin: Looks good to me, but someone else must approve
diff --git a/include/osmo-bts/csd_v110.h b/include/osmo-bts/csd_v110.h
index de868ae..a7c3a1b 100644
--- a/include/osmo-bts/csd_v110.h
+++ b/include/osmo-bts/csd_v110.h
@@ -14,6 +14,7 @@
extern const struct csd_v110_lchan_desc csd_v110_lchan_desc[256];
int csd_v110_rtp_encode(const struct gsm_lchan *lchan, uint8_t *rtp,
- const uint8_t *data, size_t data_len);
+ const uint8_t *data, size_t data_len,
+ uint8_t nt48_half_num);
int csd_v110_rtp_decode(const struct gsm_lchan *lchan, uint8_t *data,
const uint8_t *rtp, size_t rtp_len);
diff --git a/src/common/csd_v110.c b/src/common/csd_v110.c
index 7254d2d..cbbb83b 100644
--- a/src/common/csd_v110.c
+++ b/src/common/csd_v110.c
@@ -78,7 +78,8 @@
};
int csd_v110_rtp_encode(const struct gsm_lchan *lchan, uint8_t *rtp,
- const uint8_t *data, size_t data_len)
+ const uint8_t *data, size_t data_len,
+ uint8_t nt48_half_num)
{
const struct csd_v110_lchan_desc *desc;
ubit_t ra_bits[80 * 4];
@@ -110,9 +111,15 @@
/* E1 .. E3 must set by out-of-band knowledge */
if (lchan->csd_mode == LCHAN_CSD_M_NT) {
/* non-transparent: as per 3GPP TS 48.020, Table 7 */
- df.e_bits[0] = 0; /* E1: as per 15.1.2, shall be set to 0 (for BSS-MSC) */
- df.e_bits[1] = (i >> 1) & 0x01; /* E2: 0 for Q1/Q2, 1 for Q3/Q4 */
- df.e_bits[2] = (i >> 0) & 0x01; /* E3: 0 for Q1/Q3, 1 for Q2/Q4 */
+ /* E1: as per 15.1.2, shall be set to 0 (for BSS-MSC) */
+ df.e_bits[0] = 0;
+ /* E2: 0 for Q1/Q2, 1 for Q3/Q4 */
+ if (desc->num_blocks == 4)
+ df.e_bits[1] = (i >> 1) & 0x01;
+ else
+ df.e_bits[1] = nt48_half_num;
+ /* E3: 0 for Q1/Q3, 1 for Q2/Q4 */
+ df.e_bits[2] = (i >> 0) & 0x01;
} else {
/* transparent: as per 3GPP TS 44.021, Figure 4 */
df.e_bits[0] = e1e2e3_map[lchan->csd_mode][0]; /* E1 */
diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index 749598e..65ebf35 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -2056,15 +2056,27 @@
lchan->rtp_tx_marker = false;
}
+/* In the case of TCH/F4.8 NT, we have to set bit E2 based on the TDMA
+ * frame number at which we received the block in question. See
+ * GSM 05.03 section 3.4.1 and the mapping tables of GSM 05.02. */
+static const uint8_t tchf48_nt_e2_map[26] = {
+ [4] = 1, /* B1 position */
+ [13] = 1, /* B3 position */
+ [21] = 1, /* B5 position */
+};
+
static void handle_tch_ind_csd_fr(struct gsm_lchan *lchan, const struct ph_tch_param
*tch_ind,
const uint8_t *data, uint16_t data_len)
{
uint8_t rtp_pl[RFC4040_RTP_PLEN];
+ uint8_t tchf48_half = tchf48_nt_e2_map[tch_ind->fn % 26];
int rc;
gsmtap_csd_rlp_process(lchan, true, tch_ind, data, data_len);
- rc = csd_v110_rtp_encode(lchan, rtp_pl, data, data_len);
+ /* the last argument matters only for TCH/F4.8 NT mode,
+ * ignored in all other cases. */
+ rc = csd_v110_rtp_encode(lchan, rtp_pl, data, data_len, tchf48_half);
if (rc < 0)
return;
@@ -2076,7 +2088,7 @@
uint8_t rtp_pl[RFC4040_RTP_PLEN];
int rc, i;
- rc = csd_v110_rtp_encode(lchan, rtp_pl, NULL, 0);
+ rc = csd_v110_rtp_encode(lchan, rtp_pl, NULL, 0, 0);
if (rc < 0)
return;
@@ -2105,7 +2117,7 @@
for (i = 0; i < 2; i++) {
rc = csd_v110_rtp_encode(lchan, rtp_pl,
data + i * bits_per_20ms,
- bits_per_20ms);
+ bits_per_20ms, i);
if (rc < 0)
return;
send_ul_rtp_packet_hrdata(lchan, rtp_pl, sizeof(rtp_pl));
diff --git a/tests/csd/csd_test.c b/tests/csd/csd_test.c
index b6edec9..15ee84f 100644
--- a/tests/csd/csd_test.c
+++ b/tests/csd/csd_test.c
@@ -124,7 +124,7 @@
data_enc[i] = i & 0x01;
/* encode an RTP frame and print it */
- rc = csd_v110_rtp_encode(&lchan, &rtp[0], &data_enc[0], bit_num);
+ rc = csd_v110_rtp_encode(&lchan, &rtp[0], &data_enc[0], bit_num, 0);
fprintf(stderr, "[i] csd_v110_rtp_encode() returns %d\n", rc);
if (rc != RFC4040_RTP_PLEN)
return;
@@ -148,7 +148,7 @@
fprintf(stderr, "[i] Testing '%s' (IDLE)\n", tc->name);
/* encode an idle RTP frame and print it */
- rc = csd_v110_rtp_encode(&lchan, &rtp[0], &data_enc[0], 0);
+ rc = csd_v110_rtp_encode(&lchan, &rtp[0], &data_enc[0], 0, 0);
fprintf(stderr, "[i] csd_v110_rtp_encode() returns %d\n", rc);
if (rc != RFC4040_RTP_PLEN)
return;
--
To view, visit
https://gerrit.osmocom.org/c/osmo-bts/+/38554?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I485af5e01ea87c1721a298a486cd344a17884200
Gerrit-Change-Number: 38554
Gerrit-PatchSet: 4
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>