Osmocom test suites in TTCN-3 (Eclipse Titan) https://osmocom.org/projects/core-testing-infra
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
osmo-ttcn3-hacks/bts/BTS_Tests.ttcn

7398 lines
235 KiB

module BTS_Tests {
/* Integration Tests for OsmoBTS
* (C) 2018-2019 by Harald Welte <laforge@gnumonks.org>
* contributions by Vadim Yanitskiy and sysmocom - s.f.m.c. GmbH
* 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
*
* This test suite tests OsmoBTS by attaching to the external interfaces
* such as Abis RSL, PCU, VTY as well as by attaching to a MS L1 implementation
* using the L1CTL protocol/interface.
*
* You can run the tests with
* a) osmo-bts-trx + trxcon + fake_trx (without any hardware)
* b) any osmo-bts-* + OsmocomBB layer1 + osmocon (with real BTS hardware)
* c) osmo-bts-virtual + virt_phy (without any hardware)
*
* Some of the tests will only run on a subset of those three configurations
* due to limitations in the respective L1.
*/
import from Misc_Helpers all;
import from General_Types all;
import from GSM_Types all;
import from GSM_RR_Types all;
import from Osmocom_Types all;
import from GSM_Types all;
import from GSM_RestOctets all;
import from GSM_SystemInformation all;
import from L1CTL_PortType all;
import from L1CTL_Types all;
import from LAPDm_Types all;
import from LAPDm_RAW_PT all;
import from Native_Functions all;
import from Osmocom_CTRL_Adapter all;
import from Osmocom_CTRL_Functions all;
import from RSL_Types all;
import from IPA_Types all;
import from IPA_Emulation all;
import from IPA_Testing all;
import from RSL_Emulation all;
import from IPL4asp_Types all;
import from TRXC_Types all;
import from TRXC_CodecPort all;
import from TRXC_CodecPort_CtrlFunct all;
import from PCUIF_Types all;
import from PCUIF_CodecPort all;
import from UD_Types all;
import from MobileL3_CommonIE_Types all;
import from MobileL3_RRM_Types all;
import from MobileL3_Types all;
import from L3_Templates all;
import from L3_Common all;
import from MobileL3_GMM_SM_Types all;
import from Osmocom_VTY_Functions all;
import from TELNETasp_PortType all;
import from BTS_Tests_LAPDm all;
friend module BTS_Tests_SMSCB;
friend module BTS_Tests_virtphy;
friend module BTS_Tests_LAPDm;
friend module BTS_Tests_perf;
/* The tests assume a BTS with the following timeslot configuration:
* TS0 : Combined CCCH + SDCCH/4
* TS1 : TCH/F
* TS2 : TCH/F
* TS3 : TCH/F_PDCH (IPA Style)
* TS4 : TCH/F_TCH/H_PDCH (Osmocom Style)
* TS5 : TCH/H
* TS6 : SDCCH/8
* TS7 : PDCH
*/
modulepar {
charstring mp_rsl_ip := "127.0.0.2";
integer mp_rsl_port := 3003;
charstring mp_bts_trxc_ip := "127.0.0.1";
integer mp_bts_trxc_port := 5701;
charstring mp_pcu_socket := PCU_SOCK_DEFAULT;
charstring mp_ctrl_ip := "127.0.0.1";
integer mp_ctrl_port := 4238;
charstring mp_bsc_ctrl_ip := "127.0.0.1";
integer mp_bsc_ctrl_port := 4249;
integer mp_tolerance_rxqual := 1;
integer mp_tolerance_rxlev := 3;
integer mp_tolerance_timing_offset_256syms := 0;
integer mp_rxlev_exp := 57;
integer mp_ul_rxlev_exp := 10;
integer mp_ms_power_level_exp := 7;
integer mp_bts_tx_nom_pwr_exp := 50; /* Expected Tx Nominal Output Power of the BTS, in dBm */
integer mp_bts_tx_pwr_att_exp := 20; /* Expected Tx Power attenuation wrt to Tx Nominal Output Power, in dB */
integer mp_ms_actual_ta_exp := 0;
integer mp_timing_offset_256syms_exp := 512;
integer mp_uplink_power_target := -75;
integer mp_uplink_power_hysteresis := 8; /* -83 .. -67 */
/* Time to wait for RSL conn from BTS during startup of test */
float mp_ipa_up_timeout := 15.0;
float mp_ipa_up_delay := 0.0;
/* false for now, as only virtphy supports it, not calypso-l1 nor trxcon */
boolean mp_l1_supports_gprs := false;
/* how many transceivers do we expect to connect */
integer mp_transceiver_num := 1;
/* frequency hopping status */
boolean mp_freq_hop_enabled := false;
/* frequency hopping parameters */
FreqHopConfig mp_fh_config;
/* configuration for each individual transceiver */
TrxPars mp_trx_pars; /* see BTS_Tests.default */
/* default Training Sequence Code */
GsmTsc mp_tsc_def := 7;
}
type record of RslChannelNr ChannelNrs;
type component test_CT extends CTRL_Adapter_CT {
/* IPA Emulation component underneath RSL */
var IPA_Emulation_CT vc_IPA;
/* RSL Emulation component (for ConnHdlr tests) */
var RSL_Emulation_CT vc_RSL;
/* Direct RSL_CCHAN_PT */
port RSL_CCHAN_PT RSL_CCHAN;
/* L1CTL port (for classic tests) */
port L1CTL_PT L1CTL;
/* Optional TRXC connection to FakeTRX (BTS side) */
port TRXC_CODEC_PT BTS_TRXC;
var integer g_bts_trxc_conn_id;
/* VTY connections to both BTS and BSC */
port TELNETasp_PT BTSVTY;
port TELNETasp_PT BSCVTY;
/* PCU Interface of BTS */
port PCUIF_CODEC_PT PCU;
var integer g_pcu_conn_id;
/* Last PCU INFO IND we received */
var PCUIF_Message g_pcu_last_info;
/* SI configuration */
var SystemInformationConfig si_cfg := {
bcch_extended := false,
si1_present := false,
si2bis_present := false,
si2ter_present := false,
si2quater_present := false,
si7_present := false,
si8_present := false,
si9_present := false,
si13_present := false,
si13alt_present := false,
si15_present := false,
si16_present := false,
si17_present := false,
si2n_present := false,
si21_present := false,
si22_present := false
};
/* all logical channels available on the BTS */
var ChannelNrs g_AllChannels;
var ChannelNrs g_AllChanTypes;
}
/* an individual call / channel */
type component ConnHdlr extends RSL_DchanHdlr, lapdm_test_CT {
port L1CTL_PT L1CTL;
/* Optional TRXC connection to FakeTRX (BTS side) */
port TRXC_CODEC_PT BTS_TRXC;
var integer g_bts_trxc_conn_id;
/* port to be initialized optionally to access BSC VTY */
port TELNETasp_PT BSCVTY;
timer g_Tguard;
timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */
var ConnHdlrPars g_pars;
var uint8_t g_next_meas_res_nr := 0;
var boolean g_first_meas_res := true;
/* PCU Interface of BTS */
port PCUIF_CODEC_PT PCU;
}
private function f_init_rsl(charstring id) runs on test_CT {
var bitstring trx_mask := '00000000'B;
var bitstring rfind_mask := '00000000'B;
var integer trx_count := 0;
var integer rfind_count := 0;
var RSLEm_Event ev;
var ASP_RSL_Unitdata rx_ud;
timer T;
vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA");
vc_RSL := RSL_Emulation_CT.create(id & "-RSL");
map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT);
connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT);
vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port));
vc_RSL.start(RSL_Emulation.main(false));
/* We expect (N = mp_transceiver_num) IPA/RSL transceiver connections here.
* See https://gerrit.osmocom.org/q/Ib5ad31388ae25399ad09739aac3fdcb0b3a1f78b. */
T.start(mp_ipa_up_timeout);
alt {
/* These events are sent by the RSL_Emulation_CT */
[] RSL_CCHAN.receive(tr_RSLEm_EV(RSLEM_EV_TRX_UP, ?)) -> value ev {
/* Make sure that all transceivers use unique stream ID */
if (trx_mask[enum2int(ev.sid)] == '1'B) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
log2str("Duplicate RSL stream ID (", ev.sid, ")"));
}
trx_mask[enum2int(ev.sid)] := '1'B;
trx_count := trx_count + 1;
log(trx_count, "/", mp_transceiver_num, " transceiver(s) connected");
repeat;
}
/* This message (RF RESource INDication) is sent by the IUT itself */
[] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND, ?)) -> value rx_ud {
if (trx_mask[enum2int(rx_ud.streamId)] == '0'B) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
log2str("Got RF Resource Indication before RSLEM_EV_TRX_UP (", rx_ud.streamId, ")"));
}
if (rfind_mask[enum2int(rx_ud.streamId)] == '1'B) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
log2str("Duplicate RF Resource Indication ID (", rx_ud.streamId, ")"));
}
rfind_mask[enum2int(rx_ud.streamId)] := '1'B;
rfind_count := rfind_count + 1;
log(rfind_count, "/", mp_transceiver_num, " RF Resource Indication(s) received");
if (rfind_count < mp_transceiver_num) { repeat; }
}
/* osmo-bts may send us CCCH LOAD INDication or whatever else */
[] RSL_CCHAN.receive(ASP_RSL_Unitdata:?) { repeat; }
[] T.timeout {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
"Timeout waiting for RSL bring up");
}
}
}
friend type record length(1 .. 256) of TrxParsItem TrxPars;
friend type record TrxParsItem {
GsmArfcn arfcn,
TrxTsPars ts
};
friend type record length(8) of TrxTsParsItem TrxTsPars;
friend type record TrxTsParsItem {
PchanConfig config
};
friend type record FreqHopPars {
/* Whether frequency hopping is in use */
boolean enabled,
/* Mobile Allocation Index Offset / Hopping Sequence Number */
MaioHsn maio_hsn,
/* MA bitmap to be indicated in RR Immediate Assignment */
MobileAllocationLV ma_map,
/* The actual Mobile Allocation (ARFCN list) to be used */
L1ctlMA ma
};
type record ConnHdlrPars {
RslChannelNr chan_nr,
RSL_IE_ChannelMode chan_mode,
float t_guard,
ConnL1Pars l1_pars,
TestSpecUnion spec optional,
RSL_IE_EncryptionInfo encr optional,
BtsBand bts0_band optional,
/* Training Sequence Code */
GsmTsc tsc,
/* Frequency hopping parameters */
FreqHopPars fhp
};
/* Test-specific parameters */
private type union TestSpecUnion {
RllTestCase rll
}
private template (value) RachControlParameters ts_RachCtrl_default := {
max_retrans := RACH_MAX_RETRANS_7,
tx_integer := '1001'B, /* 12 slots */
cell_barr_access := false,
re_not_allowed := true,
acc := '0000010000000000'B
};
private template (value) CellSelectionParameters ts_CellSelPar_default := {
cell_resel_hyst_2dB := 2,
ms_txpwr_max_cch := mp_ms_power_level_exp,
acs := '0'B,
neci := true,
rxlev_access_min := 0
}
private template (value) LocationAreaIdentification ts_LAI_default := {
mcc_mnc := '262F42'H,
lac := 42
}
private template (value) GPRSIndicator ts_GPRSIndicator_def := {
ra_colour := 0,
si13_pos := '0'B
}
private template (value) SI3RestOctets ts_SI3RestOctets_def
modifies ts_SI3RestOctets := {
gprs_ind := {
presence := CSN1_H,
ind := ts_GPRSIndicator_def
}
}
private template (value) SI4RestOctets ts_SI4RestOctets_def
modifies ts_SI4RestOctets := {
gprs_ind := {
presence := CSN1_H,
ind := ts_GPRSIndicator_def
}
}
/* Default SYSTEM INFORMATION 3 */
private template (value) SystemInformation ts_SI3_default := {
header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18),
payload := {
si3 := {
cell_id := 23,
lai := ts_LAI_default,
ctrl_chan_desc := {
msc_r99 := true,
att := true,
bs_ag_blks_res := 1,
ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
si22ind := false,
cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
spare := '00'B,
bs_pa_mfrms := 0, /* 2 multiframes */
t3212 := 1 /* 6 minutes */
},
cell_options := {
dn_ind := false,
pwrc := false,
dtx := MS_MAY_USE_UL_DTX,
radio_link_tout_div4 := (32/4)-1
},
cell_sel_par := ts_CellSelPar_default,
rach_control := ts_RachCtrl_default,
rest_octets := valueof(ts_SI3RestOctets_def)
}
}
}
private template (value) SystemInformation ts_SI2_default := {
header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22),
payload := {
si2 := {
bcch_freq_list := '00000000000000000000000000000000'O,
ncc_permitted := '11111111'B,
rach_control := ts_RachCtrl_default
}
}
}
private template (value) SystemInformation ts_SI4_default := {
header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */
payload := {
si4 := {
lai := ts_LAI_default,
cell_sel_par := ts_CellSelPar_default,
rach_control := ts_RachCtrl_default,
cbch_chan_desc := omit,
cbch_mobile_alloc := omit,
rest_octets := valueof(ts_SI4RestOctets_def)
}
}
}
private function f_rsl_bcch_fill_raw(RSL_IE_SysinfoType rsl_si_type, octetstring si_enc)
runs on test_CT {
log("Setting ", rsl_si_type, ": ", si_enc);
RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_BCCH_INFO(rsl_si_type, si_enc)));
}
private function f_rsl_bcch_fill(RSL_IE_SysinfoType rsl_si_type, template (value) SystemInformation si_dec)
runs on test_CT {
var octetstring si_enc := enc_SystemInformation(valueof(si_dec));
log("Setting ", rsl_si_type, ": ", si_dec);
f_rsl_bcch_fill_raw(rsl_si_type, si_enc);
}
friend function f_init_vty(charstring id) runs on test_CT {
map(self:BTSVTY, system:BTSVTY);
f_vty_set_prompts(BTSVTY);
f_vty_transceive(BTSVTY, "enable");
}
friend function f_init_vty_bsc() runs on test_CT {
map(self:BSCVTY, system:BSCVTY);
f_vty_set_prompts(BSCVTY, "OsmoBSC");
f_vty_transceive(BSCVTY, "enable");
}
friend function f_connhdlr_init_vty_bsc() runs on ConnHdlr {
map(self:BSCVTY, system:BSCVTY);
f_vty_set_prompts(BSCVTY, "OsmoBSC");
f_vty_transceive(BSCVTY, "enable");
}
/* PCU socket may at any time receive a new INFO.ind */
private altstep as_pcu_info_ind(PCUIF_CODEC_PT pt, integer pcu_conn_id,
out PCUIF_Message pcu_last_info) {
var PCUIF_send_data sd;
[] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd {
pcu_last_info := sd.data;
}
[] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(?, ?, ?))) -> value sd {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Invalid PCU Version/BTS Number received");
}
}
private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id,
out integer pcu_conn_id, out PCUIF_Message pcu_last_info) {
timer T := 2.0;
var PCUIF_send_data sd;
if (mp_pcu_socket == "") {
pcu_conn_id := -1;
return;
}
pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket);
T.start;
alt {
[] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info);
[] T.timeout {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU INFO_IND");
}
}
}
private function f_init_trxc(TRXC_CODEC_PT pt, charstring id,
out integer trxc_conn_id) {
var Result res;
res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(pt, mp_bts_trxc_ip, mp_bts_trxc_port,
"", -1, -1, { udp := {} }, {});
if (not ispresent(res.connId)) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
"Could not connect to the control (TRXC) interface " &
"of FakeTRX, check your configuration");
}
trxc_conn_id := res.connId;
}
/* global init function */
friend function f_init(uint8_t trx_nr := 0)
runs on test_CT
{
var TrxParsItem trx_pars := mp_trx_pars[trx_nr];
var charstring id := testcasename();
/* FIXME: FACCH/H is unreliable with calypso firmware, see OS#3653.
* TODO: also generate this list dynamically from module parameters. */
if (mp_bts_trxc_port != -1) {
g_AllChanTypes := {
/* TS 1..4: TCH/F */
valueof(ts_RslChanNr_Bm(1)),
/* TS 5: TCH/H */
valueof(ts_RslChanNr_Lm(5,1)),
/* TS 0: SDCCH/4 */
valueof(ts_RslChanNr_SDCCH4(0,2)),
/* TS 6: SDCCH/8 */
valueof(ts_RslChanNr_SDCCH8(6,4))
};
} else {
g_AllChanTypes := {
/* TS 1..4: TCH/F */
valueof(ts_RslChanNr_Bm(1)),
/* TS 0: SDCCH/4 */
valueof(ts_RslChanNr_SDCCH4(0,2)),
/* TS 6: SDCCH/8 */
valueof(ts_RslChanNr_SDCCH8(6,4))
};
}
g_AllChannels := { };
/* Generate list of all logical channels from module parameters */
for (var integer tn := 0; tn < lengthof(trx_pars.ts); tn := tn + 1) {
select (trx_pars.ts[tn].config) {
case (GSM_PCHAN_CCCH_SDCCH4) {
g_AllChannels := g_AllChannels &
{ valueof(ts_RslChanNr_SDCCH4(tn, 0)),
valueof(ts_RslChanNr_SDCCH4(tn, 1)),
valueof(ts_RslChanNr_SDCCH4(tn, 2)),
valueof(ts_RslChanNr_SDCCH4(tn, 3)) };
}
case (GSM_PCHAN_SDCCH8) {
g_AllChannels := g_AllChannels &
{ valueof(ts_RslChanNr_SDCCH8(tn, 0)),
valueof(ts_RslChanNr_SDCCH8(tn, 1)),
valueof(ts_RslChanNr_SDCCH8(tn, 2)),
valueof(ts_RslChanNr_SDCCH8(tn, 3)),
valueof(ts_RslChanNr_SDCCH8(tn, 4)),
valueof(ts_RslChanNr_SDCCH8(tn, 5)),
valueof(ts_RslChanNr_SDCCH8(tn, 6)),
valueof(ts_RslChanNr_SDCCH8(tn, 7)) };
}
case (GSM_PCHAN_TCHH_TCHF_PDCH) {
g_AllChannels := g_AllChannels &
{ valueof(ts_RslChanNr_Lm(tn, 0)),
valueof(ts_RslChanNr_Lm(tn, 1)),
valueof(ts_RslChanNr_Bm(tn)) };
}
case (GSM_PCHAN_TCHH) {
g_AllChannels := g_AllChannels &
{ valueof(ts_RslChanNr_Lm(tn, 0)),
valueof(ts_RslChanNr_Lm(tn, 1)) };
}
case (GSM_PCHAN_TCHF, GSM_PCHAN_TCHF_PDCH) {
g_AllChannels := g_AllChannels &
{ valueof(ts_RslChanNr_Bm(tn)) };
}
}
}
f_init_rsl(id);
f_sleep(0.5); /* workaround for OS#3000 */
f_init_vty(id);
f_ipa_ctrl_start(mp_ctrl_ip, mp_ctrl_port);
/* Send SI3 to the BTS, it is needed for various computations */
f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default);
/* SI2 + SI4 are required for SI testing as they are mandatory defaults */
f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default);
f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default);
map(self:PCU, system:PCU);
f_init_pcu(PCU, id, g_pcu_conn_id, g_pcu_last_info);
if (mp_bts_trxc_port != -1) {
var TrxcMessage ret;
/* Init TRXC interface to FakeTRX */
map(self:BTS_TRXC, system:BTS_TRXC);
f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id);
/* Start with a default moderate timing offset equalling TA=2, and RSSI=-60 */
ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(2*256)));
ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_RSSI(-60)));
/* OsmoBTS may have different AB / NB threshold (see MIN_QUAL_NORM, MIN_QUAL_RACH) */
ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_CI(60)));
}
/* Wait some extra time to make sure the BTS emits a stable carrier.
* (this is only relevant when running the tests with a physical BTS.) */
f_sleep(mp_ipa_up_delay);
}
/* Attach L1CTL to master test_CT (classic tests, non-handler mode) */
friend function f_init_l1ctl() runs on test_CT {
map(self:L1CTL, system:L1CTL);
f_connect_reset(L1CTL);
}
private type function void_fn(charstring id) runs on ConnHdlr;
private type record length(8) of FreqHopGroups FreqHopConfig;
private type record of FreqHopGroup FreqHopGroups;
private type record FreqHopGroup {
uint6_t hsn,
FreqHopGroupItems trx_maio
};
private type record of FreqHopGroupItem FreqHopGroupItems;
private type record FreqHopGroupItem {
uint8_t trx_nr,
uint6_t maio
};
friend function f_resolve_fh_params(inout FreqHopPars fhp, uint8_t tn,
uint8_t trx_nr := 0)
{
var FreqHopGroups groups := mp_fh_config[tn];
var integer i, j;
fhp.enabled := false;
for (i := 0; i < lengthof(groups); i := i + 1) {
var FreqHopGroup g := groups[i];
for (j := 0; j < lengthof(g.trx_maio); j := j + 1) {
var FreqHopGroupItem gi := g.trx_maio[j];
if (gi.trx_nr == trx_nr) {
fhp.maio_hsn.maio := gi.maio;
fhp.maio_hsn.hsn := g.hsn;
fhp.enabled := true;
break;
}
}
if (fhp.enabled) {
/* Prepare the Mobile Allocation bitmask (length & padding) */
fhp.ma_map.len := (mp_transceiver_num + 8 - 1) / 8; /* in bytes */
fhp.ma_map.ma := f_pad_bit('0'B, fhp.ma_map.len * 8, '0'B);
fhp.ma := { }; /* to be composed below */
/* Compose the actual Mobile Allocation and the bitmask */
for (j := 0; j < lengthof(g.trx_maio); j := j + 1) {
var FreqHopGroupItem gi := g.trx_maio[j];
var GsmArfcn arfcn := mp_trx_pars[gi.trx_nr].arfcn;
fhp.ma := fhp.ma & { valueof(ts_GsmBandArfcn(arfcn)) };
fhp.ma_map.ma[gi.trx_nr] := '1'B;
}
log("Freq. hopping parameters: ", fhp);
break; /* We're done */
}
}
}
/* create a new test component */
friend function f_start_handler(void_fn fn, ConnHdlrPars pars,
boolean pcu_comp := false,
boolean trxc_comp := false)
runs on test_CT return ConnHdlr {
var charstring id := testcasename();
var ConnHdlr vc_conn;
vc_conn := ConnHdlr.create(id);
/* connect to RSL Emulation main component */
connect(vc_conn:RSL, vc_RSL:CLIENT_PT);
connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC);
/* The ConnHdlr component may want to talk to some ports directly,
* so we disconnect it from the test_CT and connect it to the component.
* This obviously only works for one component, i.e. no concurrency. */
if (pcu_comp) {
unmap(self:PCU, system:PCU);
map(vc_conn:PCU, system:PCU);
}
if (trxc_comp) {
unmap(self:BTS_TRXC, system:BTS_TRXC);
map(vc_conn:BTS_TRXC, system:BTS_TRXC);
}
/* Obtain frequency hopping parameters for a given timeslot */
if (mp_freq_hop_enabled and mp_transceiver_num > 1) {
f_resolve_fh_params(pars.fhp, pars.chan_nr.tn);
}
vc_conn.start(f_handler_init(fn, id, pars));
return vc_conn;
}
private altstep as_Tguard() runs on ConnHdlr {
[] g_Tguard.timeout {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout");
}
}
friend function f_l1_tune(L1CTL_PT L1CTL, L1ctlCcchMode ccch_mode := CCCH_MODE_COMBINED) {
var GsmBandArfcn arfcn := valueof(ts_GsmBandArfcn(mp_trx_pars[0].arfcn));
f_L1CTL_FBSB(L1CTL, arfcn, ccch_mode, mp_rxlev_exp);
}
private function f_trxc_fake_rssi(TRXC_RSSI rssi) runs on ConnHdlr {
var TrxcMessage ret;
ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_RSSI(rssi)));
}
private function f_trxc_fake_toffs256(int16_t toffs256) runs on ConnHdlr {
var TrxcMessage ret;
ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
}
/* first function started in ConnHdlr component */
private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars)
runs on ConnHdlr {
g_pars := pars;
g_chan_nr := pars.chan_nr;
map(self:L1CTL, system:L1CTL);
f_connect_reset(L1CTL);
if (mp_bts_trxc_port != -1 and BTS_TRXC.checkstate("Mapped")) {
f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id);
}
g_Tguard.start(pars.t_guard);
activate(as_Tguard());
f_rslem_register(0, pars.chan_nr);
/* call the user-supplied test case function */
fn.apply(id);
}
private function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx,
charstring id, boolean ignore_other := false)
runs on ConnHdlr return RSL_Message {
var RSL_Message rx;
timer T := 3.0;
RSL.send(tx);
T.start;
alt {
[] RSL.receive(exp_rx) -> value rx {
T.stop;
setverdict(pass);
}
[] T.timeout {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting " & id);
}
[not ignore_other] as_l1_sacch();
[not ignore_other] as_meas_res();
[not ignore_other] as_l1_dcch_loop();
[not ignore_other] as_l1_tch_loop();
[not ignore_other] RSL.receive {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message received");
}
[ignore_other] RSL.receive { repeat; }
}
return rx;
}
friend function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx,
charstring id, boolean ignore_other := false)
runs on ConnHdlr {
var RSL_Message rx := f_rsl_transceive_ret(tx, exp_rx, id, ignore_other);
}
friend function f_rsl_chan_act(RSL_IE_ChannelMode mode,
boolean encr_enable := false,
RSL_IE_List more_ies := {},
RSL_IE_ActivationType act_type := t_RSL_IE_ActType_IA)
runs on ConnHdlr {
var RSL_Message ch_act := valueof(ts_RSL_CHAN_ACT(g_chan_nr, mode, act_type));
if (encr_enable) {
/* append encryption related IEs, if requested */
var RSL_IE_EncryptionInfo encr_info;
encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key));
ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info :=
encr_info})) };
}
ch_act.ies := ch_act.ies & more_ies;
f_rsl_transceive(ch_act, tr_RSL_CHAN_ACT_ACK(g_chan_nr), "RSL CHAN ACT");
}
friend function f_rsl_chan_deact() runs on ConnHdlr {
f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr),
"RF CHAN REL", true);
}
friend template ConnHdlrPars t_Pars(template RslChannelNr chan_nr,
template RSL_IE_ChannelMode chan_mode,
float t_guard := 20.0) := {
chan_nr := valueof(chan_nr),
chan_mode := valueof(chan_mode),
t_guard := t_guard,
l1_pars := {
dtx_enabled := false,
toa256_enabled := false,
meas_ul := {
full := {
rxlev := mp_ul_rxlev_exp,
rxqual := 0
},
sub := {
rxlev := mp_ul_rxlev_exp,
rxqual := 0
}
},
timing_offset_256syms := mp_timing_offset_256syms_exp,
bs_power_level := 0,
ms_power_level := mp_ms_power_level_exp,
ms_actual_ta := mp_ms_actual_ta_exp,
facch_enabled := false
},
spec := omit,
encr := omit,
bts0_band := omit,
tsc := mp_tsc_def,
fhp := {
enabled := false,
maio_hsn := ts_HsnMaio(0, 0),
ma_map := c_MA_null,
ma := { }
}
}
/***********************************************************************
* Channel Activation / Deactivation
***********************************************************************/
/* Stress test: Do 500 channel activations/deactivations in rapid succession */
private function f_TC_chan_act_stress(charstring id) runs on ConnHdlr {
for (var integer i := 0; i < 500; i := i+1) {
f_rsl_chan_act(g_pars.chan_mode);
f_rsl_chan_deact();
}
setverdict(pass);
}
testcase TC_chan_act_stress() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
f_init();
vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars);
vc_conn.done;
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* Test if re-activation of an already active channel fails as expected */
private function f_TC_chan_act_react(charstring id) runs on ConnHdlr {
f_rsl_chan_act(g_pars.chan_mode);
/* attempt to activate the same lchan again -> expect reject */
RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
alt {
[] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK on double activation");
}
[] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
setverdict(pass);
}
}
f_rsl_chan_deact();
}
testcase TC_chan_act_react() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
f_init();
vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars);
vc_conn.done;
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* Attempt to de-activate a channel that's not active */
private function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr {
timer T := 3.0;
RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
T.start;
alt {
[] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
setverdict(pass);
}
[] T.timeout {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting RF_CHAN_REL_ACK");
}
}
}
testcase TC_chan_deact_not_active() runs on test_CT {
var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
f_init();
var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars);
vc_conn.done;
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */
private function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr {
RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
alt {
[] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK");
}
[] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
setverdict(pass);
}
}
}
private type record WrongChanNrCase {
RslChannelNr chan_nr,
charstring description
}
private type record of WrongChanNrCase WrongChanNrCases;
private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := {
chan_nr := chan_nr,
description := desc
}
testcase TC_chan_act_wrong_nr() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
var WrongChanNrCases wrong := {
valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")),
valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")),
valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")),
valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")),
valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")),
valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")),
valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")),
valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")),
valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")),
valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")),
valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")),
valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")),
valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H"))
};
for (var integer i := 0; i < sizeof(wrong); i := i+1) {
pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN));
vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars);
vc_conn.done;
}
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* execute the same callback function on a variety of logical channels */
friend function f_testmatrix_each_chan(ConnHdlrPars pars, void_fn fn) runs on test_CT {
var ConnHdlr vc_conn;
f_init();
/* test on each of the channels we have */
for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) {
pars.chan_nr := valueof(g_AllChanTypes[i]);
log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]);
vc_conn := f_start_handler(fn, pars);
vc_conn.done;
}
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/***********************************************************************
* SACCH handling
***********************************************************************/
private function f_exp_sacch(boolean exp) runs on ConnHdlr {
timer T_sacch := 3.0;
T_sacch.start;
alt {
[not exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received SACCH when not expecting it");
}
[not exp] T_sacch.timeout {
setverdict(pass);
}
[exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) {
setverdict(pass);
}
[exp] T_sacch.timeout {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH on ", g_chan_nr));
}
[] L1CTL.receive { repeat; }
[] RSL.receive { repeat; }
}
}
/* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */
private function f_TC_deact_sacch(charstring id) runs on ConnHdlr {
f_l1_tune(L1CTL);
RSL.clear;
/* activate the logical channel */
f_est_dchan();
L1CTL.clear;
/* check that SACCH actually are received as expected */
f_exp_sacch(true);
/* deactivate SACCH on the logical channel */
RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr));
f_sleep(1.0);
L1CTL.clear;
/* check that no SACCH are received anymore */
f_exp_sacch(false);
/* release the channel */
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
}
testcase TC_deact_sacch() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
//for (var integer i := 0; i < 1; i := i+1) {
pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
log(testcasename(), ": Starting for ", g_AllChannels[i]);
vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars);
vc_conn.done;
}
/* TODO: do the above in parallel, rather than sequentially? */
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* verify that given SACCH payload is present */
private function f_sacch_present(template octetstring l3_exp) runs on ConnHdlr {
var L1ctlDlMessage dl;
/* check that the specified SI5 value is actually sent */
timer T_sacch := 3.0;
L1CTL.clear;
T_sacch.start;
alt {
[] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
if (match(l3, l3_exp)) {
setverdict(pass);
} else {
repeat;
}
}
[] L1CTL.receive { repeat; }
[] T_sacch.timeout {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for SACCH ", l3_exp));
}
}
}
/* verify that given SACCH payload is not present */
private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr {
var L1ctlDlMessage dl;
/* check that the specified SI5 value is actually sent */
timer T_sacch := 3.0;
L1CTL.clear;
T_sacch.start;
alt {
[] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl {
var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19);
if (match(l3, l3_exp)) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected SACCH ", dl));
} else {
repeat;
}
}
[] L1CTL.receive { repeat; }
[] T_sacch.timeout {
setverdict(pass);
}
}
}
/* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */
private function f_TC_sacch_filling(charstring id) runs on ConnHdlr {
/* Set a known default SACCH filling for SI5 */
var octetstring si5 := f_rnd_octstring(19);
RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
f_l1_tune(L1CTL);
RSL.clear;
/* activate the logical channel */
f_est_dchan();
/* check that the specified SI5 value is actually sent */
f_sacch_present(si5);
/* release the channel */
RSL.clear;
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
}
testcase TC_sacch_filling() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
log(testcasename(), ": Starting for ", g_AllChannels[i]);
vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars);
vc_conn.done;
}
/* TODO: do the above in parallel, rather than sequentially? */
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */
private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr {
/* Set a known default SACCH filling for SI5 */
var octetstring si5 := f_rnd_octstring(19);
var octetstring si5_diff := f_rnd_octstring(19);
RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
f_l1_tune(L1CTL);
RSL.clear;
log("Activating channel, expecting standard SI5");
/* activate the logical channel */
f_est_dchan();
/* check that the specified SI5 value is actually sent */
f_sacch_present(si5);
/* set channel-specific different SI5 */
log("Setting channel specific SACCH INFO, expecting it");
RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff))
/* check that the specified lchan-specific value is now used */
f_sacch_present(si5_diff);
/* deactivate the channel and re-activate it, this should result in default SI5 */
log("De-activating and re-activating channel, expecting standard SI5");
f_rsl_chan_deact();
f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN));
/* Verify that the TRX-wide default SACCH filling is present again */
f_sacch_present(si5);
/* release the channel */
RSL.clear;
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
}
testcase TC_sacch_info_mod() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
log(testcasename(), ": Starting for ", g_AllChannels[i]);
vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars);
vc_conn.done;
}
/* TODO: do the above in parallel, rather than sequentially? */
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* Test SACCH scheduling of multiple different SI message types */
private function f_TC_sacch_multi(charstring id) runs on ConnHdlr {
var octetstring si5 := f_rnd_octstring(19);
var octetstring si5bis := f_rnd_octstring(19);
var octetstring si5ter := f_rnd_octstring(19);
var octetstring si6 := f_rnd_octstring(19);
RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis));
RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter));
RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
f_l1_tune(L1CTL);
RSL.clear;
/* activate the logical channel */
f_est_dchan();
L1CTL.clear;
/* check that SACCH actually are received as expected */
f_sacch_present(si5);
f_sacch_present(si5bis);
f_sacch_present(si5ter);
f_sacch_present(si6);
/* release the channel */
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
}
testcase TC_sacch_multi() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
log(testcasename(), ": Starting for ", g_AllChannels[i]);
vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars);
vc_conn.done;
}
/* TODO: do the above in parallel, rather than sequentially? */
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* Test if SACH information is modified as expected */
private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr {
var octetstring si5 := f_rnd_octstring(19);
var octetstring si6 := f_rnd_octstring(19);
/* First, configure both SI5 and SI6 to be transmitted */
RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
f_l1_tune(L1CTL);
RSL.clear;
/* activate the logical channel */
f_est_dchan();
L1CTL.clear;
/* check that SACCH actually are received as expected */
f_sacch_present(si5);
f_sacch_present(si6);
/* disable SI6 */
RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O));
/* check that SI5 is still transmitted */
f_sacch_present(si5);
/* check if SI6 is now gone */
f_sacch_missing(si6);
/* release the channel */
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
}
testcase TC_sacch_multi_chg() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
log(testcasename(), ": Starting for ", g_AllChannels[i]);
vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars);
vc_conn.done;
}
/* TODO: do the above in parallel, rather than sequentially? */
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */
private function f_TC_sacch_chan_act(charstring id) runs on ConnHdlr {
var octetstring si5 := f_rnd_octstring(19);
var octetstring si6 := f_rnd_octstring(19);
var octetstring si5_specific := f_rnd_octstring(19);
var octetstring si6_specific := f_rnd_octstring(19);
/* First, configure both SI5 and SI6 to be transmitted */
RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6));
f_l1_tune(L1CTL);
RSL.clear;
/* activate channel with different SACCH filling */
var RSL_SacchInfo sacch_info := valueof(ts_RSL_SacchInfo({
ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_5, si5_specific),
ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_6, si6_specific)
}));
var RSL_IE_List addl_ies := { valueof(t_RSL_IE(RSL_IE_SACCH_INFO,
RSL_IE_Body:{sacch_info := sacch_info})) };
f_est_dchan(more_ies := addl_ies);
/* check that SACCH actually are received as expected */
f_sacch_present(si5_specific);
f_sacch_present(si6_specific);
/* release the channel */
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
}
testcase TC_sacch_chan_act() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
log(testcasename(), ": Starting for ", g_AllChannels[i]);
vc_conn := f_start_handler(refers(f_TC_sacch_chan_act), pars);
vc_conn.done;
}
/* TODO: do the above in parallel, rather than sequentially? */
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* verify that SACCH DL transmission is started only if MS power IE present
* see section 4.1.3 of 3GPP TS 48.058 */
private function f_TC_sacch_chan_act_ho_async(charstring id) runs on ConnHdlr {
var octetstring si5 := f_rnd_octstring(19);
RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
f_l1_tune(L1CTL);
RSL.clear;
/* Step 1: Activate ASYNC HO channel without MS power IE */
var integer ho_ref := oct2int(f_rnd_octstring(1));
var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF,
RSL_IE_Body:{ handover_ref := ho_ref }));
var RSL_IE_List addl_ies := {
ho_ref_ie
};
/* Activate channel on BTS side */
f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC);
/* don't perform immediate assignment here, as we're testing non-IA case */
/* enable dedicated mode */
f_l1ctl_est_dchan(L1CTL, g_pars);
/* Verify that no DL SACCH is being received */
f_sacch_missing(?);
/* Send handover Access Burst and expect SACCH to start */
f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
f_sacch_present(si5);
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
/* Step 2: Activate ASYNC HO channel with MS power IE */
/* Activate channel on BTS side */
addl_ies := {
ho_ref_ie,
valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
};
f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC);
/* don't perform immediate assignment here, as we're testing non-IA case */
/* enable dedicated mode */
f_l1ctl_est_dchan(L1CTL, g_pars);
/* Verify that DL SACCH is being received */
f_sacch_present(si5);
/* Send handover Access Burst and expect SACCH to remain present */
f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
f_sacch_present(si5);
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
}
testcase TC_sacch_chan_act_ho_async() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
log(testcasename(), ": Starting for ", g_AllChannels[i]);
vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_async), pars);
vc_conn.done;
}
/* TODO: do the above in parallel, rather than sequentially? */
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* verify that SACCH DL transmission is started only if TA + MS power IEs present,
* see section 4.1.4 of 3GPP TS 48.058 */
private function f_TC_sacch_chan_act_ho_sync(charstring id) runs on ConnHdlr {
var octetstring si5 := f_rnd_octstring(19);
RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5));
var RSL_IE_List addl_ies;
f_l1_tune(L1CTL);
RSL.clear;
/* Step 1: Activate SYNC HO channel without MS power IE */
var integer ho_ref := oct2int(f_rnd_octstring(1));
var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF,
RSL_IE_Body:{ handover_ref := ho_ref }));
addl_ies := {
ho_ref_ie
};
/* Activate channel on BTS side */
f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
/* don't perform immediate assignment here, as we're testing non-IA case */
/* enable dedicated mode */
f_l1ctl_est_dchan(L1CTL, g_pars);
/* Verify that no DL SACCH is being received */
f_sacch_missing(?);
/* Send handover Access Burst and expect SACCH to start */
f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
f_sacch_present(si5);
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
/* Step 2a: Activate SYNC HO channel with only MS power IE */
/* Activate channel on BTS side */
addl_ies := {
ho_ref_ie,
valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
};
f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
/* don't perform immediate assignment here, as we're testing non-IA case */
/* enable dedicated mode */
f_l1ctl_est_dchan(L1CTL, g_pars);
/* Verify that DL SACCH is being received, because MS Power IE was sent */
f_sacch_present(si5);
/* Send handover Access Burst and expect SACCH to remain present */
f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
f_sacch_present(si5);
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
/* Step 2b: Activate SYNC HO channel with TA IE */
/* Activate channel on BTS side */
addl_ies := {
ho_ref_ie,
valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0}))
};
f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
/* don't perform immediate assignment here, as we're testing non-IA case */
/* enable dedicated mode */
f_l1ctl_est_dchan(L1CTL, g_pars);
/* Verify that no DL SACCH is being received */
f_sacch_missing(?);
/* Send handover Access Burst and expect SACCH to start */
f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
f_sacch_present(si5);
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
/* Step 3: Activate SYNC HO channel with MS power IE and TA IE */
/* Activate channel on BTS side */
addl_ies := {
ho_ref_ie,
valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})),
valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)}))
};
f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC);
/* don't perform immediate assignment here, as we're testing non-IA case */
/* enable dedicated mode */
f_l1ctl_est_dchan(L1CTL, g_pars);
/* Verify that DL SACCH is being received */
f_sacch_present(si5);
/* Send handover Access Burst and expect SACCH to remain present */
f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
f_sacch_present(si5);
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
}
testcase TC_sacch_chan_act_ho_sync() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) {
pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
log(testcasename(), ": Starting for ", g_AllChannels[i]);
vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_sync), pars);
vc_conn.done;
}
/* TODO: do the above in parallel, rather than sequentially? */
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/***********************************************************************
* RACH Handling
***********************************************************************/
/* Send 1000 RACH requests and check their RA+FN on the RSL side */
private function f_TC_rach_content(boolean emerg) runs on test_CT {
f_init();
f_init_l1ctl();
f_l1_tune(L1CTL);
var GsmFrameNumber fn_last := 0;
var boolean test_failed := false;
for (var integer i := 0; i < 1000; i := i+1) {
var OCT1 ra;
if (emerg == true) {
ra := f_rnd_ra_emerg();
} else {
ra := f_rnd_ra_cs();
}
var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
if (fn == fn_last) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
}
fn_last := fn;
timer T := 5.0;
T.start;
alt {
[] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(ra, fn, t_RslChanNr_RACH(0)))) {
T.stop;
}
[] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?, ?))) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD");
}
[] RSL_CCHAN.receive { repeat; }
[] T.timeout {
test_failed := true;
log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra);
}
}
}
if (test_failed) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Some out of 1000 RACH requests timed out"));
}
setverdict(pass);
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* Normal variant */
testcase TC_rach_content() runs on test_CT {
f_TC_rach_content(emerg := false);
}
/* Emergency call variant */
testcase TC_rach_content_emerg() runs on test_CT {
f_TC_rach_content(emerg := true);
}
/* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */
testcase TC_rach_count() runs on test_CT {
f_init();
f_init_l1ctl();
f_sleep(1.0);
f_l1_tune(L1CTL);
var GsmFrameNumber fn_last := 0;
for (var integer i := 0; i < 1000; i := i+1) {
var OCT1 ra := f_rnd_ra_cs();
var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
if (fn == fn_last) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
}
fn_last := fn;
}
var integer rsl_chrqd := 0;
timer T := 3.0;
T.start;
alt {
[] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?,?))) {
rsl_chrqd := rsl_chrqd + 1;
f_timer_safe_restart(T);
repeat;
}
[] RSL_CCHAN.receive { repeat; }
[] T.timeout { }
}
if (rsl_chrqd == 1000) {
setverdict(pass);
} else {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received only ", rsl_chrqd, " out of 1000 RACH"));
}
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
private function f_vty_load_ind_thresh(integer period := 10, integer bts_nr := 0) runs on test_CT {
var charstring bts_str := "bts " & int2str(bts_nr);
f_vty_config2(BSCVTY, {"network", bts_str}, "ccch load-indication-threshold " & int2str(period));
}
/* empirical value: Number of RACH slots per reporting interval (1s) on combined CCCH */
private template integer tr_rach_slots_per_interval := (90 .. 130);
/* Expect 0 RACH load on an idle BTS that has just started up */
testcase TC_rach_load_idle_thresh0() runs on test_CT {
var ASP_RSL_Unitdata rx_ud;
f_init_vty_bsc();
/* send load indications even at 0% load */
f_vty_load_ind_thresh(0);
f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
f_sleep(2.0);
f_init();
/* Skip the first RACH LOAD IND, as it may not have the full slot count (BTS started less than 1s before) */
alt {
[] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) { }
[] RSL_CCHAN.receive { repeat }
}
timer T := 5.0;
T.start;
alt {
[] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, 0, 0))) {
setverdict(pass);
repeat;
}
[] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
repeat;
}
[] RSL_CCHAN.receive {
repeat;
}
[] T.timeout { }
}
f_vty_load_ind_thresh(10);
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* Expect no RACH load indications on an idle BTS that has just started up (default threshold 10%) */
testcase TC_rach_load_idle_below_thresh() runs on test_CT {
var ASP_RSL_Unitdata rx_ud;
f_init_vty_bsc();
f_init();
timer T := 5.0;
T.start;
alt {
[] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
repeat;
}
[] RSL_CCHAN.receive {
repeat;
}
[] T.timeout {
setverdict(pass);
}
}
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* Expect 0 RACH load on an idle BTS that has just started up */
testcase TC_rach_load_count() runs on test_CT {
var ASP_RSL_Unitdata rx_ud;
var integer load_access_count := 0;
f_init_vty_bsc();
/* send load indications even at 0% load */
f_vty_load_ind_thresh(0);
f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
f_sleep(2.0);
f_init();
f_init_l1ctl();
f_sleep(1.0);
f_l1_tune(L1CTL);
/* Skip the first RACH LOAD IND, as it may not have the full slot count (BTS started less than 1s before) */
alt {
[] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) { }
[] RSL_CCHAN.receive { repeat }
}
var GsmFrameNumber fn_last := 0;
for (var integer i := 0; i < 1000; i := i+1) {
var OCT1 ra := f_rnd_ra_cs();
var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
if (fn == fn_last) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?");
}
fn_last := fn;
}
timer T := 5.0;
T.start;
alt {
[] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, ?, ?)))
-> value rx_ud {
var RSL_IE_Body ie;
f_rsl_find_ie(rx_ud.rsl, RSL_IE_RACH_LOAD, ie);
load_access_count := load_access_count + ie.rach_load.access_count;
if (ie.rach_load.busy_count < ie.rach_load.access_count) {
setverdict(fail, "Access count cannot be < Busy count");
}
repeat;
}
[] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud {
setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud);
repeat;
}
[] RSL_CCHAN.receive {
repeat;
}
[] T.timeout { }
}
if (load_access_count == 1000) {
setverdict(pass);
} else {
setverdict(fail, "Load reports state ", load_access_count, " RACH, but we sent 1000");
}
f_vty_load_ind_thresh(10);
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
private function f_rach_toffs(int16_t toffs256, boolean expect_pass) runs on test_CT {
var TrxcMessage ret;
/* tell fake_trx to use a given timing offset for all bursts */
ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256)));
f_sleep(0.5);
/* Transmit RACH request + wait for confirmation */
var OCT1 ra := f_rnd_ra_cs();
var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra));
/* Check for expected result */
timer T := 1.5;
T.start;
alt {
[expect_pass] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
setverdict(pass);
}
[not expect_pass] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("RACH passed but was expected to be dropped: ", toffs256));
}
[] RSL_CCHAN.receive { repeat; }
[not expect_pass] T.timeout {
setverdict(pass);
}
[expect_pass] T.timeout {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN RQD: FN=", fn, " RA=", ra));
}
}
}
/* Test if dropping of RACH Based on NM_ATT_MAX_TA works */
testcase TC_rach_max_ta() runs on test_CT {
f_init();
f_init_l1ctl();
f_l1_tune(L1CTL);
f_sleep(1.0);
/* default max-ta is 63 (full range of GSM timing advance */
/* We allow early arrival up to 2 symbols */
f_rach_toffs(-1*256, true);
f_rach_toffs(-2*256, true);
f_rach_toffs(-10*256, false);
/* 0 / 32 / 63 bits is legal / permitted */
f_rach_toffs(0, true);
f_rach_toffs(32*256, true);
f_rach_toffs(63*256, true);
/* more than 63 bits is not legal / permitted */
f_rach_toffs(64*256, false);
f_rach_toffs(127*256, false);
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
private function f_TC_ho_rach(charstring id) runs on ConnHdlr {
var GsmFrameNumber fn;
var RSL_Message rm;
f_l1_tune(L1CTL);
RSL.clear;
/* Generate a random Handover Reference */
var integer ho_ref := oct2int(f_rnd_octstring(1));
/* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */
var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF,
RSL_IE_Body:{ handover_ref := ho_ref }));
/* Activate a channel on the BTS side (no encryption) */
f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie },
act_type := t_RSL_IE_ActType_HO_SYNC);
/* Switch the MS side (e.g. trxcon) to a dedicated channel without
* waiting for Immediate Assignment and sending Access Burst */
f_l1ctl_est_dchan(L1CTL, g_pars);
/* Send handover Access Burst */
fn := f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr);
/* TODO: test mismatching Handover Reference, and missing IE */
/* Wait for handover detection */
timer T := 3.0;
T.start;
alt {
[] RSL.receive(tr_RSL_HANDO_DET(g_pars.chan_nr)) -> value rm {
log("Handover RACH has been detected: ", rm);
setverdict(pass);
}
[] RSL.receive(tr_RSL_CHAN_RQD(?, ?, ?, ?)) -> value rm {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
log2str("RSL_CHAN_RQD was not expected: ", rm));
}
[] RSL.receive { repeat; }
[] T.timeout {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
log2str("Timeout waiting for handover RACH: FN=", fn, " RA=", ho_ref));
}
}
/* Release the channel */
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
}
/* Test handover RACH detection */
testcase TC_ho_rach() runs on test_CT {
var ConnHdlrPars pars;
var ConnHdlr vc_conn;
f_init();
for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) {
pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN));
log(testcasename(), ": Starting for ", g_AllChannels[i]);
vc_conn := f_start_handler(refers(f_TC_ho_rach), pars);
vc_conn.done;
}
/* TODO: do the above in parallel, rather than sequentially? */
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/***********************************************************************
* Measurement Processing / Reporting
***********************************************************************/
private template (value) LapdmAddressField
ts_LapdmAddr(template (value) LapdmSapi sapi,
template (value) boolean c_r) := {
spare := '0'B,
lpd := 0,
sapi := sapi,
c_r := c_r,
ea := true
}
private template (value) LapdmFrameAB
ts_LAPDm_AB(template (value) LapdmSapi sapi,
template (value) GsmRrL3Message l3,
template (value) boolean c_r := false,
template (value) boolean p := false) := {
addr := ts_LapdmAddr(sapi, c_r),
ctrl := ts_LapdmCtrlUI(valueof(p)),
len := 0, /* overwritten */
m := false,
el := 1,
payload := enc_GsmRrL3Message(valueof(l3))
}
/* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */
private altstep as_l1_sacch() runs on ConnHdlr {
var template (value) LapdmFrameAB lb;
var L1ctlDlMessage l1_dl;
[] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
log("SACCH received: ", l1_dl.payload.data_ind.payload);
lb := ts_LAPDm_AB(0, ts_MEAS_REP(true, mp_rxlev_exp, mp_rxlev_exp));
log("LAPDm: ", lb);
var template (value) SacchL1Header l1h := ts_SacchL1Header(
g_pars.l1_pars.ms_power_level, false,
g_pars.l1_pars.ms_actual_ta);
/* TODO: we can use an extension of TTCN-3 for that, i.e. PADDING('2B'O) */
var octetstring l2 := f_pad_oct(enc_LapdmFrameAB(valueof(lb)), 21, '2B'O);
log("Sending Measurement Report: ", l1h, l2);
L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, ts_RslLinkID_SACCH(0), l1h, l2));
repeat;
}
}
/* handle incoming downlink SACCH, decode the L1 header into the given record */
private altstep as_l1_sacch_l1h(inout SacchL1Header l1h,
boolean do_apply := true)
runs on ConnHdlr
{
var L1ctlDlMessage l1_dl;
[] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
/* Parse the L1 SACCH header (MS Power Level & Timing Advance) */
l1h := dec_SacchL1Header(substr(l1_dl.payload.data_ind.payload, 0, 2));
log(%definitionId, "(): Rx SACCH L1 header: ", l1h);
if (do_apply) {
/* Update TA and MS power to follow what BTS requests */
f_L1CTL_PARAM(L1CTL, l1h.actual_ta, l1h.ms_power_lvl);
}
}
}
private altstep as_l1_dcch_loop() runs on ConnHdlr {
var L1ctlDlMessage l1_dl;
[] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value l1_dl {
log("DCCH received: ", l1_dl.payload.data_ind.payload);
var octetstring pl := '010301'O;
L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0),
f_pad_oct(pl, 23, '2B'O)));
repeat;
}
}
private altstep as_l1_tch_loop() runs on ConnHdlr {
var L1ctlDlMessage l1_dl;
[] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(g_chan_nr)) -> value l1_dl {
log("TCH received: ", l1_dl.payload.traffic_ind.data);
/* occasionaly inject FACCH frames into the uplink */
if (g_pars.l1_pars.facch_enabled == true and l1_dl.dl_info.frame_nr mod 5 == 0) {
var octetstring pl := '010301'O;
L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0),
f_pad_oct(pl, 23, '2B'O)));
} else {
L1CTL.send(ts_L1CTL_TRAFFIC_REQ(g_chan_nr, l1_dl.dl_info.link_id,
l1_dl.payload.traffic_ind.data));
}
repeat;
}
}
private type record MeasElem {
uint6_t rxlev,
uint3_t rxqual
}
private type record MeasElemFS {
MeasElem full,
MeasElem sub
}
private type record ConnL1Pars {
boolean dtx_enabled,
boolean toa256_enabled,
MeasElemFS meas_ul,
int16_t timing_offset_256syms,
uint4_t bs_power_level,
uint5_t ms_power_level,
uint8_t ms_actual_ta,
boolean facch_enabled
}
/* Convert tiing offset from 1/256th symbol to RSL Timing Offset */
private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t {
return 63 + (toffs256s/256);
}
private function f_max(integer a, integer b) return integer {
if (a > b) {
return a;
} else {
return b;
}
}
private function f_min(integer a, integer b) return integer {
if (a < b) {
return a;
} else {
return b;
}
}
/* compute negative tolerance val-tolerance, ensure >= min */
private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer {
val := val - tolerance;
return f_max(val, min);
}
/* compute positive tolerance val+tolerance, ensure <= max */
private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer {
val := val + tolerance;
return f_min(val, max);
}
/* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */
private function f_tolerance(integer val, integer min, integer max, integer tolerance)
return template integer {
var template integer ret;
ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance));
return ret;
}
/* build a template for matching measurement results against */
private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message {
var ConnL1Pars l1p := g_pars.l1_pars;
var template RSL_IE_UplinkMeas ul_meas := {
len := 3,
rfu := '0'B,
dtx_d := l1p.dtx_enabled,
rxlev_f_u := f_tolerance(l1p.meas_ul.full.rxlev, 0, 63, mp_tolerance_rxlev),
reserved1 := '00'B,
rxlev_s_u := f_tolerance(l1p.meas_ul.sub.rxlev, 0, 63, mp_tolerance_rxlev),
reserved2 := '00'B,
rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual),
rxq_s_u := f_tolerance(l1p.meas_ul.sub.rxqual, 0, 7, mp_tolerance_rxqual),
supp_meas_info := omit
};
if (l1p.toa256_enabled) {
ul_meas.len := (3+8);
ul_meas.supp_meas_info := {
toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms),
toa256_min := ?,
toa256_max := ?,
toa256_std_dev := ?
}
}
var template RSL_IE_BS_Power bs_power := {
reserved := 0,
epc := false,
fpc := false,
power_level := l1p.bs_power_level
};
var template RSL_IE_L1Info l1_info := {
ms_power_lvl := l1p.ms_power_level,
fpc := false,
reserved := 0,
actual_ta := f_tolerance(l1p.ms_actual_ta, 0, 63, mp_tolerance_timing_offset_256syms/256)
};
var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms);
var template uint8_t t_toffs := f_tolerance(offs, 0, 255, mp_tolerance_timing_offset_256syms/256);
return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info,
?, t_toffs);
}
/* build a template for matching measurement results that do not contain any
* MS related measurement (l1_info, l3_info and ms timing offset). */
private function f_build_meas_res_tmpl_empty() runs on ConnHdlr return template RSL_Message {
var ConnL1Pars l1p := g_pars.l1_pars;
var template RSL_IE_UplinkMeas ul_meas := {
len := 3,
rfu := '0'B,
dtx_d := l1p.dtx_enabled,
rxlev_f_u := ?,
reserved1 := '00'B,
rxlev_s_u := ?,
reserved2 := '00'B,
rxq_f_u := ?,
rxq_s_u := ?,
supp_meas_info := omit
};
if (l1p.toa256_enabled) {
ul_meas.len := (3+8);
ul_meas.supp_meas_info := {
toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms),
toa256_min := ?,
toa256_max := ?,
toa256_std_dev := ?
}
}
var template RSL_IE_BS_Power bs_power := {
reserved := 0,
epc := false,
fpc := false,
power_level := l1p.bs_power_level
};
return tr_RSL_MEAS_RES_EMPTY(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power);
}
/* verify we regularly receive measurement reports with incrementing numbers */
private altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr {
var RSL_Message rsl;
var boolean chan_est := false;
[not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; }
/* Receive osmocom specific measurement reports. This is the normal
* case. Here we verify that the measurement reports we sent are
* comming back as we expect them. */
[] RSL.receive(f_build_meas_res_tmpl()) -> value rsl {
/* increment counter of next to-be-expected meas rep */
g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
/* Re-start the timer expecting the next MEAS RES */
f_timer_safe_restart(g_Tmeas_exp);
/* The following two cases may only happen in the beginning
* of the channel establishment phase. Once we have received
* the "our" measurement report the first time, the channel
* is established and empty or hardcoded TRXCON reports must
* not occur anymore. */
chan_est := true;
repeat;
}
/* When the BTS has established the channel, the MS might need slightly
* more time to establish the channel and actually start sending. The
* result is then a measurement report that just lacks the measurement
* information of the MS. This is normal and we tolerate this behavior. */
[chan_est == false] RSL.receive(f_build_meas_res_tmpl_empty()) -> value rsl {
/* increment counter of next to-be-expected meas rep */
g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
/* Re-start the timer expecting the next MEAS RES */
f_timer_safe_restart(g_Tmeas_exp);
repeat;
}
/* Due to the TDMA nature of GSM, TRXCON implements a way to emit dummy
* measurements if the TTCN3 side does not supply measurement input in
* time. In those cases TRXCON will either use a cached measurement
* report or a hardcoded one. If TRXCON picks the hardcoded measurement
* report the templates above will not match. We tolerate this
* behavior, but only once. */
[chan_est == false] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, g_next_meas_res_nr)) -> value rsl {
/* increment counter of next to-be-expected meas rep */
g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256;
if (g_first_meas_res) {
g_first_meas_res := false;
repeat;
} else {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unspecific MEAS RES ", rsl));
}
}
[] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected MEAS RES ", rsl));
}
[g_Tmeas_exp.running] g_Tmeas_exp.timeout {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Didn't receive expected measurement result")
}
}
private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t {
select (rsl_alg_id) {
case (RSL_ALG_ID_A5_0) { return 0; }
case (RSL_ALG_ID_A5_1) { return 1; }
case (RSL_ALG_ID_A5_2) { return 2; }
case (RSL_ALG_ID_A5_3) { return 3; }
case (RSL_ALG_ID_A5_4) { return 4; }
case (RSL_ALG_ID_A5_5) { return 5; }
case (RSL_ALG_ID_A5_6) { return 6; }
case (RSL_ALG_ID_A5_7) { return 7; }
case else {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID");
/* Make compiler happy by calling mtc.stop here. It is already
* called in f_shutdown */
mtc.stop;
}
}
}
private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 {
select (rsl_alg_id) {
case (RSL_ALG_ID_A5_1) { return '000'B; }
case (RSL_ALG_ID_A5_2) { return '001'B; }
case (RSL_ALG_ID_A5_3) { return '010'B; }
case (RSL_ALG_ID_A5_4) { return '011'B; }
case (RSL_ALG_ID_A5_5) { return '100'B; }
case (RSL_ALG_ID_A5_6) { return '101'B; }
case (RSL_ALG_ID_A5_7) { return '110'B; }
case else {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID");
/* Make compiler happy by calling mtc.stop here. It is already
* called in f_shutdown */
mtc.stop;
}
}
}
/* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */
private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber {
var GsmFrameNumber fn;
timer T := 8.0;
/* advertise to RSL Emulation that we expect to receive confirmation from RACH */
RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1)));
f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level);
/* Send the actual RACH */
fn := f_L1CTL_RACH(L1CTL, ra);
T.start;
alt {
[] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") }
[] T.timeout {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">"));
}
}
T.stop
return fn;
}
/* Tune to a dedicated channel: L1CTL only */
private function f_l1ctl_est_dchan(L1CTL_PT pt, ConnHdlrPars pars) {
if (not pars.fhp.enabled) {
pt.send(ts_L1CTL_DM_EST_REQ_H0(pars.chan_nr, pars.tsc,
mp_trx_pars[0].arfcn));
} else {
pt.send(ts_L1CTL_DM_EST_REQ_H1(pars.chan_nr, pars.tsc,
pars.fhp.maio_hsn.hsn,
pars.fhp.maio_hsn.maio,
pars.fhp.ma));
}
}
/* Establish dedicated channel: L1CTL + RSL side */
private function f_est_dchan(boolean encr_enable := false, RSL_IE_List more_ies := {}) runs on ConnHdlr {
var GsmFrameNumber fn;
var ImmediateAssignment imm_ass;
var ChannelDescription ch_desc;
var integer ra := 23;
/* Send RACH request and wait for ChanReq */
fn := f_rach_req_wait_chan_rqd(ra);
/* Activate channel on BTS side */
f_rsl_chan_act(g_pars.chan_mode, encr_enable, more_ies);
/* Craft channel description (with or without frequency hopping parameters) */
if (g_pars.fhp.enabled) {
ch_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, g_pars.fhp.maio_hsn, g_pars.tsc));
} else {
ch_desc := valueof(ts_ChanDescH0(g_pars.chan_nr, mp_trx_pars[0].arfcn, g_pars.tsc));
}
/* Send IMM.ASS via CCHAN */
var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, g_pars.fhp.ma_map));
RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg)));
/* receive IMM.ASS on MS side */
var ImmediateAssignment ia_um;
ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn);
/* Make sure that IMM.ASS contains hopping parameters (if enabled) */
if (ch_desc.h != ia_um.chan_desc.h) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Hopping parameters mismatch");
}
/* enable dedicated mode */
f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um, ma := g_pars.fhp.ma);
/* enable encryption, if requested */
if (encr_enable) {
var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id);
f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key);
}
/* Send TCH Mode Request to the L1 if needed */
if (match(g_pars.chan_mode.spd_ind, (RSL_SPDI_SPEECH, RSL_SPDI_DATA))) {
var L1ctlTchMode tch_mode;
select (g_pars.chan_mode.coding_alg_rate) {
case (RSL_CMOD_NO_RESOURCE) { tch_mode := L1CTL_CHAN_MODE_SIGN; }
case (RSL_CMOD_SP_GSM1) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V1; }
case (RSL_CMOD_SP_GSM2) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V2; }
case (RSL_CMOD_SP_GSM3) { tch_mode := L1CTL_CHAN_MODE_SPEECH_V3; }
case else {
log("RSL channel mode := ", g_pars.chan_mode.coding_alg_rate,
" is not supported by the L1, falling back to signalling");
tch_mode := L1CTL_CHAN_MODE_SIGN;
}
}
f_L1CTL_TCH_MODE(L1CTL, tch_mode);
}
g_first_meas_res := true;
}
/* establish DChan, verify existance + contents of measurement reports */
private function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr {
f_l1_tune(L1CTL);
RSL.clear;
if (mp_bts_trxc_port != -1) {
f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
}
f_est_dchan();
/* run for a number of seconds, send SACCH + FACCH from MS side and verify
* RSL measurement reports on Abis side */
timer T := 8.0;
T.start;
alt {
[] as_l1_sacch();
[] as_meas_res();
[] as_l1_dcch_loop();
[] as_l1_tch_loop();
[] L1CTL.receive { repeat; }
[g_Tmeas_exp.running] T.timeout {
/* as_meas_res() would have done Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail) in case
* of any earlier errors, so if we reach this timeout, we're good */
setverdict(pass);
}
[] T.timeout {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all");
}
}
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
}
/* Wait until the BTS has reached full tx power (nominal tx power minus configured attenuation) */
private function f_wait_ramp_up() runs on ConnHdlr return integer {
var L1ctlDlMessage l1_dl;
var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp;
timer Tup := 10.0;
Tup.start;
alt {
[] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level;
log("Received rx_level=", rx_lvl);
if (rx_lvl != max_rx_lvl) {
repeat;
}
Tup.stop;
}
[] L1CTL.receive { repeat; }
[] Tup.timeout {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
log2str("Didn't reach full power ", max_rx_lvl));
}
}
return max_rx_lvl;
}
/* verify BTS ramps power up to full tx power (nominal tx power minus configured attenuation) */
private function f_verify_ramp_up() runs on ConnHdlr {
var L1ctlDlMessage l1_dl;
var integer initial_rx_lvl := -1;
var integer last_rx_lvl := -1;
var integer max_rx_lvl := mp_bts_tx_nom_pwr_exp - mp_bts_tx_pwr_att_exp;
timer T := 2.0;
alt {
[] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level;
log("Received rx_level=", rx_lvl);
if (initial_rx_lvl == -1) {
initial_rx_lvl := rx_lvl;
last_rx_lvl := rx_lvl;
/* Expect a somehow low value during first received messages */
if (initial_rx_lvl >= max_rx_lvl / 2) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
log2str("Detected high initial tx power during ramp up: ",
initial_rx_lvl , ", full power is", max_rx_lvl));
}
}
/* received Rx level bigger than maximum allowed power by CN */
if (rx_lvl > max_rx_lvl) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
log2str("Detected Tx power higher than full power: ",
rx_lvl , " > ", max_rx_lvl));
}
/* Make sure it never decreases, since we are rumping up */
if (last_rx_lvl > rx_lvl) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
log2str("Detected Tx power decrease during ramp up: ",
last_rx_lvl , " -> ", rx_lvl));
}
if (rx_lvl == max_rx_lvl and not T.running) {
/* We reached the maximum power, start timer and receive
/* a few more to make sure we don't surpass it */
log("Reached full power, wating a bit more until success");
T.start;
}
last_rx_lvl := rx_lvl;
repeat;
}
[] L1CTL.receive { repeat; }
[] T.timeout { }
}
/* We didn't increase tx power during ramp up */
if (initial_rx_lvl < last_rx_lvl) {
log("Tx power increased during ramp up: ", initial_rx_lvl , " -> ", last_rx_lvl);
} else {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
log2str("No Tx power increase during whole ramp up: ",
initial_rx_lvl , " -> ", last_rx_lvl));
}
}
/* verify BTS ramps power down to rx_level 0 */
private function f_verify_ramp_down(integer max_rx_lvl) runs on ConnHdlr {
var L1ctlDlMessage l1_dl;
var integer last_rx_lvl := max_rx_lvl;
timer Tdown := 5.0;
Tdown.start;
alt {
[] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
var GsmRxLev rx_lvl := l1_dl.dl_info.rx_level;
log("Received rx_level=", rx_lvl);
/* received Rx level bigger than maximum allowed power by CN */
if (rx_lvl > max_rx_lvl) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
log2str("Detected Tx power higher than full power: ",
rx_lvl , " > ", max_rx_lvl));
}
/* Make sure it never increases, since we are rumping down */
if (last_rx_lvl < rx_lvl) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
log2str("Detected Tx power increase during ramp up: ",
last_rx_lvl , " -> ", rx_lvl));
}
last_rx_lvl := rx_lvl;
if (last_rx_lvl != 0) {
repeat;
}
/* we reached power level 0, we are done */
Tdown.stop;
}
[] L1CTL.receive { repeat; }
[] Tdown.timeout { }
}
/* We didn't increase tx power during ramp down */
if (max_rx_lvl > last_rx_lvl) {
log("Tx power decreased during ramp down: ", max_rx_lvl , " -> ", last_rx_lvl);
} else {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
log2str("No Tx power decrease during whole ramp down: ",
max_rx_lvl , " -> ", last_rx_lvl));
}
}
/* Verify Tx power reduction and ramping up during BTS bring up */
private function f_TC_tx_power_start_ramp_up_bcch(charstring id) runs on ConnHdlr {
f_l1_tune(L1CTL);
RSL.clear;
f_verify_ramp_up();
setverdict(pass);
}
testcase TC_tx_power_start_ramp_up_bcch() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN));
vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_up_bcch), pars,
pcu_comp := false, trxc_comp := true);
vc_conn.done;
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* Verify Tx power reduction and ramping downd uring BTS bring shutdown due to Abis link failure */
private function f_TC_tx_power_start_ramp_down_bcch(charstring id) runs on ConnHdlr {
f_connhdlr_init_vty_bsc();
f_l1_tune(L1CTL);
RSL.clear;
/* Wait until BTS is started and at full power */
var integer max_rx_lvl := f_wait_ramp_up();
log("Reached nominal level ", max_rx_lvl, ", shutting down OML link");
f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
f_verify_ramp_down(max_rx_lvl);
setverdict(pass);
}
testcase TC_tx_power_start_ramp_down_bcch() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN));
vc_conn := f_start_handler(refers(f_TC_tx_power_start_ramp_down_bcch), pars,
pcu_comp := false, trxc_comp := true);
vc_conn.done;
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* Verify Tx power:
* + ramping down during ADM state UNLOCKED->LOCKED
* + ramping up during ADM state LOCKED->UNLOCKED
*/
private function f_TC_tx_power_ramp_adm_state_change(charstring id) runs on ConnHdlr {
var L1ctlDlMessage l1_dl;
var integer last_rx_lvl;
f_connhdlr_init_vty_bsc();
f_l1_tune(L1CTL);
RSL.clear;
/* Wait until BTS is started and at full power */
var integer max_rx_lvl := f_wait_ramp_up();
log("Reached nominal level ", max_rx_lvl, ", changing ADM state to LOCKED");
log("ADM STATE UNLOCKED->LOCKED");
f_vty_enter_cfg_trx(BSCVTY);
f_vty_transceive(BSCVTY, "rf_locked 1");
last_rx_lvl := max_rx_lvl;
f_verify_ramp_down(max_rx_lvl);
/* Let some time after we received 0dBm, then check we don't receive BCCH
* anymore because scheduler has stopped after ramping down */
f_sleep(2.0);
L1CTL.clear;
timer Tlocked := 2.0;
Tlocked.start;
alt {
[] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
log2str("Received data_ind during rf_locked: ", l1_dl));
}
[] L1CTL.receive { repeat; }
[] Tlocked.timeout { setverdict(pass, "Didn't receive data_ind while in rf_locked state."); }
}
log("ADM STATE LOCKED->UNLOCKED");
f_vty_transceive(BSCVTY, "rf_locked 0");
f_verify_ramp_up();
setverdict(pass);
}
testcase TC_tx_power_ramp_adm_state_change() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
pars := valueof(t_Pars(t_RslChanNr_Bm(0), ts_RSL_ChanMode_SIGN));
vc_conn := f_start_handler(refers(f_TC_tx_power_ramp_adm_state_change), pars,
pcu_comp := false, trxc_comp := true);
vc_conn.done;
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
private function f_check_meas_bs_power_level(integer level) runs on ConnHdlr {
timer T := 8.0;
T.start;
var RSL_Message rsl;
alt {
[] as_l1_sacch();
[] L1CTL.receive { repeat; }
[] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, ?, ?, ?)) -> value rsl {
if (rsl.ies[3].body.bs_power.power_level == level) {
setverdict(pass)
} else {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received wrong BS power level in MEAS RES ", rsl));
}
}
[] T.timeout {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all");
}
}
}
/* see if the rsl meas res contains our expeced bs power level
bs power set during assignment */
private function f_TC_rsl_bs_pwr_static_ass(charstring id) runs on ConnHdlr {
f_l1_tune(L1CTL);
RSL.clear;
if (mp_bts_trxc_port != -1) {
f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
}
var uint4_t pwr_var := 1;
var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var);
var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_BS_POWER, RSL_IE_Body:{bs_power := bs_power});
f_est_dchan(more_ies :={valueof(pwr)});
f_check_meas_bs_power_level(pwr_var);
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
}
/* see if the rsl meas res contains our expeced bs power level
bs power set after assignment */
private function f_TC_rsl_bs_pwr_static_power_control(charstring id) runs on ConnHdlr {
f_l1_tune(L1CTL);
RSL.clear;
if (mp_bts_trxc_port != -1) {
f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp));
f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms);
}
var uint4_t pwr_var := 1;
var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var);
f_est_dchan();
RSL.send(ts_RSL_BS_PWR_CTRL(g_chan_nr, bs_power));
f_check_meas_bs_power_level(pwr_var);
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
}
testcase TC_rsl_bs_pwr_static_ass() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
for (var integer tn := 1; tn <= 4; tn := tn+1) {
pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_ass), pars,
pcu_comp := false, trxc_comp := true);
vc_conn.done;
}
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
testcase TC_rsl_bs_pwr_static_power_control() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
for (var integer tn := 1; tn <= 4; tn := tn+1) {
pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_power_control), pars,
pcu_comp := false, trxc_comp := true);
vc_conn.done;
}
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* target level -100, first rssi -90, ms power 7, expected increase to 7+6 within 6 seconds,
second rssi -110, ms power 7+6, expected decrease to 7 within 6 seconds,
These power levels are valid for all bands and require no special handling */
private function f_TC_rsl_ms_pwr_dyn_ass_updown(charstring id) runs on ConnHdlr {
var uint5_t pwr_var := 7;
var SacchL1Header l1h;
f_trxc_fake_rssi(rxlev2dbm(10));
f_l1_tune(L1CTL);
RSL.clear;
var RSL_IE_List addl_ies;
var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O));
addl_ies := {
valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})),
valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp}))
};
/* establish with power parameters */
f_est_dchan(more_ies := addl_ies);
/* set a high value to ensure L1 power control level increases */
f_trxc_fake_rssi(rxlev2dbm(20));
timer T2 := 6.0;
T2.start;
alt {
[] as_l1_sacch_l1h(l1h) {
if (l1h.ms_power_lvl < (pwr_var + 6)) {
repeat;
}
T2.stop;
}
[] L1CTL.receive { repeat; }
[] T2.timeout {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
"Power Level in L1 header has not increased sufficiently");
}
}
/* set a low value to ensure L1 power control level decreases */
f_trxc_fake_rssi(rxlev2dbm(0));
timer T4 := 6.0;
T4.start;
alt {
[] as_l1_sacch_l1h(l1h) {
if (l1h.ms_power_lvl > pwr_var) {
repeat;
}
T4.stop;
setverdict(pass, "Power level in L1 decreased/increased as expected");
}
[] L1CTL.receive { repeat; }
[] T4.timeout {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
"Power Level in L1 header has not decreased sufficiently");
}
}
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
}
/* check that we do not exceed the max power */
private function f_TC_rsl_ms_pwr_dyn_max(charstring id) runs on ConnHdlr {
var uint5_t pwr_var := 7;
var SacchL1Header l1h;
/* set a low value to ensure power increases */
f_trxc_fake_rssi(rxlev2dbm(10));
f_l1_tune(L1CTL);
RSL.clear;
var RSL_IE_List addl_ies;
var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O));
addl_ies := {
valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})),
valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp}))
};
/* establish with power parameters */
f_est_dchan(more_ies := addl_ies);
timer T1 := 10.0;
T1.start;
alt {
[] as_l1_sacch_l1h(l1h) { repeat; }
[] L1CTL.receive { repeat; }
[] T1.timeout {
if (not isbound(l1h)) {
setverdict(fail, "No SACCH blocks were received");
} else if (l1h.ms_power_lvl != pwr_var) {
setverdict(fail, "Power level in L1 header should not have changed");
}
}
}
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
}
/* see if we reach the band max power */
private function f_TC_rsl_ms_pwr_dyn_up(charstring id) runs on ConnHdlr {
var SacchL1Header l1h;
var uint5_t pwr_var := 15;
var uint5_t pwr_max_var := f_get_max_power_from_band();
/* set a low value to ensure power increases */
f_trxc_fake_rssi(rxlev2dbm(10));
f_l1_tune(L1CTL);
RSL.clear;
var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
/* establish with fixed power level */
f_est_dchan(more_ies :={valueof(pwr)});
/* check our initial power level */
f_wait_for_l1_power_level(pwr_var);
/* update power param to enable power loop
48.058 The maximum power to be used is indicated in the BS and MS Power elements respectively. */
RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_max_var));
/* wait, then check that our power level was reduced */
timer T1 := 10.0;
T1.start;
alt {
[] as_l1_sacch_l1h(l1h) { repeat; }
[] L1CTL.receive { repeat; }
[] T1.timeout {
if (not isbound(l1h)) {
setverdict(fail, "No SACCH blocks were received");
} else if (f_power_level_is_highest_dbm(l1h.ms_power_lvl)) {
setverdict(pass, "Power level in L1 header reduced as expected");
} else {
setverdict(fail, "Power level := ", l1h.ms_power_lvl, " did not ",
"reach the expected value := ", pwr_max_var);
}
}
}
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
}
/* see if we reach the band min power */
private function f_TC_rsl_ms_pwr_dyn_down(charstring id) runs on ConnHdlr {
var SacchL1Header l1h;
/* set a high value to ensure power decreases */
f_trxc_fake_rssi(rxlev2dbm(50));
f_l1_tune(L1CTL);
RSL.clear;
var uint5_t pwr_var := 5;
var uint5_t pwr_target_val := 15;
var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
/* establish with fixed power level */
f_est_dchan(more_ies :={valueof(pwr)});
/* check our initial power level */
f_wait_for_l1_power_level(pwr_var);
/* update power param to enable power loop
as per spec the supplied ms power IE should set the max allowed power...*/
RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_target_val));
/* wait, then check that our power level was increased */
timer T1 := 10.0;
T1.start;
alt {
[] as_l1_sacch_l1h(l1h) { repeat; }
[] L1CTL.receive { repeat; }
[] T1.timeout {
if (not isbound(l1h)) {
setverdict(fail, "No SACCH blocks were received");
} else if (f_power_level_is_lowest_dbm(l1h.ms_power_lvl)) {
setverdict(pass, "Power level increased to lowest power value");
} else {
setverdict(fail, "Power level NOT increased to lowest power value");
}
}
}
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
}
/* see if we change the power level without receiving power parameters, which should not happen
rsl chan act WITHOUT power parameters */
private function f_TC_rsl_ms_pwr_dyn_active(charstring id) runs on ConnHdlr {
var SacchL1Header l1h;
/* set a high value to ensure power decreases */
f_trxc_fake_rssi(rxlev2dbm(50));
f_l1_tune(L1CTL);
RSL.clear;
var uint5_t pwr_var := 5;
var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
/* establish with fixed power level */
f_est_dchan(more_ies :={valueof(pwr)});
/* check our initial power level */
f_wait_for_l1_power_level(pwr_var);
/* wait, then check that our power level did not change */
timer T1 := 10.0;
T1.start;
alt {
[] as_l1_sacch_l1h(l1h, do_apply := false) {
if (l1h.ms_power_lvl != pwr_var) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
"BS power control should not be active unless we receive a power parameters IE!");
}
repeat;
}
[] L1CTL.receive { repeat; }
[] T1.timeout { setverdict(pass); }
}
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
}
/* see if we change the power level without receiving power parameters, which should not happen
ms power control WITHOUT power parameters */
private function f_TC_rsl_ms_pwr_dyn_active2(charstring id) runs on ConnHdlr {
var SacchL1Header l1h;
/* set a high value to ensure power decreases */
f_trxc_fake_rssi(rxlev2dbm(50));
f_l1_tune(L1CTL);
RSL.clear;
var uint5_t pwr_var := 5;
var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var);
var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power});
/* establish with fixed power level */
f_est_dchan(more_ies :={valueof(pwr)});
/* check our initial power level */
f_wait_for_l1_power_level(pwr_var);
/* pwr control without power params IE, should NOT activate MS power control*/
RSL.send(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
/* wait, then check that our power level did not change */
timer T1 := 10.0;
T1.start;
alt {
[] as_l1_sacch_l1h(l1h, do_apply := false) {
if (l1h.ms_power_lvl != pwr_var) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
"BS power control should not be active unless we receive a power parameters IE!");
}
repeat;
}
[] L1CTL.receive { repeat; }
[] T1.timeout { setverdict(pass); }
}
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
}
private function f_wait_for_l1_power_level(integer level) runs on ConnHdlr {
var SacchL1Header l1h;
timer T0 := 10.0;
T0.start;
alt {
[] as_l1_sacch_l1h(l1h, do_apply := false) {
if (l1h.ms_power_lvl != level) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
"Power level in L1 header != signaled (RSL) power level.");
}
}
[] L1CTL.receive { repeat; }
[] T0.timeout {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
"Timeout waiting for initial power level");
}
}
T0.stop;
}
private function f_power_level_is_lowest_dbm(integer level) runs on ConnHdlr return boolean {
var IntegerRecord min_dbm_level;
var IntegerRecord max_dbm_level;
var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level);
for (var integer i := 0; i < sizeof(min_dbm_level); i := i+1) {
if (min_dbm_level[i] == level) {
return true;
}
}
return false;
}
private function f_power_level_is_highest_dbm(integer level) runs on ConnHdlr return boolean {
var IntegerRecord min_dbm_level;
var IntegerRecord max_dbm_level;
var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level);
for (var integer i := 0; i < sizeof(max_dbm_level); i := i+1) {
if (max_dbm_level[i] == level) {
return true;
}
}
return false;
}
private function f_get_max_power_from_band() runs on ConnHdlr return integer {
var IntegerRecord min_dbm_level;
var IntegerRecord max_dbm_level;
var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level);
return max_dbm_level[0];
}
type charstring BtsBand ("GSM450","GSM480","GSM750","GSM810","GSM850","GSM900","DCS1800","PCS1900");
private template charstring BtsBand_allGSM := pattern "GSM???";
private function f_power_from_band(in BtsBand band, out IntegerRecord min_dbm_level, out IntegerRecord max_dbm_level) return IntegerRecord {
// 45.005 4.1.1
var IntegerRecord gsm_power :={31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19,
18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3,
2, 1, 0};
var IntegerRecord dcs_power :={28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15,
14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30, 29};
var IntegerRecord pcs_power :={15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30};
var IntegerRecord rv;
select(band){
case (BtsBand_allGSM){
rv := gsm_power;
min_dbm_level := {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19} ;
max_dbm_level := {2, 1, 0};
}
case("DCS1800"){
rv := dcs_power;
min_dbm_level := {28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15};
max_dbm_level := {0, 29}; // let's cheat here, assume MS_TXPWR_MAX_CCH might be being broadcast, so maybe no 29,30,31
}
case("PCS1900"){
rv := pcs_power;
min_dbm_level := {15};
max_dbm_level := {30};
}
case else {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unsupported band: " & band);
}
}
return rv;
}
private function f_vty_get_bts0_band() runs on test_CT return BtsBand {
return f_vty_transceive_match_regex(BTSVTY, "show bts 0", "BTS 0 is of*type* in band (\w+),*", 0);
}
testcase TC_rsl_ms_pwr_dyn_ass_updown() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
for (var integer tn := 1; tn <= 1; tn := tn+1) {
pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
pars.bts0_band := f_vty_get_bts0_band();
vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_ass_updown), pars, trxc_comp := true);
vc_conn.done;
}
f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
testcase TC_rsl_ms_pwr_dyn_up() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10");
for (var integer tn := 1; tn <= 1; tn := tn+1) {
pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
pars.bts0_band := f_vty_get_bts0_band();
vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_up), pars, trxc_comp := true);
vc_conn.done;
}
f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
testcase TC_rsl_ms_pwr_dyn_max() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10");
for (var integer tn := 1; tn <= 1; tn := tn+1) {
pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
pars.bts0_band := f_vty_get_bts0_band();
vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_max), pars, trxc_comp := true);
vc_conn.done;
}
f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
testcase TC_rsl_ms_pwr_dyn_down() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
for (var integer tn := 1; tn <= 1; tn := tn+1) {
pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
pars.bts0_band := f_vty_get_bts0_band();
vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_down), pars, trxc_comp := true);
vc_conn.done;
}
f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
testcase TC_rsl_ms_pwr_dyn_active() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
for (var integer tn := 1; tn <= 1; tn := tn+1) {
pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
pars.bts0_band := f_vty_get_bts0_band();
vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active), pars, trxc_comp := true);
vc_conn.done;
}
f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
testcase TC_rsl_ms_pwr_dyn_active2() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100");
for (var integer tn := 1; tn <= 1; tn := tn+1) {
pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
pars.bts0_band := f_vty_get_bts0_band();
vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active2), pars, trxc_comp := true);
vc_conn.done;
}
f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop");
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
function f_TC_meas_res_speech_tchf(boolean facch_enabled) runs on test_CT {
var template RSL_IE_ChannelMode ch_mode;
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1);
for (var integer tn := 1; tn <= 1; tn := tn + 1) {
pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ch_mode));
pars.l1_pars.facch_enabled := facch_enabled;
vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
pcu_comp := false, trxc_comp := true);
vc_conn.done;
}
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
testcase TC_meas_res_speech_tchf() runs on test_CT {
f_TC_meas_res_speech_tchf(false);
}
testcase TC_meas_res_speech_tchf_facch() runs on test_CT {
f_TC_meas_res_speech_tchf(true);
}
function f_TC_meas_res_speech_tchh(boolean facch_enabled) runs on test_CT {
var template RSL_IE_ChannelMode ch_mode;
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1);
for (var integer ss := 0; ss <= 1; ss := ss + 1) {
pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ch_mode));
pars.l1_pars.facch_enabled := facch_enabled;
vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
pcu_comp := false, trxc_comp := true);
vc_conn.done;
}
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
testcase TC_meas_res_speech_tchh() runs on test_CT {
f_TC_meas_res_speech_tchh(false)
}
testcase TC_meas_res_speech_tchh_facch() runs on test_CT {
f_TC_meas_res_speech_tchh(true)
}
testcase TC_meas_res_speech_tchh_toa256() runs on test_CT {
var template RSL_IE_ChannelMode ch_mode;
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256");
ch_mode := ts_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1);
for (var integer ss := 0; ss <= 1; ss := ss + 1) {
pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ch_mode));
pars.l1_pars.toa256_enabled := true;
vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
pcu_comp := false, trxc_comp := true);
vc_conn.done;
}
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
testcase TC_meas_res_sign_tchf() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
for (var integer tn := 1; tn <= 4; tn := tn+1) {
pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN(RSL_CHRT_TCH_F)));
vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
pcu_comp := false, trxc_comp := true);
vc_conn.done;
}
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
testcase TC_meas_res_sign_tchh() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
for (var integer ss := 0; ss <= 1; ss := ss+1) {
pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN(RSL_CHRT_TCH_H)));
vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
pcu_comp := false, trxc_comp := true);
vc_conn.done;
}
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
testcase TC_meas_res_sign_sdcch4() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
for (var integer ss := 0; ss <= 3; ss := ss+1) {
pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0, ss), ts_RSL_ChanMode_SIGN));
vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
pcu_comp := false, trxc_comp := true);
vc_conn.done;
}
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
testcase TC_meas_res_sign_sdcch8() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
for (var integer ss := 0; ss <= 7; ss := ss+1) {
pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, ss), ts_RSL_ChanMode_SIGN));
vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
pcu_comp := false, trxc_comp := true);
vc_conn.done;
}
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
testcase TC_meas_res_sign_tchh_toa256() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256");
for (var integer ss := 0; ss <= 1; ss := ss+1) {
pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN(RSL_CHRT_TCH_H)));
pars.l1_pars.toa256_enabled := true;
vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars,
pcu_comp := false, trxc_comp := true);
vc_conn.done;
}
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* establish DChan, and send MS POWER CONTROL messages via RSL, verify that
* the BTS is forwarding those values to the MS via the SACCH L1 header. */
private function f_tc_rsl_ms_pwr_ctrl(charstring id) runs on ConnHdlr {
var SacchL1Header l1h;
var RSL_IE_MS_Power ms_power;
var RSL_Message rsl;
var uint5_t power_level := 0;
f_l1_tune(L1CTL);
RSL.clear;
f_est_dchan();
ms_power.reserved := 0;
ms_power.fpc_epc := false;
/* Send the first power control command. This will disable any BTS/TRX
* internal power control and switch the MS (which is not in scope of
* this test) to a constant power level. We start with a power level
* of 0 */
ms_power.power_level := power_level;
rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
RSL.send(rsl);
alt {
[] as_l1_sacch_l1h(l1h, do_apply := false) {
if (l1h.ms_power_lvl != power_level) {
setverdict(fail, "Power level := ", l1h.ms_power_lvl, "does not ",
"match the signaled (RSL) power level := ", power_level);
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* Signal a new power level via RSL for the next turn. */
if (power_level < 31) {
power_level := power_level + 1;
ms_power.power_level := power_level;
rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power));
RSL.send(rsl);
repeat;
}
}
/* Ignore all other blocks */
[] L1CTL.receive { repeat; }
}
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
setverdict(pass);
}
testcase TC_rsl_ms_pwr_ctrl() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
for (var integer tn := 1; tn <= 4; tn := tn+1) {
pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN));
vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars);
vc_conn.done;
}
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* establish DChan, verify that the BTS sets the TA in the first SACCH L1 header.
TA for the IMM ASS messages is still controlled by g_pars.l1_pars.ms_actual_ta! */
private function f_tc_rsl_chan_initial_ta(charstring id) runs on ConnHdlr {
var uint5_t ta_to_test := 16;
var SacchL1Header l1h;
f_l1_tune(L1CTL);
RSL.clear;
/* tell fake_trx to use a given timing offset for all bursts */
f_trxc_fake_toffs256(ta_to_test*256);
f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := ta_to_test}))} );
alt {
[] as_l1_sacch_l1h(l1h, do_apply := false) {
if (l1h.actual_ta != ta_to_test) {
setverdict(fail, "TA in L1 header does not match the signaled (RSL) TA.");
}
}
/* Ignore all other blocks */
[] L1CTL.receive { repeat; }
}
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
setverdict(pass);
}
testcase TC_rsl_chan_initial_ta() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars,
pcu_comp := false, trxc_comp := true);
vc_conn.done;
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* establish DChan, verify that the BTS sets MS power in the first SACCH L1 header. */
private function f_tc_rsl_chan_initial_ms_pwr(charstring id) runs on ConnHdlr {
var uint5_t ms_power_level := 7;
var SacchL1Header l1h;
var RSL_IE_MS_Power ms_power;
ms_power.reserved := 0;
ms_power.fpc_epc := false;
ms_power.power_level := ms_power_level;
f_l1_tune(L1CTL);
RSL.clear;
f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}))} );
timer T := 1.0;
T.start;
alt {
/* Pick all SACCH blocks for checking */
[] as_l1_sacch_l1h(l1h, do_apply := false) {
if (l1h.ms_power_lvl != ms_power_level) {
setverdict(fail, "Power level := ", l1h.ms_power_lvl, "does not ",
"match the signaled (RSL) power level := ", ms_power_level);
}
}
/* Ignore all other blocks */
[] L1CTL.receive { repeat; }
[] T.timeout {
setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level.");
}
}
f_rsl_chan_deact();
f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr);
setverdict(pass);
}
testcase TC_rsl_chan_initial_ms_pwr() runs on test_CT {
var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
f_testmatrix_each_chan(pars, refers(f_tc_rsl_chan_initial_ms_pwr));
}
/* Test if a channel without valid uplink bursts generates RSL CONN FAIL IND (TS 48.058 4.10) */
private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr {
f_l1_tune(L1CTL);
RSL.clear;
f_est_dchan();
f_sleep(2.0);
L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr));
timer T := 40.0;
T.start;
alt {
[] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) {
setverdict(pass)
}
[] RSL.receive { repeat };
[] T.timeout {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received");
}
}
f_rsl_chan_deact();
}
testcase TC_conn_fail_crit() runs on test_CT {
var ConnHdlr vc_conn;
var ConnHdlrPars pars;
f_init();
pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN));
pars.t_guard := 60.0;
vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars);
vc_conn.done;
}
/***********************************************************************
* Paging
***********************************************************************/
private function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean {
if (tmsi == 'FFFFFFFF'O) {
return true;
} else {
return false;
}
}
private type record allowedFn { integer frame_nr }
private template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) }
private template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) }
private template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) }
private template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) }
private template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) }
private template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) }
private template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) }
private template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) }
private function check_pch_fn(integer frame_nr, integer bs_ag_blks_res) runs on test_CT
{
var integer frame_nr_51;
frame_nr_51 := frame_nr mod 51
var allowedFn fn_check;
fn_check.frame_nr := frame_nr_51;
if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "bs_ag_blks_res out of valid range (0..7)");
return;
}
if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) {
return;
}
if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) {
return;
}
if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) {
return;
}
if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) {
return;
}
if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) {
return;
}
if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) {
return;
}
if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) {
return;
}
if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) {
return;
}
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH");
return;
}
private altstep as_l1_count_paging(inout integer num_paging_rcv_msgs,
inout integer num_paging_rcv_ids,
PagingTestCfg cfg)
runs on test_CT {
var L1ctlDlMessage dl;
[] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_DummyUI)) {
repeat;
}
[] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl {
var octetstring without_plen :=
substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1);
var PDU_ML3_NW_MS rr := dec_PDU_ML3_NW_MS(without_plen);
check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res);
if (match(rr, tr_PAGING_REQ1(tr_MI_LV(t_MI_NoIdentity(?))))) {
/* Ignore empty RR Paging Request (PCH filling) messages.
* TODO: does it make sense to count them? */
} else if (match(rr, tr_PAGING_REQ1)) {
num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
num_paging_rcv_ids := num_paging_rcv_ids + 1;
if (ispresent(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) {
num_paging_rcv_ids := num_paging_rcv_ids + 1;
}
} else if (match(rr, tr_PAGING_REQ2)) {
num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) {
num_paging_rcv_ids := num_paging_rcv_ids + 1;
}
if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) {
num_paging_rcv_ids := num_paging_rcv_ids + 1;
}
if (ispresent(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) {
num_paging_rcv_ids := num_paging_rcv_ids + 1;
}
} else if (match(rr, tr_PAGING_REQ3)) {
num_paging_rcv_msgs := num_paging_rcv_msgs + 1;
if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) {
num_paging_rcv_ids := num_paging_rcv_ids + 1;
}
if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) {
num_paging_rcv_ids := num_paging_rcv_ids + 1;
}
if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) {
num_paging_rcv_ids := num_paging_rcv_ids + 1;
}
if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) {
num_paging_rcv_ids := num_paging_rcv_ids + 1;
}
}
repeat;
}
}
private type record PagingTestCfg {
boolean combined_ccch,
integer bs_ag_blks_res,
float load_factor,
boolean exp_load_ind,
boolean exp_overload,
boolean use_tmsi
}
private type record PagingTestState {
integer num_paging_sent,
integer num_paging_rcv_msgs,
integer num_paging_rcv_ids,
integer num_overload
}
/* Helper function for paging related testing */
private function f_TC_paging(PagingTestCfg cfg) runs on test_CT return PagingTestState {
f_init();
f_init_l1ctl();
f_l1_tune(L1CTL);
var PagingTestState st := {
num_paging_sent := 0,
num_paging_rcv_msgs := 0,
num_paging_rcv_ids := 0,
num_overload := 0
};
var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res);
var float max_pch_imsi_per_sec;
if (cfg.use_tmsi) {
max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */
} else {
max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */
}
var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor;
var float interval := 1.0 / pch_blocks_per_sec;
var float time_total := 20.0;
var integer pkt_total := float2int(time_total * pch_blocks_per_sec);
log("pch_blocks_total=", pkt_total," pch_blocks_per_sec=", pch_blocks_per_sec, " interval=", interval);
timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */
T_total.start;
timer T_itv := 0.0;
T_itv.start;
while (st.num_paging_sent < pkt_total) {
alt {
/* check for presence of CCCH LOAD IND (paging load) */
[cfg.exp_overload] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
st.num_overload := st.num_overload + 1;
repeat;
}
[not cfg.exp_overload] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload");
}
[cfg.exp_load_ind] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND)) {
log("Rx LOAD_IND");
/* FIXME: analyze/verify interval + contents */
repeat;
}
/* check if paging requests arrive on Um side */
[] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
[] L1CTL.receive { repeat; }
[] T_itv.timeout {
/* Send paging cmds based on elapsed time */
var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1);
while (st.num_paging_sent < new_sent) {
var MobileIdentityV mi;
/* build mobile Identity */
if (cfg.use_tmsi) {
mi := valueof(t_MI_TMSI(f_rnd_octstring(4)));
} else {
mi := valueof(ts_MI_IMSI(f_gen_imsi(st.num_paging_sent)));
}
/* Send RSL PAGING COMMAND */
RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_PAGING_CMD(mi, st.num_paging_sent mod 4)));
st.num_paging_sent := st.num_paging_sent + 1;
}
if (st.num_paging_sent < pkt_total) {
/* Wait for interval to next PAGING COMMAND */
var float time_now := T_total.read;
var float next_sched := int2float(st.num_paging_sent)*interval;
if (next_sched > time_now) {
T_itv.start(next_sched - time_now);
} else {
T_itv.start(0.0);
}
} else {
/* We are done, no need to keep counting */
T_total.stop;
}
}
[] T_total.timeout { }
}
}
/* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */
timer T_wait := 18.0;
T_wait.start;
alt {
[] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids, cfg);
[] L1CTL.receive { repeat; }
/* 65535 == empty paging queue, we can terminate*/
[] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { }
[] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { repeat; }
[] T_wait.timeout {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Waiting for empty paging queue");
}
}
log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs,
" rcvd_ids=", st.num_paging_rcv_ids);
return st;
}
/* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that
* - the number of Mobile Identities on Um PCH match the number of pages on RSL
* - that CCCH LOAD IND (PCH) are being generated
* - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
testcase TC_paging_imsi_80percent() runs on test_CT {
var SystemInformation si3 := valueof(ts_SI3_default);
var PagingTestCfg cfg := {
combined_ccch := true,
bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
load_factor := 0.8,
exp_load_ind := true,
exp_overload := false,
use_tmsi := false
};
var PagingTestState st := f_TC_paging(cfg);
if (st.num_paging_sent != st.num_paging_rcv_ids) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ",
st.num_paging_rcv_ids));
} else {
setverdict(pass);
}
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that
* - the number of Mobile Identities on Um PCH match the number of pages on RSL
* - that CCCH LOAD IND (PCH) are being generated
* - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
testcase TC_paging_tmsi_80percent() runs on test_CT {
var SystemInformation si3 := valueof(ts_SI3_default);
var PagingTestCfg cfg := {
combined_ccch := true,
bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
load_factor := 0.8,
exp_load_ind := true,
exp_overload := false,
use_tmsi := true
};
var PagingTestState st := f_TC_paging(cfg);
if (st.num_paging_sent != st.num_paging_rcv_ids) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ",
st.num_paging_rcv_ids));
} else {
setverdict(pass);
}
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that
* - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
* - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
* - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
testcase TC_paging_imsi_200percent() runs on test_CT {
var SystemInformation si3 := valueof(ts_SI3_default);
var PagingTestCfg cfg := {
combined_ccch := true,
bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
load_factor := 2.0,
exp_load_ind := true,
exp_overload := true,
use_tmsi := false
};
var PagingTestState st := f_TC_paging(cfg);
/* We expect about 80-85% to pass, given that we can fill the paging buffer of 200
* slots and will fully drain that buffer before returning */
var template integer tpl := (st.num_paging_sent*78/100 .. st.num_paging_sent *85/100);
if (not match(st.num_paging_rcv_ids, tpl)) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids));
} else {
setverdict(pass);
}
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that
* - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL
* - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point
* - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */
testcase TC_paging_tmsi_200percent() runs on test_CT {
var SystemInformation si3 := valueof(ts_SI3_default);
var PagingTestCfg cfg := {
combined_ccch := true,
bs_ag_blks_res := si3.payload.si3.ctrl_chan_desc.bs_ag_blks_res,
load_factor := 2.0,
exp_load_ind := true,
exp_overload := true,
use_tmsi := true
};
var PagingTestState st := f_TC_paging(cfg);
/* We expect about 70% to pass, given that we can fill the paging buffer of 200
* slots and will fully drain that buffer before returning */
var template integer tpl := (st.num_paging_sent*64/100 .. st.num_paging_sent *72/100);
if (not match(st.num_paging_rcv_ids, tpl)) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids));
} else {
setverdict(pass);
}
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/***********************************************************************
* Immediate Assignment / AGCH
***********************************************************************/
private const MobileAllocationLV c_MA_null := {
len := 0,
ma := ''B
}
private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring {
return int2str(num_tx) & " sent, "
& int2str(num_rx) & " received, "
& int2str(num_del) & " deleted";
}
private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT {
var L1ctlDlMessage l1_dl;
timer T := 10.0;
var integer num_tx := 0;
var integer num_rx := 0;
var integer num_del := 0;
var charstring res_str;
var float rx_ratio;
f_init();
f_init_l1ctl();
f_l1_tune(L1CTL);
for (var integer i := 0; i < num_total; i := i+1) {
var ChannelDescription ch_desc := valueof(ts_ChanDescH0(ts_RslChanNr_SDCCH4(0, 0),
mp_trx_pars[0].arfcn,
mp_tsc_def));
var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null));
var octetstring ia_enc := enc_GsmRrMessage(ia);
RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_IMM_ASSIGN(ia_enc, 0)));
num_tx := num_tx+1;
f_sleep(sleep_s);
}
/* FIXME: check if imm.ass arrive on Um side */
T.start;
alt {
[] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_DELETE_IND(?, 0))) {
num_del := num_del+1;
repeat;
}
[] RSL_CCHAN.receive {
repeat;
}
[] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?)) -> value l1_dl {
var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload);
if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) {
/* FIXME: Why are we seeing paging requests on PCH/AGCH? */
//Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Unexpected IMM-ASS values on AGCH: ", rr));
} else {
num_rx := num_rx+1;
}
repeat;
}
[] L1CTL.receive { repeat; }
[] T.timeout { }
}
res_str := f_fmt_ia_stats(num_tx, num_rx, num_del);
log("AGCH test: " & res_str);
if (num_rx + num_del != num_tx) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str);
}
rx_ratio := int2float(num_rx) / int2float(num_tx);
if (rx_ratio < exp_pass*0.8 or rx_ratio > exp_pass*1.2) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX ratio ("&float2str(rx_ratio)&") far from expected ("&float2str(exp_pass)&") " & res_str);
} else {
setverdict(pass);
}
Misc_Helpers.f_shutdown(__BFILE__, __LINE__);
}
/* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */
testcase TC_imm_ass_1000_20ms() runs on test_CT {
f_TC_imm_ass(1000, 0.02, 0.25);
}
/* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */
testcase TC_imm_ass_200_0ms() runs on test_CT {
f_TC_imm_ass(200, 0.0, 0.05);
}
/* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */
testcase TC_imm_ass_200_76ms() runs on test_CT {
f_TC_imm_ass(150, 0.076, 1.00);
}
/***********************************************************************
* BCCH
***********************************************************************/
/* tuple of Frame Number + decoded SI */
private type record SystemInformationFn {
GsmFrameNumber frame_number,
SystemInformation si
}
/* an arbitrary-length vector of decoded SI + gsmtap header */
private type record of SystemInformationFn SystemInformationVector;
/* an array of SI-vectors indexed by TC value */
private type SystemInformationVector SystemInformationVectorPerTc[8];
/* determine if a given SI vector contains given SI type at least once */
private function f_si_vecslot_contains(SystemInformationVector arr,
RrMessageType key,
boolean bcch_ext := false)
return boolean {
for (var integer i:= 0; i< sizeof(arr); i := i + 1) {
var integer fn_mod51 := arr[i].frame_number mod 51;
if (not bcch_ext and fn_mod51 == 2 or
bcch_ext and fn_mod51 == 6) {
if (arr[i].si.header.message_type == key) {
return true;
}
}
}
return false;
}
/* ensure a given TC slot of the SI vector contains given SI type at least once at TC */
private function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr,
integer tc, RrMessageType key,
boolean ext_bcch := false)
{
if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("No ", key, " in TC=", tc, "!"));
}
}
/* check if a given SI vector contains given SI type at least once on any TC */
private function f_si_vec_contains(SystemInformationVectorPerTc arr,
RrMessageType key)
return boolean {
for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) {
if (f_si_vecslot_contains(arr[tc], key) or
f_si_vecslot_contains(arr[tc], key, true)) {
return true;
}
}
return false;
}
/* determine if a given SI vector contains given SI type at least N of M times */
private function f_si_vecslot_contains_n_of_m(SystemInformationVector arr,
RrMessageType key,
boolean bcch_ext := false,
integer n := 1, integer m := 4)
return boolean {
var integer count := 0;
if (sizeof(arr) < m) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array: "
& int2str(sizeof(arr)) & " < " & int2str(m));
}
for (var integer i:= 0; i < m; i := i + 1) {
var integer fn_mod51 := arr[i].frame_number mod 51;
if (not bcch_ext and fn_mod51 == 2 or
bcch_ext and fn_mod51 == 6) {
if (arr[i].si.header.message_type == key) {
count := count + 1;
}
}
}
if (count >= n) {
return true;
} else {
return false;
}
}
/* ensure a given TC slot of the SI vector contains given SI type at least N out of M times at TC */
private function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr,
integer tc, RrMessageType key,
boolean ext_bcch := false,
integer n, integer m)
{
if (not f_si_vecslot_contains_n_of_m(arr[tc], key, ext_bcch, n, m)) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Not ", n, "/", m, " of ", key, " in TC=", tc, "!"));
}
}