laforge submitted this change.

View Change


Approvals: Jenkins Builder: Verified fixeria: Looks good to me, but someone else must approve laforge: Looks good to me, approved
RTP input, FR & EFR: preen incoming payloads for SID errors

Those network elements which receive a stream of codec frames that
may come from the uplink of GSM call A and which are responsible
for preparing the frame stream for the downlink of GSM call B
(such as OsmoBTS receiving RTP and feeding DL to its PHY) must be
prepared for the possibility that their incoming frame stream may
contain corrupted SID frames, presumably from bit errors on radio
link A. Per the rules of section 6.1.1 of GSM 06.31 for FR and
GSM 06.81 for EFR, SID frames with just one errored bit are still
to be accepted as valid, whereas frames with more corrupted bits
which are still recognizable as SID are classified as invalid SID.

In the case of a TrFO call, the entity switching from leg A UL to
leg B DL is responsible for *not* transmitting invalid SID frames
on the destination leg (they should be treated like BFIs), and any
deemed-valid SID frames that are forwarded should be preened,
correcting that one bit error they may exhibit. Implement this
functionality in OsmoBTS.

Change-Id: I89df2f12c49dd5378667cf149d19bde654f80134
---
M src/common/l1sap.c
M src/osmo-bts-omldummy/Makefile.am
2 files changed, 68 insertions(+), 9 deletions(-)

diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index a7eb830..f24bc2f 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -37,6 +37,8 @@
#include <osmocom/core/gsmtap_util.h>
#include <osmocom/core/utils.h>

+#include <osmocom/codec/codec.h>
+
#include <osmocom/trau/osmo_ortp.h>

#include <osmo-bts/logging.h>
@@ -1241,6 +1243,24 @@
return true;
}

+static bool rtppayload_validate_fr(struct msgb *msg)
+{
+ if (msg->len != GSM_FR_BYTES)
+ return false;
+ if ((msg->data[0] & 0xF0) != 0xD0)
+ return false;
+ return osmo_fr_sid_preen(msg->data);
+}
+
+static bool rtppayload_validate_efr(struct msgb *msg)
+{
+ if (msg->len != GSM_EFR_BYTES)
+ return false;
+ if ((msg->data[0] & 0xF0) != 0xC0)
+ return false;
+ return osmo_efr_sid_preen(msg->data);
+}
+
static bool rtppayload_is_valid(struct gsm_lchan *lchan, struct msgb *resp_msg)
{
/* If rtp continuous-streaming is enabled, we shall emit RTP packets
@@ -1255,16 +1275,27 @@
if (resp_msg->len == 0)
return false;

- /* Avoid forwarding bw-efficient AMR to lower layers, most bts models
- * don't support it. */
- if (lchan->tch_mode == GSM48_CMODE_SPEECH_AMR &&
- !rtppayload_is_octet_aligned(resp_msg->data, resp_msg->len)) {
- LOGPLCHAN(lchan, DL1P, LOGL_NOTICE,
- "RTP->L1: Dropping unexpected AMR encoding (bw-efficient?) %s\n",
- osmo_hexdump(resp_msg->data, resp_msg->len));
- return false;
+ switch (lchan->tch_mode) {
+ case GSM48_CMODE_SPEECH_V1:
+ if (lchan->type == GSM_LCHAN_TCH_F)
+ return rtppayload_validate_fr(resp_msg);
+ else
+ return true; /* FIXME: implement preening for HR1 */
+ case GSM48_CMODE_SPEECH_EFR:
+ return rtppayload_validate_efr(resp_msg);
+ case GSM48_CMODE_SPEECH_AMR:
+ /* Avoid forwarding bw-efficient AMR to lower layers,
+ * most bts models don't support it. */
+ if (!rtppayload_is_octet_aligned(resp_msg->data, resp_msg->len)) {
+ LOGPLCHAN(lchan, DL1P, LOGL_NOTICE,
+ "RTP->L1: Dropping unexpected AMR encoding (bw-efficient?) %s\n",
+ osmo_hexdump(resp_msg->data, resp_msg->len));
+ return false;
+ }
+ return true;
+ default:
+ return true;
}
- return true;
}

/* TCH-RTS-IND prim received from bts model */
diff --git a/src/osmo-bts-omldummy/Makefile.am b/src/osmo-bts-omldummy/Makefile.am
index 81da29b..f7a0504 100644
--- a/src/osmo-bts-omldummy/Makefile.am
+++ b/src/osmo-bts-omldummy/Makefile.am
@@ -20,6 +20,7 @@
$(LIBOSMOABIS_LIBS) \
$(LIBOSMOTRAU_LIBS) \
$(LIBOSMONETIF_LIBS) \
+ $(LIBOSMOCODEC_LIBS) \
-ldl \
$(NULL)


To view, visit change 32668. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I89df2f12c49dd5378667cf149d19bde654f80134
Gerrit-Change-Number: 32668
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon@freecalypso.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-MessageType: merged