[PATCH 5/9] Adding handling of BFI (Bad Frame Indicatior) of received TRAU frames

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Andreas Eversberg jolly at eversberg.eu
Wed Jan 22 09:05:54 UTC 2014


If a bad TRAU frame is received, it is forwarded to MNCC application
as GSM_BAD_FRAME. The application can now handle the GAP of missing
audio. (e.g. by extrapolation)

If TRAU frames are forwarded via RTP, bad frames are dropped, but frame
counter and timestamp of RTP sender state is increased.
---
 openbsc/include/openbsc/mncc.h  |  2 +-
 openbsc/src/libmsc/mncc_sock.c  |  3 ++-
 openbsc/src/libtrau/rtp_proxy.c | 11 +++++++++++
 openbsc/src/libtrau/trau_mux.c  |  7 +++++--
 openbsc/tests/trau/trau_test.c  |  2 +-
 5 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/openbsc/include/openbsc/mncc.h b/openbsc/include/openbsc/mncc.h
index 45ad83e..48f4f7d 100644
--- a/openbsc/include/openbsc/mncc.h
+++ b/openbsc/include/openbsc/mncc.h
@@ -97,7 +97,7 @@ struct gsm_call {
 #define GSM_TCHF_FRAME_EFR	0x0301
 #define GSM_TCHH_FRAME		0x0302
 #define GSM_TCH_FRAME_AMR	0x0303
-#define GSM_TCHF_BAD_FRAME	0x03ff
+#define GSM_BAD_FRAME		0x03ff
 
 #define MNCC_SOCKET_HELLO	0x0400
 
diff --git a/openbsc/src/libmsc/mncc_sock.c b/openbsc/src/libmsc/mncc_sock.c
index 4a880c7..c8cfa6a 100644
--- a/openbsc/src/libmsc/mncc_sock.c
+++ b/openbsc/src/libmsc/mncc_sock.c
@@ -57,7 +57,8 @@ int mncc_sock_from_cc(struct gsm_network *net, struct msgb *msg)
 		if (msg_type != GSM_TCHF_FRAME
 		 && msg_type != GSM_TCHF_FRAME_EFR
 		 && msg_type != GSM_TCHH_FRAME
-		 && msg_type != GSM_TCH_FRAME_AMR) {
+		 && msg_type != GSM_TCH_FRAME_AMR
+		 && msg_type != GSM_BAD_FRAME) {
 			/* release the request */
 			struct gsm_mncc mncc_out;
 			memset(&mncc_out, 0, sizeof(mncc_out));
diff --git a/openbsc/src/libtrau/rtp_proxy.c b/openbsc/src/libtrau/rtp_proxy.c
index 59efa21..89ed8a4 100644
--- a/openbsc/src/libtrau/rtp_proxy.c
+++ b/openbsc/src/libtrau/rtp_proxy.c
@@ -277,6 +277,14 @@ int rtp_send_frame(struct rtp_socket *rs, struct gsm_data_frame *frame)
 		duration = RTP_GSM_DURATION;
 		amr = 1;
 		break;
+	case GSM_BAD_FRAME:
+		/* in case of a bad frame, just count and drop packt */
+		payload_type = 0;
+		payload_len = 0;
+		duration = RTP_GSM_DURATION;
+		rs->transmit.timestamp += duration;
+		rs->transmit.sequence++;
+		break;
 	default:
 		DEBUGPC(DLMUX, "unsupported message type %d\n",
 			frame->msg_type);
@@ -304,6 +312,9 @@ int rtp_send_frame(struct rtp_socket *rs, struct gsm_data_frame *frame)
 		}
 	}
 
+	if (frame->msg_type == GSM_BAD_FRAME)
+		return 0;
+
 	msg = msgb_alloc(sizeof(struct rtp_hdr) + payload_len, "RTP-GSM-FULL");
 	if (!msg)
 		return -ENOMEM;
diff --git a/openbsc/src/libtrau/trau_mux.c b/openbsc/src/libtrau/trau_mux.c
index 7b9bac0..bb513cc 100644
--- a/openbsc/src/libtrau/trau_mux.c
+++ b/openbsc/src/libtrau/trau_mux.c
@@ -242,7 +242,10 @@ struct msgb *trau_decode_fr(uint32_t callref,
 		i++;
 		j++;
 	}
-	frame->msg_type = GSM_TCHF_FRAME;
+	if (tf->c_bits[11]) /* BFI */
+		frame->msg_type = GSM_BAD_FRAME;
+	else
+		frame->msg_type = GSM_TCHF_FRAME;
 	frame->callref = callref;
 	msgb_put(msg, sizeof(struct gsm_data_frame) + 33);
 
@@ -314,7 +317,7 @@ struct msgb *trau_decode_efr(uint32_t callref,
 	return msg;
 
 bad_frame:
-	frame->msg_type = GSM_TCHF_BAD_FRAME;
+	frame->msg_type = GSM_BAD_FRAME;
 
 	return msg;
 }
diff --git a/openbsc/tests/trau/trau_test.c b/openbsc/tests/trau/trau_test.c
index f8a48db..b95f1e8 100644
--- a/openbsc/tests/trau/trau_test.c
+++ b/openbsc/tests/trau/trau_test.c
@@ -57,7 +57,7 @@ void test_trau_fr_efr(unsigned char *data)
 	msg = trau_decode_efr(1, &tf);
 	OSMO_ASSERT(msg != NULL);
 	frame = (struct gsm_data_frame *)msg->data;
-	OSMO_ASSERT(frame->msg_type == GSM_TCHF_BAD_FRAME);
+	OSMO_ASSERT(frame->msg_type == GSM_BAD_FRAME);
 	msgb_free(msg);
 }
 
-- 
1.8.1.5





More information about the OpenBSC mailing list