Change in osmo-ttcn3-hacks[master]: pcu: Get rid of PCU_Tests.ttcn tests

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/.

pespin gerrit-no-reply at lists.osmocom.org
Thu Apr 30 11:12:16 UTC 2020


pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16321 )

Change subject: pcu: Get rid of PCU_Tests.ttcn tests
......................................................................

pcu: Get rid of PCU_Tests.ttcn tests

Delete PCU_Tests.ttcn along with the configs, since they are broken and
we are only adding new tests to PCU_Tests_RAW.ttcn. They are broken
because it's not possible to run multiple tests after another.

Some components which used to be in PCU_Tests.ttcn and which were used
by other PCU_Tests*.ttcn files have been moved to SGSN_Components.ttcn

Selftests have been moved to PCU_selftest.ttcn.

Small placeholder for module PCU_Tests is left in PCU_Tests.ttcn to
still be able to compile the binary as "PCU_Tests" and avoid changing
that part of docker setup. We'll eventually rename RAW tests soon
anyway.

Change-Id: Ie862a1525e9f4f9a3f2427ac3898810e3d044d2f
---
M pcu/PCU_Tests.cfg
M pcu/PCU_Tests.default
M pcu/PCU_Tests.ttcn
M pcu/PCU_Tests_RAW.ttcn
M pcu/PCU_Tests_RAW_NS.ttcn
M pcu/PCU_Tests_RAW_SNS.ttcn
M pcu/PCU_Tests_SNS.cfg
A pcu/PCU_selftest.ttcn
M pcu/README.md
A pcu/SGSN_Components.ttcn
M pcu/gen_links.sh
D pcu/osmo-bsc.cfg
D pcu/osmo-bts.cfg
M pcu/regen_makefile.sh
14 files changed, 380 insertions(+), 990 deletions(-)

Approvals:
  Jenkins Builder: Verified
  osmith: Looks good to me, but someone else must approve
  fixeria: Looks good to me, but someone else must approve
  pespin: Looks good to me, approved



diff --git a/pcu/PCU_Tests.cfg b/pcu/PCU_Tests.cfg
index 0424e4f..692ebbd 100644
--- a/pcu/PCU_Tests.cfg
+++ b/pcu/PCU_Tests.cfg
@@ -7,7 +7,7 @@
 [LOGGING]
 
 [MODULE_PARAMETERS]
-PCU_Tests.mp_nsconfig := {
+SGSN_Components.mp_nsconfig := {
 	local_ip := "127.0.0.1",
 	local_udp_port := 23000,
 	remote_ip := "127.0.0.1",
diff --git a/pcu/PCU_Tests.default b/pcu/PCU_Tests.default
index 537744f..9d9e966 100644
--- a/pcu/PCU_Tests.default
+++ b/pcu/PCU_Tests.default
@@ -7,7 +7,7 @@
 ConsoleMask := ERROR | WARNING | TESTCASE | TIMEROP_START | DEBUG_ENCDEC
 
 [MODULE_PARAMETERS]
-PCU_Tests.mp_gb_cfg := {
+SGSN_Components.mp_gb_cfg := {
 	nsei := 1234,
 	bvci := 1234,
 	cell_id := {
diff --git a/pcu/PCU_Tests.ttcn b/pcu/PCU_Tests.ttcn
index 7ef3d0a..43a6178 100644
--- a/pcu/PCU_Tests.ttcn
+++ b/pcu/PCU_Tests.ttcn
@@ -1,706 +1,2 @@
 module PCU_Tests {
-
-/* Osmocom PCU test suite in TTCN-3
- * (C) 2018-2019 Harald Welte <laforge at gnumonks.org>
- * All rights reserved.
- *
- * Released under the terms of GNU General Public License, Version 2 or
- * (at your option) any later version.
- *
- * SPDX-License-Identifier: GPL-2.0-or-later
- */
-
-import from General_Types all;
-import from Osmocom_Types all;
-import from GSM_Types all;
-import from GSM_RR_Types all;
-import from Osmocom_Gb_Types all;
-import from BSSGP_Types all;
-import from BSSGP_Emulation all;
-import from NS_Types all;
-import from NS_Emulation all;
-import from LLC_Types all;
-import from LLC_Templates all;
-import from RLCMAC_Types all;
-import from RLCMAC_CSN1_Types all;
-import from LAPDm_RAW_PT all;
-import from GPRS_Context all;
-import from GPRS_TBF all;
-import from L1CTL_PortType all;
-import from MobileL3_Types all;
-import from MobileL3_CommonIE_Types all;
-import from L3_Templates all;
-
-modulepar {
-	BssgpConfig mp_gb_cfg := {
-		nsei := 1234,
-		bvci := 1234,
-		cell_id := {
-			ra_id := {
-				lai := {
-					mcc_mnc := '262F42'H, lac := 13135
-				},
-				rac := 0
-			},
-			cell_id := 20960
-		},
-		sgsn_role := true,
-		depth := BSSGP_DECODE_DEPTH_BSSGP
-	};
-
-	NSConfiguration mp_nsconfig := {
-		local_udp_port := 23000,
-		local_ip := "127.0.0.1",
-		remote_udp_port := 21000,
-		remote_ip := "127.0.0.1",
-		nsvci := 0,
-		nsei := 2342,
-		role_sgsn := true,
-		handle_sns := true
-	};
 }
-
-type component dummy_CT extends BSSGP_Client_CT {
-	var lapdm_CT lapdm_component;
-	port LAPDm_PT L1;
-
-	var NS_CT ns_component;
-	var BSSGP_CT bssgp_component;
-
-	var MmContext g_mmctx := {
-		tlli := 'FFFFFFFF'O,
-		n_u := 0
-	};
-
-	var boolean g_initialized := false;
-}
-
-function f_init() runs on dummy_CT {
-	if (g_initialized == true) {
-		return;
-	}
-	g_initialized := true;
-	/* create a new NS component */
-	ns_component := NS_CT.create;
-	bssgp_component := BSSGP_CT.create;
-	/* connect our BSSGP port to the BSSGP Emulation */
-	connect(self:BSSGP[0], bssgp_component:BSSGP_SP);
-	connect(self:BSSGP_SIG[0], bssgp_component:BSSGP_SP_SIG);
-	connect(self:BSSGP_PROC[0], bssgp_component:BSSGP_PROC);
-	/* connect lower-end of BSSGP with BSSGP_CODEC_PORT (maps to NS_PT*/
-	connect(bssgp_component:BSCP, ns_component:NS_SP);
-	/* connect lower-end of NS emulation to NS_CODEC_PORT (on top of IPl4) */
-	map(ns_component:NSCP, system:NS_CODEC_PORT);
-	ns_component.start(NSStart(mp_nsconfig));
-	bssgp_component.start(BssgpStart(mp_gb_cfg));
-
-	lapdm_component := lapdm_CT.create;
-	connect(self:L1, lapdm_component:LAPDM_SP);
-	map(lapdm_component:L1CTL, system:L1CTL);
-	lapdm_component.start(LAPDmStart());
-
-	f_bssgp_client_register(g_mmctx.imsi, g_mmctx.tlli, mp_gb_cfg.cell_id);
-	f_bssgp_establish();
-}
-
-function f_exit() runs on dummy_CT {
-	lapdm_component.stop;
-	ns_component.stop;
-	bssgp_component.stop;
-}
-
-function f_bssgp_dec_and_log(in octetstring inp) {
-	log("BSSGP Input: ", inp);
-	var PDU_BSSGP dec := dec_PDU_BSSGP(inp);
-	log("BSSGP Decoded: ", dec);
-}
-
-testcase TC_selftest_bssgp() runs on dummy_CT {
-	const octetstring c_bvc_reset_pcu := '2204820000078108088832f44000c80051e0'O;
-	const octetstring c_bvc_reset_q := '2204820000078100'O;
-	const octetstring c_status_pcu := '4107810515882204820000078103'O;
-	const octetstring c_reset_ack_q := '2304820000'O;
-	const octetstring c_reset_ack_pcu := '23048200c4'O;
-	const octetstring c_unblock_pcu := '24048200c4'O;
-	const octetstring c_unblock_ack_q := '25048200c4'O;
-	const octetstring c_fc_bvc_pcu := '261e8101058200fa038200c8018200fa1c8200c806820000'O;
-	const octetstring c_fc_bvc_ack_q := '271e8101'O;
-	const octetstring c_gmm_mo_att_req := '01bb146ddd000004088832f44000c80051e000800e003b01c001080103e5e000110a0005f4fb146ddd32f44000c8001d1b53432b37159ef9090070000dd9c6321200e00019b32c642401c0002017057bf0ec'O;
-	const octetstring c_gmm_mt_ac_req := '00bb146ddd0050001682ffff0a8204030e9c41c001081200102198c72477ea104895e8b959acc58b108182f4d045'O;
-	const octetstring c_gmm_mo_ac_resp := '01bb146ddd000004088832f44000c80051e000800e000e01c00508130122fa361f5fdd623d'O;
-	const octetstring c_gmm_mt_att_acc := '00bb146ddd0050001682ffff0a8204030e9841c005080201340432f44000c8001805f4fb146ddd0967d0'O;
-	const octetstring c_gmm_mt_det_req := '00bb146ddd0050001682ffff0a8204030e8941c00908050215f0b6'O;
-	const octetstring c_gmm_mo_att_cpl := '01fb146ddd000004088832f44000c80051e000800e000801c009080339d7bc'O;
-
-	f_bssgp_dec_and_log(c_bvc_reset_pcu);
-	f_bssgp_dec_and_log(c_bvc_reset_q);
-	f_bssgp_dec_and_log(c_status_pcu);
-	f_bssgp_dec_and_log(c_reset_ack_q);
-	f_bssgp_dec_and_log(c_reset_ack_pcu);
-	f_bssgp_dec_and_log(c_unblock_pcu);
-	f_bssgp_dec_and_log(c_unblock_ack_q);
-	f_bssgp_dec_and_log(c_fc_bvc_pcu);
-	f_bssgp_dec_and_log(c_fc_bvc_ack_q);
-	f_bssgp_dec_and_log(c_gmm_mo_att_req);
-	f_bssgp_dec_and_log(c_gmm_mt_ac_req);
-	f_bssgp_dec_and_log(c_gmm_mo_ac_resp);
-	f_bssgp_dec_and_log(c_gmm_mt_att_acc);
-	f_bssgp_dec_and_log(c_gmm_mt_det_req);
-	f_bssgp_dec_and_log(c_gmm_mo_att_cpl);
-
-	log(ts_BSSGP_PS_PAGING_IMSI(196, '262420123456789'H));
-}
-
-function f_ns_assert_prepr(in octetstring a, in octetstring b) {
-	log("NS Input: ", a);
-	log("NS Expected: ", b);
-
-	if (a != b) {
-		setverdict(fail, "Values mismatch", a, b);
-		mtc.stop;
-	} else {
-		setverdict(pass);
-	}
-}
-
-function f_ns_dec_and_log(in octetstring inp) {
-	log("NS Input: ", inp);
-	var PDU_NS dec := dec_PDU_NS(inp);
-	log("NS Decoded: ", dec);
-}
-
-testcase TC_selftest_ns() runs on dummy_CT {
-	const octetstring c_ns_reset_pcu := '000000c4271e813d'O;
-
-	/* single byte length to two byte length */
-	f_ns_assert_prepr('04058101'O, '0405000101'O);
-	f_ns_assert_prepr('040589000102030405060708'O, '04050009000102030405060708'O);
-	/* two byte length to two byte length */
-	f_ns_assert_prepr('0405000101'O, '0405000101'O);
-	/* special case: NS-UNITDATA */
-	f_ns_assert_prepr('00aabbccddeeffaa29822342'O, '00aabbccddeeffaa2900022342'O);
-	/* multiple TLVs */
-	f_ns_assert_prepr('234281aa4382bbbb'O, '23420001aa430002bbbb'O);
-	/* zero-length */
-	f_ns_assert_prepr('230080'O, '23000000'O);
-
-	f_ns_dec_and_log(c_ns_reset_pcu);
-}
-
-const octetstring gmm_auth_req := '081200102198c72477ea104895e8b959acc58b108182'O;
-
-/* Wrap downlink GMM into LLC, encode + send it via BSSGP to PCU */
-function tx_gmm(BIT1 c_r, in octetstring gmm_pdu, BIT4 sapi := c_LLC_SAPI_LLGMM) runs on dummy_CT {
-	var PDU_LLC llc;
-
-	//log("GMM Tx: ", dec_PDU_L3_SGSN_MS(gmm_pdu));
-
-	log(c_r, g_mmctx.n_u, gmm_pdu, sapi);
-	llc := valueof(ts_LLC_UI(gmm_pdu, sapi, c_r, g_mmctx.n_u));
-	log(llc);
-	g_mmctx.n_u := g_mmctx.n_u + 1;
-
-	log(ts_BSSGP_DL_UD(g_mmctx.tlli, enc_PDU_LLC(llc)));
-
-	BSSGP[0].send(ts_BSSGP_DL_UD(g_mmctx.tlli, enc_PDU_LLC(llc)));
-}
-
-/* Establish BSSGP connection to PCU */
-function f_bssgp_establish() runs on BSSGP_Client_CT {
-	timer T:= 10.0;
-
-	T.start
-	alt {
-	[] BSSGP[0].receive(t_BssgpStsInd(?, ?, BVC_S_UNBLOCKED)) { }
-	[] BSSGP[0].receive { repeat; }
-	[] T.timeout {
-		setverdict(fail, "Timeout establishing BSSGP connection");
-		mtc.stop;
-		}
-	}
-	T.stop
-	log("BSSGP successfully initialized");
-}
-
-function f_wait_paging_req_type1(template (present) MobileIdentityV mi) runs on dummy_CT {
-	var LAPDm_ph_data ph_data;
-	timer T := 5.0;
-
-	T.start;
-	alt {
-	[] L1.receive(LAPDm_ph_data:{sacch:=?,sapi:=0,lapdm:={bbis:=?}}) -> value ph_data {
-		var octetstring payload := substr(ph_data.lapdm.bbis.payload, 1, lengthof(ph_data.lapdm.bbis.payload) - 1);
-		var PDU_ML3_NW_MS pdu;
-
-		if (dec_PDU_ML3_NW_MS_backtrack(payload, pdu) != 0) {
-			repeat;
-		}
-
-		if (not ischosen(pdu.msgs.rrm)) {
-			repeat;
-		}
-
-		if (match(pdu, tr_PAGING_REQ1(tr_MI_LV(mi)))) {
-			setverdict(pass);
-		} else {
-			repeat;
-		}
-	}
-	[] L1.receive { repeat; }
-	[] T.timeout { setverdict(fail); }
-	}
-}
-
-/* Send PS-PAGING via BSSGP to PCU, expect it to show up on L1/Um */
-testcase TC_paging() runs on dummy_CT {
-	var hexstring tmsi_hex := '01234567'H;
-	var GsmTmsi tmsi := hex2int(tmsi_hex);
-
-	g_mmctx.imsi := '262420123456789'H;
-	g_mmctx.tlli := f_random_tlli();
-	f_init();
-
-	var BCCH_tune_req tune_req := { { false, 871 }, true };
-	L1.send(tune_req);
-	/* FIXME: wait for confirm */
-
-	/* Send paging on signalling BVCI 0 since osmo-pcu does not support paging on PTP yet. */
-	/*
-	TODO: Paging by IMSI does not work yet because osmo-pcu does not copy IMSI into paging requests.
-	BSSGP_SIG[0].send(ts_BSSGP_PS_PAGING_IMSI(0, g_mmctx.imsi));
-	f_wait_paging_req_type1(tr_MI_IMSI(g_mmctx.imsi));
-	*/
-
-	/* Page by TMSI */
-	BSSGP_SIG[0].send(ts_BSSGP_PS_PAGING_PTMSI(0, g_mmctx.imsi, tmsi));
-	f_wait_paging_req_type1(t_MI_TMSI(hex2oct(tmsi_hex)));
-}
-
-/* Establish an UL TBF: Tune to ARFCN, send RACH, receive AGCH, enable TBF Rx */
-function f_establish_ul_tbf() runs on dummy_CT {
-	timer T := 5.0;
-	var BCCH_tune_req tune_req := { { false, 871 }, true };
-	L1.send(tune_req);
-	/* FIXME: wait for confirm */
-
-	var TBF_UL_establish_req est_req := { tbf_nr := 0, ra := hex2int('7B'H) };
-	L1.send(est_req);
-	T.start;
-	/* FIXME: wait for confirm */
-	alt {
-	[] L1.receive(TBF_UL_establish_res:?) {}
-	[] L1.receive { repeat; }
-	[] T.timeout {
-		setverdict(fail, "Timeout establishing UL TBF");
-		mtc.stop;
-		}
-	}
-	T.stop;
-}
-
-/* compute a random TLLI; FIXME: what about TLLI prefix / local/foreign/...? */
-function f_random_tlli() return GprsTlli {
-	var GprsTlli tlli := f_rnd_octstring(4);
-	return tlli;
-}
-
-/* Compute the frame number of the uplink block based on current fn + rrbp */
-function f_rrbp_fn(GsmFrameNumber fn, MacRrbp rrbp) return GsmFrameNumber {
-	var integer add;
-	select (rrbp) {
-	case (RRBP_Nplus13_mod_2715648) {
-		add := 13;
-		}
-	case (RRBP_Nplus17_or_18_mod_2715648) {
-		add := 17; /* FIXME: What about 'or 18'? */
-		}
-	case (RRBP_Nplus21_or_22_mod_2715648) {
-		add := 21; /* FIXME: What about 'or 22'? */
-		}
-	case (RRBP_Nplus26_mod_2715648) {
-		add := 26;
-		}
-	}
-	return (fn + add) mod 2715648;
-}
-
-
-function f_bssgp_wait_ul_ud(template PDU_BSSGP exp) runs on dummy_CT {
-	timer T := 5.0;
-	T.start;
-	alt {
-	[] BSSGP[0].receive(exp) {
-		log("found matching BSSGP UL-UNITDATA PDU");
-		}
-	[] T.timeout {
-		setverdict(fail, "Timeout waiting for ", exp);
-		mtc.stop;
-		}
-	}
-}
-
-
-function f_ul_tbf(inout UlTbfState us) runs on dummy_CT {
-	var RLCMAC_ph_data_ind dl;
-
-	/* Establish an UL-TBF */
-	f_establish_ul_tbf();
-
-	while (true) {
-		var RlcmacUlBlock blk;
-		if (f_ul_tbf_get_next_block(blk, us, g_mmctx, true) == false) {
-			break;
-		}
-
-		/* Send the block to L1 for transmission */
-		log("L1=", blk);
-		L1.send(RLCMAC_ph_data_req:{dyn:={tbf_id := 0, cs := us.tbf.initial_cs, block := blk}});
-	}
-
-	alt {
-	[] L1.receive(RLCMAC_ph_data_ind:{cs:=?, ts_nr:=?, fn:=?, block:=tr_RLCMAC_UL_ACK_NACK(0, g_mmctx.tlli)}) -> value dl {
-		log("found matching ACK/NACK");
-		/* send CTRL ACK in uplink */
-		var GsmFrameNumber ul_fn := f_rrbp_fn(dl.fn, dl.block.ctrl.mac_hdr.rrbp);
-		var RlcmacUlCtrlMsg ctrl_ack := valueof(ts_RlcMacUlCtrl_PKT_CTRL_ACK(g_mmctx.tlli));
-		var RlcmacUlBlock ul_block := valueof(ts_RLC_UL_CTRL_ACK(ctrl_ack));
-		L1.send(ts_PH_DATA_ABS(0, CS1, dl.ts_nr, ul_fn, {false, 871}, ul_block));
-		/* wait for the final ACK */
-		if (dl.block.ctrl.payload.u.ul_ack_nack.gprs.ack_nack_desc.final_ack == '0'B) {
-			repeat;
-		}
-		}
-	[] L1.receive { repeat; }
-	}
-
-	for (var integer i := 0; i < sizeof(us.tbf.llc_pdus_enc); i := i+1) {
-		f_bssgp_wait_ul_ud(tr_BSSGP_UL_UD(g_mmctx.tlli, ?, us.tbf.llc_pdus_enc[i]));
-	}
-	setverdict(pass);
-
-	L1.send(DCCH_release_req:{});
-}
-
-testcase TC_rach() runs on dummy_CT {
-	var BssgpBvci bvci := 196;
-	g_mmctx.imsi := '262420123456789'H;
-	g_mmctx.tlli := f_random_tlli();
-
-	f_init();
-
-	f_bssgp_client_register(g_mmctx.imsi, g_mmctx.tlli, mp_gb_cfg.cell_id);
-
-	f_bssgp_establish();
-}
-
-
-
-function f_llc_dec_and_log(in octetstring inp) {
-	log("LLC Input: ", inp);
-	var PDU_LLC dec := dec_PDU_LLC(inp);
-	log("LLC Decoded: ", dec);
-}
-
-function f_llc_assert(in octetstring a, in octetstring b) {
-	log("LLC Input: ", a);
-	log("LLC Expected: ", b);
-
-	if (a != b) {
-		setverdict(fail, "LLC input ", b, " != expected ", a);
-		mtc.stop;
-	} else {
-		setverdict(pass);
-	}
-}
-
-
-testcase TC_selftest_llc() runs on dummy_CT {
-	const octetstring c_gmm_att_pcu := '01c001080103e5e000210a0005f4fb146ddd32f44000c8001d1b53432b37159ef9090070000dd9c6321200e00019b32c642401c00020170580460b'O;
-	const octetstring c_gmm_att_pcu_nofcs := '01c001080103e5e000210a0005f4fb146ddd32f44000c8001d1b53432b37159ef9090070000dd9c6321200e00019b32c642401c000201705'O;
-
-	f_llc_dec_and_log(c_gmm_att_pcu);
-
-	//f_llc_assert(f_LLC_append_fcs(c_gmm_att_pcu_nofcs), c_gmm_att_pcu);
-
-	log(valueof(ts_LLC_UI(gmm_auth_req, c_LLC_SAPI_LLGMM, LLC_CR_DL_CMD, g_mmctx.n_u)));
-	log(ts_LLC_UI(gmm_auth_req, c_LLC_SAPI_LLGMM, LLC_CR_DL_CMD, g_mmctx.n_u));
-}
-
-testcase TC_selftest_rlcmac() runs on dummy_CT {
-	var RlcmacDlCtrlBlock dcb;
-	var RlcmacUlCtrlBlock ucb;
-	const octetstring c_dl_ul_ack_nack := '40240080400000000000000077628dbba14b2b2b2b2b2b'O;
-	const octetstring c_dl_data := '0f00007341c001081200102198c72477ea104895e8b959acc58b108182f4d0454300'O;
-	const octetstring c_dl_data2 := '070002165dc0012b2b2b43c0012b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b00'O;
-	const octetstring c_ul_ctrl_ack := '4006ec51b7772b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b'O;
-	const octetstring c_ul_dl_ack_nack := '4008004000000000000000701000edc0000b2b2b2b2b2b'O;
-	const octetstring c_dl_ul_assign := '482857628dbbaf0126e68800082b2b2b2b2b2b2b2b2b2b'O;
-
-	log(c_dl_ul_ack_nack);
-	dcb := dec_RlcmacDlCtrlBlock(c_dl_ul_ack_nack);
-	log(dcb);
-	//log(dec_RlcmacDlCtrlMsg(dcb.payload));
-
-	f_rlcmac_dld_decenc(c_dl_data);
-
-	f_rlcmac_dld_decenc(c_dl_data2);
-
-	log(c_ul_ctrl_ack);
-	ucb := dec_RlcmacUlCtrlBlock(c_ul_ctrl_ack);
-	log(ucb);
-	//log(dec_RlcmacUlCtrlMsg(ucb.payload));
-
-	log(c_ul_dl_ack_nack);
-	ucb := dec_RlcmacUlCtrlBlock(c_ul_dl_ack_nack);
-	log(ucb);
-	//log(dec_RlcmacUlCtrlMsg(ucb.payload));
-
-	log(c_dl_ul_assign);
-	dcb := dec_RlcmacDlCtrlBlock(c_dl_ul_assign);
-	log(dcb);
-	//log(dec_RlcmacDlCtrlMsg(dcb.payload));
-
-	const octetstring c_uld_tlli_noext := '080101a61cab5201c001080103e5e000310a0005f4e61cab5232f44000c8001d1b00'O;
-	f_rlcmac_uld_decenc(c_uld_tlli_noext);
-
-	const octetstring c_uld_tlli_ext7pad := '0001041da61cab5200201705a96e102b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b00'O;
-	log("ULD_decenc");
-	f_rlcmac_uld_decenc(c_uld_tlli_ext7pad);
-	log("UL_decenc");
-	f_rlcmac_ul_decenc(c_uld_tlli_ext7pad);
-
-	f_rlcmac_ul_decenc(c_ul_dl_ack_nack);
-}
-
-function f_rlcmac_ul_decenc(in octetstring buf) {
-	log("==================================");
-	log("In: ", buf);
-	var RlcmacUlBlock udb := dec_RlcmacUlBlock(buf);
-	log("Dec: ", udb);
-	var octetstring enc := enc_RlcmacUlBlock(udb);
-	log("Enc: ", enc);
-	if (enc != buf) {
-		setverdict(fail, "Re-encoded data doesn't equal input data");
-		mtc.stop;
-	}
-}
-
-function f_rlcmac_uld_decenc(in octetstring buf) {
-	log("==================================");
-	log("In: ", buf);
-	var RlcmacUlDataBlock udb := dec_RlcmacUlDataBlock(buf);
-	log("Dec: ", udb);
-	var octetstring enc := enc_RlcmacUlDataBlock(udb);
-	log("Enc: ", enc);
-	if (enc != buf) {
-		setverdict(fail, "Re-encoded data doesn't equal input data");
-		mtc.stop;
-	}
-}
-
-function f_rlcmac_dld_decenc(in octetstring buf) {
-	log("==================================");
-	log("In: ", buf);
-	var RlcmacDlDataBlock udb := dec_RlcmacDlDataBlock(buf);
-	log("Dec: ", udb);
-	var octetstring enc := enc_RlcmacDlDataBlock(udb);
-	log("Enc: ", enc);
-	if (enc != buf) {
-		setverdict(fail, "Re-encoded data doesn't equal input data");
-		mtc.stop;
-	}
-}
-
-
-testcase TC_selftest_rr() runs on dummy_CT {
-	//const octetstring c_paging_none := '06210001F02B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O
-	const octetstring c_paging_none := '1506210001F0'O;
-	const octetstring c_ia_tbf := '2d063f100fe3677bd8440000c800100b2b2b2b2b2b2b2b'O
-	log(c_paging_none);
-	log(dec_GsmRrMessage(c_paging_none));
-
-	log(c_ia_tbf);
-	log(dec_GsmRrMessage(c_ia_tbf));
-}
-
-function f_seq_octstr(integer len) return octetstring {
-	var octetstring payload := ''O;
-	for (var integer i := 0; i < len; i := i+1 ) {
-		payload := payload & int2oct(i mod 256, 1);
-	}
-	return payload;
-}
-
-testcase TC_ul_tbf_single_llc_sizes() runs on dummy_CT {
-	g_mmctx.imsi := '262420123456789'H;
-	g_mmctx.tlli := f_random_tlli();
-	f_init();
-
-	for (var integer len := 1; len <= 1560; len := len+1) {
-		log("Testing Uplink TBF with single LLC-PDU of ", len, " bytes");
-		var octetstring payload := f_seq_octstr(len);
-		var UlTbfPars ul_tbf_pars := {
-			ack_mode := true,
-			initial_cs := CS1,
-			llc_pdus := {
-				valueof(ts_LLC_UI(payload, c_LLC_SAPI_LLGMM, '0'B, g_mmctx.n_u))
-			}
-		}
-		var UlTbfState ul_tbf_state;
-		f_UlTbfState_init(ul_tbf_state, ul_tbf_pars);
-		f_ul_tbf(ul_tbf_state);
-		f_sleep(1.0);
-	}
-
-	f_exit();
-}
-
-testcase TC_ul_tbf() runs on dummy_CT {
-	g_mmctx.imsi := '262420123456789'H;
-	g_mmctx.tlli := f_random_tlli();
-	f_init();
-
-	var octetstring payload := f_seq_octstr(1023);
-	var UlTbfPars ul_tbf_pars := {
-		ack_mode := true,
-		initial_cs := CS1,
-		llc_pdus := { 
-			valueof(ts_LLC_UI(payload, c_LLC_SAPI_LLGMM, '0'B, g_mmctx.n_u)),
-			valueof(ts_LLC_UI(payload, c_LLC_SAPI_LLGMM, '0'B, g_mmctx.n_u+1)),
-			valueof(ts_LLC_UI(payload, c_LLC_SAPI_LLGMM, '0'B, g_mmctx.n_u+2)),
-			valueof(ts_LLC_UI(payload, c_LLC_SAPI_LLGMM, '0'B, g_mmctx.n_u+3)),
-			valueof(ts_LLC_UI(payload, c_LLC_SAPI_LLGMM, '0'B, g_mmctx.n_u+4)),
-			valueof(ts_LLC_UI(payload, c_LLC_SAPI_LLGMM, '0'B, g_mmctx.n_u+5))
-		}
-	};
-	var UlTbfState ul_tbf_state;
-	f_UlTbfState_init(ul_tbf_state, ul_tbf_pars);
-	f_ul_tbf(ul_tbf_state);
-
-	f_exit();
-}
-
-testcase TC_dl_tbf() runs on dummy_CT {
-	g_mmctx.imsi := '262420123456789'H;
-	g_mmctx.tlli := f_random_tlli();
-	f_init();
-
-	f_establish_dl_tbf();
-
-	f_exit();
-}
-
-function f_wait_tbf_dl(TbfNr tbf_nr, GprsTlli tlli) runs on dummy_CT return ImmediateAssignment {
-	var template PacketDlAssign dl_ass := tr_PacketDlAssign(tlli);
-	var template IaRestOctets rest := tr_IaRestOctets_DLAss(dl_ass);
-	var LAPDm_ph_data ph_data;
-	var GsmRrMessage rr;
-	timer T := 10.0;
-	T.start;
-	alt {
-	[] L1.receive(LAPDm_ph_data:{sacch:=?,sapi:=0,lapdm:={bbis:=?}}) -> value ph_data {
-		rr := dec_GsmRrMessage(ph_data.lapdm.bbis.payload);
-		log("PCH/AGCH DL RR: ", rr);
-		if (match(rr, tr_IMM_TBF_ASS(dl := true, rest := rest))) {
-			var TbfPars tbf_pars := valueof(t_TbfParsInit);
-			log("Received IMM.ASS for our TLLI!");
-			tbf_pars.tfi[rr.payload.imm_ass.pkt_chan_desc.tn] :=
-				rr.payload.imm_ass.rest_octets.hh.pa.uldl.ass.dl.group1.tfi_assignment;
-			L1.send(TBF_DL_establish_req:{tbf_nr, tbf_pars});
-		} else {
-			repeat;
-		}
-	}
-	[] L1.receive { repeat };
-	[] T.timeout {
-		setverdict(fail, "Timeout waiting for IMM ASS")
-		mtc.stop;
-		}
-	}
-	T.stop;
-	return rr.payload.imm_ass;
-}
-
-/* Establish an UL TBF: Tune to ARFCN, send RACH, receive AGCH, enable TBF Rx */
-function f_establish_dl_tbf() runs on dummy_CT {
-	timer T := 5.0;
-	var BCCH_tune_req tune_req := { { false, 871 }, true };
-	L1.send(tune_req);
-	/* FIXME: wait for confirm */
-
-	/* sending a GMM PDU as DL-UNITDATA should trigger Paging + DL TBF Assignment */
-	tx_gmm('1'B, '01020304'O, c_LLC_SAPI_LLGMM);
-
-	/* Expect an IMM.ASS for PDCH on the AGCH */
-	f_wait_tbf_dl(0, g_mmctx.tlli);
-
-	var RLCMAC_ph_data_ind dl;
-	alt {
-	[] L1.receive(RLCMAC_ph_data_ind:{cs:=?, ts_nr:=?, fn:=?, block:=tr_RLCMAC_DATA_RRBP}) -> value dl {
-		var uint6_t tfi := dl.block.data.mac_hdr.hdr_ext.tfi;
-		var GsmFrameNumber ul_fn := f_rrbp_fn(dl.fn, dl.block.data.mac_hdr.mac_hdr.rrbp);
-		var AckNackDescription an_desc := { /* FIXME: compute this based on state */
-			final_ack := '1'B,
-			starting_seq_nr := 0,
-			receive_block_bitmap := '0000000000000000000000000000000000000000000000000000000000000001'B
-		}
-		var RlcmacUlCtrlMsg ctrl_ack;
-		ctrl_ack := valueof(ts_RlcMacUlCtrl_PKT_DL_ACK(tfi, an_desc));
-		var RlcmacUlBlock ul_block := valueof(ts_RLC_UL_CTRL_ACK(ctrl_ack));
-		L1.send(ts_PH_DATA_ABS(0, CS1, dl.ts_nr, ul_fn, {false, 871}, ul_block));
-		log("Sent DL ACK: ", ul_block);
-		}
-	[] L1.receive { repeat; }
-	}
-
-	f_sleep(10.0);
-}
-
-/* FIXME: merge this into BSSGP_Client_CT ? */
-type component bssgp_CT extends BSSGP_Client_CT {
-	var NS_CT ns_component;
-	var BSSGP_CT bssgp_component;
-	var boolean g_initialized := false;
-}
-
-/* FIXME: merge this into BSSGP_Client_CT ? */
-function f_init_bssgp() runs on bssgp_CT {
-	var MmContext mmctx := {
-		imsi := '262420000000001'H,
-		tlli := 'FFFFFFFF'O,
-		n_u := 0
-	};
-
-
-	if (g_initialized == true) {
-		return;
-	}
-	g_initialized := true;
-
-	/* create a new NS component */
-	ns_component := NS_CT.create;
-	bssgp_component := BSSGP_CT.create;
-	/* connect our BSSGP port to the BSSGP Emulation */
-	connect(self:BSSGP[0], bssgp_component:BSSGP_SP);
-	connect(self:BSSGP_SIG[0], bssgp_component:BSSGP_SP_SIG);
-	connect(self:BSSGP_PROC[0], bssgp_component:BSSGP_PROC);
-	/* connect lower-end of BSSGP with BSSGP_CODEC_PORT (maps to NS_PT*/
-	connect(bssgp_component:BSCP, ns_component:NS_SP);
-	/* connect lower-end of NS emulation to NS_CODEC_PORT (on top of IPl4) */
-	map(ns_component:NSCP, system:NS_CODEC_PORT);
-	ns_component.start(NSStart(mp_nsconfig));
-	bssgp_component.start(BssgpStart(mp_gb_cfg));
-
-	f_bssgp_client_register(mmctx.imsi, mmctx.tlli, mp_gb_cfg.cell_id);
-}
-
-
-
-control {
-	execute(TC_selftest_ns());
-	execute(TC_ul_tbf_single_llc_sizes());
-	execute(TC_ul_tbf());
-	execute(TC_paging());
-}
-
-};
diff --git a/pcu/PCU_Tests_RAW.ttcn b/pcu/PCU_Tests_RAW.ttcn
index 524dfb7..1348a8e 100644
--- a/pcu/PCU_Tests_RAW.ttcn
+++ b/pcu/PCU_Tests_RAW.ttcn
@@ -46,7 +46,7 @@
 import from PCUIF_RAW_Components all;
 import from IPL4asp_Types all;
 import from Native_Functions all;
-import from PCU_Tests all;
+import from SGSN_Components all;
 
 modulepar {
 	charstring mp_pcu_sock_path := PCU_SOCK_DEFAULT;
diff --git a/pcu/PCU_Tests_RAW_NS.ttcn b/pcu/PCU_Tests_RAW_NS.ttcn
index b1b19bb..81b60c3 100644
--- a/pcu/PCU_Tests_RAW_NS.ttcn
+++ b/pcu/PCU_Tests_RAW_NS.ttcn
@@ -12,8 +12,8 @@
 
 import from General_Types all;
 import from Osmocom_Types all;
-import from PCU_Tests all;
 import from PCU_Tests_RAW all;
+import from SGSN_Components all;
 import from Osmocom_Gb_Types all;
 import from NS_CodecPort all;
 import from NS_Types all;
diff --git a/pcu/PCU_Tests_RAW_SNS.ttcn b/pcu/PCU_Tests_RAW_SNS.ttcn
index 1a8c30f..1690ad4 100644
--- a/pcu/PCU_Tests_RAW_SNS.ttcn
+++ b/pcu/PCU_Tests_RAW_SNS.ttcn
@@ -11,8 +11,8 @@
  */
 
 import from Osmocom_Types all;
-import from PCU_Tests all;
 import from PCU_Tests_RAW_NS all;
+import from SGSN_Components all;
 import from Osmocom_Gb_Types all;
 import from NS_CodecPort all;
 import from NS_Types all;
diff --git a/pcu/PCU_Tests_SNS.cfg b/pcu/PCU_Tests_SNS.cfg
index 1419e1e..0368f36 100644
--- a/pcu/PCU_Tests_SNS.cfg
+++ b/pcu/PCU_Tests_SNS.cfg
@@ -7,7 +7,7 @@
 [LOGGING]
 
 [MODULE_PARAMETERS]
-PCU_Tests.mp_nsconfig := {
+SGSN_Components.mp_nsconfig := {
 	local_ip := "127.0.0.1",
 	local_udp_port := 23000,
 	remote_ip := "127.0.0.1",
diff --git a/pcu/PCU_selftest.ttcn b/pcu/PCU_selftest.ttcn
new file mode 100644
index 0000000..3cdb4f4
--- /dev/null
+++ b/pcu/PCU_selftest.ttcn
@@ -0,0 +1,267 @@
+module PCU_selftest {
+/*
+ * Osmocom PCU test suite in TTCN-3, selftest procedures
+ * (C) 2018-2019 Harald Welte <laforge at gnumonks.org>
+ * (C) 2020 by sysmocom s.f.m.c. GmbH <info at sysmocom.de>
+ * All rights reserved.
+ *
+ * Released under the terms of GNU General Public License, Version 2 or
+ * (at your option) any later version.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+import from BSSGP_Types all;
+import from BSSGP_Emulation all;
+import from NS_Types all;
+import from NS_Emulation all;
+import from GPRS_Context all;
+import from Osmocom_Gb_Types all;
+import from LLC_Types all;
+import from LLC_Templates all;
+import from L3_Templates all;
+import from GSM_RR_Types all;
+import from RLCMAC_Types all;
+import from RLCMAC_CSN1_Types all;
+
+type component dummy_CT extends BSSGP_Client_CT {
+	var NS_CT ns_component;
+	var BSSGP_CT bssgp_component;
+
+	var MmContext g_mmctx := {
+		tlli := 'FFFFFFFF'O,
+		n_u := 0
+	};
+
+	var boolean g_initialized := false;
+}
+
+
+///////////////////
+// BSSGP selftest
+///////////////////
+function f_bssgp_dec_and_log(in octetstring inp) {
+	log("BSSGP Input: ", inp);
+	var PDU_BSSGP dec := dec_PDU_BSSGP(inp);
+	log("BSSGP Decoded: ", dec);
+}
+
+testcase TC_selftest_bssgp() runs on dummy_CT {
+	const octetstring c_bvc_reset_pcu := '2204820000078108088832f44000c80051e0'O;
+	const octetstring c_bvc_reset_q := '2204820000078100'O;
+	const octetstring c_status_pcu := '4107810515882204820000078103'O;
+	const octetstring c_reset_ack_q := '2304820000'O;
+	const octetstring c_reset_ack_pcu := '23048200c4'O;
+	const octetstring c_unblock_pcu := '24048200c4'O;
+	const octetstring c_unblock_ack_q := '25048200c4'O;
+	const octetstring c_fc_bvc_pcu := '261e8101058200fa038200c8018200fa1c8200c806820000'O;
+	const octetstring c_fc_bvc_ack_q := '271e8101'O;
+	const octetstring c_gmm_mo_att_req := '01bb146ddd000004088832f44000c80051e000800e003b01c001080103e5e000110a0005f4fb146ddd32f44000c8001d1b53432b37159ef9090070000dd9c6321200e00019b32c642401c0002017057bf0ec'O;
+	const octetstring c_gmm_mt_ac_req := '00bb146ddd0050001682ffff0a8204030e9c41c001081200102198c72477ea104895e8b959acc58b108182f4d045'O;
+	const octetstring c_gmm_mo_ac_resp := '01bb146ddd000004088832f44000c80051e000800e000e01c00508130122fa361f5fdd623d'O;
+	const octetstring c_gmm_mt_att_acc := '00bb146ddd0050001682ffff0a8204030e9841c005080201340432f44000c8001805f4fb146ddd0967d0'O;
+	const octetstring c_gmm_mt_det_req := '00bb146ddd0050001682ffff0a8204030e8941c00908050215f0b6'O;
+	const octetstring c_gmm_mo_att_cpl := '01fb146ddd000004088832f44000c80051e000800e000801c009080339d7bc'O;
+
+	f_bssgp_dec_and_log(c_bvc_reset_pcu);
+	f_bssgp_dec_and_log(c_bvc_reset_q);
+	f_bssgp_dec_and_log(c_status_pcu);
+	f_bssgp_dec_and_log(c_reset_ack_q);
+	f_bssgp_dec_and_log(c_reset_ack_pcu);
+	f_bssgp_dec_and_log(c_unblock_pcu);
+	f_bssgp_dec_and_log(c_unblock_ack_q);
+	f_bssgp_dec_and_log(c_fc_bvc_pcu);
+	f_bssgp_dec_and_log(c_fc_bvc_ack_q);
+	f_bssgp_dec_and_log(c_gmm_mo_att_req);
+	f_bssgp_dec_and_log(c_gmm_mt_ac_req);
+	f_bssgp_dec_and_log(c_gmm_mo_ac_resp);
+	f_bssgp_dec_and_log(c_gmm_mt_att_acc);
+	f_bssgp_dec_and_log(c_gmm_mt_det_req);
+	f_bssgp_dec_and_log(c_gmm_mo_att_cpl);
+
+	log(ts_BSSGP_PS_PAGING_IMSI(196, '262420123456789'H));
+}
+
+/////////////////
+// NS selftest
+/////////////////
+function f_ns_assert_prepr(in octetstring a, in octetstring b) {
+	log("NS Input: ", a);
+	log("NS Expected: ", b);
+
+	if (a != b) {
+		setverdict(fail, "Values mismatch", a, b);
+		mtc.stop;
+	} else {
+		setverdict(pass);
+	}
+}
+
+function f_ns_dec_and_log(in octetstring inp) {
+	log("NS Input: ", inp);
+	var PDU_NS dec := dec_PDU_NS(inp);
+	log("NS Decoded: ", dec);
+}
+
+testcase TC_selftest_ns() runs on dummy_CT {
+	const octetstring c_ns_reset_pcu := '000000c4271e813d'O;
+
+	/* single byte length to two byte length */
+	f_ns_assert_prepr('04058101'O, '0405000101'O);
+	f_ns_assert_prepr('040589000102030405060708'O, '04050009000102030405060708'O);
+	/* two byte length to two byte length */
+	f_ns_assert_prepr('0405000101'O, '0405000101'O);
+	/* special case: NS-UNITDATA */
+	f_ns_assert_prepr('00aabbccddeeffaa29822342'O, '00aabbccddeeffaa2900022342'O);
+	/* multiple TLVs */
+	f_ns_assert_prepr('234281aa4382bbbb'O, '23420001aa430002bbbb'O);
+	/* zero-length */
+	f_ns_assert_prepr('230080'O, '23000000'O);
+
+	f_ns_dec_and_log(c_ns_reset_pcu);
+}
+
+/////////////////
+// LLC selftest
+/////////////////
+function f_llc_dec_and_log(in octetstring inp) {
+	log("LLC Input: ", inp);
+	var PDU_LLC dec := dec_PDU_LLC(inp);
+	log("LLC Decoded: ", dec);
+}
+
+function f_llc_assert(in octetstring a, in octetstring b) {
+	log("LLC Input: ", a);
+	log("LLC Expected: ", b);
+
+	if (a != b) {
+		setverdict(fail, "LLC input ", b, " != expected ", a);
+		mtc.stop;
+	} else {
+		setverdict(pass);
+	}
+}
+
+testcase TC_selftest_llc() runs on dummy_CT {
+	const octetstring c_gmm_att_pcu := '01c001080103e5e000210a0005f4fb146ddd32f44000c8001d1b53432b37159ef9090070000dd9c6321200e00019b32c642401c00020170580460b'O;
+	const octetstring c_gmm_att_pcu_nofcs := '01c001080103e5e000210a0005f4fb146ddd32f44000c8001d1b53432b37159ef9090070000dd9c6321200e00019b32c642401c000201705'O;
+	const octetstring gmm_auth_req := '081200102198c72477ea104895e8b959acc58b108182'O;
+
+	f_llc_dec_and_log(c_gmm_att_pcu);
+
+	//f_llc_assert(f_LLC_append_fcs(c_gmm_att_pcu_nofcs), c_gmm_att_pcu);
+
+	log(valueof(ts_LLC_UI(gmm_auth_req, c_LLC_SAPI_LLGMM, LLC_CR_DL_CMD, g_mmctx.n_u)));
+	log(ts_LLC_UI(gmm_auth_req, c_LLC_SAPI_LLGMM, LLC_CR_DL_CMD, g_mmctx.n_u));
+}
+
+
+///////////////////
+// RLCMAC selftest
+///////////////////
+
+function f_rlcmac_ul_decenc(in octetstring buf) {
+	log("==================================");
+	log("In: ", buf);
+	var RlcmacUlBlock udb := dec_RlcmacUlBlock(buf);
+	log("Dec: ", udb);
+	var octetstring enc := enc_RlcmacUlBlock(udb);
+	log("Enc: ", enc);
+	if (enc != buf) {
+		setverdict(fail, "Re-encoded data doesn't equal input data");
+		mtc.stop;
+	}
+}
+
+function f_rlcmac_uld_decenc(in octetstring buf) {
+	log("==================================");
+	log("In: ", buf);
+	var RlcmacUlDataBlock udb := dec_RlcmacUlDataBlock(buf);
+	log("Dec: ", udb);
+	var octetstring enc := enc_RlcmacUlDataBlock(udb);
+	log("Enc: ", enc);
+	if (enc != buf) {
+		setverdict(fail, "Re-encoded data doesn't equal input data");
+		mtc.stop;
+	}
+}
+
+function f_rlcmac_dld_decenc(in octetstring buf) {
+	log("==================================");
+	log("In: ", buf);
+	var RlcmacDlDataBlock udb := dec_RlcmacDlDataBlock(buf);
+	log("Dec: ", udb);
+	var octetstring enc := enc_RlcmacDlDataBlock(udb);
+	log("Enc: ", enc);
+	if (enc != buf) {
+		setverdict(fail, "Re-encoded data doesn't equal input data");
+		mtc.stop;
+	}
+}
+
+testcase TC_selftest_rlcmac() runs on dummy_CT {
+	const octetstring c_gmm_att_pcu := '402400804000000000000000'O;
+
+	var RlcmacDlCtrlBlock dcb;
+	var RlcmacUlCtrlBlock ucb;
+
+	// Some octstrings are concatenated to avoid Atom editor hanging: https://github.com/karolwiniarski/language-ttcn-3/issues/3
+	const octetstring c_dl_ul_ack_nack := '402400804000000000000000'O & '77628dbba14b2b2b2b2b2b'O;
+	const octetstring c_dl_data := '0f00007341c001081200102198c72477ea104895e8b959acc58b108182f4d0454300'O;
+	const octetstring c_dl_data2 := '070002165dc0012b2b2b43c0012b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b00'O;
+	const octetstring c_ul_ctrl_ack := '4006ec51b7772b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b'O;
+	const octetstring c_ul_dl_ack_nack := '4008004000000000000000'O & '701000edc0000b2b2b2b2b2b'O;
+	const octetstring c_dl_ul_assign := '482857628dbbaf0126e68800082b2b2b2b2b2b2b2b2b2b'O;
+
+	log(c_dl_ul_ack_nack);
+	dcb := dec_RlcmacDlCtrlBlock(c_dl_ul_ack_nack);
+	log(dcb);
+	//log(dec_RlcmacDlCtrlMsg(dcb.payload));
+
+	f_rlcmac_dld_decenc(c_dl_data);
+
+	f_rlcmac_dld_decenc(c_dl_data2);
+
+	log(c_ul_ctrl_ack);
+	ucb := dec_RlcmacUlCtrlBlock(c_ul_ctrl_ack);
+	log(ucb);
+	//log(dec_RlcmacUlCtrlMsg(ucb.payload));
+
+	log(c_ul_dl_ack_nack);
+	ucb := dec_RlcmacUlCtrlBlock(c_ul_dl_ack_nack);
+	log(ucb);
+	//log(dec_RlcmacUlCtrlMsg(ucb.payload));
+
+	log(c_dl_ul_assign);
+	dcb := dec_RlcmacDlCtrlBlock(c_dl_ul_assign);
+	log(dcb);
+	//log(dec_RlcmacDlCtrlMsg(dcb.payload));
+
+	const octetstring c_uld_tlli_noext := '080101a61cab5201c001080103e5e000310a0005f4e61cab5232f44000c8001d1b00'O;
+	f_rlcmac_uld_decenc(c_uld_tlli_noext);
+
+	const octetstring c_uld_tlli_ext7pad := '0001041da61cab5200201705a96e102b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b00'O;
+	log("ULD_decenc");
+	f_rlcmac_uld_decenc(c_uld_tlli_ext7pad);
+	log("UL_decenc");
+	f_rlcmac_ul_decenc(c_uld_tlli_ext7pad);
+
+	f_rlcmac_ul_decenc(c_ul_dl_ack_nack);
+}
+
+///////////////////
+// RR selftest
+///////////////////
+
+testcase TC_selftest_rr() runs on dummy_CT {
+	//const octetstring c_paging_none := '06210001F02B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O
+	const octetstring c_paging_none := '1506210001F0'O;
+	const octetstring c_ia_tbf := '2d063f100fe3677bd8440000c800100b2b2b2b2b2b2b2b'O
+	log(c_paging_none);
+	log(dec_GsmRrMessage(c_paging_none));
+
+	log(c_ia_tbf);
+	log(dec_GsmRrMessage(c_ia_tbf));
+}
+
+}
diff --git a/pcu/README.md b/pcu/README.md
index a2e439a..a711410 100644
--- a/pcu/README.md
+++ b/pcu/README.md
@@ -1,4 +1,4 @@
-# PCU_Tests.ttcn
+# PCU_Tests_RAW.ttcn
 
 * external interfaces
     * Gb (emulates SGSN side NS/BSSGP)
diff --git a/pcu/SGSN_Components.ttcn b/pcu/SGSN_Components.ttcn
new file mode 100644
index 0000000..4bbd18c
--- /dev/null
+++ b/pcu/SGSN_Components.ttcn
@@ -0,0 +1,104 @@
+module SGSN_Components {
+/*
+ * Osmocom PCU test suite in TTCN-3, components for BSSGP handlng
+ * (C) 2018-2019 Harald Welte <laforge at gnumonks.org>
+ * (C) 2020 by sysmocom s.f.m.c. GmbH <info at sysmocom.de>
+ * All rights reserved.
+ *
+ * Released under the terms of GNU General Public License, Version 2 or
+ * (at your option) any later version.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+import from BSSGP_Types all;
+import from BSSGP_Emulation all;
+import from NS_Types all;
+import from NS_Emulation all;
+import from GPRS_Context all;
+
+modulepar {
+	BssgpConfig mp_gb_cfg := {
+		nsei := 1234,
+		bvci := 1234,
+		cell_id := {
+			ra_id := {
+				lai := {
+					mcc_mnc := '262F42'H, lac := 13135
+				},
+				rac := 0
+			},
+			cell_id := 20960
+		},
+		sgsn_role := true,
+		depth := BSSGP_DECODE_DEPTH_BSSGP
+	};
+
+	NSConfiguration mp_nsconfig := {
+		local_udp_port := 23000,
+		local_ip := "127.0.0.1",
+		remote_udp_port := 21000,
+		remote_ip := "127.0.0.1",
+		nsvci := 0,
+		nsei := 2342,
+		role_sgsn := true,
+		handle_sns := true
+	};
+}
+
+/* FIXME: merge this into BSSGP_Client_CT ? */
+type component bssgp_CT extends BSSGP_Client_CT {
+	var NS_CT ns_component;
+	var BSSGP_CT bssgp_component;
+	var boolean g_initialized := false;
+}
+
+/* FIXME: merge this into BSSGP_Client_CT ? */
+function f_init_bssgp() runs on bssgp_CT {
+	var MmContext mmctx := {
+		imsi := '262420000000001'H,
+		tlli := 'FFFFFFFF'O,
+		n_u := 0
+	};
+
+
+	if (g_initialized == true) {
+		return;
+	}
+	g_initialized := true;
+
+	/* create a new NS component */
+	ns_component := NS_CT.create;
+	bssgp_component := BSSGP_CT.create;
+	/* connect our BSSGP port to the BSSGP Emulation */
+	connect(self:BSSGP[0], bssgp_component:BSSGP_SP);
+	connect(self:BSSGP_SIG[0], bssgp_component:BSSGP_SP_SIG);
+	connect(self:BSSGP_PROC[0], bssgp_component:BSSGP_PROC);
+	/* connect lower-end of BSSGP with BSSGP_CODEC_PORT (maps to NS_PT*/
+	connect(bssgp_component:BSCP, ns_component:NS_SP);
+	/* connect lower-end of NS emulation to NS_CODEC_PORT (on top of IPl4) */
+	map(ns_component:NSCP, system:NS_CODEC_PORT);
+	ns_component.start(NSStart(mp_nsconfig));
+	bssgp_component.start(BssgpStart(mp_gb_cfg));
+
+	f_bssgp_client_register(mmctx.imsi, mmctx.tlli, mp_gb_cfg.cell_id);
+}
+
+/* Establish BSSGP connection to PCU */
+function f_bssgp_establish() runs on BSSGP_Client_CT {
+	timer T:= 10.0;
+
+	T.start
+	alt {
+	[] BSSGP[0].receive(t_BssgpStsInd(?, ?, BVC_S_UNBLOCKED)) { }
+	[] BSSGP[0].receive { repeat; }
+	[] T.timeout {
+		setverdict(fail, "Timeout establishing BSSGP connection");
+		mtc.stop;
+		}
+	}
+	T.stop
+	log("BSSGP successfully initialized");
+}
+
+}
diff --git a/pcu/gen_links.sh b/pcu/gen_links.sh
index 9ad318c..da035cb 100755
--- a/pcu/gen_links.sh
+++ b/pcu/gen_links.sh
@@ -49,7 +49,7 @@
 gen_links $DIR $FILES
 
 DIR=../library
-FILES="Misc_Helpers.ttcn General_Types.ttcn Osmocom_VTY_Functions.ttcn Native_Functions.ttcn Native_FunctionDefs.cc GSM_Types.ttcn GSM_RR_Types.ttcn Osmocom_Types.ttcn RLCMAC_Types.ttcn RLCMAC_CSN1_Types.ttcn RLCMAC_EncDec.cc L1CTL_Types.ttcn L1CTL_PortType.ttcn L1CTL_PortType_CtrlFunct.ttcn L1CTL_PortType_CtrlFunctDef.cc LAPDm_RAW_PT.ttcn LAPDm_Types.ttcn "
+FILES="Misc_Helpers.ttcn General_Types.ttcn Osmocom_VTY_Functions.ttcn Native_Functions.ttcn Native_FunctionDefs.cc GSM_Types.ttcn GSM_RR_Types.ttcn Osmocom_Types.ttcn RLCMAC_Types.ttcn RLCMAC_CSN1_Types.ttcn RLCMAC_EncDec.cc "
 FILES+="NS_Emulation.ttcn NS_CodecPort.ttcn NS_CodecPort_CtrlFunct.ttcn NS_CodecPort_CtrlFunctDef.cc "
 FILES+="BSSGP_Emulation.ttcn Osmocom_Gb_Types.ttcn "
 FILES+="LLC_Templates.ttcn L3_Templates.ttcn L3_Common.ttcn "
diff --git a/pcu/osmo-bsc.cfg b/pcu/osmo-bsc.cfg
deleted file mode 100644
index c561955..0000000
--- a/pcu/osmo-bsc.cfg
+++ /dev/null
@@ -1,194 +0,0 @@
-!
-! OsmoBSC (1.1.2.236-5f22) configuration saved from vty
-!!
-password foo
-!
-log gsmtap 127.0.0.1
- logging level set-all debug
-!
-
-log stderr
- logging color 1
- logging filter all 1
- logging print level 1
- logging print category 1
- logging print category-hex 0
- logging print file basename last
- logging print extended-timestamp 1
- logging level set-all debug
- #~ logging level hodec info
- #~ logging level ho info
- #~ logging level nm info
- #~ logging level meas info
- #~ logging level lmi info
- #~ logging level linp notice
- #~ logging level lss7 notice
- #~ logging level lsccp notice
- #~ logging level lsua notice
- #~ logging level lm3ua notice
-
-stats interval 5
-!
-line vty
- no login
- bind 127.0.0.1
-!
-e1_input
- e1_line 0 driver ipa
- e1_line 0 port 0
- no e1_line 0 keepalive
- ipa bind 127.0.0.1
-cs7 instance 0
- point-code 0.23.3
- asp asp-clnt-msc-0 2905 0 m3ua
- as as-clnt-msc-0 m3ua
-  asp asp-clnt-msc-0
-  routing-key 2 0.23.3
-network
- network country code 262
- mobile network code 42
- encryption a5 0
- neci 1
- paging any use tch 0
- handover 0
- handover1 window rxlev averaging 10
- handover1 window rxqual averaging 1
- handover1 window rxlev neighbor averaging 10
- handover1 power budget interval 6
- handover1 power budget hysteresis 3
- handover1 maximum distance 9999
- periodic location update 30
- bts 0
-  type sysmobts
-  band DCS1800
-  cell_identity 20960
-  location_area_code 13135
-  dtx uplink force
-  dtx downlink
-  base_station_id_code 63
-  ms max power 15
-  cell reselection hysteresis 4
-  rxlev access min 0
-  radio-link-timeout 32
-  channel allocator ascending
-  rach tx integer 9
-  rach max transmission 7
-  channel-descrption attach 1
-  channel-descrption bs-pa-mfrms 5
-  channel-descrption bs-ag-blks-res 1
-  early-classmark-sending forbidden
-  early-classmark-sending-3g allowed
-  ip.access unit_id 1234 0
-  ip.access rsl-ip 127.0.0.1
-  oml ip.access stream_id 255 line 0
-  neighbor-list mode manual-si5
-  neighbor-list add arfcn 100
-  neighbor-list add arfcn 200
-  si5 neighbor-list add arfcn 10
-  si5 neighbor-list add arfcn 20
-  codec-support fr
-  gprs mode gprs
-  gprs 11bit_rach_support_for_egprs 0
-  gprs routing area 0
-  gprs network-control-order nc0
-  gprs cell bvci 1234
-  gprs cell timer blocking-timer 3
-  gprs cell timer blocking-retries 3
-  gprs cell timer unblocking-retries 3
-  gprs cell timer reset-timer 3
-  gprs cell timer reset-retries 3
-  gprs cell timer suspend-timer 10
-  gprs cell timer suspend-retries 3
-  gprs cell timer resume-timer 10
-  gprs cell timer resume-retries 3
-  gprs cell timer capability-update-timer 10
-  gprs cell timer capability-update-retries 3
-  gprs nsei 1234
-  gprs ns timer tns-block 3
-  gprs ns timer tns-block-retries 3
-  gprs ns timer tns-reset 3
-  gprs ns timer tns-reset-retries 3
-  gprs ns timer tns-test 30
-  gprs ns timer tns-alive 3
-  gprs ns timer tns-alive-retries 10
-  gprs nsvc 0 nsvci 1234
-  gprs nsvc 0 local udp port 22000
-  gprs nsvc 0 remote udp port 23000
-  gprs nsvc 0 remote ip 127.0.0.1
-  no force-combined-si
-  trx 0
-   rf_locked 0
-   arfcn 871
-   nominal power 23
-   max_power_red 20
-   rsl e1 tei 0
-   timeslot 0
-    phys_chan_config CCCH+SDCCH4
-    hopping enabled 0
-   timeslot 1
-    phys_chan_config TCH/H
-    hopping enabled 0
-   timeslot 2
-    phys_chan_config TCH/H
-    hopping enabled 0
-   timeslot 3
-    phys_chan_config TCH/H
-    hopping enabled 0
-   timeslot 4
-    phys_chan_config TCH/H
-    hopping enabled 0
-   timeslot 5
-    phys_chan_config TCH/H
-    hopping enabled 0
-   timeslot 6
-    phys_chan_config TCH/H
-    hopping enabled 0
-   timeslot 7
-    phys_chan_config PDCH
-    hopping enabled 0
-   #~ timeslot 1
-    #~ phys_chan_config TCH/F
-    #~ hopping enabled 0
-   #~ timeslot 2
-    #~ phys_chan_config TCH/F
-    #~ hopping enabled 0
-   #~ timeslot 3
-    #~ phys_chan_config TCH/F_PDCH
-    #~ hopping enabled 0
-   #~ timeslot 4
-    #~ phys_chan_config TCH/F_TCH/H_PDCH
-    #~ hopping enabled 0
-   #~ timeslot 5
-    #~ phys_chan_config TCH/H
-    #~ hopping enabled 0
-   #~ timeslot 6
-    #~ phys_chan_config SDCCH8
-    #~ hopping enabled 0
-   #~ timeslot 7
-    #~ phys_chan_config PDCH
-    #~ hopping enabled 0
-msc 0
- core-location-area-code 666
- core-cell-identity 333
- ip.access rtp-base 4000
- timeout-ping 12
- timeout-pong 14
- no timeout-ping advanced
- no bsc-welcome-text
- no bsc-msc-lost-text
- no bsc-grace-text
- codec-list fr1 fr2 fr3
- type normal
- allow-emergency allow
- amr-config 12_2k forbidden
- amr-config 10_2k forbidden
- amr-config 7_95k forbidden
- amr-config 7_40k forbidden
- amr-config 6_70k forbidden
- amr-config 5_90k allowed
- amr-config 5_15k forbidden
- amr-config 4_75k forbidden
-bsc
- mid-call-timeout 0
- no missing-msc-text
- access-list-name bsc-list
diff --git a/pcu/osmo-bts.cfg b/pcu/osmo-bts.cfg
deleted file mode 100644
index 7f36f87..0000000
--- a/pcu/osmo-bts.cfg
+++ /dev/null
@@ -1,83 +0,0 @@
-!
-! OsmoBTS (0.4.0.446-e0fb) configuration saved from vty
-!!
-!
-log gsmtap 127.0.0.1
- logging level set-all debug
-!
-log stderr
- logging filter all 1
- logging color 1
- logging print category 1
- logging timestamp 1
- logging print extended-timestamp 1
- logging level rsl info
- logging level oml info
- logging level rll notice
- logging level rr notice
- logging level meas info
- logging level pag info
- logging level l1c info
- logging level l1p notice
- logging level dsp info
- logging level pcu debug
- logging level ho notice
- logging level trx info
- logging level loop notice
- logging level abis notice
- logging level rtp notice
- logging level sum notice
- logging level lglobal notice
- logging level llapd notice
- logging level linp notice
- logging level lmux notice
- logging level lmi notice
- logging level lmib debug
- logging level lsms notice
- logging level lctrl notice
- logging level lgtp notice
- logging level lstats notice
- logging level lgsup notice
- logging level loap notice
- logging level lss7 notice
- logging level lsccp notice
- logging level lsua notice
- logging level lm3ua notice
-!
-line vty
- no login
- bind 127.0.0.1
-!
-e1_input
- e1_line 0 driver ipa
- e1_line 0 port 0
- no e1_line 0 keepalive
-phy 0
- !virtual-um ms-multicast-group 239.193.23.1
- !virtual-um bts-multicast-group 239.193.23.2
- instance 0
-bts 0
- band DCS1800
- ipa unit-id 1234 0
- oml remote-ip 127.0.0.1
- rtp jitter-buffer 100
- paging queue-size 200
- paging lifetime 0
- uplink-power-target -75
- gsmtap-sapi rach
- gsmtap-sapi agch
- gsmtap-sapi bcch
- gsmtap-sapi pch
- gsmtap-sapi sdcch
- gsmtap-sapi sacch
- min-qual-rach 50
- min-qual-norm -5
- pcu-socket /tmp/pcu_bts
- trx 0
-  power-ramp max-initial 0 mdBm
-  power-ramp step-size 2000 mdB
-  power-ramp step-interval 1
-  ms-power-control dsp
-  phy 0 instance 0
-ctrl
- bind 127.0.0.1
diff --git a/pcu/regen_makefile.sh b/pcu/regen_makefile.sh
index c2f636d..6fd000e 100755
--- a/pcu/regen_makefile.sh
+++ b/pcu/regen_makefile.sh
@@ -1,5 +1,5 @@
 #!/bin/sh
 
-FILES="*.ttcn BSSGP_EncDec.cc IPL4asp_PT.cc IPL4asp_discovery.cc TCCConversion.cc TCCInterface.cc NS_CodecPort_CtrlFunctDef.cc UD_PT.cc RLCMAC_EncDec.cc LLC_EncDec.cc L1CTL_PortType_CtrlFunctDef.cc TELNETasp_PT.cc Native_FunctionDefs.cc"
+FILES="*.ttcn BSSGP_EncDec.cc IPL4asp_PT.cc IPL4asp_discovery.cc TCCConversion.cc TCCInterface.cc NS_CodecPort_CtrlFunctDef.cc UD_PT.cc RLCMAC_EncDec.cc LLC_EncDec.cc TELNETasp_PT.cc Native_FunctionDefs.cc"
 
 ../regen-makefile.sh PCU_Tests.ttcn $FILES

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16321
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Ie862a1525e9f4f9a3f2427ac3898810e3d044d2f
Gerrit-Change-Number: 16321
Gerrit-PatchSet: 4
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200430/ffb0e9c8/attachment.htm>


More information about the gerrit-log mailing list