Change in osmo-ttcn3-hacks[master]: BSC_Tests: use correct payload types and encoding names on MGCP

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/gerrit-log@lists.osmocom.org/.

dexter gerrit-no-reply at lists.osmocom.org
Mon Jun 25 15:12:09 UTC 2018


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/9737


Change subject: BSC_Tests: use correct payload types and encoding names on MGCP
......................................................................

BSC_Tests: use correct payload types and encoding names on MGCP

The test currently use a hardcoded payload type and encoding name.
This does mean in practice that even when an assignment with EFR
is happeining. The MGCP responses to the BSC tell that the codec
is AMR. This is not correct. The testcases should always pick a
suitable payload type / encoding name in the MGCP response

- Add constants for IANA/3GPP assigned payload types
- Add function to lookup the right encoding name for a payload type
- Initalize the encoding name and payload type in g_media according
  to the BSSAP PDU.

Change-Id: I2735267091059e2f2169da80bdcd30abc2b1554b
Realted: OS#2728
---
M bsc/MSC_ConnectionHandler.ttcn
M library/MGCP_Emulation.ttcn
M library/MGCP_Types.ttcn
3 files changed, 67 insertions(+), 6 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/37/9737/1

diff --git a/bsc/MSC_ConnectionHandler.ttcn b/bsc/MSC_ConnectionHandler.ttcn
index 2042979..0f123b6 100644
--- a/bsc/MSC_ConnectionHandler.ttcn
+++ b/bsc/MSC_ConnectionHandler.ttcn
@@ -32,6 +32,24 @@
  * Media related handling
  ***********************************************************************/
 
+/* Get the matching payload type for a specified BSSAP codec type
+ * (see also: BSSAP_Types.ttcn */
+private function f_get_mgcp_pt(BSSMAP_FIELD_CodecType codecType) return SDP_FIELD_PayloadType {
+	if (codecType == GSM_FR) {
+		return PT_GSM;
+	} else if (codecType == GSM_HR) {
+		return PT_GSMHR;
+	} else if (codecType == GSM_EFR) {
+		return PT_GSMEFR;
+	} else if (codecType == FR_AMR or codecType == HR_AMR) {
+		return PT_AMR;
+	} else if (codecType == FR_AMR_WB or codecType == OHR_AMR or codecType == OFR_AMR_WB or codecType == OHR_AMR_WB) {
+		return PT_AMRWB;
+	}
+
+	return PT_PCMU;
+}
+
 /* Tuple containing host/ip and port */
 type record HostPort {
 	HostName	host,
@@ -66,7 +84,7 @@
 	BtsMediaState	bts1 /* only during hand-over */
 };
 
-function f_MediaState_init(inout MediaState g_media, integer nr, HostName bts, HostName mgw) {
+function f_MediaState_init(inout MediaState g_media, integer nr, HostName bts, HostName mgw, BSSMAP_FIELD_CodecType codecType) {
 	/* BTS Side */
 	g_media.bts := {
 		ipa_crcx_seen := false,
@@ -93,10 +111,10 @@
 	g_media.mgcp_ep := "rtpbridge/" & int2str(nr) & "@mgw";
 
 	for (var integer i:= 0; i < sizeof(g_media.mgcp_conn); i := i+1) {
-		g_media.mgcp_conn[i].mime_type := "AMR";
+		g_media.mgcp_conn[i].mime_type := f_encoding_name_from_pt(f_get_mgcp_pt(codecType));
 		g_media.mgcp_conn[i].sample_rate := 8000;
 		g_media.mgcp_conn[i].ptime := 20;
-		g_media.mgcp_conn[i].rtp_pt := 98;
+		g_media.mgcp_conn[i].rtp_pt := enum2int(f_get_mgcp_pt(codecType));
 		g_media.mgcp_conn[i].crcx_seen := false;
 		g_media.mgcp_conn[i].conn_id := f_mgcp_alloc_conn_id();
 	}
@@ -301,8 +319,8 @@
 }
 
 /* initialize all parameters */
-function f_MscConnHdlr_init(integer i, HostName bts, HostName mgw) runs on MSC_ConnHdlr {
-	f_MediaState_init(g_media, i, bts, mgw);
+function f_MscConnHdlr_init(integer i, HostName bts, HostName mgw, BSSMAP_FIELD_CodecType codecType) runs on MSC_ConnHdlr {
+	f_MediaState_init(g_media, i, bts, mgw, codecType);
 	if (not g_vty_initialized) {
 		map(self:BSCVTY, system:BSCVTY);
 		f_vty_set_prompts(BSCVTY);
@@ -754,7 +772,18 @@
 /* establish a channel fully, expecting an assignment matching 'exp' */
 function f_establish_fully(template (omit) PDU_BSSAP ass_tpl, template PDU_BSSAP exp_ass_cpl)
 runs on MSC_ConnHdlr {
-	f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3");
+
+	var BSSMAP_FIELD_CodecType codecType;
+
+	if (isvalue(ass_tpl.pdu.bssmap.assignmentRequest.codecList)) {
+		codecType := valueof(ass_tpl.pdu.bssmap.assignmentRequest.codecList.codecElements[0].codecType);
+	} else {
+		/* Make sure a meaningful default is assigned in case the
+		 * codecList is not populated */
+		codecType := FR_AMR;
+	}
+
+	f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", codecType);
 
 	/* patch in the LCLS related items, as needed */
 	f_ass_patch_lcls(ass_tpl, exp_ass_cpl);
diff --git a/library/MGCP_Emulation.ttcn b/library/MGCP_Emulation.ttcn
index b02dc06..0863511 100644
--- a/library/MGCP_Emulation.ttcn
+++ b/library/MGCP_Emulation.ttcn
@@ -441,5 +441,26 @@
 	return omit;
 }
 
+/* Determine encoding name for a specified payload type number */
+function f_encoding_name_from_pt(SDP_FIELD_PayloadType pt) return charstring {
+	if (pt == PT_PCMU) {
+		return "PCMU";
+	} else if (pt == PT_GSM) {
+		return "GSM";
+	} else if (pt == PT_PCMA) {
+		return "PCMA";
+	} else if (pt == PT_GSMEFR) {
+		return "GSM-EFR";
+	} else if (pt == PT_GSMHR) {
+		return "GSM-HR-08";
+	} else if (pt == PT_AMR) {
+		return "AMR";
+	} else if (pt == PT_AMRWB) {
+		return "AMR-WB";
+	}
+
+	setverdict(fail);
+	return "";
+}
 
 }
diff --git a/library/MGCP_Types.ttcn b/library/MGCP_Types.ttcn
index 9d1a4e1..6bb266e 100644
--- a/library/MGCP_Types.ttcn
+++ b/library/MGCP_Types.ttcn
@@ -121,5 +121,16 @@
 	external function dec_MgcpMessage(in charstring  id) return MgcpMessage
 		with { extension "prototype(convert) decode(TEXT)" };
 
+	/* IANA / 3gpp assigned payload type numbers */
+	type enumerated SDP_FIELD_PayloadType {
+		PT_PCMU(0),
+		PT_GSM(3),
+		PT_PCMA(8),
+		PT_G729(18),
+		PT_GSMEFR(110),
+		PT_GSMHR(111),
+		PT_AMR(112),
+		PT_AMRWB(113)
+	}
 
 } with { encode "TEXT" }

-- 
To view, visit https://gerrit.osmocom.org/9737
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2735267091059e2f2169da80bdcd30abc2b1554b
Gerrit-Change-Number: 9737
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180625/cae4b04c/attachment.htm>


More information about the gerrit-log mailing list