aboutsummaryrefslogtreecommitdiffstats
path: root/pcu
diff options
context:
space:
mode:
Diffstat (limited to 'pcu')
-rw-r--r--pcu/GPRS_Components.ttcn1484
-rw-r--r--pcu/GPRS_TBF.ttcn13
-rw-r--r--pcu/PCUIF_Components.ttcn (renamed from pcu/PCUIF_RAW_Components.ttcn)273
-rw-r--r--pcu/PCU_Tests.cfg57
-rw-r--r--pcu/PCU_Tests.default54
-rw-r--r--pcu/PCU_Tests.ttcn7881
-rw-r--r--pcu/PCU_Tests_NS.ttcn248
-rw-r--r--pcu/PCU_Tests_RAW.ttcn1067
-rw-r--r--pcu/PCU_Tests_SNS.cfg56
-rw-r--r--pcu/PCU_Tests_SNS.ttcn (renamed from pcu/PCU_Tests_RAW_SNS.ttcn)297
-rw-r--r--pcu/PCU_Tests_SNSv6.cfg36
-rw-r--r--pcu/PCU_selftest.ttcn318
-rw-r--r--pcu/README.md95
-rw-r--r--pcu/SGSN_Components.ttcn151
-rw-r--r--pcu/expected-results.xml148
-rwxr-xr-xpcu/gen_links.sh15
-rw-r--r--pcu/osmo-bsc.cfg194
-rw-r--r--pcu/osmo-bts.cfg83
-rw-r--r--pcu/osmo-pcu-sns.cfg4
-rw-r--r--pcu/osmo-pcu.cfg17
-rwxr-xr-xpcu/regen_makefile.sh26
21 files changed, 10447 insertions, 2070 deletions
diff --git a/pcu/GPRS_Components.ttcn b/pcu/GPRS_Components.ttcn
new file mode 100644
index 00000000..849a251d
--- /dev/null
+++ b/pcu/GPRS_Components.ttcn
@@ -0,0 +1,1484 @@
+module GPRS_Components {
+/*
+ * Osmocom PCU test suite in TTCN-3, components for GPRS handlng
+ * (C) 2018-2019 Harald Welte <laforge@gnumonks.org>
+ * (C) 2019 Vadim Yanitskiy <axilirator@gmail.com>
+ * (C) 2020 by sysmocom s.f.m.c. GmbH <info@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 General_Types all;
+import from Osmocom_Types all;
+import from GSM_Types all;
+import from GSM_RR_Types all;
+import from GSM_RestOctets all;
+
+import from RLCMAC_CSN1_Types all;
+import from RLCMAC_CSN1_Templates all;
+import from RLCMAC_Types all;
+import from RLCMAC_Templates all;
+
+import from MobileL3_CommonIE_Types all;
+import from L3_Templates all;
+
+import from PCUIF_Types all;
+import from PCUIF_Components all;
+import from Native_Functions all;
+
+modulepar {
+ /* ARFCN of 1st TRX. Subsequent TRX are allocated incrementing ARFCNs. Nth TRX => base_arfcn + N-1 */
+ GsmArfcn mp_base_arfcn := 871;
+};
+
+type record TsTrxBtsNum {
+ uint3_t ts_nr,
+ uint3_t trx_nr,
+ uint8_t bts_nr,
+ uint8_t blk_nr
+};
+
+/* Useful to store poll FN + BTS+TRX+TS requested by network */
+type record PollFnCtx {
+ TsTrxBtsNum tstrxbts,
+ uint32_t fn
+};
+
+template (value) TsTrxBtsNum ts_TsTrxBtsNum(uint3_t ts_nr := 7,
+ uint3_t trx_nr := 0,
+ uint8_t bts_nr := 0,
+ uint8_t blk_nr := 0) := {
+ ts_nr := ts_nr,
+ trx_nr := trx_nr,
+ bts_nr := bts_nr,
+ blk_nr := blk_nr
+};
+template TsTrxBtsNum tr_TsTrxBtsNum(template uint3_t ts_nr := ?,
+ template uint3_t trx_nr := ?,
+ template uint8_t bts_nr := ?,
+ template uint8_t blk_nr := ?) := {
+ ts_nr := ts_nr,
+ trx_nr := trx_nr,
+ bts_nr := bts_nr,
+ blk_nr := blk_nr
+};
+
+type union PacketDlAssignChan {
+ PacketDlAssign ccch,
+ PacketDlAssignment pacch
+};
+
+type record DlTbf {
+ GsmRrMessage rr_imm_ass optional,
+ PacketDlAssignChan ass optional,
+ uint5_t tfi,
+ GsmArfcn arfcn optional,
+ BIT8 ts_mask,
+ AckNackDescription acknack_desc,
+ EgprsAckNackDescription egprs_acknack_desc
+};
+
+type union PacketUlAssignChan {
+ PacketUlAssign ccch,
+ EgprsUlAss ccch_egprs,
+ PacketUlAssignment pacch
+};
+
+type record UlTbf {
+ GsmRrMessage rr_imm_ass optional,
+ PacketUlAssignChan ass optional,
+ uint5_t tfi,
+ GsmArfcn arfcn optional,
+ BIT8 ts_mask,
+ uint3_t usf[8],
+ boolean is_egprs,
+ uint14_t bsn,
+ CodingScheme tx_cs_mcs,
+ GsmFrameNumber start_time_fn
+};
+
+type record GprsMS {
+ hexstring imsi,
+ GprsTlli tlli,
+ uint16_t ra,
+ uint8_t ra_is_11bit,
+ PCUIF_BurstType burst_type,
+ TimingAdvance ta,
+ int16_t lqual_cb,
+ UlTbf ul_tbf optional, /* TODO: Only 1 UL tbf supported for now */
+ DlTbf dl_tbf optional /* TODO: Only 1 DL tbf supported for now */
+};
+type record of GprsMS GprsMSList;
+
+template AckNackDescription t_AckNackDescription_init := {
+ final_ack := '0'B,
+ starting_seq_nr := 0,
+ receive_block_bitmap := '0000000000000000000000000000000000000000000000000000000000000000'B
+}
+
+template EgprsAckNackDescription t_EgprsAckNackDescription_init := {
+ final_ack := '0'B,
+ begin_window := '1'B,
+ end_window := '1'B,
+ starting_seq_nr := 1,
+ compressed := '0'B,
+ urbb := '0000000000000000000000000000000000000000000000000000000000000000'B
+}
+
+const uint3_t USF_UNUSED := 7; /* used to indicate PRACH */
+
+template (value) GprsMS t_GprsMS_def := {
+ imsi := f_gen_imsi(42),
+ tlli := f_gen_tlli(),
+ ra := bit2int(chan_req_def),
+ ra_is_11bit := 0,
+ burst_type := BURST_TYPE_0,
+ ta := 0,
+ lqual_cb := 0,
+ ul_tbf := omit,
+ dl_tbf := omit
+};
+
+template (value) DlTbf t_DlTbf_def := {
+ rr_imm_ass := omit,
+ ass := omit,
+ tfi := 0,
+ arfcn := omit,
+ ts_mask := '00000000'B,
+ acknack_desc := t_AckNackDescription_init,
+ egprs_acknack_desc := t_EgprsAckNackDescription_init
+};
+
+template (value) UlTbf t_UlTbf_def := {
+ rr_imm_ass := omit,
+ ass := omit,
+ tfi := 0,
+ arfcn := omit,
+ ts_mask := '00000000'B,
+ usf := { USF_UNUSED, USF_UNUSED, USF_UNUSED, USF_UNUSED, USF_UNUSED, USF_UNUSED, USF_UNUSED, USF_UNUSED },
+ is_egprs := false,
+ bsn := 0,
+ tx_cs_mcs := CS_1,
+ start_time_fn := 0
+};
+
+type component MS_BTS_IFACE_CT {
+ /* Virtual BTS component */
+ var RAW_PCU_BTS_CT vc_BTS;
+ /* Connection to the BTS component (one for now) */
+ port RAW_PCU_MSG_PT BTS;
+
+ /* Mobile station(s) involved in a testing scenario */
+ var GprsMSList g_ms := { };
+
+ /* Value at which Countdown Procedure starts. Announced by network (GPRS Cell Options as per TS 04.60 Chapter 12.24) */
+ var uint4_t g_bs_cv_max := 4;
+}
+
+/* Generate a list of GprsMS (unique IMSI/TLLI, cyclic RA) of the given size */
+function f_init_gprs_ms(integer num_ms := 1, template (value) GprsMS t_ms := t_GprsMS_def)
+runs on MS_BTS_IFACE_CT {
+ for (var integer i := 0; i < num_ms; i := i + 1 ) {
+ var GprsMS ms := valueof(t_ms);
+
+ /* We assume that num_ms is not a large number */
+ ms.imsi := f_gen_imsi(i + 1);
+ ms.tlli := int2oct(i + 1, 4);
+
+ /* Ensure different RA for siblings */
+ if (ms.ra == bit2int(chan_req_def)) {
+ /* 01111 { 0xx | x0x | xx0 } */
+ f_ms_use_ra(ms, ms.ra + (i mod 7));
+ } else if (ms.ra == bit2int(chan_req_sb)) {
+ /* 01110xxx */
+ f_ms_use_ra(ms, ms.ra + (i mod 8));
+ }
+
+ /* Append to the global list */
+ g_ms := g_ms & { ms };
+ }
+}
+
+
+function f_shutdown(charstring file, integer line,
+ boolean final := false)
+runs on MS_BTS_IFACE_CT {
+ /* Determine if the test case was aborted in the middle */
+ if (not final) {
+ log("Test case ", testcasename(), " aborted at ", file, ":", line);
+ } else {
+ /* Guard verdict to avoid 'none' */
+ setverdict(pass);
+ }
+
+ /* Properly shutdown virtual BTS and its clock generator */
+ BTS.send(ts_RAW_PCU_CMD(GENERAL_CMD_SHUTDOWN));
+ vc_BTS.done; /* wait untill it's done */
+
+ /* Shutdown the others and MTC */
+ all component.stop;
+ mtc.stop;
+}
+
+function f_arfcn2trxnr(GsmArfcn arfcn) runs on MS_BTS_IFACE_CT return uint3_t {
+ if (arfcn < mp_base_arfcn) {
+ setverdict(fail, "Unable to find TRX NR for arfcn ", arfcn);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ return arfcn - mp_base_arfcn;
+}
+
+function f_trxnr2arfcn(uint3_t trx_nr) return GsmArfcn {
+ return mp_base_arfcn + trx_nr;
+}
+
+/* 3GPP TS 44.018 10.5.2.38 Starting Time */
+function f_tbf_starting_time_2_fn_mod_42432(TbfStartingTime st)
+runs on MS_BTS_IFACE_CT return GsmFrameNumber {
+ return 51 * ((st.t3 - st.t2) mod 26) + st.t3 + 51 * 26 * st.t1;
+}
+
+function fn2bn(GsmFrameNumber fn) return uint32_t {
+ return (fn mod 52) / 4;
+}
+function f_next_pdch_block(GsmFrameNumber fn) return GsmFrameNumber
+{
+ var uint32_t bn := fn2bn(fn) + 1;
+ fn := fn - (fn mod 52);
+ fn := fn + bn * 4 + bn / 3;
+ return fn mod GsmMaxFrameNumber;
+}
+
+function f_ultbf_new_from_rr_imm_ass(in GsmRrMessage rr_imm_ass)
+runs on MS_BTS_IFACE_CT return UlTbf {
+ var UlTbf ul_tbf := valueof(t_UlTbf_def);
+ var uint3_t tn_allocated := rr_imm_ass.payload.imm_ass.pkt_chan_desc.tn;
+
+ ul_tbf.rr_imm_ass := rr_imm_ass;
+ if (rr_imm_ass.payload.imm_ass.pkt_chan_desc.presence == '0'B and
+ rr_imm_ass.payload.imm_ass.pkt_chan_desc.zero.hopping == '0'B) {
+ ul_tbf.arfcn := rr_imm_ass.payload.imm_ass.pkt_chan_desc.zero.arfcn;
+ }
+ ul_tbf.ts_mask[tn_allocated] := '1'B;
+
+ /* Make sure we received an UL TBF Assignment */
+ if (match(rr_imm_ass, tr_IMM_TBF_ASS(dl := false, rest := tr_IaRestOctets_ULAss(?)))) {
+ ul_tbf.ass.ccch := rr_imm_ass.payload.imm_ass.rest_octets.hh.pa.uldl.ass.ul;
+ log("Rx Uplink TBF GPRS assignment: ", ul_tbf.ass.ccch);
+ ul_tbf.is_egprs := false;
+ if (match(ul_tbf.ass.ccch, tr_PacketUlDynAssign)) {
+ ul_tbf.tfi := ul_tbf.ass.ccch.dynamic.tfi_assignment;
+ ul_tbf.tx_cs_mcs := f_rlcmac_block_ChCodingCommand2cs_mcs(ul_tbf.ass.ccch.dynamic.ch_coding_cmd);
+ ul_tbf.usf[tn_allocated] := ul_tbf.ass.ccch.dynamic.usf;
+ if (ul_tbf.ass.ccch.dynamic.tbf_starting_time_present == '1'B) {
+ ul_tbf.start_time_fn := f_tbf_starting_time_2_fn_mod_42432(ul_tbf.ass.ccch.dynamic.tbf_starting_time);
+ }
+ } else if (match(ul_tbf.ass.ccch, tr_PacketUlSglAssign)) {
+ ul_tbf.start_time_fn := f_tbf_starting_time_2_fn_mod_42432(ul_tbf.ass.ccch.single.tbf_starting_time);
+ }
+ } else if (match(rr_imm_ass, tr_IMM_TBF_ASS(dl := false, rest := tr_IaRestOctets_EGPRSULAss(?)))) {
+ ul_tbf.ass.ccch_egprs := rr_imm_ass.payload.imm_ass.rest_octets.lh.egprs_ul;
+ log("Rx Uplink TBF EGPRS assignment: ", ul_tbf.ass.ccch_egprs);
+ ul_tbf.is_egprs := true;
+ if (match(ul_tbf.ass.ccch_egprs, tr_EgprsUlAssDynamic)) {
+ ul_tbf.tfi := ul_tbf.ass.ccch_egprs.dynamic.tfi_assignment;
+ ul_tbf.tx_cs_mcs := f_rlcmac_block_EgprsChCodingCommand2cs_mcs(ul_tbf.ass.ccch_egprs.dynamic.egprs_ch_coding_cmd);
+ ul_tbf.usf[tn_allocated] := ul_tbf.ass.ccch_egprs.dynamic.usf;
+ if (ul_tbf.ass.ccch_egprs.dynamic.tbf_starting_time_present == '1'B) {
+ ul_tbf.start_time_fn := f_tbf_starting_time_2_fn_mod_42432(ul_tbf.ass.ccch_egprs.dynamic.tbf_starting_time);
+ }
+ } else if (match(ul_tbf.ass.ccch_egprs, tr_EgprsUlAssMultiblock)) {
+ ul_tbf.start_time_fn := f_tbf_starting_time_2_fn_mod_42432(ul_tbf.ass.ccch_egprs.multiblock.tbf_starting_time);
+ /* Nothing to do here yet */
+ }
+ } else {
+ setverdict(fail, "Failed to match UL TBF Assignment: ", rr_imm_ass);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ setverdict(pass);
+ return ul_tbf;
+}
+
+function f_ultbf_new_from_ass_pacch(RlcmacDlBlock dl_block)
+runs on MS_BTS_IFACE_CT return UlTbf {
+ var UlTbf ul_tbf := valueof(t_UlTbf_def);
+ var boolean freq_par_present := false;
+ var FrequencyParameters freq_par;
+
+ ul_tbf.ass.pacch := dl_block.ctrl.payload.u.ul_assignment;
+ ul_tbf.tx_cs_mcs := f_rlcmac_dl_block_get_assigned_ul_cs_mcs(dl_block);
+ ul_tbf.tfi := f_rlcmac_dl_block_get_tfi(dl_block);
+ /* TODO: handle GlobalTfiOrTlli tfi_or_tlli from pkt_ul_ass */
+
+ /* TODO: support single block allocation */
+ if (match(dl_block, tr_RLCMAC_UL_PACKET_ASS_GPRS(?, tr_PktUlAssGprsDynamic(tr_DynamicAllocation(?))))) {
+ ul_tbf.tfi := dl_block.ctrl.payload.u.ul_assignment.gprs.dyn_block_alloc.ul_tfi_assignment;
+ freq_par_present := dl_block.ctrl.payload.u.ul_assignment.gprs.freq_par_present == '1'B;
+ if (freq_par_present) {
+ freq_par := dl_block.ctrl.payload.u.ul_assignment.gprs.freq_par;
+ }
+ ul_tbf.is_egprs := false;
+ for (var integer i := 0; i < 8; i := i + 1) {
+ if (dl_block.ctrl.payload.u.ul_assignment.gprs.dyn_block_alloc.ts_allocation.ts[i].presence == '1'B) {
+ ul_tbf.ts_mask[i] := '1'B;
+ ul_tbf.usf[i] := dl_block.ctrl.payload.u.ul_assignment.gprs.dyn_block_alloc.ts_allocation.ts[i].usf_tn;
+ }
+ }
+ } else if (match(dl_block, tr_RLCMAC_UL_PACKET_ASS_EGPRS(?, tr_PktUlAssEgprsDynamic(tr_DynamicAllocation(?))))) {
+ ul_tbf.tfi := dl_block.ctrl.payload.u.ul_assignment.egprs.dyn_block_alloc.ul_tfi_assignment;
+ freq_par_present := dl_block.ctrl.payload.u.ul_assignment.egprs.freq_par_present == '1'B;
+ if (freq_par_present) {
+ freq_par := dl_block.ctrl.payload.u.ul_assignment.egprs.freq_par;
+ }
+ ul_tbf.is_egprs := true;
+ for (var integer i := 0; i < 8; i := i + 1) {
+ if (dl_block.ctrl.payload.u.ul_assignment.egprs.dyn_block_alloc.ts_allocation.ts[i].presence == '1'B) {
+ ul_tbf.ts_mask[i] := '1'B;
+ ul_tbf.usf[i] := dl_block.ctrl.payload.u.ul_assignment.egprs.dyn_block_alloc.ts_allocation.ts[i].usf_tn;
+ }
+ }
+ }
+
+ /* FIXME: freq_par and arfcn are optional. in that case we need to
+ * infer/reuse from current dl_tbf or ul_tbf */
+ if (freq_par_present and freq_par.presence == '00'B) {
+ ul_tbf.arfcn := freq_par.arfcn;
+ }
+
+ return ul_tbf;
+}
+
+function f_dltbf_new_from_rr_imm_ass(in GsmRrMessage rr_imm_ass, template PacketDlAssign dl_ass := tr_PacketDlAssign(?))
+runs on MS_BTS_IFACE_CT return DlTbf {
+ var DlTbf dl_tbf := valueof(t_DlTbf_def);
+
+ dl_tbf.rr_imm_ass := rr_imm_ass;
+ if (rr_imm_ass.payload.imm_ass.pkt_chan_desc.presence == '0'B and
+ rr_imm_ass.payload.imm_ass.pkt_chan_desc.zero.hopping == '0'B) {
+ dl_tbf.arfcn := rr_imm_ass.payload.imm_ass.pkt_chan_desc.zero.arfcn;
+ }
+ dl_tbf.ts_mask[rr_imm_ass.payload.imm_ass.pkt_chan_desc.tn] := '1'B;
+
+ /* Make sure we received a DL TBF Assignment */
+ if (match(rr_imm_ass, tr_IMM_TBF_ASS(dl := true, rest := tr_IaRestOctets_DLAss(dl_ass)))) {
+ dl_tbf.ass.ccch := rr_imm_ass.payload.imm_ass.rest_octets.hh.pa.uldl.ass.dl;
+ log("Rx Downlink TBF assignment: ", dl_tbf.ass);
+ } else {
+ setverdict(fail, "Failed to match DL TBF Assignment: ", rr_imm_ass);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ /* TODO: match TLLI */
+ if (dl_tbf.ass.ccch.group1_present == '1'B) {
+ dl_tbf.tfi := dl_tbf.ass.ccch.group1.tfi_assignment;
+ } else {
+ setverdict(fail, "Immediate Assignment contains no DL TFI");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ setverdict(pass);
+ return dl_tbf;
+}
+
+function f_dltbf_new_from_ass_pacch(RlcmacDlBlock dl_block)
+runs on MS_BTS_IFACE_CT return DlTbf {
+ var DlTbf dl_tbf := valueof(t_DlTbf_def);
+ var boolean freq_par_present := false;
+ var FrequencyParameters freq_par;
+
+ dl_tbf.ass.pacch := dl_block.ctrl.payload.u.dl_assignment;
+ dl_tbf.tfi := f_rlcmac_dl_block_get_tfi(dl_block);
+ /* TODO: handle GlobalTfiOrTlli tfi_or_tlli from pkt_dl_ass */
+
+ if (match(dl_block, tr_RLCMAC_DL_PACKET_ASS(?))) {
+ dl_tbf.tfi := dl_block.ctrl.payload.u.dl_assignment.dl_tfi_assignment;
+ freq_par_present := dl_block.ctrl.payload.u.dl_assignment.freq_par_present == '1'B;
+ if (freq_par_present) {
+ freq_par := dl_block.ctrl.payload.u.dl_assignment.freq_par;
+ }
+ dl_tbf.ts_mask := dl_block.ctrl.payload.u.dl_assignment.timeslot_alloc; /* TODO: is this the correct order ? */
+ /* TODO: check egprs in dl_assignment.rel_additions (PktDlAssR99Additions) */
+ }
+
+ /* FIXME: freq_par and arfcn are optional. in that case we need to
+ * infer/reuse from current dl_tbf or ul_tbf */
+ if (freq_par_present and freq_par.presence == '00'B) {
+ dl_tbf.arfcn := freq_par.arfcn;
+ }
+ return dl_tbf;
+}
+
+function f_ms_tx_TsTrxBtsNum(inout GprsMS ms)
+runs on MS_BTS_IFACE_CT return TsTrxBtsNum {
+ var uint3_t ts_nr := f_ultbf_next_ts(ms.ul_tbf);
+
+ var uint3_t trx_nr;
+ if (ispresent(ms.ul_tbf.arfcn)) {
+ trx_nr := f_arfcn2trxnr(ms.ul_tbf.arfcn);
+ } else {
+ /* FIXME: implement search by hsn+maio+ma when freq hopping is enabled */
+ setverdict(fail, "Asked for trx_nr but arfcn not available in ms.ul_tbf!");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ return valueof(ts_TsTrxBtsNum(ts_nr, trx_nr));
+}
+
+function f_dltbf_num_slots(DlTbf dl_tbf)
+runs on MS_BTS_IFACE_CT return integer {
+ var integer n := 0;
+ for (var integer i := 0; i < lengthof(dl_tbf.ts_mask); i := i + 1) {
+ if (dl_tbf.ts_mask[i] == '1'B) {
+ n := n + 1;
+ }
+ }
+ return n;
+}
+
+function f_dltbf_ack_block(inout DlTbf dl_tbf, RlcmacDlBlock dl_block, BIT1 final_ack := '0'B)
+runs on MS_BTS_IFACE_CT {
+ var boolean is_egprs := ischosen(dl_block.data_egprs);
+ if (is_egprs) {
+ f_egprs_acknackdesc_ack_block(dl_tbf.egprs_acknack_desc, dl_block, final_ack);
+ } else {
+ f_acknackdesc_ack_block(dl_tbf.acknack_desc, dl_block, final_ack);
+ }
+}
+
+function f_dltbf_ts_RLCMAC_DL_ACK_NACK(DlTbf dl_tbf, boolean use_egprs := false,
+ template (omit) ChannelReqDescription chreq_desc := omit)
+runs on MS_BTS_IFACE_CT return template (value) RlcmacUlBlock {
+ if (use_egprs) {
+ return ts_RLCMAC_DL_ACK_NACK_EGPRS(dl_tbf.tfi, dl_tbf.egprs_acknack_desc, false, chreq_desc);
+ } else {
+ return ts_RLCMAC_DL_ACK_NACK(dl_tbf.tfi, dl_tbf.acknack_desc, false, chreq_desc);
+ }
+}
+
+function f_ultbf_inc_bsn(inout UlTbf ul_tbf)
+runs on MS_BTS_IFACE_CT {
+ ul_tbf.bsn := ul_tbf.bsn + 1;
+ if (ul_tbf.is_egprs) {
+ ul_tbf.bsn := ul_tbf.bsn mod 2048;
+ } else {
+ ul_tbf.bsn := ul_tbf.bsn mod 128;
+ }
+}
+
+function f_ultbf_next_ts(UlTbf ul_tbf)
+runs on MS_BTS_IFACE_CT return uint3_t {
+ /* FIXME: in the future we probably want to store last used internally
+ /* and continue from there */
+ for (var integer i := 0; i < lengthof(ul_tbf.ts_mask); i := i + 1) {
+ if (ul_tbf.ts_mask[i] == '1'B) {
+ return i;
+ }
+ }
+ setverdict(fail, "No TS available for tx!");
+ f_shutdown(__BFILE__, __LINE__);
+ return 0;
+}
+
+function f_ultbf_num_slots(UlTbf ul_tbf)
+runs on MS_BTS_IFACE_CT return integer {
+ var integer n := 0;
+ for (var integer i := 0; i < lengthof(ul_tbf.ts_mask); i := i + 1) {
+ if (ul_tbf.ts_mask[i] == '1'B) {
+ n := n + 1;
+ }
+ }
+ return n;
+}
+
+function f_ultbf_payload_fill_length(UlTbf ul_tbf, boolean tlli := false, integer li_bytes := 0)
+runs on MS_BTS_IFACE_CT return uint32_t {
+ var uint32_t blk_len := f_rlcmac_cs_mcs2block_len_no_spare_bits(ul_tbf.tx_cs_mcs);
+ var uint32_t payload_fill_len;
+
+ if (f_rlcmac_cs_mcs_is_mcs(ul_tbf.tx_cs_mcs)) {
+ payload_fill_len := blk_len - 5 - li_bytes;
+ } else {
+ /* GPRS: blk_len = 3 Header bytes + payload length. No LI byte in this case. */
+ payload_fill_len := blk_len - 3 - li_bytes;
+ }
+
+ if (tlli) {
+ payload_fill_len := payload_fill_len - 4;
+ }
+ return payload_fill_len;
+}
+
+function f_ms_use_ra(inout GprsMS ms, uint16_t ra, uint8_t ra_is_11bit := 0)
+runs on MS_BTS_IFACE_CT {
+ ms.ra_is_11bit := ra_is_11bit;
+ ms.ra := ra;
+ if (ra_is_11bit == 0) {
+ ms.burst_type := BURST_TYPE_0;
+ } else {
+ ms.burst_type := BURST_TYPE_1;
+ }
+}
+
+function f_ms_rx_pkt_ass_pacch(inout GprsMS ms, out uint32_t poll_fn,
+ template RlcmacDlBlock t_pkt_ass := ?,
+ template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum,
+ boolean ignore_dummy := true)
+runs on MS_BTS_IFACE_CT return RlcmacDlBlock {
+ var RlcmacDlBlock dl_block;
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+ alt {
+ [] as_ms_rx_pkt_ass_pacch(ms, poll_fn, t_pkt_ass, nr, dl_block);
+ [ignore_dummy] as_ms_rx_ignore_dummy(ms, nr);
+ /* TODO: fail */
+ [] BTS.receive {
+ setverdict(fail, "Unexpected BTS message");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ }
+ return dl_block;
+}
+
+altstep as_ms_rx_ignore_dummy(inout GprsMS ms, template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum)
+runs on MS_BTS_IFACE_CT {
+ var BTS_PDTCH_Block data_msg;
+ [] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ tr_RLCMAC_DL_DUMMY_CTRL())) -> value data_msg {
+
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+ repeat;
+ }
+}
+
+altstep as_pcuif_rx_ignore_empty(template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum)
+runs on MS_BTS_IFACE_CT {
+ var BTS_PDTCH_Block data_msg;
+ [] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ omit)) -> value data_msg {
+
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+ repeat;
+ }
+}
+
+altstep as_rx_fail_dummy(template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum)
+runs on MS_BTS_IFACE_CT {
+ var BTS_PDTCH_Block data_msg;
+ [] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ tr_RLCMAC_DL_DUMMY_CTRL())) -> value data_msg {
+ setverdict(fail, "Unexpected Dummy Ctrl block ", data_msg);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+}
+
+altstep as_ms_rx_pkt_ass_pacch(inout GprsMS ms, out uint32_t poll_fn,
+ template RlcmacDlBlock t_pkt_ass := ?,
+ template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum,
+ out RlcmacDlBlock dl_block)
+runs on MS_BTS_IFACE_CT {
+ var BTS_PDTCH_Block data_msg;
+ [] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH),
+ t_pkt_ass)) -> value data_msg {
+ var uint32_t dl_fn := data_msg.raw.fn;
+ dl_block := data_msg.dl_block;
+ poll_fn := f_rrbp_ack_fn(dl_fn, dl_block.ctrl.mac_hdr.rrbp);
+
+ if (match(dl_block, tr_RLCMAC_UL_PACKET_ASS)) {
+ ms.ul_tbf := f_ultbf_new_from_ass_pacch(dl_block);
+ if (ms.ul_tbf.ass.pacch.identity.tlli.tlli != ms.tlli) {
+ setverdict(fail, "Wrong TLLI ", ms.ul_tbf.ass.pacch.identity.tlli, " received vs exp ", ms.tlli);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ } else if (match(dl_block, tr_RLCMAC_DL_PACKET_ASS)) {
+ ms.dl_tbf := f_dltbf_new_from_ass_pacch(dl_block);
+ if (ischosen(ms.dl_tbf.ass.pacch.tfi_or_tlli.tlli) and
+ ms.dl_tbf.ass.pacch.tfi_or_tlli.tlli.tlli != ms.tlli) {
+ setverdict(fail, "Wrong TLLI ", ms.dl_tbf.ass.pacch.tfi_or_tlli.tlli.tlli, " received vs exp ", ms.tlli);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ } else {
+ setverdict(fail, "Should not happen:", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ }
+}
+
+function f_ms_establish_ul_tbf(inout GprsMS ms, template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum)
+runs on MS_BTS_IFACE_CT {
+ var GsmRrMessage rr_imm_ass;
+
+ rr_imm_ass := f_pcuif_tx_rach_rx_imm_ass(ms.ra, ms.ra_is_11bit, ms.burst_type, ms.ta, nr := nr);
+ ms.ul_tbf := f_ultbf_new_from_rr_imm_ass(rr_imm_ass);
+}
+
+function f_ms_exp_dl_tbf_ass_ccch(inout GprsMS ms, template PCUIF_Sapi sapi := PCU_IF_SAPI_PCH_2,
+ template GsmRrMessage t_imm_ass := tr_IMM_TBF_ASS(true, ?, ?),
+ template (present) TsTrxBtsNum nr := tr_TsTrxBtsNum)
+runs on MS_BTS_IFACE_CT {
+ var GsmRrMessage rr_imm_ass;
+
+ rr_imm_ass := f_pcuif_rx_imm_ass(sapi, t_imm_ass, nr := nr);
+ ms.dl_tbf := f_dltbf_new_from_rr_imm_ass(rr_imm_ass, tr_PacketDlAssign(ms.tlli));
+}
+
+/* Enqueue DATA.ind (both TDMA frame and block numbers to be patched) */
+function f_ms_tx_data_ind(inout GprsMS ms, octetstring data, uint32_t fn := 0,
+ template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum)
+runs on MS_BTS_IFACE_CT {
+ f_pcuif_tx_data_ind(data, fn, ms.ta, ms.lqual_cb, nr := nr);
+}
+
+function f_ms_tx_ul_block(inout GprsMS ms, template (value) RlcmacUlBlock ul_data,
+ uint32_t fn := 0, template (omit) CodingScheme force_cs_mcs := omit,
+ template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum)
+runs on MS_BTS_IFACE_CT {
+ var octetstring data;
+ var CodingScheme cs_mcs;
+ var uint32_t cs_mcs_len;
+
+ /* Encode the payload of DATA.ind */
+ data := enc_RlcmacUlBlock(valueof(ul_data));
+
+ if (ischosen(ul_data.ctrl)) {
+ /* Ctrl blocks are right now encoded by RAW encoder, which was
+ * found to have some issue with final padding, so we add it
+ * here manually. This is actually still incorrect because the
+ * remaining bits of last octet with data are not filled with
+ * the padding sequence, but it's good enough since anyway PCU
+ * don't check these. */
+ data := f_pad_oct(data, f_rlcmac_cs_mcs2block_len(CS_1), '2b'O);
+ }
+ /* Enqueue DATA.ind (both TDMA frame and block numbers to be patched) */
+ f_ms_tx_data_ind(ms, data, fn, nr := nr);
+}
+
+function f_ms_tx_ul_data_blocks_gprs(inout GprsMS ms, template (value) LlcBlocks blocks,
+ uint4_t cv := 15, boolean with_tlli := false, uint32_t fn := 0,
+ template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum)
+runs on MS_BTS_IFACE_CT {
+ var template (value) RlcmacUlBlock ul_data;
+
+ ul_data := t_RLCMAC_UL_DATA(cs := ms.ul_tbf.tx_cs_mcs,
+ tfi := ms.ul_tbf.tfi,
+ cv := cv,
+ bsn := ms.ul_tbf.bsn,
+ blocks := blocks);
+ if (with_tlli) {
+ ul_data.data.mac_hdr.tlli_ind := true;
+ ul_data.data.tlli := ms.tlli;
+ }
+ f_ultbf_inc_bsn(ms.ul_tbf);
+ f_ms_tx_ul_block(ms, ul_data, fn, nr := nr);
+}
+
+function f_ms_tx_ul_data_blocks_egprs(inout GprsMS ms, template (value) EgprsLlcBlocks blocks,
+ uint4_t cv := 15, boolean with_tlli := false, uint32_t fn := 0,
+ template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum)
+runs on MS_BTS_IFACE_CT {
+ var template (value) RlcmacUlBlock ul_data;
+
+ ul_data := t_RLCMAC_UL_EGPRS_DATA(mcs := ms.ul_tbf.tx_cs_mcs,
+ tfi := ms.ul_tbf.tfi,
+ cv := cv,
+ bsn1 := ms.ul_tbf.bsn,
+ bsn2_offset := 0,
+ blocks := blocks);
+ if (with_tlli) {
+ ul_data.data_egprs.tlli_ind := true;
+ ul_data.data_egprs.tlli := ms.tlli;
+ }
+ f_ultbf_inc_bsn(ms.ul_tbf);
+ f_ms_tx_ul_block(ms, ul_data, fn, nr := nr);
+}
+
+function f_ms_tx_ul_data_block(inout GprsMS ms, octetstring payload,
+ uint4_t cv := 15, boolean with_tlli := false, uint32_t fn := 0,
+ template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum)
+runs on MS_BTS_IFACE_CT {
+ var template (value) RlcmacUlBlock ul_data;
+
+ if (f_rlcmac_cs_mcs_is_mcs(ms.ul_tbf.tx_cs_mcs)) {
+ f_ms_tx_ul_data_blocks_egprs(ms, {t_RLCMAC_LLCBLOCK_EGPRS(payload)}, cv, with_tlli, fn, nr)
+ } else {
+ f_ms_tx_ul_data_blocks_gprs(ms, {t_RLCMAC_LLCBLOCK(payload)}, cv, with_tlli, fn, nr);
+ }
+}
+
+/* Send random payload for last "num_blocks" blocks in Ul TBF (ending with CV=0). */
+function f_ms_tx_ul_data_block_multi(inout GprsMS ms, integer num_blocks := 1, boolean with_tlli := false,
+ uint32_t fn := 0, template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum)
+runs on MS_BTS_IFACE_CT return octetstring {
+ var octetstring total_payload := ''O;
+ var uint32_t payload_fill_len := f_ultbf_payload_fill_length(ms.ul_tbf, with_tlli, 0);
+
+ for (var integer i := 0; i < num_blocks; i := i + 1) {
+ var octetstring payload := f_rnd_octstring(payload_fill_len);
+ /* Prepare a new UL block (CV, random payload) */
+ var integer cv := num_blocks - i - 1;
+ if (cv > g_bs_cv_max) {
+ cv := 15;
+ }
+ if (i == 1) {
+ /* We use FN on i=0 to jump to wanted FN time, then simply submit on next
+ * available frame (fn=0) */
+ fn := 0;
+ }
+ f_ms_tx_ul_data_block(ms, payload, cv := cv, with_tlli := with_tlli, fn := fn, nr := nr);
+ total_payload := total_payload & payload;
+ }
+ return total_payload;
+}
+
+function f_rlcmac_dl_block_get_tfi(RlcmacDlBlock dl_block)
+runs on MS_BTS_IFACE_CT return uint5_t {
+ if (ischosen(dl_block.data)) {
+ return dl_block.data.mac_hdr.hdr_ext.tfi;
+ } else if (ischosen(dl_block.data_egprs)) {
+ return dl_block.data_egprs.mac_hdr.tfi;
+ } else { /* Ctrl block */
+ if (match(dl_block, tr_RLCMAC_UL_PACKET_ASS_GPRS(?, tr_PktUlAssGprsDynamic(tr_DynamicAllocation(?))))) {
+ return dl_block.ctrl.payload.u.ul_assignment.gprs.dyn_block_alloc.ul_tfi_assignment;
+ }
+ if (match(dl_block, tr_RLCMAC_UL_PACKET_ASS_EGPRS(?, tr_PktUlAssEgprsDynamic(tr_DynamicAllocation(?))))) {
+ return dl_block.ctrl.payload.u.ul_assignment.egprs.dyn_block_alloc.ul_tfi_assignment;
+ }
+ if (match(dl_block, tr_RLCMAC_DL_PACKET_ASS(?))) {
+ return dl_block.ctrl.payload.u.dl_assignment.dl_tfi_assignment;
+ }
+ }
+ setverdict(fail, "DlBlock doesn't contain a TFI:", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ return 0; /* make compiler happy */
+}
+
+function f_rlcmac_dl_block_get_usf(RlcmacDlBlock dl_block)
+runs on MS_BTS_IFACE_CT return uint3_t {
+ if (ischosen(dl_block.data)) {
+ return dl_block.data.mac_hdr.mac_hdr.usf;
+ } else if (ischosen(dl_block.data_egprs)) {
+ return dl_block.data_egprs.mac_hdr.usf;
+ } else { /* Ctrl block */
+ return dl_block.ctrl.mac_hdr.usf;
+ }
+ setverdict(fail, "DlBlock doesn't contain a USF:", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ return 0; /* make compiler happy */
+}
+
+/* Get the Chan coding command from a dl block containing PACCH UL Assignment */
+function f_rlcmac_dl_block_get_assigned_ul_cs_mcs(RlcmacDlBlock dl_block)
+runs on MS_BTS_IFACE_CT return CodingScheme {
+ if (match(dl_block, tr_RLCMAC_UL_PACKET_ASS_GPRS(?, tr_PktUlAssGprsDynamic(?)))) {
+ return f_rlcmac_block_ChCodingCommand2cs_mcs(dl_block.ctrl.payload.u.ul_assignment.gprs.ch_coding_cmd);
+ }
+ if (match(dl_block, tr_RLCMAC_UL_PACKET_ASS_EGPRS(?, tr_PktUlAssEgprsDynamic(?)))) {
+ return f_rlcmac_block_EgprsChCodingCommand2cs_mcs(dl_block.ctrl.payload.u.ul_assignment.egprs.chan_coding_cmd);
+ }
+ setverdict(fail, "DlBlock doesn't contain CS_MCS information:", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ return CS_1; /* make compiler happy */
+}
+
+/* TS 44.060 sec 12.3 Ack/Nack Description */
+function f_acknackdesc_ack_block(inout AckNackDescription desc, RlcmacDlBlock dl_block, BIT1 final_ack := '0'B)
+{
+ var uint7_t bsn;
+ var integer i;
+ var integer inc;
+ bsn := dl_block.data.mac_hdr.hdr_ext.bsn;
+
+ /* Filling hole? */
+ if (bsn < desc.starting_seq_nr) {
+ desc.receive_block_bitmap[lengthof(desc.receive_block_bitmap) - (desc.starting_seq_nr - bsn)] := int2bit(1, 1);
+ return;
+ }
+ /* Filling hole, wraparound: */
+ if (bsn - desc.starting_seq_nr > lengthof(desc.receive_block_bitmap)) {
+ desc.receive_block_bitmap[lengthof(desc.receive_block_bitmap) - (desc.starting_seq_nr + (218 - bsn))] := int2bit(1, 1);
+ return;
+ }
+
+ inc := bsn - desc.starting_seq_nr + 1;
+
+ /* SSN is increased, and so RBB values need to be moved */
+ for (i := 0; i < lengthof(desc.receive_block_bitmap) - inc; i := i+1) {
+ desc.receive_block_bitmap[i] := desc.receive_block_bitmap[i + inc];
+ }
+ for (i := lengthof(desc.receive_block_bitmap) - inc; i < lengthof(desc.receive_block_bitmap) - 1; i := i+1) {
+ desc.receive_block_bitmap[i] := int2bit(0, 1);
+ }
+ /* Now we can set current bit and update SSN */
+ desc.starting_seq_nr := (bsn + 1) mod 128;
+ desc.receive_block_bitmap[lengthof(desc.receive_block_bitmap) - 1] := int2bit(1, 1);
+
+ /* Finally update the final_ack bit as requested: */
+ desc.final_ack := final_ack;
+}
+
+/* TS 44.060 sec 12.3 Ack/Nack Description */
+function f_egprs_acknackdesc_ack_block(inout EgprsAckNackDescription desc, RlcmacDlBlock dl_block, BIT1 final_ack := '0'B)
+{
+ var uint11_t bsn;
+ var integer i;
+ var integer inc;
+ var integer n := 0;
+ var integer v_q := (desc.starting_seq_nr + 2047) mod 2048; /* SSN = V(Q) + 1 */
+
+ bsn := dl_block.data_egprs.mac_hdr.bsn1;
+
+ /* Repetition? */
+ if (bsn < v_q) {
+ /* Filling hole, wraparound: */
+ if (bsn - v_q > lengthof(desc.urbb)) {
+ desc.urbb[lengthof(desc.urbb) - (v_q + (2048 - bsn))] := int2bit(1, 1);
+ return;
+ }
+ return;
+ }
+
+ inc := bsn - v_q + 1;
+ desc.urbb[lengthof(desc.urbb) - inc] := int2bit(1, 1);
+
+ for (i := lengthof(desc.urbb) - 1; i >= lengthof(desc.urbb) - inc; i := i - 1) {
+ if (desc.urbb[i] == '0'B) {
+ break;
+ }
+ n := n + 1;
+ }
+
+ if (n > 0) {
+ /* SSN is increased, and so RBB values need to be moved */
+ for (i := lengthof(desc.urbb) - 1; i >= n; i := i - 1) {
+ desc.urbb[i] := desc.urbb[i - n];
+ }
+ for (i := n - 1; i >= 0; i := i - 1) {
+ desc.urbb[i] := int2bit(0, 1);
+ }
+
+ desc.starting_seq_nr := (desc.starting_seq_nr + n) mod 2048;
+ }
+
+ /* Finally update the final_ack bit as requested: */
+ desc.final_ack := final_ack;
+}
+
+/* This function can be used to send DATA.cnf in response to the IUT originated DATA.req. */
+function f_pcuif_tx_data_cnf(in BTS_CCCH_Block data_msg)
+runs on MS_BTS_IFACE_CT {
+ var PCUIF_data_cnf cnf := {
+ sapi := data_msg.raw.sapi,
+ msg_id := data_msg.msg_id
+ };
+
+ var PCUIF_Message pcu_msg_cnf := {
+ msg_type := PCU_IF_MSG_DATA_CNF_2,
+ bts_nr := data_msg.bts_nr,
+ spare := '0000'O,
+ u := { data_cnf2 := cnf}
+ };
+
+ BTS.send(pcu_msg_cnf);
+}
+
+private function f_ms_gtfi_tmpl(inout GprsMS ms)
+runs on MS_BTS_IFACE_CT return template (present) GlobalTfi {
+ var template (present) GlobalTfi gtfi;
+ if (ispresent(ms.ul_tbf) and ispresent(ms.dl_tbf)) {
+ gtfi := ({ is_dl_tfi := false, tfi := ms.ul_tbf.tfi },
+ { is_dl_tfi := true, tfi := ms.dl_tbf.tfi });
+ } else if (ispresent(ms.ul_tbf)) {
+ gtfi := { is_dl_tfi := false, tfi := ms.ul_tbf.tfi };
+ } else if (ispresent(ms.dl_tbf)) {
+ gtfi := { is_dl_tfi := true, tfi := ms.dl_tbf.tfi };
+ } else {
+ gtfi := ?;
+ }
+ return gtfi;
+}
+
+altstep as_ms_rx_pkt_neighbor_cell_data(inout GprsMS ms, octetstring exp_si,
+ inout uint5_t exp_container_idx /* := 0 */,
+ inout integer si_offset /* := 0 */,
+ template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum,
+ boolean single_step := false)
+runs on MS_BTS_IFACE_CT {
+ var integer len;
+ var octetstring exp_si_chunk;
+ var template (present) GlobalTfi gtfi := f_ms_gtfi_tmpl(ms);
+ var BTS_PDTCH_Block data_msg;
+ var boolean do_repeat := true;
+
+ [] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr, tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ tr_RLCMAC_DL_CTRL(?, tr_RlcMacDlCtrl_PKT_NEIGH_CELL_DATA(gtfi, exp_container_idx))
+ )) -> value data_msg {
+
+ var PacketNeighbourCellData neigh_data := data_msg.dl_block.ctrl.payload.u.neighbour_cell_data;
+ var PacketNeighbourCellDataContainer cont := neigh_data.container_list[0];
+
+ if (cont.cd_length == 31) { /* continues on next message */
+ len := lengthof(cont.container_data);
+ exp_si_chunk := substr(exp_si, si_offset, len);
+ if (cont.container_data != exp_si_chunk) {
+ setverdict(fail, "Rx unexpected SI chunk at offset ", si_offset, ": ",
+ cont.container_data, " vs exp ", exp_si_chunk);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ si_offset := si_offset + len;
+ } else if (cont.cd_length == 0) {
+ /* we are done */
+ if (si_offset != lengthof(exp_si)) {
+ setverdict(fail, "Rx unexpectd SI length ", si_offset,
+ " vs exp ", lengthof(exp_si));
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ do_repeat := false;
+ } else { /* data length, last message */
+ len := cont.cd_length;
+ exp_si_chunk := substr(exp_si, si_offset, len);
+ if (cont.container_data != exp_si_chunk) {
+ setverdict(fail, "Rx unexpected SI chunk at offset ", si_offset, ": ",
+ cont.container_data, " vs exp ", exp_si_chunk);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ si_offset := si_offset + len;
+ /* we are done */
+ if (si_offset != lengthof(exp_si)) {
+ setverdict(fail, "Rx unexpectd SI length ", si_offset,
+ " vs exp ", lengthof(exp_si));
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ do_repeat := false;
+ }
+
+ exp_container_idx := exp_container_idx + 1;
+
+ if (not single_step and do_repeat) {
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+ repeat;
+ }
+ }
+}
+
+/* Handle groups of PKT NEIGHBOUR CELL DATA packets */
+function f_ms_handle_pkt_neighbor_cell_data(inout GprsMS ms, octetstring exp_si,
+ template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum,
+ uint5_t exp_container_idx := 0,
+ integer si_offset := 0,
+ boolean single_step := false)
+runs on MS_BTS_IFACE_CT {
+ var BTS_PDTCH_Block data_msg;
+
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+ alt {
+ [exp_container_idx == 0] as_ms_rx_ignore_dummy(ms, nr);
+ [exp_container_idx > 0] as_rx_fail_dummy(nr);
+ [] as_ms_rx_pkt_neighbor_cell_data(ms, exp_si, exp_container_idx, si_offset, nr, single_step);
+ [] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ tr_RLCMAC_DL_CTRL(?, ?))) -> value data_msg {
+ var GlobalTfi gtfi := { is_dl_tfi := false, tfi := ms.ul_tbf.tfi };
+ setverdict(fail, "Rx unexpected DL block: ", data_msg.dl_block, " vs exp ",
+ tr_RLCMAC_DL_CTRL(?, tr_RlcMacDlCtrl_PKT_NEIGH_CELL_DATA(gtfi, exp_container_idx)));
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ };
+
+ return;
+}
+
+/* Keep receiving & discarding DL blocks until the PCU requests USF for this MS */
+function f_ms_wait_usf(inout GprsMS ms, template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum)
+runs on MS_BTS_IFACE_CT return uint32_t {
+ var BTS_PDTCH_Block data_msg;
+
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+ alt {
+ [] as_pcuif_rx_ignore_empty(nr);
+ [] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ ?)) -> value data_msg {
+ var uint3_t rx_usf := f_rlcmac_dl_block_get_usf(data_msg.dl_block);
+ var uint3_t exp_usf := ms.ul_tbf.usf[valueof(nr.ts_nr)];
+ log("Rx DL block USF ", rx_usf, " vs exp USF ", exp_usf);
+ if (rx_usf != exp_usf) {
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+ repeat;
+ }
+ }
+ };
+
+ return data_msg.raw.fn;
+}
+
+////////////////////////
+// Low level APIs
+////////////////////////
+
+altstep as_rx_ptcch(out BTS_PTCCH_Block ret_msg, template (present) PTCCHDownlinkMsg msg := ?,
+ template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum, boolean do_repeat := false)
+runs on MS_BTS_IFACE_CT {
+ [] BTS.receive(tr_PCUIF_DATA_PTCCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PTCCH),
+ msg)) -> value ret_msg {
+ if (do_repeat) {
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PTCCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr))
+ repeat;
+ }
+ }
+}
+
+altstep as_ms_rx_imm_ass(template PCUIF_Sapi sapi := PCU_IF_SAPI_AGCH_2,
+ template GsmRrMessage t_imm_ass := ?,
+ template (present) TsTrxBtsNum nr := ts_TsTrxBtsNum,
+ out GsmRrMessage rr_imm_ass)
+runs on MS_BTS_IFACE_CT {
+ var BTS_CCCH_Block data_msg;
+ [] BTS.receive(tr_PCUIF_DATA_RR(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, 0, sapi := sapi),
+ t_imm_ass)) -> value data_msg {
+ rr_imm_ass := data_msg.rr_msg;
+ log("Rx Immediate Assignment: ", rr_imm_ass);
+ /* Send DATA.cnf back to the IUT */
+ if (ispresent(data_msg.confirm) and data_msg.confirm) {
+ f_pcuif_tx_data_cnf(data_msg);
+ }
+ setverdict(pass);
+ }
+}
+
+function f_pcuif_rx_imm_ass(template PCUIF_Sapi sapi := PCU_IF_SAPI_AGCH_2,
+ template GsmRrMessage t_imm_ass := ?,
+ template (present) TsTrxBtsNum nr := tr_TsTrxBtsNum)
+runs on MS_BTS_IFACE_CT return GsmRrMessage {
+ var GsmRrMessage rr_imm_ass;
+ timer T;
+
+ T.start(2.0);
+ alt {
+ [] as_ms_rx_imm_ass(sapi, t_imm_ass, nr, rr_imm_ass);
+ [] BTS.receive { repeat; } /* TODO: use as_ms_rx_ignore_dummy instead? */
+ [] T.timeout {
+ setverdict(fail, "Timeout waiting for Immediate Assignment");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ }
+
+ return rr_imm_ass;
+}
+
+/* One phase packet access (see 3GPP TS 44.018, table 9.1.8.1) */
+const BIT8 chan_req_def := '01111000'B; /* 01111 { 0xx | x0x | xx0 } */
+/* Single block (two phase or RR signalling) packet access */
+const BIT8 chan_req_sb := '01110000'B; /* 01110xxx */
+
+/* Establish an Uplink TBF by sending RACH.ind towards the PCU */
+function f_pcuif_tx_rach_rx_imm_ass(uint16_t ra := bit2int(chan_req_def),
+ uint8_t is_11bit := 0,
+ PCUIF_BurstType burst_type := BURST_TYPE_0,
+ TimingAdvance ta := 0,
+ template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum)
+runs on MS_BTS_IFACE_CT return GsmRrMessage {
+ var uint32_t fn;
+
+ /* FIXME: ask the BTS component to give us the current TDMA fn */
+ fn := 1337 + ta;
+
+ /* Send RACH.ind */
+ log("Sending RACH.ind on fn=", fn, " with RA=", ra, ", TA=", ta);
+ BTS.send(ts_PCUIF_RACH_IND(nr.bts_nr, nr.trx_nr, ts_nr := 0,
+ ra := ra, is_11bit := is_11bit,
+ burst_type := burst_type,
+ fn := fn, arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ qta := ta * 4));
+
+ /* 3GPP TS 44.018, table 9.1.8.1, note 2b: Request Reference shall be set to 127
+ * when Immediate Assignment is triggered by EGPRS Packet Channel Request. Here
+ * we assume that 11 bit RA always contains EGPRS Packet Channel Request. */
+ if (is_11bit != 0) { ra := 127; }
+
+ /* Expect Immediate (TBF) Assignment on the same TS/TRX/BTS */
+ return f_pcuif_rx_imm_ass(PCU_IF_SAPI_AGCH_2, tr_IMM_TBF_ASS(false, ra, fn), nr);
+}
+
+/* Enqueue DATA.ind (both TDMA frame and block numbers to be patched) */
+function f_pcuif_tx_data_ind(octetstring data, uint32_t fn := 0,
+ TimingAdvance ta := 0, int16_t lqual_cb := 0,
+ template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum)
+runs on MS_BTS_IFACE_CT {
+ var template RAW_PCU_EventParam ev_param := {tdma_fn := ? };
+ BTS.send(ts_PCUIF_DATA_IND(nr.bts_nr, nr.trx_nr, nr.ts_nr, nr.blk_nr,
+ sapi := PCU_IF_SAPI_PDTCH, data := data,
+ fn := fn, arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ ta_offs_qbits := ta * 4, lqual_cb := lqual_cb));
+ if (fn != 0) {
+ ev_param := {tdma_fn := fn };
+ }
+ BTS.receive(tr_RAW_PCU_EV(TDMA_EV_PDTCH_BLOCK_SENT, ev_param));
+}
+
+/* Enqueue RTS.req, expect DATA.req with UL ACK from the PCU */
+function f_pcuif_rx_data_req_pdtch(out BTS_PDTCH_Block data_msg,
+ template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum)
+runs on MS_BTS_IFACE_CT {
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)), block_nr := nr.blk_nr));
+
+ BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH), *)
+ ) -> value data_msg;
+}
+
+/* Expect a Paging Request Type 1 from PCU on PCUIF on specified sapi. */
+function f_pcuif_rx_pch_pag_req1(template MobileIdentityV mi1 := ?,
+ template integer pag_group := ?,
+ template (present) TsTrxBtsNum nr := tr_TsTrxBtsNum)
+runs on MS_BTS_IFACE_CT return GsmRrMessage {
+ var GsmRrMessage rr_pag_req1;
+ var octetstring imsi_suff_octstr;
+ var integer pag_group_rx;
+
+ var BTS_CCCH_Block data_msg;
+ BTS.receive(tr_PCUIF_DATA_RR(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PCH_2),
+ tr_PAG_REQ1(tr_MI_LV(mi1)))) -> value data_msg;
+ rr_pag_req1 := data_msg.rr_msg;
+ log("Rx Paging Request Type1: ", rr_pag_req1);
+
+ /* The last 3 digits of the IMSI are used to calculate paging group: */
+ imsi_suff_octstr := substr(char2oct(data_msg.imsi), lengthof(data_msg.imsi) - 3, 3);
+ pag_group_rx := str2int(oct2char(imsi_suff_octstr[0])) * 100 +
+ str2int(oct2char(imsi_suff_octstr[1])) * 10 +
+ str2int(oct2char(imsi_suff_octstr[2]));
+
+ /* Make sure that received paging froup matches the expected one */
+ if (not match(pag_group_rx, pag_group)) {
+ setverdict(fail, "Paging group", pag_group_rx, " does not match expected ", pag_group);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ /* Send DATA.cnf back to the IUT */
+ if (ispresent(data_msg.confirm) and data_msg.confirm) {
+ f_pcuif_tx_data_cnf(data_msg);
+ }
+ return rr_pag_req1;
+}
+
+function f_rx_rlcmac_dl_block(out RlcmacDlBlock dl_block, out uint32_t dl_fn,
+ template (present) CodingScheme exp_cs_mcs := ?,
+ template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum)
+runs on MS_BTS_IFACE_CT {
+ var BTS_PDTCH_Block data_msg;
+ f_pcuif_rx_data_req_pdtch(data_msg, nr := nr);
+
+ if (data_msg.dl_block == omit) {
+ setverdict(fail, "Expected RLCMAC block but received idle block (", data_msg.raw.len, ")");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ dl_block := data_msg.dl_block;
+ dl_fn := data_msg.raw.fn;
+
+ var integer len := lengthof(data_msg.raw.data);
+ var CodingScheme cs_mcs := f_rlcmac_block_len2cs_mcs(len)
+ if (not match(f_rlcmac_block_len2cs_mcs(len), exp_cs_mcs)) {
+ setverdict(fail, "Failed to match Coding Scheme exp ", exp_cs_mcs, " vs ", cs_mcs, " (", len, ")");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+}
+
+function f_rx_rlcmac_dl_block_exp_ack_nack(out RlcmacDlBlock dl_block, out uint32_t poll_fn,
+ template RlcmacDlBlock acknack_tmpl := (tr_RLCMAC_UL_ACK_NACK_GPRS(ul_tfi := ?),
+ tr_RLCMAC_UL_ACK_NACK_EGPRS(ul_tfi := ?)),
+ template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum)
+runs on MS_BTS_IFACE_CT {
+ var uint32_t dl_fn;
+
+ f_rx_rlcmac_dl_block(dl_block, dl_fn, nr := nr);
+ if (match(dl_block, acknack_tmpl)) {
+ poll_fn := f_rrbp_ack_fn(dl_fn, dl_block.ctrl.mac_hdr.rrbp);
+ return;
+ }
+ setverdict(fail, "Failed to match Packet Uplink ACK / NACK:", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+}
+
+function f_rx_rlcmac_dl_block_exp_dummy(out RlcmacDlBlock dl_block,
+ template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum)
+runs on MS_BTS_IFACE_CT return uint32_t {
+ var uint32_t dl_fn;
+
+ f_rx_rlcmac_dl_block(dl_block, dl_fn, nr := nr);
+ if (not match(dl_block, tr_RLCMAC_DL_DUMMY_CTRL())) {
+ setverdict(fail, "Failed to match Packet DUMMY DL");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ return dl_fn;
+}
+
+/* Keep getting dl_block until first non RLCMAC Dummy is received, then return it */
+function f_rx_rlcmac_dl_block_skip_dummy(out RlcmacDlBlock dl_block,
+ integer max_dummy := -1,
+ template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum)
+runs on MS_BTS_IFACE_CT return uint32_t {
+ var integer i := 0;
+ var uint32_t dl_fn;
+
+ while (true) {
+ f_rx_rlcmac_dl_block(dl_block, dl_fn, nr := nr);
+ if (not match(dl_block, tr_RLCMAC_DL_DUMMY_CTRL)) {
+ /* Received first data, starting processing: */
+ break;
+ }
+ i := i + 1;
+ if (max_dummy >= 0 and i > max_dummy) {
+ setverdict(fail, "Didn't receive DL data after receiving ", i, " dummy blocks");
+ f_shutdown(__BFILE__, __LINE__);
+ break;
+ }
+ }
+ return dl_fn;
+}
+
+function f_rx_rlcmac_dl_block_exp_pkt_pag_req(out RlcmacDlBlock dl_block,
+ template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum)
+runs on MS_BTS_IFACE_CT {
+ var uint32_t dl_fn;
+
+ f_rx_rlcmac_dl_block(dl_block, dl_fn, nr := nr);
+ if (not match(dl_block, tr_RLCMAC_PACKET_PAG_REQ())) {
+ setverdict(fail, "Failed to match Packet Paging Request: ", dl_block, " vs ", tr_RLCMAC_PACKET_PAG_REQ());
+ f_shutdown(__BFILE__, __LINE__);
+ }
+}
+
+/* This function does what could probably be done with templates */
+function f_rlcmac_dl_block_verify_data_gprs(in RlcmacDlDataBlock data_block,
+ template (present) octetstring data := ?,
+ template (present) uint7_t exp_bsn := ?,
+ template (present) CodingScheme exp_cs := ?)
+runs on MS_BTS_IFACE_CT {
+ if (not match(data_block.mac_hdr.hdr_ext.bsn, exp_bsn)) {
+ setverdict(fail, "DL block BSN doesn't match: ",
+ data_block.mac_hdr.hdr_ext.bsn, " vs exp ", exp_bsn);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ if (lengthof(data_block.blocks) < 1) {
+ setverdict(fail, "DL block has no LLC payload: ", data_block);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ if (not match(data_block.blocks[0].payload, data)) {
+ setverdict(fail, "Failed to match content of LLC payload in DL Block: ",
+ data_block.blocks[0].payload, " vs ", data);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ if (not match(data_block.cs, exp_cs)) {
+ setverdict(fail, "Failed to match ", data_block.cs, " vs exp ", exp_cs);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+}
+
+/* This function does what could probably be done with templates */
+function f_rlcmac_dl_block_verify_data_egprs(in RlcmacDlEgprsDataBlock data_block,
+ template (present) octetstring data := ?,
+ template (present) uint14_t exp_bsn := ?,
+ template (present) CodingScheme exp_cs := ?)
+runs on MS_BTS_IFACE_CT {
+ if (not match(data_block.mac_hdr.bsn1, exp_bsn)) {
+ setverdict(fail, "DL block BSN doesn't match: ",
+ data_block.mac_hdr.bsn1, " vs exp ", exp_bsn);
+ }
+
+ if (lengthof(data_block.blocks) < 1) {
+ setverdict(fail, "DL block has no LLC payload: ", data_block);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ if (not match(data_block.blocks[0].payload, data)) {
+ setverdict(fail, "Failed to match content of LLC payload in DL Block: ",
+ data_block.blocks[0].payload, " vs ", data);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ if (not match(data_block.mcs, exp_cs)) {
+ setverdict(fail, "Failed to match ", data_block.mcs, " vs exp ", exp_cs);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+}
+
+/* High level (task specific) helper for matching GPRS/EGPRS data blocks */
+function f_rlcmac_dl_block_exp_data(in RlcmacDlBlock dl_block,
+ template (present) octetstring data := ?,
+ template (present) uint7_t exp_bsn := ?,
+ template (present) CodingScheme exp_cs := ?)
+runs on MS_BTS_IFACE_CT {
+ /* Make sure it's either GPRS or EGPRS data block */
+ if (not match(dl_block, tr_RLCMAC_DATA)) {
+ setverdict(fail, "Failed to match DL DATA: ", dl_block, " vs ", tr_RLCMAC_DATA);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ if (ischosen(dl_block.data_egprs)) {
+ f_rlcmac_dl_block_verify_data_egprs(dl_block.data_egprs, data, exp_bsn, exp_cs);
+ } else if (ischosen(dl_block.data)) {
+ f_rlcmac_dl_block_verify_data_gprs(dl_block.data, data, exp_bsn, exp_cs);
+ } else {
+ /* Should not happen, but the caller may theoretically give us a template for CTRL */
+ setverdict(fail, "DL block is neither GPRS nor EGPRS data block: ", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+}
+
+/* High level (task specific) helper for receiving and matching GPRS/EGPRS data blocks */
+function f_rx_rlcmac_dl_block_exp_data(out RlcmacDlBlock dl_block, out uint32_t dl_fn,
+ template (present) octetstring data := ?,
+ template (present) uint7_t exp_bsn := ?,
+ template (present) CodingScheme exp_cs := ?,
+ template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum)
+runs on MS_BTS_IFACE_CT {
+ /* FIXME: ideally we should use an alt statement with timeout here, rather than
+ * having +100500 layers of abstraction. This would facilitate developing the
+ * multi-TBF/-TRX/-BTS tests, where you cannot expect that the first received
+ * block is exactly what you need. */
+ f_rx_rlcmac_dl_block(dl_block, dl_fn, nr := nr);
+
+ f_rlcmac_dl_block_exp_data(dl_block, data, exp_bsn, exp_cs);
+}
+
+function f_dl_block_ack_fn(in RlcmacDlBlock dl_block, uint32_t dl_fn)
+runs on MS_BTS_IFACE_CT return uint32_t {
+ var boolean rrbp_valid;
+ var MacRrbp rrbp;
+
+ /* The argument must be either a GPRS or EGPRS data block */
+ if (ischosen(dl_block.data_egprs)) {
+ rrbp_valid := dl_block.data_egprs.mac_hdr.esp != '00'B;
+ rrbp := dl_block.data_egprs.mac_hdr.rrbp;
+ } else if (ischosen(dl_block.data)) {
+ rrbp_valid := dl_block.data.mac_hdr.mac_hdr.rrbp_valid;
+ rrbp := dl_block.data.mac_hdr.mac_hdr.rrbp;
+ } else {
+ rrbp_valid := dl_block.ctrl.mac_hdr.rrbp_valid;
+ rrbp := dl_block.ctrl.mac_hdr.rrbp;
+ }
+
+ /* Make sure that the given block really needs to be ACKnowledged */
+ if (not rrbp_valid) {
+ setverdict(fail, "DL block shall not be ACKnowledged, field RRBP is not valid");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ return f_rrbp_ack_fn(dl_fn, rrbp);
+}
+
+function f_dl_block_rrbp_valid(in RlcmacDlBlock dl_block)
+runs on MS_BTS_IFACE_CT return boolean {
+ if (ischosen(dl_block.data_egprs)) {
+ return dl_block.data_egprs.mac_hdr.esp != '00'B;
+ } else if (ischosen(dl_block.data)) {
+ return dl_block.data.mac_hdr.mac_hdr.rrbp_valid;
+ } else {
+ return dl_block.ctrl.mac_hdr.rrbp_valid;
+ }
+}
+
+/* Return true if a given Packet Paging Request contains the given IMSI, false otherwise */
+function f_pkt_paging_match_imsi(in PacketPagingReq req, template (present) hexstring imsi,
+ boolean cs_domain := true, boolean ps_domain := true)
+runs on MS_BTS_IFACE_CT return boolean {
+ if (not ispresent(req.repeated_pageinfo)) {
+ setverdict(fail, "Packet Paging Request without MIs?!?");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ for (var integer i := 0; i < lengthof(req.repeated_pageinfo); i := i + 1) {
+ var PageInfo info := req.repeated_pageinfo[i].item;
+ var MobileIdentityLV_Paging mi_lv;
+
+ if (ischosen(info.cs)) { /* CS domain */
+ if (not ispresent(info.cs.mobile_identity))
+ { continue; }
+ if (not cs_domain)
+ { continue; }
+ mi_lv := info.cs.mobile_identity;
+ } else { /* PS domain */
+ if (not ispresent(info.ps.mobile_identity))
+ { continue; }
+ if (not ps_domain)
+ { continue; }
+ mi_lv := info.ps.mobile_identity;
+ }
+
+ /* Make sure MI contains IMSI before referencing it */
+ if (match(mi_lv.mobile_id, decmatch tr_MI_IMSI(imsi))) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+/* Return true if a given Packet Paging Request contains the given P-TMSI, false otherwise */
+function f_pkt_paging_match_tmsi(in PacketPagingReq req, template GsmTmsi tmsi,
+ boolean cs_domain := true, boolean ps_domain := true)
+runs on MS_BTS_IFACE_CT return boolean {
+ if (not ispresent(req.repeated_pageinfo)) {
+ setverdict(fail, "Packet Paging Request without MIs?!?");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ for (var integer i := 0; i < lengthof(req.repeated_pageinfo); i := i + 1) {
+ var PageInfo info := req.repeated_pageinfo[i].item;
+
+ if (cs_domain and ischosen(info.cs)) {
+ if (not ispresent(info.cs.tmsi))
+ { continue; }
+ if (match(info.cs.tmsi, tmsi))
+ { return true; }
+ } else if (ps_domain) {
+ if (not ispresent(info.ps.ptmsi))
+ { continue; }
+ if (match(info.ps.ptmsi, tmsi))
+ { return true; }
+ }
+ }
+
+ return false;
+}
+
+}
diff --git a/pcu/GPRS_TBF.ttcn b/pcu/GPRS_TBF.ttcn
index 1c9a75b5..3794410b 100644
--- a/pcu/GPRS_TBF.ttcn
+++ b/pcu/GPRS_TBF.ttcn
@@ -14,8 +14,10 @@ module GPRS_TBF {
import from GSM_Types all;
import from Osmocom_Types all;
import from General_Types all;
-import from RLCMAC_Types all;
+import from Misc_Helpers all;
import from RLCMAC_CSN1_Types all;
+import from RLCMAC_Types all;
+import from RLCMAC_Templates all;
import from LLC_Types all;
import from GPRS_Context all;
@@ -325,10 +327,10 @@ function f_ul_tbf_get_next_block(out RlcmacUlBlock blk, inout UlTbfState us, ino
/* include TLLI when needed */
if (tlli_needed) {
- blk := valueof(t_RLCMAC_UL_DATA_TLLI(us.tfi, cv, us.et.v_s,
+ blk := valueof(t_RLCMAC_UL_DATA_TLLI(CS_1, us.tfi, cv, us.et.v_s,
llc_blocks, false, mmctx.tlli));
} else {
- blk := valueof(t_RLCMAC_UL_DATA(us.tfi, cv, us.et.v_s, llc_blocks, false));
+ blk := valueof(t_RLCMAC_UL_DATA(CS_1, us.tfi, cv, us.et.v_s, llc_blocks, false));
}
/* Increment Block Sequence Number */
@@ -408,8 +410,9 @@ function f_dl_tbf_mod_sns(DlTbfState ds, integer val) return integer
}
function f_dl_tbf_is_in_window(integer bsn) return boolean {
- setverdict(fail, "pleaes implement me");
- mtc.stop;
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+ "please implement me");
+ return false;
}
function f_dl_tbf_is_received(inout DlTbfState ds, integer bsn) return boolean {
diff --git a/pcu/PCUIF_RAW_Components.ttcn b/pcu/PCUIF_Components.ttcn
index ab8b3b75..6e956ba8 100644
--- a/pcu/PCUIF_RAW_Components.ttcn
+++ b/pcu/PCUIF_Components.ttcn
@@ -1,4 +1,4 @@
-module PCUIF_RAW_Components {
+module PCUIF_Components {
/*
* Components for (RAW) PCU test cases.
@@ -19,6 +19,11 @@ import from UD_Types all;
import from PCUIF_Types all;
import from PCUIF_CodecPort all;
+import from Osmocom_Types all;
+import from General_Types all;
+import from RLCMAC_Types all;
+import from GSM_RR_Types all;
+
/* Component communication diagram:
*
* +-----+ +----------+ +---------+
@@ -100,6 +105,7 @@ template RAW_PCU_Event tr_RAW_PCU_CLCK_EV := {
/* Commands are mostly used by the MTC to configure the components
* at run-time, e.g. to enable or disable some optional features. */
type enumerated RAW_PCU_CommandType {
+ GENERAL_CMD_SHUTDOWN, /*!< Shut down component and all its child components */
TDMA_CMD_ENABLE_PTCCH_UL_FWD /*!< Enable forwarding of TDMA_EV_PTCCH_UL_BURST to the MTC */
};
@@ -118,11 +124,63 @@ template RAW_PCU_Command tr_RAW_PCU_CMD(template RAW_PCU_CommandType cmd := ?,
data := data
}
+/* PCUIF req_data containing decoded rlcmac/rr, for users to be able to match
+ * directly on receive()
+ */
+type record BTS_PDTCH_Block {
+ uint8_t bts_nr,
+ PCUIF_data raw,
+ RlcmacDlBlock dl_block optional
+};
+type record BTS_PTCCH_Block {
+ uint8_t bts_nr,
+ PCUIF_data raw,
+ PTCCHDownlinkMsg dl_block optional
+};
+type record BTS_CCCH_Block {
+ uint8_t bts_nr,
+ PCUIF_data raw,
+ OCT4 msg_id optional,
+ charstring imsi optional,
+ GsmRrMessage rr_msg,
+ boolean confirm optional
+};
+template BTS_PDTCH_Block tr_PCUIF_DATA_PDTCH(template uint8_t bts_nr,
+ template PCUIF_data raw,
+ template RlcmacDlBlock dl_block := ?) := {
+ bts_nr := bts_nr,
+ raw := raw,
+ dl_block := dl_block
+};
+template BTS_PTCCH_Block tr_PCUIF_DATA_PTCCH(template uint8_t bts_nr,
+ template PCUIF_data raw,
+ template PTCCHDownlinkMsg dl_block := ?) := {
+ bts_nr := bts_nr,
+ raw := raw,
+ dl_block := dl_block
+};
+template BTS_CCCH_Block tr_PCUIF_DATA_RR(template uint8_t bts_nr,
+ template PCUIF_data raw,
+ template GsmRrMessage rr_msg := ?,
+ template OCT4 msg_id := *,
+ template charstring imsi := *,
+ template boolean confirm := *) := {
+ bts_nr := bts_nr,
+ raw := raw,
+ msg_id := msg_id,
+ imsi := imsi,
+ rr_msg := rr_msg,
+ confirm := confirm
+};
+
/* Generic port for messages and events */
type port RAW_PCU_MSG_PT message {
inout RAW_PCU_Command;
inout RAW_PCU_Event;
inout PCUIF_Message;
+ inout BTS_PDTCH_Block;
+ inout BTS_PTCCH_Block;
+ inout BTS_CCCH_Block;
} with { extension "internal" };
/* TDMA frame clock generator */
@@ -164,10 +222,12 @@ function f_tdma_ptcch_fn2ss(integer fn) return integer
return ss;
}
-function f_ClckGen_CT_handler()
+function f_ClckGen_CT_handler(integer start_fn := 0)
runs on RAW_PCU_ClckGen_CT {
var integer fn104, fn52, fn13;
+ fn := start_fn;
+
while (true) {
fn104 := fn mod 104;
fn52 := fn mod 52;
@@ -228,6 +288,18 @@ private function f_PCUIF_MsgQueue_dequeue(inout PCUIF_MsgQueue queue,
}
}
+/* Get first message from queue. true if non-empty, false otherwise */
+private function f_PCUIF_MsgQueue_first(inout PCUIF_MsgQueue queue,
+ out PCUIF_Message msg) return boolean
+{
+ if (lengthof(queue) == 0) {
+ return false;
+ }
+
+ msg := queue[0];
+ return true;
+}
+
/* Multiple base stations can be connected to the PCU. This component
* represents one BTS with an associated TDMA clock generator. */
type component RAW_PCU_BTS_CT {
@@ -248,15 +320,24 @@ type component RAW_PCU_BTS_CT {
/* Whether to forward PTCCH/U burst events to the TC */
var boolean cfg_ptcch_burst_fwd := false;
+
+ var PCUIF_info_ind g_info_ind;
}
+/* Queue received messages from Test Case, they will eventually be scheduled and
+ * sent according to their FN. FN value of 0 has the special meaning of "schedule
+ * as soon as possible". */
private altstep as_BTS_CT_MsgQueue(integer bts_nr)
runs on RAW_PCU_BTS_CT {
var PCUIF_Message pcu_msg;
/* Enqueue DATA.ind and RTS.req messages */
[] TC.receive(tr_PCUIF_MSG(PCU_IF_MSG_DATA_IND, bts_nr)) -> value pcu_msg {
- f_PCUIF_MsgQueue_enqueue(pdtch_data_queue, pcu_msg);
+ if (pcu_msg.u.data_ind.sapi == PCU_IF_SAPI_BCCH) {
+ PCUIF.send(pcu_msg); /* Forward directly ASAP */
+ } else {
+ f_PCUIF_MsgQueue_enqueue(pdtch_data_queue, pcu_msg);
+ }
repeat;
}
[] TC.receive(tr_PCUIF_RTS_REQ(bts_nr, sapi := PCU_IF_SAPI_PDTCH)) -> value pcu_msg {
@@ -274,10 +355,91 @@ runs on RAW_PCU_BTS_CT {
}
}
+/* Submit empty data on any available TS, to set up initial TDMA clock */
+private function f_tx_first_data_ind(integer bts_nr, PCUIF_info_ind info_ind, integer start_fn)
+runs on RAW_PCU_BTS_CT
+{
+ var PCUIF_Message pcu_msg;
+
+ /* Find an active TS: */
+ for (var uint8_t ts_nr := 0; ts_nr < 8; ts_nr := ts_nr + 1) {
+ for (var integer trx_nr := 0; trx_nr < lengthof(g_info_ind.trx); trx_nr := trx_nr + 1) {
+ if (g_info_ind.trx[trx_nr].pdch_mask[ts_nr] == '0'B) {
+ continue; /* TRX+TS not activated */
+ }
+
+ /* Send empty DATA.ind to set up FN */
+ pcu_msg := valueof(ts_PCUIF_DATA_IND(bts_nr, trx_nr, ts_nr, 0 /* FIXME */,
+ PCU_IF_SAPI_PDTCH, ''O, start_fn,
+ g_info_ind.trx[trx_nr].arfcn,
+ rssi := -80, ber10k := 0,
+ ta_offs_qbits := 0, lqual_cb := 10));
+ PCUIF.send(pcu_msg);
+ return;
+ }
+ }
+}
+
+private function fn2macblock(uint32_t fn) return uint8_t
+{
+ return (fn mod 52) / 4;
+}
+
+/* Get first message from queue. true if non-empty, false otherwise */
+private function f_tx_data_ind_fn(integer bts_nr, integer fn)
+runs on RAW_PCU_BTS_CT
+{
+ var PCUIF_Message pcu_msg;
+ var boolean has_msg, use_msg;
+
+ for (var uint8_t ts_nr := 0; ts_nr < 8; ts_nr := ts_nr + 1) {
+ for (var integer trx_nr := 0; trx_nr < lengthof(g_info_ind.trx); trx_nr := trx_nr + 1) {
+ //var charstring prefix := "BTS=" & int2str(bts_nr) & ",TRX=" & int2str(trx_nr) & ",TS=" & int2str(ts_nr) & ",FN=" & int2str(fn) & ": ";
+ if (g_info_ind.trx[trx_nr].pdch_mask[ts_nr] == '0'B) {
+ //log(prefix, "disabled");
+ continue; /* TRX+TS not activated */
+ }
+
+ /* Check if we reached time to serve the first DATA.ind message in the queue: */
+ has_msg := f_PCUIF_MsgQueue_first(pdtch_data_queue, pcu_msg) and
+ pcu_msg.u.data_ind.trx_nr == trx_nr and
+ pcu_msg.u.data_ind.ts_nr == ts_nr;
+ use_msg := has_msg and (pcu_msg.u.data_ind.fn == 0 or pcu_msg.u.data_ind.fn == fn);
+ if (use_msg) {
+ /* Dequeue a DATA.ind message */
+ f_PCUIF_MsgQueue_dequeue(pdtch_data_queue, pcu_msg);
+ /* Patch TDMA frame / block number */
+ pcu_msg.u.data_ind.fn := fn;
+ pcu_msg.u.data_ind.block_nr := fn2macblock(fn);
+ //log(prefix, "DATA.ind");
+ } else if (has_msg and pcu_msg.u.data_ind.fn < fn) {
+ setverdict(fail, "We are late scheduling the block! ", pcu_msg.u.data_ind.fn, " < ", fn);
+ mtc.stop;
+ } else {
+ /* NOPE.ind: */
+ pcu_msg := valueof(ts_PCUIF_DATA_IND(bts_nr, trx_nr, ts_nr, 0 /* FIXME */,
+ PCU_IF_SAPI_PDTCH, ''O, fn,
+ g_info_ind.trx[trx_nr].arfcn,
+ rssi := -80, ber10k := 0,
+ ta_offs_qbits := 0, lqual_cb := 10));
+ //log(prefix, "DATA.ind (len=0)");
+ }
+
+ PCUIF.send(pcu_msg); /* Send to the PCU and notify the TC */
+ if (use_msg) {
+ TC.send(ts_RAW_PCU_CLCK_EV(TDMA_EV_PDTCH_BLOCK_SENT, fn));
+ }
+ }
+ }
+}
+
+/* Handle schedule events and manage actions: Send msgs over PCUIF to PCU,
+ * advertise Test Case about sent messages, etc. */
private altstep as_BTS_CT_TDMASched(integer bts_nr)
runs on RAW_PCU_BTS_CT {
var PCUIF_Message pcu_msg;
var RAW_PCU_Event event;
+ var integer ev_begin_fn;
[] CLCK.receive(tr_RAW_PCU_EV(TDMA_EV_PDTCH_BLOCK_BEG)) -> value event {
/* If the RTS queue for PDTCH is not empty, send a message */
@@ -286,7 +448,7 @@ runs on RAW_PCU_BTS_CT {
/* Patch TDMA frame / block number and send */
pcu_msg.u.rts_req.fn := event.data.tdma_fn;
- pcu_msg.u.rts_req.block_nr := 0; /* FIXME! */
+ pcu_msg.u.rts_req.block_nr := fn2macblock(event.data.tdma_fn);
PCUIF.send(pcu_msg);
}
@@ -295,25 +457,21 @@ runs on RAW_PCU_BTS_CT {
PCUIF.send(ts_PCUIF_TIME_IND(bts_nr, event.data.tdma_fn));
repeat;
}
- [lengthof(pdtch_data_queue) > 0] CLCK.receive(tr_RAW_PCU_EV(TDMA_EV_PDTCH_BLOCK_END)) -> value event {
- /* Dequeue a DATA.ind message */
- f_PCUIF_MsgQueue_dequeue(pdtch_data_queue, pcu_msg);
-
- /* Patch TDMA frame / block number */
- pcu_msg.u.data_ind.fn := event.data.tdma_fn;
- pcu_msg.u.data_ind.block_nr := 0; /* FIXME! */
-
- PCUIF.send(pcu_msg); /* Send to the PCU and notify the TC */
- TC.send(ts_RAW_PCU_CLCK_EV(TDMA_EV_PDTCH_BLOCK_SENT, event.data.tdma_fn));
+ [] CLCK.receive(tr_RAW_PCU_EV(TDMA_EV_PDTCH_BLOCK_END)) -> value event {
+ /* FN matching the beginning of current block: */
+ ev_begin_fn := event.data.tdma_fn - 3;
+ f_tx_data_ind_fn(bts_nr, ev_begin_fn);
repeat;
}
[lengthof(ptcch_rts_queue) > 0] CLCK.receive(tr_RAW_PCU_EV(TDMA_EV_PTCCH_DL_BLOCK)) -> value event {
+ /* FN matching the beginning of current block (PTCCH is interleaved over 4 non-consecutive bursts): */
+ ev_begin_fn := event.data.tdma_fn - 78;
/* Dequeue an RTS.req message for PTCCH */
f_PCUIF_MsgQueue_dequeue(ptcch_rts_queue, pcu_msg);
/* Patch TDMA frame / block number and send */
- pcu_msg.u.rts_req.fn := event.data.tdma_fn;
- pcu_msg.u.rts_req.block_nr := 0; /* FIXME! */
+ pcu_msg.u.rts_req.fn := ev_begin_fn;
+ pcu_msg.u.rts_req.block_nr := fn2macblock(ev_begin_fn);
PCUIF.send(pcu_msg);
repeat;
}
@@ -326,11 +484,16 @@ runs on RAW_PCU_BTS_CT {
[] CLCK.receive(tr_RAW_PCU_CLCK_EV) { repeat; }
}
-function f_BTS_CT_handler(integer bts_nr, PCUIF_info_ind info_ind)
+function f_BTS_CT_handler(integer bts_nr, PCUIF_info_ind info_ind, boolean decode_data_req := false)
runs on RAW_PCU_BTS_CT {
var PCUIF_Message pcu_msg;
var RAW_PCU_Command cmd;
var RAW_PCU_Event event;
+ var BTS_PDTCH_Block pcu_msg_pdtch;
+ var BTS_PTCCH_Block pcu_msg_ptcch;
+ var BTS_CCCH_Block pcu_msg_rr;
+
+ g_info_ind := info_ind;
/* Init TDMA clock generator (so we can stop and start it) */
vc_CLCK_GEN := RAW_PCU_ClckGen_CT.create("ClckGen-" & int2str(bts_nr)) alive;
@@ -339,7 +502,6 @@ runs on RAW_PCU_BTS_CT {
/* Wait until the PCU is connected */
PCUIF.receive(tr_RAW_PCU_EV(PCU_EV_CONNECT));
- /* TODO: implement ACT.req handling */
alt {
/* Wait for TXT.ind (PCU_VERSION) and respond with INFO.ind (SI13) */
[] PCUIF.receive(tr_PCUIF_TXT_IND(bts_nr, PCU_VERSION, ?)) -> value pcu_msg {
@@ -353,13 +515,81 @@ runs on RAW_PCU_BTS_CT {
u := { info_ind := info_ind }
});
+ const integer start_fn := 0;
+ f_tx_first_data_ind(bts_nr, info_ind, start_fn);
+
/* Notify the test case that we're done with SI13 */
TC.send(ts_RAW_PCU_EV(BTS_EV_SI13_NEGO));
/* Start feeding clock to the PCU */
- vc_CLCK_GEN.start(f_ClckGen_CT_handler());
+ vc_CLCK_GEN.start(f_ClckGen_CT_handler(start_fn));
+ repeat;
+ }
+ /* PCU -> TS becomes active */
+ [] PCUIF.receive(tr_PCUIF_ACT_REQ(bts_nr, ?, ?)) -> value pcu_msg {
+ log("Rx ACT.req from the PCU: TRX" & int2str(pcu_msg.u.act_req.trx_nr) &
+ "/TS" & int2str(pcu_msg.u.act_req.ts_nr));
+ repeat;
+ }
+ /* PCU -> TS becomes inactive */
+ [] PCUIF.receive(tr_PCUIF_DEACT_REQ(bts_nr, ?, ?)) -> value pcu_msg {
+ log("Rx DEACT.req from the PCU: TRX" & int2str(pcu_msg.u.act_req.trx_nr) &
+ "/TS" & int2str(pcu_msg.u.act_req.ts_nr));
repeat;
}
+ [decode_data_req] PCUIF.receive(tr_PCUIF_DATA_REQ(bts_nr, ?, ?, sapi := PCU_IF_SAPI_PCH_2)) -> value pcu_msg {
+ var charstring imsi_filter_regexp := "(\d*)"; /* numbers only */
+ var PCUIF_pch pch;
+
+ pcu_msg_rr.bts_nr := bts_nr;
+ pcu_msg_rr.raw := pcu_msg.u.data_req;
+
+ pch := dec_PCUIF_pch(pcu_msg_rr.raw.data);
+ pcu_msg_rr.msg_id := pch.msg_id;
+ pcu_msg_rr.imsi := regexp(pch.imsi, imsi_filter_regexp, 0);
+ pcu_msg_rr.rr_msg := dec_GsmRrMessage(pch.data);
+ pcu_msg_rr.confirm := pch.confirm;
+
+ TC.send(pcu_msg_rr);
+ repeat;
+ }
+ [decode_data_req] PCUIF.receive(tr_PCUIF_DATA_REQ(bts_nr, ?, ?, sapi := PCU_IF_SAPI_AGCH_2)) -> value pcu_msg {
+ var PCUIF_agch agch;
+
+ pcu_msg_rr.bts_nr := bts_nr;
+ pcu_msg_rr.raw := pcu_msg.u.data_req;
+
+ agch := dec_PCUIF_agch(pcu_msg_rr.raw.data);
+ pcu_msg_rr.imsi := omit;
+ pcu_msg_rr.msg_id := agch.msg_id;
+ pcu_msg_rr.rr_msg := dec_GsmRrMessage(agch.data);
+ pcu_msg_rr.confirm := agch.confirm;
+
+ TC.send(pcu_msg_rr);
+ repeat;
+ }
+ [decode_data_req] PCUIF.receive(tr_PCUIF_DATA_REQ(bts_nr, ?, ?, sapi := PCU_IF_SAPI_PDTCH)) -> value pcu_msg {
+ pcu_msg_pdtch.bts_nr := bts_nr;
+ pcu_msg_pdtch.raw := pcu_msg.u.data_req;
+ if (pcu_msg_pdtch.raw.len != 0) {
+ pcu_msg_pdtch.dl_block := dec_RlcmacDlBlock(pcu_msg_pdtch.raw.data);
+ } else {
+ pcu_msg_pdtch.dl_block := omit;
+ }
+ TC.send(pcu_msg_pdtch);
+ repeat;
+ }
+ [decode_data_req] PCUIF.receive(tr_PCUIF_DATA_REQ(bts_nr, ?, ?, sapi := PCU_IF_SAPI_PTCCH)) -> value pcu_msg {
+ pcu_msg_ptcch.bts_nr := bts_nr;
+ pcu_msg_ptcch.raw := pcu_msg.u.data_req;
+ if (pcu_msg_ptcch.raw.len != 0) {
+ pcu_msg_ptcch.dl_block := dec_PTCCHDownlinkMsg(pcu_msg_ptcch.raw.data);
+ } else {
+ pcu_msg_ptcch.dl_block := omit;
+ }
+ TC.send(pcu_msg_ptcch);
+ repeat;
+ }
/* PCU -> test case forwarding (filter by the BTS number) */
[] PCUIF.receive(tr_PCUIF_MSG(?, bts_nr)) -> value pcu_msg {
TC.send(pcu_msg);
@@ -372,6 +602,11 @@ runs on RAW_PCU_BTS_CT {
[] as_BTS_CT_TDMASched(bts_nr);
/* Command handling */
+ [] TC.receive(tr_RAW_PCU_CMD(GENERAL_CMD_SHUTDOWN)) {
+ log("Shutting down virtual BTS #", bts_nr, "...");
+ vc_CLCK_GEN.stop;
+ break;
+ }
[] TC.receive(tr_RAW_PCU_CMD(TDMA_CMD_ENABLE_PTCCH_UL_FWD)) {
log("Enabling forwarding of PTCCH/U TDMA events to the TC");
cfg_ptcch_burst_fwd := true;
diff --git a/pcu/PCU_Tests.cfg b/pcu/PCU_Tests.cfg
index 6ea5a5a5..6d3407de 100644
--- a/pcu/PCU_Tests.cfg
+++ b/pcu/PCU_Tests.cfg
@@ -7,13 +7,53 @@
[LOGGING]
[MODULE_PARAMETERS]
-PCU_Tests.mp_nsconfig := {
- local_ip := "127.0.0.1",
- local_udp_port := 23000,
- remote_ip := "127.0.0.1",
- remote_udp_port := 22000,
- nsvci := 1234,
- nsei := 1234
+SGSN_Components.mp_nsconfig := {
+ nsei := 1234,
+ handle_sns := false,
+ nsvc := {
+ {
+ provider := {
+ ip := {
+ address_family := AF_INET,
+ local_ip := "127.0.0.1",
+ local_udp_port := 23000,
+ remote_ip := "127.0.0.1",
+ remote_udp_port := 22000,
+ data_weight := 1,
+ signalling_weight := 1
+ }
+ },
+ nsvci := 1234
+ },
+ {
+ provider := {
+ ip := {
+ address_family := AF_INET,
+ local_ip := "127.0.0.1",
+ local_udp_port := 23001,
+ remote_ip := "127.0.0.1",
+ remote_udp_port := 22000,
+ data_weight := 1,
+ signalling_weight := 1
+ }
+ },
+ nsvci := 1234
+ },
+ {
+ provider := {
+ ip := {
+ address_family := AF_INET,
+ local_ip := "127.0.0.1",
+ local_udp_port := 23002,
+ remote_ip := "127.0.0.1",
+ remote_udp_port := 22000,
+ data_weight := 1,
+ signalling_weight := 1
+ }
+ },
+ nsvci := 1234
+ }
+ }
}
[TESTPORT_PARAMETERS]
@@ -21,4 +61,5 @@ PCU_Tests.mp_nsconfig := {
[MAIN_CONTROLLER]
[EXECUTE]
-PCU_Tests_RAW.control
+PCU_Tests.control
+PCU_Tests_NS.control
diff --git a/pcu/PCU_Tests.default b/pcu/PCU_Tests.default
index 2a87345f..c72720b7 100644
--- a/pcu/PCU_Tests.default
+++ b/pcu/PCU_Tests.default
@@ -4,27 +4,53 @@
[LOGGING]
#*.FileMask := LOG_ALL
-ConsoleMask := ERROR | WARNING | TESTCASE | TIMEROP_START | DEBUG_ENCDEC
+ConsoleMask := ERROR | WARNING | TESTCASE | TIMEROP_START | USER
+PCUIF.ConsoleMask := ERROR | TESTCASE | TIMEROP_START | USER
+"ClckGen-0".ConsoleMask := ERROR
[MODULE_PARAMETERS]
-PCU_Tests.mp_gb_cfg := {
+SGSN_Components.mp_gb_cfg := {
nsei := 1234,
- bvci := 1234,
- cell_id := {
- ra_id := {
- lai := {
- mcc_mnc := '262F42'H, lac := 13135
+ sgsn_role := true,
+ bvc := {
+ {
+ bvci := 1234,
+ cell_id := {
+ ra_id := {
+ lai := {
+ mcc_mnc := '262F42'H, lac := 13135
+ },
+ rac := 0
+ },
+ cell_id := 20960
},
- rac := 0
- },
- cell_id := 20960
- },
- sgsn_role := true
-}
+ depth := BSSGP_DECODE_DEPTH_BSSGP
+ }
+ }
+};
+Osmocom_VTY_Functions.mp_prompt_prefix := "OsmoPCU";
+PCUIF_Types.mp_pcuif_version := 12;
[TESTPORT_PARAMETERS]
-*.*.udpReuseAddress := "yes";
*.PCU.socket_type := "SEQPACKET"
+*.PCUVTY.CTRL_MODE := "client"
+*.PCUVTY.CTRL_HOSTNAME := "127.0.0.1"
+*.PCUVTY.CTRL_PORTNUM := "4240"
+*.PCUVTY.CTRL_LOGIN_SKIPPED := "yes"
+*.PCUVTY.CTRL_DETECT_SERVER_DISCONNECTED := "yes"
+*.PCUVTY.CTRL_READMODE := "buffered"
+*.PCUVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes"
+*.PCUVTY.CTRL_DETECT_CONNECTION_ESTABLISHMENT_RESULT := "yes"
+*.PCUVTY.PROMPT1 := "OsmoPCU> "
+*.STATSVTY.CTRL_MODE := "client"
+*.STATSVTY.CTRL_HOSTNAME := "127.0.0.1"
+*.STATSVTY.CTRL_PORTNUM := "4240"
+*.STATSVTY.CTRL_LOGIN_SKIPPED := "yes"
+*.STATSVTY.CTRL_DETECT_SERVER_DISCONNECTED := "yes"
+*.STATSVTY.CTRL_READMODE := "buffered"
+*.STATSVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes"
+*.STATSVTY.CTRL_DETECT_CONNECTION_ESTABLISHMENT_RESULT := "yes"
+*.STATSVTY.PROMPT1 := "OsmoPCU> "
[MAIN_CONTROLLER]
diff --git a/pcu/PCU_Tests.ttcn b/pcu/PCU_Tests.ttcn
index 42880610..cab70e8e 100644
--- a/pcu/PCU_Tests.ttcn
+++ b/pcu/PCU_Tests.ttcn
@@ -1,7 +1,13 @@
module PCU_Tests {
-/* Osmocom PCU test suite in TTCN-3
- * (C) 2018-2019 Harald Welte <laforge@gnumonks.org>
+/* "RAW" PCU tests: Talk directly to the PCU socket of OsmoPCU on the one hand side (emulating
+ the BTS/BSC side PCU socket server) and the Gb interface on the other hand side. No NS/BSSGP
+ Emulation is used; rather, we simply use the NS_CodecPort to implement both standard and non-
+ standard procedures on the NS and BSSGP level. The goal of these tests is to test exactly
+ those NS and BSSGP implementations on the BSS (PCU) side. */
+
+/* (C) 2018-2019 Harald Welte <laforge@gnumonks.org>
+ * (C) 2019-2020 Vadim Yanitskiy <axilirator@gmail.com>
* All rights reserved.
*
* Released under the terms of GNU General Public License, Version 2 or
@@ -10,697 +16,7562 @@ module PCU_Tests {
* SPDX-License-Identifier: GPL-2.0-or-later
*/
+friend module PCU_Tests_NS;
+
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 GSM_RestOctets all;
+
+import from Osmocom_VTY_Functions all;
+import from TELNETasp_PortType all;
+
+import from MobileL3_GMM_SM_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 RLCMAC_CSN1_Templates all;
+import from RLCMAC_Types all;
+import from RLCMAC_Templates all;
+
import from MobileL3_CommonIE_Types all;
import from L3_Templates all;
+import from NS_Types all;
+import from BSSGP_Types all;
+import from Osmocom_Gb_Types all;
+
+import from BSSGP_Emulation all; /* BssgpConfig */
+import from NS_Emulation all; /* NSConfiguration */
+
+import from UD_Types all;
+import from PCUIF_Types all;
+import from PCUIF_CodecPort all;
+import from PCUIF_Components all;
+import from IPL4asp_Types all;
+import from Native_Functions all;
+import from SGSN_Components all;
+import from GPRS_Components all;
+
+import from StatsD_Types all;
+import from StatsD_CodecPort all;
+import from StatsD_CodecPort_CtrlFunct all;
+import from StatsD_Checker all;
+
+import from IPA_Emulation all;
+import from Osmocom_CTRL_Types all;
+import from Osmocom_CTRL_Adapter all;
+import from Osmocom_CTRL_Functions 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;
+ charstring mp_pcu_sock_path := PCU_SOCK_DEFAULT;
+
+ float X2002 := 0.2; /* Timer -2002, IMM ASSIGN confirm delay */
+
+ charstring mp_pcu_statsd_ip := "127.0.0.1";
+ integer mp_pcu_statsd_port := 8125;
+
+ charstring mp_ctrl_neigh_ip := ""; /* Use new PCUIF over IPA multiplex for Neigh Addr Resolution */
+ integer mp_ctrl_neigh_port := 4248;
+}
+
+
+/* FIXME: make sure to use parameters from mp_gb_cfg.cell_id in the PCU INFO IND */
+friend template (value) PCUIF_info_ind ts_PCUIF_INFO_default(template (value) PCUIF_Flags flags := c_PCUIF_Flags_default)
+:= {
+ version := PCUIF_Types.mp_pcuif_version,
+ flags := flags,
+ trx := ts_PCUIF_InfoTrxs_def(GPRS_Components.mp_base_arfcn),
+ bsic := 7,
+ mcc := 262,
+ mnc := 42,
+ mnc_3_digits := 0,
+ lac := 13135,
+ rac := 0,
+ nsei := mp_nsconfig.nsei,
+ nse_timer := { 3, 3, 3, 3, 30, 3, 10 },
+ cell_timer := { 3, 3, 3, 3, 3, 10, 3, 10, 3, 10, 3 },
+ cell_id := 20960,
+ repeat_time := 5 * 50,
+ repeat_count := 3,
+ bvci := mp_gb_cfg.bvc[0].bvci,
+ t3142 := 20,
+ t3169 := 5,
+ t3191 := 5,
+ t3193_10ms := 160,
+ t3195 := 5,
+ n3101 := 10,
+ n3103 := 4,
+ n3105 := 8,
+ cv_countdown := 15,
+ dl_tbf_ext := 250 * 10, /* ms */
+ ul_tbf_ext := 250 * 10, /* ms */
+ initial_cs := 2,
+ initial_mcs := 1,
+ nsvci := { mp_nsconfig.nsvc[0].nsvci, 0 },
+ local_port := { mp_nsconfig.nsvc[0].provider.ip.remote_udp_port, 0 },
+ remote_port := { mp_nsconfig.nsvc[0].provider.ip.local_udp_port, 0 },
+ remote_addr := f_PCUIF_RemoteAddr(
+ f_PCUIF_AF2addr_type(mp_nsconfig.nsvc[0].provider.ip.address_family), mp_nsconfig.nsvc[0].provider.ip.local_ip),
+ bts_model := PCU_IF_BTS_MODEL_TRX
+}
+
+/* Passed in RAN-INFO message from emulated neighbor using RIM */
+const octetstring si1_default := '198fb100000000000000000000000000007900002b'O;
+const octetstring si3_default := '1b753000f110236ec9033c2747407900003c0b2b2b'O;
+const octetstring si13_default := '009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O;
+const octetstring si_default := si1_default & si3_default & si13_default;
+
+const MultislotCap_GPRS mscap_gprs_def := {
+ gprsmultislotclass := '00011'B,
+ gprsextendeddynalloccap := '0'B
+};
+const MultislotCap_EGPRS mscap_egprs_def := {
+ egprsmultislotclass := '00011'B,
+ egprsextendeddynalloccap := '0'B
+};
+template (value) MSRadioAccessCapabilityV ms_racap_gprs_def := { ts_RaCapRec('0001'B /* E-GSM */, mscap_gprs_def, omit) };
+template (value) MSRadioAccessCapabilityV ms_racap_egprs_def := { ts_RaCapRec('0001'B /* E-GSM */, mscap_gprs_def, mscap_egprs_def) };
+
+const MultislotCap_GPRS_BSSGP bssgp_mscap_gprs_def := {
+ gprsmultislotclass := '00011'B,
+ gprsextendeddynalloccap := '0'B
+};
+const MultislotCap_EGPRS_BSSGP bssgp_mscap_egprs_def := {
+ egprsmultislotclass := '00011'B,
+ egprsextendeddynalloccap := '0'B
+};
+template (value) MSRadioAccessCapabilityV_BSSGP bssgp_ms_racap_gprs_def := { valueof(ts_RaCapRec_BSSGP('0001'B /* E-GSM */, bssgp_mscap_gprs_def, omit)) };
+template (value) MSRadioAccessCapabilityV_BSSGP bssgp_ms_racap_egprs_def := { valueof(ts_RaCapRec_BSSGP('0001'B /* E-GSM */, bssgp_mscap_gprs_def, bssgp_mscap_egprs_def)) };
+
+type record lqual_range {
+ /* component reference to the IPA_Client component used for RSL */
+ uint8_t low,
+ uint8_t high
+}
+
+type component RAW_PCU_Test_CT extends bssgp_CT, MS_BTS_IFACE_CT, StatsD_ConnHdlr, CTRL_Adapter_CT {
+ /* PCU interface abstraction component */
+ var RAW_PCUIF_CT vc_PCUIF;
+
+ /* StatsD */
+ var StatsD_Checker_CT vc_STATSD;
+
+ /* Connection to the PCUIF component */
+ //port RAW_PCU_MSG_PT PCUIF;
+ /* VTY connection to the PCU */
+ port TELNETasp_PT PCUVTY;
+
+ /* Uplink CS/MCS thresholds, default from pcu_main.c: */
+ var lqual_range g_cs_lqual_ranges[4] := {{low := 0, high := 6},
+ {low := 5, high := 8},
+ {low := 7, high := 13},
+ {low := 12,high := 35}};
+ var lqual_range g_mcs_lqual_ranges[9] := {{low := 0, high := 6},
+ {low := 5, high := 8},
+ {low := 7, high := 13},
+ {low := 12,high := 15},
+ {low := 14, high := 17},
+ {low := 16, high := 18},
+ {low := 17,high := 20},
+ {low := 19, high := 24},
+ {low := 23,high := 35}};
+ var uint8_t g_cs_initial_dl := 1;
+ var uint8_t g_cs_initial_ul := 1;
+ var uint8_t g_mcs_initial_dl := 1;
+ var uint8_t g_mcs_initial_ul := 1;
+ var uint8_t g_cs_max_dl := 4;
+ var uint8_t g_cs_max_ul := 4;
+ var uint8_t g_mcs_max_dl := 9;
+ var uint8_t g_mcs_max_ul := 9;
+
+ var boolean g_force_two_phase_access := false;
+
+ /* Guard timeout */
+ timer g_T_guard := 60.0;
+};
+
+private altstep as_Tguard_RAW() runs on RAW_PCU_Test_CT {
+ [] g_T_guard.timeout {
+ setverdict(fail, "Timeout of T_guard");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+}
+
+private function f_pcuvty_set_allowed_cs_mcs() runs on RAW_PCU_Test_CT {
+ f_vty_config2(PCUVTY, {"pcu"}, "cs " & int2str(g_cs_initial_dl) & " " & int2str(g_cs_initial_ul));
+ f_vty_config2(PCUVTY, {"pcu"}, "cs max " & int2str(g_cs_max_dl) & " " & int2str(g_cs_max_ul));
+
+ f_vty_config2(PCUVTY, {"pcu"}, "mcs " & int2str(g_mcs_initial_dl) & " " & int2str(g_mcs_initial_ul));
+ f_vty_config2(PCUVTY, {"pcu"}, "mcs max " & int2str(g_mcs_max_dl) & " " & int2str(g_mcs_max_ul));
+}
+
+private function f_pcuvty_set_link_quality_ranges() runs on RAW_PCU_Test_CT {
+ var charstring cmd;
+
+ cmd := "cs link-quality-ranges" &
+ " cs1 " & int2str(g_cs_lqual_ranges[0].high) &
+ " cs2 " & int2str(g_cs_lqual_ranges[1].low) & " " & int2str(g_cs_lqual_ranges[1].high) &
+ " cs3 " & int2str(g_cs_lqual_ranges[2].low) & " " & int2str(g_cs_lqual_ranges[2].high) &
+ " cs4 " & int2str(g_cs_lqual_ranges[3].low);
+ f_vty_config2(PCUVTY, {"pcu"}, cmd);
+
+ cmd := "mcs link-quality-ranges" &
+ " mcs1 " & int2str(g_mcs_lqual_ranges[0].high) &
+ " mcs2 " & int2str(g_mcs_lqual_ranges[1].low) & " " & int2str(g_mcs_lqual_ranges[1].high) &
+ " mcs3 " & int2str(g_mcs_lqual_ranges[2].low) & " " & int2str(g_mcs_lqual_ranges[2].high) &
+ " mcs4 " & int2str(g_mcs_lqual_ranges[3].low) & " " & int2str(g_mcs_lqual_ranges[3].high) &
+ " mcs5 " & int2str(g_mcs_lqual_ranges[4].low) & " " & int2str(g_mcs_lqual_ranges[4].high) &
+ " mcs6 " & int2str(g_mcs_lqual_ranges[5].low) & " " & int2str(g_mcs_lqual_ranges[5].high) &
+ " mcs7 " & int2str(g_mcs_lqual_ranges[6].low) & " " & int2str(g_mcs_lqual_ranges[6].high) &
+ " mcs8 " & int2str(g_mcs_lqual_ranges[7].low) & " " & int2str(g_mcs_lqual_ranges[7].high) &
+ " mcs9 " & int2str(g_mcs_lqual_ranges[8].low);
+ f_vty_config2(PCUVTY, {"pcu"}, cmd);
+}
+
+private function f_pcuvty_flush_neigh_caches() runs on RAW_PCU_Test_CT {
+ f_pcuvty_set_neigh_caches(0, 0);
+}
+
+private function f_pcuvty_set_neigh_caches(integer neigh_cache_secs := -1, integer si_cache_secs := -1)
+runs on RAW_PCU_Test_CT {
+ if (neigh_cache_secs == -1) {
+ f_vty_config2(PCUVTY, {"pcu"}, "timer X10 default");
} else {
+ f_vty_config2(PCUVTY, {"pcu"}, "timer X10 " & int2str(neigh_cache_secs));
+ }
+ if (si_cache_secs == -1) {
+ f_vty_config2(PCUVTY, {"pcu"}, "timer X11 default");
+ } else {
+ f_vty_config2(PCUVTY, {"pcu"}, "timer X11 " & int2str(si_cache_secs));
+ }
+}
+
+private function f_pcuvty_set_timer(integer t, integer val)
+runs on RAW_PCU_Test_CT {
+ if (t >= 0) {
+ f_vty_config2(PCUVTY, {"pcu"}, "timer T" & int2str(t) & " " & int2str(val));
+ } else {
+ f_vty_config2(PCUVTY, {"pcu"}, "timer X" & int2str(t * -1) & " " & int2str(val));
+ }
+}
+
+private function f_init_vty(charstring id, boolean egprs_only) runs on RAW_PCU_Test_CT {
+ map(self:PCUVTY, system:PCUVTY);
+ f_vty_set_prompts(PCUVTY);
+ f_vty_transceive(PCUVTY, "enable");
+
+ /* This will be removed soon, not needed. EGPRS support is controlled through pcu_ind flags */
+ if (egprs_only) {
+ f_vty_config2(PCUVTY, {"pcu"}, "egprs only");
+ } else {
+ f_vty_config2(PCUVTY, {"pcu"}, "no egprs");
+ }
+
+ if (g_force_two_phase_access) {
+ f_vty_config2(PCUVTY, {"pcu"}, "two-phase-access");
+ } else {
+ f_vty_config2(PCUVTY, {"pcu"}, "no two-phase-access");
+ }
+}
+
+function f_init_raw(charstring id, template (value) PCUIF_info_ind info_ind := ts_PCUIF_INFO_default)
+runs on RAW_PCU_Test_CT {
+ /* Start the guard timer */
+ g_T_guard.start;
+ activate(as_Tguard_RAW());
+
+ /* Init PCU interface component */
+ vc_PCUIF := RAW_PCUIF_CT.create("PCUIF") alive;
+ //connect(vc_PCUIF:MTC, self:PCUIF);
+ map(vc_PCUIF:PCU, system:PCU);
+
+ /* Create one BTS component (we may want more some day) */
+ vc_BTS := RAW_PCU_BTS_CT.create("BTS") alive;
+ connect(vc_BTS:PCUIF, vc_PCUIF:BTS);
+ connect(vc_BTS:TC, self:BTS);
+
+ f_init_vty(id, f_pcuif_ind_flags_egprs_enabled(valueof(info_ind.flags)));
+
+ f_init_statsd(id, vc_STATSD, mp_pcu_statsd_ip, mp_pcu_statsd_port);
+ /* This is normally done in the ConnHdlr component, but here
+ * the Test_CT doubles as ConnHdlr */
+ connect(self:STATSD_PROC, vc_STATSD:STATSD_PROC);
+
+ vc_PCUIF.start(f_PCUIF_CT_handler(mp_pcu_sock_path));
+ vc_BTS.start(f_BTS_CT_handler(0, valueof(info_ind), true));
+
+ /* Wait until the BTS is ready (SI13 negotiated) */
+ BTS.receive(tr_RAW_PCU_EV(BTS_EV_SI13_NEGO));
+}
+
+/* Register TLLI of each allocated GprsMS instance */
+private function f_multi_ms_bssgp_register()
+runs on RAW_PCU_Test_CT {
+ for (var integer i := 0; i < lengthof(g_ms); i := i + 1) {
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, g_ms[i].tlli);
+ }
+}
+
+/* Allocate [and activate] an Uplink TBF for each allocated GprsMS instance */
+private function f_multi_ms_establish_tbf(boolean do_activate := false)
+runs on RAW_PCU_Test_CT {
+ for (var integer i := 0; i < lengthof(g_ms); i := i + 1) {
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(g_ms[i]);
+
+ /* Send a random block, so this TBF becomes "active" */
+ if (do_activate) {
+ /* FIXME: use the new APU by Pau to get correct TRX/TS here */
+ var template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum(7, i mod 8);
+ var octetstring dummy := f_rnd_octstring(12);
+ var RlcmacDlBlock dl_block;
+ var uint32_t poll_fn;
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ f_ms_wait_usf(g_ms[i]);
+
+ f_ms_tx_ul_data_block(g_ms[i], dummy, with_tlli := true, fn := g_ms[i].ul_tbf.start_time_fn, nr := nr);
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, poll_fn, nr := nr);
+ }
+ }
+}
+
+private function f_ms_establish_ul_tbf_2phase_access(inout GprsMS ms,
+ template (omit) RlcmacUlCtrlMsg pkt_res_req := omit)
+runs on RAW_PCU_Test_CT return PollFnCtx {
+ var PollFnCtx pollctx;
+
+ /* Single block (two phase) packet access */
+ var uint16_t ra := bit2int(chan_req_sb);
+ if (g_force_two_phase_access) {
+ /* If 2phase access is enforced by the network, then let's
+ * request a One phase packet access, we'll receive a single block
+ * anyway
+ */
+ ra := bit2int(chan_req_def);
+ }
+
+ /* Establish an Uplink TBF */
+ f_ms_use_ra(ms, ra, ra_is_11bit := 0);
+ f_ms_establish_ul_tbf(ms);
+
+ /* Make sure we've got an Uplink TBF assignment */
+ if (not match(ms.ul_tbf.ass.ccch, tr_PacketUlSglAssign)) {
+ setverdict(fail, "Wrong Packet Uplink Assignment received: ", ms.ul_tbf.ass.ccch, " vs exp: ", tr_PacketUlSglAssign);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ /* Send PACKET RESOURCE REQUEST
+ * (see 3GPP TS 04.60 "7.1.3.1 Initiation of the Packet resource request procedure")
+ */
+ if (istemplatekind(pkt_res_req, "omit")) {
+ pkt_res_req := ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, omit);
+ }
+
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(valueof(pkt_res_req)), ms.ul_tbf.start_time_fn, nr := f_ms_tx_TsTrxBtsNum(ms));
+ /* Store 1st UlTBF context before receiving next one, will
+ * overwrite the TS allocation on MS with info from new UL TBF:
+ */
+ pollctx.tstrxbts := f_ms_tx_TsTrxBtsNum(ms);
+ f_ms_rx_pkt_ass_pacch(ms, pollctx.fn, tr_RLCMAC_UL_PACKET_ASS, nr := f_ms_tx_TsTrxBtsNum(ms));
+ return pollctx;
+}
+
+testcase TC_pcuif_suspend() runs on RAW_PCU_Test_CT {
+ var octetstring ra_id := enc_RoutingAreaIdentification(mp_gb_cfg.bvc[0].cell_id.ra_id);
+ var GprsTlli tlli := TLLI_UNUSED;
+ timer T;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+
+ BTS.send(ts_PCUIF_SUSP_REQ(0, tlli, ra_id, 0));
+
+ T.start(2.0);
+ alt {
+ [] BSSGP_GLOBAL[0].receive(tr_BSSGP_SUSPEND(tlli, mp_gb_cfg.bvc[0].cell_id.ra_id)) {
+ setverdict(pass);
+ }
+ [] T.timeout {
+ setverdict(fail, "Timeout waiting for BSSGP SUSPEND");
+ }
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Make sure TBF is released and no data is sent for in after reciving a Suspend Request from that MS. See OS#4761 */
+testcase TC_pcuif_suspend_active_tbf() runs on RAW_PCU_Test_CT {
+ var octetstring ra_id := enc_RoutingAreaIdentification(mp_gb_cfg.bvc[0].cell_id.ra_id);
+ var BTS_PDTCH_Block data_msg;
+ var RlcmacDlBlock dl_block;
+ var octetstring data := f_rnd_octstring(10);
+ var uint32_t sched_fn;
+ var uint32_t dl_fn;
+ var GprsMS ms;
+ timer T;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ f_ms_wait_usf(ms);
+
+ /* Send one UL block (with TLLI since we are in One-Phase Access
+ contention resolution) and make sure it is ACKED fine */
+ f_ms_tx_ul_data_block_multi(ms, 1, with_tlli := true, fn := ms.ul_tbf.start_time_fn);
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn);
+ /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+
+ /* UL block should be received in SGSN */
+ BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id));
+
+ /* Now SGSN sends some DL data, PCU will page on CCCH (PCH) */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
+ f_sleep(X2002);
+ f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0);
+
+ /* MS has moved to CS, it sent SUSP REQ to BTS and PCU gets it, TBF is freed: */
+ BTS.send(ts_PCUIF_SUSP_REQ(0, ms.tlli, ra_id, 0));
+
+ T.start(2.0);
+ alt {
+ [] BSSGP_GLOBAL[0].receive(tr_BSSGP_SUSPEND(ms.tlli, mp_gb_cfg.bvc[0].cell_id.ra_id)) {
setverdict(pass);
+ }
+ [] T.timeout {
+ setverdict(fail, "Timeout waiting for BSSGP SUSPEND");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ }
+
+ /* Make sure we don't receive data for that TBF since it was released
+ * before. Also check our TBF is not polled for UL. */
+ f_pcuif_rx_data_req_pdtch(data_msg);
+ if (data_msg.dl_block == omit) {
+ /* IDLE block, expected on new PCU versions */
+ } else {
+ setverdict(fail, "Unexpected dl_block", data_msg.dl_block);
+ f_shutdown(__BFILE__, __LINE__);
}
+
+ /* New data arrives, PCU should page the MS since no TBF active exists: */
+ /* Send some more data, it will never reach the MS */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
}
-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);
+/* Test of correct Timing Advance at the time of TBF establishment
+ * (derived from timing offset of the Access Burst). */
+testcase TC_ta_rach_imm_ass() runs on RAW_PCU_Test_CT {
+ var GprsMS ms;
+
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+
+ /* We cannot send too many TBF requests in a short time because
+ * at some point the PCU will fail to allocate a new TBF. */
+ for (var TimingAdvance ta := 0; ta < 64; ta := ta + 16) {
+ /* Establish an Uplink TBF (send RACH.ind with current TA) */
+ ms.ta := ta;
+ f_ms_establish_ul_tbf(ms);
+
+ /* Make sure Timing Advance IE matches out expectations */
+ if (ms.ul_tbf.rr_imm_ass.payload.imm_ass.timing_advance != ta) {
+ setverdict(fail, "Timing Advance mismatch: ",
+ ms.ul_tbf.rr_imm_ass.payload.imm_ass.timing_advance,
+ " vs expected ", ta);
+ break;
+ }
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
}
-testcase TC_selftest_ns() runs on dummy_CT {
- const octetstring c_ns_reset_pcu := '000000c4271e813d'O;
+/* Verify Timing Advance value indicated in Packet Uplink ACK/NACK message
+ * sent in response to the first Uplink block after resource allocation. */
+testcase TC_ta_ul_ack_nack_first_block() runs on RAW_PCU_Test_CT {
+ var GprsMS ms := valueof(t_GprsMS_def);
+ var PacketUlAckNack ul_ack_nack;
+ var PacketTimingAdvance pkt_ta;
+ var RlcmacDlBlock dl_block;
+ var uint32_t sched_fn;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
- /* 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);
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
- f_ns_dec_and_log(c_ns_reset_pcu);
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ f_ms_wait_usf(ms);
+
+ /* In a busy network, there can be a significant delay between resource
+ * allocation (Packet Uplink Assignment above) and the actual time when
+ * the MS is allowed to transmit the first Uplink data block. */
+
+ /* Simulate a delay > 0 */
+ ms.ta := 2;
+
+ /* We're in One-Phase Access contention resolution, include TLLI */
+ f_ms_tx_ul_data_block_multi(ms, 1, with_tlli := true, fn := ms.ul_tbf.start_time_fn);
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn);
+
+ ul_ack_nack := dl_block.ctrl.payload.u.ul_ack_nack;
+ if (ispresent(ul_ack_nack.gprs.pkt_ta)) {
+ pkt_ta := ul_ack_nack.gprs.pkt_ta;
+ } else if (ispresent(ul_ack_nack.egprs.pkt_ta)) {
+ pkt_ta := ul_ack_nack.egprs.pkt_ta;
+ } else {
+ setverdict(fail, "PacketTimingAdvance IE is not present");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ if (not ispresent(pkt_ta.val)) {
+ setverdict(fail, "Timing Advance value is not present");
+ f_shutdown(__BFILE__, __LINE__);
+ } else if (pkt_ta.val != ms.ta) {
+ setverdict(fail, "Timing Advance mismatch: expected ",
+ ms.ta, ", but received ", pkt_ta.val);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
}
-const octetstring gmm_auth_req := '081200102198c72477ea104895e8b959acc58b108182'O;
+/* Verify Timing Advance value(s) indicated during the packet Downlink assignment
+ * procedure as per 3GPP TS 44.018, section 3.5.3. There seems to be a bug in the
+ * IUT that causes it to send an unreasonable Timing Advance value > 0 despite
+ * no active TBF exists at the moment of establishment (idle mode). */
+testcase TC_ta_idle_dl_tbf_ass() runs on RAW_PCU_Test_CT {
+ var GprsMS ms := valueof(t_GprsMS_def);
-/* 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;
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
- //log("GMM Tx: ", dec_PDU_L3_SGSN_MS(gmm_pdu));
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
- 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;
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* SGSN sends some DL data, PCU will initiate Packet Downlink
+ * Assignment on CCCH (PCH). We don't care about the payload. */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, f_rnd_octstring(10), imsi := ts_BSSGP_IMSI(ms.imsi)));
+ f_ms_exp_dl_tbf_ass_ccch(ms);
- log(ts_BSSGP_DL_UD(g_mmctx.tlli, enc_PDU_LLC(llc)));
+ /* Make sure that Timing Advance is 0 (the actual value is not known yet).
+ * As per 3GPP S 44.018, section 3.5.3.1.2, the network *shall* initiate
+ * the procedures defined in 3GPP TS 44.060 or use the polling mechanism. */
+ if (ms.dl_tbf.rr_imm_ass.payload.imm_ass.timing_advance != 0) {
+ setverdict(fail, "Timing Advance value doesn't match");
+ }
- BSSGP[0].send(ts_BSSGP_DL_UD(g_mmctx.tlli, enc_PDU_LLC(llc)));
+ f_shutdown(__BFILE__, __LINE__, final := true);
}
-/* Establish BSSGP connection to PCU */
-function f_bssgp_establish() runs on BSSGP_Client_CT {
- timer T:= 10.0;
+/* Verify that the PCU generates idle blocks in PTCCH/D
+ * while neither Uplink nor Downlink TBF is established. */
+testcase TC_ta_ptcch_idle() runs on RAW_PCU_Test_CT {
+ var BTS_PTCCH_Block pcu_msg;
+ timer T;
- T.start
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
+
+ /* Sent an RTS.req for PTCCH/D */
+ BTS.send(ts_PCUIF_RTS_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7,
+ sapi := PCU_IF_SAPI_PTCCH, fn := 0,
+ arfcn := 871, block_nr := 0));
+
+ T.start(5.0);
alt {
- [] BSSGP[0].receive(t_BssgpStsInd(?, ?, BVC_S_UNBLOCKED)) { }
- [] BSSGP[0].receive { repeat; }
+ [] BTS.receive(tr_PCUIF_DATA_PTCCH(0,
+ tr_PCUIF_DATA(0, 7, sapi := PCU_IF_SAPI_PTCCH),
+ omit)) {
+ }
+ [] as_rx_ptcch(pcu_msg, tr_PTCCHDownlinkMsg) {
+ setverdict(fail, "Expected IDLE block instead of PTCCH/D block");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ [] BTS.receive(PCUIF_Message:?) { repeat; }
[] T.timeout {
- setverdict(fail, "Timeout establishing BSSGP connection");
- mtc.stop;
+ setverdict(fail, "Timeout waiting for a PTCCH/D block");
+ f_shutdown(__BFILE__, __LINE__);
}
}
- T.stop
- log("BSSGP successfully initialized");
+ log("Decoded PTCCH/D message: ", pcu_msg.dl_block);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
}
-function f_wait_paging_req_type1(hexstring expected_tmsi) runs on dummy_CT {
- var LAPDm_ph_data ph_data;
- timer T := 5.0;
+/* Test of correct Timing Advance during an active Uplink TBF.
+ *
+ * Unlike the circuit-switched domain, Uplink transmissions on PDCH time-slots
+ * are not continuous and there can be long time gaps between them. This happens
+ * due to a bursty nature of packet data. The actual Timing Advance of a MS may
+ * significantly change between such rare Uplink transmissions, so GPRS introduces
+ * additional mechanisms to control Timing Advance, and thus reduce interference
+ * between neighboring TDMA time-slots.
+ *
+ * At the moment of Uplink TBF establishment, initial Timing Advance is measured
+ * from ToA (Timing of Arrival) of an Access Burst. This is covered by another
+ * test case - TC_ta_rach_imm_ass. In response to that Access Burst the network
+ * sends Immediate Assignment on AGCH, which _may_ contain Timing Advance Index
+ * among with the initial Timing Advance value. And here PTCCH comes to play.
+ *
+ * PTCCH is a unidirectional channel on which the network can instruct a sub-set
+ * of 16 MS (whether TBFs are active or not) to adjust their Timing Advance
+ * continuously. To ensure continuous measurements of the signal propagation
+ * delay, the MSs shall transmit Access Bursts on Uplink (PTCCH/U) on sub-slots
+ * defined by an assigned Timing Advance Index (see 3GPP TS 45.002).
+ *
+ * The purpose of this test case is to verify the assignment of Timing Advance
+ * Index, and the process of Timing Advance notification on PTCCH/D. The MTC
+ * first establishes several Uplink TBFs, but does not transmit any Uplink
+ * blocks on them. During 4 TDMA multi-frame periods the MTC is sending RACH
+ * indications to the PCU, checking the correctness of two received PTCCH/D
+ * messages (period of PTCCH/D is two multi-frames).
+ */
- T.start;
+/* List of ToA values for Access Bursts to be sent on PTCCH/U,
+ * each ToA (Timing of Arrival) value is in units of 1/4 of
+ * a symbol (i.e. 1 symbol is 4 QTA units). */
+type record length(16) of int16_t PTCCH_TAI_ToA_MAP;
+const PTCCH_TAI_ToA_MAP ptcch_toa_map_def := {
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0
+};
+
+private altstep as_ta_ptcch(uint8_t bts_nr := 0, uint8_t trx_nr := 0, uint8_t ts_nr := 7,
+ in PTCCH_TAI_ToA_MAP toa_map := ptcch_toa_map_def)
+runs on RAW_PCU_Test_CT {
+ var RAW_PCU_Event event;
+ var integer ss;
+
+ /* Send Access Bursts on PTCCH/U for every TA Index */
+ [] BTS.receive(tr_RAW_PCU_EV(TDMA_EV_PTCCH_UL_BURST)) -> value event {
+ ss := f_tdma_ptcch_fn2ss(event.data.tdma_fn);
+ if (ss < 0) { /* Shall not happen */
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ log("Sending an Access Burst on PTCCH/U",
+ ", sub-slot=", ss, " (TAI)",
+ ", fn=", event.data.tdma_fn,
+ ", ToA=", toa_map[ss], " (QTA)");
+ /* TODO: do we care about RA and burst format? */
+ BTS.send(ts_PCUIF_RACH_IND(bts_nr, trx_nr, ts_nr,
+ ra := oct2int('3A'O),
+ is_11bit := 0,
+ burst_type := BURST_TYPE_0,
+ fn := event.data.tdma_fn,
+ arfcn := 871,
+ qta := toa_map[ss],
+ sapi := PCU_IF_SAPI_PTCCH));
+ repeat;
+ }
+}
+
+private function f_TC_ta_ptcch_ul_multi_tbf(in PTCCH_TAI_ToA_MAP ptcch_toa_map,
+ template PTCCHDownlinkMsg t_ta_msg)
+runs on RAW_PCU_Test_CT {
+ var PTCCHDownlinkMsg ta_msg;
+ var PCUIF_Message pcu_msg;
+ timer T;
+
+ /* First, send an RTS.req for the upcoming PTCCH/D block */
+ BTS.send(ts_PCUIF_RTS_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7,
+ sapi := PCU_IF_SAPI_PTCCH, fn := 0,
+ arfcn := 871, block_nr := 0));
+ T.start(2.0);
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;
+ /* Keep sending of Access Bursts during two multi-frames (period of PTCCH/D)
+ * with increasing ToA (Timing of Arrival) values: 0, 7, 14, 28, 35... */
+ [] as_ta_ptcch(bts_nr := 0, trx_nr := 0, ts_nr := 7, toa_map := ptcch_toa_map);
+ /* In the end of 2nd multi-frame we should receive a PTCCH/D block */
+ [] BTS.receive(tr_PCUIF_DATA_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7,
+ sapi := PCU_IF_SAPI_PTCCH)) -> value pcu_msg {
+ ta_msg := dec_PTCCHDownlinkMsg(pcu_msg.u.data_req.data);
+ log("Rx PTCCH/D message: ", ta_msg);
- if (dec_PDU_ML3_NW_MS_backtrack(payload, pdu) != 0) {
- repeat;
+ /* Make sure Timing Advance values match our expectations */
+ if (not match(ta_msg, t_ta_msg)) {
+ setverdict(fail, "PTCCH/D message does not match: ", t_ta_msg);
}
+ }
+ [] BTS.receive { repeat; }
+ [] T.timeout {
+ setverdict(fail, "Timeout waiting for a PTCCH/D block");
+ }
+ }
+}
- if (not ischosen(pdu.msgs.rrm)) {
- repeat;
+testcase TC_ta_ptcch_ul_multi_tbf() runs on RAW_PCU_Test_CT {
+ var template PacketUlAssign t_ul_tbf_ass;
+ var GprsMS ms;
+
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
+
+ /* Enable forwarding of PTCCH/U TDMA events to us */
+ BTS.send(ts_RAW_PCU_CMD(TDMA_CMD_ENABLE_PTCCH_UL_FWD));
+
+ /* Establish 7 Uplink TBFs (USF flag is 3 bits long, '111'B is reserved) */
+ for (var integer i := 0; i < 7; i := i + 1) {
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ /* We expect incremental TFI/USF assignment (dynamic allocation) */
+ t_ul_tbf_ass := tr_PacketUlDynAssign(tfi := i, usf := i);
+ if (not match(ms.ul_tbf.ass.ccch, t_ul_tbf_ass)) {
+ setverdict(fail, "Failed to match Packet Uplink Assignment for #", i);
+ break;
}
- if (match(pdu, tr_PAGING_REQ1(tr_PAGING_REQ1_MI1_TMSI(hex2oct(expected_tmsi))))) {
- setverdict(pass);
+ /* We also expect Timing Advance Index to be a part of the assignment */
+ if (ms.ul_tbf.ass.ccch.dynamic.ta_index != i) {
+ setverdict(fail, "Failed to match Timing Advance Index for #", i);
+ /* Keep going, the current OsmoPCU does not assign TA Index */
+ }
+ }
+
+ /* Prepare a list of ToA values for Access Bursts to be sent on PTCCH/U */
+ var PTCCH_TAI_ToA_MAP toa_map := ptcch_toa_map_def;
+ for (var integer i := 0; i < 7; i := i + 1) {
+ /* ToA in units of 1/4 of a symbol */
+ toa_map[i] := (i + 1) * 7 * 4;
+ }
+
+ /* Now we have all 7 TBFs established in one-phase access mode,
+ * however we will not be sending any data on them. Instead, we
+ * will be sending RACH.ind on PTCCH/U during 4 multi-frame
+ * periods (TAI 0..8), and then will check two PTCCH/D blocks.
+ *
+ * Why not 4 TBFs at once? Because Uplink is delayed by 3 TDMA
+ * time-slots, so at the moment of scheduling a PTCCH/D block
+ * the PCU has odd number of PTCCH/U Access Bursts received. */
+ f_TC_ta_ptcch_ul_multi_tbf(toa_map, tr_PTCCHDownlinkMsg(
+ tai0_ta := 7, tai1_ta := 14, tai2_ta := 21,
+ /* Other values are not known (yet) */
+ tai3_ta := ?));
+ f_TC_ta_ptcch_ul_multi_tbf(toa_map, tr_PTCCHDownlinkMsg(
+ tai0_ta := 7, tai1_ta := 14, tai2_ta := 21,
+ tai3_ta := 28, tai4_ta := 35, tai5_ta := 42,
+ /* Other values are out of our interest */
+ tai6_ta := ?));
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Default link quality adaptation (Coding Scheme) ranges (inclusive).
+ * OsmoPCU (VTY): cs link-quality-ranges cs1 6 cs2 5 8 cs3 7 13 cs4 12
+ *
+ * NOTE: the ranges are intentionally overlapping because OsmoPCU
+ * does not change CS/MCS on the range borders (5-6, 7-8, 12-13). */
+private template integer CS1_lqual_dB_range := (-infinity .. 6);
+private template integer CS2_lqual_dB_range := (5 .. 8);
+private template integer CS3_lqual_dB_range := (7 .. 13);
+private template integer CS4_lqual_dB_range := (12 .. infinity);
+
+testcase TC_cs_lqual_ul_tbf() runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var GprsMS ms;
+ var uint32_t unused_fn, sched_fn;
+ var uint4_t cv;
+
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+
+ f_pcuvty_set_allowed_cs_mcs();
+ f_pcuvty_set_link_quality_ranges();
+
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ f_ms_wait_usf(ms);
+
+ /* The actual / old link quality values. We need to keep track of the old
+ * (basically previous) link quality value, because OsmoPCU actually
+ * changes the coding scheme if not only the actual, but also the old
+ * value leaves the current link quality range (window). */
+ var integer lqual_old;
+ ms.lqual_cb := 0;
+
+ /* Send one UL block (with TLLI since we are in One-Phase Access
+ contention resolution) and make sure it is ACKED fine. */
+ /* 16 bytes fills the llc block (because TLLI takes 4 bytes) */
+ /* Set CV = 15 to signal there's still more than BS_CV_MAX blocks to be sent */
+ f_ms_tx_ul_data_block(ms, f_rnd_octstring(16), cv := 15, with_tlli := true, fn := ms.ul_tbf.start_time_fn)
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn);
+ /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+
+ /* 16 UL blocks (0 .. 15 dB, step = 1 cB) */
+ for (var integer i := 150; i >= 0; i := i - 1) {
+ /* Update the old / actual link quality */
+ lqual_old := ms.lqual_cb;
+ ms.lqual_cb := 150 - i;
+
+ /* Enqueue DATA.ind (both TDMA frame and block numbers to be patched) */
+ log("Sending DATA.ind with link quality (dB): ", ms.lqual_cb);
+ if (i > g_bs_cv_max) {
+ cv := 15;
} else {
- repeat;
+ cv := i;
+ }
+
+ f_ms_tx_ul_data_block(ms, f_rnd_octstring(10), cv := cv)
+
+ /* we will receive UL ACK/NACK from time to time. In that case, check CdCofing increases */
+ f_rx_rlcmac_dl_block(dl_block, unused_fn);
+ if (match(dl_block, tr_RLCMAC_DL_DUMMY_CTRL())) {
+ continue;
+ }
+ if (not match(dl_block, tr_RLCMAC_UL_ACK_NACK_GPRS(ul_tfi := ?)) and
+ not match(dl_block, tr_RLCMAC_UL_ACK_NACK_EGPRS(ul_tfi := ?))) {
+ setverdict(fail, "Failed to match Packet Uplink ACK / NACK:", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ log("Rx Packet Uplink ACK / NACK with Channel Coding Command: ",
+ dl_block.ctrl.payload.u.ul_ack_nack.gprs.ch_coding_cmd);
+
+ /* Match the received Channel Coding Command. Since we are increasing
+ * the link quality value on each iteration and not decreasing, there
+ * is no need to check the both old and current link quality values. */
+ var template ChCodingCommand ch_coding;
+ select (lqual_old / 10) {
+ case (CS1_lqual_dB_range) { ch_coding := CH_CODING_CS1; }
+ case (CS2_lqual_dB_range) { ch_coding := CH_CODING_CS2; }
+ case (CS3_lqual_dB_range) { ch_coding := CH_CODING_CS3; }
+ case (CS4_lqual_dB_range) { ch_coding := CH_CODING_CS4; }
+ }
+
+ if (not match(dl_block.ctrl.payload.u.ul_ack_nack.gprs.ch_coding_cmd, ch_coding)) {
+ setverdict(fail, "Channel Coding does not match our expectations: ", ch_coding);
+ f_shutdown(__BFILE__, __LINE__);
}
}
- [] L1.receive { repeat; }
- [] T.timeout { setverdict(fail); }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Test the max UL CS set by VTY works fine */
+testcase TC_cs_initial_ul() runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var ChCodingCommand last_ch_coding;
+ var uint32_t unused_fn, sched_fn;
+ var GprsMS ms;
+
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+
+ /* Set initial UL CS to 3 */
+ g_cs_initial_ul := 3;
+ f_pcuvty_set_allowed_cs_mcs();
+ f_pcuvty_set_link_quality_ranges();
+
+ /* Take lqual (dB->cB) so that we stay in that CS */
+ ms.lqual_cb := g_cs_lqual_ranges[2].low * 10;
+
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ f_ms_wait_usf(ms);
+
+ /* Send one UL block (with TLLI since we are in One-Phase Access
+ contention resolution) and make sure it is ACKED fine. */
+ /* 16 bytes fills the llc block (because TLLI takes 4 bytes) */
+ /* Set CV = 15 to signal there's still more than BS_CV_MAX blocks to be sent */
+ f_ms_tx_ul_data_block(ms, f_rnd_octstring(16), cv := 15, with_tlli := true, fn := ms.ul_tbf.start_time_fn)
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn);
+ /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+
+ /* Send UL blocks, until we receive UL ACK/NACK and check we are in same initial CS: */
+ while (true) {
+ f_ms_tx_ul_data_block(ms, f_rnd_octstring(10), cv := 15);
+ f_rx_rlcmac_dl_block(dl_block, unused_fn);
+ if (match(dl_block, tr_RLCMAC_DL_DUMMY_CTRL())) {
+ continue;
+ }
+
+ if (not match(dl_block, tr_RLCMAC_UL_ACK_NACK_GPRS(ul_tfi := ?)) and
+ not match(dl_block, tr_RLCMAC_UL_ACK_NACK_EGPRS(ul_tfi := ?))) {
+ setverdict(fail, "Failed to match Packet Uplink ACK / NACK:", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ break;
+ }
+
+ last_ch_coding := dl_block.ctrl.payload.u.ul_ack_nack.gprs.ch_coding_cmd;
+ break;
}
+ if (last_ch_coding != CH_CODING_CS3) {
+ setverdict(fail, "Channel Coding does not match our expectations (CS-3): ", last_ch_coding);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ /* Remaining UL blocks are used to make sure regardless of initial
+ /* lqual, we can go lower at any time */
+ /* 0 dB, make sure we downgrade CS */
+ ms.lqual_cb := 0;
+ /* 5 UL blocks, check we are in same initial CS: */
+ f_ms_tx_ul_data_block_multi(ms, 5);
+ /* Enqueue RTS.req, expect DATA.req with UL ACK from the PCU */
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, unused_fn);
+ last_ch_coding := dl_block.ctrl.payload.u.ul_ack_nack.gprs.ch_coding_cmd;
+
+ if (last_ch_coding != CH_CODING_CS1) {
+ setverdict(fail, "Channel Coding does not match our expectations (CS-1): ", last_ch_coding);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
}
-/* 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);
+/* Test the max UL CS set by VTY works fine */
+testcase TC_cs_max_ul() runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var ChCodingCommand last_ch_coding;
+ var uint32_t unused_fn, sched_fn;
+ var GprsMS ms;
- g_mmctx.imsi := '262420123456789'H;
- g_mmctx.tlli := f_random_tlli();
- f_init();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
- var BCCH_tune_req tune_req := { { false, 871 }, true };
- L1.send(tune_req);
- /* FIXME: wait for confirm */
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
- /* 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(hex2oct(g_mmctx.imsi));
- */
+ /* Set maximum allowed UL CS to 3 */
+ g_cs_max_ul := 3;
+ f_pcuvty_set_allowed_cs_mcs();
+ f_pcuvty_set_link_quality_ranges();
- /* Page by TMSI */
- BSSGP_SIG[0].send(ts_BSSGP_PS_PAGING_PTMSI(0, g_mmctx.imsi, tmsi));
- f_wait_paging_req_type1(tmsi_hex);
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ f_ms_wait_usf(ms);
+
+ /* Send one UL block (with TLLI since we are in One-Phase Access
+ contention resolution) and make sure it is ACKED fine. */
+ /* 16 bytes fills the llc block (because TLLI takes 4 bytes) */
+ /* Set CV = 15 to signal there's still more than BS_CV_MAX blocks to be sent */
+ f_ms_tx_ul_data_block(ms, f_rnd_octstring(16), cv := 15, with_tlli := true, fn := ms.ul_tbf.start_time_fn)
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn);
+ /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+
+ ms.lqual_cb := 40*10; /* 40 dB */
+ f_ms_tx_ul_data_block_multi(ms, 16);
+
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, unused_fn);
+ last_ch_coding := dl_block.ctrl.payload.u.ul_ack_nack.gprs.ch_coding_cmd;
+
+ if (last_ch_coding != CH_CODING_CS3) {
+ setverdict(fail, "Channel Coding does not match our expectations (CS-3): ", last_ch_coding);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
}
-/* 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 */
+/* Test the initial DL CS set by VTY works fine */
+testcase TC_cs_initial_dl() runs on RAW_PCU_Test_CT {
+ var octetstring data := f_rnd_octstring(10);
+ var CodingScheme exp_dl_cs_mcs;
+ var RlcmacDlBlock dl_block;
+ var uint32_t poll_fn;
+ var GprsMS ms;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+
+ /* Set initial allowed DL CS to 3 */
+ g_cs_initial_dl := 3;
+ exp_dl_cs_mcs := CS_3;
+ /* Set maximum allowed UL CS to 4 */
+ g_cs_max_dl := 4;
+ f_pcuvty_set_allowed_cs_mcs();
+ f_pcuvty_set_link_quality_ranges();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* SGSN sends some DL data, PCU will page on CCCH (PCH) */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
+ f_sleep(X2002);
+ f_rx_rlcmac_dl_block_exp_data(dl_block, poll_fn, data, 0, exp_dl_cs_mcs);
+
+ /* ACK the DL block */
+ f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block, '1'B);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc),
+ f_dl_block_ack_fn(dl_block, poll_fn));
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Verify scheduling of multiple Downlink data blocks, enough to reach CS4 */
+function f_dl_data_exp_cs(template (present) CodingScheme exp_final_cs := ?, template (omit) MSRadioAccessCapabilityV_BSSGP ms_racap := omit) runs on RAW_PCU_Test_CT {
+ var octetstring data := f_rnd_octstring(1400);
+ var RlcmacDlBlock prev_dl_block, dl_block;
+ var uint32_t ack_fn;
+ var uint32_t fn;
+ var GprsMS ms;
+ var integer tx_data_remain := 10;
+ var integer bsn := 0;
+ var boolean using_egprs := f_rlcmac_cs_mcs_is_mcs(valueof(exp_final_cs));
+ var integer bsn_mod;
+ var template (present) CodingScheme exp_tmp_csmcs;
+
+ if (using_egprs) {
+ exp_tmp_csmcs := mcs_egprs_any;
+ bsn_mod := 2048;
+ } else {
+ exp_tmp_csmcs := cs_gprs_any;
+ bsn_mod := 128;
+ }
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+
+ ms := g_ms[0]; /* We only use first MS in this test */
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* SGSN sends some DL data, PCU will page on CCCH (PCH) */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, ms_racap, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS */
+ f_sleep(X2002);
+
+ /* Skip potential dummy blocks before X2002 triggers at PCU after us: */
+ fn := f_rx_rlcmac_dl_block_skip_dummy(dl_block, max_dummy := 10);
+
+ for (var integer i := 0; i < 800; i := i + 1) {
+ bsn := i mod bsn_mod;
+
+ if (match(dl_block, tr_RLCMAC_DL_DUMMY_CTRL)) {
+ /* No more data to receive, done */
+ break;
+ }
+
+ f_rlcmac_dl_block_exp_data(dl_block, ?, bsn, exp_tmp_csmcs);
+
+ /* Keep Ack/Nack description updated */
+ f_dltbf_ack_block(ms.dl_tbf, dl_block);
+
+ /* TDMA frame number on which we are supposed to send the ACK */
+ if (f_dl_block_rrbp_valid(dl_block)) {
+ ack_fn := f_dl_block_ack_fn(dl_block, fn);
+ f_ms_tx_ul_block(ms, f_dltbf_ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf, using_egprs), ack_fn);
+ if (tx_data_remain != 0) {
+ /* Submit more data from time to time to keep the TBF ongoing */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data));
+ tx_data_remain := tx_data_remain - 1;
+ }
+ }
+ prev_dl_block := dl_block;
+ f_rx_rlcmac_dl_block(dl_block, fn);
+ }
+
+ bsn := (bsn + (bsn_mod-1)) mod bsn_mod; /* previous bsn: bsn -1 */
+ f_rlcmac_dl_block_exp_data(prev_dl_block, ?, bsn, exp_final_cs);
+
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Verify DL CS above "cs max" set by VTY is never used */
+testcase TC_cs_max_dl() runs on RAW_PCU_Test_CT {
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+
+ /* Set maximum allowed DL CS to 3 */
+ g_cs_initial_dl := 1;
+ g_cs_max_dl := 3;
+ f_pcuvty_set_allowed_cs_mcs();
+ f_pcuvty_set_link_quality_ranges();
+
+ f_dl_data_exp_cs(f_rlcmac_block_int2cs_mcs(g_cs_max_dl, false));
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Check DL CS4 is used in good link conditions if allowed by config */
+testcase TC_dl_cs1_to_cs4() runs on RAW_PCU_Test_CT {
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+
+ /* Set initial DL CS to 1 & maximum allowed DL CS to 4 */
+ g_cs_initial_dl := 1;
+ g_cs_max_dl := 4;
+ f_pcuvty_set_allowed_cs_mcs();
+ f_pcuvty_set_link_quality_ranges();
+
+ f_dl_data_exp_cs(f_rlcmac_block_int2cs_mcs(g_cs_max_dl, false));
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Test the initial UL MCS set by VTY works fine */
+testcase TC_mcs_initial_ul() runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var PollFnCtx pollctx;
+ var EgprsChCodingCommand last_ch_coding;
+ var uint32_t unused_fn, sched_fn;
+ var GprsMS ms;
+ var CodingScheme exp_ul_mcs;
+
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
+
+ /* Set initial UL MCS to 3 */
+ g_mcs_initial_ul := 3;
+ exp_ul_mcs := f_rlcmac_block_int2cs_mcs(g_mcs_initial_ul, true);
+ f_pcuvty_set_allowed_cs_mcs();
+ f_pcuvty_set_link_quality_ranges();
+
+ /* Take lqual (dB->cB) so that we stay in that MCS */
+ ms.lqual_cb := g_mcs_lqual_ranges[2].low * 10;
+
+ /* Send PACKET RESOURCE REQUEST to upgrade to EGPRS */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap_egprs_def));
+
+ if (not match(ms.ul_tbf.tx_cs_mcs, exp_ul_mcs)) {
+ setverdict(fail, "Wrong CS_MCS ", ms.ul_tbf.tx_cs_mcs, " received vs exp ", exp_ul_mcs);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ /* Send UL blocks, until we receive UL ACK/NACK and check we are in same initial CS: */
+ while (true) {
+ f_ms_tx_ul_data_block(ms, f_rnd_octstring(10), cv := 15);
+ f_rx_rlcmac_dl_block(dl_block, unused_fn);
+ if (match(dl_block, tr_RLCMAC_DL_DUMMY_CTRL())) {
+ continue;
+ }
+
+ if (not match(dl_block, tr_RLCMAC_UL_ACK_NACK_EGPRS(ul_tfi := ?))) {
+ setverdict(fail, "Failed to match Packet Uplink ACK / NACK:", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ break;
+ }
+
+ last_ch_coding := dl_block.ctrl.payload.u.ul_ack_nack.egprs.ch_coding_cmd;
+ break;
+ }
+ if (f_rlcmac_block_EgprsChCodingCommand2cs_mcs(last_ch_coding) != exp_ul_mcs) {
+ setverdict(fail, "Channel Coding does not match our expectations ", exp_ul_mcs, ": ", last_ch_coding);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ /* Remaining UL blocks are used to make sure regardless of initial
+ * lqual, we can go lower at any time
+ * 0 dB, make sure we downgrade MCS */
+ ms.lqual_cb := 0;
+ /* 5 UL blocks, check we are in same initial MCS: */
+ f_ms_tx_ul_data_block_multi(ms, 5);
+ /* Enqueue RTS.req, expect DATA.req with UL ACK from the PCU */
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, unused_fn);
+ last_ch_coding := dl_block.ctrl.payload.u.ul_ack_nack.egprs.ch_coding_cmd;
+
+ if (last_ch_coding != CH_CODING_MCS1) {
+ setverdict(fail, "Channel Coding does not match our expectations (MCS-1): ", last_ch_coding);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Test the maximum UL MCS set by VTY works fine */
+testcase TC_mcs_max_ul() runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var EgprsChCodingCommand last_ch_coding;
+ var PollFnCtx pollctx;
+ var uint32_t unused_fn, sched_fn;
+ var GprsMS ms;
+
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
+
+ /* Set maximum allowed UL MCS to 5 */
+ g_mcs_max_ul := 5;
+ f_pcuvty_set_allowed_cs_mcs();
+ f_pcuvty_set_link_quality_ranges();
+
+ /* Send PACKET RESOURCE REQUEST to upgrade to EGPRS */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap_egprs_def));
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ ms.lqual_cb := 40*10; /* 40 dB */
+ f_ms_tx_ul_data_block_multi(ms, 16);
+
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, unused_fn);
+ last_ch_coding := dl_block.ctrl.payload.u.ul_ack_nack.egprs.ch_coding_cmd;
+
+ if (last_ch_coding != CH_CODING_MCS5) {
+ setverdict(fail, "Channel Coding does not match our expectations (MCS-5): ", last_ch_coding);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Test the initial DL CS set by VTY works fine */
+testcase TC_mcs_initial_dl() runs on RAW_PCU_Test_CT {
+ var octetstring data := f_rnd_octstring(10);
+ var CodingScheme exp_dl_cs_mcs;
+ var RlcmacDlBlock dl_block;
+ var uint32_t poll_fn;
+ var GprsMS ms;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
+
+ /* Set initial allowed DL MCS to 3 */
+ g_mcs_initial_dl := 3;
+ exp_dl_cs_mcs := MCS_3;
+ /* Set maximum allowed DL MCS to 4 */
+ g_mcs_max_dl := 4;
+ f_pcuvty_set_allowed_cs_mcs();
+ f_pcuvty_set_link_quality_ranges();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* SGSN sends some DL data, PCU will page on CCCH (PCH) */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, bssgp_ms_racap_egprs_def, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
+ f_sleep(X2002);
+ f_rx_rlcmac_dl_block_exp_data(dl_block, poll_fn, data, 0, exp_dl_cs_mcs);
+
+ /* ACK the DL block */
+ f_dltbf_ack_block(ms.dl_tbf, dl_block, '1'B);
+ f_ms_tx_ul_block(ms, f_dltbf_ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf, ischosen(dl_block.data_egprs)),
+ f_dl_block_ack_fn(dl_block, poll_fn));
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Verify DL MCS above "mcs max" set by VTY is never used */
+testcase TC_mcs_max_dl() runs on RAW_PCU_Test_CT {
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
+
+ /* Set maximum allowed DL CS to 3 */
+ g_mcs_initial_dl := 1;
+ g_mcs_max_dl := 3;
+ f_pcuvty_set_allowed_cs_mcs();
+ f_pcuvty_set_link_quality_ranges();
+
+ f_dl_data_exp_cs(f_rlcmac_block_int2cs_mcs(g_mcs_max_dl, true), bssgp_ms_racap_egprs_def);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Verify PCU drops TBF after some time of inactivity. */
+testcase TC_t3141() runs on RAW_PCU_Test_CT {
+ var PCUIF_info_ind info_ind;
+ var template (value) TsTrxBtsNum nr;
+ var BTS_PDTCH_Block data_msg;
+ var GprsMS ms;
+ var uint3_t rx_usf;
+ timer T_3141 := 1.0;
+ var boolean ul_tbf_usf_req := false;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ info_ind := valueof(ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+ /* Only use 1 PDCH to simplify test: */
+ f_PCUIF_PDCHMask_set(info_ind, '00000001'B, 0);
+ f_PCUIF_PDCHMask_set(info_ind, '00000000'B, (1 .. 7));
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ f_vty_config2(PCUVTY, {"pcu"}, "timer T3141 1");
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Establish a one-phase access Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ T_3141.start;
+
+ /* Now we wait for PCU to transmit our USF */
+ nr := ts_TsTrxBtsNum;
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
- 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;
+ [] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ ?)) -> value data_msg {
+ if (ms.ul_tbf.usf[valueof(nr.ts_nr)] == USF_UNUSED) {
+ setverdict(fail, "Unexpected ts_nr ", valueof(nr.ts_nr), " without USF allocated");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ rx_usf := f_rlcmac_dl_block_get_usf(data_msg.dl_block);
+ if (rx_usf == ms.ul_tbf.usf[valueof(nr.ts_nr)]) {
+ /* PCU requests our USF, transmit WITHOUT tlli to avoid contention resolution success */
+ ul_tbf_usf_req := true;
+ f_ms_tx_ul_data_block(ms, f_rnd_octstring(10), cv := 15, with_tlli := false, fn := f_next_pdch_block(data_msg.raw.fn))
+ } else if (rx_usf == USF_UNUSED) {
+ if (data_msg.raw.fn >= ms.ul_tbf.start_time_fn) {
+ if (ul_tbf_usf_req) {
+ /* TBF was dropped by T3141, success */
+ setverdict(pass);
+ break;
+ } else {
+ log("PCU never requested USF, unexpected");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ } /* else: Keep waiting for TBF to be active by network */
+ } else {
+ log("PCU requests ", rx_usf, ", we have ", ms.ul_tbf.usf[valueof(nr.ts_nr)]);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ /* Make sure we don't receive a Ul ACK/NACK with TLLI set: */
+ if (match(data_msg.dl_block,
+ tr_RLCMAC_UL_ACK_NACK_GPRS(ms.ul_tbf.tfi,
+ tr_UlAckNackGprs(tlli := ?,
+ acknack_desc := ?,
+ rel99 := *))))
+ {
+ log("Received UL ACK/NACK with TLLI set");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ nr := ts_TsTrxBtsNum;
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+ repeat;
+ }
+ [ul_tbf_usf_req] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ omit)) {
+ /* TBF was dropped by T3141, and PCU answered with an IDLE block to
+ our last RTS.req because there's no longer any MS listening on
+ the TS. */
+ setverdict(pass);
+ break;
+ }
+ [] T_3141.timeout {
+ log("T_3141 expired but TBF is still active, unexpected");
+ f_shutdown(__BFILE__, __LINE__);
}
+ [] BTS.receive {
+ /* We should never receive non-dummy messages, aka UL ACK/NACK,
+ * because we never sent the TLLI to the PCU */
+ setverdict(fail, "Unexpected BTS message");
+ f_shutdown(__BFILE__, __LINE__);
+ }
}
- T.stop;
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
}
-/* 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;
+/* Validate what happens when RACH to get UL TBF and then PCU receives no UL
+ * data. It should end up in N3101 reaching N3101_MAX and finally triggering
+ * T3169. See OS#5033 */
+testcase TC_n3101_max_t3169() runs on RAW_PCU_Test_CT {
+ var PCUIF_info_ind info_ind;
+ var template (value) TsTrxBtsNum nr;
+ var BTS_PDTCH_Block data_msg;
+ var GprsMS ms;
+ var uint3_t rx_usf;
+ const integer N3101_MAX := 9; /* N3101 shall be greater than 8 */
+ var integer n3101 := 0;
+ timer T_3169 := 1.0;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ info_ind := valueof(ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+ info_ind.n3101 := N3101_MAX;
+ info_ind.t3169 := 1;
+ f_init_raw(testcasename(), info_ind);
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Establish UL TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Now we wait for PCU to transmit our USF */
+ nr := ts_TsTrxBtsNum;
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+
+ alt {
+ [] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ ?)) -> value data_msg {
+ if (ms.ul_tbf.usf[valueof(nr.ts_nr)] == USF_UNUSED) {
+ setverdict(fail, "Unexpected ts_nr ", valueof(nr.ts_nr), " without USF allocated");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ rx_usf := f_rlcmac_dl_block_get_usf(data_msg.dl_block);
+ if (rx_usf == ms.ul_tbf.usf[valueof(nr.ts_nr)]) {
+ log("PCU requests our USF ", rx_usf, ", n3101=", n3101);
+ n3101 := n3101 + 1;
+ if (n3101 > N3101_MAX + 1) { //+1: DL<->UL FN offset
+ setverdict(fail, "Reached ", n3101, " > ", N3101_MAX + 1, " (N3101_MAX+1) and PCU still sends us USFs");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ } else if (rx_usf == USF_UNUSED and n3101 == N3101_MAX + 1) {
+ /* If we already received USFs for us and we don't receive them anymore, that means the TBF entered T3169 */
+ log("PCU stopped requesting USF ", ms.ul_tbf.usf[valueof(nr.ts_nr)]);
+ if (not T_3169.running) {
+ log("T3169 started");
+ T_3169.start;
+ }
+ } else if(rx_usf == USF_UNUSED and n3101 > 0) {
+ setverdict(fail, "PCU stopped requesting USFs too early: ", n3101, " < ", N3101_MAX, " (N3101_MAX)");
+ f_shutdown(__BFILE__, __LINE__);
+ } else {
+ log("PCU requests ", rx_usf, ", we have ", ms.ul_tbf.usf[valueof(nr.ts_nr)]);
+ }
+ nr := ts_TsTrxBtsNum;
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+ repeat;
+ }
+ /* We may already receive empty (idle) blocks before our own TTCN3 timer
+ * triggers due to the TBF being released. Keep going until our T_3169 triggers. */
+ [n3101 == N3101_MAX + 1] as_pcuif_rx_ignore_empty(nr);
+ [] T_3169.timeout {
+ log("T_3169 expired");
+ /* Done in alt */
+ }
+ [] BTS.receive {
+ setverdict(fail, "Unexpected BTS message");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ }
+
+ /* Now that T3169 has expired, establishing a Ul TBF should provide same
+ /* USFs as per previous TBF since they were freed at expiration time: */
+ var uint3_t old_usf[8] := ms.ul_tbf.usf;
+ var uint5_t old_tfi := ms.ul_tbf.tfi;
+ f_ms_establish_ul_tbf(ms);
+ if (old_tfi != ms.ul_tbf.tfi) {
+ setverdict(fail, "Unexpected TFI change: ", ms.ul_tbf.tfi, " vs exp ", old_tfi);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ for (var integer i := 0; i < 8; i := i +1) {
+ if (ms.ul_tbf.usf[i] != old_usf[i]) {
+ setverdict(fail, "Unexpected USF change: ", ms.ul_tbf.usf[i], " vs exp ", old_usf[i]);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
}
-/* 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;
+
+/* Verify after N3103_MAX is reached, T3169 is started and upon timeout TBF is
+ freed and no longer available. Trigger it by sending a few UL blocks CTRL ACKING
+ the final UL ACK sent at us. */
+testcase TC_n3103_max_t3169() runs on RAW_PCU_Test_CT {
+ var PCUIF_info_ind info_ind;
+ var BTS_PDTCH_Block data_msg;
+ var RlcmacDlBlock dl_block;
+ var uint32_t sched_fn;
+ var template (value) TsTrxBtsNum nr;
+ var template RlcmacDlBlock exp_ul_ack;
+ var template UlAckNackGprs exp_ul_ack_sub;
+ var GprsMS ms;
+ const integer N3103_MAX := 2; /* N3103 is usually somewhere 2-5 */
+ var integer N3103 := 0;
+ timer T_3169 := 1.0;
+
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ info_ind := valueof(ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+ info_ind.n3103 := N3103_MAX;
+ info_ind.t3169 := 1;
+ f_init_raw(testcasename(), info_ind);
+
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ f_ms_wait_usf(ms);
+
+ f_ms_tx_ul_data_block_multi(ms, 5, with_tlli := true);
+ exp_ul_ack_sub := tr_UlAckNackGprs(*, tr_AckNackDescription('1'B), *);
+ exp_ul_ack := tr_RLCMAC_UL_ACK_NACK_GPRS(ms.ul_tbf.tfi, exp_ul_ack_sub);
+
+ nr := ts_TsTrxBtsNum;
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+ alt {
+ [N3103 < N3103_MAX] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ exp_ul_ack)) -> value data_msg {
+ if (not f_dl_block_rrbp_valid(data_msg.dl_block)) {
+ setverdict(fail, "Unexpected DL BLOCK has no RRBP: ", data_msg.dl_block);
+ f_shutdown(__BFILE__, __LINE__);
}
- case (RRBP_Nplus17_or_18_mod_2715648) {
- add := 17; /* FIXME: What about 'or 18'? */
+
+ nr := ts_TsTrxBtsNum;
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+ N3103 := N3103 + 1;
+ if (N3103 == N3103_MAX) {
+ /* At this point in time (N3103_MAX reached), PCU is
+ * moving the TBF to RELEASE state so no data/ctrl for
+ * it is tx'ed, hence the dummy blocks: */
+ T_3169.start;
}
- case (RRBP_Nplus21_or_22_mod_2715648) {
- add := 21; /* FIXME: What about 'or 22'? */
+ repeat;
+ }
+ [N3103 >= N3103_MAX] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ exp_ul_ack)) -> value data_msg {
+ setverdict(fail, "Unexpected UL ACK/NACK after reaching N3103_MAX");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ [] as_ms_rx_ignore_dummy(ms, nr);
+ [] as_pcuif_rx_ignore_empty(nr);
+ [T_3169.running] T_3169.timeout {
+ log("T_3169 timeout");
+ /* Done in alt, wait for pending RTS initiated previously in
+ * above case before continuing (expect /* Dummy block): */
+ BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ tr_RLCMAC_DL_DUMMY_CTRL));
}
- case (RRBP_Nplus26_mod_2715648) {
- add := 26;
+ [] BTS.receive {
+ setverdict(fail, "Unexpected BTS message");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ }
+
+ /* Now that T3169 has expired, establishing a Ul TBF should provide same
+ * USFs as per previous TBF since they were freed at expiration time: */
+ var uint3_t old_usf[8] := ms.ul_tbf.usf;
+ var uint5_t old_tfi := ms.ul_tbf.tfi;
+ f_ms_establish_ul_tbf(ms);
+ if (old_tfi != ms.ul_tbf.tfi) {
+ setverdict(fail, "Unexpected TFI change: ", ms.ul_tbf.tfi, " vs exp ", old_tfi);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ for (var integer i := 0; i < 8; i := i +1) {
+ if (ms.ul_tbf.usf[i] != old_usf[i]) {
+ setverdict(fail, "Unexpected USF change: ", ms.ul_tbf.usf[i], " vs exp ", old_usf[i]);
+ f_shutdown(__BFILE__, __LINE__);
}
}
- return (fn + add) mod 2715648;
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
}
+/* Verify that a Downlink TBF is kept available until T3191 fires, at which
+ * point the TBF is no longer available. In order to get to start of T3191, we
+ * have to wait for x2031 since that marks the IDLE TBF time, that is, the delay
+ * until TBF release procedure starts after draining DL queue. */
+testcase TC_x2031_t3191() runs on RAW_PCU_Test_CT {
+ var PCUIF_info_ind info_ind;
+ var RlcmacDlBlock dl_block;
+ var octetstring data1 := f_rnd_octstring(200);
+ var octetstring data2 := f_rnd_octstring(10);
+ var uint32_t dl_fn;
+ var template (value) TsTrxBtsNum nr;
+ var BTS_PDTCH_Block data_msg;
+ var GprsMS ms;
-function f_bssgp_wait_ul_ud(template PDU_BSSGP exp) runs on dummy_CT {
- timer T := 5.0;
- T.start;
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ info_ind := valueof(ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+ /* Set timer to 1 sec (default 5) to speedup test: */
+ info_ind.t3191 := 1;
+ f_init_raw(testcasename(), info_ind);
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* SGSN sends some DL data, PCU will page on CCCH (PCH) */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data1, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
+ f_sleep(X2002);
+
+ while (true) {
+ f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, ?, ?);
+
+ /* Keep Ack/Nack description updated (except for last BSN) */
+ f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block);
+
+ if (f_dl_block_rrbp_valid(dl_block)) {
+ f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc),
+ f_dl_block_ack_fn(dl_block, dl_fn));
+ break;
+ }
+ }
+
+ /* Now we wait for IDLE TBF timer (X2031) to time out and receive a FINAL ACK */
+ nr := ts_TsTrxBtsNum;
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+ alt {
+ [] as_ms_rx_ignore_dummy(ms, nr);
+ [] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ ?)) -> value data_msg {
+ if (data_msg.dl_block.data.mac_hdr.hdr_ext.fbi) {
+ log("Received FINAL_ACK");
+ ms.dl_tbf.acknack_desc.final_ack := '1'B;
+ break;
+ }
+ if (f_dl_block_rrbp_valid(data_msg.dl_block)) {
+ f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, data_msg.dl_block);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc),
+ f_dl_block_ack_fn(dl_block, data_msg.raw.fn));
+ }
+ nr := ts_TsTrxBtsNum;
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+ repeat;
+ }
+ [] BTS.receive {
+ setverdict(fail, "Unexpected BTS message");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ }
+
+ /* Avoid ACKing the last RLC data block on purpose here, wait for t3191
+ to time out. We simply sleep instead of requesting blocks because
+ otherwise retransmissions would keep restarting the timer. */
+ f_sleep(int2float(info_ind.t3191));
+
+ /* The TBF should be freed now, so new data should trigger an Assignment: */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data2, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
+ f_sleep(X2002);
+ /* Now that we confirmed the new assignment in the dl-tbf, lets receive the data and ack it */
+ f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data2, 0);
+ f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block, '1'B);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc),
+ f_dl_block_ack_fn(dl_block, dl_fn));
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Same as TC_zero_x2031_t3191, but this time without x2031 (immediate FINAL_ACK). */
+testcase TC_zero_x2031_t3191() runs on RAW_PCU_Test_CT {
+ var PCUIF_info_ind info_ind;
+ var RlcmacDlBlock dl_block;
+ var octetstring data1 := f_rnd_octstring(1400);
+ var octetstring data2 := f_rnd_octstring(10);
+ var uint32_t dl_fn;
+ var GprsMS ms;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ info_ind := valueof(ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+ /* Set timer to 1 sec (default 5) to speedup test: */
+ info_ind.t3191 := 1;
+ f_init_raw(testcasename(), info_ind);
+
+ f_vty_config2(PCUVTY, {"pcu"}, "timer X2031 0");
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* SGSN sends some DL data, PCU will page on CCCH (PCH) */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data1, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
+ f_sleep(X2002);
+
+ /* Send enough DL data to at least be able to DL ACK once (excl the
+ * FINAL_ACK one), so that PCU sees we are listening in PDCH and avoids
+ * other code paths like trying to Imm Assign on CCCH again, etc.. */
+ while (true) {
+ f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, ?, ?);
+
+ if (dl_block.data.mac_hdr.hdr_ext.fbi) {
+ log("Received FINAL_ACK");
+ ms.dl_tbf.acknack_desc.final_ack := '1'B;
+ break;
+ }
+
+ /* Keep Ack/Nack description updated (except for last BSN) */
+ f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block);
+
+ if (f_dl_block_rrbp_valid(dl_block)) {
+ f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc),
+ f_dl_block_ack_fn(dl_block, dl_fn));
+ }
+ }
+
+ /* Avoid ACKing the last RLC data block on purpose here, wait for t3191
+ to time out. We simply sleep instead of requesting blocks because
+ otherwise retransmissions would keep restarting the timer. */
+ f_sleep(int2float(info_ind.t3191));
+
+ /* The TBF should be freed now, so new data should trigger an Assignment: */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data2, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
+ f_sleep(X2002);
+ /* Now that we confirmed the new assignment in the dl-tbf, lets receive the data and ack it */
+ f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data2, 0);
+ f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block, '1'B);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc),
+ f_dl_block_ack_fn(dl_block, dl_fn));
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Verify that a Downlink TBF can be assigned using PACCH shortly after the
+ * release of prev DL TBF due to MS staying in PDCH for a while (T3192, in PCU
+ * T3193) after DL TBF release */
+testcase TC_t3193() runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var octetstring data := f_rnd_octstring(10);
+ var boolean ok;
+ var uint32_t sched_fn;
+ var uint32_t dl_fn;
+ var GprsMS ms;
+ var AckNackDescription ack_nack_desc := valueof(t_AckNackDescription_init);
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
+
+ /* Disable "idle DL TBF alive" timer, to make the test easier and avoid
+ * having to keep receiving dummy LLC blocks for a while until the last
+ * block with FBI=1 is set. This way the first and only DL block is already
+ * the FBI one. */
+ f_vty_config2(PCUVTY, {"pcu"}, "timer X2031 0");
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* SGSN sends some DL data, PCU will page on CCCH (PCH) */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
+ f_sleep(X2002);
+ f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0);
+ if (dl_block.data.mac_hdr.hdr_ext.fbi == false) {
+ setverdict(fail, "Expected DL data block with FBI=1 but got FBI=0");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ /* ACK the DL block */
+ f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block, '1'B);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc),
+ f_dl_block_ack_fn(dl_block, dl_fn));
+
+ /* Now that final DL block is ACKED and TBF is released, T3193 in PCU
+ (T3192 in MS) was started and until it fires the MS will be available
+ on PDCH in case new data arrives from SGSN. Let's verify it: */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data));
+ f_ms_rx_pkt_ass_pacch(ms, sched_fn, tr_RLCMAC_DL_PACKET_ASS);
+
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+
+ /* Now that we confirmed the new assignment in the dl-tbf, lets receive the data and ack it */
+ f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0);
+ f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block, '1'B);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc),
+ f_dl_block_ack_fn(dl_block, dl_fn));
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Verify after N3105_MAX is reached, T3195 is started and upon timeout TBF is
+ freed and no longer available. Trigger it by sending DL blocks and never DL
+ ACKing the data (which are requested through RRBP) */
+testcase TC_n3105_max_t3195() runs on RAW_PCU_Test_CT {
+ var PCUIF_info_ind info_ind;
+ var RlcmacDlBlock dl_block;
+ var octetstring data1 := f_rnd_octstring(1000);
+ var octetstring data2 := f_rnd_octstring(10);
+ var uint32_t dl_fn;
+ var template (value) TsTrxBtsNum nr;
+ var BTS_PDTCH_Block data_msg;
+ var GprsMS ms;
+ const integer N3105_MAX := 2;
+ var integer N3105 := 0;
+ timer T_3195 := 1.0;
+ var integer num_poll_recv := 0;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ info_ind := valueof(ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+ /* Speedup test: */
+ info_ind.n3105 := N3105_MAX;
+ info_ind.t3195 := 1;
+ f_init_raw(testcasename(), info_ind);
+
+ /* Disable "MS delay release" timer, to avoid old DL data kept in cached
+ * MS and retransmitted after the TBF is released and later on created
+ * (because the MS is reused) */
+ f_vty_config2(PCUVTY, {"pcu"}, "timer X2030 0");
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* SGSN sends some DL data, PCU will page on CCCH (PCH) */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data1, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
+ f_sleep(X2002);
+
+ /* Now we go on receiving DL data and not answering RRBP: */
+ nr := ts_TsTrxBtsNum;
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
alt {
- [] BSSGP[0].receive(exp) {
- log("found matching BSSGP UL-UNITDATA PDU");
+ [not T_3195.running] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ tr_RLCMAC_DATA)) -> value data_msg {
+ if (f_dl_block_rrbp_valid(data_msg.dl_block)) {
+ if (num_poll_recv == 0) {
+ /* ACK first one so PCU detects we are there and doesn't retransmit Imm Ass */
+ f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, data_msg.dl_block);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc),
+ f_dl_block_ack_fn(data_msg.dl_block, data_msg.raw.fn));
+ } else {
+ log("Ignoring RRBP ", num_poll_recv);
+ N3105 := N3105 + 1;
+ }
+ num_poll_recv := num_poll_recv + 1;
+ }
+
+ nr := ts_TsTrxBtsNum;
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+ repeat;
+ }
+ /* At this point in time (N3105_MAX reached), PCU already moved TBF to
+ * RELEASE state so no data for it is tx'ed, hence the dummy/idle blocks:
+ */
+ [N3105 == N3105_MAX] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ tr_RLCMAC_DL_DUMMY_CTRL)) -> value data_msg {
+ if (not T_3195.running) {
+ T_3195.start;
+ /* We even send some new data, nothing should be sent to MS */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data1));
}
+ nr := ts_TsTrxBtsNum;
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+ repeat;
+ }
+ /* We may already receive idle blocks before our own TTCN3 timer
+ * triggers due to the TBF being released. Keep going until our T_3195 triggers. */
+ [N3105 == N3105_MAX] as_pcuif_rx_ignore_empty(nr);
+ [T_3195.running] T_3195.timeout {
+ log("T_3195 timeout");
+ /* Done in alt, wait for pending RTS initiated previously in
+ * above case before continuing (expect empty block): */
+ alt {
+ [] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ omit)); /* DONE, continue after altstep. */
+ [] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ tr_RLCMAC_DL_DUMMY_CTRL)) {
+ setverdict(fail, "Rx unexpected DUMMY message, expected empty data block");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ }
+ }
+ [] BTS.receive {
+ setverdict(fail, "Unexpected BTS message");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ }
+
+ /* after T_3195 timeout, TBF is released */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data2, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
+ f_sleep(X2002);
+ f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data2, 0);
+
+ /* ACK the DL block */
+ f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block, '1'B);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc),
+ f_dl_block_ack_fn(dl_block, dl_fn));
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Verify configured T3172 is properly transmitted as WAIT_INDICATION in Pkt Access Reject in PACCH. */
+function f_TC_t3172(integer t3172_ms, BIT1 wait_ind_size) runs on RAW_PCU_Test_CT {
+ var PCUIF_info_ind info_ind;
+ var template IARRestOctets rest;
+ var BIT11 ra11;
+ var GprsMS ms;
+ var octetstring data := f_rnd_octstring(10);
+ var RlcmacDlBlock dl_block;
+ var template RlcmacDlBlock rej_tmpl;
+ var uint32_t dl_fn;
+ var uint32_t sched_fn;
+ var uint8_t wait_ind_val;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ info_ind := valueof(ts_PCUIF_INFO_default);
+
+ /* Only the first TRX is enabled. */
+ f_PCUIF_PDCHMask_set(info_ind, '00000000'B, (1 .. 7));
+ f_PCUIF_PDCHMask_set(info_ind, '00000001'B, 0);
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ f_pcuvty_set_timer(3172, t3172_ms);
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ var EGPRSPktChRequest req := {
+ one_phase := {
+ tag := '0'B,
+ multislot_class := '10101'B,
+ priority := '01'B,
+ random_bits := '101'B
+ }
+ };
+
+ /* We send 7 requests, the IUT gives us all available USFs (0..6) */
+ for (var integer i := 0; i < 7; i := i + 1) {
+ req.one_phase.random_bits := int2bit(f_rnd_int(8), 3);
+ f_TC_egprs_pkt_chan_req(req, tr_IMM_TBF_ASS);
+ }
+
+ /* SGSN sends some DL data, PCU will page on CCCH (PCH) */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
+ f_sleep(X2002);
+ f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0);
+
+ /* ACK the DL block */
+ f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block, '1'B);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc, false, ts_ChannelReqDescription()),
+ f_dl_block_ack_fn(dl_block, dl_fn));
+
+ /* Since all USF are taken, we should receive a Reject: */
+
+ if (wait_ind_size == '0'B) {
+ wait_ind_val := t3172_ms / 1000;
+ } else {
+ wait_ind_val := t3172_ms / 20;
+ }
+ rej_tmpl := tr_RLCMAC_DL_CTRL(?, tr_RlcMacDlCtrl_PKT_ACC_REJ(
+ tr_PacketAccessRejectStruct_TLLI(ms.tlli,
+ wait_ind_val,
+ wait_ind_size)));
+ template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum;
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+ alt {
+ [] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ rej_tmpl));
+ [] BTS.receive {
+ setverdict(fail, "Unexpected BTS message");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ }
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+testcase TC_t3172_wait_ind_size0() runs on RAW_PCU_Test_CT {
+ /* size=0 means value is provided in seconds. Due to value being 8
+ * bit, in the 20ms step case (size=1) the maximum value possible is 20 * 255
+ * = 5100. Hence, values above it should use size=0 to be able to
+ * provide values in range. Let's use 6 seconds, 6000ms
+ */
+ f_TC_t3172(6000, '0'B);
+}
+testcase TC_t3172_wait_ind_size1() runs on RAW_PCU_Test_CT {
+ f_TC_t3172(3000, '1'B);
+}
+
+/* Verify PCU handles correctly Countdown Procedure based on BS_CV_MAX */
+testcase TC_countdown_procedure() runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var uint32_t sched_fn;
+ var octetstring total_payload;
+ var GprsMS ms;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ f_ms_wait_usf(ms);
+
+ /* Send one UL block (with TLLI since we are in One-Phase Access
+ contention resolution) and make sure it is ACKED fine. */
+ total_payload := f_rnd_octstring(f_ultbf_payload_fill_length(ms.ul_tbf, true));
+ /* Set CV = 15 to signal there's still more than BS_CV_MAX blocks to be sent */
+ f_ms_tx_ul_data_block(ms, total_payload, cv := 15, with_tlli := true, fn := ms.ul_tbf.start_time_fn)
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn);
+ /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+
+ /* Send enough blocks to test whole procedure: Until Nth block
+ (N=BS_CV_MAX), CV=15 is sent, and then the decreasing countdown value is sent.
+ */
+ total_payload := total_payload & f_ms_tx_ul_data_block_multi(ms, 20);
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn);
+ /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+
+ /* receive one message on BSSGP with all aggregated data in payload: */
+ BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id, total_payload));
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Verify PCU handles correctly CS1..4 with all possible LLC payload sizes fitting alone in one RLC block */
+testcase TC_ul_all_sizes() runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var uint32_t dl_fn, sched_fn;
+ var octetstring payload;
+ var template (value) RlcmacUlBlock ul_data;
+ var template (value) LlcBlockHdr blk_hdr;
+ var template (value) LlcBlocks blocks;
+ var integer blk_len;
+ var CodingScheme tx_cs;
+ var GprsMS ms;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ f_ms_wait_usf(ms);
+
+ /* Send one UL block (with TLLI since we are in One-Phase Access
+ contention resolution) and make sure it is ACKED fine. */
+ payload := f_rnd_octstring(16); /* 16 bytes fills the llc block (because TLLI takes 4 bytes) */
+ blk_hdr := t_RLCMAC_LLCBLOCK_HDR(length_ind := lengthof(payload),
+ more := false, e := true);
+ blocks := { t_RLCMAC_LLCBLOCK(payload, blk_hdr) };
+ /* Set CV = 15 to signal there's still more than BS_CV_MAX blocks to be sent */
+ ul_data := t_RLCMAC_UL_DATA_TLLI(cs := ms.ul_tbf.tx_cs_mcs,
+ tfi := ms.ul_tbf.tfi,
+ cv := 15,
+ bsn := ms.ul_tbf.bsn,
+ blocks := blocks,
+ tlli := ms.tlli);
+ f_ultbf_inc_bsn(ms.ul_tbf);
+ f_ms_tx_ul_block(ms, ul_data, ms.ul_tbf.start_time_fn);
+
+ /* ACK and check it was received fine */
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn);
+ /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ /* receive one message on BSSGP with all aggregated data in payload: */
+ BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id, payload));
+
+ /* Test sending LLC PDUS of incrementing size */
+ var integer max_size := 49;
+ for (var integer i := 1; i <= max_size; i := i + 1) {
+ var integer cv;
+ /* Enqueue DATA.ind (both TDMA frame and block numbers to be patched) */
+ log("Sending DATA.ind with LLC payload size ", i);
+ if (i < max_size - g_bs_cv_max) {
+ cv := 15;
+ } else {
+ cv := max_size - i;
+ }
+
+ blk_len := 3 + 1 + i; /* 3 Header bytes + LI byte + payload length */
+ tx_cs := f_rlcmac_block_len_required_cs_mcs(blk_len, false);
+ payload := f_rnd_octstring(i);
+ blk_hdr := t_RLCMAC_LLCBLOCK_HDR(length_ind := lengthof(payload),
+ more := false, e := true);
+ blocks := { t_RLCMAC_LLCBLOCK(payload, blk_hdr) };
+ /* Set CV = 15 to signal there's still more than BS_CV_MAX blocks to be sent */
+ ul_data := t_RLCMAC_UL_DATA(cs := tx_cs,
+ tfi := ms.ul_tbf.tfi,
+ cv := cv,
+ bsn := ms.ul_tbf.bsn,
+ blocks := blocks);
+ f_ultbf_inc_bsn(ms.ul_tbf);
+ f_ms_tx_ul_block(ms, ul_data);
+
+ /* receive one message on BSSGP with all aggregated data in payload: */
+ BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id, payload));
+
+ /* we will receive UL ACK/NACK from time to time, handle it. */
+ f_rx_rlcmac_dl_block(dl_block, dl_fn);
+ if (match(dl_block, tr_RLCMAC_DL_DUMMY_CTRL())) {
+ continue;
+ }
+ if (not match(dl_block, tr_RLCMAC_UL_ACK_NACK_GPRS(ul_tfi := ?)) and
+ not match(dl_block, tr_RLCMAC_UL_ACK_NACK_EGPRS(ul_tfi := ?))) {
+ setverdict(fail, "Failed to match Packet Uplink ACK / NACK:", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ log("Rx Packet Uplink ACK / NACK");
+ sched_fn := f_rrbp_ack_fn(dl_fn, dl_block.ctrl.mac_hdr.rrbp);
+ /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+function f_TC_ul_data_toolong_fills_padding_cs(inout GprsMS ms, CodingScheme cs, integer cv) runs on RAW_PCU_Test_CT {
+ var octetstring payload;
+ var template (value) RlcmacUlBlock ul_data;
+ var template (value) LlcBlockHdr blk_hdr;
+ var template (value) LlcBlocks blocks;
+ var integer block_len, max_valid_data_len;
+ timer T;
+
+ block_len := f_rlcmac_cs_mcs2block_len(cs);
+ /* We need to send with TLLI since we are in One-Phase Access Contenion
+ * resolution), so that's -4 bytes of data, -3 for headers, -1 for LI
+ * indicator, -1 for spare bits octet at the end */
+ max_valid_data_len := block_len - 4 - 3 - 1 - 1;
+ payload := f_rnd_octstring(max_valid_data_len + 1); /* +1 to write LLC data on last padding octet */
+ blk_hdr := t_RLCMAC_LLCBLOCK_HDR(length_ind := lengthof(payload),
+ more := false, e := true);
+ blocks := { t_RLCMAC_LLCBLOCK(payload, blk_hdr) };
+ ul_data := t_RLCMAC_UL_DATA_TLLI(cs := cs,
+ tfi := ms.ul_tbf.tfi,
+ cv := cv,
+ bsn := ms.ul_tbf.bsn,
+ blocks := blocks,
+ tlli := ms.tlli);
+ f_ultbf_inc_bsn(ms.ul_tbf);
+ f_ms_tx_data_ind(ms, enc_RlcmacUlBlock(valueof(ul_data)));
+
+ T.start(0.5);
+ alt {
+ [] BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id, ?)) {
+ setverdict(fail, "LLC PDU in Malformed RLC block was forwarded");
+ f_shutdown(__BFILE__, __LINE__);
+ }
[] T.timeout {
- setverdict(fail, "Timeout waiting for ", exp);
- mtc.stop;
+ setverdict(pass);
}
}
}
+/* Verify PCU finds out incorrectly formated RLC block and discards it. This
+ blocks intentionally contain last byte of data placed in last byte of RLC
+ containing padding/spare bits, which is incorrect. Spare bits exist and are
+ described for CS2..4 in 3GPP TS 44.060 Table 10.2.1: "RLC data block size,
+ discounting padding in octet" */
+testcase TC_ul_data_toolong_fills_padding() runs on RAW_PCU_Test_CT {
+ var GprsMS ms;
+ var integer block_len, max_valid_data_len;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ f_ms_wait_usf(ms);
+
+ f_TC_ul_data_toolong_fills_padding_cs(ms, CS_2, 2);
+ f_TC_ul_data_toolong_fills_padding_cs(ms, CS_3, 1);
+ f_TC_ul_data_toolong_fills_padding_cs(ms, CS_4, 0);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Test scenario where MS wants to send some data on PDCH against SGSN and it is
+ * answered, so TBFs for uplink and later for downlink are created.
+ */
+private function f_TC_mo_ping_pong_1phase_access(template (present) CodingScheme exp_cs_mcs := ?) runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var octetstring data := f_rnd_octstring(10);
+ var uint32_t sched_fn;
+ var uint32_t dl_fn;
+ var GprsMS ms;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ f_ms_wait_usf(ms);
+
+ /* Send one UL block (with TLLI since we are in One-Phase Access
+ contention resolution) and make sure it is ACKED fine */
+ f_ms_tx_ul_data_block_multi(ms, 1, with_tlli := true, fn := ms.ul_tbf.start_time_fn);
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn);
+ /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+
+ /* UL block should be received in SGSN */
+ BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id));
+
+ /* Now SGSN sends some DL data, PCU will page on CCCH (PCH) */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
+ f_sleep(X2002);
+ f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0, exp_cs_mcs);
+
+ /* ACK the DL block */
+ f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block, '1'B);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc),
+ f_dl_block_ack_fn(dl_block, dl_fn));
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Test scenario where MS wants to send some data on PDCH against SGSN and it is
+ * answered, so TBFs for uplink and later for downlink are created.
+ */
+testcase TC_mo_ping_pong() runs on RAW_PCU_Test_CT {
+ var template (present) CodingScheme exp_cs_mcs := cs_gprs_any;
+ f_TC_mo_ping_pong_1phase_access(exp_cs_mcs);
+}
+
+/* Test scenario where MS wants to send some data on PDCH against SGSN and it is
+ * answered, so TBFs for uplink and later for downlink are created.
+ */
+private function f_TC_mo_ping_pong_2phase_access(PCUIF_Flags ind_flags,
+ template (value) MSRadioAccessCapabilityV ms_racap,
+ template (present) CodingScheme exp_ul_cs_mcs := ?,
+ template (present) CodingScheme exp_dl_cs_mcs := ?)
+runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var octetstring data := f_rnd_octstring(10);
+ var PollFnCtx pollctx;
+ var uint32_t sched_fn;
+ var uint32_t dl_fn;
+ var uint32_t unused_fn;
+ var GprsMS ms;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(ind_flags));
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Send PACKET RESOURCE REQUEST to upgrade to EGPRS */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap));
+
+ if (not match(ms.ul_tbf.tx_cs_mcs, exp_ul_cs_mcs)) {
+ setverdict(fail, "Wrong CS_MCS ", ms.ul_tbf.tx_cs_mcs, " received vs exp ", exp_ul_cs_mcs);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ /* Send one UL block (without TLLI since we are in Second-Phase Access)
+ and make sure it is ACKED fine */
+ f_ms_tx_ul_data_block_multi(ms, 1);
+
+ /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ /* UL block should be received in SGSN */
+ BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id));
+
+ /* Now SGSN sends some DL data, PCU will page on PACCH */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data));
+ /* Sleep a bit to make sure PCU received the DL data and hence it will be prioritized by scheduler: */
+ f_sleep(0.5);
+ f_ms_rx_pkt_ass_pacch(ms, sched_fn, tr_RLCMAC_DL_PACKET_ASS);
+ /* DL Ass sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+
+ /* PCU acks the UL data after having received CV=0) */
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, unused_fn);
+
+ /* After acking the dl assignment, dl tbf goes into FLOW state and PCU will provide DL data when BTS asks for it */
+ f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0, exp_dl_cs_mcs);
+
+ /* ACK the DL block */
+ f_dltbf_ack_block(ms.dl_tbf, dl_block, '1'B);
+ f_ms_tx_ul_block(ms, f_dltbf_ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf, ischosen(dl_block.data_egprs)),
+ f_dl_block_ack_fn(dl_block, dl_fn));
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+testcase TC_mo_ping_pong_with_ul_racap() runs on RAW_PCU_Test_CT {
+ var template (present) CodingScheme exp_ul_cs_mcs := cs_gprs_any;
+ var template (present) CodingScheme exp_dl_cs_mcs := cs_gprs_any;
+
+ f_TC_mo_ping_pong_2phase_access(c_PCUIF_Flags_noMCS, ms_racap_gprs_def, exp_ul_cs_mcs, exp_dl_cs_mcs);
+
+ var StatsDExpects expect := {
+ { name := "TTCN3.bts.0.rach.requests", mtype := "c", min := 1, max := 1 },
+ { name := "TTCN3.bts.0.rach.requests.11bit", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.rach.requests.one_phase", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.rach.requests.two_phase", mtype := "c", min := 1, max := 1 },
+ { name := "TTCN3.bts.0.immediate.assignment_UL", mtype := "c", min := 1, max := 1 },
+ { name := "TTCN3.bts.0.immediate.assignment_ul.one_phase", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.immediate.assignment_ul.two_phase", mtype := "c", min := 1, max := 1 },
+ { name := "TTCN3.bts.0.immediate.assignment_ul.contention_resolution_success", mtype := "c", min := 1, max := 1 },
+ { name := "TTCN3.bts.0.immediate.assignment_DL", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.pkt.ul_assignment", mtype := "c", min := 1, max := 1 }
+ };
+ f_statsd_expect(expect);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+testcase TC_mo_ping_pong_with_ul_racap_egprs_only() runs on RAW_PCU_Test_CT {
+ var template (present) CodingScheme exp_ul_cs_mcs := mcs_egprs_any;
+ var template (present) CodingScheme exp_dl_cs_mcs := mcs_egprs_any;
+
+ f_TC_mo_ping_pong_2phase_access(c_PCUIF_Flags_default, ms_racap_egprs_def, exp_ul_cs_mcs, exp_dl_cs_mcs);
+
+ var StatsDExpects expect := {
+ { name := "TTCN3.bts.0.rach.requests", mtype := "c", min := 1, max := 1 },
+ { name := "TTCN3.bts.0.rach.requests.11bit", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.rach.requests.one_phase", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.rach.requests.two_phase", mtype := "c", min := 1, max := 1 },
+ { name := "TTCN3.bts.0.immediate.assignment_UL", mtype := "c", min := 1, max := 1 },
+ { name := "TTCN3.bts.0.immediate.assignment_ul.one_phase", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.immediate.assignment_ul.two_phase", mtype := "c", min := 1, max := 1 },
+ { name := "TTCN3.bts.0.immediate.assignment_ul.contention_resolution_success", mtype := "c", min := 1, max := 1 },
+ { name := "TTCN3.bts.0.immediate.assignment_DL", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.pkt.ul_assignment", mtype := "c", min := 1, max := 1 }
+ };
+ f_statsd_expect(expect);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+testcase TC_force_two_phase_access() runs on RAW_PCU_Test_CT {
+ /* Configure PCU to force two phase access */
+ g_force_two_phase_access := true;
+
+ var CodingScheme exp_ul_cs_mcs := f_rlcmac_block_int2cs_mcs(g_mcs_initial_ul, false);
+ var template (present) CodingScheme exp_dl_cs_mcs := cs_gprs_any;
+
+ f_TC_mo_ping_pong_2phase_access(c_PCUIF_Flags_noMCS, ms_racap_gprs_def, exp_ul_cs_mcs, exp_dl_cs_mcs);
+
+ var StatsDExpects expect := {
+ { name := "TTCN3.bts.0.rach.requests", mtype := "c", min := 1, max := 1 },
+ { name := "TTCN3.bts.0.rach.requests.11bit", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.rach.requests.one_phase", mtype := "c", min := 1, max := 1 },
+ { name := "TTCN3.bts.0.rach.requests.two_phase", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.immediate.assignment_UL", mtype := "c", min := 1, max := 1 },
+ { name := "TTCN3.bts.0.immediate.assignment_ul.one_phase", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.immediate.assignment_ul.two_phase", mtype := "c", min := 1, max := 1 },
+ { name := "TTCN3.bts.0.immediate.assignment_ul.contention_resolution_success", mtype := "c", min := 1, max := 1 },
+ { name := "TTCN3.bts.0.immediate.assignment_DL", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.pkt.ul_assignment", mtype := "c", min := 1, max := 1 }
+ };
+ f_statsd_expect(expect);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Test scenario where SGSN wants to send some data against MS and it is
+ * answered by the MS on PDCH, so TBFs for downlink and later for uplink are created.
+ */
+private function f_TC_mt_ping_pong(template (omit) MSRadioAccessCapabilityV_BSSGP ms_racap := omit,
+ template (present) CodingScheme exp_cs_mcs := ?)
+runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var octetstring data := f_rnd_octstring(10);
+ var uint32_t sched_fn;
+ var uint32_t dl_fn;
+ var GprsMS ms;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* SGSN sends some DL data, PCU will page on CCCH (PCH) */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, ms_racap, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
+ f_sleep(X2002);
+ /* Skip potential dummy blocks before X2002 triggers at PCU after us: */
+ dl_fn := f_rx_rlcmac_dl_block_skip_dummy(dl_block, max_dummy := 10);
+
+ f_rlcmac_dl_block_exp_data(dl_block, data, 0, exp_cs_mcs);
+
+ /* ACK the DL block, and request UL TBF at the same time */
+ f_dltbf_ack_block(ms.dl_tbf, dl_block, '1'B);
+ f_ms_tx_ul_block(ms, f_dltbf_ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf, ischosen(dl_block.data_egprs), c_ChReqDesc_default),
+ f_dl_block_ack_fn(dl_block, dl_fn));
+
+ /* Expect UL ass */
+ f_ms_rx_pkt_ass_pacch(ms, sched_fn, tr_RLCMAC_UL_PACKET_ASS);
+
+ /* Send one UL block (with TLLI since we are in One-Phase Access
+ contention resolution) and make sure it is ACKED fine */
+ f_ms_tx_ul_data_block_multi(ms, 1, with_tlli := true);
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn);
+ /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+
+ /* UL block should be received in SGSN */
+ BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id));
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+testcase TC_mt_ping_pong() runs on RAW_PCU_Test_CT {
+ var template (present) CodingScheme exp_cs_mcs := cs_gprs_any;
+ f_TC_mt_ping_pong(omit, exp_cs_mcs);
+}
+
+/* TC_mt_ping_pong, but DL-UNITDATA contains RA Access capability with (M)CS
+/* information about the MS */
+testcase TC_mt_ping_pong_with_dl_racap() runs on RAW_PCU_Test_CT {
+ var template (present) CodingScheme exp_cs_mcs := cs_gprs_any;
+ f_TC_mt_ping_pong(bssgp_ms_racap_gprs_def, exp_cs_mcs);
+}
+
+/* Verify that if PCU doesn't get one of the intermediate UL data blocks in a UL
+ * TBF, it will request retransmission through UL ACK/NACK (with missing block
+ * in its bitmap) when CV=0 is received (and hence it knows no more data is to
+ * be transferred).
+ */
+testcase TC_ul_intermediate_retrans() runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var template (value) RlcmacUlBlock ul_data;
+ var uint32_t sched_fn;
+ var octetstring total_payload;
+ var octetstring payload;
+ var octetstring lost_payload;
+ var uint5_t tfi;
+ var GprsMS ms;
+ var uint32_t payload_fill_len;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+ tfi := ms.ul_tbf.tfi;
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ f_ms_wait_usf(ms);
+
+ /* Send one UL block (with TLLI since we are in One-Phase Access
+ contention resolution) and make sure it is ACKED fine. */
+ payload := f_rnd_octstring(f_ultbf_payload_fill_length(ms.ul_tbf, true)); /* 16 bytes fills the llc block (because TLLI takes 4 bytes) */
+ f_ms_tx_ul_data_block(ms, payload, cv := 15, with_tlli := true, fn := ms.ul_tbf.start_time_fn);
+
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn);
+ /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ total_payload := payload;
+
+ payload_fill_len := f_ultbf_payload_fill_length(ms.ul_tbf);
+
+ /* Send 2 packets, skip 1 (inc bsn) and send another one */
+ payload := f_rnd_octstring(payload_fill_len);
+ f_ms_tx_ul_data_block(ms, payload, cv := 15);
+ total_payload := total_payload & payload;
+
+ payload := f_rnd_octstring(payload_fill_len);
+ f_ms_tx_ul_data_block(ms, payload, cv := 15);
+ total_payload := total_payload & payload;
+
+ lost_payload := f_rnd_octstring(payload_fill_len);
+ ms.ul_tbf.bsn := ms.ul_tbf.bsn + 1; /* LOST PAYLOAD bsn=3, will be retransmitted, next bsn is increased +2 */
+ total_payload := total_payload & lost_payload;
+
+ payload := f_rnd_octstring(payload_fill_len)
+ f_ms_tx_ul_data_block(ms, payload, cv := 15);
+ total_payload := total_payload & payload;
+
+ /* Send enough blocks to finish the transmission (since we were sending BSN=15, send BS_CV_MAX packets) */
+ total_payload := total_payload & f_ms_tx_ul_data_block_multi(ms, g_bs_cv_max);
+
+ /* On CV=0, we'll receive a UL ACK asking about missing block */
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn);
+ /* TODO: check ack ack bitmap (URBB) */
+ ul_data := t_RLCMAC_UL_DATA(cs := ms.ul_tbf.tx_cs_mcs,
+ tfi := tfi,
+ cv := 15,
+ bsn := 3,
+ blocks := {t_RLCMAC_LLCBLOCK(lost_payload)});
+ f_ms_tx_ul_block(ms, ul_data);
+
+ /* Now final ack is recieved */
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn);
+ /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+
+ /* receive one message on BSSGP with all aggregated data in payload: */
+ BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id, total_payload));
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Verify that if PCU doesn't get an ACK for first DL block after IMM ASS, it
+ * will retry by retransmitting both the IMM ASS + DL block after poll (ack)
+ * timeout occurs (specified by sent RRBP on DL block). */
+testcase TC_imm_ass_dl_block_retrans() runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var octetstring data := f_rnd_octstring(10);
+ var uint32_t dl_fn;
+ var GprsMS ms;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* SGSN sends some DL data, PCU will page on CCCH (PCH) */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
+ f_sleep(X2002);
+ f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0);
+
+ /* Now we don't ack the dl block (emulate MS failed receiveing IMM ASS
+ * or GPRS DL, or DL ACK was lost for some reason). As a result, PCU
+ * should retrigger IMM ASS + GPRS DL procedure after poll timeout. */
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
+ f_sleep(X2002);
+ f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0);
+
+ /* ACK the DL block */
+ f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block, '1'B);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc),
+ f_dl_block_ack_fn(dl_block, dl_fn));
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Verify scheduling of multiple Downlink data blocks during one RRBP. */
+testcase TC_dl_flow_more_blocks() runs on RAW_PCU_Test_CT {
+ var AckNackDescription ack_nack_desc := valueof(t_AckNackDescription_init);
+ var octetstring data := f_rnd_octstring(16);
+ var PacketDlAssign dl_tbf_ass;
+ var RlcmacDlBlock dl_block;
+ var uint32_t ack_fn;
+ var uint32_t fn;
+ var GprsMS ms;
+ timer T := 5.0;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+
+ f_statsd_reset();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* SGSN sends some DL data, PCU will page on CCCH (PCH) */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS */
+ f_sleep(X2002);
+ /* Skip potential dummy blocks before X2002 triggers at PCU after us: */
+ fn := f_rx_rlcmac_dl_block_skip_dummy(dl_block, max_dummy := 10);
+ /* Expect the first (GPRS DL) block with bsn=0 and rrbp_valid=1 */
+ f_rlcmac_dl_block_exp_data(dl_block, data, 0);
+ f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block);
-function f_ul_tbf(inout UlTbfState us) runs on dummy_CT {
- var RLCMAC_ph_data_ind dl;
+ /* TDMA frame number on which we are supposed to send the ACK */
+ ack_fn := f_dl_block_ack_fn(dl_block, fn);
- /* Establish an UL-TBF */
- f_establish_ul_tbf();
+ /* SGSN sends more blocks during the indicated RRBP */
+ for (var integer bsn := 1; bsn < 63; bsn := bsn + 1) {
+ data := f_rnd_octstring(16); /* Random LLC data */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data));
+ f_rx_rlcmac_dl_block_exp_data(dl_block, fn, data, bsn);
+
+ /* Make sure this block has the same TFI as was assigned
+ * FIXME: this is only valid for GPRS, not EGPRS. */
+ if (dl_block.data.mac_hdr.hdr_ext.tfi != ms.dl_tbf.tfi) {
+ setverdict(fail, "Rx DL data block with unexpected TFI: ",
+ dl_block.data.mac_hdr.hdr_ext.tfi);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ /* Keep Ack/Nack description updated */
+ f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block);
+
+ /* Break if this is the end of RRBP */
+ if (fn == ack_fn) {
+ ms.dl_tbf.acknack_desc.final_ack := '1'B;
+ break;
+ }
+ }
+
+ /* This is the end of RRBP, send Packet Downlink Ack/Nack */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc), fn := fn);
+
+ /* Make sure that the next block (after the Ack) is dummy */
+ f_rx_rlcmac_dl_block_exp_dummy(dl_block);
+
+ var StatsDExpects expect := {
+ { name := "TTCN3.bts.0.rach.requests", mtype := "c", min := 0, max := 0},
+ { name := "TTCN3.bts.0.immediate.assignment_DL", mtype := "c", min := 1, max := 1},
+ { name := "TTCN3.bts.0.immediate.assignment_UL", mtype := "c", min := 0, max := 0},
+ { name := "TTCN3.bts.0.tbf.dl.alloc", mtype := "c", min := 1, max := 1},
+ { name := "TTCN3.bts.0.tbf.ul.alloc", mtype := "c", min := 0, max := 0},
+ { name := "TTCN3.bts.0.rlc.dl_payload_bytes", mtype := "c", min := 64, max := 64},
+ { name := "TTCN3.bts.0.rlc.ul_payload_bytes", mtype := "c", min := 0, max := 0}
+ };
+ f_statsd_expect(expect);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Verify Decoding and segmentation of UL LLC PDUs into RLC data blocks, OS#4559.
+ * Check "GPRS from A-Z" slide "Example of LI-Field and E-Bit" page 186.
+ * Check "3GPP TS 44.060" Annex B. */
+testcase TC_ul_flow_multiple_llc_blocks() runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var octetstring dataA := f_rnd_octstring(20);
+ var octetstring dataB := f_rnd_octstring(13);
+ var octetstring dataC := f_rnd_octstring(3);
+ var octetstring dataD := f_rnd_octstring(12);
+ var uint32_t sched_fn;
+ var GprsMS ms;
+ var template (value) RlcmacUlBlock ul_data;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ f_ms_wait_usf(ms);
+
+ /* Summary of what's transmitted:
+ * 1- UL RlcDataBlock(dataA) [BSN=0, CV=3]
+ * 2- UL RlcDataBlock(dataA finished, dataB starts) [BSN=1, CV=2]
+ * 3- UL RlcDataBlock(dataB finished, dataC starts and finishes, dataD starts) [BSN=2, CV=1]
+ * 4- UL RlcDataBlock(dataD finishes) [BSN=3, CV=0]
+ * And on SGSN we receive 4 packets, one for each LlcBlock dataA..D.
+ * We'll also receive some UL ACK/NACK we need to reply with CTRL ACK.
+ */
+
+ /* UL RlcDataBlock(dataA) [BSN=0, CV=3] */
+ ul_data := t_RLCMAC_UL_DATA_TLLI(cs := CS_1,
+ tfi := ms.ul_tbf.tfi,
+ cv := 3,
+ bsn := ms.ul_tbf.bsn,
+ blocks := { t_RLCMAC_LLCBLOCK(substr(dataA, 0, 16)) },
+ tlli := ms.tlli);
+ /* Indicate no llc header, meaning first LLC block doesn't finish in current
+ * RLCMAC block being sent. */
+ ul_data.data.mac_hdr.e := true;
+ f_ultbf_inc_bsn(ms.ul_tbf);
+ f_ms_tx_ul_block(ms, ul_data, ms.ul_tbf.start_time_fn);
+
+ /* UL RlcDataBlock(dataA finished, dataB starts) [BSN=1, CV=2] */
+ ul_data := t_RLCMAC_UL_DATA_TLLI(cs := CS_1,
+ tfi := ms.ul_tbf.tfi,
+ cv := 2,
+ bsn := ms.ul_tbf.bsn,
+ blocks := { t_RLCMAC_LLCBLOCK(substr(dataA, 16, 4),
+ t_RLCMAC_LLCBLOCK_HDR(length_ind := 4, more := true, e := true)),
+ t_RLCMAC_LLCBLOCK(substr(dataB, 0, 11))
+ },
+ tlli := ms.tlli);
+ f_ultbf_inc_bsn(ms.ul_tbf);
+ f_ms_tx_ul_block(ms, ul_data);
+
+ /* UL block dataA should be received in SGSN */
+ BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id, dataA));
+
+ /* UL RlcDataBlock(dataB finished, dataC starts and finishes, dataD starts) [BSN=2, CV=1] */
+ ul_data := t_RLCMAC_UL_DATA_TLLI(cs := CS_1,
+ tfi := ms.ul_tbf.tfi,
+ cv := 1,
+ bsn := ms.ul_tbf.bsn,
+ blocks := { t_RLCMAC_LLCBLOCK(substr(dataB, 11, 2),
+ t_RLCMAC_LLCBLOCK_HDR(length_ind := 2, more := true, e := false)),
+ t_RLCMAC_LLCBLOCK(substr(dataC, 0, 3),
+ t_RLCMAC_LLCBLOCK_HDR(length_ind := 3, more := true, e := true)),
+ t_RLCMAC_LLCBLOCK(substr(dataD, 0, 9))
+ },
+ tlli := ms.tlli);
+ f_ultbf_inc_bsn(ms.ul_tbf);
+ f_ms_tx_ul_block(ms, ul_data);
+
+ /* UL block dataB and dataC should be received in SGSN */
+ BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id, dataB));
+ BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id, dataC));
+
+ /* UL RlcDataBlock(dataD finishes) [BSN=3, CV=0] */
+ ul_data := t_RLCMAC_UL_DATA_TLLI(
+ cs := CS_1,
+ tfi := ms.ul_tbf.tfi,
+ cv := 0,
+ bsn := ms.ul_tbf.bsn,
+ blocks := { t_RLCMAC_LLCBLOCK(substr(dataD, 9, 3),
+ t_RLCMAC_LLCBLOCK_HDR(length_ind := 3, more := false, e := true))
+ },
+ tlli := ms.tlli);
+ f_ultbf_inc_bsn(ms.ul_tbf);
+ f_ms_tx_ul_block(ms, ul_data);
+
+ /* UL block dataB and dataD should be received in SGSN */
+ BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id, dataD));
+
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn);
+ /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Validate an Imm Assignment is retransmitted if first RRBP requesting DL
+ * ACK/NACK is not answered */
+testcase TC_dl_no_ack_retrans_imm_ass() runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var octetstring data1 := f_rnd_octstring(200);
+ var octetstring data2 := f_rnd_octstring(10);
+ var uint32_t dl_fn;
+ var GprsMS ms;
+ var template (value) TsTrxBtsNum nr;
+ var BTS_PDTCH_Block data_msg;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename())
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* SGSN sends some DL data, PCU will page on CCCH (PCH) */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data1, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
+ f_sleep(X2002);
+
+ /* Recv DL data until receiving RRBP to DL ACK (because it's last queued DL data) */
while (true) {
- var RlcmacUlBlock blk;
- if (f_ul_tbf_get_next_block(blk, us, g_mmctx, true) == false) {
+ f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, ?, ?);
+
+ /* Keep Ack/Nack description updated (except for last BSN) */
+ f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block);
+
+ if (f_dl_block_rrbp_valid(dl_block)) {
+ /* Don't transmit DL ACK here on purpose ignore it */
break;
}
+ }
+
+ /* PCU starts whole process again */
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
+ f_sleep(X2002);
- /* 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}});
+ /* Recv DL data until receiving RRBP to DL ACK (because it's last queued
+ /* DL data), after that we receive only DUMMY blocks so we are done */
+ var boolean data_received := false;
+ nr := ts_TsTrxBtsNum;
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+ alt {
+ [data_received] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ tr_RLCMAC_DL_DUMMY_CTRL)) { /* done */ }
+ [] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ tr_RLCMAC_DATA)) -> value data_msg {
+ data_received := true;
+ f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, data_msg.dl_block);
+ if (data_msg.dl_block.data.mac_hdr.hdr_ext.fbi) {
+ log("Received FINAL_ACK");
+ ms.dl_tbf.acknack_desc.final_ack := '1'B;
+ }
+ if (f_dl_block_rrbp_valid(data_msg.dl_block)) {
+ f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc),
+ f_dl_block_ack_fn(dl_block, data_msg.raw.fn));
+ }
+ nr := ts_TsTrxBtsNum;
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+ repeat;
+ }
+ [] BTS.receive {
+ setverdict(fail, "Unexpected BTS message");
+ f_shutdown(__BFILE__, __LINE__);
}
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* OS#5508: Verify scheduling of LLC frames with SAPI=1 (GMM) takes precedence
+ * over SAPI2/7/8 which in turn take prececende over others */
+testcase TC_dl_llc_sapi_priority() runs on RAW_PCU_Test_CT {
+ var octetstring data_sapi1 := f_pad_oct('01'O, 19, 'ff'O);
+ var octetstring data_sapi2 := f_pad_oct('02'O, 19, 'ff'O);
+ var octetstring data_sapi7 := f_pad_oct('07'O, 19, 'ff'O);
+ var octetstring data_sapi8 := f_pad_oct('08'O, 19, 'ff'O);
+ var octetstring data_sapi_other := f_pad_oct('03'O, 19, 'ff'O);
+ var RlcmacDlBlock dl_block;
+ var uint32_t dl_fn;
+ var GprsMS ms;
+ var integer state := 1;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+
+ /* Lock to CS1 to keep same DL RLCMAC data block size: */
+ g_cs_initial_dl := 1;
+ g_mcs_max_dl := 1;
+ f_pcuvty_set_allowed_cs_mcs();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* SGSN sends some low prio DL data, PCU will page on CCCH (PCH) */
+ for (var integer i := 0; i < 10; i := i + 1) {
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data_sapi_other, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ }
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data_sapi2, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data_sapi7, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data_sapi8, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data_sapi1, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS */
+ f_sleep(X2002);
+
+ while (state != 0) {
+ var OCT1 rx_sapi;
+ f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, ?, ?);
+ rx_sapi := dl_block.data.blocks[0].payload[0];
+
+ select (state) {
+ case(1) { /* We expect the first GMM LLC frame here (SAPI=1, highest prio) */
+ if (rx_sapi != '01'O) {
+ setverdict(fail, "Wrong prio: Expected LLC SAPI 1 (GMM) but got ", rx_sapi);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ state := 2;
+ }
+ case(2) { /* We expect the second LLC frame here (SAPI=2, middle prio) */
+ if (rx_sapi != '02'O) {
+ setverdict(fail, "Wrong prio: Expected LLC SAPI 2 but got ", rx_sapi);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ state := 7;
+ }
+ case(7) { /* We expect the third LLC frame here (SAPI=7, middle prio) */
+ if (rx_sapi != '07'O) {
+ setverdict(fail, "Wrong prio: Expected LLC SAPI 7 but got ", rx_sapi);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ state := 8;
+ }
+ case(8) { /* We expect the fourth LLC frame here (SAPI=8, middle prio) */
+ if (rx_sapi != '08'O) {
+ setverdict(fail, "Wrong prio: Expected LLC SAPI 8 but got ", rx_sapi);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ state := 3;
+ }
+ case(3) { /* We expect the other LLC frame here (SAPI=3, lower prio) */
+ if (rx_sapi != '03'O) {
+ setverdict(fail, "Wrong prio: Expected LLC SAPI 3 but got ", rx_sapi);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ state := 0; /* Done, break */
+ }
+ }
+ /* Keep Ack/Nack description updated (except for last BSN) */
+ f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block);
+
+ if (f_dl_block_rrbp_valid(dl_block)) {
+ f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc),
+ f_dl_block_ack_fn(dl_block, dl_fn));
+ }
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Verify allocation and use of multislot tbf, triggered by MS class provided in SGSN. SYS#5131 */
+testcase TC_dl_multislot_tbf_ms_class_from_sgsn() runs on RAW_PCU_Test_CT {
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+ var octetstring data := f_rnd_octstring(10);
+ var PacketDlAssign dl_tbf_ass;
+ var RlcmacDlBlock dl_block;
+ var uint32_t poll_fn;
+ var uint32_t dl_fn;
+ var uint32_t sched_fn;
+ var GprsMS ms;
+ timer T := 5.0;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Only 1 TRX with 8 PDCH */
+ f_PCUIF_PDCHMask_set(info_ind, '11111111'B, 0);
+ f_PCUIF_PDCHMask_set(info_ind, '00000000'B, (1 .. 7));
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Establish an Uplink TBF, this way the PCU can send DL Assignment
+ through PDCH (no multiblock assignment possible through PCH) */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ dl_fn := f_ms_wait_usf(ms, nr := f_ms_tx_TsTrxBtsNum(ms));
+ sched_fn := f_next_pdch_block(dl_fn);
+
+ /* Send one UL block (with TLLI since we are in One-Phase Access
+ contention resolution) and make sure it is ACKED fine */
+ f_ms_tx_ul_data_block(ms, data, with_tlli := true, fn := sched_fn,
+ nr := f_ms_tx_TsTrxBtsNum(ms));
+ /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, poll_fn, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* SGSN sends some DL data, PCU will assign DL TBF through PACCH */
+ var MultislotCap_GPRS_BSSGP mscap_gprs := {
+ gprsmultislotclass := '10010'B, /* MS class 18, supports 8 DL and 8 UL */
+ gprsextendeddynalloccap := '0'B
+ };
+ var MSRadioAccessCapabilityV_BSSGP ms_racap := { valueof(ts_RaCapRec_BSSGP('0001'B /* E-GSM */, mscap_gprs, omit)) };
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, ms_racap));
+ dl_block := f_ms_rx_pkt_ass_pacch(ms, sched_fn, tr_RLCMAC_DL_PACKET_ASS, nr := f_ms_tx_TsTrxBtsNum(ms));
+ if (f_dltbf_num_slots(ms.dl_tbf) != 8) {
+ setverdict(fail, "Expected 8 PDCH slots allocated but got ", f_dltbf_num_slots(ms.dl_tbf));
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Test DL TBF assignment over PACCH if Multislot class is unknown both at PCU
+ * and SGSN (eg. because MS started 1-phase access and SGSN answered back).
+ * Since the msclass is unknown, it shouldn't assign multiple timeslots since
+ * the MS may not support it. Related OS#6118. */
+testcase TC_dl_multislot_tbf_ms_class_unknown() runs on RAW_PCU_Test_CT
+{
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+ var RlcmacDlBlock dl_block;
+ var octetstring payload;
+ var template (value) LlcBlockHdr blk_hdr;
+ var template (value) LlcBlocks blocks;
+ var uint32_t sched_fn;
+ var uint32_t dl_fn;
+ var template RlcmacDlBlock acknack_tmpl;
+ var GprsMS ms;
+ var octetstring data := f_rnd_octstring(10);
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+
+ /* Only 1 TRX with 8 PDCH */
+ f_PCUIF_PDCHMask_set(info_ind, '11111111'B, 0);
+ f_PCUIF_PDCHMask_set(info_ind, '00000000'B, (1 .. 7));
+
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Establish an Uplink TBF. 1 TS is assigned over AGCH. */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ dl_fn := f_ms_wait_usf(ms, nr := f_ms_tx_TsTrxBtsNum(ms));
+ sched_fn := f_next_pdch_block(dl_fn);
+
+ /* Send one UL block (with TLLI since we are in One-Phase Access
+ * contention resolution) and make sure it is ACKED fine. */
+ payload := f_rnd_octstring(16); /* 16 bytes fills the llc block (because TLLI takes 4 bytes) */
+ blk_hdr := t_RLCMAC_LLCBLOCK_HDR(length_ind := lengthof(payload),
+ more := false, e := true);
+ blocks := { t_RLCMAC_LLCBLOCK(payload, blk_hdr) };
+ /* Set CV = 15 to signal there's still more than BS_CV_MAX blocks to be sent */
+ f_ms_tx_ul_data_blocks_gprs(ms, blocks, cv := 15, with_tlli := true, fn := sched_fn, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* UL block should be received in SGSN */
+ BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id));
+
+ acknack_tmpl := tr_RLCMAC_UL_ACK_NACK_GPRS(ms.ul_tbf.tfi,
+ tr_UlAckNackGprs(ms.tlli,
+ tr_AckNackDescription(final_ack := '0'B)))
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn, acknack_tmpl, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, racap := omit));
+ dl_block := f_ms_rx_pkt_ass_pacch(ms, sched_fn, tr_RLCMAC_DL_PACKET_ASS, nr := f_ms_tx_TsTrxBtsNum(ms));
+ if (f_dltbf_num_slots(ms.dl_tbf) != 1) {
+ setverdict(fail, "Expected 1 PDCH slots allocated but got ", f_dltbf_num_slots(ms.dl_tbf));
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+testcase TC_dl_multislot_tbf_ms_class_from_2phase() runs on RAW_PCU_Test_CT {
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+ var RlcmacDlBlock dl_block;
+ var octetstring data := f_rnd_octstring(10);
+ var PollFnCtx pollctx;
+ var uint32_t sched_fn;
+ var GprsMS ms;
+
+ var MultislotCap_GPRS mscap_gprs := {
+ gprsmultislotclass := '10010'B, /* MS class 18, supports 8 DL and 8 UL */
+ gprsextendeddynalloccap := '0'B
+ };
+ var MSRadioAccessCapabilityV ms_racap := { valueof(ts_RaCapRec('0001'B /* E-GSM */, mscap_gprs, omit)) };
+
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Only 1 TRX with 8 PDCH */
+ f_PCUIF_PDCHMask_set(info_ind, '11111111'B, 0);
+ f_PCUIF_PDCHMask_set(info_ind, '00000000'B, (1 .. 7));
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Send PACKET RESOURCE REQUEST to notify the MultiSlot Class */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap));
+
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data));
+ dl_block := f_ms_rx_pkt_ass_pacch(ms, sched_fn, tr_RLCMAC_DL_PACKET_ASS, nr := f_ms_tx_TsTrxBtsNum(ms));
+ if (f_dltbf_num_slots(ms.dl_tbf) != 8) {
+ setverdict(fail, "Expected 8 PDCH slot allocated but got ", f_dltbf_num_slots(ms.dl_tbf));
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+testcase TC_ul_multislot_tbf_ms_class_from_2phase() runs on RAW_PCU_Test_CT {
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default);
+ var RlcmacDlBlock dl_block;
+ var octetstring data := f_rnd_octstring(10);
+ var PollFnCtx pollctx;
+ var uint32_t sched_fn;
+ var GprsMS ms;
+
+ var MultislotCap_GPRS mscap_gprs := {
+ gprsmultislotclass := '10010'B, /* MS class 18, supports 8 DL and 8 UL */
+ gprsextendeddynalloccap := '0'B
+ };
+ var MSRadioAccessCapabilityV ms_racap := { valueof(ts_RaCapRec('0001'B /* E-GSM */, mscap_gprs, omit)) };
+
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Only 1 TRX with 8 PDCH */
+ f_PCUIF_PDCHMask_set(info_ind, '11111111'B, 0);
+ f_PCUIF_PDCHMask_set(info_ind, '00000000'B, (1 .. 7));
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Send PACKET RESOURCE REQUEST to notify the MultiSlot Class */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap));
+
+ if (f_ultbf_num_slots(ms.ul_tbf) != 8) {
+ setverdict(fail, "Expected 8 PDCH slot allocated but got ", f_ultbf_num_slots(ms.ul_tbf));
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Test scenario where MS wants to request a new TBF once the current one is
+ * ending, by means of sending a Packet Resource Request on ul slot provided by
+ * last Pkt Ul ACK's RRBP.
+ * See 3GPP TS 44.060 sec 9.3.2.4.2 "Non-extended uplink TBF mode" */
+testcase TC_ul_tbf_reestablish_with_pkt_resource_req() runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var octetstring data := f_rnd_octstring(10);
+ var uint32_t sched_fn;
+ var uint32_t dl_fn;
+ var template RlcmacDlBlock acknack_tmpl;
+ var GprsMS ms;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
+ f_statsd_reset();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ f_ms_wait_usf(ms);
+
+ /* Send one UL block (with TLLI since we are in One-Phase Access
+ contention resolution) and make sure it is ACKED fine */
+ f_ms_tx_ul_data_block_multi(ms, 1, with_tlli := true, fn := ms.ul_tbf.start_time_fn);
+
+ /* UL block should be received in SGSN */
+ BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id));
+
+ acknack_tmpl := tr_RLCMAC_UL_ACK_NACK_GPRS(ms.ul_tbf.tfi,
+ tr_UlAckNackGprs(ms.tlli,
+ tr_AckNackDescription(final_ack := '1'B),
+ tr_UlAckNackGprsAdditionsRel99(tbf_est := true)))
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn, acknack_tmpl);
+
+ /* TODO: verify TBF_EST and FinalACK are both '1' above */
+
+ /* Send PACKET RESOURCE REQUEST to request a new UL TBF */
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, omit)), sched_fn);
+ f_ms_rx_pkt_ass_pacch(ms, sched_fn, tr_RLCMAC_UL_PACKET_ASS);
+ /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+
+ /* Send one UL block (without TLLI since we are in Second-Phase Access)
+ and make sure it is ACKED fine */
+ f_ms_tx_ul_data_block_multi(ms, 1, with_tlli := false); /* TODO: send using cs_mcs */
+
+ /* UL block should be received in SGSN */
+ BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id));
+
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn, acknack_tmpl);
+ /* ACK the ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+
+ var StatsDExpects expect := {
+ { name := "TTCN3.bts.0.rach.requests", mtype := "c", min := 1, max := 1 },
+ { name := "TTCN3.bts.0.rach.requests.11bit", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.rach.requests.one_phase", mtype := "c", min := 1, max := 1 },
+ { name := "TTCN3.bts.0.rach.requests.two_phase", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.immediate.assignment_UL", mtype := "c", min := 1, max := 1 },
+ { name := "TTCN3.bts.0.immediate.assignment_ul.one_phase", mtype := "c", min := 1, max := 1 },
+ { name := "TTCN3.bts.0.immediate.assignment_ul.two_phase", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.immediate.assignment_ul.contention_resolution_success", mtype := "c", min := 1, max := 1 },
+ { name := "TTCN3.bts.0.immediate.assignment_DL", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.pkt.ul_assignment", mtype := "c", min := 1, max := 1 }
+ };
+ f_statsd_expect(expect);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Test scenario where MS wants to request a new TBF once the current one is
+ * ending, by means of sending a Packet Resource Request on ul slot provided by
+ * last Pkt Ul ACK's RRBP. new Pkt Ul Ass is never confirmed by the MS in this test.
+ * See 3GPP TS 44.060 sec 9.3.2.4.2 "Non-extended uplink TBF mode" */
+testcase TC_ul_tbf_reestablish_with_pkt_resource_req_t3168() runs on RAW_PCU_Test_CT {
+ var PCUIF_info_ind info_ind;
+ var RlcmacDlBlock dl_block;
+ var octetstring data := f_rnd_octstring(10);
+ var uint32_t sched_fn;
+ var uint32_t dl_fn;
+ var template (value) TsTrxBtsNum nr;
+ var BTS_PDTCH_Block data_msg;
+ var template RlcmacDlBlock acknack_tmpl;
+ var GprsMS ms;
+ var integer cnt_rrbp := 0;
+ var integer cnt_dummy_after_timeout := 0;
+ /* Maximum T3168 value = 8 * 500 ms = 4s => * 4 retrans = 16s */
+ timer T_3168 := 16.0 + 0.5; /* 0.5: extra offset since we cannot match exactly */
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ info_ind := valueof(ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+ /* TODO: Speedup test by sending a PCU_IF_SAPI_BCCH SI13 with T3168=0 (500ms) */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ f_ms_wait_usf(ms);
+
+ /* Send one UL block (with TLLI since we are in One-Phase Access
+ contention resolution) and make sure it is ACKED fine */
+ f_ms_tx_ul_data_block_multi(ms, 1, with_tlli := true, fn := ms.ul_tbf.start_time_fn);
+
+ /* UL block should be received in SGSN */
+ BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id));
+
+ acknack_tmpl := tr_RLCMAC_UL_ACK_NACK_GPRS(ms.ul_tbf.tfi,
+ tr_UlAckNackGprs(ms.tlli,
+ tr_AckNackDescription(final_ack := '1'B),
+ tr_UlAckNackGprsAdditionsRel99(tbf_est := true)))
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn, acknack_tmpl);
+
+ /* TODO: verify TBF_EST and FinalACK are both '1' above */
+
+ /* Send PACKET RESOURCE REQUEST to request a new UL TBF */
+ T_3168.start;
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, omit)), sched_fn);
+
+ /* Now Keep ignoring the Pkt Ul Ass on PACCH: */
+ /* Now we go on receiving DL data and not answering RRBP: */
+ nr := ts_TsTrxBtsNum;
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
alt {
- [] L1.receive(RLCMAC_ph_data_ind:{cs:=?, ts_nr:=?, fn:=?, block:=tr_RLCMAC_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;
+ [] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ tr_RLCMAC_UL_PACKET_ASS)) -> value data_msg {
+ /* We should not be receiving PKT UL ASS anymore after T3168 timeout */
+ if (not T_3168.running) {
+ setverdict(fail, log2str("Unexpected PKT UL ASS after T3168 timeout: ", data_msg));
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ if (f_dl_block_rrbp_valid(data_msg.dl_block)) {
+ log("Ignoring RRBP ", cnt_rrbp);
+ cnt_rrbp := cnt_rrbp + 1;
}
+ nr := ts_TsTrxBtsNum;
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+ repeat;
+ }
+ [] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ tr_RLCMAC_DL_DUMMY_CTRL)) -> value data_msg {
+ nr := ts_TsTrxBtsNum;
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+ repeat;
+ }
+ [] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ omit)) -> value data_msg {
+
+ /* T3168 expired and we are not receiving blocks anymore, meaning PCU released the TBF. */
+ break;
+ }
+ [] BTS.receive {
+ setverdict(fail, "Unexpected BTS message");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ }
+
+ /* Check that we received at least a few PKT UL ASS before T3168 expiration */
+ if (cnt_rrbp <= 3) {
+ setverdict(fail, log2str("Received only ", cnt_rrbp, " before T3168 timeout!"));
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Test scenario where MS wants to request a new UL TBF using a DL (EGPRS) ACK/NACK
+ * transmitted on ul slot provided by its DL TBF.
+ * See 3GPP TS 44.060 sec 9.3.2.4.2 "Non-extended uplink TBF mode" */
+function f_TC_ul_tbf_reestablish_with_pkt_dl_ack_nack(boolean use_egprs) runs on RAW_PCU_Test_CT {
+ var GprsMS ms;
+ var octetstring data := f_rnd_octstring(10);
+ var RlcmacDlBlock dl_block;
+ var template RlcmacDlBlock rej_tmpl;
+ var uint32_t dl_fn;
+ var uint32_t sched_fn;
+ var template (value) MSRadioAccessCapabilityV_BSSGP racap_tmpl;
+
+ if (use_egprs == true) {
+ racap_tmpl := bssgp_ms_racap_egprs_def;
+ } else {
+ racap_tmpl := bssgp_ms_racap_gprs_def;
+ }
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* SGSN sends some DL data, PCU will page on CCCH (PCH) */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, racap_tmpl, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
+ f_sleep(X2002);
+ f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0);
+
+ /* ACK the DL block, asking for new UL TBF by including ChanReqDesc */
+ f_dltbf_ack_block(ms.dl_tbf, dl_block, '1'B);
+ f_ms_tx_ul_block(ms, f_dltbf_ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf, use_egprs, ts_ChannelReqDescription()),
+ f_dl_block_ack_fn(dl_block, dl_fn));
+
+ /* We should receive a Pkt Ul ASS */
+ f_ms_rx_pkt_ass_pacch(ms, sched_fn, tr_RLCMAC_UL_PACKET_ASS);
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+testcase TC_ul_tbf_reestablish_with_pkt_dl_ack_nack() runs on RAW_PCU_Test_CT {
+ f_TC_ul_tbf_reestablish_with_pkt_dl_ack_nack(false);
+}
+testcase TC_ul_tbf_reestablish_with_pkt_dl_ack_nack_egprs() runs on RAW_PCU_Test_CT {
+ f_TC_ul_tbf_reestablish_with_pkt_dl_ack_nack(true);
+}
+
+/* Test UL data blocks BSN 0..127 and then continue again at BSN 0... up to 300
+ * BSNs in total to test several wrap arounds. */
+testcase TC_ul_tbf_bsn_wraparound_gprs() runs on RAW_PCU_Test_CT
+{
+ var PCUIF_info_ind info_ind;
+ var RlcmacDlBlock dl_block;
+ var octetstring payload;
+ var template (value) LlcBlockHdr blk_hdr;
+ var template (value) LlcBlocks blocks;
+ var uint32_t sched_fn;
+ var uint32_t dl_fn;
+ var template (value) TsTrxBtsNum nr;
+ var BTS_PDTCH_Block data_msg;
+ var template RlcmacDlBlock acknack_tmpl;
+ var GprsMS ms;
+ var integer blocks_sent := 0;
+ var integer blocks_received := 0;
+ const integer target_bsn_set := 300;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ info_ind := valueof(ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+ f_init_raw(testcasename(), info_ind);
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ dl_fn := f_ms_wait_usf(ms);
+ sched_fn := f_next_pdch_block(dl_fn);
+
+ /* Send one UL block (with TLLI since we are in One-Phase Access
+ contention resolution) and make sure it is ACKED fine. */
+ payload := f_rnd_octstring(16); /* 16 bytes fills the llc block (because TLLI takes 4 bytes) */
+ blk_hdr := t_RLCMAC_LLCBLOCK_HDR(length_ind := lengthof(payload),
+ more := false, e := true);
+ blocks := { t_RLCMAC_LLCBLOCK(payload, blk_hdr) };
+ /* Set CV = 15 to signal there's still more than BS_CV_MAX blocks to be sent */
+ f_ms_tx_ul_data_blocks_gprs(ms, blocks, cv := 15, with_tlli := true, fn := sched_fn);
+ blocks_sent := blocks_sent + 1;
+
+ /* UL block should be received in SGSN */
+ BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id));
+
+ acknack_tmpl := tr_RLCMAC_UL_ACK_NACK_GPRS(ms.ul_tbf.tfi,
+ tr_UlAckNackGprs(ms.tlli,
+ tr_AckNackDescription(final_ack := '0'B)))
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn, acknack_tmpl);
+
+ nr := f_ms_tx_TsTrxBtsNum(ms);
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+ alt {
+ [] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ tr_RLCMAC_UL_ACK_NACK_GPRS)) -> value data_msg {
+
+ if (f_dl_block_rrbp_valid(data_msg.dl_block)) {
+ var uint32_t ack_fn := f_dl_block_ack_fn(data_msg.dl_block, data_msg.raw.fn)
+ log("ACKING FN ", data_msg.raw.fn, " on FN ", ack_fn);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), ack_fn);
+ }
+ f_ms_tx_ul_data_blocks_gprs(ms, blocks);
+ blocks_sent := blocks_sent + 1;
+
+ if (blocks_sent == target_bsn_set) {
+ break;
+ }
+
+ nr := f_ms_tx_TsTrxBtsNum(ms);
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+ repeat;
+ }
+ [] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ tr_RLCMAC_DL_DUMMY_CTRL)) -> value data_msg {
+
+ f_ms_tx_ul_data_blocks_gprs(ms, blocks);
+ blocks_sent := blocks_sent + 1;
+
+ if (blocks_sent == target_bsn_set) {
+ break;
}
- [] L1.receive { repeat; }
+
+ nr := f_ms_tx_TsTrxBtsNum(ms);
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+ repeat;
+ }
+ [] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ omit)) -> value data_msg {
+ nr := f_ms_tx_TsTrxBtsNum(ms);
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)),
+ block_nr := nr.blk_nr));
+ repeat;
+ }
+ [] BTS.receive {
+ setverdict(fail, "Unexpected BTS message");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ [] BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id)) {
+ blocks_received := blocks_received + 1;
+ 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]));
+ /* Validate most part of them were accepted and forwarded: */
+ if (blocks_received < target_bsn_set * 95 / 100) {
+ setverdict(fail, "Forwarded ", blocks_received, " out of ", target_bsn_set, " transmitted");
+ f_shutdown(__BFILE__, __LINE__);
}
- setverdict(pass);
+ log("Forwarded ", blocks_received, " out of ", target_bsn_set, " transmitted");
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Test CS paging over the BTS<->PCU socket.
+ * When a (class B or C, not A) MS has an active TBF (or is on the PDCH), the MS can not react on CS paging over CCCH.
+ * Paging should be send on the PACCH.
+ *
+ * 1. Send a Paging Request over PCU socket.
+ * 2. Send a Ready-To-Send message over PCU socket
+ * 3. Expect a Paging Frame
+ */
+testcase TC_paging_cs_from_bts() runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var MobileIdentityLV mi;
+ var octetstring mi_enc_lv;
+ var hexstring imsi := f_gen_imsi(42);
+ var GprsMS ms;
- L1.send(DCCH_release_req:{});
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ f_ms_wait_usf(ms);
+
+ /* build mobile Identity */
+ mi := valueof(ts_MI_IMSI_LV(imsi));
+ mi_enc_lv := enc_MobileIdentityLV(mi);
+ /* Send paging request */
+ BTS.send(ts_PCUIF_PAG_REQ(bts_nr := 0, id_lv := mi_enc_lv, chan_needed := 0,
+ sapi :=PCU_IF_SAPI_PDTCH));
+
+ /* Receive it on BTS side towards MS */
+ f_rx_rlcmac_dl_block_exp_pkt_pag_req(dl_block);
+
+ /* Make sure that Packet Paging Request contains the same IMSI */
+ var PacketPagingReq req := dl_block.ctrl.payload.u.paging;
+ if (not f_pkt_paging_match_imsi(req, imsi, ps_domain := false)) {
+ setverdict(fail, "Failed to match IMSI ", imsi, " in ", req);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
}
-testcase TC_rach() runs on dummy_CT {
- var BssgpBvci bvci := 196;
- g_mmctx.imsi := '262420123456789'H;
- g_mmctx.tlli := f_random_tlli();
+/* Test CS paging over Gb (SGSN->PCU->BTS[PDCH]).
+ */
+private function f_tc_paging_cs_from_sgsn(Nsvci bvci, boolean use_ptmsi := false)
+runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var hexstring imsi := f_gen_imsi(42);
+ var GsmTmsi tmsi;
+ var GprsMS ms;
- f_init();
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
- f_bssgp_client_register(g_mmctx.imsi, g_mmctx.tlli, mp_gb_cfg.cell_id);
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+ /* Establish BSSGP connection to the PCU */
f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ f_ms_wait_usf(ms);
+
+ /* Send paging request with or without TMSI */
+ if (use_ptmsi) {
+ tmsi := oct2int(f_rnd_octstring(4)); /* Random P-TMSI */
+ BSSGP[0].send(ts_BSSGP_CS_PAGING_PTMSI(bvci, imsi, tmsi));
+ } else {
+ BSSGP[0].send(ts_BSSGP_CS_PAGING_IMSI(bvci, imsi));
+ }
+
+ /* Now receive it on BTS side towards MS.
+ * Skip any dummy blocks in case the PCUIF req arrives before the BSSP CS_PAGING:
+ */
+ f_rx_rlcmac_dl_block_skip_dummy(dl_block, max_dummy := 10);
+
+ if (not match(dl_block, tr_RLCMAC_PACKET_PAG_REQ())) {
+ setverdict(fail, "Failed to match Packet Paging Request: ",
+ dl_block, " vs ", tr_RLCMAC_PACKET_PAG_REQ());
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ /* Make sure that Packet Paging Request contains the same P-TMSI/IMSI */
+ var PacketPagingReq req := dl_block.ctrl.payload.u.paging;
+ if (use_ptmsi) {
+ if (not f_pkt_paging_match_tmsi(req, tmsi, ps_domain := false)) {
+ setverdict(fail, "Failed to match P-TMSI ", tmsi, " in ", req);
+ }
+ } else {
+ if (not f_pkt_paging_match_imsi(req, imsi, ps_domain := false)) {
+ setverdict(fail, "Failed to match IMSI ", imsi, " in ", req);
+ }
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
}
+testcase TC_paging_cs_from_sgsn_sign_ptmsi() runs on RAW_PCU_Test_CT {
+ f_tc_paging_cs_from_sgsn(0, true);
+}
+testcase TC_paging_cs_from_sgsn_sign() runs on RAW_PCU_Test_CT {
+ f_tc_paging_cs_from_sgsn(0);
+}
-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);
+testcase TC_paging_cs_from_sgsn_ptp() runs on RAW_PCU_Test_CT {
+ f_tc_paging_cs_from_sgsn(mp_gb_cfg.bvc[0].bvci);
}
-function f_llc_assert(in octetstring a, in octetstring b) {
- log("LLC Input: ", a);
- log("LLC Expected: ", b);
+/* Test PS paging over Gb (SGSN->PCU->BTS[CCCH]).
+ */
+private function f_tc_paging_ps_from_sgsn(Nsvci bvci, boolean use_ptmsi := false)
+runs on RAW_PCU_Test_CT {
+ var integer imsi_suff_tx := 423;
+ var hexstring imsi := f_gen_imsi(imsi_suff_tx);
+ var GprsMS ms;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
- if (a != b) {
- setverdict(fail, "LLC input ", b, " != expected ", a);
- mtc.stop;
+ f_statsd_reset();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Send BSSGP PAGING-PS (with or without TMSI), wait for RR Paging Request Type 1.
+ * Make sure that both paging group (IMSI suffix) and Mobile Identity match. */
+ if (use_ptmsi) {
+ var OCT4 tmsi := f_rnd_octstring(4); /* Random P-TMSI */
+ BSSGP[0].send(ts_BSSGP_PS_PAGING_PTMSI(bvci, imsi, oct2int(tmsi)));
+ f_pcuif_rx_pch_pag_req1(t_MI_TMSI(tmsi), imsi_suff_tx);
} else {
- setverdict(pass);
+ BSSGP[0].send(ts_BSSGP_PS_PAGING_IMSI(bvci, imsi));
+ f_pcuif_rx_pch_pag_req1(tr_MI_IMSI(imsi), imsi_suff_tx);
}
+
+ var StatsDExpects expect := {
+ { name := "TTCN3.pcu.sgsn.0.rx_paging_ps", mtype := "c", min := 1, max := 1 },
+ /* After the PCU receives the paging request from SGSN,
+ * and it doesn't have any errors, PCU sends it to the
+ * BTS to do paging over PCH. */
+ { name := "TTCN3.bts.0.pch.requests", mtype := "c", min := 1, max := 1 }
+ };
+ f_statsd_expect(expect);
+}
+
+testcase TC_paging_ps_from_sgsn_sign_ptmsi() runs on RAW_PCU_Test_CT {
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
+
+ f_tc_paging_ps_from_sgsn(0, true);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+testcase TC_paging_ps_from_sgsn_sign() runs on RAW_PCU_Test_CT {
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
+
+ f_tc_paging_ps_from_sgsn(0);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+testcase TC_paging_ps_from_sgsn_ptp() runs on RAW_PCU_Test_CT {
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
+
+ f_tc_paging_ps_from_sgsn(mp_gb_cfg.bvc[0].bvci);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+testcase TC_paging_pch_timeout() runs on RAW_PCU_Test_CT {
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
+
+ /* Set T3113 to 1s to shorten the test duration */
+ f_vty_config2(PCUVTY, {"pcu"}, "timer T3113 1");
+
+ /* Reset stats and send paging PS request */
+ f_tc_paging_ps_from_sgsn(mp_gb_cfg.bvc[0].bvci);
+
+ /* Verify that counter increases when T3113 times out (MS did not start
+ * TBF to respond to paging). */
+ f_sleep(1.2);
+ var StatsDExpects expect := {
+ { name := "TTCN3.bts.0.pch.requests.timeout", mtype := "c", min := 1, max := 1 }
+ };
+ f_statsd_expect(expect);
+
+ f_vty_config2(PCUVTY, {"pcu"}, "timer T3113 default");
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Verify osmo-pcu handles DL UNIT_DATA from SGSN with IMSI IE correctly. See OS#4729 */
+testcase TC_bssgp_dl_unitdata_with_valid_imsi() runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var octetstring data := f_rnd_octstring(10);
+ var uint32_t sched_fn;
+ var uint32_t dl_fn;
+ var GprsMS ms;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+
+ f_statsd_reset();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ f_ms_wait_usf(ms);
+
+ /* Fake GMM GPRS Attach or similar, PCU doesn't care about upper layers here */
+ f_ms_tx_ul_data_block_multi(ms, 1, with_tlli := true, fn := ms.ul_tbf.start_time_fn);
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn);
+ /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+
+ /* UL block should be received in SGSN */
+ BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id));
+
+ /* Now SGSN sends some DL data, PCU will page on CCCH (PCH) */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
+ f_sleep(X2002);
+ f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0);
+
+ /* ACK the DL block */
+ f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block, '1'B);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc),
+ f_dl_block_ack_fn(dl_block, dl_fn));
+
+ var StatsDExpects expect := {
+ { name := "TTCN3.bts.0.rach.requests", mtype := "c", min := 1, max := 1},
+ { name := "TTCN3.bts.0.immediate.assignment_DL", mtype := "c", min := 1, max := 1},
+ { name := "TTCN3.bts.0.tbf.dl.alloc", mtype := "c", min := 1, max := 1},
+ { name := "TTCN3.bts.0.tbf.ul.alloc", mtype := "c", min := 1, max := 1},
+ { name := "TTCN3.bts.0.rlc.dl_payload_bytes", mtype := "c", min := 10, max := 10},
+ { name := "TTCN3.bts.0.rlc.ul_payload_bytes", mtype := "c", min := 26, max := 26}
+ };
+ f_statsd_expect(expect);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Verify osmo-pcu acts on incorrect IMSI IE content in DL UNIT_DATA from SGSN. See OS#4729 */
+testcase TC_bssgp_dl_unitdata_with_invalid_imsi() runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var octetstring data := f_rnd_octstring(10);
+ var uint32_t sched_fn;
+ var uint32_t dl_fn;
+ var GprsMS ms;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ f_ms_wait_usf(ms);
+
+ /* Fake GMM GPRS Attach or similar, PCU doesn't care about upper layers here */
+ f_ms_tx_ul_data_block_multi(ms, 1, with_tlli := true, fn := ms.ul_tbf.start_time_fn);
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn);
+ /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+
+ /* UL block should be received in SGSN */
+ BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id));
+
+ /* Now SGSN sends some DL data with an invalid IMSI */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, imsi := ts_BSSGP_IMSI('1122'H)));
+
+ BSSGP_GLOBAL[0].receive(tr_BSSGP_STATUS(omit, BSSGP_CAUSE_CONDITIONAL_IE_ERROR, ?));
+
+ /* TODO: make sure no data is sent over PCU -> MS */
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+private function f_tc_dl_data_no_llc_ui_dummy(template (omit) MSRadioAccessCapabilityV_BSSGP ms_racap := omit) runs on RAW_PCU_Test_CT {
+ var AckNackDescription ack_nack_desc := valueof(t_AckNackDescription_init);
+ var octetstring data := f_rnd_octstring(6);
+ var RlcmacDlBlock dl_block;
+ var GprsMS ms;
+ var uint32_t fn;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* SGSN sends some DL data, PCU will page on CCCH (PCH) */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, ms_racap, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS */
+ f_sleep(X2002);
+
+ /* Expect the first (GPRS DL) block with bsn=0 and rrbp_valid=1 */
+ f_rx_rlcmac_dl_block_exp_data(dl_block, fn, data, 0);
+
+ if (ischosen(dl_block.data_egprs)) {
+ if (lengthof(dl_block.data_egprs.blocks) != 2) {
+ setverdict(fail, "DL EGPRS block has unexpected number of LLC frames: ", dl_block.data_egprs);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ if (dl_block.data_egprs.blocks[1].hdr.length_ind != 127) {
+ setverdict(fail, "DL EGPRS block 2nd llc frame is not padding!: ", dl_block.data_egprs);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ if (not match(dl_block.data_egprs.blocks[1].payload,
+ f_pad_oct(''O, lengthof(dl_block.data_egprs.blocks[1].payload), '2B'O))) {
+ setverdict(fail, "DL EGPRS block 2nd llc frame is not padding!: ", dl_block.data_egprs);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ } else if (lengthof(dl_block.data.blocks) > 1) {
+ setverdict(fail, "DL GPRS block has extra unexpected LLC frames: ", dl_block.data);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Verify osmo-pcu Doesn't append LLC UI dummy frames to rlcmac blocks
+ * containing llc data. See OS#4849 */
+testcase TC_dl_gprs_data_no_llc_ui_dummy() runs on RAW_PCU_Test_CT {
+ f_tc_dl_data_no_llc_ui_dummy(omit);
+}
+
+/* Verify osmo-pcu Doesn't append LLC UI dummy frames to rlcmac blocks
+ * containing llc data. See OS#4849 */
+testcase TC_dl_egprs_data_no_llc_ui_dummy() runs on RAW_PCU_Test_CT {
+ f_tc_dl_data_no_llc_ui_dummy(bssgp_ms_racap_egprs_def);
+}
+
+/* Scenario: MS creates one phase access, does contention resolution CV>0 and
+ * finishes sending data (CV=0), which is forwarded to SGSN by PCU. PCU acks with
+ * FINAL_ACK=1 (hence UL TBF moves to FINISHED state). Then SGSN answers and PCU
+ * has to assign a DL TBF (through PCH because of FINISHED state, TS 44.060 9.3.3.3.2).
+ * Make sure the assignment is not done until we receive the PKT CTRL ACK from the MS
+ * (at that time we know the MS is listening on PCH again). OS#5700.
+ */
+testcase TC_ul_tbf_finished_pkt_dl_ass_pch() runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var octetstring data := f_rnd_octstring(10);
+ var uint32_t sched_fn;
+ var uint32_t dl_fn;
+ var GprsMS ms;
+ timer T;
+ var octetstring payload;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ f_ms_wait_usf(ms);
+
+ /* Send one UL block (with TLLI since we are in One-Phase Access
+ contention resolution) and make sure it is ACKED fine. */
+ payload := f_rnd_octstring(f_ultbf_payload_fill_length(ms.ul_tbf, true));
+ dl_fn := f_rx_rlcmac_dl_block_exp_dummy(dl_block);
+ f_ms_tx_ul_data_block(ms, payload, cv := 1, with_tlli := true, fn := f_next_pdch_block(dl_fn));
+
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn);
+ payload := f_rnd_octstring(f_ultbf_payload_fill_length(ms.ul_tbf, false));
+ f_ms_tx_ul_data_block(ms, payload, cv := 0);
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn);
+
+ /* 1 UL block should be received in SGSN */
+ BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id));
+ /* Now SGSN sends some DL data, PCU will page on CCCH (PCH) */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, imsi := ts_BSSGP_IMSI(ms.imsi)));
+
+ /* UL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */
+ f_sleep(X2002);
+ f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
}
+/* Scenario: MS creates a UL TBF and
+ * finishes sending data (CV=0), which is forwarded to SGSN by PCU. PCU acks with
+ * FINAL_ACK=1 (hence UL TBF moves to FINISHED state). Then SGSN answers and PCU
+ * has to assign a DL TBF on PCH. While the network is waiting for the MS to
+ * move to PDCH before transmitting DL data (timer X2002), the MS finds out it
+ * needs to send new UL data and hence sends a RACH request to create a new UL
+ * TBF.
+ * Make sure the the MS is assigned a DL TBF through PACCH in that case even if
+ * no new DL data is received from the SGSN. OS#5700.
+ * This test validates the specific case where the 2nd UL TBF is done through
+ * 1phase-access.
+ */
+testcase TC_ul_tbf_1phase_while_dl_ass_pch() runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var octetstring data := f_rnd_octstring(10);
+ var uint32_t sched_fn;
+ var uint32_t poll_fn;
+ var uint32_t dl_fn;
+ var GprsMS ms;
+ timer T;
+ var octetstring payload;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ f_ms_wait_usf(ms);
+
+ /* Send one UL block (with TLLI since we are in One-Phase Access
+ contention resolution) and make sure it is ACKED fine. */
+ payload := f_rnd_octstring(f_ultbf_payload_fill_length(ms.ul_tbf, true));
+ dl_fn := f_rx_rlcmac_dl_block_exp_dummy(dl_block);
+ f_ms_tx_ul_data_block(ms, payload, cv := 1, with_tlli := true, fn := f_next_pdch_block(dl_fn));
+
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn);
+ payload := f_rnd_octstring(f_ultbf_payload_fill_length(ms.ul_tbf, false));
+ f_ms_tx_ul_data_block(ms, payload, cv := 0);
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn);
+
+ /* 1 UL block should be received in SGSN */
+ BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id));
+ /* Now SGSN sends some DL data, PCU will page on CCCH (PCH) */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, imsi := ts_BSSGP_IMSI(ms.imsi)));
+
+ /* UL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ f_ms_exp_dl_tbf_ass_ccch(ms);
+
+ /* Now the PCU is waiting for the MS to move to PDCH in order to send data to it (timer X2002).
+ * The MS decides it want to send new Ul TBF so it send RACH req to ask for it: */
+ f_ms_establish_ul_tbf(ms);
-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;
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ dl_fn := f_ms_wait_usf(ms);
- f_llc_dec_and_log(c_gmm_att_pcu);
+ /* Send one UL block (with TLLI since we are in One-Phase Access
+ * contention resolution) and make sure it is ACKED fine. */
+ payload := f_rnd_octstring(f_ultbf_payload_fill_length(ms.ul_tbf, true));
+ f_ms_tx_ul_data_block(ms, payload, cv := 1, with_tlli := true, fn := f_next_pdch_block(dl_fn));
- //f_llc_assert(f_LLC_append_fcs(c_gmm_att_pcu_nofcs), c_gmm_att_pcu);
+ /* UL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn);
- 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));
+ /* The PCU considers the MS to have gone over Contention Resolution
+ * after having sent the first UL ACK/NACK to it, hence next it will try to
+ * assign the DL-TBF to send the data it received from the SGSN previously: */
+ f_ms_rx_pkt_ass_pacch(ms, poll_fn, tr_RLCMAC_DL_PACKET_ASS);
+ /* the MS ACKs the PKT_DL_ASS: */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), poll_fn);
+
+ /* We should finally receive the DL-data that was received previously from the SGSN: */
+ f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
}
-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;
+/* Same as TC_ul_tbf_2phase_while_dl_ass_pch, but this test validates the
+ * specific case where the 2nd UL TBF is done through 2phase-access. */
+testcase TC_ul_tbf_2phase_while_dl_ass_pch() runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var octetstring data := f_rnd_octstring(10);
+ var uint32_t sched_fn;
+ var uint32_t poll_fn;
+ var uint32_t dl_fn;
+ var GprsMS ms;
+ timer T;
+ var octetstring payload;
+ var PollFnCtx pollctx;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
- log(c_dl_ul_ack_nack);
- dcb := dec_RlcmacDlCtrlBlock(c_dl_ul_ack_nack);
- log(dcb);
- //log(dec_RlcmacDlCtrlMsg(dcb.payload));
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ f_ms_wait_usf(ms);
- f_rlcmac_dld_decenc(c_dl_data);
+ /* Send one UL block (with TLLI since we are in One-Phase Access
+ contention resolution) and make sure it is ACKED fine. */
+ payload := f_rnd_octstring(f_ultbf_payload_fill_length(ms.ul_tbf, true));
+ dl_fn := f_rx_rlcmac_dl_block_exp_dummy(dl_block);
+ f_ms_tx_ul_data_block(ms, payload, cv := 1, with_tlli := true, fn := f_next_pdch_block(dl_fn));
- f_rlcmac_dld_decenc(c_dl_data2);
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn);
+ payload := f_rnd_octstring(f_ultbf_payload_fill_length(ms.ul_tbf, false));
+ f_ms_tx_ul_data_block(ms, payload, cv := 0);
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, sched_fn);
- log(c_ul_ctrl_ack);
- ucb := dec_RlcmacUlCtrlBlock(c_ul_ctrl_ack);
- log(ucb);
- //log(dec_RlcmacUlCtrlMsg(ucb.payload));
+ /* 1 UL block should be received in SGSN */
+ BSSGP[0].receive(tr_BSSGP_UL_UD(ms.tlli, mp_gb_cfg.bvc[0].cell_id));
+ /* Now SGSN sends some DL data, PCU will page on CCCH (PCH) */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, imsi := ts_BSSGP_IMSI(ms.imsi)));
- log(c_ul_dl_ack_nack);
- ucb := dec_RlcmacUlCtrlBlock(c_ul_dl_ack_nack);
- log(ucb);
- //log(dec_RlcmacUlCtrlMsg(ucb.payload));
+ /* UL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ f_ms_exp_dl_tbf_ass_ccch(ms);
- log(c_dl_ul_assign);
- dcb := dec_RlcmacDlCtrlBlock(c_dl_ul_assign);
- log(dcb);
- //log(dec_RlcmacDlCtrlMsg(dcb.payload));
+ /* Now the PCU is waiting for the MS to move to PDCH in order to send data to it (timer X2002).
+ * The MS decides it want to send new Ul TBF so it send RACH req to ask for it: */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap_gprs_def));
- const octetstring c_uld_tlli_noext := '080101a61cab5201c001080103e5e000310a0005f4e61cab5232f44000c8001d1b00'O;
- f_rlcmac_uld_decenc(c_uld_tlli_noext);
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts);
- 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);
+ /* Now that MS seized the UL-TBF, PCU sends DL-TBF Assignment on PACCH */
+ f_ms_rx_pkt_ass_pacch(ms, poll_fn, tr_RLCMAC_DL_PACKET_ASS);
+ /* the MS ACKs the PKT_DL_ASS: */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), poll_fn);
- f_rlcmac_ul_decenc(c_ul_dl_ack_nack);
+ /* We should finally receive the DL-data that was received previously from the SGSN: */
+ f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
}
-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;
+private function f_TC_egprs_pkt_chan_req(in EGPRSPktChRequest req,
+ template GsmRrMessage t_imm_ass := ?,
+ PCUIF_BurstType bt := BURST_TYPE_1)
+runs on RAW_PCU_Test_CT {
+ var GsmRrMessage rr_msg;
+ var uint16_t ra11;
+
+ ra11 := enc_EGPRSPktChRequest2uint(req);
+ log("Sending EGPRS Packet Channel Request (", ra11, "): ", req);
+
+ rr_msg := f_pcuif_tx_rach_rx_imm_ass(ra := ra11, is_11bit := 1, burst_type := bt);
+ if (not match(rr_msg, t_imm_ass)) {
+ setverdict(fail, "Immediate Assignment does not match");
+ f_shutdown(__BFILE__, __LINE__);
}
+
+ setverdict(pass);
}
-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;
+testcase TC_egprs_pkt_chan_req_signalling() runs on RAW_PCU_Test_CT {
+ var template GsmRrMessage imm_ass;
+ var template IaRestOctets rest;
+ var template EgprsUlAss ul_ass;
+ const integer num_req := 6;
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
+ f_statsd_reset();
+
+ var EGPRSPktChRequest req := {
+ /* NOTE: other fields are set in the loop */
+ signalling := { tag := '110011'B }
+ };
+
+ for (var integer i := 0; i < num_req; i := i + 1) {
+ var BIT5 ext_ra := int2bit(f_rnd_int(32), 5);
+ req.signalling.random_bits := ext_ra;
+
+ /* For signalling, do we expect Multiblock UL TBF Assignment? */
+ ul_ass := tr_EgprsUlAssMultiblock(ext_ra := ext_ra);
+ rest := tr_IaRestOctets_EGPRSULAss(ul_ass);
+ imm_ass := tr_IMM_TBF_ASS(dl := false, rest := rest);
+
+ f_TC_egprs_pkt_chan_req(req, imm_ass);
}
+
+ var StatsDExpects expect := {
+ { name := "TTCN3.bts.0.rach.requests", mtype := "c", min := num_req, max := num_req },
+ { name := "TTCN3.bts.0.rach.requests.11bit", mtype := "c", min := num_req, max := num_req },
+ { name := "TTCN3.bts.0.rach.requests.one_phase", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.rach.requests.two_phase", mtype := "c", min := num_req, max := num_req },
+ { name := "TTCN3.bts.0.immediate.assignment_UL", mtype := "c", min := num_req, max := num_req },
+ { name := "TTCN3.bts.0.immediate.assignment_ul.one_phase", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.immediate.assignment_ul.two_phase", mtype := "c", min := num_req, max := num_req },
+ { name := "TTCN3.bts.0.immediate.assignment_ul.contention_resolution_success", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.immediate.assignment_DL", mtype := "c", min := 0, max := 0 }
+ };
+ f_statsd_expect(expect);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
}
-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_egprs_pkt_chan_req_one_phase() runs on RAW_PCU_Test_CT {
+ var template GsmRrMessage imm_ass;
+ var template IaRestOctets rest;
+ var template EgprsUlAss ul_ass;
+ const integer num_req := 6;
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
+ f_statsd_reset();
+
+ var EGPRSPktChRequest req := {
+ /* NOTE: other fields are set in the loop */
+ one_phase := { tag := '0'B }
+ };
+
+ for (var integer i := 0; i < num_req; i := i + 1) {
+ var BIT5 ext_ra := int2bit(f_rnd_int(32), 5);
+ var BIT5 mslot_class := int2bit(f_rnd_int(32), 5);
+ var BIT2 priority := substr(ext_ra, 0, 2);
+ var BIT3 rand := substr(ext_ra, 2, 3);
+
+ req.one_phase.multislot_class := mslot_class;
+ req.one_phase.priority := priority;
+ req.one_phase.random_bits := rand;
+
+ /* For one phase access, do we expect Dynamic UL TBF Assignment? */
+ ul_ass := tr_EgprsUlAssDynamic(ext_ra := ext_ra);
+ rest := tr_IaRestOctets_EGPRSULAss(ul_ass);
+ imm_ass := tr_IMM_TBF_ASS(dl := false, rest := rest);
+
+ f_TC_egprs_pkt_chan_req(req, imm_ass);
}
+
+ var StatsDExpects expect := {
+ { name := "TTCN3.bts.0.rach.requests", mtype := "c", min := num_req, max := num_req },
+ { name := "TTCN3.bts.0.rach.requests.11bit", mtype := "c", min := num_req, max := num_req },
+ { name := "TTCN3.bts.0.rach.requests.one_phase", mtype := "c", min := num_req, max := num_req },
+ { name := "TTCN3.bts.0.rach.requests.two_phase", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.immediate.assignment_UL", mtype := "c", min := num_req, max := num_req },
+ { name := "TTCN3.bts.0.immediate.assignment_ul.one_phase", mtype := "c", min := num_req, max := num_req },
+ { name := "TTCN3.bts.0.immediate.assignment_ul.two_phase", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.immediate.assignment_ul.contention_resolution_success", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.immediate.assignment_DL", mtype := "c", min := 0, max := 0 }
+ };
+ f_statsd_expect(expect);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
}
+testcase TC_egprs_pkt_chan_req_two_phase() runs on RAW_PCU_Test_CT {
+ var template GsmRrMessage imm_ass;
+ var template IaRestOctets rest;
+ var template EgprsUlAss ul_ass;
+ const integer num_req := 6;
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
+ f_statsd_reset();
+
+ var EGPRSPktChRequest req := {
+ /* NOTE: other fields are set in the loop */
+ two_phase := { tag := '110000'B }
+ };
+
+ for (var integer i := 0; i < num_req; i := i + 1) {
+ var BIT5 ext_ra := int2bit(f_rnd_int(32), 5);
+ var BIT2 priority := substr(ext_ra, 0, 2);
+ var BIT3 rand := substr(ext_ra, 2, 3);
+
+ req.two_phase.priority := priority;
+ req.two_phase.random_bits := rand;
-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));
+ /* For two phase access, do we expect Multiblock UL TBF Assignment? */
+ ul_ass := tr_EgprsUlAssMultiblock(ext_ra := ext_ra);
+ rest := tr_IaRestOctets_EGPRSULAss(ul_ass);
+ imm_ass := tr_IMM_TBF_ASS(dl := false, rest := rest);
- log(c_ia_tbf);
- log(dec_GsmRrMessage(c_ia_tbf));
+ f_TC_egprs_pkt_chan_req(req, imm_ass);
+ }
+
+ var StatsDExpects expect := {
+ { name := "TTCN3.bts.0.rach.requests", mtype := "c", min := num_req, max := num_req },
+ { name := "TTCN3.bts.0.rach.requests.11bit", mtype := "c", min := num_req, max := num_req },
+ { name := "TTCN3.bts.0.rach.requests.one_phase", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.rach.requests.two_phase", mtype := "c", min := num_req, max := num_req },
+ { name := "TTCN3.bts.0.immediate.assignment_UL", mtype := "c", min := num_req, max := num_req },
+ { name := "TTCN3.bts.0.immediate.assignment_ul.one_phase", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.immediate.assignment_ul.two_phase", mtype := "c", min := num_req, max := num_req },
+ { name := "TTCN3.bts.0.immediate.assignment_ul.contention_resolution_success", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.immediate.assignment_DL", mtype := "c", min := 0, max := 0 }
+ };
+ f_statsd_expect(expect);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
}
-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;
+private function f_TC_egprs_pkt_chan_req_reject(bitstring ra11, uint32_t fn,
+ template IARRestOctets rest := ?,
+ PCUIF_BurstType bt := BURST_TYPE_1,
+ template WaitIndication wi := ?)
+runs on RAW_PCU_Test_CT {
+ var template ReqRefWaitInd tr_ref;
+ var GsmRrMessage rr_msg;
+
+ /* Send RACH.ind with malformed EGPRS Packet Channel Request */
+ BTS.send(ts_PCUIF_RACH_IND(bts_nr := 0, trx_nr := 0, ts_nr := 0,
+ ra := bit2int(ra11), is_11bit := 1,
+ burst_type := bt, fn := fn,
+ arfcn := 871));
+
+ /* Abuse f_pcuif_rx_imm_ass(): wait for Immediate Assignment Reject */
+ rr_msg := f_pcuif_rx_imm_ass(t_imm_ass := tr_IMM_ASS_REJ);
+
+ /* Just to have a short-name reference to the actual message */
+ var ImmediateAssignmentReject iar := rr_msg.payload.imm_ass_rej;
+
+ /* Make sure that Request Reference list contains at least one entry
+ * with our TDMA frame number, and RA is set to 'reserved' value 127. */
+ tr_ref := tr_ReqRefWaitInd(f_compute_ReqRef(127, fn), wi);
+ if (not match(iar.payload, { *, tr_ref, * })) {
+ setverdict(fail, "Request Reference list does not match");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ /* Match Feature Indicator (must indicate PS domain) */
+ if (not match(iar.feature_ind, FeatureIndicator:{?, false, true})) {
+ setverdict(fail, "Feature Indicator does not match");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ /* Match IAR Rest Octets */
+ if (not match(iar.rest_octets, rest)) {
+ setverdict(fail, "IAR Rest Octets does not match: ",
+ iar.rest_octets, " vs expected ", rest);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ setverdict(pass);
}
-testcase TC_ul_tbf_single_llc_sizes() runs on dummy_CT {
- g_mmctx.imsi := '262420123456789'H;
- g_mmctx.tlli := f_random_tlli();
- f_init();
+/* Verify the contents of RR Immediate Assignment Reject message and its
+ * Rest Octets sent in response to EGPRS Packet Channel Request (11 bit). */
+testcase TC_egprs_pkt_chan_req_reject_content() runs on RAW_PCU_Test_CT {
+ var template IARRestOctets rest;
+ var BIT5 ext_ra;
+ const integer num_req := 6;
- 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))
- }
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
+ f_statsd_reset();
+
+ for (var integer i := 0; i < num_req; i := i + 1) {
+ ext_ra := int2bit(f_rnd_int(32), 5); /* 5 LSB's of RA11 */
+ rest := tr_IARRestOctets({ *, tr_ExtRAOpt(ext_ra), * });
+
+ /* Intentionally incorrect message (see table 11.2.5a.2) */
+ f_TC_egprs_pkt_chan_req_reject('111111'B & ext_ra, 1337 + i, rest);
+ }
+
+ var StatsDExpects expect := {
+ { name := "TTCN3.bts.0.rach.requests", mtype := "c", min := num_req, max := num_req },
+ { name := "TTCN3.bts.0.rach.requests.11bit", mtype := "c", min := num_req, max := num_req },
+ { name := "TTCN3.bts.0.rach.requests.one_phase", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.rach.requests.two_phase", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.rach.requests.unexpected", mtype := "c", min := num_req, max := num_req },
+ { name := "TTCN3.bts.0.immediate.assignment_UL", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.immediate.assignment_rej", mtype := "c", min := num_req, max := num_req },
+ { name := "TTCN3.bts.0.immediate.assignment_DL", mtype := "c", min := 0, max := 0 }
+ };
+ f_statsd_expect(expect);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* At the moment, the IUT does not support any emergency services. Make sure
+ * that EGPRS Packet Channel Request for an emergency call is properly rejected. */
+testcase TC_egprs_pkt_chan_req_reject_emergency() runs on RAW_PCU_Test_CT {
+ var template IARRestOctets rest;
+ var BIT5 ext_ra;
+ var BIT11 ra11;
+ const integer num_req := 6;
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
+ f_statsd_reset();
+
+ var EGPRSPktChRequest req := {
+ /* NOTE: other fields are set in the loop */
+ emergency := { tag := '110111'B }
+ };
+
+ for (var integer i := 0; i < num_req; i := i + 1) {
+ ext_ra := int2bit(f_rnd_int(32), 5); /* 5 LSB's of RA11 */
+ rest := tr_IARRestOctets({ *, tr_ExtRAOpt(ext_ra), * });
+
+ req.emergency.random_bits := ext_ra;
+ ra11 := enc_EGPRSPktChRequest2bits(req);
+
+ /* Intentionally incorrect message (see table 11.2.5a.2) */
+ f_TC_egprs_pkt_chan_req_reject(ra11, 1337 + i, rest);
+ }
+
+ var StatsDExpects expect := {
+ { name := "TTCN3.bts.0.rach.requests", mtype := "c", min := num_req, max := num_req },
+ { name := "TTCN3.bts.0.rach.requests.11bit", mtype := "c", min := num_req, max := num_req },
+ { name := "TTCN3.bts.0.rach.requests.one_phase", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.rach.requests.two_phase", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.rach.requests.unexpected", mtype := "c", min := num_req, max := num_req },
+ { name := "TTCN3.bts.0.immediate.assignment_UL", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.immediate.assignment_rej", mtype := "c", min := num_req, max := num_req },
+ { name := "TTCN3.bts.0.immediate.assignment_DL", mtype := "c", min := 0, max := 0 }
+ };
+ f_statsd_expect(expect);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Make sure that IUT responds with RR Immediate Assignment Reject due to exhaustion. */
+testcase TC_egprs_pkt_chan_req_reject_exhaustion() runs on RAW_PCU_Test_CT {
+ var PCUIF_info_ind info_ind;
+ var template IARRestOctets rest;
+ var BIT11 ra11;
+
+ info_ind := valueof(ts_PCUIF_INFO_default);
+ info_ind.t3142 := 3;
+
+ /* Only the first TRX is enabled. */
+ f_PCUIF_PDCHMask_set(info_ind, '00000000'B, (1 .. 7));
+ f_PCUIF_PDCHMask_set(info_ind, '00000001'B, 0);
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+ f_statsd_reset();
+
+ var EGPRSPktChRequest req := {
+ one_phase := {
+ tag := '0'B,
+ multislot_class := '10101'B,
+ priority := '01'B,
+ random_bits := '101'B
}
- var UlTbfState ul_tbf_state;
- f_UlTbfState_init(ul_tbf_state, ul_tbf_pars);
- f_ul_tbf(ul_tbf_state);
- f_sleep(1.0);
+ };
+
+ /* We send 7 requests, the IUT gives us all available USFs (0..6).
+ * TODO: make it configurable: usf_max := mp_pdch_ts_num * 7. */
+ for (var integer i := 0; i < 7; i := i + 1) {
+ req.one_phase.random_bits := int2bit(f_rnd_int(8), 3);
+ f_TC_egprs_pkt_chan_req(req, tr_IMM_TBF_ASS);
}
- f_exit();
+ ra11 := enc_EGPRSPktChRequest2bits(req);
+ rest := tr_IARRestOctets({ *, tr_ExtRAOpt(substr(ra11, 6, 5)), * });
+
+ /* At this point, the IUT should run out of free USFs */
+ f_TC_egprs_pkt_chan_req_reject(ra11, 1870, rest, wi := info_ind.t3142);
+
+ var StatsDExpects expect := {
+ { name := "TTCN3.bts.0.rach.requests", mtype := "c", min := 8, max := 8 },
+ { name := "TTCN3.bts.0.rach.requests.11bit", mtype := "c", min := 8, max := 8 },
+ { name := "TTCN3.bts.0.rach.requests.one_phase", mtype := "c", min := 8, max := 8 },
+ { name := "TTCN3.bts.0.rach.requests.two_phase", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.rach.requests.unexpected", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.immediate.assignment_UL", mtype := "c", min := 7, max := 7 },
+ { name := "TTCN3.bts.0.immediate.assignment_ul.one_phase", mtype := "c", min := 7, max := 7 },
+ { name := "TTCN3.bts.0.immediate.assignment_ul.two_phase", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.immediate.assignment_ul.contention_resolution_success", mtype := "c", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.immediate.assignment_rej", mtype := "c", min := 1, max := 1 },
+ { name := "TTCN3.bts.0.immediate.assignment_DL", mtype := "c", min := 0, max := 0 }
+ };
+ f_statsd_expect(expect);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
}
-testcase TC_ul_tbf() runs on dummy_CT {
- g_mmctx.imsi := '262420123456789'H;
- g_mmctx.tlli := f_random_tlli();
- f_init();
+/* Randomly generate a set of hopping parameters for one timeslot */
+private function f_TC_pcuif_fh_params_gen(integer max_ma_len)
+return template (value) PCUIF_InfoTrxTs {
+ /* Pick a random MA length in range 2 .. max_ma_len */
+ var integer ma_len := 2 + f_rnd_int(max_ma_len - 2);
- 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))
+ return ts_PCUIF_InfoTrxTsH1(tsc := f_rnd_int(7),
+ hsn := f_rnd_int(63),
+ maio := f_rnd_int(63),
+ ma := f_rnd_bitstring(ma_len));
+}
+
+private function f_TC_pcuif_fh_check_imm_ass(in PCUIF_info_ind info_ind,
+ in GsmRrMessage rr_msg)
+{
+ var ImmediateAssignment ia := rr_msg.payload.imm_ass;
+ var PCUIF_InfoTrxTs ts := info_ind.trx[0].ts[ia.pkt_chan_desc.tn];
+
+ var template PacketChannelDescription tr_pkt_chan_desc := {
+ channel_Type_spare := ?,
+ tn := ?,
+ tsc := ts.tsc,
+ presence := '1'B,
+ zero := omit,
+ one := {
+ maio := ts.maio,
+ hsn := ts.hsn
}
};
- var UlTbfState ul_tbf_state;
- f_UlTbfState_init(ul_tbf_state, ul_tbf_pars);
- f_ul_tbf(ul_tbf_state);
- f_exit();
+ if (not match(ia.pkt_chan_desc, tr_pkt_chan_desc)) {
+ setverdict(fail, "Packet Channel Description does not match: ",
+ ia.pkt_chan_desc, " vs ", tr_pkt_chan_desc);
+ }
+
+ /* Mobile Allocation is expected to be octet-aligned */
+ var uint8_t ma_oct_len := (ts.ma_bit_len + 8 - 1) / 8;
+ var template MobileAllocationLV tr_ma := {
+ len := ma_oct_len, /* in bytes */
+ ma := substr(ts.ma, 0, ma_oct_len * 8)
+ };
+
+ if (not match(ia.mobile_allocation, tr_ma)) {
+ setverdict(fail, "Mobile Allocation does not match: ",
+ ia.mobile_allocation, " vs ", tr_ma);
+ }
+
+ setverdict(pass);
}
-testcase TC_dl_tbf() runs on dummy_CT {
- g_mmctx.imsi := '262420123456789'H;
- g_mmctx.tlli := f_random_tlli();
- f_init();
+/* Make sure that Immediate (UL EGPRS TBF) Assignment contains hopping parameters */
+testcase TC_pcuif_fh_imm_ass_ul_egprs() runs on RAW_PCU_Test_CT {
+ var template (value) PCUIF_info_ind info_ind := ts_PCUIF_INFO_default;
+ var GprsMS ms := valueof(t_GprsMS_def);
+
+ /* Enable frequency hopping on TRX0/TS7 */
+ info_ind.trx[0].ts[7] := f_TC_pcuif_fh_params_gen(32);
- f_establish_dl_tbf();
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
- f_exit();
+ /* EGPRS Packet Channel Request (cause=Signalling) */
+ f_ms_use_ra(ms, bit2int('11001101010'B), ra_is_11bit := 1);
+
+ /* Establish an Uplink EGPRS TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ f_TC_pcuif_fh_check_imm_ass(valueof(info_ind), ms.ul_tbf.rr_imm_ass);
+ f_shutdown(__BFILE__, __LINE__, final := true);
}
-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});
+/* Make sure that Immediate (UL TBF) Assignment contains hopping parameters */
+testcase TC_pcuif_fh_imm_ass_ul() runs on RAW_PCU_Test_CT {
+ var template (value) PCUIF_info_ind info_ind := ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS);
+ var GprsMS ms := valueof(t_GprsMS_def);
+
+ /* Enable frequency hopping on TRX0/TS7 */
+ info_ind.trx[0].ts[7] := f_TC_pcuif_fh_params_gen(32);
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ f_TC_pcuif_fh_check_imm_ass(valueof(info_ind), ms.ul_tbf.rr_imm_ass);
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Make sure that Immediate (DL TBF) Assignment contains hopping parameters */
+testcase TC_pcuif_fh_imm_ass_dl() runs on RAW_PCU_Test_CT {
+ var template (value) PCUIF_info_ind info_ind := ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS);
+ var GprsMS ms := valueof(t_GprsMS_def);
+
+ /* Enable frequency hopping on TRX0/TS7 */
+ info_ind.trx[0].ts[7] := f_TC_pcuif_fh_params_gen(16);
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* SGSN sends some DL data, PCU will page on CCCH (PCH) */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, f_rnd_octstring(12)));
+
+ /* The PCU will send an IMMEDIATE ASSIGNMENT message on the AGCH. It
+ * should be noted that IMMEDIATE ASSIGNMENT messages for DL TBFs are
+ * commonly sent on the PCH. However in this case the IMSI is not
+ * known to the PCU and hence no paging group can be calculated. The
+ * PCU is then forced to use the AGCH.
+ *
+ * As a background information to this it should be noted that this
+ * works because the IMSI is commonly unknown during a GMM ATTACH
+ * REQUEST. In this phase the MS is in non-DRX mode, which means that
+ * it listens on all CCCH blocks (PCH and AGCH)
+ *
+ * See also: 3gpp TS 44.060, section 5.5.1.5 and
+ * 3gpp TS 45.002, section 6.5.3, 6.5.6
+ */
+ f_ms_exp_dl_tbf_ass_ccch(ms, PCU_IF_SAPI_AGCH_2);
+
+ f_TC_pcuif_fh_check_imm_ass(valueof(info_ind), ms.dl_tbf.rr_imm_ass);
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+private function f_TC_pcuif_fh_check_pkt_ass(in PCUIF_info_ind info_ind,
+ in FrequencyParameters fp)
+{
+ /* FIXME: TRX0/TS7 is a hard-coded expectation, make it configurable */
+ var PCUIF_InfoTrxTs ts := info_ind.trx[0].ts[7];
+
+ /* Table 12.8.1: Frequency Parameters information elements */
+ var template FrequencyParameters tr_fp := {
+ tsc := ts.tsc,
+ presence := '10'B, /* Direct encoding 1 */
+ arfcn := omit,
+ indirect := omit,
+ direct1 := {
+ maio := ts.maio,
+ /* Table 12.10a.1: GPRS Mobile Allocation information elements */
+ mobile_allocation := {
+ hsn := ts.hsn,
+ rfl_number_list_present := '0'B,
+ rfl_number_list := omit,
+ ma_present := '0'B, /* inverted logic */
+ ma_length := ts.ma_bit_len,
+ ma_bitmap := substr(ts.ma, 0, ts.ma_bit_len)
+ }
+ },
+ direct2 := omit
+ };
+
+ if (not match(fp, tr_fp)) {
+ setverdict(fail, "Frequency Parameters IE does not match: ",
+ fp, " vs ", tr_fp);
+ }
+
+ setverdict(pass);
+}
+
+/* Make sure that Packet Uplink Assignment contains hopping parameters */
+testcase TC_pcuif_fh_pkt_ass_ul() runs on RAW_PCU_Test_CT {
+ var template (value) PCUIF_info_ind info_ind := ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS);
+ var GprsMS ms := valueof(t_GprsMS_def);
+ var uint32_t poll_fn;
+
+ /* Enable frequency hopping on TRX0/TS7 */
+ info_ind.trx[0].ts[7] := f_TC_pcuif_fh_params_gen(33);
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Single block (two phase) packet access */
+ var uint16_t ra := bit2int(chan_req_sb);
+ f_ms_use_ra(ms, ra, ra_is_11bit := 0);
+
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Send Packet Resource Request, so the network will allocate an Uplink resource */
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, omit)),
+ fn := ms.ul_tbf.start_time_fn);
+
+ /* Expect an RLC/MAC block with Packet Uplink Assignment on PACCH (see 11.2.29) */
+ f_ms_rx_pkt_ass_pacch(ms, poll_fn, tr_RLCMAC_UL_PACKET_ASS);
+ var PacketUlAssignment ua := ms.ul_tbf.ass.pacch;
+
+ /* 3GPP TS 44.060, section 12.8 "Frequency Parameters" */
+ var template (omit) FrequencyParameters fp;
+ if (ua.is_egprs == '1'B) {
+ fp := ua.egprs.freq_par;
+ } else {
+ fp := ua.gprs.freq_par;
+ }
+
+ /* This is an optional IE, so it's worth to check its presence */
+ if (istemplatekind(fp, "omit")) {
+ setverdict(fail, "Frequency Parameters IE is not present");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ f_TC_pcuif_fh_check_pkt_ass(valueof(info_ind), valueof(fp));
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Make sure that Packet Downlink Assignment contains hopping parameters */
+testcase TC_pcuif_fh_pkt_ass_dl() runs on RAW_PCU_Test_CT {
+ var template (value) PCUIF_info_ind info_ind := ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS);
+ var octetstring data := f_rnd_octstring(10);
+ var GprsMS ms := valueof(t_GprsMS_def);
+ var RlcmacDlBlock dl_block;
+ var uint32_t poll_fn;
+
+ /* Enable frequency hopping on TRX0/TS7 */
+ info_ind.trx[0].ts[7] := f_TC_pcuif_fh_params_gen(33);
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Establish an Uplink TBF */
+ f_ms_establish_ul_tbf(ms);
+
+ /* Wait until PCU starts requesting for UL block on this TBF: */
+ f_ms_wait_usf(ms);
+
+ /* Send an Uplink block, so this TBF becomes "active" */
+ f_ms_tx_ul_data_block(ms, data, with_tlli := true, fn := ms.ul_tbf.start_time_fn);
+
+ /* DL ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_rx_rlcmac_dl_block_exp_ack_nack(dl_block, poll_fn);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), poll_fn);
+
+ /* SGSN sends some DL data, PCU will assign Downlink resource on PACCH */
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data));
+
+ /* Expect an RLC/MAC block with Packet Downlink Assignment on PACCH (see 11.2.29) */
+ f_ms_rx_pkt_ass_pacch(ms, poll_fn, tr_RLCMAC_DL_PACKET_ASS);
+ var PacketDlAssignment da := ms.dl_tbf.ass.pacch;
+
+ /* This is an optional IE, so it's worth to check its presence */
+ if (not ispresent(da.freq_par)) {
+ setverdict(fail, "Frequency Parameters IE is not present");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ f_TC_pcuif_fh_check_pkt_ass(valueof(info_ind), da.freq_par);
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Check if the IUT handles subsequent INFO.ind messages */
+testcase TC_pcuif_info_ind_subsequent() runs on RAW_PCU_Test_CT {
+ var template (value) PCUIF_info_ind info_ind := ts_PCUIF_INFO_default;
+ var BTS_PDTCH_Block data_msg;
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Send 16 conseqtive INFO.ind messages and check that the IUT stays alive */
+ for (var integer i := 0; i < 16; i := i + 1) {
+ BTS.send(ts_PCUIF_INFO_IND(0, info_ind));
+ f_pcuif_rx_data_req_pdtch(data_msg);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Verify allocation of several MS along PDCH ts of several TRX. See OS#1775, SYS#5030 */
+testcase TC_multitrx_multims_alloc() runs on RAW_PCU_Test_CT {
+ var PCUIF_info_ind info_ind;
+ var integer i;
+ const integer num_ms := 8;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms(num_ms);
+
+ info_ind := valueof(ts_PCUIF_INFO_default(c_PCUIF_Flags_noMCS));
+ /* Only the 3 first TRX are enabled. The enabled ones all have same
+ amount of resources, hence same amount of initial resources. */
+ f_PCUIF_PDCHMask_set(info_ind, '00000000'B, (3 .. 7));
+ f_PCUIF_PDCHMask_set(info_ind, '00000011'B, 0);
+ f_PCUIF_PDCHMask_set(info_ind, '00001100'B, 1);
+ f_PCUIF_PDCHMask_set(info_ind, '11000000'B, 2);
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_multi_ms_bssgp_register();
+
+ /* Establish an Uplink TBF for each GprsMS instance */
+ f_multi_ms_establish_tbf(do_activate := false);
+
+ /* Check if all TBFs are allocated on different TRX in an uniform way */
+ for (i := 0; i < num_ms; i := i + 1) {
+ if (g_ms[i].ul_tbf.arfcn != info_ind.trx[i mod 3].arfcn) {
+ setverdict(fail, "Got assigned ARFCN ", g_ms[i].ul_tbf.arfcn,
+ " vs exp ", info_ind.trx[i mod 3].arfcn);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Verify concurrent PDCH use of EGPRS and GPRS (EGPRS dl rlcmac blk is
+ * downgraded to CS1-4 so that GPRS can read the USF).
+ * See 3GPP TS 44.060 5.2.4a "Multiplexing of GPRS, EGPRS and EGPRS2 capable mobile stations"
+ */
+testcase TC_multiplex_dl_gprs_egprs() runs on RAW_PCU_Test_CT {
+ var PCUIF_info_ind info_ind;
+ const integer num_ms := 2; /* 2 MS, first one is GPRS-only, second one is EGPRS */
+ var PollFnCtx pollctx;
+ var uint32_t sched_fn, dl_fn, ack_fn;
+ var octetstring data := f_rnd_octstring(10);
+ var RlcmacDlBlock dl_block;
+ var integer tx_data_remain := 5;
+ var integer tgt_ms, usf_ms;
+ var integer ms_gprs_usf_count[num_ms] := { 0, 0 };
+ var integer ms_egprs_usf_count[num_ms] := { 0, 0 };
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms(num_ms);
+
+ info_ind := valueof(ts_PCUIF_INFO_default);
+ /* Only use 1 PDCH to make sure both end up in the same slot: */
+ f_PCUIF_PDCHMask_set(info_ind, '00000001'B, 0);
+ f_PCUIF_PDCHMask_set(info_ind, '00000000'B, (1 .. 7));
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Set Initial MCS > 4 and maintain it non-variable to simplify test */
+ g_mcs_initial_dl := 5;
+ g_mcs_max_dl := 5;
+ f_pcuvty_set_allowed_cs_mcs();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_multi_ms_bssgp_register();
+
+ /* Establish UL TBF for MS0 (GPRS-only) */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(g_ms[0], ts_RlcMacUlCtrl_PKT_RES_REQ(g_ms[0].tlli, ms_racap_gprs_def));
+ if (not match(g_ms[0].ul_tbf.tx_cs_mcs, cs_gprs_any)) {
+ setverdict(fail, "Wrong CS_MCS ", g_ms[0].ul_tbf.tx_cs_mcs, " received vs exp ", cs_gprs_any);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(g_ms[0], ts_RLCMAC_CTRL_ACK(g_ms[0].tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ /* Establish UL TBF for MS1 (EGPRS) */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(g_ms[1], ts_RlcMacUlCtrl_PKT_RES_REQ(g_ms[1].tlli, ms_racap_egprs_def));
+ if (not match(g_ms[1].ul_tbf.tx_cs_mcs, mcs_egprs_any)) {
+ setverdict(fail, "Wrong CS_MCS ", g_ms[1].ul_tbf.tx_cs_mcs, " received vs exp ", mcs_egprs_any);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(g_ms[1], ts_RLCMAC_CTRL_ACK(g_ms[1].tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ /* Now SGSN sends some DL data to MS0, PCU will assign a GPRS DL TBF on PACCH */
+ BSSGP[0].send(ts_BSSGP_DL_UD(g_ms[0].tlli, data));
+ f_sleep(0.1);
+ f_ms_rx_pkt_ass_pacch(g_ms[0], sched_fn, tr_RLCMAC_DL_PACKET_ASS);
+ /* DL Ass sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(g_ms[0], ts_RLCMAC_CTRL_ACK(g_ms[0].tlli), sched_fn);
+ /* After acking the dl assignment, dl tbf goes into FLOW state and PCU will provide DL data when BTS asks for it */
+ f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0, cs_gprs_any);
+ /* ACK the DL block */
+ f_dltbf_ack_block(g_ms[0].dl_tbf, dl_block, '0'B);
+ f_ms_tx_ul_block(g_ms[0], f_dltbf_ts_RLCMAC_DL_ACK_NACK(g_ms[0].dl_tbf, false),
+ f_dl_block_ack_fn(dl_block, dl_fn));
+
+ /* Now SGSN sends some DL data to MS1, PCU will assign a EGPRS DL TBF on PACCH */
+ BSSGP[0].send(ts_BSSGP_DL_UD(g_ms[1].tlli, data));
+ f_sleep(0.1);
+ f_ms_rx_pkt_ass_pacch(g_ms[1], sched_fn, tr_RLCMAC_DL_PACKET_ASS);
+ /* DL Ass sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(g_ms[1], ts_RLCMAC_CTRL_ACK(g_ms[1].tlli), sched_fn);
+ /* After acking the dl assignment, dl tbf goes into FLOW state and PCU will provide DL data when BTS asks for it */
+ f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0, mcs_egprs_any);
+ /* ACK the DL block */
+ f_dltbf_ack_block(g_ms[1].dl_tbf, dl_block, '0'B);
+ f_ms_tx_ul_block(g_ms[1], f_dltbf_ts_RLCMAC_DL_ACK_NACK(g_ms[1].dl_tbf, true),
+ f_dl_block_ack_fn(dl_block, dl_fn));
+
+ data := f_rnd_octstring(1400);
+ BSSGP[0].send(ts_BSSGP_DL_UD(g_ms[0].tlli, data));
+ BSSGP[0].send(ts_BSSGP_DL_UD(g_ms[1].tlli, data));
+
+ for (var integer i := 0; i < 800; i := i + 1) {
+ f_rx_rlcmac_dl_block(dl_block, dl_fn);
+
+ if (match(dl_block, tr_RLCMAC_DL_DUMMY_CTRL)) {
+ /* No more data to receive, done */
+ break;
+ }
+
+ usf_ms := -1;
+
+ if (ischosen(dl_block.ctrl)) {
+ setverdict(fail, "Unexpected DL CTRL block ", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ } else if (ischosen(dl_block.data_egprs)) {
+ if (not match(dl_block.data_egprs.mac_hdr.tfi, g_ms[1].dl_tbf.tfi)) {
+ setverdict(fail, "EGPRS DL DATA not matching EGPRS MS TFI (", g_ms[1].dl_tbf.tfi, "): ", dl_block.data_egprs.mac_hdr.tfi);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ tgt_ms := 1;
+ if (match(dl_block.data_egprs.mac_hdr.usf, g_ms[0].ul_tbf.usf[7])) {
+ if (dl_block.data_egprs.mcs > MCS_4) {
+ setverdict(fail, "Signalling USF ", dl_block.data_egprs.mac_hdr.usf, " for GPRS-only MS using MCS > 4: ", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ usf_ms := 0;
+ ms_egprs_usf_count[usf_ms] := ms_egprs_usf_count[usf_ms] + 1;
+ } else {
+ if (dl_block.data_egprs.mcs <= MCS_4) {
+ setverdict(fail, "Using too-low MCS for EGPRS MS: ", dl_block.data_egprs.mcs);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ if (match(dl_block.data_egprs.mac_hdr.usf, g_ms[1].ul_tbf.usf[7])) {
+ usf_ms := 1;
+ ms_egprs_usf_count[usf_ms] := ms_egprs_usf_count[usf_ms] + 1;
+ }
+ }
} else {
+ if (not match(dl_block.data.mac_hdr.hdr_ext.tfi, g_ms[0].dl_tbf.tfi)) {
+ setverdict(fail, "GPRS DL DATA not matching GPRS MS TFI (", g_ms[0].dl_tbf.tfi, "): ", dl_block.data.mac_hdr.hdr_ext.tfi);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ tgt_ms := 0;
+ if (match(dl_block.data.mac_hdr.mac_hdr.usf, g_ms[0].ul_tbf.usf[7])) {
+ usf_ms := 0;
+ ms_gprs_usf_count[usf_ms] := ms_gprs_usf_count[usf_ms] + 1;
+ } else if (match(dl_block.data.mac_hdr.mac_hdr.usf, g_ms[1].ul_tbf.usf[7])) {
+ usf_ms := 1;
+ ms_gprs_usf_count[usf_ms] := ms_gprs_usf_count[usf_ms] + 1;
+ }
+ }
+
+ /* Keep Ack/Nack description updated */
+ f_dltbf_ack_block(g_ms[tgt_ms].dl_tbf, dl_block);
+
+ /* TDMA frame number on which we are supposed to send the ACK */
+ if (f_dl_block_rrbp_valid(dl_block)) {
+ ack_fn := f_dl_block_ack_fn(dl_block, dl_fn);
+ f_ms_tx_ul_block(g_ms[tgt_ms], f_dltbf_ts_RLCMAC_DL_ACK_NACK(g_ms[tgt_ms].dl_tbf, ischosen(dl_block.data_egprs)), ack_fn);
+ if (tx_data_remain != 0) {
+ /* Submit more data from time to time to keep the TBF ongoing */
+ BSSGP[0].send(ts_BSSGP_DL_UD(g_ms[0].tlli, data));
+ BSSGP[0].send(ts_BSSGP_DL_UD(g_ms[1].tlli, data));
+ tx_data_remain := tx_data_remain - 1;
+ }
+ } else if (tx_data_remain != 0) {
+ /* keep sending UL blocks when requested by USF to avoid
+ * UL TBF timeout and hence stop receival of USFs */
+ if (usf_ms != -1) {
+ f_ms_tx_ul_data_block(g_ms[usf_ms], f_rnd_octstring(10), cv := 15);
+ }
+ }
+ }
+
+ log("results: ms_gprs_usf_count=", ms_gprs_usf_count, " / ms_egprs_usf_count=", ms_egprs_usf_count);
+ /* He we check that DL blocks scheduled at GPRS can still request UL
+ * blocks for EGPRS MS, and the other way around. Furthermore, the 2nd
+ * condition also ensures the downgrade to <=MCS4 condition is tested
+ * above */
+ if (ms_gprs_usf_count[1] == 0 or ms_egprs_usf_count[0] == 0) {
+ setverdict(fail, "USF exchange thresholds not met!");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ /* Here check for some level of fairness between them (at least ~40%): */
+ var integer gprs_usf_cnt := ms_gprs_usf_count[0] + ms_egprs_usf_count[0];
+ var integer egprs_usf_cnt := ms_gprs_usf_count[1] + ms_egprs_usf_count[1];
+ var integer total_usf_cnt := gprs_usf_cnt + egprs_usf_cnt;
+ if (gprs_usf_cnt < total_usf_cnt * 4 / 10) {
+ setverdict(fail, "USF GPRS-only MS ", gprs_usf_cnt, " < ", total_usf_cnt * 4 / 10);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ if (egprs_usf_cnt < total_usf_cnt * 4 / 10) {
+ setverdict(fail, "USF EGPRS MS ", egprs_usf_cnt, " < ", total_usf_cnt * 4 / 10);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+
+private function f_TC_paging_cs_multi_ms(template (value) TsTrxBtsNum nr,
+ boolean exp_imsi, boolean exp_tmsi)
+runs on RAW_PCU_Test_CT {
+ var bitstring mask := f_pad_bit(''B, lengthof(g_ms), '0'B);
+ var integer pending := lengthof(g_ms);
+ var RlcmacDlBlock dl_block;
+ var boolean f1, f2;
+
+ while (pending > 0) {
+ var uint32_t poll_fn;
+
+ /* Obtain a Downlink block and make sure it is a paging request */
+ f_rx_rlcmac_dl_block(dl_block, poll_fn, nr := nr);
+ if (not match(dl_block, tr_RLCMAC_PACKET_PAG_REQ)) {
+ setverdict(fail, "Rx unexpected DL block: ", dl_block);
+ break;
+ }
+
+ /* This should not happen in general, but who knows... */
+ var PacketPagingReq req := dl_block.ctrl.payload.u.paging;
+ if (not ispresent(req.repeated_pageinfo)) {
+ setverdict(fail, "Repeated Page Info IE is absent?!?");
+ break;
+ }
+
+ /* A single message may contain several MIs depending on their type */
+ for (var integer i := 0; i < lengthof(g_ms); i := i + 1) {
+ f1 := exp_imsi and f_pkt_paging_match_imsi(req, g_ms[i].imsi,
+ ps_domain := false);
+ f2 := exp_tmsi and f_pkt_paging_match_tmsi(req, oct2int(g_ms[i].tlli),
+ ps_domain := false);
+ if (not f1 and not f2)
+ { continue; }
+
+ /* Detect duplicate MIs */
+ if (mask[i] == '1'B) {
+ setverdict(fail, "MS is paged twice: ", g_ms[i].imsi);
+ continue;
+ }
+
+ mask[i] := '1'B;
+ }
+
+ pending := pending - lengthof(req.repeated_pageinfo);
+ }
+
+ for (var integer i := 0; i < lengthof(mask); i := i + 1) {
+ if (mask[i] != '1'B) {
+ setverdict(fail, "MS was not paged at all: ", g_ms[i].imsi);
+ log("===== mask := ", mask);
+ }
+ }
+
+ /* All messages must have been received by now, expect a dummy block */
+ f_rx_rlcmac_dl_block_exp_dummy(dl_block, nr := nr);
+}
+
+private function f_TC_paging_cs_multi_ms_init(BIT8 pdch_mask)
+runs on RAW_PCU_Test_CT {
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default);
+ const BssgpBvci bvci := mp_gb_cfg.bvc[0].bvci;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+
+ /* Explicitly set the given PDCH slot-mask to all transceivers */
+ f_PCUIF_PDCHMask_set(info_ind, pdch_mask);
+
+ /* Allocate 56 GprsMS instances (maximum for 8 PDCH slots) */
+ f_init_gprs_ms(7 * 8);
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_multi_ms_bssgp_register();
+
+ /* Establish an Uplink TBF for each GprsMS instance */
+ f_multi_ms_establish_tbf(do_activate := true);
+}
+
+testcase TC_paging_cs_multi_ms_imsi() runs on RAW_PCU_Test_CT {
+ const BssgpBvci bvci := mp_gb_cfg.bvc[0].bvci;
+
+ /* Common part: send INFO.ind, establish TBFs... */
+ f_TC_paging_cs_multi_ms_init(pdch_mask := '00000001'B);
+
+ /* Enqueue multiple CS PAGING requests at a time (IMSI only) */
+ for (var integer i := 0; i < lengthof(g_ms); i := i + 1) {
+ BSSGP[0].send(ts_BSSGP_CS_PAGING_IMSI(bvci, g_ms[i].imsi));
+ }
+
+ /* FIXME: work around a race condition between PCUIF and BSSGP */
+ f_sleep(0.2); /* i.e. give the IUT some time to process everything */
+
+ /* Check what the IUT sends on PACCH, all GprsMS instances must be paged.
+ * The IUT is expected to page on all PDCH slots of all transceivers. */
+ for (var integer trx_nr := 0; trx_nr < 8; trx_nr := trx_nr + 1) {
+ var template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum(7, trx_nr);
+ f_TC_paging_cs_multi_ms(nr, exp_imsi := true, exp_tmsi := false);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+testcase TC_paging_cs_multi_ms_tmsi() runs on RAW_PCU_Test_CT {
+ const BssgpBvci bvci := mp_gb_cfg.bvc[0].bvci;
+
+ /* Common part: send INFO.ind, establish TBFs... */
+ f_TC_paging_cs_multi_ms_init(pdch_mask := '00000001'B);
+
+ /* Enqueue multiple CS PAGING requests at a time (P-TMSI only) */
+ for (var integer i := 0; i < lengthof(g_ms); i := i + 1) {
+ var GsmTmsi tmsi := oct2int(g_ms[i].tlli); /* P-TMSI == TLLI */
+ BSSGP[0].send(ts_BSSGP_CS_PAGING_PTMSI(bvci, g_ms[i].imsi, tmsi));
+ }
+
+ /* FIXME: work around a race condition between PCUIF and BSSGP */
+ f_sleep(0.2); /* i.e. give the IUT some time to process everything */
+
+ /* Check what the IUT sends on PACCH, all GprsMS instances must be paged.
+ * The IUT is expected to page on all PDCH slots of all transceivers. */
+ for (var integer trx_nr := 0; trx_nr < 8; trx_nr := trx_nr + 1) {
+ var template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum(7, trx_nr);
+ f_TC_paging_cs_multi_ms(nr, exp_imsi := false, exp_tmsi := true);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+testcase TC_paging_cs_multi_ms_imsi_tmsi() runs on RAW_PCU_Test_CT {
+ const BssgpBvci bvci := mp_gb_cfg.bvc[0].bvci;
+
+ /* Common part: send INFO.ind, establish TBFs... */
+ f_TC_paging_cs_multi_ms_init(pdch_mask := '00000001'B);
+
+ /* Enqueue multiple CS PAGING requests at a time (IMSI & P-TMSI) */
+ for (var integer i := 0; i < lengthof(g_ms); i := i + 1) {
+ var GsmTmsi tmsi := oct2int(g_ms[i].tlli); /* P-TMSI == TLLI */
+ if (i mod 3 == 0) { /* One PDU fits: 1 IMSI and 2 P-TMSI MIs */
+ BSSGP[0].send(ts_BSSGP_CS_PAGING_PTMSI(bvci, g_ms[i].imsi, tmsi));
+ } else {
+ BSSGP[0].send(ts_BSSGP_CS_PAGING_IMSI(bvci, g_ms[i].imsi));
+ }
+ }
+
+ /* FIXME: work around a race condition between PCUIF and BSSGP */
+ f_sleep(0.2); /* i.e. give the IUT some time to process everything */
+
+ /* Check what the IUT sends on PACCH, all GprsMS instances must be paged.
+ * The IUT is expected to page on all PDCH slots of all transceivers. */
+ for (var integer trx_nr := 0; trx_nr < 8; trx_nr := trx_nr + 1) {
+ var template (value) TsTrxBtsNum nr := ts_TsTrxBtsNum(7, trx_nr);
+ f_TC_paging_cs_multi_ms(nr, exp_imsi := true, exp_tmsi := true);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+private function f_skip_dummy(integer max_num_iter, out uint32_t sched_fn)
+runs on RAW_PCU_Test_CT return RlcmacDlBlock {
+ var RlcmacDlBlock dl_block;
+ var integer i := 0;
+ while (true) {
+ f_rx_rlcmac_dl_block(dl_block, sched_fn);
+ if (not match(dl_block, tr_RLCMAC_DL_DUMMY_CTRL())) {
+ break;
+ }
+ if (max_num_iter > 0 and i > max_num_iter) {
+ setverdict(fail, "Rx unexpected DL block: ", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ i := i + 1;
+ }
+ return dl_block;
+}
+
+private const GsmMcc c_BssgpCellMcc := '623'H; /* MCC: Central African Republic */
+private const GsmMnc c_BssgpCellMnc := '03'H; /* MNC: Celca (Socatel) */
+private template (value) BssgpCellId ts_BssgpCellIdDstAddr_default := {
+ ra_id := {
+ lai := {
+ mcc_mnc := f_build_BcdMccMnc(c_BssgpCellMcc, c_BssgpCellMnc),
+ lac := 423
+ },
+ rac := 2
+ },
+ cell_id := 5
+}
+
+private function f_outbound_nacc_rim_tx_resp(PCUIF_info_ind info_ind)
+runs on RAW_PCU_Test_CT {
+ /* Source Cell Identifier IE is generated by osmo-pcu based on the INFO.ind */
+ var BcdMccMnc src_mcc_mnc := f_build_BcdMccMnc_int(info_ind.mcc, info_ind.mnc, info_ind.mnc_3_digits == 1);
+ var BssgpCellId src := valueof(ts_BssgpCellId(ts_RAI(ts_LAI(src_mcc_mnc, info_ind.lac), info_ind.rac),
+ info_ind.cell_id));
+ /* Destination Cell Identifier IE is resolved by the testsuite itself (emulating BSC) */
+ var BssgpCellId dst := valueof(ts_BssgpCellIdDstAddr_default);
+ var RIM_Routing_Address src_addr := valueof(t_RIM_Routing_Address_cid(src));
+ var RIM_Routing_Address dst_addr := valueof(t_RIM_Routing_Address_cid(dst));
+ var template (value) RAN_Information_RIM_Container res_cont :=
+ ts_RAN_Information_RIM_Container(ts_RIM_Application_Identity(RIM_APP_ID_NACC),
+ ts_RIM_Sequence_Number(2),
+ ts_RIM_PDU_Indications(false, RIM_PDU_TYPE_SING_REP),
+ ts_RIM_Protocol_Version_Number(1),
+ tsu_ApplContainer_or_ApplErrContainer_NACC(tsu_ApplContainer_NACC(dst, false, 3, si_default)),
+ omit);
+ RIM.send(ts_PDU_BSSGP_RAN_INFORMATION(ts_RIM_Routing_Information(RIM_ADDR_GERAN_CELL_ID, src_addr),
+ ts_RIM_Routing_Information(RIM_ADDR_GERAN_CELL_ID, dst_addr),
+ res_cont));
+}
+
+altstep as_outbound_nacc_rim_resolve(PCUIF_info_ind info_ind, boolean do_answer := true, boolean do_repeat := false)
+runs on RAW_PCU_Test_CT {
+ /* Source Cell Identifier IE is generated by osmo-pcu based on the INFO.ind */
+ var BcdMccMnc src_mcc_mnc := f_build_BcdMccMnc_int(info_ind.mcc, info_ind.mnc, info_ind.mnc_3_digits == 1);
+ var BssgpCellId src := valueof(ts_BssgpCellId(ts_RAI(ts_LAI(src_mcc_mnc, info_ind.lac), info_ind.rac),
+ info_ind.cell_id));
+ /* Destination Cell Identifier IE is resolved by the testsuite itself (emulating BSC) */
+ var BssgpCellId dst := valueof(ts_BssgpCellIdDstAddr_default);
+ var RIM_Routing_Address src_addr := valueof(t_RIM_Routing_Address_cid(src));
+ var RIM_Routing_Address dst_addr := valueof(t_RIM_Routing_Address_cid(dst));
+ [] RIM.receive(tr_RAN_INFORMATION_REQUEST(tr_RIM_Routing_Information(RIM_ADDR_GERAN_CELL_ID, dst_addr),
+ tr_RIM_Routing_Information(RIM_ADDR_GERAN_CELL_ID, src_addr),
+ tr_RAN_Information_Request_RIM_Container)) {
+ if (do_answer) {
+ f_outbound_nacc_rim_tx_resp(info_ind);
+ }
+ if (do_repeat) {
repeat;
}
}
- [] L1.receive { repeat };
+}
+
+private function f_ctrl_rx_nacc_rac_ci_req(out CtrlMessage ctrl_req,
+ PCUIF_info_ind info_ind,
+ GsmArfcn req_arfcn,
+ uint6_t req_bsic)
+runs on RAW_PCU_Test_CT {
+ var charstring ctrl_var := "neighbor_resolve_cgi_ps_from_lac_ci." &
+ int2str(info_ind.lac) & "." &
+ int2str(info_ind.cell_id) & "." &
+ int2str(req_arfcn) & "." &
+ int2str(req_bsic);
+ f_ipa_ctrl_wait_link_up();
+ IPA_CTRL.receive(tr_CtrlMsgGet(?, ctrl_var)) -> value ctrl_req;
+}
+
+private function f_ctrl_tx_nacc_rac_ci_rsp(in CtrlMessage ctrl_req)
+runs on RAW_PCU_Test_CT {
+ var BssgpCellId addr := valueof(ts_BssgpCellIdDstAddr_default);
+ IPA_CTRL.send(ts_CtrlMsgGetRepl(ctrl_req.cmd.id,
+ ctrl_req.cmd.variable,
+ hex2str(c_BssgpCellMcc) & "-" &
+ hex2str(c_BssgpCellMnc) & "-" &
+ int2str(addr.ra_id.lai.lac) & "-" &
+ int2str(addr.ra_id.rac) & "-" &
+ int2str(addr.cell_id)));
+}
+
+private function f_pcuif_rx_nacc_rac_ci_req(out PCUIF_Message addr_req,
+ PCUIF_info_ind info_ind,
+ GsmArfcn req_arfcn,
+ uint6_t req_bsic)
+runs on RAW_PCU_Test_CT {
+ BTS.receive(tr_PCUIF_NEIGH_ADDR_REQ(0, info_ind.lac, info_ind.cell_id,
+ req_arfcn, req_bsic)) -> value addr_req;
+}
+
+private function f_pcuif_tx_nacc_rac_ci_rsp(in PCUIF_Message addr_req)
+runs on RAW_PCU_Test_CT {
+ var BssgpCellId addr := valueof(ts_BssgpCellIdDstAddr_default);
+ BTS.send(ts_PCUIF_NEIGH_ADDR_CNF(0, addr_req.u.container.u.neigh_addr_req, 0,
+ str2int(hex2str(c_BssgpCellMcc)),
+ str2int(hex2str(c_BssgpCellMnc)),
+ lengthof(c_BssgpCellMnc) - 2,
+ addr.ra_id.lai.lac,
+ addr.ra_id.rac,
+ addr.cell_id));
+}
+
+private function f_handle_nacc_rac_ci_query(PCUIF_info_ind info_ind, GsmArfcn req_arfcn, uint6_t req_bsic,
+ boolean answer := true, boolean use_old_ctrl_iface := false)
+runs on RAW_PCU_Test_CT {
+ if (use_old_ctrl_iface == true) {
+ var CtrlMessage ctrl_req;
+ f_ctrl_rx_nacc_rac_ci_req(ctrl_req, info_ind, req_arfcn, req_bsic);
+ if (answer) {
+ f_ctrl_tx_nacc_rac_ci_rsp(ctrl_req);
+ }
+ } else {
+ var PCUIF_Message pcuif_req;
+ f_pcuif_rx_nacc_rac_ci_req(pcuif_req, info_ind, req_arfcn, req_bsic);
+ if (answer) {
+ f_pcuif_tx_nacc_rac_ci_rsp(pcuif_req);
+ }
+ }
+}
+
+private function f_outbound_nacc_success_no_si(inout GprsMS ms, PCUIF_info_ind info_ind,
+ boolean exp_rac_ci_query := true, boolean exp_si_query := true,
+ boolean skip_final_ctrl_ack := false,
+ boolean use_old_ctrl_iface := false,
+ template (value) RlcmacUlCtrlMsg cell_chg_notif)
+runs on RAW_PCU_Test_CT {
+ var template RlcmacDlCtrlMsg cell_chg_cont;
+ var RlcmacDlBlock dl_block;
+ var uint32_t sched_fn;
+
+ /* Start NACC from MS side */
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* Obtain a Downlink block and make sure it is a PacketCellChangeContine. We also make sure that this
+ * PacketCellChangeContine message does not contain any ARFCN/BSIC. */
+ f_rx_rlcmac_dl_block(dl_block, sched_fn);
+ cell_chg_cont := tr_RlcMacDlCtrl_PKT_CELL_CHG_CONTINUE
+ cell_chg_cont.u.cell_chg_continue.arfcn_bsic_presence := '0'B
+ if (not match(dl_block, tr_RLCMAC_DL_CTRL(?, cell_chg_cont))) {
+ setverdict(fail, "Rx unexpected DL block: ", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ /* PKT CELL CHG CONTINUE ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ if (not skip_final_ctrl_ack and dl_block.ctrl.mac_hdr.rrbp_valid) {
+ sched_fn := f_rrbp_ack_fn(sched_fn, dl_block.ctrl.mac_hdr.rrbp);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ }
+}
+
+/* Start NACC from MS side, propose an UTRAN cell */
+private function f_outbound_nacc_success_utran(inout GprsMS ms, PCUIF_info_ind info_ind,
+ boolean exp_rac_ci_query := true, boolean exp_si_query := true,
+ boolean skip_final_ctrl_ack := false,
+ boolean use_old_ctrl_iface := false)
+runs on RAW_PCU_Test_CT {
+ var template (value) RlcmacUlCtrlMsg cell_chg_notif;
+ var uint14_t req_uarfcn := 1234;
+ var uint10_t req_scrambling_code := 456;
+
+ /* Start NACC from MS side */
+ cell_chg_notif := ts_RlcMacUlCtrl_PKT_CELL_CHG_NOTIF_UTRAN(ms.ul_tbf.tfi, req_uarfcn, req_scrambling_code);
+ f_outbound_nacc_success_no_si(ms, info_ind, exp_rac_ci_query, exp_si_query, skip_final_ctrl_ack, use_old_ctrl_iface, cell_chg_notif);
+}
+
+/* Start NACC from MS side, propose an E-UTRAN cell */
+private function f_outbound_nacc_success_eutran(inout GprsMS ms, PCUIF_info_ind info_ind,
+ boolean exp_rac_ci_query := true, boolean exp_si_query := true,
+ boolean skip_final_ctrl_ack := false,
+ boolean use_old_ctrl_iface := false)
+runs on RAW_PCU_Test_CT {
+ var template (value) RlcmacUlCtrlMsg cell_chg_notif;
+ var uint16_t req_earfcn := 1234;
+ var uint9_t phys_layer_cell_id := 456;
+
+ /* Start NACC from MS side */
+ cell_chg_notif := ts_RlcMacUlCtrl_PKT_CELL_CHG_NOTIF_EUTRAN(ms.ul_tbf.tfi, req_earfcn, phys_layer_cell_id);
+ f_outbound_nacc_success_no_si(ms, info_ind, exp_rac_ci_query, exp_si_query, skip_final_ctrl_ack, use_old_ctrl_iface, cell_chg_notif);
+}
+
+/* Start NACC from MS side, propose a GERAN cell */
+private function f_outbound_nacc_success_geran(inout GprsMS ms, PCUIF_info_ind info_ind,
+ boolean exp_rac_ci_query := true, boolean exp_si_query := true,
+ boolean skip_final_ctrl_ack := false,
+ boolean use_old_ctrl_iface := false)
+runs on RAW_PCU_Test_CT {
+ var template (value) RlcmacUlCtrlMsg cell_chg_notif;
+ var template RlcmacDlCtrlMsg cell_chg_cont;
+ var RlcmacDlBlock dl_block;
+ var uint32_t sched_fn;
+ var GsmArfcn req_arfcn := 862;
+ var uint6_t req_bsic := 43;
+
+ /* Start NACC from MS side */
+ cell_chg_notif := ts_RlcMacUlCtrl_PKT_CELL_CHG_NOTIF(ms.ul_tbf.tfi, req_arfcn, req_bsic);
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ if (exp_rac_ci_query == true) {
+ /* osmo-pcu should now ask for resolution: */
+ f_handle_nacc_rac_ci_query(info_ind, req_arfcn, req_bsic, true, use_old_ctrl_iface);
+ }
+
+ if (exp_si_query == true) {
+ /* RIM procedure: */
+ as_outbound_nacc_rim_resolve(info_ind);
+ }
+
+ /* Announce SI back to MS, continue NACC procedure */
+ f_ms_handle_pkt_neighbor_cell_data(ms, si_default);
+
+ /* Obtain a Downlink block and make sure it is a PacketCellChangeContinue, also verify that
+ * the PacketCellChangeContinue message contains the ARFCN and BSIC which was proposed in
+ * the PacketCellChangeNotification before. */
+ f_rx_rlcmac_dl_block(dl_block, sched_fn);
+ cell_chg_cont := tr_RlcMacDlCtrl_PKT_CELL_CHG_CONTINUE
+ cell_chg_cont.u.cell_chg_continue.arfcn_bsic_presence := '1'B
+ cell_chg_cont.u.cell_chg_continue.arfcn := req_arfcn;
+ cell_chg_cont.u.cell_chg_continue.bsic := req_bsic;
+ if (not match(dl_block, tr_RLCMAC_DL_CTRL(?, cell_chg_cont))) {
+ setverdict(fail, "Rx unexpected DL block: ", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ /* PKT CELL CHG CONTINUE ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ if (not skip_final_ctrl_ack and dl_block.ctrl.mac_hdr.rrbp_valid) {
+ sched_fn := f_rrbp_ack_fn(sched_fn, dl_block.ctrl.mac_hdr.rrbp);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ }
+}
+
+type enumerated f_TC_nacc_outbound_success_ran_type {
+ NACC_RAN_GERAN,
+ NACC_RAN_UTRAN,
+ NACC_RAN_EUTRAN
+}
+
+/* Verify PCU handles outbound Network Assisted Cell Change Cell Change (NACC, TS 44.060 sec 8.8). */
+function f_TC_nacc_outbound_success(f_TC_nacc_outbound_success_ran_type ran_type) runs on RAW_PCU_Test_CT {
+ var PollFnCtx pollctx;
+ var GprsMS ms;
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default);
+ var boolean use_old_ctrl_iface := mp_ctrl_neigh_ip != "";
+
+ if (use_old_ctrl_iface) {
+ /* Initialize osmo-bsc emulation neighbor resolution CTRL port */
+ f_ipa_ctrl_start_server(mp_ctrl_neigh_ip, mp_ctrl_neigh_port);
+ }
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Make sure we are not affected by full cache from previous tests */
+ f_pcuvty_flush_neigh_caches();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Send PACKET RESOURCE REQUEST */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap_gprs_def));
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ /* Start NACC from MS side */
+ if (ran_type == NACC_RAN_GERAN) {
+ f_outbound_nacc_success_geran(ms, info_ind, use_old_ctrl_iface := use_old_ctrl_iface);
+ } else if (ran_type == NACC_RAN_UTRAN) {
+ f_outbound_nacc_success_utran(ms, info_ind, use_old_ctrl_iface := use_old_ctrl_iface);
+ } else if (ran_type == NACC_RAN_EUTRAN) {
+ f_outbound_nacc_success_eutran(ms, info_ind, use_old_ctrl_iface := use_old_ctrl_iface);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+testcase TC_nacc_outbound_success() runs on RAW_PCU_Test_CT {
+ f_TC_nacc_outbound_success(NACC_RAN_GERAN);
+}
+
+testcase TC_nacc_outbound_success_utran() runs on RAW_PCU_Test_CT {
+ f_TC_nacc_outbound_success(NACC_RAN_UTRAN);
+}
+
+testcase TC_nacc_outbound_success_eutran() runs on RAW_PCU_Test_CT {
+ f_TC_nacc_outbound_success(NACC_RAN_EUTRAN);
+}
+
+/* Verify Pkt Cell Change Continue is retransmitted if not CTRL ACKed */
+testcase TC_nacc_outbound_success_no_ctrl_ack() runs on RAW_PCU_Test_CT {
+ var PollFnCtx pollctx;
+ var GprsMS ms;
+ var RlcmacDlBlock dl_block;
+ var uint32_t sched_fn;
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default);
+ var boolean use_old_ctrl_iface := mp_ctrl_neigh_ip != "";
+
+ if (use_old_ctrl_iface) {
+ /* Initialize osmo-bsc emulation neighbor resolution CTRL port */
+ f_ipa_ctrl_start_server(mp_ctrl_neigh_ip, mp_ctrl_neigh_port);
+ }
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Make sure we are not affected by full cache from previous tests */
+ f_pcuvty_flush_neigh_caches();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Send PACKET RESOURCE REQUEST */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap_gprs_def));
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ /* Start NACC from MS side, avoid sending final CTRL ACK */
+ f_outbound_nacc_success_geran(ms, info_ind, skip_final_ctrl_ack := true,
+ use_old_ctrl_iface := use_old_ctrl_iface);
+
+ /* Wait until we receive something non-dummy */
+ dl_block := f_skip_dummy(0, sched_fn);
+ /* Make sure it is a Pkt Cell Chg Continue (retransmitted)*/
+ if (not match(dl_block, tr_RLCMAC_DL_CTRL(?, tr_RlcMacDlCtrl_PKT_CELL_CHG_CONTINUE))) {
+ setverdict(fail, "Rx unexpected DL block: ", dl_block);
+ }
+ /* PKT CELL CHG CONTINUE ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ if (dl_block.ctrl.mac_hdr.rrbp_valid) {
+ sched_fn := f_rrbp_ack_fn(sched_fn, dl_block.ctrl.mac_hdr.rrbp);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Verify PCU handles outbound Network Assisted Cell Change Cell Change (NACC, TS 44.060 sec 8.8) twice, the second time using the caches */
+testcase TC_nacc_outbound_success_twice() runs on RAW_PCU_Test_CT {
+ var PollFnCtx pollctx;
+ var GprsMS ms;
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default);
+ var template (value) RlcmacUlCtrlMsg cell_chg_notif;
+ var boolean use_old_ctrl_iface := mp_ctrl_neigh_ip != "";
+
+ if (use_old_ctrl_iface) {
+ /* Initialize osmo-bsc emulation neighbor resolution CTRL port */
+ f_ipa_ctrl_start_server(mp_ctrl_neigh_ip, mp_ctrl_neigh_port);
+ }
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Make sure we are not affected by full cache from previous tests */
+ f_pcuvty_flush_neigh_caches();
+ /* Set timeout values for caches so that entries will be in cache during second try */
+ f_pcuvty_set_neigh_caches(10, 10);
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Send PACKET RESOURCE REQUEST */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap_gprs_def));
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ /* Start NACC from MS side */
+ f_outbound_nacc_success_geran(ms, info_ind, use_old_ctrl_iface := use_old_ctrl_iface);
+
+ /* First NACC procedure is done, let's try to start a new one now that previous queries are cached: */
+ f_outbound_nacc_success_geran(ms, info_ind, false, false, use_old_ctrl_iface := use_old_ctrl_iface);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Verify PCU handles outbound Network Assisted Cell Change Cell Change (NACC,
+ * TS 44.060 sec 8.8) twice, the second time after caches timed out
+ */
+testcase TC_nacc_outbound_success_twice_nocache() runs on RAW_PCU_Test_CT {
+ var PollFnCtx pollctx;
+ var GprsMS ms;
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default);
+ var template (value) RlcmacUlCtrlMsg cell_chg_notif;
+ var boolean use_old_ctrl_iface := mp_ctrl_neigh_ip != "";
+
+ if (use_old_ctrl_iface) {
+ /* Initialize osmo-bsc emulation neighbor resolution CTRL port */
+ f_ipa_ctrl_start_server(mp_ctrl_neigh_ip, mp_ctrl_neigh_port);
+ }
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Make sure we are not affected by full cache from previous tests */
+ f_pcuvty_flush_neigh_caches();
+ /* Set timeout values for caches so that entries will be erased before the second try */
+ f_pcuvty_set_neigh_caches(1, 1);
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Send PACKET RESOURCE REQUEST */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap_gprs_def));
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ /* Start NACC from MS side */
+ f_outbound_nacc_success_geran(ms, info_ind, use_old_ctrl_iface := use_old_ctrl_iface);
+
+ /* CTRL client should have disconnected from us */
+ f_ipa_ctrl_wait_link_down();
+ /* wait for cache entries to time out */
+ f_sleep(2.0);
+ /* First NACC procedure is done, let's try to start a new one now that previous queries have timed out: */
+ f_outbound_nacc_success_geran(ms, info_ind, use_old_ctrl_iface := use_old_ctrl_iface);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Verify PCU transmits Pkt Cell Change Continue if RAC+CI resolution fails during outbound NACC procedure */
+testcase TC_nacc_outbound_rac_ci_resolve_conn_refused() runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var PollFnCtx pollctx;
+ var uint32_t sched_fn;
+ var GprsMS ms;
+ var template (value) RlcmacUlCtrlMsg cell_chg_notif;
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default);
+ var GsmArfcn req_arfcn := 862;
+ var uint6_t req_bsic := 43;
+
+ /* In here we explicitly avoid starting osmo-bsc emulation neighbor
+ * resolution CTRL port, to trigger Conn Refused by socket:
+ * f_ipa_ctrl_start_server(mp_ctrl_neigh_ip, mp_ctrl_neigh_port);
+ */
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Make sure we are not affected by full cache from previous tests */
+ f_pcuvty_flush_neigh_caches();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Send PACKET RESOURCE REQUEST */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap_gprs_def));
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ /* Start NACC from MS side */
+ cell_chg_notif := ts_RlcMacUlCtrl_PKT_CELL_CHG_NOTIF(ms.ul_tbf.tfi, req_arfcn, req_bsic);
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* Wait until we receive something non-dummy */
+ dl_block := f_skip_dummy(0, sched_fn);
+ /* Make sure it is a Pkt Cell Chg Continue */
+ if (not match(dl_block, tr_RLCMAC_DL_CTRL(?, tr_RlcMacDlCtrl_PKT_CELL_CHG_CONTINUE))) {
+ setverdict(fail, "Rx unexpected DL block: ", dl_block);
+ }
+ /* PKT CELL CHG CONTINUE ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ if (dl_block.ctrl.mac_hdr.rrbp_valid) {
+ sched_fn := f_rrbp_ack_fn(sched_fn, dl_block.ctrl.mac_hdr.rrbp);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Verify PCU transmits Pkt Cell Change Continue if RAC+CI resolution fails during outbound NACC procedure */
+testcase TC_nacc_outbound_rac_ci_resolve_timeout() runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var PollFnCtx pollctx;
+ var uint32_t sched_fn;
+ var GprsMS ms;
+ var template (value) RlcmacUlCtrlMsg cell_chg_notif;
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default);
+ var GsmArfcn req_arfcn := 862;
+ var uint6_t req_bsic := 43;
+ var boolean use_old_ctrl_iface := mp_ctrl_neigh_ip != "";
+
+ if (use_old_ctrl_iface) {
+ /* Initialize osmo-bsc emulation neighbor resolution CTRL port */
+ f_ipa_ctrl_start_server(mp_ctrl_neigh_ip, mp_ctrl_neigh_port);
+ }
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Make sure we are not affected by full cache from previous tests */
+ f_pcuvty_flush_neigh_caches();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Send PACKET RESOURCE REQUEST */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap_gprs_def));
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ /* Start NACC from MS side */
+ cell_chg_notif := ts_RlcMacUlCtrl_PKT_CELL_CHG_NOTIF(ms.ul_tbf.tfi, req_arfcn, req_bsic);
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* osmo-pcu should now ask for resolution: */
+ /* we receive RAC+CI resolution request, but we never answer to it, timeout should occur */
+ f_handle_nacc_rac_ci_query(info_ind, req_arfcn, req_bsic, false, use_old_ctrl_iface);
+
+ /* Wait until we receive something non-dummy */
+ dl_block := f_skip_dummy(0, sched_fn);
+ /* Make sure it is a Pkt Cell Chg Continue */
+ if (not match(dl_block, tr_RLCMAC_DL_CTRL(?, tr_RlcMacDlCtrl_PKT_CELL_CHG_CONTINUE))) {
+ setverdict(fail, "Rx unexpected DL block: ", dl_block);
+ }
+ /* PKT CELL CHG CONTINUE ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ if (dl_block.ctrl.mac_hdr.rrbp_valid) {
+ sched_fn := f_rrbp_ack_fn(sched_fn, dl_block.ctrl.mac_hdr.rrbp);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Verify PCU transmits Pkt Cell Change Continue if RAC+CI resolution fails during outbound NACC procedure */
+testcase TC_nacc_outbound_rac_ci_resolve_fail_parse_response() runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var PollFnCtx pollctx;
+ var uint32_t sched_fn;
+ var GprsMS ms;
+ var template (value) RlcmacUlCtrlMsg cell_chg_notif;
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default);
+ var GsmArfcn req_arfcn := 862;
+ var uint6_t req_bsic := 43;
+
+ /* Initialize osmo-bsc emulation neighbor resolution CTRL port */
+ f_ipa_ctrl_start_server(mp_ctrl_neigh_ip, mp_ctrl_neigh_port);
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Make sure we are not affected by full cache from previous tests */
+ f_pcuvty_flush_neigh_caches();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Send PACKET RESOURCE REQUEST */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap_gprs_def));
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ /* Start NACC from MS side */
+ cell_chg_notif := ts_RlcMacUlCtrl_PKT_CELL_CHG_NOTIF(ms.ul_tbf.tfi, req_arfcn, req_bsic);
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* osmo-pcu should now ask for resolution: */
+ f_ipa_ctrl_wait_link_up();
+ var charstring ctrl_var := "neighbor_resolve_cgi_ps_from_lac_ci." &
+ int2str(info_ind.lac) & "." &
+ int2str(info_ind.cell_id) & "." &
+ int2str(req_arfcn) & "." &
+ int2str(req_bsic);
+ /* we receive RAC+CI resolution request and we send incorrectly formated response */
+ f_ctrl_exp_get(IPA_CTRL, ctrl_var, "foobar-error");
+
+ /* Wait until we receive something non-dummy */
+ dl_block := f_skip_dummy(0, sched_fn);
+ /* Make sure it is a Pkt Cell Chg Continue */
+ if (not match(dl_block, tr_RLCMAC_DL_CTRL(?, tr_RlcMacDlCtrl_PKT_CELL_CHG_CONTINUE))) {
+ setverdict(fail, "Rx unexpected DL block: ", dl_block);
+ }
+ /* PKT CELL CHG CONTINUE ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ if (dl_block.ctrl.mac_hdr.rrbp_valid) {
+ sched_fn := f_rrbp_ack_fn(sched_fn, dl_block.ctrl.mac_hdr.rrbp);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Verify PCU transmits Pkt Cell Change Continue if SI resolution fails during outbound NACC procedure */
+testcase TC_nacc_outbound_si_resolve_timeout() runs on RAW_PCU_Test_CT {
+ var RlcmacDlBlock dl_block;
+ var PollFnCtx pollctx;
+ var uint32_t sched_fn;
+ var GprsMS ms;
+ var template (value) RlcmacUlCtrlMsg cell_chg_notif;
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default);
+ var GsmArfcn req_arfcn := 862;
+ var uint6_t req_bsic := 43;
+ var boolean use_old_ctrl_iface := mp_ctrl_neigh_ip != "";
+
+ if (use_old_ctrl_iface) {
+ /* Initialize osmo-bsc emulation neighbor resolution CTRL port */
+ f_ipa_ctrl_start_server(mp_ctrl_neigh_ip, mp_ctrl_neigh_port);
+ }
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Make sure we are not affected by full cache from previous tests */
+ f_pcuvty_flush_neigh_caches();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Send PACKET RESOURCE REQUEST */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap_gprs_def));
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ /* Start NACC from MS side */
+ cell_chg_notif := ts_RlcMacUlCtrl_PKT_CELL_CHG_NOTIF(ms.ul_tbf.tfi, req_arfcn, req_bsic);
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* osmo-pcu should now ask for resolution: */
+ f_handle_nacc_rac_ci_query(info_ind, req_arfcn, req_bsic, true, use_old_ctrl_iface);
+
+ /* RIM procedure: */
+ as_outbound_nacc_rim_resolve(info_ind, do_answer := false);
+ /* We never answer the RIM procude -> PCU timeouts and should send Pkt Cell Chg continue */
+
+ /* Wait until we receive something non-dummy */
+ dl_block := f_skip_dummy(0, sched_fn);
+ /* Make sure it is a Pkt Cell Chg Continue */
+ if (not match(dl_block, tr_RLCMAC_DL_CTRL(?, tr_RlcMacDlCtrl_PKT_CELL_CHG_CONTINUE))) {
+ setverdict(fail, "Rx unexpected DL block: ", dl_block);
+ }
+ /* PKT CELL CHG CONTINUE ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ if (dl_block.ctrl.mac_hdr.rrbp_valid) {
+ sched_fn := f_rrbp_ack_fn(sched_fn, dl_block.ctrl.mac_hdr.rrbp);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Test MS sending Pkt Cell Change Notify twice (duplicate msg) while waiting for CTRL resolution */
+testcase TC_nacc_outbound_pkt_cell_chg_notif_dup() runs on RAW_PCU_Test_CT {
+ var PollFnCtx pollctx;
+ var GprsMS ms;
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default);
+ var template (value) RlcmacUlCtrlMsg cell_chg_notif;
+ var RlcmacDlBlock dl_block;
+ var uint32_t sched_fn;
+ var CtrlMessage rx_ctrl;
+ var charstring ctrl_var;
+ var PCUIF_Message pcu_msg;
+ var GsmArfcn req_arfcn := 862;
+ var uint6_t req_bsic := 43;
+ var boolean use_old_ctrl_iface := mp_ctrl_neigh_ip != "";
+
+ if (use_old_ctrl_iface) {
+ /* Initialize osmo-bsc emulation neighbor resolution CTRL port */
+ f_ipa_ctrl_start_server(mp_ctrl_neigh_ip, mp_ctrl_neigh_port);
+ }
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Make sure we are not affected by full cache from previous tests */
+ f_pcuvty_flush_neigh_caches();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Send PACKET RESOURCE REQUEST */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap_gprs_def));
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ /* Start NACC from MS side */
+ cell_chg_notif := ts_RlcMacUlCtrl_PKT_CELL_CHG_NOTIF(ms.ul_tbf.tfi, req_arfcn, req_bsic);
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* osmo-pcu should now ask for resolution: */
+ if (use_old_ctrl_iface) {
+ f_ctrl_rx_nacc_rac_ci_req(rx_ctrl, info_ind, req_arfcn, req_bsic);
+ } else {
+ f_pcuif_rx_nacc_rac_ci_req(pcu_msg, info_ind, req_arfcn, req_bsic);
+ }
+
+ /* Before receiving CTRL response, MS retransmits Pkt cell Chg Notif */
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+ f_sleep(0.2); /* let some time to avoid race conditons between CTRL and RLCMAC */
+
+ if (use_old_ctrl_iface) {
+ f_ctrl_tx_nacc_rac_ci_rsp(rx_ctrl);
+ } else {
+ f_pcuif_tx_nacc_rac_ci_rsp(pcu_msg);
+ }
+
+ timer T := 2.0;
+ T.start;
+ alt {
+ [] as_outbound_nacc_rim_resolve(info_ind, do_repeat := true);
+ [use_old_ctrl_iface] IPA_CTRL.receive(tr_CtrlMsgGet(?, ctrl_var)) -> value rx_ctrl {
+ setverdict(fail, "Received unexpected CTRL resolution after duplicate Pkt Cell Change Notification:", rx_ctrl);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ [not use_old_ctrl_iface] BTS.receive(tr_PCUIF_NEIGH_ADDR_REQ(0, info_ind.lac, info_ind.cell_id, req_arfcn, req_bsic)) -> value pcu_msg {
+ setverdict(fail, "Received unexpected PCUIF resolution after duplicate Pkt Cell Change Notification:", pcu_msg);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ [] T.timeout {
+ setverdict(pass);
+ }
+ }
+
+ /* Announce SI back to MS, continue NACC procedure */
+ f_ms_handle_pkt_neighbor_cell_data(ms, si_default);
+
+ /* Obtain a Downlink block and make sure it is a Pkt Cell Chg Continue */
+ f_rx_rlcmac_dl_block(dl_block, sched_fn);
+ if (not match(dl_block, tr_RLCMAC_DL_CTRL(?, tr_RlcMacDlCtrl_PKT_CELL_CHG_CONTINUE))) {
+ setverdict(fail, "Rx unexpected DL block: ", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ /* PKT CELL CHG CONTINUE ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ if (dl_block.ctrl.mac_hdr.rrbp_valid) {
+ sched_fn := f_rrbp_ack_fn(sched_fn, dl_block.ctrl.mac_hdr.rrbp);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Test MS sending Pkt Cell Change Notify twice (duplicate msg) while waiting for SI resolution */
+testcase TC_nacc_outbound_pkt_cell_chg_notif_dup2() runs on RAW_PCU_Test_CT {
+ var PollFnCtx pollctx;
+ var GprsMS ms;
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default);
+ var template (value) RlcmacUlCtrlMsg cell_chg_notif;
+ var RlcmacDlBlock dl_block;
+ var uint32_t sched_fn;
+ var CtrlMessage rx_ctrl;
+ var GsmArfcn req_arfcn := 862;
+ var uint6_t req_bsic := 43;
+ var boolean use_old_ctrl_iface := mp_ctrl_neigh_ip != "";
+
+ if (use_old_ctrl_iface) {
+ /* Initialize osmo-bsc emulation neighbor resolution CTRL port */
+ f_ipa_ctrl_start_server(mp_ctrl_neigh_ip, mp_ctrl_neigh_port);
+ }
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Make sure we are not affected by full cache from previous tests */
+ f_pcuvty_flush_neigh_caches();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Send PACKET RESOURCE REQUEST */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap_gprs_def));
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ /* Start NACC from MS side */
+ cell_chg_notif := ts_RlcMacUlCtrl_PKT_CELL_CHG_NOTIF(ms.ul_tbf.tfi, req_arfcn, req_bsic);
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* osmo-pcu should now ask for resolution: */
+ f_handle_nacc_rac_ci_query(info_ind, req_arfcn, req_bsic, true, use_old_ctrl_iface);
+ as_outbound_nacc_rim_resolve(info_ind, do_answer := false);
+ /* Before receiving RIM response, MS retransmits Pkt cell Chg Notif */
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+ f_sleep(0.2); /* let some time to avoid race conditons between CTRL and RLCMAC */
+ f_outbound_nacc_rim_tx_resp(info_ind);
+ timer T := 1.0;
+ T.start;
+ alt {
+ [] RIM.receive {
+ setverdict(fail, "Received unexpected RIM message");
+ f_shutdown(__BFILE__, __LINE__);
+ }
[] T.timeout {
- setverdict(fail, "Timeout waiting for IMM ASS")
- mtc.stop;
+ setverdict(pass);
}
}
- T.stop;
- return rr.payload.imm_ass;
+
+ /* Announce SI back to MS, continue NACC procedure */
+ f_ms_handle_pkt_neighbor_cell_data(ms, si_default);
+
+ /* Obtain a Downlink block and make sure it is a Pkt Cell Chg Continue */
+ f_rx_rlcmac_dl_block(dl_block, sched_fn);
+ if (not match(dl_block, tr_RLCMAC_DL_CTRL(?, tr_RlcMacDlCtrl_PKT_CELL_CHG_CONTINUE))) {
+ setverdict(fail, "Rx unexpected DL block: ", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ /* PKT CELL CHG CONTINUE ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ if (dl_block.ctrl.mac_hdr.rrbp_valid) {
+ sched_fn := f_rrbp_ack_fn(sched_fn, dl_block.ctrl.mac_hdr.rrbp);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
}
-/* 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 */
+/* Test MS sending Pkt Cell Change Notification twice (duplicate msg) while sending Pkt Neigh Data Change */
+testcase TC_nacc_outbound_pkt_cell_chg_notif_dup3() runs on RAW_PCU_Test_CT {
+ var PollFnCtx pollctx;
+ var GprsMS ms;
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default);
+ var template (value) RlcmacUlCtrlMsg cell_chg_notif;
+ var RlcmacDlBlock dl_block;
+ var uint32_t sched_fn;
+ var CtrlMessage rx_ctrl;
+ var GsmArfcn req_arfcn := 862;
+ var uint6_t req_bsic := 43;
+ var boolean use_old_ctrl_iface := mp_ctrl_neigh_ip != "";
+
+ if (use_old_ctrl_iface) {
+ /* Initialize osmo-bsc emulation neighbor resolution CTRL port */
+ f_ipa_ctrl_start_server(mp_ctrl_neigh_ip, mp_ctrl_neigh_port);
+ }
- /* sending a GMM PDU as DL-UNITDATA should trigger Paging + DL TBF Assignment */
- tx_gmm('1'B, '01020304'O, c_LLC_SAPI_LLGMM);
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
- /* Expect an IMM.ASS for PDCH on the AGCH */
- f_wait_tbf_dl(0, g_mmctx.tlli);
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Make sure we are not affected by full cache from previous tests */
+ f_pcuvty_flush_neigh_caches();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
- var RLCMAC_ph_data_ind dl;
+ /* Send PACKET RESOURCE REQUEST */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap_gprs_def));
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ /* Start NACC from MS side */
+ cell_chg_notif := ts_RlcMacUlCtrl_PKT_CELL_CHG_NOTIF(ms.ul_tbf.tfi, req_arfcn, req_bsic);
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* osmo-pcu should now ask for resolution: */
+ f_handle_nacc_rac_ci_query(info_ind, req_arfcn, req_bsic, true, use_old_ctrl_iface);
+ /* RIM procedure: */
+ as_outbound_nacc_rim_resolve(info_ind);
+
+ /* Receive first Pkt Neigh data Change, then trigger a new Pkt Cell Change Notif: */
+ f_ms_handle_pkt_neighbor_cell_data(ms, si_default, single_step := true);
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* It should be ignored, let's continue fetching Pkt Neigh Data Change */
+ f_ms_handle_pkt_neighbor_cell_data(ms, si_default, f_ms_tx_TsTrxBtsNum(ms), 1, 16);
+
+ /* Obtain a Downlink block and make sure it is a Pkt Cell Chg Continue */
+ f_rx_rlcmac_dl_block(dl_block, sched_fn);
+ if (not match(dl_block, tr_RLCMAC_DL_CTRL(?, tr_RlcMacDlCtrl_PKT_CELL_CHG_CONTINUE))) {
+ setverdict(fail, "Rx unexpected DL block: ", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ /* PKT CELL CHG CONTINUE ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ if (dl_block.ctrl.mac_hdr.rrbp_valid) {
+ sched_fn := f_rrbp_ack_fn(sched_fn, dl_block.ctrl.mac_hdr.rrbp);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Test MS sending Pkt Cell Change Notification twice (duplicate msg) while sending Pkt Cell Change Continue */
+testcase TC_nacc_outbound_pkt_cell_chg_notif_dup4() runs on RAW_PCU_Test_CT {
+ var PollFnCtx pollctx;
+ var GprsMS ms;
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default);
+ var template (value) RlcmacUlCtrlMsg cell_chg_notif;
+ var RlcmacDlBlock dl_block;
+ var uint32_t sched_fn;
+ var CtrlMessage rx_ctrl;
+ var GsmArfcn req_arfcn := 862;
+ var uint6_t req_bsic := 43;
+ var boolean use_old_ctrl_iface := mp_ctrl_neigh_ip != "";
+
+ if (use_old_ctrl_iface) {
+ /* Initialize osmo-bsc emulation neighbor resolution CTRL port */
+ f_ipa_ctrl_start_server(mp_ctrl_neigh_ip, mp_ctrl_neigh_port);
+ }
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Make sure we are not affected by full cache from previous tests */
+ f_pcuvty_flush_neigh_caches();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Send PACKET RESOURCE REQUEST */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap_gprs_def));
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ /* Start NACC from MS side */
+ cell_chg_notif := ts_RlcMacUlCtrl_PKT_CELL_CHG_NOTIF(ms.ul_tbf.tfi, req_arfcn, req_bsic);
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* osmo-pcu should now ask for resolution: */
+ f_handle_nacc_rac_ci_query(info_ind, req_arfcn, req_bsic, true, use_old_ctrl_iface);
+ /* RIM procedure: */
+ as_outbound_nacc_rim_resolve(info_ind);
+
+ /* Announce SI back to MS, continue NACC procedure */
+ f_ms_handle_pkt_neighbor_cell_data(ms, si_default);
+
+ /* trigger a dup Pkt Cell Change Notif, it should be ignored: */
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* Obtain a Downlink block and make sure it is a Pkt Cell Chg Continue */
+ f_rx_rlcmac_dl_block(dl_block, sched_fn);
+ if (not match(dl_block, tr_RLCMAC_DL_CTRL(?, tr_RlcMacDlCtrl_PKT_CELL_CHG_CONTINUE))) {
+ setverdict(fail, "Rx unexpected DL block: ", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ /* PKT CELL CHG CONTINUE ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ if (dl_block.ctrl.mac_hdr.rrbp_valid) {
+ sched_fn := f_rrbp_ack_fn(sched_fn, dl_block.ctrl.mac_hdr.rrbp);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Test MS sending Pkt Cell Change Notification twice (duplicate msg) while waiting for Pkt Cell Change Continue CTRL ACK */
+testcase TC_nacc_outbound_pkt_cell_chg_notif_dup5() runs on RAW_PCU_Test_CT {
+ var PollFnCtx pollctx;
+ var GprsMS ms;
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default);
+ var template (value) RlcmacUlCtrlMsg cell_chg_notif;
+ var RlcmacDlBlock dl_block;
+ var uint32_t sched_fn;
+ var CtrlMessage rx_ctrl;
+ var GsmArfcn req_arfcn := 862;
+ var uint6_t req_bsic := 43;
+ var boolean use_old_ctrl_iface := mp_ctrl_neigh_ip != "";
+
+ if (use_old_ctrl_iface) {
+ /* Initialize osmo-bsc emulation neighbor resolution CTRL port */
+ f_ipa_ctrl_start_server(mp_ctrl_neigh_ip, mp_ctrl_neigh_port);
+ }
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Make sure we are not affected by full cache from previous tests */
+ f_pcuvty_flush_neigh_caches();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Send PACKET RESOURCE REQUEST */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap_gprs_def));
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ /* Start NACC from MS side */
+ cell_chg_notif := ts_RlcMacUlCtrl_PKT_CELL_CHG_NOTIF(ms.ul_tbf.tfi, req_arfcn, req_bsic);
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* osmo-pcu should now ask for resolution: */
+ f_handle_nacc_rac_ci_query(info_ind, req_arfcn, req_bsic, true, use_old_ctrl_iface);
+ /* RIM procedure: */
+ as_outbound_nacc_rim_resolve(info_ind);
+
+ /* Announce SI back to MS, continue NACC procedure */
+ f_ms_handle_pkt_neighbor_cell_data(ms, si_default);
+
+ /* Obtain a Downlink block and make sure it is a Pkt Cell Chg Continue */
+ f_rx_rlcmac_dl_block(dl_block, sched_fn);
+ if (not match(dl_block, tr_RLCMAC_DL_CTRL(?, tr_RlcMacDlCtrl_PKT_CELL_CHG_CONTINUE))) {
+ setverdict(fail, "Rx unexpected DL block: ", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ /* trigger a dup Pkt Cell Change Notif, it should be ignored: */
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* PKT CELL CHG CONTINUE ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ if (dl_block.ctrl.mac_hdr.rrbp_valid) {
+ sched_fn := f_rrbp_ack_fn(sched_fn, dl_block.ctrl.mac_hdr.rrbp);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Test MS sending Pkt Cell Change Notify twice (different tgt cell each time)
+ * while waiting for CTRL resolution */
+testcase TC_nacc_outbound_pkt_cell_chg_notif_twice() runs on RAW_PCU_Test_CT {
+ var PollFnCtx pollctx;
+ var GprsMS ms;
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default);
+ var template (value) RlcmacUlCtrlMsg cell_chg_notif;
+ var RlcmacDlBlock dl_block;
+ var uint32_t sched_fn;
+ var CtrlMessage rx_ctrl;
+ var charstring ctrl_var;
+ var PCUIF_Message pcu_msg;
+ var GsmArfcn req_arfcn := 862;
+ var uint6_t req_bsic := 43;
+ var boolean use_old_ctrl_iface := mp_ctrl_neigh_ip != "";
+
+ if (use_old_ctrl_iface) {
+ /* Initialize osmo-bsc emulation neighbor resolution CTRL port */
+ f_ipa_ctrl_start_server(mp_ctrl_neigh_ip, mp_ctrl_neigh_port);
+ }
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Make sure we are not affected by full cache from previous tests */
+ f_pcuvty_flush_neigh_caches();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Send PACKET RESOURCE REQUEST */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap_gprs_def));
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ /* Start NACC from MS side */
+ cell_chg_notif := ts_RlcMacUlCtrl_PKT_CELL_CHG_NOTIF(ms.ul_tbf.tfi, req_arfcn, req_bsic);
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* osmo-pcu should now ask for resolution: */
+ if (use_old_ctrl_iface) {
+ f_ctrl_rx_nacc_rac_ci_req(rx_ctrl, info_ind, req_arfcn, req_bsic);
+ } else {
+ f_pcuif_rx_nacc_rac_ci_req(pcu_msg, info_ind, req_arfcn, req_bsic);
+ }
+ /* Before receiving CTRL response, MS retransmits Pkt cell Chg Notif with different tgt arfcn */
+ cell_chg_notif := ts_RlcMacUlCtrl_PKT_CELL_CHG_NOTIF(ms.ul_tbf.tfi, req_arfcn + 1, req_bsic + 1);
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+ f_sleep(0.2); /* let some time to avoid race conditons between CTRL and RLCMAC */
+ if (use_old_ctrl_iface) {
+ f_ctrl_tx_nacc_rac_ci_rsp(rx_ctrl);
+ } else {
+ f_pcuif_tx_nacc_rac_ci_rsp(pcu_msg);
+ }
+ /* We should now receive a 2nd CTRL request with the new ARFCN+BSIC */
+ f_handle_nacc_rac_ci_query(info_ind, req_arfcn + 1, req_bsic + 1, true, use_old_ctrl_iface);
+
+ /* And finally everything continues as usual with RIN procedure */
+ as_outbound_nacc_rim_resolve(info_ind);
+
+ /* Announce SI back to MS, continue NACC procedure */
+ f_ms_handle_pkt_neighbor_cell_data(ms, si_default);
+
+ /* Obtain a Downlink block and make sure it is a Pkt Cell Chg Continue */
+ f_rx_rlcmac_dl_block(dl_block, sched_fn);
+ if (not match(dl_block, tr_RLCMAC_DL_CTRL(?, tr_RlcMacDlCtrl_PKT_CELL_CHG_CONTINUE))) {
+ setverdict(fail, "Rx unexpected DL block: ", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ /* PKT CELL CHG CONTINUE ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ if (dl_block.ctrl.mac_hdr.rrbp_valid) {
+ sched_fn := f_rrbp_ack_fn(sched_fn, dl_block.ctrl.mac_hdr.rrbp);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Test MS sending Pkt Cell Change Notify twice (different tgt cell each time)
+ * while waiting for SI resolution */
+testcase TC_nacc_outbound_pkt_cell_chg_notif_twice2() runs on RAW_PCU_Test_CT {
+ var PollFnCtx pollctx;
+ var GprsMS ms;
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default);
+ var template (value) RlcmacUlCtrlMsg cell_chg_notif;
+ var RlcmacDlBlock dl_block;
+ var uint32_t sched_fn;
+ var CtrlMessage rx_ctrl;
+ var GsmArfcn req_arfcn := 862;
+ var uint6_t req_bsic := 43;
+ var boolean use_old_ctrl_iface := mp_ctrl_neigh_ip != "";
+
+ if (use_old_ctrl_iface) {
+ /* Initialize osmo-bsc emulation neighbor resolution CTRL port */
+ f_ipa_ctrl_start_server(mp_ctrl_neigh_ip, mp_ctrl_neigh_port);
+ }
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Make sure we are not affected by full cache from previous tests */
+ f_pcuvty_flush_neigh_caches();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Send PACKET RESOURCE REQUEST */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap_gprs_def));
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ /* Start NACC from MS side */
+ cell_chg_notif := ts_RlcMacUlCtrl_PKT_CELL_CHG_NOTIF(ms.ul_tbf.tfi, req_arfcn, req_bsic);
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* osmo-pcu should now ask for resolution: */
+ f_handle_nacc_rac_ci_query(info_ind, req_arfcn, req_bsic, true, use_old_ctrl_iface);
+ as_outbound_nacc_rim_resolve(info_ind, do_answer := false);
+ /* Before receiving RIM response, MS retransmits Pkt cell Chg Notif with different tgt cell: */
+ cell_chg_notif := ts_RlcMacUlCtrl_PKT_CELL_CHG_NOTIF(ms.ul_tbf.tfi, req_arfcn + 1, req_bsic + 1);
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+ f_sleep(0.2); /* let some time to avoid race conditons between CTRL and RLCMAC */
+ f_outbound_nacc_rim_tx_resp(info_ind);
+
+ /* As a result, CTRL + RIM resolution for new tgt cell should now be done: */
+ f_handle_nacc_rac_ci_query(info_ind, req_arfcn + 1, req_bsic + 1, true, use_old_ctrl_iface);
+
+ /* And finally everything continues as usual with RIN procedure */
+ as_outbound_nacc_rim_resolve(info_ind);
+
+ /* Announce SI back to MS, continue NACC procedure */
+ f_ms_handle_pkt_neighbor_cell_data(ms, si_default);
+
+ /* Obtain a Downlink block and make sure it is a Pkt Cell Chg Continue */
+ f_rx_rlcmac_dl_block(dl_block, sched_fn);
+ if (not match(dl_block, tr_RLCMAC_DL_CTRL(?, tr_RlcMacDlCtrl_PKT_CELL_CHG_CONTINUE))) {
+ setverdict(fail, "Rx unexpected DL block: ", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ /* PKT CELL CHG CONTINUE ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ if (dl_block.ctrl.mac_hdr.rrbp_valid) {
+ sched_fn := f_rrbp_ack_fn(sched_fn, dl_block.ctrl.mac_hdr.rrbp);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Test MS sending Pkt Cell Change Notify twice (different tgt cell each time)
+ * while sending Pkt Neigh Data Change */
+testcase TC_nacc_outbound_pkt_cell_chg_notif_twice3() runs on RAW_PCU_Test_CT {
+ var PollFnCtx pollctx;
+ var GprsMS ms;
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default);
+ var template (value) RlcmacUlCtrlMsg cell_chg_notif;
+ var RlcmacDlBlock dl_block;
+ var uint32_t sched_fn;
+ var CtrlMessage rx_ctrl;
+ var GsmArfcn req_arfcn := 862;
+ var uint6_t req_bsic := 43;
+ var boolean use_old_ctrl_iface := mp_ctrl_neigh_ip != "";
+
+ if (use_old_ctrl_iface) {
+ /* Initialize osmo-bsc emulation neighbor resolution CTRL port */
+ f_ipa_ctrl_start_server(mp_ctrl_neigh_ip, mp_ctrl_neigh_port);
+ }
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Make sure we are not affected by full cache from previous tests */
+ f_pcuvty_flush_neigh_caches();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Send PACKET RESOURCE REQUEST */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap_gprs_def));
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ /* Start NACC from MS side */
+ cell_chg_notif := ts_RlcMacUlCtrl_PKT_CELL_CHG_NOTIF(ms.ul_tbf.tfi, req_arfcn, req_bsic);
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* osmo-pcu should now ask for resolution: */
+ f_handle_nacc_rac_ci_query(info_ind, req_arfcn, req_bsic, true, use_old_ctrl_iface);
+ /* RIM procedure: */
+ as_outbound_nacc_rim_resolve(info_ind);
+
+ /* Receive first Pkt Neigh data Change, then trigger a new Pkt Cell Change Notif (different ARFCN+BSIC): */
+ f_ms_handle_pkt_neighbor_cell_data(ms, si_default, single_step := true);
+ cell_chg_notif := ts_RlcMacUlCtrl_PKT_CELL_CHG_NOTIF(ms.ul_tbf.tfi, req_arfcn + 1, req_bsic + 1);
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* It should trigger RAC_CI resolution to start again: */
+ f_handle_nacc_rac_ci_query(info_ind, req_arfcn + 1, req_bsic + 1, true, use_old_ctrl_iface);
+ /* RIM procedure: */
+ as_outbound_nacc_rim_resolve(info_ind);
+ /* Transmit SI back to MS */
+ f_ms_handle_pkt_neighbor_cell_data(ms, si_default);
+
+ /* Obtain a Downlink block and make sure it is a Pkt Cell Chg Continue */
+ f_rx_rlcmac_dl_block(dl_block, sched_fn);
+ if (not match(dl_block, tr_RLCMAC_DL_CTRL(?, tr_RlcMacDlCtrl_PKT_CELL_CHG_CONTINUE))) {
+ setverdict(fail, "Rx unexpected DL block: ", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ /* PKT CELL CHG CONTINUE ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ if (dl_block.ctrl.mac_hdr.rrbp_valid) {
+ sched_fn := f_rrbp_ack_fn(sched_fn, dl_block.ctrl.mac_hdr.rrbp);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Test MS sending Pkt Cell Change Notification twice (different tgt cell) while sending Pkt Cell Change Continue */
+testcase TC_nacc_outbound_pkt_cell_chg_notif_twice4() runs on RAW_PCU_Test_CT {
+ var PollFnCtx pollctx;
+ var GprsMS ms;
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default);
+ var template (value) RlcmacUlCtrlMsg cell_chg_notif;
+ var RlcmacDlBlock dl_block;
+ var uint32_t sched_fn;
+ var CtrlMessage rx_ctrl;
+ var GsmArfcn req_arfcn := 862;
+ var uint6_t req_bsic := 43;
+ var boolean use_old_ctrl_iface := mp_ctrl_neigh_ip != "";
+
+ if (use_old_ctrl_iface) {
+ /* Initialize osmo-bsc emulation neighbor resolution CTRL port */
+ f_ipa_ctrl_start_server(mp_ctrl_neigh_ip, mp_ctrl_neigh_port);
+ }
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Make sure we are not affected by full cache from previous tests */
+ f_pcuvty_flush_neigh_caches();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Send PACKET RESOURCE REQUEST */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap_gprs_def));
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ /* Start NACC from MS side */
+ cell_chg_notif := ts_RlcMacUlCtrl_PKT_CELL_CHG_NOTIF(ms.ul_tbf.tfi, req_arfcn, req_bsic);
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* osmo-pcu should now ask for resolution: */
+ f_handle_nacc_rac_ci_query(info_ind, req_arfcn, req_bsic, true, use_old_ctrl_iface);
+ /* RIM procedure: */
+ as_outbound_nacc_rim_resolve(info_ind);
+
+ /* Announce SI back to MS, continue NACC procedure */
+ f_ms_handle_pkt_neighbor_cell_data(ms, si_default);
+
+ /* trigger a Pkt Cell Change Notif with different tgt cell */
+ cell_chg_notif := ts_RlcMacUlCtrl_PKT_CELL_CHG_NOTIF(ms.ul_tbf.tfi, req_arfcn + 1, req_bsic + 1);
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* It should trigger RAC_CI resolution to start again: */
+ f_handle_nacc_rac_ci_query(info_ind, req_arfcn + 1, req_bsic + 1, true, use_old_ctrl_iface);
+
+ /* PCU TBF NACC state changed, so we should next receive a dummy block: */
+ f_rx_rlcmac_dl_block_exp_dummy(dl_block, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* RIM procedure: */
+ as_outbound_nacc_rim_resolve(info_ind);
+ /* Transmit SI back to MS */
+ f_ms_handle_pkt_neighbor_cell_data(ms, si_default);
+
+ /* Obtain a Downlink block and make sure it is a Pkt Cell Chg Continue */
+ f_rx_rlcmac_dl_block(dl_block, sched_fn);
+ if (not match(dl_block, tr_RLCMAC_DL_CTRL(?, tr_RlcMacDlCtrl_PKT_CELL_CHG_CONTINUE))) {
+ setverdict(fail, "Rx unexpected DL block: ", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ /* PKT CELL CHG CONTINUE ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ if (dl_block.ctrl.mac_hdr.rrbp_valid) {
+ sched_fn := f_rrbp_ack_fn(sched_fn, dl_block.ctrl.mac_hdr.rrbp);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Test MS sending Pkt Cell Change Notification twice (different tgt cell) while waiting for Pkt Cell Change Continue CTRL ACK*/
+testcase TC_nacc_outbound_pkt_cell_chg_notif_twice5() runs on RAW_PCU_Test_CT {
+ var PollFnCtx pollctx;
+ var GprsMS ms;
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default);
+ var template (value) RlcmacUlCtrlMsg cell_chg_notif;
+ var RlcmacDlBlock dl_block;
+ var uint32_t sched_fn;
+ var CtrlMessage rx_ctrl;
+ var GsmArfcn req_arfcn := 862;
+ var uint6_t req_bsic := 43;
+ var boolean use_old_ctrl_iface := mp_ctrl_neigh_ip != "";
+
+ if (use_old_ctrl_iface) {
+ /* Initialize osmo-bsc emulation neighbor resolution CTRL port */
+ f_ipa_ctrl_start_server(mp_ctrl_neigh_ip, mp_ctrl_neigh_port);
+ }
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Make sure we are not affected by full cache from previous tests */
+ f_pcuvty_flush_neigh_caches();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Send PACKET RESOURCE REQUEST */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap_gprs_def));
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ /* Start NACC from MS side */
+ cell_chg_notif := ts_RlcMacUlCtrl_PKT_CELL_CHG_NOTIF(ms.ul_tbf.tfi, req_arfcn, req_bsic);
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* osmo-pcu should now ask for resolution: */
+ f_handle_nacc_rac_ci_query(info_ind, req_arfcn, req_bsic, true, use_old_ctrl_iface);
+ /* RIM procedure: */
+ as_outbound_nacc_rim_resolve(info_ind);
+
+ /* Announce SI back to MS, continue NACC procedure */
+ f_ms_handle_pkt_neighbor_cell_data(ms, si_default);
+
+ /* Obtain a Downlink block and make sure it is a Pkt Cell Chg Continue */
+ f_rx_rlcmac_dl_block(dl_block, sched_fn);
+ if (not match(dl_block, tr_RLCMAC_DL_CTRL(?, tr_RlcMacDlCtrl_PKT_CELL_CHG_CONTINUE))) {
+ setverdict(fail, "Rx unexpected DL block: ", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+
+ /* trigger a Pkt Cell Change Notif with different tgt cell */
+ cell_chg_notif := ts_RlcMacUlCtrl_PKT_CELL_CHG_NOTIF(ms.ul_tbf.tfi, req_arfcn + 1, req_bsic + 1);
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* It should trigger RAC_CI resolution to start again: */
+ /* When using new PCUIF interface for resolution, we must
+ * PCUIF.receive() here since that's the first message in the PCUIF
+ * queue that PCU will have sent. Calling other functions doing
+ * PCUIF.receive() (like f_ms_tx_ul_block() below) will make them fail
+ * due to unexpected message receive. */
+ if (not use_old_ctrl_iface) {
+ f_handle_nacc_rac_ci_query(info_ind, req_arfcn + 1, req_bsic + 1, true, use_old_ctrl_iface);
+ }
+
+ /* PKT CELL CHG CONTINUE ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ if (dl_block.ctrl.mac_hdr.rrbp_valid) {
+ sched_fn := f_rrbp_ack_fn(sched_fn, dl_block.ctrl.mac_hdr.rrbp);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ }
+
+ /* When using CTRL interface, we must schedule the ACK before (see
+ * above) blocking here waiting for the resoltion, otherwise we'll be
+ * too late scheduling by the time the resolution is done. */
+ if (use_old_ctrl_iface) {
+ f_handle_nacc_rac_ci_query(info_ind, req_arfcn + 1, req_bsic + 1, true, use_old_ctrl_iface);
+ }
+
+ /* PCU TBF NACC state changed, so we should next receive a dummy block: */
+ f_rx_rlcmac_dl_block_exp_dummy(dl_block);
+
+ /* RIM procedure: */
+ as_outbound_nacc_rim_resolve(info_ind);
+ /* Transmit SI back to MS */
+ f_ms_handle_pkt_neighbor_cell_data(ms, si_default);
+
+ /* Obtain a Downlink block and make sure it is a Pkt Cell Chg Continue */
+ f_rx_rlcmac_dl_block(dl_block, sched_fn);
+ if (not match(dl_block, tr_RLCMAC_DL_CTRL(?, tr_RlcMacDlCtrl_PKT_CELL_CHG_CONTINUE))) {
+ setverdict(fail, "Rx unexpected DL block: ", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ /* PKT CELL CHG CONTINUE ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ if (dl_block.ctrl.mac_hdr.rrbp_valid) {
+ sched_fn := f_rrbp_ack_fn(sched_fn, dl_block.ctrl.mac_hdr.rrbp);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Test MS sending Pkt Cell Change Notification on an MS with an existing but unassigned (no TFI) DL TBF */
+testcase TC_nacc_outbound_pkt_cell_chg_notif_unassigned_dl_tbf() runs on RAW_PCU_Test_CT {
+ var PollFnCtx pollctx;
+ var GprsMS ms;
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default);
+ var template (value) RlcmacUlCtrlMsg cell_chg_notif;
+ var RlcmacDlBlock dl_block;
+ var uint32_t sched_fn, dl_fn;
+ var CtrlMessage rx_ctrl;
+ var GsmArfcn req_arfcn := 862;
+ var uint6_t req_bsic := 43;
+ var octetstring data := f_rnd_octstring(10);
+ var boolean use_old_ctrl_iface := mp_ctrl_neigh_ip != "";
+
+ if (use_old_ctrl_iface) {
+ /* Initialize osmo-bsc emulation neighbor resolution CTRL port */
+ f_ipa_ctrl_start_server(mp_ctrl_neigh_ip, mp_ctrl_neigh_port);
+ }
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+ /* Initialize GPRS MS side */
+ f_init_gprs_ms();
+ ms := g_ms[0]; /* We only use first MS in this test */
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Make sure we are not affected by full cache from previous tests */
+ f_pcuvty_flush_neigh_caches();
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
+
+ /* Send PACKET RESOURCE REQUEST */
+ pollctx := f_ms_establish_ul_tbf_2phase_access(ms, ts_RlcMacUlCtrl_PKT_RES_REQ(ms.tlli, ms_racap_gprs_def));
+ /* Pkt Uplink Assignment above sets poll+rrbp requesting PACKET CONTROL ACK */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), pollctx.fn, nr := pollctx.tstrxbts);
+
+ /* Start NACC from MS side */
+ cell_chg_notif := ts_RlcMacUlCtrl_PKT_CELL_CHG_NOTIF(ms.ul_tbf.tfi, req_arfcn, req_bsic);
+ f_ms_tx_ul_block(ms, ts_RLC_UL_CTRL_ACK(cell_chg_notif), 0, nr := f_ms_tx_TsTrxBtsNum(ms));
+
+ /* osmo-pcu should now ask for resolution: */
+ f_handle_nacc_rac_ci_query(info_ind, req_arfcn, req_bsic, true, use_old_ctrl_iface);
+ /* RIM procedure: */
+ as_outbound_nacc_rim_resolve(info_ind);
+
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data));
+ /* Make sure we leave some time for SGSN->PCU data to arrive to PCU */
+ f_sleep(0.1);
+ /* rx DL assignment, don't ack it yet (keep TBF in state ASSIGN): */
+ f_ms_rx_pkt_ass_pacch(ms, sched_fn, tr_RLCMAC_DL_PACKET_ASS);
+
+ /* NACC: scheduler selects tx Pkt Cell Neighbor Data. Receive first one: */
+ f_ms_handle_pkt_neighbor_cell_data(ms, si_default, single_step := true);
+ /* ACK DL assignment (we do it here on purpose to test tx Pkt Neigh Cell
+ * Data with unassigned DL TBF in line above): */
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ /* Continue receiving Pkt Cell Neighbor Data */
+ f_ms_handle_pkt_neighbor_cell_data(ms, si_default, f_ms_tx_TsTrxBtsNum(ms), 1, 16);
+
+ /* Obtain a Downlink block and make sure it is a Pkt Cell Chg Continue */
+ f_rx_rlcmac_dl_block(dl_block, sched_fn);
+ if (not match(dl_block, tr_RLCMAC_DL_CTRL(?, tr_RlcMacDlCtrl_PKT_CELL_CHG_CONTINUE))) {
+ setverdict(fail, "Rx unexpected DL block: ", dl_block);
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ /* PKT CELL CHG CONTINUE ACK/NACK sets poll+rrbp requesting PACKET CONTROL ACK */
+ if (dl_block.ctrl.mac_hdr.rrbp_valid) {
+ sched_fn := f_rrbp_ack_fn(sched_fn, dl_block.ctrl.mac_hdr.rrbp);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_CTRL_ACK(ms.tlli), sched_fn);
+ }
+
+ /* Now that we confirmed the new assignment in the dl-tbf, lets receive the data and ack it */
+ f_rx_rlcmac_dl_block_exp_data(dl_block, dl_fn, data, 0);
+ f_acknackdesc_ack_block(ms.dl_tbf.acknack_desc, dl_block, '1'B);
+ f_ms_tx_ul_block(ms, ts_RLCMAC_DL_ACK_NACK(ms.dl_tbf.tfi, ms.dl_tbf.acknack_desc),
+ f_dl_block_ack_fn(dl_block, dl_fn));
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+
+function f_do_inbound_nacc(template (value) RIM_Routing_Information tx_src_addr, template RIM_Routing_Information rx_dst_addr)
+runs on RAW_PCU_Test_CT
+{
+ var template (value) RAN_Information_Request_RIM_Container req_cont;
+ var template (value) PDU_BSSGP bssgp_rim_pdu;
+ var template PDU_BSSGP bssgp_rim_pdu_expect;
+ var template RAN_Information_RIM_Container rim_cont_expect;
+ var RIM_Routing_Address bts_addr;
+
+ /* Send sysinfo to the PCU */
+ var template PCUIF_Message si1_data_ind := ts_PCUIF_DATA_IND(0, 0, 0, 0, PCU_IF_SAPI_BCCH, '5506'O & si1_default, 0, 0, 0, 0, 32767);
+ BTS.send(si1_data_ind);
+ var template PCUIF_Message si3_data_ind := ts_PCUIF_DATA_IND(0, 0, 0, 0, PCU_IF_SAPI_BCCH, '4906'O & si3_default, 0, 0, 0, 0, 32767);
+ BTS.send(si3_data_ind);
+ var template PCUIF_Message si13_data_ind := ts_PCUIF_DATA_IND(0, 0, 0, 0, PCU_IF_SAPI_BCCH, '0106'O & si13_default, 0, 0, 0, 0, 32767);
+ BTS.send(si13_data_ind);
+ f_sleep(1.0);
+
+ bts_addr := valueof(t_RIM_Routing_Address_cid(mp_gb_cfg.bvc[0].cell_id));
+
+ req_cont := ts_RAN_Information_Request_RIM_Container(ts_RIM_Application_Identity(RIM_APP_ID_NACC),
+ ts_RIM_Sequence_Number(1),
+ ts_RIM_PDU_Indications(false, RIM_PDU_TYPE_SING_REP),
+ ts_RIM_Protocol_Version_Number(1),
+ tsu_RAN_Information_Request_Application_Container_NACC(mp_gb_cfg.bvc[0].cell_id),
+ omit);
+ bssgp_rim_pdu := ts_RAN_INFORMATION_REQUEST(ts_RIM_Routing_Information(RIM_ADDR_GERAN_CELL_ID, bts_addr),
+ tx_src_addr, req_cont);
+
+ rim_cont_expect := tr_RAN_Information_RIM_Container(tr_RIM_Application_Identity(RIM_APP_ID_NACC),
+ tr_RIM_Sequence_Number(1),
+ tr_RIM_PDU_Indications(false, RIM_PDU_TYPE_SING_REP),
+ tr_RIM_Protocol_Version_Number(1),
+ tru_ApplContainer_or_ApplErrContainer_NACC(tru_ApplContainer_NACC(mp_gb_cfg.bvc[0].cell_id, false, 3, si_default)),
+ omit);
+
+ bssgp_rim_pdu_expect := tr_PDU_BSSGP_RAN_INFORMATION(rx_dst_addr,
+ tr_RIM_Routing_Information(RIM_ADDR_GERAN_CELL_ID, bts_addr),
+ rim_cont_expect);
+ RIM.send(bssgp_rim_pdu);
+ timer T := 2.0;
+ T.start;
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
+ [] RIM.receive(bssgp_rim_pdu_expect) { }
+ [] RIM.receive {
+ setverdict(fail, "Unexpected BSSGP RIM PDU received");
+ }
+ [] T.timeout {
+ setverdict(fail, "No BSSGP RIM PDU received");
+ mtc.stop;
+ }
+ }
+}
+/* Send a RIM RAN info request to the PCU and verify the response, we expect
+ * getting the system information back which we have transfered to the PCU via
+ * PCUIF on startup. */
+testcase TC_rim_ran_info_req_single_rep() runs on RAW_PCU_Test_CT {
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+
+ var BssgpCellId src_cid := {ra_id := { lai := { mcc_mnc := '262F42'H, lac := 12345}, rac := 0 }, cell_id := 20962 };
+ var RIM_Routing_Address src_addr := valueof(t_RIM_Routing_Address_cid(src_cid));
+
+ f_do_inbound_nacc(ts_RIM_Routing_Information(RIM_ADDR_GERAN_CELL_ID, src_addr),
+ tr_RIM_Routing_Information(RIM_ADDR_GERAN_CELL_ID, src_addr));
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Same as TC_rim_ran_info_req_single_rep, but using an EUTRAN eNodeB ID as
+ * Routing information, to verify PCU handles that kind of address just fine
+ */
+testcase TC_rim_ran_info_req_single_rep_eutran() runs on RAW_PCU_Test_CT {
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+
+ var BssgpCellId src_cid := {ra_id := { lai := { mcc_mnc := '262F42'H, lac := 12345}, rac := 0 }, cell_id := 20962 };
+ var RIM_Routing_Address src_addr := valueof(t_RIM_Routing_Address_enbid(src_cid, tac := 3, gnbid := '12345678123456'O));
+
+ f_do_inbound_nacc(ts_RIM_Routing_Information(RIM_ADDR_EUTRAN_NODEB_ID, src_addr),
+ tr_RIM_Routing_Information(RIM_ADDR_EUTRAN_NODEB_ID, src_addr));
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Same as above, but in this case we simulate the rare case in which the PCU
+ * has no system information available. We expect getting a response back but
+ * with no system information inside. */
+testcase TC_rim_ran_info_req_single_rep_no_si() runs on RAW_PCU_Test_CT {
+ var template (value) PCUIF_info_ind info_ind := ts_PCUIF_INFO_default;
+ var PCUIF_Message pcu_msg;
+ timer T := 2.0;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+
+ /* Clear sysinfo from the PCU */
+ var template PCUIF_Message si1_data_ind := ts_PCUIF_DATA_IND(0, 0, 0, 0, PCU_IF_SAPI_BCCH, '01'O, 0, 0, 0, 0, 32767);
+ BTS.send(si1_data_ind);
+ var template PCUIF_Message si3_data_ind := ts_PCUIF_DATA_IND(0, 0, 0, 0, PCU_IF_SAPI_BCCH, '03'O, 0, 0, 0, 0, 32767);
+ BTS.send(si3_data_ind);
+ var template PCUIF_Message si16_data_ind := ts_PCUIF_DATA_IND(0, 0, 0, 0, PCU_IF_SAPI_BCCH, '0b'O, 0, 0, 0, 0, 32767);
+ BTS.send(si16_data_ind);
+ f_sleep(1.0);
+
+ var RIM_Routing_Address dst_addr;
+ var RIM_Routing_Address src_addr;
+ var template (value) RAN_Information_Request_RIM_Container req_cont;
+ var template (value) PDU_BSSGP bssgp_rim_pdu;
+ var template PDU_BSSGP bssgp_rim_pdu_expect;
+ var template RAN_Information_RIM_Container rim_cont_expect;
+
+ var BssgpCellId src_cid := {ra_id := { lai := { mcc_mnc := '262F42'H, lac := 12345}, rac := 0 }, cell_id := 20962 };
+ src_addr := valueof(t_RIM_Routing_Address_cid(src_cid));
+ dst_addr := valueof(t_RIM_Routing_Address_cid(mp_gb_cfg.bvc[0].cell_id));
+
+ req_cont := ts_RAN_Information_Request_RIM_Container(ts_RIM_Application_Identity(RIM_APP_ID_NACC),
+ ts_RIM_Sequence_Number(1),
+ ts_RIM_PDU_Indications(false, RIM_PDU_TYPE_SING_REP),
+ ts_RIM_Protocol_Version_Number(1),
+ tsu_RAN_Information_Request_Application_Container_NACC(mp_gb_cfg.bvc[0].cell_id),
+ omit);
+ bssgp_rim_pdu := ts_RAN_INFORMATION_REQUEST(ts_RIM_Routing_Information(RIM_ADDR_GERAN_CELL_ID, dst_addr),
+ ts_RIM_Routing_Information(RIM_ADDR_GERAN_CELL_ID, src_addr),
+ req_cont);
+
+
+ rim_cont_expect := tr_RAN_Information_RIM_Container(tr_RIM_Application_Identity(RIM_APP_ID_NACC),
+ tr_RIM_Sequence_Number(1),
+ tr_RIM_PDU_Indications(false, RIM_PDU_TYPE_SING_REP),
+ tr_RIM_Protocol_Version_Number(1),
+ tru_ApplContainer_or_ApplErrContainer_NACC(tru_ApplContainer_NACC(mp_gb_cfg.bvc[0].cell_id, false, 0, ''O)),
+ omit);
+
+ bssgp_rim_pdu_expect := tr_PDU_BSSGP_RAN_INFORMATION(tr_RIM_Routing_Information(RIM_ADDR_GERAN_CELL_ID, src_addr),
+ tr_RIM_Routing_Information(RIM_ADDR_GERAN_CELL_ID, dst_addr),
+ rim_cont_expect);
+ RIM.send(bssgp_rim_pdu);
+ T.start;
+ alt {
+ [] RIM.receive(bssgp_rim_pdu_expect) { }
+ [] RIM.receive {
+ setverdict(fail, "Unexpected BSSGP RIM PDU received");
+ }
+ [] T.timeout {
+ setverdict(fail, "No BSSGP RIM PDU received");
+ mtc.stop;
+ }
+ }
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
+
+/* Verify PCU schedule idle blocks (len=0) if no TBF attached to it. See OS#4772, SYS#4919 */
+testcase TC_pdch_energy_saving() runs on RAW_PCU_Test_CT {
+ var PCUIF_info_ind info_ind;
+ var template (value) TsTrxBtsNum nr;
+ var RlcmacDlBlock dl_block;
+ var BTS_PDTCH_Block data_msg;
+ var integer ts;
+ timer T;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+
+ info_ind := valueof(ts_PCUIF_INFO_default);
+ /* The 2 first TRX are enabled. */
+ f_PCUIF_PDCHMask_set(info_ind, '00000000'B, (2 .. 7));
+ f_PCUIF_PDCHMask_set(info_ind, '00000001'B, 0);
+ f_PCUIF_PDCHMask_set(info_ind, '00000001'B, 1);
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Establish BSSGP connection to the PCU */
+ f_bssgp_establish();
+
+ for (ts := 0; ts < 2; ts := ts + 1) {
+ nr := ts_TsTrxBtsNum(ts_nr := 7, trx_nr := ts, bts_nr := 0, blk_nr := 0);
+
+ BTS.send(ts_PCUIF_RTS_REQ(nr.bts_nr, nr.trx_nr, nr.ts_nr,
+ sapi := PCU_IF_SAPI_PDTCH, fn := 0,
+ arfcn := f_trxnr2arfcn(valueof(nr.trx_nr)), block_nr := nr.blk_nr));
+ T.start(0.5);
+ alt {
+ [] BTS.receive(tr_PCUIF_DATA_PDTCH(nr.bts_nr,
+ tr_PCUIF_DATA(nr.trx_nr, nr.ts_nr, sapi := PCU_IF_SAPI_PDTCH),
+ omit)) -> value data_msg {
+ setverdict(pass);
+ T.stop;
+ }
+ [] as_rx_fail_dummy(nr);
+ [] BTS.receive {
+ setverdict(fail, "Unexpected block from BTS");
+ f_shutdown(__BFILE__, __LINE__);
+ }
+ [] T.timeout {
+ setverdict(fail, "Expected IDLE block from BTS");
+ f_shutdown(__BFILE__, __LINE__);
}
- 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);
+ f_shutdown(__BFILE__, __LINE__, final := 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;
+/* Test stats for available and occupied PDCHs */
+testcase TC_stat_pdch_avail_occ() runs on RAW_PCU_Test_CT {
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default);
+ const BssgpBvci bvci := mp_gb_cfg.bvc[0].bvci;
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+
+ /* Only the 4 first TRX are enabled, each with 2 PDCHs. */
+ f_PCUIF_PDCHMask_set(info_ind, '00000011'B, 0);
+ f_PCUIF_PDCHMask_set(info_ind, '00001100'B, 1);
+ f_PCUIF_PDCHMask_set(info_ind, '11000000'B, 2);
+ f_PCUIF_PDCHMask_set(info_ind, '00110000'B, 3);
+ f_PCUIF_PDCHMask_set(info_ind, '00000000'B, (4 .. 7));
+
+ /* Allocate 4 GprsMS instances */
+ f_init_gprs_ms(4);
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Reset stats */
+ f_statsd_reset();
+
+ /* Establish BSSGP */
+ f_bssgp_establish();
+
+ /* 8 PDCHs available, 0 occupied */
+ var StatsDExpects expect := {
+ { name := "TTCN3.bts.0.pdch.available", mtype := "g", min := 8, max := 8 },
+ { name := "TTCN3.bts.0.pdch.occupied", mtype := "g", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.pdch.occupied.gprs", mtype := "g", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.pdch.occupied.egprs", mtype := "g", min := 0, max := 0 }
+ };
+ f_statsd_expect(expect);
+
+ /* Establish an Uplink TBF for each GprsMS instance (3x GPRS, 1x EGPRS) */
+ f_multi_ms_bssgp_register();
+ f_ms_establish_ul_tbf(g_ms[0]);
+ f_ms_establish_ul_tbf(g_ms[1]);
+ f_ms_establish_ul_tbf(g_ms[2]);
+ f_ms_establish_ul_tbf_2phase_access(g_ms[3], ts_RlcMacUlCtrl_PKT_RES_REQ(g_ms[3].tlli, ms_racap_egprs_def));
+
+ /* 4 PDCHs occupied */
+ expect := {
+ { name := "TTCN3.bts.0.pdch.available", mtype := "g", min := 8, max := 8 },
+ { name := "TTCN3.bts.0.pdch.occupied", mtype := "g", min := 4, max := 4 },
+ { name := "TTCN3.bts.0.pdch.occupied.gprs", mtype := "g", min := 3, max := 3 },
+ { name := "TTCN3.bts.0.pdch.occupied.egprs", mtype := "g", min := 1, max := 1 }
+ };
+ f_statsd_expect(expect);
+
+ f_shutdown(__BFILE__, __LINE__, final := true);
}
-/* 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
+/* Test stats for available and occupied PDCHs, for MS which is not known by
+ * the PCU (e.g. because it was forgotten due to no interaction, and old DL
+ * data arrives from SGSN) */
+function f_tc_stat_pdch_avail_occ_ms_not_known(boolean egprs) runs on RAW_PCU_Test_CT {
+ var PCUIF_info_ind info_ind := valueof(ts_PCUIF_INFO_default);
+ const BssgpBvci bvci := mp_gb_cfg.bvc[0].bvci;
+
+ /* Ensure a deterministic slot allocation of 1 PDCH with MS class 1 */
+ const MultislotCap_GPRS_BSSGP bssgp_mscap_gprs := {
+ gprsmultislotclass := '00001'B,
+ gprsextendeddynalloccap := '0'B
};
+ const MultislotCap_EGPRS_BSSGP bssgp_mscap_egprs := {
+ egprsmultislotclass := '00001'B,
+ egprsextendeddynalloccap := '0'B
+ };
+ template (value) MSRadioAccessCapabilityV_BSSGP bssgp_ms_racap_gprs := {
+ valueof(ts_RaCapRec_BSSGP('0001'B /* E-GSM */, bssgp_mscap_gprs, omit)) };
+ template (value) MSRadioAccessCapabilityV_BSSGP bssgp_ms_racap_egprs := {
+ valueof(ts_RaCapRec_BSSGP('0001'B /* E-GSM */, bssgp_mscap_gprs, bssgp_mscap_egprs)) };
+
+ /* Initialize NS/BSSGP side */
+ f_init_bssgp();
+
+ /* Only the 4 first TRX are enabled, each with 2 PDCHs. */
+ f_PCUIF_PDCHMask_set(info_ind, '00000011'B, 0);
+ f_PCUIF_PDCHMask_set(info_ind, '00001100'B, 1);
+ f_PCUIF_PDCHMask_set(info_ind, '11000000'B, 2);
+ f_PCUIF_PDCHMask_set(info_ind, '00110000'B, 3);
+ f_PCUIF_PDCHMask_set(info_ind, '00000000'B, (4 .. 7));
+
+ /* Allocate 1 GprsMS instance */
+ f_init_gprs_ms(1);
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+
+ /* Reset stats */
+ f_statsd_reset();
+
+ /* Establish BSSGP */
+ f_bssgp_establish();
+
+ /* 8 PDCHs available, 0 occupied */
+ var StatsDExpects expect := {
+ { name := "TTCN3.bts.0.pdch.available", mtype := "g", min := 8, max := 8 },
+ { name := "TTCN3.bts.0.pdch.occupied", mtype := "g", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.pdch.occupied.gprs", mtype := "g", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.pdch.occupied.egprs", mtype := "g", min := 0, max := 0 }
+ };
+ f_statsd_expect(expect);
+ var GprsMS ms := g_ms[0]; /* We only use first MS in this test */
+ f_bssgp_client_llgmm_assign(TLLI_UNUSED, ms.tlli);
- if (g_initialized == true) {
- return;
+ /* SGSN sends some DL data, PCU will page on CCCH (PCH) */
+ var octetstring data := f_rnd_octstring(1400);
+ if (egprs) {
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, bssgp_ms_racap_egprs, imsi := ts_BSSGP_IMSI(ms.imsi)));
+ } else {
+ BSSGP[0].send(ts_BSSGP_DL_UD(ms.tlli, data, bssgp_ms_racap_gprs, imsi := ts_BSSGP_IMSI(ms.imsi)));
}
- g_initialized := true;
+ f_ms_exp_dl_tbf_ass_ccch(ms);
- /* 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));
+ /* Wait timer X2002 and DL block is available after CCCH IMM ASS */
+ f_sleep(X2002);
+
+ /* 1 PDCH occupied */
+ if (egprs) {
+ expect := {
+ { name := "TTCN3.bts.0.pdch.available", mtype := "g", min := 8, max := 8 },
+ { name := "TTCN3.bts.0.pdch.occupied", mtype := "g", min := 1, max := 1 },
+ { name := "TTCN3.bts.0.pdch.occupied.gprs", mtype := "g", min := 0, max := 0 },
+ { name := "TTCN3.bts.0.pdch.occupied.egprs", mtype := "g", min := 1, max := 1 }
+ };
+ } else {
+ expect := {
+ { name := "TTCN3.bts.0.pdch.available", mtype := "g", min := 8, max := 8 },
+ { name := "TTCN3.bts.0.pdch.occupied", mtype := "g", min := 1, max := 1 },
+ { name := "TTCN3.bts.0.pdch.occupied.gprs", mtype := "g", min := 1, max := 1 },
+ { name := "TTCN3.bts.0.pdch.occupied.egprs", mtype := "g", min := 0, max := 0 }
+ };
+ }
+ f_statsd_expect(expect);
- f_bssgp_client_register(mmctx.imsi, mmctx.tlli, mp_gb_cfg.cell_id);
+ /* Clean up */
+ f_shutdown(__BFILE__, __LINE__, final := true);
}
+testcase TC_stat_pdch_avail_occ_ms_not_known_gprs() runs on RAW_PCU_Test_CT {
+ f_tc_stat_pdch_avail_occ_ms_not_known(false);
+}
+testcase TC_stat_pdch_avail_occ_ms_not_known_egprs() runs on RAW_PCU_Test_CT {
+ f_tc_stat_pdch_avail_occ_ms_not_known(true);
+}
+
+/* Make sure that bts.0.pdch.all_allocated is set when we allocate all resources */
+testcase TC_ratectr_all_available_allocated() runs on RAW_PCU_Test_CT {
+ var PCUIF_info_ind info_ind;
+ var template IARRestOctets rest;
+ var BIT11 ra11;
+
+ info_ind := valueof(ts_PCUIF_INFO_default);
+
+ /* Only the first TRX is enabled. */
+ f_PCUIF_PDCHMask_set(info_ind, '00000000'B, (1 .. 7));
+ f_PCUIF_PDCHMask_set(info_ind, '00000001'B, 0);
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename(), info_ind);
+ f_statsd_reset();
+
+ var EGPRSPktChRequest req := {
+ one_phase := {
+ tag := '0'B,
+ multislot_class := '10101'B,
+ priority := '01'B,
+ random_bits := '101'B
+ }
+ };
+
+ /* We send 7 requests, the IUT gives us all available USFs (0..6) */
+ for (var integer i := 0; i < 7; i := i + 1) {
+ req.one_phase.random_bits := int2bit(f_rnd_int(8), 3);
+ f_TC_egprs_pkt_chan_req(req, tr_IMM_TBF_ASS);
+ }
+ ra11 := enc_EGPRSPktChRequest2bits(req);
+ rest := tr_IARRestOctets({ *, tr_ExtRAOpt(substr(ra11, 6, 5)), * });
+
+ /* At this point, the IUT should run out of free USFs */
+ f_TC_egprs_pkt_chan_req_reject(ra11, 1870, rest);
+
+ /* bts.0.pdch.all_allocated is updated once per second, wait some time to make sure it was updated. */
+ f_sleep(2.0);
+ var StatsDExpects expect := {
+ { name := "TTCN3.bts.0.pdch.all_allocated", mtype := "c", min := 1, max := 1 }
+ };
+ f_statsd_expect(expect);
+ f_shutdown(__BFILE__, __LINE__, final := true);
+}
control {
- execute(TC_selftest_ns());
- execute(TC_ul_tbf_single_llc_sizes());
- execute(TC_ul_tbf());
- execute(TC_paging());
+ execute( TC_pcuif_suspend() );
+ execute( TC_pcuif_suspend_active_tbf() );
+ execute( TC_ta_ptcch_idle() );
+ execute( TC_ta_rach_imm_ass() );
+ execute( TC_ta_ul_ack_nack_first_block() );
+ execute( TC_ta_idle_dl_tbf_ass() );
+ execute( TC_ta_ptcch_ul_multi_tbf() );
+ execute( TC_cs_lqual_ul_tbf() );
+ execute( TC_cs_initial_ul() );
+ execute( TC_cs_max_ul() );
+ execute( TC_cs_initial_dl() );
+ execute( TC_cs_max_dl() );
+ execute( TC_dl_cs1_to_cs4() );
+ execute( TC_mcs_initial_ul() );
+ execute( TC_mcs_max_ul() );
+ execute( TC_mcs_initial_dl() );
+ execute( TC_mcs_max_dl() );
+ execute( TC_t3141() );
+ execute( TC_n3101_max_t3169() );
+ execute( TC_n3103_max_t3169() );
+ execute( TC_x2031_t3191() );
+ execute( TC_zero_x2031_t3191() );
+ execute( TC_t3193() );
+ execute( TC_n3105_max_t3195() );
+ execute( TC_t3172_wait_ind_size0() );
+ execute( TC_t3172_wait_ind_size1() );
+ execute( TC_countdown_procedure() );
+ execute( TC_ul_all_sizes() );
+ execute( TC_ul_data_toolong_fills_padding() );
+ execute( TC_mo_ping_pong() );
+ execute( TC_mo_ping_pong_with_ul_racap() );
+ execute( TC_force_two_phase_access() );
+ execute( TC_mt_ping_pong() );
+ execute( TC_mt_ping_pong_with_dl_racap() );
+ execute( TC_ul_intermediate_retrans() );
+ execute( TC_imm_ass_dl_block_retrans() );
+ execute( TC_dl_flow_more_blocks() );
+ execute( TC_ul_flow_multiple_llc_blocks() );
+ execute( TC_dl_no_ack_retrans_imm_ass() );
+ execute( TC_dl_llc_sapi_priority() );
+ execute( TC_ul_tbf_bsn_wraparound_gprs());
+ execute( TC_paging_cs_from_bts() );
+ execute( TC_paging_cs_from_sgsn_sign_ptmsi() );
+ execute( TC_paging_cs_from_sgsn_sign() );
+ execute( TC_paging_cs_from_sgsn_ptp() );
+ execute( TC_paging_ps_from_sgsn_sign_ptmsi() );
+ execute( TC_paging_ps_from_sgsn_sign() );
+ execute( TC_paging_ps_from_sgsn_ptp() );
+ execute( TC_paging_pch_timeout() );
+
+ execute( TC_paging_cs_multi_ms_imsi_tmsi() );
+ execute( TC_paging_cs_multi_ms_imsi() );
+ execute( TC_paging_cs_multi_ms_tmsi() );
+ execute( TC_bssgp_dl_unitdata_with_valid_imsi() );
+ execute( TC_bssgp_dl_unitdata_with_invalid_imsi() );
+ execute( TC_dl_gprs_data_no_llc_ui_dummy() );
+ execute( TC_dl_egprs_data_no_llc_ui_dummy() );
+
+ execute( TC_ul_tbf_finished_pkt_dl_ass_pch() );
+ execute( TC_ul_tbf_1phase_while_dl_ass_pch() );
+ execute( TC_ul_tbf_2phase_while_dl_ass_pch() );
+
+ /* EGPRS specific test cases */
+ execute( TC_egprs_pkt_chan_req_signalling() );
+ execute( TC_egprs_pkt_chan_req_one_phase() );
+ execute( TC_egprs_pkt_chan_req_two_phase() );
+ execute( TC_egprs_pkt_chan_req_reject_content() );
+ execute( TC_egprs_pkt_chan_req_reject_emergency() );
+ execute( TC_egprs_pkt_chan_req_reject_exhaustion() );
+
+ execute( TC_mo_ping_pong_with_ul_racap_egprs_only() );
+
+ /* Immediate Assignment on AGCH/PCH */
+ execute( TC_pcuif_fh_imm_ass_ul_egprs() );
+ execute( TC_pcuif_fh_imm_ass_ul() );
+ execute( TC_pcuif_fh_imm_ass_dl() );
+ /* Packet Uplink/Downlink Assignment on PACCH */
+ execute( TC_pcuif_fh_pkt_ass_ul() );
+ execute( TC_pcuif_fh_pkt_ass_dl() );
+ execute( TC_multitrx_multims_alloc() );
+ execute( TC_dl_multislot_tbf_ms_class_from_sgsn() );
+ execute( TC_dl_multislot_tbf_ms_class_unknown() );
+ execute( TC_dl_multislot_tbf_ms_class_from_2phase() );
+ execute( TC_ul_multislot_tbf_ms_class_from_2phase() );
+ execute( TC_ul_tbf_reestablish_with_pkt_resource_req() );
+ execute( TC_ul_tbf_reestablish_with_pkt_resource_req_t3168() );
+ execute( TC_ul_tbf_reestablish_with_pkt_dl_ack_nack() );
+ execute( TC_ul_tbf_reestablish_with_pkt_dl_ack_nack_egprs() );
+
+ execute( TC_multiplex_dl_gprs_egprs() );
+
+ execute( TC_pcuif_info_ind_subsequent() );
+ execute( TC_nacc_outbound_success() );
+ execute( TC_nacc_outbound_success_utran() );
+ execute( TC_nacc_outbound_success_eutran() );
+ execute( TC_nacc_outbound_success_no_ctrl_ack() );
+ execute( TC_nacc_outbound_success_twice() );
+ execute( TC_nacc_outbound_success_twice_nocache() );
+ execute( TC_nacc_outbound_rac_ci_resolve_timeout() );
+ execute( TC_nacc_outbound_si_resolve_timeout() );
+ execute( TC_nacc_outbound_pkt_cell_chg_notif_dup() );
+ execute( TC_nacc_outbound_pkt_cell_chg_notif_dup2() );
+ execute( TC_nacc_outbound_pkt_cell_chg_notif_dup3() );
+ execute( TC_nacc_outbound_pkt_cell_chg_notif_dup4() );
+ execute( TC_nacc_outbound_pkt_cell_chg_notif_dup5() );
+ execute( TC_nacc_outbound_pkt_cell_chg_notif_twice() );
+ execute( TC_nacc_outbound_pkt_cell_chg_notif_twice2() );
+ execute( TC_nacc_outbound_pkt_cell_chg_notif_twice3() );
+ execute( TC_nacc_outbound_pkt_cell_chg_notif_twice4() );
+ execute( TC_nacc_outbound_pkt_cell_chg_notif_twice5() );
+ execute( TC_nacc_outbound_pkt_cell_chg_notif_unassigned_dl_tbf() );
+ if (mp_ctrl_neigh_ip != "") { /* PCU using old CTRL neigh addr resolution iface */
+ execute( TC_nacc_outbound_rac_ci_resolve_conn_refused() );
+ execute( TC_nacc_outbound_rac_ci_resolve_fail_parse_response() );
+ }
+
+ execute( TC_rim_ran_info_req_single_rep() );
+ execute( TC_rim_ran_info_req_single_rep_eutran() );
+ execute( TC_rim_ran_info_req_single_rep_no_si() );
+
+ execute (TC_pdch_energy_saving() );
+
+ execute( TC_stat_pdch_avail_occ() );
+ execute( TC_stat_pdch_avail_occ_ms_not_known_gprs() );
+ execute( TC_stat_pdch_avail_occ_ms_not_known_egprs() );
+ execute( TC_ratectr_all_available_allocated() );
}
-};
+}
diff --git a/pcu/PCU_Tests_NS.ttcn b/pcu/PCU_Tests_NS.ttcn
new file mode 100644
index 00000000..eea8d3f5
--- /dev/null
+++ b/pcu/PCU_Tests_NS.ttcn
@@ -0,0 +1,248 @@
+module PCU_Tests_NS {
+
+/* Osmocom PCU test suite for IP Sub-Network-Service (SNS) in TTCN-3
+ * (C) 2018-2019 Harald Welte <laforge@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 Osmocom_VTY_Functions all;
+import from TELNETasp_PortType all;
+import from PCU_Tests all;
+import from SGSN_Components all;
+import from Osmocom_Gb_Types all;
+import from NS_Types all;
+import from BSSGP_Types all;
+import from UD_Types all;
+import from NS_Emulation all;
+import from Native_Functions all;
+import from IPL4asp_Types all;
+import from PCUIF_Types all;
+import from PCUIF_CodecPort all;
+import from RAW_NS all;
+
+type component RAW_PCU_CT {
+ /* PCUIF (we emulate the BTS part) */
+ port PCUIF_CODEC_PT PCU;
+ var ConnectionId g_pcu_conn_id := -1;
+ /* VTY connection to the PCU */
+ port TELNETasp_PT PCUVTY;
+}
+
+type component RAW_Test_CT extends RAW_NS_CT, RAW_PCU_CT {
+}
+
+function f_init_vty(charstring id) runs on RAW_PCU_CT {
+ map(self:PCUVTY, system:PCUVTY);
+ f_vty_set_prompts(PCUVTY);
+ f_vty_transceive(PCUVTY, "enable");
+}
+
+function f_init_pcuif() runs on RAW_PCU_CT {
+ var PCUIF_info_ind info_ind;
+ map(self:PCU, system:PCU);
+
+
+ info_ind := valueof(ts_PCUIF_INFO_default);
+
+ /* Connect the Unix Domain Socket */
+ g_pcu_conn_id := f_pcuif_listen(PCU, mp_pcu_sock_path);
+ PCU.receive(UD_connected:?);
+
+ /* Wait for PCU_VERSION and return INFO_IND */
+ PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TXT_IND(0, PCU_VERSION, ?)));
+ /* FIXME: make sure to use parameters from mp_gb_cfg.bvc[0].cell_id in the PCU INFO IND */
+ var template PCUIF_Message info_ind_msg := ts_PCUIF_INFO_IND(0, info_ind);
+ PCU.send(t_SD_PCUIF(g_pcu_conn_id, info_ind_msg));
+}
+
+function f_pcuif_tx(template (value) PCUIF_Message msg) runs on RAW_PCU_CT {
+ PCU.send(t_SD_PCUIF(g_pcu_conn_id, msg));
+}
+
+/* ensure no matching message is received within 'tout' */
+function f_ensure_no_ns(template PDU_NS ns := ?, integer idx := 0, float tout := 3.0)
+runs on RAW_Test_CT {
+ timer T := tout;
+ T.start;
+ alt {
+ [] NSCP[idx].receive(ns) {
+ setverdict(fail, "NS-ALIVE from unconfigured (possibly initial) endpoint");
+ }
+ [] T.timeout {
+ setverdict(pass);
+ }
+ }
+}
+
+/* test the NS-RESET procedure */
+testcase TC_ns_reset() runs on RAW_Test_CT {
+ f_init_ns_codec(mp_nsconfig);
+ f_init_pcuif();
+
+
+ /* Expect inbound NS-RESET procedure */
+ as_rx_ns_reset_ack(oneshot := true);
+ setverdict(pass);
+ f_clean_ns_codec();
+}
+
+/* ensure NS-RESET are re-transmitted */
+testcase TC_ns_reset_retrans() runs on RAW_Test_CT {
+ f_init_ns_codec(mp_nsconfig);
+ f_init_pcuif();
+
+ var integer i;
+ for (i := 0; i < 3; i := i+1) {
+ NSCP[0].receive(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION,
+ g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
+ }
+
+ /* Expect inbound NS-RESET procedure */
+ as_rx_ns_reset_ack(oneshot := true);
+ setverdict(pass);
+ f_clean_ns_codec();
+}
+
+/* test the inbound NS-ALIVE procedure after NS-RESET */
+testcase TC_ns_alive() runs on RAW_Test_CT {
+ f_init_ns_codec(mp_nsconfig);
+ f_init_pcuif();
+
+ /* Expect inbound NS-RESET procedure */
+ as_rx_ns_reset_ack(oneshot := true);
+
+ alt {
+ /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
+ [] NSCP[0].receive(t_NS_ALIVE) { setverdict(pass); };
+ [] NSCP[0].receive(t_NS_UNBLOCK) { repeat; }
+ }
+ f_clean_ns_codec();
+}
+
+/* Test for NS-RESET after NS-ALIVE timeout */
+testcase TC_ns_alive_timeout_reset() runs on RAW_Test_CT {
+ f_init_ns_codec(mp_nsconfig, guard_secs := 100.0);
+ f_init_pcuif();
+
+ /* Expect inbound NS-RESET procedure */
+ as_rx_ns_reset_ack(oneshot := true);
+
+ /* wait for at least one NS-ALIVE */
+ alt {
+ [] as_rx_alive_tx_ack(oneshot := true) { };
+ [] NSCP[0].receive(t_NS_UNBLOCK) { repeat; }
+ }
+
+ /* wait for NS-RESET to re-appear, ignoring any NS-ALIVE until then */
+ alt {
+ [] as_rx_ns_reset_ack(oneshot := true) { setverdict(pass); }
+ [] NSCP[0].receive(t_NS_ALIVE) { repeat; }
+ [] NSCP[0].receive(t_NS_UNBLOCK) { repeat; }
+ }
+
+ f_clean_ns_codec();
+}
+
+/* test for NS-RESET/NS-ALIVE/NS-UNBLOCK */
+testcase TC_ns_unblock() runs on RAW_Test_CT {
+ f_init_ns_codec(mp_nsconfig);
+ f_init_pcuif();
+
+ /* Expect inbound NS-RESET procedure */
+ as_rx_ns_reset_ack(oneshot := true);
+
+ /* keep it alive */
+ activate(as_rx_alive_tx_ack());
+
+ as_rx_ns_unblock_ack(oneshot := true);
+ setverdict(pass);
+ f_clean_ns_codec();
+}
+
+/* test for NS-UNBLOCK re-transmissions */
+testcase TC_ns_unblock_retrans() runs on RAW_Test_CT {
+ f_init_ns_codec(mp_nsconfig);
+ f_init_pcuif();
+
+ /* Expect inbound NS-RESET procedure */
+ as_rx_ns_reset_ack(oneshot := true);
+
+ /* keep it alive */
+ activate(as_rx_alive_tx_ack());
+
+ /* wait for first NS-UNBLOCK, don't respond */
+ NSCP[0].receive(t_NS_UNBLOCK);
+
+ /* wait for re-transmission of NS-UNBLOCK */
+ as_rx_ns_unblock_ack(oneshot := true);
+ setverdict(pass);
+ f_clean_ns_codec();
+}
+
+/* full bring-up of the Gb link for NS and BSSGP layer up to BVC-FC */
+testcase TC_ns_full_bringup() runs on RAW_Test_CT {
+ f_init_ns_codec(mp_nsconfig);
+ f_init_pcuif();
+
+ /* Expect inbound NS-RESET procedure */
+ as_rx_ns_reset_ack(oneshot := true);
+
+ /* keep it alive */
+ activate(as_rx_alive_tx_ack());
+
+ as_rx_ns_unblock_ack(oneshot := true);
+
+ f_outgoing_ns_alive();
+
+ /* Expect BVC-RESET for signaling (0) and ptp BVCI */
+ as_rx_bvc_reset_tx_ack(0, omit, omit, oneshot := true);
+ as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvc[0].bvci, mp_gb_cfg.bvc[0].cell_id, omit, oneshot := true);
+ as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true);
+
+ /* wait for one FLOW-CONTROL BVC and then ACK any further in the future */
+ as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true);
+ activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci));
+ setverdict(pass);
+ f_clean_ns_codec();
+}
+
+/* test outbound (SGSN-originated) NS-BLOCK procedure */
+testcase TC_ns_so_block() runs on RAW_Test_CT {
+ f_init_ns_codec(mp_nsconfig);
+ f_init_pcuif();
+
+ /* Expect inbound NS-RESET procedure */
+ as_rx_ns_reset_ack(oneshot := true);
+
+ /* keep it alive */
+ activate(as_rx_alive_tx_ack());
+
+ as_rx_ns_unblock_ack(oneshot := true);
+
+ f_outgoing_ns_alive();
+
+ f_outgoing_ns_block(NS_CAUSE_EQUIPMENT_FAILURE);
+ setverdict(pass);
+ f_clean_ns_codec();
+}
+
+
+control {
+ execute( TC_ns_reset() );
+ execute( TC_ns_reset_retrans() );
+ execute( TC_ns_alive() );
+ execute( TC_ns_alive_timeout_reset() );
+ execute( TC_ns_unblock() );
+ execute( TC_ns_unblock_retrans() );
+ execute( TC_ns_full_bringup() );
+ execute( TC_ns_so_block() );
+}
+
+}
diff --git a/pcu/PCU_Tests_RAW.ttcn b/pcu/PCU_Tests_RAW.ttcn
deleted file mode 100644
index af1ef99d..00000000
--- a/pcu/PCU_Tests_RAW.ttcn
+++ /dev/null
@@ -1,1067 +0,0 @@
-module PCU_Tests_RAW {
-
-/* "RAW" PCU tests: Talk directly to the PCU socket of OsmoPCU on the one hand side (emulating
- the BTS/BSC side PCU socket server) and the Gb interface on the other hand side. No NS/BSSGP
- Emulation is used; rather, we simply use the NS_CodecPort to implement both standard and non-
- standard procedures on the NS and BSSGP level. The goal of these tests is to test exactly
- those NS and BSSGP implementations on the BSS (PCU) side. */
-
-/* (C) 2018-2019 Harald Welte <laforge@gnumonks.org>
- * (C) 2019 Vadim Yanitskiy <axilirator@gmail.com>
- * 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 RLCMAC_CSN1_Types all;
-import from RLCMAC_Types all;
-
-import from NS_Types all;
-import from BSSGP_Types all;
-import from Osmocom_Gb_Types all;
-
-import from BSSGP_Emulation all; /* BssgpConfig */
-import from NS_Emulation all; /* NSConfiguration */
-
-import from UD_Types all;
-import from PCUIF_Types all;
-import from PCUIF_CodecPort all;
-import from PCUIF_RAW_Components all;
-import from IPL4asp_Types all;
-import from NS_CodecPort all;
-import from NS_CodecPort_CtrlFunct all;
-import from Native_Functions all;
-import from PCU_Tests all;
-
-modulepar {
- charstring mp_pcu_sock_path := PCU_SOCK_DEFAULT;
-}
-
-type component RAW_NS_CT {
- /* UDP port towards the bottom (IUT) */
- port NS_CODEC_PT NSCP[4];
- var ConnectionId g_ns_conn_id[4] := {-1, -1, -1, -1};
- var NSConfiguration g_nsconfig[4];
- timer g_T_guard;
-}
-
-type component RAW_PCU_CT {
- /* PCUIF (we emulate the BTS part) */
- port PCUIF_CODEC_PT PCU;
- var ConnectionId g_pcu_conn_id := -1;
-}
-
-type component RAW_Test_CT extends RAW_NS_CT, RAW_PCU_CT {
-}
-
-private altstep as_Tguard() runs on RAW_NS_CT {
- [] g_T_guard.timeout {
- setverdict(fail, "Timeout of T_guard");
- mtc.stop;
- }
-}
-
-/* FIXME: make sure to use parameters from mp_gb_cfg.cell_id in the PCU INFO IND */
-template (value) PCUIF_info_ind ts_PCUIF_INFO_default := {
- version := PCU_IF_VERSION,
- flags := c_PCUIF_Flags_default,
- trx := valueof(ts_PCUIF_InfoTrxs_def),
- bsic := 7,
- mcc := 262,
- mnc := 42,
- mnc_3_digits := 0,
- lac := 13135,
- rac := 0,
- nsei := mp_nsconfig.nsei,
- nse_timer := { 3, 3, 3, 3, 30, 3, 10 },
- cell_timer := { 3, 3, 3, 3, 3, 10, 3, 10, 3, 10, 3 },
- cell_id := 20960,
- repeat_time := 5 * 50,
- repeat_count := 3,
- bvci := mp_gb_cfg.bvci,
- t3142 := 20,
- t3169 := 5,
- t3191 := 5,
- t3193_10ms := 160,
- t3195 := 5,
- t3101 := 10,
- t3103 := 4,
- t3105 := 8,
- cv_countdown := 15,
- dl_tbf_ext := 250 * 10, /* ms */
- ul_tbf_ext := 250 * 10, /* ms */
- initial_cs := 2,
- initial_mcs := 6,
- nsvci := { mp_nsconfig.nsvci, 0 },
- local_pprt := { mp_nsconfig.remote_udp_port, 0 },
- remote_port := { mp_nsconfig.local_udp_port, 0 },
- remote_ip := { f_inet_haddr(mp_nsconfig.local_ip) , '00000000'O }
-}
-
-function f_init_pcuif() runs on RAW_PCU_CT {
- var PCUIF_info_ind info_ind;
- map(self:PCU, system:PCU);
-
-
- info_ind := valueof(ts_PCUIF_INFO_default);
-
- /* Connect the Unix Domain Socket */
- g_pcu_conn_id := f_pcuif_listen(PCU, mp_pcu_sock_path);
- PCU.receive(UD_connected:?);
-
- /* Wait for PCU_VERSION and return INFO_IND */
- PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TXT_IND(0, PCU_VERSION, ?)));
- /* FIXME: make sure to use parameters from mp_gb_cfg.cell_id in the PCU INFO IND */
- var template PCUIF_Message info_ind_msg := ts_PCUIF_INFO_IND(0, info_ind);
- PCU.send(t_SD_PCUIF(g_pcu_conn_id, info_ind_msg));
-}
-
-function f_pcuif_tx(template (value) PCUIF_Message msg) runs on RAW_PCU_CT {
- PCU.send(t_SD_PCUIF(g_pcu_conn_id, msg));
-}
-
-function f_init_ns_codec(integer idx := 0, float guard_secs := 60.0) runs on RAW_NS_CT {
- var Result res;
-
- if (not g_T_guard.running) {
- g_T_guard.start(guard_secs);
- activate(as_Tguard());
- }
-
- if (not isbound(g_nsconfig) or not isbound(g_nsconfig[idx])) {
- /* copy most parts from mp_nsconfig */
- g_nsconfig[idx] := mp_nsconfig;
- /* adjust those parts different for each NS-VC */
- g_nsconfig[idx].nsvci := mp_nsconfig.nsvci + idx;
- g_nsconfig[idx].local_udp_port := mp_nsconfig.local_udp_port + idx;
- }
-
- map(self:NSCP[idx], system:NSCP);
- /* Connect the UDP socket */
- log("connecting NSCP[", idx, "] to ", g_nsconfig[idx]);
- res := f_IPL4_connect(NSCP[idx], g_nsconfig[idx].remote_ip, g_nsconfig[idx].remote_udp_port,
- g_nsconfig[idx].local_ip, g_nsconfig[idx].local_udp_port, 0, { udp := {}});
- if (not ispresent(res.connId)) {
- setverdict(fail, "Could not connect NS UDP socket, check your configuration ", g_nsconfig[idx]);
- mtc.stop;
- }
- g_ns_conn_id[idx] := res.connId;
-
-}
-
-function f_ns_exp(template PDU_NS exp_rx, integer idx := 0) runs on RAW_NS_CT return PDU_NS {
- var NS_RecvFrom nrf;
- log("f_ns_exp() expecting ", exp_rx);
- alt {
- [] NSCP[idx].receive(t_NS_RecvFrom(exp_rx)) -> value nrf { }
- [] NSCP[idx].receive {
- setverdict(fail, "Received unexpected NS: ", nrf);
- mtc.stop;
- }
- }
- return nrf.msg;
-}
-
-/* perform outbound NS-ALIVE procedure */
-function f_outgoing_ns_alive(integer idx := 0) runs on RAW_NS_CT {
- NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE));
- alt {
- [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE_ACK));
- [] NSCP[idx].receive { repeat; }
- }
-}
-
-/* perform outbound NS-ALIVE procedure */
-function f_outgoing_ns_alive_no_ack(integer idx := 0, float tout := 10.0) runs on RAW_NS_CT {
- timer T := tout;
- NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE));
- T.start;
- alt {
- [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE_ACK)) {
- setverdict(fail, "Received unexpected NS-ALIVE ACK");
- }
- [] NSCP[idx].receive { repeat; }
- [] T.timeout {
- setverdict(pass);
- }
- }
-}
-
-/* ensure no matching message is received within 'tout' */
-function f_ensure_no_ns(template PDU_NS ns := ?, integer idx := 0, float tout := 3.0)
-runs on RAW_Test_CT {
- timer T := tout;
- T.start;
- alt {
- [] NSCP[idx].receive(t_NS_RecvFrom(ns)) {
- setverdict(fail, "NS-ALIVE from unconfigured (possibly initial) endpoint");
- }
- [] T.timeout {
- setverdict(pass);
- }
- }
-}
-
-/* perform outbound NS-BLOCK procedure */
-function f_outgoing_ns_block(NsCause cause, integer idx := 0) runs on RAW_NS_CT {
- NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_BLOCK(cause, g_nsconfig[idx].nsvci)));
- alt {
- [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_BLOCK_ACK(g_nsconfig[idx].nsvci)));
- [] NSCP[idx].receive { repeat; }
- }
-}
-
-/* receive NS-ALIVE and ACK it */
-altstep as_rx_alive_tx_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
- [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE)) {
- NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE_ACK));
- if (not oneshot) { repeat; }
- }
-}
-
-/* Transmit BSSGP RESET for given BVCI and expect ACK */
-function f_tx_bvc_reset_rx_ack(BssgpBvci bvci, integer idx := 0, boolean exp_ack := true)
-runs on RAW_NS_CT {
- var PDU_BSSGP bssgp_tx := valueof(ts_BVC_RESET(BSSGP_CAUSE_NET_SV_CAP_MOD_GT_ZERO_KBPS, bvci,
- mp_gb_cfg.cell_id));
- timer T := 5.0;
- NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx))));
- T.start;
- alt {
- [exp_ack] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0,
- decmatch tr_BVC_RESET_ACK(bvci, ?)))) {
- setverdict(pass);
- }
- [exp_ack] T.timeout {
- setverdict(fail, "No response to BVC-RESET");
- }
- [not exp_ack] T.timeout {
- setverdict(pass);
- }
- [] NSCP[idx].receive { repeat; }
- }
-}
-
-/* Receive a BSSGP RESET for given BVCI and ACK it */
-altstep as_rx_bvc_reset_tx_ack(BssgpBvci bvci, boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
- var NS_RecvFrom ns_rf;
- /* FIXME: nail down received cell_id in match */
- [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0,
- decmatch tr_BVC_RESET(?, bvci, ?))))
- -> value ns_rf {
- var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU);
- var PDU_BSSGP bssgp_tx := valueof(ts_BVC_RESET_ACK(bvci, mp_gb_cfg.cell_id));
- NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx))));
- if (not oneshot) { repeat; }
- }
-}
-
-
-/* Receive a BSSGP UNBLOCK for given BVCI and ACK it */
-altstep as_rx_bvc_unblock_tx_ack(BssgpBvci bvci, boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
- var NS_RecvFrom ns_rf;
- [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0,
- decmatch t_BVC_UNBLOCK(bvci))))
- -> value ns_rf {
- var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU);
- var PDU_BSSGP bssgp_tx := valueof(t_BVC_UNBLOCK_ACK(bvci));
- NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx))));
- if (not oneshot) { repeat; }
- }
-}
-
-/* Receive a BSSGP FLOW-CONTROL-BVC and ACK it */
-altstep as_rx_bvc_fc_tx_ack(BssgpBvci bvci, boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
- var NS_RecvFrom ns_rf;
- [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, bvci,
- decmatch tr_BVC_FC_BVC)))
- -> value ns_rf {
- var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU);
- var OCT1 tag := bssgp_rx.pDU_BSSGP_FLOW_CONTROL_BVC.tag.unstructured_Value;
- var PDU_BSSGP bssgp_tx := valueof(t_BVC_FC_BVC_ACK(tag));
- NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, bvci, enc_PDU_BSSGP(bssgp_tx))));
- if (not oneshot) { repeat; }
- }
-}
-
-/**********************************************************************************
- * Classic Gb/IP bring-up test cases using NS-{RESET,BLOCK,UNBLOCK} and no IP-SNS *
- **********************************************************************************/
-
-/* Receive a NS-RESET and ACK it */
-private altstep as_rx_ns_reset_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
- var NS_RecvFrom ns_rf;
- [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION, g_nsconfig[idx].nsvci,
- g_nsconfig[idx].nsei))) -> value ns_rf {
- NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_RESET_ACK(g_nsconfig[idx].nsvci,
- g_nsconfig[idx].nsei)));
- if (not oneshot) { repeat; }
- }
-}
-/* Receive a NS-UNBLOCK and ACK it */
-private altstep as_rx_ns_unblock_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
- var NS_RecvFrom ns_rf;
- [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_UNBLOCK)) -> value ns_rf {
- NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_UNBLOCK_ACK));
- if (not oneshot) { repeat; }
- }
-}
-
-/* test the NS-RESET procedure */
-testcase TC_ns_reset() runs on RAW_Test_CT {
- f_init_ns_codec();
- f_init_pcuif();
-
-
- /* Expect inbound NS-RESET procedure */
- as_rx_ns_reset_ack(oneshot := true);
- setverdict(pass);
-}
-
-/* ensure NS-RESET are re-transmitted */
-testcase TC_ns_reset_retrans() runs on RAW_Test_CT {
- f_init_ns_codec();
- f_init_pcuif();
-
- var integer i;
- for (i := 0; i < 3; i := i+1) {
- NSCP[0].receive(t_NS_RecvFrom(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION,
- g_nsconfig[0].nsvci, g_nsconfig[0].nsei)));
- }
-
- /* Expect inbound NS-RESET procedure */
- as_rx_ns_reset_ack(oneshot := true);
- setverdict(pass);
-}
-
-/* test the inbound NS-ALIVE procedure after NS-RESET */
-testcase TC_ns_alive() runs on RAW_Test_CT {
- f_init_ns_codec();
- f_init_pcuif();
-
- /* Expect inbound NS-RESET procedure */
- as_rx_ns_reset_ack(oneshot := true);
-
- /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
- as_rx_alive_tx_ack(oneshot := true);
- setverdict(pass);
-}
-
-/* Test for NS-RESET after NS-ALIVE timeout */
-testcase TC_ns_alive_timeout_reset() runs on RAW_Test_CT {
- f_init_ns_codec(guard_secs := 100.0);
- f_init_pcuif();
-
- /* Expect inbound NS-RESET procedure */
- as_rx_ns_reset_ack(oneshot := true);
-
- /* wait for at least one NS-ALIVE */
- NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE));
-
- /* wait for NS-RESET to re-appear, ignoring any NS-ALIVE until then */
- alt {
- [] as_rx_ns_reset_ack(oneshot := true) { setverdict(pass); }
- [] NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE)) { repeat; }
- }
-}
-
-/* test for NS-RESET/NS-ALIVE/NS-UNBLOCK */
-testcase TC_ns_unblock() runs on RAW_Test_CT {
- f_init_ns_codec();
- f_init_pcuif();
-
- /* Expect inbound NS-RESET procedure */
- as_rx_ns_reset_ack(oneshot := true);
-
- /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
- as_rx_alive_tx_ack(oneshot := true);
- activate(as_rx_alive_tx_ack());
-
- as_rx_ns_unblock_ack(oneshot := true);
- setverdict(pass);
-}
-
-/* test for NS-UNBLOCK re-transmissions */
-testcase TC_ns_unblock_retrans() runs on RAW_Test_CT {
- f_init_ns_codec();
- f_init_pcuif();
-
- /* Expect inbound NS-RESET procedure */
- as_rx_ns_reset_ack(oneshot := true);
-
- /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
- as_rx_alive_tx_ack(oneshot := true);
- activate(as_rx_alive_tx_ack());
-
- /* wait for first NS-UNBLOCK, don't respond */
- NSCP[0].receive(t_NS_RecvFrom(t_NS_UNBLOCK));
-
- /* wait for re-transmission of NS-UNBLOCK */
- as_rx_ns_unblock_ack(oneshot := true);
- setverdict(pass);
-}
-
-/* full bring-up of the Gb link for NS and BSSGP layer up to BVC-FC */
-testcase TC_ns_full_bringup() runs on RAW_Test_CT {
- f_init_ns_codec();
- f_init_pcuif();
-
- /* Expect inbound NS-RESET procedure */
- as_rx_ns_reset_ack(oneshot := true);
-
- /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
- as_rx_alive_tx_ack(oneshot := true);
- activate(as_rx_alive_tx_ack());
-
- as_rx_ns_unblock_ack(oneshot := true);
-
- f_outgoing_ns_alive();
-
- /* Expect BVC-RESET for signaling (0) and ptp BVCI */
- as_rx_bvc_reset_tx_ack(0, oneshot := true);
- as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvci, oneshot := true);
- as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvci, oneshot := true);
-
- /* wait for one FLOW-CONTROL BVC and then ACK any further in the future */
- as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, oneshot := true);
- activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci));
- setverdict(pass);
-}
-
-/* test outbound (SGSN-originated) NS-BLOCK procedure */
-testcase TC_ns_so_block() runs on RAW_Test_CT {
- f_init_ns_codec();
- f_init_pcuif();
-
- /* Expect inbound NS-RESET procedure */
- as_rx_ns_reset_ack(oneshot := true);
-
- /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
- as_rx_alive_tx_ack(oneshot := true);
- activate(as_rx_alive_tx_ack());
-
- as_rx_ns_unblock_ack(oneshot := true);
-
- f_outgoing_ns_alive();
-
- f_outgoing_ns_block(NS_CAUSE_EQUIPMENT_FAILURE);
- setverdict(pass);
-}
-
-type component RAW_PCU_Test_CT extends bssgp_CT {
- /* Connection to the BTS component (one for now) */
- port RAW_PCU_MSG_PT BTS;
- /* Connection to the PCUIF component */
- port RAW_PCU_MSG_PT PCUIF;
-
- /* Guard timeout */
- timer g_T_guard := 60.0;
-};
-
-private altstep as_Tguard_RAW() runs on RAW_PCU_Test_CT {
- [] g_T_guard.timeout {
- setverdict(fail, "Timeout of T_guard");
- mtc.stop;
- }
-}
-
-private function f_init_raw(charstring id, template (value) PCUIF_info_ind info_ind := ts_PCUIF_INFO_default)
-runs on RAW_PCU_Test_CT {
- var RAW_PCUIF_CT vc_PCUIF;
- var RAW_PCU_BTS_CT vc_BTS;
-
- /* Start the guard timer */
- g_T_guard.start;
- activate(as_Tguard_RAW());
-
- /* Init PCU interface component */
- vc_PCUIF := RAW_PCUIF_CT.create("PCUIF-" & id);
- connect(vc_PCUIF:MTC, self:PCUIF);
- map(vc_PCUIF:PCU, system:PCU);
-
- /* Create one BTS component (we may want more some day) */
- vc_BTS := RAW_PCU_BTS_CT.create("BTS-" & id);
- connect(vc_BTS:PCUIF, vc_PCUIF:BTS);
- connect(vc_BTS:TC, self:BTS);
-
- vc_PCUIF.start(f_PCUIF_CT_handler(mp_pcu_sock_path));
- vc_BTS.start(f_BTS_CT_handler(0, valueof(info_ind)));
-
- /* Wait until the BTS is ready (SI13 negotiated) */
- BTS.receive(tr_RAW_PCU_EV(BTS_EV_SI13_NEGO));
-}
-
-/* FIXME: properly encode RA (see TS 24.060, table 11.2.5.2) */
-private function f_establish_tbf(out GsmRrMessage rr_imm_ass, uint8_t bts_nr := 0,
- uint16_t ra := oct2int('3A'O), uint8_t is_11bit := 0,
- PCUIF_BurstType burst_type := BURST_TYPE_0,
- TimingAdvance ta := 0)
-runs on RAW_PCU_Test_CT return boolean {
- var PCUIF_Message pcu_msg;
- var GsmRrMessage rr_msg;
- var uint32_t fn;
- timer T;
-
- /* FIXME: ask the BTS component to give us the current TDMA fn */
- fn := 1337 + ta;
-
- /* Send RACH.ind */
- log("Sending RACH.ind on fn=", fn, " with RA=", ra, ", TA=", ta);
- BTS.send(ts_PCUIF_RACH_IND(bts_nr := bts_nr,
- ra := ra, is_11bit := is_11bit,
- burst_type := burst_type,
- fn := fn, arfcn := 871,
- qta := ta * 4));
-
- /* Expect Immediate (TBF) Assignment on TS0/AGCH */
- T.start(2.0);
- alt {
- [] BTS.receive(tr_PCUIF_DATA_REQ(bts_nr := bts_nr, trx_nr := ?, ts_nr := 0,
- sapi := PCU_IF_SAPI_AGCH, data := ?))
- -> value pcu_msg {
- rr_imm_ass := dec_GsmRrMessage(pcu_msg.u.data_req.data);
- log("Rx Immediate Assignment: ", rr_imm_ass);
-
- /* Make sure this assignment is for us
- * TODO: Uplink or Downlink TBF? */
- if (match(rr_imm_ass, tr_IMM_TBF_ASS(?, ra, fn))) {
- setverdict(pass);
- return true;
- }
-
- /* Not for us? Wait for more. */
- repeat;
- }
- [] BTS.receive { repeat; }
- [] T.timeout {
- setverdict(fail, "Timeout waiting for Immediate Assignment");
- }
- }
-
- return false;
-}
-
-private function f_imm_ass_verify_ul_tbf_ass(GsmRrMessage rr_imm_ass, out PacketUlAssign ul_tbf_ass)
-runs on RAW_PCU_Test_CT return boolean {
-
- /* Make sure we received an UL TBF Assignment */
- if (match(rr_imm_ass, tr_IMM_TBF_ASS(dl := false, rest := tr_IaRestOctets_ULAss(?)))) {
- ul_tbf_ass := rr_imm_ass.payload.imm_ass.rest_octets.hh.pa.uldl.ass.ul;
- log("Rx Uplink TBF assignment: ", ul_tbf_ass);
- setverdict(pass);
- } else {
- setverdict(fail, "Failed to match UL TBF Assignment");
- return false;
- }
-
- /* Make sure we have got a TBF with Dynamic Block Allocation */
- if (ul_tbf_ass.dynamic == omit) {
- setverdict(fail, "Single Block Allocation is not handled by ", testcasename());
- return false;
- }
-
- return true;
-}
-
-/* Enqueue DATA.ind (both TDMA frame and block numbers to be patched) */
-private function f_pcuif_tx_data_ind(octetstring data, int16_t lqual_cb := 0)
-runs on RAW_PCU_Test_CT {
-
- BTS.send(ts_PCUIF_DATA_IND(bts_nr := 0, trx_nr := 0, ts_nr := 7, block_nr := 0,
- sapi := PCU_IF_SAPI_PDTCH, data := data,
- fn := 0, arfcn := 871, lqual_cb := lqual_cb));
- BTS.receive(tr_RAW_PCU_EV(TDMA_EV_PDTCH_BLOCK_SENT));
-}
-
-/* Enqueue RTS.req, expect DATA.req with UL ACK from the PCU */
-private function f_pcuif_rx_data_req(out PCUIF_Message pcu_msg)
-runs on RAW_PCU_Test_CT {
- BTS.send(ts_PCUIF_RTS_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7,
- sapi := PCU_IF_SAPI_PDTCH, fn := 0,
- arfcn := 871, block_nr := 0));
- BTS.receive(tr_PCUIF_DATA_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7,
- sapi := PCU_IF_SAPI_PDTCH)) -> value pcu_msg;
-}
-
-private function f_tx_rlcmac_ul_block(template (value) RlcmacUlBlock ul_data, int16_t lqual_cb := 0)
-runs on RAW_PCU_Test_CT {
- var octetstring data;
- /* Encode the payload of DATA.ind */
- data := enc_RlcmacUlBlock(valueof(ul_data));
- data := f_pad_oct(data, 23, '00'O); /* CS-1 */
-
- /* Enqueue DATA.ind (both TDMA frame and block numbers to be patched) */
- f_pcuif_tx_data_ind(data, lqual_cb);
-}
-
-private function f_tx_rlcmac_ul_n_blocks(PacketUlAssign ul_tbf_ass, integer num_blocks := 1)
-runs on RAW_PCU_Test_CT {
- var template (value) RlcmacUlBlock ul_data := t_RLCMAC_UL_DATA(
- tfi := ul_tbf_ass.dynamic.tfi_assignment,
- cv := num_blocks - 1, /* num UL blocks to be sent (to be overridden in loop) */
- bsn := 0, /* TODO: what should be here? */
- blocks := { /* To be generated in loop */ });
-
- /* HACK: patch missing TLLI; otherwise OsmoPCU rejects DATA.req */
- ul_data.data.tlli := '00000001'O;
-
- for (var integer i := 0; i < num_blocks; i := i + 1) {
- /* Prepare a new UL block (CV, random payload) */
- ul_data.data.mac_hdr.countdown := (num_blocks - i - 1);
- ul_data.data.blocks := { valueof(t_RLCMAC_LLCBLOCK(f_rnd_octstring(10))) };
- f_tx_rlcmac_ul_block(ul_data);
- }
-}
-
-private function f_rx_rlcmac_dl_block(out RlcmacDlBlock dl_block)
-runs on RAW_PCU_Test_CT {
- var PCUIF_Message pcu_msg;
- f_pcuif_rx_data_req(pcu_msg);
- dl_block := dec_RlcmacDlBlock(pcu_msg.u.data_req.data);
-}
-
-private function f_rx_rlcmac_dl_block_exp_ack_nack(out RlcmacDlBlock dl_block)
-runs on RAW_PCU_Test_CT {
- f_rx_rlcmac_dl_block(dl_block);
- if (not match(dl_block, tr_RLCMAC_ACK_NACK(ul_tfi := ?, tlli := ?))) {
- setverdict(fail, "Failed to match Packet Uplink ACK / NACK");
- mtc.stop;
- }
-}
-
-private function f_rx_rlcmac_dl_block_exp_dummy(out RlcmacDlBlock dl_block)
-runs on RAW_PCU_Test_CT {
- f_rx_rlcmac_dl_block(dl_block);
- if (not match(dl_block, tr_RLCMAC_DUMMY_CTRL())) {
- setverdict(fail, "Failed to match Packet DUMMY DL");
- mtc.stop;
- }
-}
-
-testcase TC_pcuif_suspend() runs on RAW_PCU_Test_CT {
- var octetstring ra_id := enc_RoutingAreaIdentification(mp_gb_cfg.cell_id.ra_id);
- var GprsTlli tlli := 'FFFFFFFF'O;
- timer T;
-
- /* Initialize NS/BSSGP side */
- f_init_bssgp();
-
- /* Initialize the PCU interface abstraction */
- f_init_raw(testcasename());
-
- /* Establish BSSGP connection to the PCU */
- f_bssgp_establish();
-
- BTS.send(ts_PCUIF_SUSP_REQ(0, tlli, ra_id, 0));
-
- T.start(2.0);
- alt {
- [] BSSGP_SIG[0].receive(tr_BSSGP_SUSPEND(tlli, mp_gb_cfg.cell_id.ra_id)) {
- setverdict(pass);
- }
- [] T.timeout {
- setverdict(fail, "Timeout waiting for BSSGP SUSPEND");
- }
- }
-}
-
-/* Test of correct Timing Advance at the time of TBF establishment
- * (derived from timing offset of the Access Burst). */
-testcase TC_ta_rach_imm_ass() runs on RAW_PCU_Test_CT {
- var GsmRrMessage rr_msg;
- var boolean ok;
-
- /* Initialize the PCU interface abstraction */
- f_init_raw(testcasename());
-
- /* We cannot send too many TBF requests in a short time because
- * at some point the PCU will fail to allocate a new TBF. */
- for (var TimingAdvance ta := 0; ta < 64; ta := ta + 16) {
- /* Establish an Uplink TBF (send RACH.ind with current TA) */
- ok := f_establish_tbf(rr_msg, bts_nr := 0, ta := ta);
- if (not ok) {
- setverdict(fail, "Failed to establish an Uplink TBF");
- mtc.stop;
- }
-
- /* Make sure Timing Advance IE matches out expectations */
- if (match(rr_msg, tr_IMM_TBF_ASS(dl := false, ta := ta))) {
- setverdict(pass);
- }
- }
-}
-
-/* Verify that the PCU generates valid PTCCH/D messages
- * while neither Uplink nor Downlink TBF is established. */
-testcase TC_ta_ptcch_idle() runs on RAW_PCU_Test_CT {
- var PTCCHDownlinkMsg ptcch_msg;
- var PCUIF_Message pcu_msg;
- timer T;
-
- /* Initialize the PCU interface abstraction */
- f_init_raw(testcasename());
-
- /* Sent an RTS.req for PTCCH/D */
- BTS.send(ts_PCUIF_RTS_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7,
- sapi := PCU_IF_SAPI_PTCCH, fn := 0,
- arfcn := 871, block_nr := 0));
- T.start(5.0);
- alt {
- [] BTS.receive(tr_PCUIF_DATA_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7,
- sapi := PCU_IF_SAPI_PTCCH)) -> value pcu_msg {
- log("Rx DATA.req message: ", pcu_msg);
- setverdict(pass);
- }
- [] BTS.receive(PCUIF_Message:?) { repeat; }
- [] T.timeout {
- setverdict(fail, "Timeout waiting for a PTCCH/D block");
- mtc.stop;
- }
- }
-
- ptcch_msg := dec_PTCCHDownlinkMsg(pcu_msg.u.data_req.data);
- log("Decoded PTCCH/D message: ", ptcch_msg);
-
- /* Make sure the message is encoded correctly
- * TODO: do we expect all TA values to be equal '1111111'B? */
- if (not match(ptcch_msg, tr_PTCCHDownlinkMsg)) {
- setverdict(fail, "Malformed PTCCH/D message");
- mtc.stop;
- }
-}
-
-/* Test of correct Timing Advance during an active Uplink TBF.
- *
- * Unlike the circuit-switched domain, Uplink transmissions on PDCH time-slots
- * are not continuous and there can be long time gaps between them. This happens
- * due to a bursty nature of packet data. The actual Timing Advance of a MS may
- * significantly change between such rare Uplink transmissions, so GPRS introduces
- * additional mechanisms to control Timing Advance, and thus reduce interference
- * between neighboring TDMA time-slots.
- *
- * At the moment of Uplink TBF establishment, initial Timing Advance is measured
- * from ToA (Timing of Arrival) of an Access Burst. This is covered by another
- * test case - TC_ta_rach_imm_ass. In response to that Access Burst the network
- * sends Immediate Assignment on AGCH, which _may_ contain Timing Advance Index
- * among with the initial Timing Advance value. And here PTCCH comes to play.
- *
- * PTCCH is a unidirectional channel on which the network can instruct a sub-set
- * of 16 MS (whether TBFs are active or not) to adjust their Timing Advance
- * continuously. To ensure continuous measurements of the signal propagation
- * delay, the MSs shall transmit Access Bursts on Uplink (PTCCH/U) on sub-slots
- * defined by an assigned Timing Advance Index (see 3GPP TS 45.002).
- *
- * The purpose of this test case is to verify the assignment of Timing Advance
- * Index, and the process of Timing Advance notification on PTCCH/D. The MTC
- * first establishes several Uplink TBFs, but does not transmit any Uplink
- * blocks on them. During 4 TDMA multi-frame periods the MTC is sending RACH
- * indications to the PCU, checking the correctness of two received PTCCH/D
- * messages (period of PTCCH/D is two multi-frames).
- */
-
-/* List of ToA values for Access Bursts to be sent on PTCCH/U,
- * each ToA (Timing of Arrival) value is in units of 1/4 of
- * a symbol (i.e. 1 symbol is 4 QTA units). */
-type record length(16) of int16_t PTCCH_TAI_ToA_MAP;
-const PTCCH_TAI_ToA_MAP ptcch_toa_map_def := {
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0
-};
-
-private altstep as_ta_ptcch(uint8_t bts_nr := 0, /* TODO: TRX / TS number */
- in PTCCH_TAI_ToA_MAP toa_map := ptcch_toa_map_def)
-runs on RAW_PCU_Test_CT {
- var RAW_PCU_Event event;
- var integer ss;
-
- /* Send Access Bursts on PTCCH/U for every TA Index */
- [] BTS.receive(tr_RAW_PCU_EV(TDMA_EV_PTCCH_UL_BURST)) -> value event {
- ss := f_tdma_ptcch_fn2ss(event.data.tdma_fn);
- if (ss < 0) { mtc.stop; } /* Shall not happen */
-
- log("Sending an Access Burst on PTCCH/U",
- ", sub-slot=", ss, " (TAI)",
- ", fn=", event.data.tdma_fn,
- ", ToA=", toa_map[ss], " (QTA)");
- /* TODO: do we care about RA and burst format? */
- BTS.send(ts_PCUIF_RACH_IND(bts_nr := bts_nr,
- ra := oct2int('3A'O),
- is_11bit := 0,
- burst_type := BURST_TYPE_0,
- fn := event.data.tdma_fn,
- arfcn := 871,
- qta := toa_map[ss],
- sapi := PCU_IF_SAPI_PTCCH));
- repeat;
- }
-}
-
-private function f_TC_ta_ptcch_ul_multi_tbf(in PTCCH_TAI_ToA_MAP ptcch_toa_map,
- template PTCCHDownlinkMsg t_ta_msg)
-runs on RAW_PCU_Test_CT {
- var PTCCHDownlinkMsg ta_msg;
- var PCUIF_Message pcu_msg;
- timer T;
-
- /* First, send an RTS.req for the upcoming PTCCH/D block */
- BTS.send(ts_PCUIF_RTS_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7,
- sapi := PCU_IF_SAPI_PTCCH, fn := 0,
- arfcn := 871, block_nr := 0));
- T.start(2.0);
- alt {
- /* Keep sending of Access Bursts during two multi-frames (period of PTCCH/D)
- * with increasing ToA (Timing of Arrival) values: 0, 7, 14, 28, 35... */
- [] as_ta_ptcch(bts_nr := 0, toa_map := ptcch_toa_map);
- /* In the end of 2nd multi-frame we should receive a PTCCH/D block */
- [] BTS.receive(tr_PCUIF_DATA_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7,
- sapi := PCU_IF_SAPI_PTCCH)) -> value pcu_msg {
- ta_msg := dec_PTCCHDownlinkMsg(pcu_msg.u.data_req.data);
- log("Rx PTCCH/D message: ", ta_msg);
-
- /* Make sure Timing Advance values match our expectations */
- if (match(ta_msg, t_ta_msg)) {
- setverdict(pass);
- } else {
- setverdict(fail, "PTCCH/D message does not match: ", t_ta_msg);
- }
- }
- [] BTS.receive { repeat; }
- [] T.timeout {
- setverdict(fail, "Timeout waiting for a PTCCH/D block");
- mtc.stop;
- }
- }
-}
-
-testcase TC_ta_ptcch_ul_multi_tbf() runs on RAW_PCU_Test_CT {
- var template PacketUlAssign t_ul_tbf_ass;
- var PacketUlAssign ul_tbf_ass[7];
- var GsmRrMessage rr_msg[7];
- var boolean ok;
-
- /* Initialize the PCU interface abstraction */
- f_init_raw(testcasename());
-
- /* Enable forwarding of PTCCH/U TDMA events to us */
- BTS.send(ts_RAW_PCU_CMD(TDMA_CMD_ENABLE_PTCCH_UL_FWD));
-
- /* Establish 7 Uplink TBFs (USF flag is 3 bits long, '111'B is reserved) */
- for (var integer i := 0; i < 7; i := i + 1) {
- ok := f_establish_tbf(rr_msg[i], ta := 0);
- if (not ok) {
- setverdict(fail, "Failed to establish an Uplink TBF #", i);
- mtc.stop;
- }
-
- /* Make sure we received an UL TBF Assignment */
- if (match(rr_msg[i], tr_IMM_TBF_ASS(dl := false, rest := tr_IaRestOctets_ULAss(?)))) {
- ul_tbf_ass[i] := rr_msg[i].payload.imm_ass.rest_octets.hh.pa.uldl.ass.ul;
- log("Rx Uplink TBF assignment for #", i, ": ", ul_tbf_ass[i]);
- } else {
- setverdict(fail, "Failed to match UL TBF Assignment for #", i);
- mtc.stop;
- }
-
- /* We expect incremental TFI/USF assignment (dynamic allocation) */
- t_ul_tbf_ass := tr_PacketUlDynAssign(tfi := i, usf := i);
- if (not match(ul_tbf_ass[i], t_ul_tbf_ass)) {
- setverdict(fail, "Failed to match Packet Uplink Assignment for #", i);
- mtc.stop;
- }
-
- /* We also expect Timing Advance Index to be a part of the assignment */
- if (ul_tbf_ass[i].dynamic.ta_index != i) {
- setverdict(fail, "Failed to match Timing Advance Index for #", i);
- /* Keep going, the current OsmoPCU does not assign TA Index */
- }
- }
-
- /* Prepare a list of ToA values for Access Bursts to be sent on PTCCH/U */
- var PTCCH_TAI_ToA_MAP toa_map := ptcch_toa_map_def;
- for (var integer i := 0; i < 7; i := i + 1) {
- /* ToA in units of 1/4 of a symbol */
- toa_map[i] := (i + 1) * 7 * 4;
- }
-
- /* Now we have all 7 TBFs established in one-phase access mode,
- * however we will not be sending any data on them. Instead, we
- * will be sending RACH.ind on PTCCH/U during 4 multi-frame
- * periods (TAI 0..8), and then will check two PTCCH/D blocks.
- *
- * Why not 4 TBFs at once? Because Uplink is delayed by 3 TDMA
- * time-slots, so at the moment of scheduling a PTCCH/D block
- * the PCU has odd number of PTCCH/U Access Bursts received. */
- f_TC_ta_ptcch_ul_multi_tbf(toa_map, tr_PTCCHDownlinkMsg(
- tai0_ta := 7, tai1_ta := 14, tai2_ta := 21,
- /* Other values are not known (yet) */
- tai3_ta := ?));
- f_TC_ta_ptcch_ul_multi_tbf(toa_map, tr_PTCCHDownlinkMsg(
- tai0_ta := 7, tai1_ta := 14, tai2_ta := 21,
- tai3_ta := 28, tai4_ta := 35, tai5_ta := 42,
- /* Other values are out of our interest */
- tai6_ta := ?));
-}
-
-/* Default link quality adaptation (Coding Scheme) ranges:
-/* CS1: ... 6 dB, CS2: 5 .. 8 dB, CS3: 7 .. 13 db, CS4: 12 ... dB */
-private template integer CS1_lqual_dB_range := (-infinity .. 6);
-private template integer CS2_lqual_dB_range := (5 .. 8);
-private template integer CS3_lqual_dB_range := (7 .. 13);
-private template integer CS4_lqual_dB_range := (12 .. infinity);
-
-testcase TC_cs_lqual_ul_tbf() runs on RAW_PCU_Test_CT {
- var GsmRrMessage rr_imm_ass;
- var PacketUlAssign ul_tbf_ass;
- var RlcmacDlBlock dl_block;
- var PCUIF_Message pcu_msg;
- var octetstring data;
- var boolean ok;
-
- /* Initialize the PCU interface abstraction */
- f_init_raw(testcasename());
-
- /* Establish an Uplink TBF */
- ok := f_establish_tbf(rr_imm_ass);
- if (not ok) {
- setverdict(fail, "Failed to establish TBF");
- mtc.stop;
- }
-
- ok := f_imm_ass_verify_ul_tbf_ass(rr_imm_ass, ul_tbf_ass);
- if (not ok) {
- setverdict(fail, "Immediate Assignment not an Uplink TBF");
- mtc.stop;
- }
-
- var template (value) RlcmacUlBlock ul_data := t_RLCMAC_UL_DATA(
- tfi := ul_tbf_ass.dynamic.tfi_assignment,
- cv := 15, /* 15 UL blocks to be sent (to be overridden in loop) */
- bsn := 0, /* TODO: what should be here? */
- blocks := { /* To be generated in loop */ });
-
- /* HACK: patch missing TLLI; otherwise OsmoPCU rejects DATA.req */
- ul_data.data.tlli := '00000001'O;
-
- /* 16 UL blocks (0 .. 32 dB, step = 2 dB) */
- for (var integer i := 0; i < 16; i := i + 1) {
- /* Prepare a new UL block (CV, random payload) */
- ul_data.data.mac_hdr.countdown := (15 - i);
- ul_data.data.blocks := { valueof(t_RLCMAC_LLCBLOCK(f_rnd_octstring(10))) };
-
- /* Link quality in dB and our CS1-4 expectations */
- var integer lqual := i * 2;
-
- /* Enqueue DATA.ind (both TDMA frame and block numbers to be patched) */
- log("Sending DATA.ind with link quality (dB): ", lqual);
- f_tx_rlcmac_ul_block(ul_data, lqual * 10);
-
- /* Enqueue RTS.req, expect DATA.req with UL ACK from the PCU */
- f_rx_rlcmac_dl_block_exp_ack_nack(dl_block);
-
- log("Rx Packet Uplink ACK / NACK with Channel Coding Command: ",
- dl_block.ctrl.payload.u.ul_ack_nack.gprs.ch_coding_cmd);
-
- /* Match the received Channel Coding Command */
- var template ChCodingCommand ch_coding;
- select (lqual) {
- case (CS1_lqual_dB_range) { ch_coding := CH_CODING_CS1; }
- case (CS2_lqual_dB_range) { ch_coding := CH_CODING_CS2; }
- case (CS3_lqual_dB_range) { ch_coding := CH_CODING_CS3; }
- case (CS4_lqual_dB_range) { ch_coding := CH_CODING_CS4; }
- }
-
- if (not match(dl_block.ctrl.payload.u.ul_ack_nack.gprs.ch_coding_cmd, ch_coding)) {
- setverdict(fail, "Channel Coding does not match our expectations: ", ch_coding);
- } else {
- setverdict(pass);
- }
- }
-}
-
-/* Verify PCU drops TBF after some time of inactivity. */
-testcase TC_t3169() runs on RAW_PCU_Test_CT {
- var PCUIF_info_ind info_ind;
- var GsmRrMessage rr_imm_ass;
- var PacketUlAssign ul_tbf_ass;
- var RlcmacDlBlock dl_block;
- var PCUIF_Message pcu_msg;
- var octetstring data;
- var boolean ok;
- var OCT4 tlli := '00000001'O;
-
- /* Initialize NS/BSSGP side */
- f_init_bssgp();
-
- info_ind := valueof(ts_PCUIF_INFO_default);
- /* Set timer to 1 sec (default 5) to speedup test: */
- info_ind.t3169 := 1;
-
- /* Initialize the PCU interface abstraction */
- f_init_raw(testcasename(), info_ind);
-
- /* Establish BSSGP connection to the PCU */
- f_bssgp_establish();
- f_bssgp_client_llgmm_assign('FFFFFFFF'O, tlli);
-
- /* Establish an Uplink TBF */
- ok := f_establish_tbf(rr_imm_ass);
- if (not ok) {
- setverdict(fail, "Failed to establish TBF");
- mtc.stop;
- }
-
- ok := f_imm_ass_verify_ul_tbf_ass(rr_imm_ass, ul_tbf_ass);
- if (not ok) {
- setverdict(fail, "Immediate Assignment not an Uplink TBF");
- mtc.stop;
- }
-
- /* Send one UL block and make sure it is ACKED fine */
- f_tx_rlcmac_ul_n_blocks(ul_tbf_ass, 1);
- f_rx_rlcmac_dl_block_exp_ack_nack(dl_block);
- /* UL block should be received in SGSN */
- BSSGP[0].receive(tr_BSSGP_UL_UD(tlli, mp_gb_cfg.cell_id));
-
- /* Wait until T3169 fires (plus 1 extra sec to make sure) */
- f_sleep(int2float(info_ind.t3169) + 1.0);
-
- /* Send an UL block once again, the TBF should be gone by now so no ACK */
- f_tx_rlcmac_ul_n_blocks(ul_tbf_ass, 1);
- f_rx_rlcmac_dl_block_exp_dummy(dl_block);
-}
-
-
-control {
- execute( TC_ns_reset() );
- execute( TC_ns_reset_retrans() );
- execute( TC_ns_alive() );
- execute( TC_ns_alive_timeout_reset() );
- execute( TC_ns_unblock() );
- execute( TC_ns_unblock_retrans() );
- execute( TC_ns_full_bringup() );
- execute( TC_ns_so_block() );
-
- execute( TC_pcuif_suspend() );
- execute( TC_ta_ptcch_idle() );
- execute( TC_ta_rach_imm_ass() );
- execute( TC_ta_ptcch_ul_multi_tbf() );
- execute( TC_cs_lqual_ul_tbf() );
- execute( TC_t3169() );
-}
-
-
-
-
-
-
-}
diff --git a/pcu/PCU_Tests_SNS.cfg b/pcu/PCU_Tests_SNS.cfg
index 1419e1eb..bd0875bb 100644
--- a/pcu/PCU_Tests_SNS.cfg
+++ b/pcu/PCU_Tests_SNS.cfg
@@ -7,18 +7,58 @@
[LOGGING]
[MODULE_PARAMETERS]
-PCU_Tests.mp_nsconfig := {
- local_ip := "127.0.0.1",
- local_udp_port := 23000,
- remote_ip := "127.0.0.1",
- remote_udp_port := 22000,
- nsvci := 1234,
- nsei := 1234
+SGSN_Components.mp_nsconfig := {
+ nsei := 1234,
+ nsvc := {
+ {
+ provider := {
+ ip := {
+ address_family := AF_INET,
+ local_ip := "127.0.0.1",
+ local_udp_port := 23000,
+ remote_ip := "127.0.0.1",
+ remote_udp_port := 22000,
+ data_weight := 1,
+ signalling_weight := 1
+ }
+ },
+ nsvci := 1234
+ },
+ {
+ provider := {
+ ip := {
+ address_family := AF_INET,
+ local_ip := "127.0.0.1",
+ local_udp_port := 23001,
+ remote_ip := "127.0.0.1",
+ remote_udp_port := 22000,
+ data_weight := 1,
+ signalling_weight := 1
+ }
+ },
+ nsvci := 1234
+ },
+ {
+ provider := {
+ ip := {
+ address_family := AF_INET,
+ local_ip := "127.0.0.1",
+ local_udp_port := 23002,
+ remote_ip := "127.0.0.1",
+ remote_udp_port := 22000,
+ data_weight := 1,
+ signalling_weight := 1
+ }
+ },
+ nsvci := 1234
+ }
+ }
}
+PCUIF_Types.mp_pcuif_version := 12
[TESTPORT_PARAMETERS]
[MAIN_CONTROLLER]
[EXECUTE]
-PCU_Tests_RAW_SNS.control
+PCU_Tests_SNS.control
diff --git a/pcu/PCU_Tests_RAW_SNS.ttcn b/pcu/PCU_Tests_SNS.ttcn
index 28dd6548..b90fe37e 100644
--- a/pcu/PCU_Tests_RAW_SNS.ttcn
+++ b/pcu/PCU_Tests_SNS.ttcn
@@ -1,4 +1,4 @@
-module PCU_Tests_RAW_SNS {
+module PCU_Tests_SNS {
/* Osmocom PCU test suite for IP Sub-Network-Service (SNS) in TTCN-3
* (C) 2018-2019 Harald Welte <laforge@gnumonks.org>
@@ -11,169 +11,68 @@ module PCU_Tests_RAW_SNS {
*/
import from Osmocom_Types all;
-import from PCU_Tests all;
-import from PCU_Tests_RAW all;
+import from Osmocom_VTY_Functions all;
+import from PCU_Tests_NS all;
+import from SGSN_Components all;
import from Osmocom_Gb_Types all;
-import from NS_CodecPort all;
+import from NS_Emulation all;
import from NS_Types all;
+import from RAW_NS all;
+import from BSSGP_Types all;
/**********************************************************************************
* Modern Gb/IP bring-up test cases using IP Sub-Network Service (SNS)
**********************************************************************************/
-/* perform inbound SNS-SIZE procedure */
-function f_incoming_sns_size(template (omit) NsCause cause := omit, integer idx := 0)
-runs on RAW_NS_CT {
- log("f_incoming_sns_size(idx=", idx, ")");
- var PDU_NS rx;
- /* expect one single SNS-SIZE with RESET flag; one remote v4 EP; no v6 EP */
- rx := f_ns_exp(tr_SNS_SIZE(g_nsconfig[idx].nsei, rst_flag := true, max_nsvcs := 8,
- num_v4 := 4, num_v6 := omit), idx);
- NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_SIZE_ACK(g_nsconfig[idx].nsei, cause)));
-}
-
-/* perform outbound SNS-SIZE procedure */
-function f_outgoing_sns_size(template (omit) NsCause cause := omit, integer idx:= 0)
-runs on RAW_NS_CT {
- log("f_outgoing_sns_size(idx=", idx, ")");
- var PDU_NS rx;
- NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_SIZE(g_nsconfig[idx].nsei, rst_flag := true, max_nsvcs := 1,
- num_v4 := 1, num_v6 := omit)
- ));
- /* expect one single SNS-SIZE with RESET flag; one remote v4 EP; no v6 EP */
- rx := f_ns_exp(tr_SNS_SIZE_ACK(g_nsconfig[idx].nsei, cause), idx);
-}
-
-/* perform inbound SNS-CONFIG procedure */
-function f_incoming_sns_config(template (omit) NsCause cause := omit, integer idx := 0)
-runs on RAW_NS_CT {
- log("f_incoming_sns_config(idx=", idx, ")");
- var PDU_NS rx;
- var template IP4_Elements v4_elem := { tr_SNS_IPv4(mp_nsconfig.remote_ip,
- mp_nsconfig.remote_udp_port) };
- rx := f_ns_exp(tr_SNS_CONFIG(g_nsconfig[idx].nsei, end_flag := true, v4 := v4_elem), idx);
- NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CONFIG_ACK(g_nsconfig[idx].nsei, cause)));
-}
-
-/* perform outbound SNS-CONFIG procedure */
-function f_outgoing_sns_config(template (omit) NsCause cause := omit, integer idx := 0)
-runs on RAW_NS_CT {
- log("f_outgoing_sns_config(idx=", idx, ")");
- var PDU_NS rx;
- var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig[idx].local_ip,
- g_nsconfig[idx].local_udp_port) }
- NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CONFIG(g_nsconfig[idx].nsei, true, v4)));
- rx := f_ns_exp(tr_SNS_CONFIG_ACK(g_nsconfig[idx].nsei, cause), idx);
-}
-
-/* perform outbound SNS-CONFIG procedure (separate endpoints: 1 for control, 1 for user */
-function f_outgoing_sns_config_1c1u(template (omit) NsCause cause := omit, integer idx := 0)
-runs on RAW_NS_CT {
- log("f_outgoing_sns_config_1c1u(idx=", idx, ")");
- var PDU_NS rx;
- var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig[0].local_ip,
- g_nsconfig[0].local_udp_port, 1, 0),
- ts_SNS_IPv4(g_nsconfig[1].local_ip,
- g_nsconfig[1].local_udp_port, 0, 1) };
- NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CONFIG(g_nsconfig[idx].nsei, true, v4)));
- rx := f_ns_exp(tr_SNS_CONFIG_ACK(g_nsconfig[idx].nsei, cause), idx);
-}
-
-/* perform outbound SNS-CONFIG procedure (separate endpoints: 1 for control, 1 for user */
-function f_outgoing_sns_config_1c1u_separate(template (omit) NsCause cause := omit, integer idx := 0)
-runs on RAW_NS_CT {
- log("f_outgoing_sns_config_1c1u_separate(idx=", idx, ")");
- var PDU_NS rx;
- var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig[1].local_ip,
- g_nsconfig[1].local_udp_port, 1, 0),
- ts_SNS_IPv4(g_nsconfig[2].local_ip,
- g_nsconfig[2].local_udp_port, 0, 1) };
- NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CONFIG(g_nsconfig[idx].nsei, true, v4)));
- rx := f_ns_exp(tr_SNS_CONFIG_ACK(g_nsconfig[idx].nsei, cause), idx);
-}
-
-function f_outgoing_sns_add(integer idx_add, uint8_t w_sig := 1, uint8_t w_user := 1, integer idx := 0)
-runs on RAW_NS_CT {
- log("f_outgoing_sns_add(idx_add=", idx_add, ")");
- var PDU_NS rx;
- var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig[idx_add].local_ip,
- g_nsconfig[idx_add].local_udp_port,
- w_sig, w_user) };
- NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_ADD(g_nsconfig[idx].nsei, 23, v4)));
- rx := f_ns_exp(tr_SNS_ACK(g_nsconfig[idx].nsei, 23, omit, v4));
-}
-
-function f_outgoing_sns_del(integer idx_del, uint8_t w_sig := 1, uint8_t w_user := 1, integer idx := 0)
-runs on RAW_NS_CT {
- log("f_outgoing_sns_del(idx_del=", idx_del, ")");
- var PDU_NS rx;
- var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig[idx_del].local_ip,
- g_nsconfig[idx_del].local_udp_port,
- w_sig, w_user) };
- NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_DEL(g_nsconfig[idx].nsei, 24, omit, v4)));
- rx := f_ns_exp(tr_SNS_ACK(g_nsconfig[idx].nsei, 24, omit, v4));
-}
-
-function f_outgoing_sns_chg_weight(integer idx_chg, uint8_t w_sig, uint8_t w_user, integer idx := 0)
-runs on RAW_NS_CT {
- log("f_outgoing_sns_chg_weight(idx_chg=", idx_chg, ")");
- var PDU_NS rx;
- var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig[idx_chg].local_ip,
- g_nsconfig[idx_chg].local_udp_port,
- w_sig, w_user) };
- NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CHG_WEIGHT(g_nsconfig[idx].nsei, 25, v4)));
- rx := f_ns_exp(tr_SNS_ACK(g_nsconfig[idx].nsei, 25, omit, v4));
-}
-
-
-
-
-
/* PCU-originated SNS-SIZE: successful case */
testcase TC_sns_po_size_success() runs on RAW_Test_CT {
- f_init_ns_codec();
+ f_init_ns_codec(mp_nsconfig);
f_init_pcuif();
f_incoming_sns_size();
f_sleep(1.0);
setverdict(pass);
+ f_clean_ns_codec();
}
/* PCU-originated SNS-SIZE: NACK from our side */
testcase TC_sns_po_size_nack() runs on RAW_Test_CT {
- f_init_ns_codec();
+ f_init_ns_codec(mp_nsconfig);
f_init_pcuif();
- f_incoming_sns_size(NS_CAUSE_PROTOCOL_ERROR_UNSPEIFIED);
+ f_incoming_sns_size(NS_CAUSE_PROTOCOL_ERROR_UNSPECIFIED);
/* FIXME: ensure we don't get a SNS-CONFIG */
/* FIXME: ensure we get re-transmitted SNS-SIZE attempts */
f_sleep(10.0);
setverdict(pass);
+ f_clean_ns_codec();
}
/* PCU-originated SNS-CONFIG: successful case */
testcase TC_sns_po_config_success() runs on RAW_Test_CT {
- f_init_ns_codec();
+ f_init_ns_codec(mp_nsconfig);
f_init_pcuif();
f_incoming_sns_size();
f_incoming_sns_config();
f_sleep(1.0);
setverdict(pass);
+ f_clean_ns_codec();
}
/* PCU-originated SNS-CONFIG: successful case */
testcase TC_sns_po_config_nack() runs on RAW_Test_CT {
- f_init_ns_codec();
+ f_init_ns_codec(mp_nsconfig);
f_init_pcuif();
f_incoming_sns_size();
- f_incoming_sns_config(NS_CAUSE_PROTOCOL_ERROR_UNSPEIFIED);
+ f_incoming_sns_config(NS_CAUSE_PROTOCOL_ERROR_UNSPECIFIED);
/* FIXME: ensure we get re-transmitted SNS-CONFIG attempts */
f_sleep(10.0);
setverdict(pass);
+ f_clean_ns_codec();
}
/* SGSN-originated SNS-SIZE: successful case */
testcase TC_sns_so_config_success() runs on RAW_Test_CT {
- f_init_ns_codec();
+ f_init_ns_codec(mp_nsconfig);
f_init_pcuif();
f_incoming_sns_size();
f_incoming_sns_config();
@@ -186,20 +85,21 @@ testcase TC_sns_so_config_success() runs on RAW_Test_CT {
f_outgoing_ns_alive();
/* Expect BVC-RESET for signaling (0) and ptp BVCI */
- as_rx_bvc_reset_tx_ack(0, oneshot := true);
- as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvci, oneshot := true);
- as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvci, oneshot := true);
+ as_rx_bvc_reset_tx_ack(0, omit, omit, oneshot := true);
+ as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvc[0].bvci, mp_gb_cfg.bvc[0].cell_id, omit, oneshot := true);
+ as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true);
/* wait for one FLOW-CONTROL BVC and then ACK any further in the future */
- as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, oneshot := true);
- activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci));
+ as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true);
+ activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci));
setverdict(pass);
+ f_clean_ns_codec();
}
private function f_sns_bringup_1c1u(boolean sgsn_originated_reset := false) runs on RAW_Test_CT {
/* Activate two NS codec ports */
- f_init_ns_codec();
- f_init_ns_codec(1);
+ f_init_ns_codec(mp_nsconfig);
+ f_init_ns_codec(mp_nsconfig, 1);
f_init_pcuif();
/* Perform Size + BSS-originated config */
f_incoming_sns_size();
@@ -219,33 +119,44 @@ private function f_sns_bringup_1c1u(boolean sgsn_originated_reset := false) runs
f_outgoing_ns_alive(1);
if (sgsn_originated_reset) {
- f_tx_bvc_reset_rx_ack(0);
- f_tx_bvc_reset_rx_ack(mp_gb_cfg.bvci);
+ /* Expect BVC-RESET, but ignore it to prevent a race condition of BVC RESETs */
+ var template PDU_NS pdu := tr_NS_UNITDATA(t_SduCtrlB, 0, decmatch tr_BVC_RESET(?, 0, omit));
+ f_ns_exp(pdu);
+ /* SGSN originated BVC-RESET on an uninitialized signalling BVC */
+ f_tx_bvc_reset_rx_ack(0, omit, omit);
+
+ /* Expect BVC-RESET PTP BVC, but ignore it to prevent a race condition of BVC RESETs */
+ pdu := tr_NS_UNITDATA(t_SduCtrlB, 0, decmatch tr_BVC_RESET(?, mp_gb_cfg.bvc[0].bvci, mp_gb_cfg.bvc[0].cell_id));
+ f_ns_exp(pdu);
+ /* SGSN originated BVC-RESET on an uninitialized PTP BVC */
+ f_tx_bvc_reset_rx_ack(mp_gb_cfg.bvc[0].bvci, omit, mp_gb_cfg.bvc[0].cell_id);
} else {
- /* Expect BVC-RESET for signaling (0) and ptp BVCI */
- as_rx_bvc_reset_tx_ack(0, oneshot := true);
- as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvci, oneshot := true);
+ /* Expect BVC-RESET for signaling BVCI=0 */
+ as_rx_bvc_reset_tx_ack(0, omit, omit, oneshot := true);
+ /* Expect BVC-RESET from the PCU on PTP BVC */
+ as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvc[0].bvci, mp_gb_cfg.bvc[0].cell_id, omit, oneshot := true);
}
/* Expect UNBLOCK for ptp BVCI on signaling NS-VC (idx==0) */
- as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvci, oneshot := true);
+ as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true);
/* wait for one FLOW-CONTROL BVC and then ACK any further in the future. Flow
* control happens on the p-t-p BVCI and hence on index 1 */
- as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, oneshot := true, idx := 1);
- activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, idx := 1));
+ as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true, idx := 1);
+ activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, idx := 1));
}
/* Test full IP-SNS bring-up with two NS-VCs, one sig-only and one user-only */
testcase TC_sns_1c1u() runs on RAW_Test_CT {
f_sns_bringup_1c1u();
setverdict(pass);
+ f_clean_ns_codec();
}
private function f_sns_bringup_1c1u_separate(boolean sgsn_originated_reset := false) runs on RAW_Test_CT {
/* Activate two NS codec ports */
- f_init_ns_codec();
- f_init_ns_codec(1);
- f_init_ns_codec(2);
+ f_init_ns_codec(mp_nsconfig);
+ f_init_ns_codec(mp_nsconfig, 1);
+ f_init_ns_codec(mp_nsconfig, 2);
f_init_pcuif();
/* Perform Size + BSS-originated config */
f_incoming_sns_size();
@@ -269,20 +180,29 @@ private function f_sns_bringup_1c1u_separate(boolean sgsn_originated_reset := fa
f_outgoing_ns_alive_no_ack(idx := 0);
if (sgsn_originated_reset) {
- f_tx_bvc_reset_rx_ack(0, idx := 1);
- f_tx_bvc_reset_rx_ack(mp_gb_cfg.bvci, idx := 1);
+ /* Expect BVC-RESET, but ignore it to prevent a race condition of BVC RESETs */
+ var template PDU_NS pdu := tr_NS_UNITDATA(t_SduCtrlB, 0, decmatch tr_BVC_RESET(?, 0, omit));
+ f_ns_exp(pdu, idx := 1);
+ /* SGSN originated BVC-RESET on an uninitialized sign BVC */
+ f_tx_bvc_reset_rx_ack(0, omit, omit, idx := 1);
+
+ /* Expect BVC-RESET PTP BVC, but ignore it to prevent a race condition of BVC RESETs */
+ pdu := tr_NS_UNITDATA(t_SduCtrlB, 0, decmatch tr_BVC_RESET(?, mp_gb_cfg.bvc[0].bvci, mp_gb_cfg.bvc[0].cell_id));
+ f_ns_exp(pdu, idx := 1);
+ f_tx_bvc_reset_rx_ack(mp_gb_cfg.bvc[0].bvci, omit, mp_gb_cfg.bvc[0].cell_id, idx := 1);
} else {
- /* Expect BVC-RESET for signaling BVCI=0 and ptp BVCI */
- as_rx_bvc_reset_tx_ack(0, oneshot := true, idx := 1);
- as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvci, oneshot := true, idx := 1);
+ /* Expect BVC-RESET for signaling BVCI=0 */
+ as_rx_bvc_reset_tx_ack(0, omit, omit, oneshot := true, idx := 1);
+ /* Expect BVC-RESET from the PCU on PTP BVC */
+ as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvc[0].bvci, mp_gb_cfg.bvc[0].cell_id, omit, oneshot := true, idx := 1);
}
/* Expect UNBLOCK for ptp BVCI on signaling NS-VC (idx==1) */
- as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvci, oneshot := true, idx := 1);
+ as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true, idx := 1);
/* wait for one FLOW-CONTROL BVC and then ACK any further in the future. Flow
* control happens on the p-t-p BVCI and hence on index 1 */
- as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, oneshot := true, idx := 2);
- activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, idx := 2));
+ as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true, idx := 2);
+ activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, idx := 2));
}
/* Test full IP-SNS bring-up with two NS-VCs, one sig-only and one user-only - and where
@@ -290,6 +210,7 @@ private function f_sns_bringup_1c1u_separate(boolean sgsn_originated_reset := fa
testcase TC_sns_1c1u_separate() runs on RAW_Test_CT {
f_sns_bringup_1c1u_separate();
setverdict(pass);
+ f_clean_ns_codec();
}
/* Test full IP-SNS bring-up with two NS-VCs, one sig-only and one user-only and use
@@ -297,14 +218,24 @@ testcase TC_sns_1c1u_separate() runs on RAW_Test_CT {
testcase TC_sns_1c1u_so_bvc_reset() runs on RAW_Test_CT {
f_sns_bringup_1c1u_separate(sgsn_originated_reset := true);
setverdict(pass);
+ f_clean_ns_codec();
+}
+
+/* Test full IP_SNS bring-up over an initial NS-VC with two NS-VCs */
+testcase TC_sns_1c1u_unconfigured_nsvc() runs on RAW_Test_CT {
+ f_init_vty(testcasename());
+ f_sns_bringup_1c1u_separate();
+ f_vty_transceive_not_match(PCUVTY, "show ns entities", pattern "*UNCONFIGURED*");
+ setverdict(pass);
+ f_clean_ns_codec();
}
/* Transmit BVC-RESET before NS-ALIVE of PCU was ACKed: expect no response */
testcase TC_sns_1c1u_so_bvc_reset_too_early() runs on RAW_Test_CT {
/* Activate two NS codec ports */
- f_init_ns_codec();
- f_init_ns_codec(1);
- f_init_ns_codec(2);
+ f_init_ns_codec(mp_nsconfig);
+ f_init_ns_codec(mp_nsconfig, 1);
+ f_init_ns_codec(mp_nsconfig, 2);
f_init_pcuif();
/* Perform Size + BSS-originated config */
f_incoming_sns_size();
@@ -321,16 +252,56 @@ testcase TC_sns_1c1u_so_bvc_reset_too_early() runs on RAW_Test_CT {
f_outgoing_ns_alive_no_ack(idx := 0);
/* Transmit BVC-RESET and expect no ACK*/
- f_tx_bvc_reset_rx_ack(0, idx := 1, exp_ack := false);
- f_tx_bvc_reset_rx_ack(mp_gb_cfg.bvci, idx := 1, exp_ack := false);
+ f_tx_bvc_reset_rx_ack(0, omit, omit, idx := 1, exp_ack := false);
+ f_tx_bvc_reset_rx_ack(mp_gb_cfg.bvc[0].bvci, omit, mp_gb_cfg.bvc[0].cell_id, idx := 1, exp_ack := false);
+ f_clean_ns_codec();
+}
+
+/* Do an SGSN originated BSSGP-Reset of a not-configured BVCI.
+ *
+ * PCU -X SGSN: BVCI 0 BSSGP-RESET (ignores reset)
+ * PCU <- SGSN: BVCI 0 BSSGP-RESET
+ * PCU -> SGSN: BVCI 0 BSSGP-RESET-ACK (with cell information)
+ * PCU -X SGSN: BVCI 23 BSSGP-RESET (ignores reset, 23 is configured on PCU, 24 is not configured)
+ * PCU <- SGSN: BVCI 24 BSSGP-RESET (unconfigured BVCI)
+ * PCU -> SGSN: BVCI 24 BSSGP-STATUS Unknown BVCI
+ */
+testcase TC_sns_so_bvc_reset_unknown_bvci() runs on RAW_Test_CT {
+ g_handle_rx_alive := true;
+ f_init_ns_codec(mp_nsconfig);
+ f_init_pcuif();
+ f_incoming_sns_size();
+ f_incoming_sns_config();
+ f_outgoing_sns_config();
+
+ /* Expect BVC-RESET, but ignore it to prevent a race condition of BVC RESETs */
+ var template PDU_NS pdu := tr_NS_UNITDATA(t_SduCtrlB, 0, decmatch tr_BVC_RESET(?, 0, omit));
+ f_ns_exp(pdu, idx := 0);
+ /* SGSN originated BVC-RESET on an uninitialized sign BVC */
+ f_tx_bvc_reset_rx_ack(0, omit, omit, idx := 0);
+
+ /* Expect BVC-RESET PTP BVC, but ignore it to prevent a race condition of BVC RESETs */
+ pdu := tr_NS_UNITDATA(t_SduCtrlB, 0, decmatch tr_BVC_RESET(?, mp_gb_cfg.bvc[0].bvci, mp_gb_cfg.bvc[0].cell_id));
+ f_ns_exp(pdu);
+
+ /* Send a BVC-RESET on the wrong BVC */
+ var BssgpCellId cell_id := mp_gb_cfg.bvc[0].cell_id;
+ cell_id.cell_id := cell_id.cell_id + 1;
+ var PDU_BSSGP bssgp_tx := valueof(ts_BVC_RESET(BSSGP_CAUSE_NET_SV_CAP_MOD_GT_ZERO_KBPS,
+ mp_gb_cfg.bvc[0].bvci + 1, cell_id));
+ NSCP[0].send(ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx)));
+ NSCP[0].receive(tr_NS_UNITDATA(t_SduCtrlB, 0, decmatch tr_BSSGP_STATUS(mp_gb_cfg.bvc[0].bvci + 1, BSSGP_CAUSE_BVCI_UNKNOWN, *)));
+ setverdict(pass);
+
+ f_clean_ns_codec();
}
/* Test adding new IP endpoints at runtime */
testcase TC_sns_add() runs on RAW_Test_CT {
f_sns_bringup_1c1u();
- /* crate another NS codec port on the tester side */
- f_init_ns_codec(2);
+ /* create another NS codec port on the tester side */
+ f_init_ns_codec(mp_nsconfig, 2);
f_outgoing_sns_add(idx_add := 2, w_sig := 0, w_user := 1, idx := 0);
@@ -339,8 +310,17 @@ testcase TC_sns_add() runs on RAW_Test_CT {
activate(as_rx_alive_tx_ack(idx := 2));
f_outgoing_ns_alive(2);
- /* TODO: Should we expect FLOW-CONTROL BVC here too? */
setverdict(pass);
+ f_clean_ns_codec();
+}
+
+/* Test adding an already present IP endpoint at runtime */
+testcase TC_sns_add_nack() runs on RAW_Test_CT {
+ f_sns_bringup_1c1u();
+
+ f_outgoing_sns_add(idx_add := 0, w_sig := 0, w_user := 1, idx := 0, cause := NS_CAUSE_PROTOCOL_ERROR_UNSPECIFIED);
+ setverdict(pass);
+ f_clean_ns_codec();
}
/* Test deleting IP endpoints at runtime */
@@ -350,6 +330,7 @@ testcase TC_sns_del() runs on RAW_Test_CT {
f_outgoing_sns_del(idx_del := 1, w_sig := 0, w_user := 1, idx := 0);
/* FIXME: ensure we don't receive anything on just-deleted NS-VC anymore */
setverdict(pass);
+ f_clean_ns_codec();
}
/* Test changing weights at runtime */
@@ -359,6 +340,7 @@ testcase TC_sns_chg_weight() runs on RAW_Test_CT {
/* change w_user from 1 to 200 */
f_outgoing_sns_chg_weight(idx_chg := 1, w_sig := 0, w_user := 200, idx := 0);
setverdict(pass);
+ f_clean_ns_codec();
}
import from PCUIF_Types all;
@@ -374,12 +356,14 @@ testcase TC_pcuif_rach() runs on RAW_Test_CT {
f_sns_bringup_1c1u();
activate(as_pcu_activate());
- f_pcuif_tx(ts_PCUIF_RACH_IND(bts_nr:=0, ra:=23, is_11bit:=0, burst_type:=BURST_TYPE_0,
+ f_pcuif_tx(ts_PCUIF_RACH_IND(bts_nr:=0, trx_nr:=0, ts_nr:=0, ra:=23,
+ is_11bit:=0, burst_type:=BURST_TYPE_0,
fn:=42, arfcn:=871, qta:=0));
PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
tr_PCUIF_DATA_REQ(bts_nr:=0, trx_nr:=0, ts_nr:=0, block_nr:=?, fn:=?,
- sapi:=PCU_IF_SAPI_AGCH, data:=?)));
+ sapi:=PCU_IF_SAPI_AGCH_2, data:=?)));
setverdict(pass);
+ f_clean_ns_codec();
}
@@ -394,7 +378,10 @@ control {
execute( TC_sns_1c1u_separate() );
execute( TC_sns_1c1u_so_bvc_reset() );
execute( TC_sns_1c1u_so_bvc_reset_too_early() );
+ execute( TC_sns_1c1u_unconfigured_nsvc() );
+ execute( TC_sns_so_bvc_reset_unknown_bvci() );
execute( TC_sns_add() );
+ execute( TC_sns_add_nack() );
execute( TC_sns_del() );
execute( TC_sns_chg_weight() );
diff --git a/pcu/PCU_Tests_SNSv6.cfg b/pcu/PCU_Tests_SNSv6.cfg
new file mode 100644
index 00000000..3093c2c4
--- /dev/null
+++ b/pcu/PCU_Tests_SNSv6.cfg
@@ -0,0 +1,36 @@
+[ORDERED_INCLUDE]
+# Common configuration, shared between test suites
+"../Common.cfg"
+# testsuite specific configuration, not expected to change
+"./PCU_Tests.default"
+
+[LOGGING]
+
+[MODULE_PARAMETERS]
+SGSN_Components.mp_nsconfig := {
+ nsei := 1234,
+ nsvc : {
+ {
+ provider := {
+ ip := {
+ address_family := AF_INET6,
+ local_ip := "::1",
+ local_udp_port := 23000,
+ remote_ip := "::1",
+ remote_udp_port := 22000,
+ data_weight := 1,
+ signalling_weight := 1
+ }
+ },
+ nsvci := 1234
+ }
+ }
+}
+PCUIF_Types.mp_pcuif_version := 12
+
+[TESTPORT_PARAMETERS]
+
+[MAIN_CONTROLLER]
+
+[EXECUTE]
+PCU_Tests_SNS.control
diff --git a/pcu/PCU_selftest.ttcn b/pcu/PCU_selftest.ttcn
new file mode 100644
index 00000000..a8bcaee7
--- /dev/null
+++ b/pcu/PCU_selftest.ttcn
@@ -0,0 +1,318 @@
+module PCU_selftest {
+/*
+ * Osmocom PCU test suite in TTCN-3, selftest procedures
+ * (C) 2018-2019 Harald Welte <laforge@gnumonks.org>
+ * (C) 2020 by sysmocom s.f.m.c. GmbH <info@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 Osmocom_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_CSN1_Types all;
+import from RLCMAC_Types all;
+import from RLCMAC_Templates all;
+import from GPRS_Components all;
+import from PCU_Tests 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);
+}
+
+testcase TC_selftest_rlcmac_egprs() runs on RAW_PCU_Test_CT
+{
+ var octetstring data;
+ var CodingSchemeArray schemes := {
+ //MCS_0,
+ MCS_1,
+ MCS_2,
+ MCS_3,
+ MCS_4,
+ MCS_5,
+ MCS_6,
+ MCS_7,
+ MCS_8,
+ MCS_9
+ };
+
+ /* Initialize the PCU interface abstraction */
+ f_init_raw(testcasename());
+
+ log("Started Uplink test");
+ for (var integer i := 0; i < sizeof(schemes); i := i+1) {
+ log("Testing Coding Schema ", schemes[i]);
+ var template (value) RlcmacUlBlock ul_data := t_RLCMAC_UL_EGPRS_DATA(
+ schemes[i],
+ tfi := 4,
+ cv := 1, /* num UL blocks to be sent (to be overridden in loop) */
+ bsn1 := 2, /* TODO: what should be here? */
+ blocks := { /* To be generated in loop */ });
+
+ ul_data.data_egprs.tlli := '00100101'O;
+ ul_data.data_egprs.blocks := { valueof(t_RLCMAC_LLCBLOCK_EGPRS('AABBCCDDEEFF00112233'O)) };
+
+ /* Encode the payload of DATA.ind */
+ log("Encoding ", valueof(ul_data));
+ data := enc_RlcmacUlBlock(valueof(ul_data));
+ data := f_pad_oct(data, f_rlcmac_cs_mcs2block_len(schemes[i]), '00'O);
+
+ /* Send to PCU so that we get gsmtap traces to verify with wireshark */
+ f_pcuif_tx_data_ind(data);
+
+ log("Decoding ", schemes[i]);
+ ul_data := dec_RlcmacUlBlock(data);
+ log("Decoded: ", ul_data);
+ }
+ log("Done Uplink test");
+}
+
+///////////////////
+// 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
new file mode 100644
index 00000000..0a1d31f5
--- /dev/null
+++ b/pcu/README.md
@@ -0,0 +1,95 @@
+# PCU_Tests.ttcn
+
+* external interfaces
+ * Gb (emulates SGSN side NS/BSSGP)
+ * PCUIF: unix pcu socket (emulates BTS)
+ * VTY
+ * CTRL
+ * StatsD
+
+{% dot pcu_tests.svg
+digraph G {
+ PCU [label="IUT\nosmo-pcu",shape="box", color=red];
+
+ subgraph cluster_ats {
+ label = "ATS\n(TTCN-3)";
+
+ system_PCU_PT [label="port system:PCU"];
+
+ subgraph cluster_RAW_PCU_Test_CT {
+ label = "RAW_PCU_Test_CT\n(PCU_Tests.ttcn)";
+
+ RAW_PCU_MSG_PT_PCUIF_A [label="port RAW_PCU_MSG_PT PCUIF\n(unused)"]
+ PCUVTY [label="PCUVTY"];
+ StatsD_ConnHdlr [label="StatsD_ConnHdlr"];
+ CTRL_Adapter_CT [label="CTRL_Adapter_CT"];
+
+ test [label="testcasename()\n(PCU_Tests.ttcn)", color=red];
+
+ subgraph cluster_bssgp_CT {
+ label="bssgp_CT\nSGSN_Components.ttcn";
+ subgraph cluster_BSSGP_Client_CT {
+ label="BSSGP_Client_CT\nBSSGP_Emulation.ttcnpp";
+ BSSGP_PT [label="port BSSGP_PT BSSGP"];
+ }
+ }
+
+ subgraph cluster_MS_BTS_IFACE_CT {
+ label = "MS_BTS_IFACE_CT\n(GPRS_Components.ttcn)";
+
+ RAW_PCU_MSG_PT_BTS_IFACE [label="port RAW_PCU_MSG_PT BTS"];
+ }
+
+ }
+
+ subgraph cluster_RAW_PCUIF_CT {
+ label = "RAW_PCUIF_CT\n(PCUIF_Components.ttcn)";
+
+ PCUIF_CODEC_PT_PCU [label="port PCUIF_CODEC_PT PCU"];
+ RAW_PCU_MSG_PT_BTS [label="port RAW_PCU_MSG_PT BTS"];
+ RAW_PCU_MSG_PT_MTC [label="port RAW_PCU_MSG_PT MTC"];
+
+ PCUIF_CODEC_PT_PCU -> RAW_PCU_MSG_PT_BTS [dir=none];
+ PCUIF_CODEC_PT_PCU -> RAW_PCU_MSG_PT_MTC [dir=none];
+
+ }
+
+ subgraph cluster_RAW_PCU_BTS_CT {
+ label = "RAW_PCU_BTS_CT\n(PCUIF_Components.ttcn)";
+
+ RAW_PCU_MSG_PT_CLCK_A [label="port RAW_PCU_MSG_PT CLCK"];
+ RAW_PCU_MSG_PT_PCUIF_B [label="port RAW_PCU_MSG_PT PCUIF"];
+ RAW_PCU_MSG_PT_TC [label="port RAW_PCU_MSG_PT TC"];
+
+ subgraph cluster_RAW_PCU_ClckGen_CT {
+ label = "RAW_PCU_ClckGen_CT\n(PCUIF_Components.ttcn)";
+
+ RAW_PCU_MSG_PT_CLCK_B [label="port RAW_PCU_MSG_PT CLCK", color=purple];
+ }
+
+ RAW_PCU_MSG_PT_CLCK_A -> RAW_PCU_MSG_PT_CLCK_B [dir=back];
+ RAW_PCU_MSG_PT_PCUIF_B -> RAW_PCU_MSG_PT_TC [dir=none];
+ }
+
+
+ RAW_PCU_MSG_PT_TC -> RAW_PCU_MSG_PT_BTS_IFACE [dir=none];
+ RAW_PCU_MSG_PT_PCUIF_A -> RAW_PCU_MSG_PT_MTC [dir=none];
+ RAW_PCU_MSG_PT_PCUIF_B -> RAW_PCU_MSG_PT_BTS [dir=none];
+
+ PCUIF_CODEC_PT_PCU -> system_PCU_PT [dir=none];
+
+ test -> RAW_PCU_MSG_PT_BTS_IFACE [dir=none];
+ test -> RAW_PCU_MSG_PT_PCUIF_A [label="(unused)", dir=none];
+ test -> BSSGP_PT;
+ test -> PCUVTY;
+ test -> StatsD_ConnHdlr;
+ test -> CTRL_Adapter_CT;
+ }
+
+ PCU -> BSSGP_PT [label="Gb"];
+ PCU -> StatsD_ConnHdlr [label="statsd"];
+ system_PCU_PT -> PCU [label="PCUIF"];
+ PCUVTY -> PCU [label="VTY"];
+ CTRL_Adapter_CT -> PCU [label="CTRL"];
+}
+%}
diff --git a/pcu/SGSN_Components.ttcn b/pcu/SGSN_Components.ttcn
new file mode 100644
index 00000000..bbac9b0d
--- /dev/null
+++ b/pcu/SGSN_Components.ttcn
@@ -0,0 +1,151 @@
+module SGSN_Components {
+/*
+ * Osmocom PCU test suite in TTCN-3, components for BSSGP handlng
+ * (C) 2018-2019 Harald Welte <laforge@gnumonks.org>
+ * (C) 2020 by sysmocom s.f.m.c. GmbH <info@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,
+ sgsn_role := true,
+ bvc := {
+ {
+ bvci := 1234,
+ cell_id := {
+ ra_id := {
+ lai := {
+ mcc_mnc := '262F42'H, lac := 13135
+ },
+ rac := 0
+ },
+ cell_id := 20960
+ },
+ depth := BSSGP_DECODE_DEPTH_BSSGP,
+ create_cb := refers(BSSGP_Emulation.DefaultCreateCallback)
+ }
+ }
+ };
+
+ NSConfiguration mp_nsconfig := {
+ nsei := 2342,
+ role_sgsn := true,
+ handle_sns := true,
+ nsvc := {
+ {
+ provider := {
+ ip := {
+ address_family := AF_INET,
+ local_udp_port := 23000,
+ local_ip := "127.0.0.1",
+ remote_udp_port := 21000,
+ remote_ip := "127.0.0.1"
+ }
+ },
+ nsvci := 0
+ },
+ {
+ provider := {
+ ip := {
+ address_family := AF_INET,
+ local_udp_port := 23001,
+ local_ip := "127.0.0.1",
+ remote_udp_port := 21000,
+ remote_ip := "127.0.0.1"
+ }
+ },
+ nsvci := 0
+ },
+ {
+ provider := {
+ ip := {
+ address_family := AF_INET,
+ local_udp_port := 23002,
+ local_ip := "127.0.0.1",
+ remote_udp_port := 21000,
+ remote_ip := "127.0.0.1"
+ }
+ },
+ nsvci := 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;
+ port BSSGP_CT_PROC_PT PROC;
+ port BSSGP_PT RIM;
+ 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 alive;
+ bssgp_component := BSSGP_CT.create alive;
+ /* connect lower-end of BSSGP with BSSGP_CODEC_PORT (maps to NS_PT*/
+ connect(bssgp_component:BSCP, ns_component:NS_SP);
+ connect(self:PROC, bssgp_component:PROC);
+ ns_component.start(NSStart(mp_nsconfig));
+ bssgp_component.start(BssgpStart(mp_gb_cfg, testcasename()));
+
+ for (var integer i := 0; i < lengthof(mp_gb_cfg.bvc); i := i+1) {
+ var BSSGP_BVC_CT vc_BVC;
+ /* obtain reference for BVC component (created by BssgpStart) */
+ vc_BVC := f_bssgp_get_bvci_ct(mp_gb_cfg.bvc[i].bvci, PROC);
+ /* connect our BSSGP port to the BSSGP Emulation */
+ connect(self:BSSGP[i], vc_BVC:BSSGP_SP);
+ connect(self:BSSGP_SIG[i], vc_BVC:BSSGP_SP_SIG);
+ connect(self:BSSGP_PROC[i], vc_BVC:BSSGP_PROC);
+ f_bssgp_client_register(mmctx.imsi, mmctx.tlli);
+ }
+ /* connect RIM related port */
+ connect(self:RIM, bssgp_component:RIM);
+ connect(self:BSSGP_GLOBAL[0], bssgp_component:GLOBAL);
+}
+
+/* Establish BSSGP connection to PCU */
+function f_bssgp_establish() runs on BSSGP_Client_CT {
+ timer T:= 10.0;
+
+ T.start
+ alt {
+ [] BSSGP[0].receive(tr_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/expected-results.xml b/pcu/expected-results.xml
index e9610bd5..17d95cc5 100644
--- a/pcu/expected-results.xml
+++ b/pcu/expected-results.xml
@@ -1,7 +1,145 @@
<?xml version="1.0"?>
-<testsuite name='PCU_Tests' tests='4' failures='0' errors='0' skipped='0' inconc='0' time='MASKED'>
- <testcase classname='PCU_Tests' name='TC_ul_tbf_single_llc_sizes' time='MASKED'/>
- <testcase classname='PCU_Tests' name='TC_ul_tbf' time='MASKED'/>
- <testcase classname='PCU_Tests' name='TC_selftest_ns' time='MASKED'/>
- <testcase classname='PCU_Tests' name='TC_paging' time='MASKED'/>
+<testsuite name='Titan' tests='117' failures='5' errors='0' skipped='0' inconc='0' time='MASKED'>
+ <testcase classname='PCU_Tests' name='TC_pcuif_suspend' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_pcuif_suspend_active_tbf' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_ta_ptcch_idle' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_ta_rach_imm_ass' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_ta_ul_ack_nack_first_block' time='MASKED'>
+ <failure type='fail-verdict'>Timing Advance mismatch: expected 2, but received 0
+ PCU_Tests.ttcn:MASKED PCU_Tests control part
+ PCU_Tests.ttcn:MASKED TC_ta_ul_ack_nack_first_block testcase
+ </failure>
+ </testcase>
+ <testcase classname='PCU_Tests' name='TC_ta_idle_dl_tbf_ass' time='MASKED'>
+ <failure type='fail-verdict'>Timing Advance value doesn't match
+ PCU_Tests.ttcn:MASKED PCU_Tests control part
+ PCU_Tests.ttcn:MASKED TC_ta_idle_dl_tbf_ass testcase
+ </failure>
+ </testcase>
+ <testcase classname='PCU_Tests' name='TC_ta_ptcch_ul_multi_tbf' time='MASKED'>
+ <failure type='fail-verdict'>Failed to match Timing Advance Index for #0
+ PCU_Tests.ttcn:MASKED PCU_Tests control part
+ PCU_Tests.ttcn:MASKED TC_ta_ptcch_ul_multi_tbf testcase
+ </failure>
+ </testcase>
+ <testcase classname='PCU_Tests' name='TC_cs_lqual_ul_tbf' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_cs_initial_ul' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_cs_max_ul' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_cs_initial_dl' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_cs_max_dl' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_dl_cs1_to_cs4' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_mcs_initial_ul' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_mcs_max_ul' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_mcs_initial_dl' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_mcs_max_dl' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_t3141' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_n3101_max_t3169' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_n3103_max_t3169' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_x2031_t3191' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_zero_x2031_t3191' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_t3193' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_n3105_max_t3195' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_t3172_wait_ind_size0' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_t3172_wait_ind_size1' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_countdown_procedure' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_ul_all_sizes' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_ul_data_toolong_fills_padding' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_mo_ping_pong' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_mo_ping_pong_with_ul_racap' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_force_two_phase_access' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_mt_ping_pong' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_mt_ping_pong_with_dl_racap' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_ul_intermediate_retrans' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_imm_ass_dl_block_retrans' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_dl_flow_more_blocks' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_ul_flow_multiple_llc_blocks' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_dl_no_ack_retrans_imm_ass' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_dl_llc_sapi_priority' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_ul_tbf_bsn_wraparound_gprs' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_paging_cs_from_bts' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_paging_cs_from_sgsn_sign_ptmsi' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_paging_cs_from_sgsn_sign' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_paging_cs_from_sgsn_ptp' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_paging_ps_from_sgsn_sign_ptmsi' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_paging_ps_from_sgsn_sign' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_paging_ps_from_sgsn_ptp' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_paging_pch_timeout' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_paging_cs_multi_ms_imsi_tmsi' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_paging_cs_multi_ms_imsi' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_paging_cs_multi_ms_tmsi' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_bssgp_dl_unitdata_with_valid_imsi' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_bssgp_dl_unitdata_with_invalid_imsi' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_dl_gprs_data_no_llc_ui_dummy' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_dl_egprs_data_no_llc_ui_dummy' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_ul_tbf_finished_pkt_dl_ass_pch' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_ul_tbf_1phase_while_dl_ass_pch' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_ul_tbf_2phase_while_dl_ass_pch' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_egprs_pkt_chan_req_signalling' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_egprs_pkt_chan_req_one_phase' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_egprs_pkt_chan_req_two_phase' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_egprs_pkt_chan_req_reject_content' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_egprs_pkt_chan_req_reject_emergency' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_egprs_pkt_chan_req_reject_exhaustion' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_mo_ping_pong_with_ul_racap_egprs_only' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_pcuif_fh_imm_ass_ul_egprs' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_pcuif_fh_imm_ass_ul' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_pcuif_fh_imm_ass_dl' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_pcuif_fh_pkt_ass_ul' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_pcuif_fh_pkt_ass_dl' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_multitrx_multims_alloc' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_dl_multislot_tbf_ms_class_from_sgsn' time='MASKED'>
+ <failure type='fail-verdict'>Expected 8 PDCH slots allocated but got 4
+ PCU_Tests.ttcn:MASKED PCU_Tests control part
+ PCU_Tests.ttcn:MASKED TC_dl_multislot_tbf_ms_class_from_sgsn testcase
+ </failure>
+ </testcase>
+ <testcase classname='PCU_Tests' name='TC_dl_multislot_tbf_ms_class_unknown' time='MASKED'>
+ <failure type='fail-verdict'>Expected 1 PDCH slots allocated but got 4
+ PCU_Tests.ttcn:MASKED PCU_Tests control part
+ PCU_Tests.ttcn:MASKED TC_dl_multislot_tbf_ms_class_unknown testcase
+ </failure>
+ </testcase>
+ <testcase classname='PCU_Tests' name='TC_dl_multislot_tbf_ms_class_from_2phase' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_ul_multislot_tbf_ms_class_from_2phase' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_ul_tbf_reestablish_with_pkt_resource_req' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_ul_tbf_reestablish_with_pkt_resource_req_t3168' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_ul_tbf_reestablish_with_pkt_dl_ack_nack' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_ul_tbf_reestablish_with_pkt_dl_ack_nack_egprs' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_multiplex_dl_gprs_egprs' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_pcuif_info_ind_subsequent' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_nacc_outbound_success' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_nacc_outbound_success_utran' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_nacc_outbound_success_eutran' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_nacc_outbound_success_no_ctrl_ack' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_nacc_outbound_success_twice' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_nacc_outbound_success_twice_nocache' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_nacc_outbound_rac_ci_resolve_timeout' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_nacc_outbound_si_resolve_timeout' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_nacc_outbound_pkt_cell_chg_notif_dup' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_nacc_outbound_pkt_cell_chg_notif_dup2' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_nacc_outbound_pkt_cell_chg_notif_dup3' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_nacc_outbound_pkt_cell_chg_notif_dup4' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_nacc_outbound_pkt_cell_chg_notif_dup5' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_nacc_outbound_pkt_cell_chg_notif_twice' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_nacc_outbound_pkt_cell_chg_notif_twice2' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_nacc_outbound_pkt_cell_chg_notif_twice3' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_nacc_outbound_pkt_cell_chg_notif_twice4' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_nacc_outbound_pkt_cell_chg_notif_twice5' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_nacc_outbound_pkt_cell_chg_notif_unassigned_dl_tbf' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_rim_ran_info_req_single_rep' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_rim_ran_info_req_single_rep_eutran' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_rim_ran_info_req_single_rep_no_si' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_pdch_energy_saving' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_stat_pdch_avail_occ' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_stat_pdch_avail_occ_ms_not_known_gprs' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_stat_pdch_avail_occ_ms_not_known_egprs' time='MASKED'/>
+ <testcase classname='PCU_Tests' name='TC_ratectr_all_available_allocated' time='MASKED'/>
+ <testcase classname='PCU_Tests_NS' name='TC_ns_reset' time='MASKED'/>
+ <testcase classname='PCU_Tests_NS' name='TC_ns_reset_retrans' time='MASKED'/>
+ <testcase classname='PCU_Tests_NS' name='TC_ns_alive' time='MASKED'/>
+ <testcase classname='PCU_Tests_NS' name='TC_ns_alive_timeout_reset' time='MASKED'/>
+ <testcase classname='PCU_Tests_NS' name='TC_ns_unblock' time='MASKED'/>
+ <testcase classname='PCU_Tests_NS' name='TC_ns_unblock_retrans' time='MASKED'/>
+ <testcase classname='PCU_Tests_NS' name='TC_ns_full_bringup' time='MASKED'/>
+ <testcase classname='PCU_Tests_NS' name='TC_ns_so_block' time='MASKED'/>
</testsuite>
diff --git a/pcu/gen_links.sh b/pcu/gen_links.sh
index f9f6dd5d..556f02a7 100755
--- a/pcu/gen_links.sh
+++ b/pcu/gen_links.sh
@@ -44,13 +44,20 @@ DIR=$BASEDIR/titan.ProtocolModules.SNDCP_v7.0.0/src
FILES="SNDCP_Types.ttcn"
gen_links $DIR $FILES
+DIR=$BASEDIR/titan.TestPorts.TELNETasp/src
+FILES="TELNETasp_PT.cc TELNETasp_PT.hh TELNETasp_PortType.ttcn"
+gen_links $DIR $FILES
DIR=../library
-FILES="Misc_Helpers.ttcn General_Types.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+="NS_Emulation.ttcn NS_CodecPort.ttcn NS_CodecPort_CtrlFunct.ttcn NS_CodecPort_CtrlFunctDef.cc "
-FILES+="BSSGP_Emulation.ttcn Osmocom_Gb_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 GSM_RestOctets.ttcn Osmocom_Types.ttcn RLCMAC_Templates.ttcn RLCMAC_Types.ttcn RLCMAC_CSN1_Templates.ttcn RLCMAC_CSN1_Types.ttcn RLCMAC_EncDec.cc "
+FILES+="StatsD_Types.ttcn StatsD_CodecPort.ttcn StatsD_CodecPort_CtrlFunct.ttcn StatsD_CodecPort_CtrlFunctdef.cc StatsD_Checker.ttcn "
+FILES+="RAW_NS.ttcnpp NS_Provider_IPL4.ttcn NS_Emulation.ttcnpp "
+FILES+="BSSGP_Emulation.ttcnpp Osmocom_Gb_Types.ttcn "
FILES+="LLC_Templates.ttcn L3_Templates.ttcn L3_Common.ttcn "
-FILES+="PCUIF_Types.ttcn PCUIF_CodecPort.ttcn "
+FILES+="PCUIF_Types.ttcn PCUIF_CodecPort.ttcn RAW_NS.ttcnpp "
+# IPA_Emulation + dependencies
+FILES+="IPA_Types.ttcn IPA_Emulation.ttcnpp IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc "
+FILES+="Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn Osmocom_CTRL_Adapter.ttcn "
gen_links $DIR $FILES
ignore_pp_results
diff --git a/pcu/osmo-bsc.cfg b/pcu/osmo-bsc.cfg
deleted file mode 100644
index c5619557..00000000
--- 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 7f36f87e..00000000
--- 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/osmo-pcu-sns.cfg b/pcu/osmo-pcu-sns.cfg
index c2cd58ac..cfe4ccfe 100644
--- a/pcu/osmo-pcu-sns.cfg
+++ b/pcu/osmo-pcu-sns.cfg
@@ -1,8 +1,10 @@
log gsmtap 127.0.0.1
logging level set-all debug
+ logging filter all 1
log stderr
logging filter all 1
+ logging color 1
logging print level 1
logging print category 1
logging print category-hex 0
@@ -21,3 +23,5 @@ pcu
gamma 0
pcu-socket /tmp/pcu_bts
gb-dialect ip-sns
+ns
+ timer tns-test 10
diff --git a/pcu/osmo-pcu.cfg b/pcu/osmo-pcu.cfg
index d6213b51..68ea521b 100644
--- a/pcu/osmo-pcu.cfg
+++ b/pcu/osmo-pcu.cfg
@@ -1,14 +1,26 @@
log gsmtap 127.0.0.1
logging level set-all debug
+ logging filter all 1
log stderr
logging filter all 1
+ logging color 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
+!
+stats interval 0
+stats reporter statsd
+ prefix TTCN3
+ level subscriber
+ remote-ip 127.0.0.1
+ remote-port 8125
+ flush-period 1
+ mtu 1024
+ enable
line vty
no login
@@ -17,6 +29,9 @@ pcu
flow-control-interval 10
cs 2
alloc-algorithm dynamic
- alpha 0
gamma 0
pcu-socket /tmp/pcu_bts
+! By default, use the PCUIF for neighbor resolution
+! neighbor resolution 127.0.0.1
+ gsmtap-remote-host 127.0.0.1
+ gsmtap-category enable-all
diff --git a/pcu/regen_makefile.sh b/pcu/regen_makefile.sh
index ff712dc4..006c6baa 100755
--- a/pcu/regen_makefile.sh
+++ b/pcu/regen_makefile.sh
@@ -1,5 +1,27 @@
#!/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 Native_FunctionDefs.cc"
+NAME=PCU_Tests
-../regen-makefile.sh PCU_Tests.ttcn $FILES
+FILES="
+ *.ttcn
+ *.ttcnpp
+ BSSGP_EncDec.cc
+ IPA_CodecPort_CtrlFunctDef.cc
+ IPL4asp_PT.cc
+ IPL4asp_discovery.cc
+ LLC_EncDec.cc
+ Native_FunctionDefs.cc
+ RLCMAC_EncDec.cc
+ StatsD_CodecPort_CtrlFunctdef.cc
+ TCCConversion.cc
+ TCCInterface.cc
+ TELNETasp_PT.cc
+ UD_PT.cc
+"
+
+export CPPFLAGS_TTCN3="
+ -DBSSGP_EM_L3
+ -DIPA_EMULATION_CTRL
+"
+
+../regen-makefile.sh -e $NAME $FILES