From b5b7a6ea2723ee96adfa7bcd9a7cb00684d48bc9 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Fri, 4 Jun 2021 19:03:45 +0200 Subject: [PATCH] bsc: test TSC in various messages In a recent osmo-bsc patch: "allow explixit TSC Set and TSC on chan activ / modif / assignment" c33eb8d56943b8981523754b081967e6ff5f245d Ic665125255d7354f5499d10dda1dd866ab243d24 I accidentally changed the default behavior of the Training Sequence Code sent to BTS and MS. So now, make sure that we verify the expected Training Sequence Code in BSC_Tests, in: RSL Channel Activate RR Immediate Assignment RR Assignment Command RR Channel Mode Modify RSL Mode Modify Related: OS#5172 SYS#5315 Change-Id: Id67a949e0f61ec8123976eb8d336f04510c55c01 --- bsc/BSC_Tests.ttcn | 3 ++ bsc/MSC_ConnectionHandler.ttcn | 57 ++++++++++++++++++++++++++++++++-- library/RSL_Emulation.ttcn | 21 ++++++++++++- 3 files changed, 77 insertions(+), 4 deletions(-) diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn index 6f603b1f1..9ea026951 100644 --- a/bsc/BSC_Tests.ttcn +++ b/bsc/BSC_Tests.ttcn @@ -684,6 +684,9 @@ private function f_gen_test_hdlr_pars(integer bssap_idx := 0) return TestHdlrPar pars.exp_ms_power_level := mp_exp_ms_power_level; pars.mscpool.bssap_idx := bssap_idx; + /* BTS 0 has BSIC 10 (and no explicit timeslot training_sequence_code config), so expecting TSC = (BSIC & 7) = 2 */ + pars.expect_tsc := 2; + return pars; } diff --git a/bsc/MSC_ConnectionHandler.ttcn b/bsc/MSC_ConnectionHandler.ttcn index c6e82d4ea..c29ccd42e 100644 --- a/bsc/MSC_ConnectionHandler.ttcn +++ b/bsc/MSC_ConnectionHandler.ttcn @@ -590,7 +590,8 @@ type record TestHdlrParams { TestHdlrParamsMSCPool mscpool, boolean media_mgw_offer_ipv6, OCT3 last_used_eutran_plmn optional, - boolean expect_channel_mode_modify + boolean expect_channel_mode_modify, + uint3_t expect_tsc optional }; /* Note: Do not use valueof() to get a value of this template, use @@ -627,17 +628,23 @@ template (value) TestHdlrParams t_def_TestHdlrPars := { }, media_mgw_offer_ipv6 := true, last_used_eutran_plmn := omit, - expect_channel_mode_modify := false + expect_channel_mode_modify := false, + expect_tsc := omit } function f_create_chan_and_exp() runs on MSC_ConnHdlr { var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi)); var octetstring l3_enc := enc_PDU_ML3_MS_NW(l3_info); + var template uint3_t tsc := ?; + + if (not istemplatekind(g_pars.expect_tsc, "omit")) { + tsc := g_pars.expect_tsc; + } f_create_bssmap_exp(l3_enc); /* call helper function for CHAN_RQD -> IMM ASS ->EST_IND */ - RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn); + RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn, tsc); } function f_rsl_send_l3(template PDU_ML3_MS_NW l3, template (omit) RslLinkId link_id := omit, @@ -859,6 +866,14 @@ private function f_check_chan_act(AssignmentState st, RSL_Message chan_act) runs } +private function rr_chan_desc_tsc(ChannelDescription2_V cd2) + return uint3_t +{ + var uint3_t tsc := oct2int(cd2.octet3); + tsc := tsc / 32; /* shl 5 */ + return tsc; +} + altstep as_assignment(inout AssignmentState st) runs on MSC_ConnHdlr { var RSL_Message rsl; [not st.rr_ass_cmpl_seen] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl { @@ -867,6 +882,16 @@ altstep as_assignment(inout AssignmentState st) runs on MSC_ConnHdlr { if (ischosen(l3.msgs.rrm.assignmentCommand)) { var RslChannelNr new_chan_nr; var GsmArfcn arfcn; + + if (not istemplatekind(g_pars.expect_tsc, "omit")) { + var uint3_t got_tsc := rr_chan_desc_tsc(l3.msgs.rrm.assignmentCommand.descrOf1stChAfterTime); + if (not match(got_tsc, g_pars.expect_tsc)) { + setverdict(fail, "RR Assignment: unexpected TSC in Channel Description: expected ", + g_pars.expect_tsc, " got ", got_tsc); + mtc.stop; + } + } + f_ChDesc2RslChanNr(l3.msgs.rrm.assignmentCommand.descrOf1stChAfterTime, new_chan_nr, arfcn); /* FIXME: Determine TRX NR by ARFCN, instead of hard-coded TRX0! */ @@ -1264,6 +1289,32 @@ runs on MSC_ConnHdlr { " to signalling mode, but got spd_ind == ", rsl_spd_ind); mtc.stop; } + + if (not istemplatekind(g_pars.expect_tsc, "omit")) { + var uint3_t got_tsc := rr_chan_desc_tsc(st.rr_channel_mode_modify_msg.msgs.rrm.channelModeModify.channelDescription); + if (not match(got_tsc, g_pars.expect_tsc)) { + setverdict(fail, "RR Channel Mode Modify: unexpected TSC in Channel Description: expected ", + g_pars.expect_tsc, " got ", got_tsc); + mtc.stop; + } + } + + } else { + /* not exp_modify, so this did a Channel Activate */ + + /* Check the TSC */ + if (not istemplatekind(g_pars.expect_tsc, "omit")) { + var RSL_Message chan_act := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr); + var RSL_IE_Body ie; + if (f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, ie)) { + var uint3_t got_tsc := ie.chan_ident.ch_desc.v.tsc; + if (not match(got_tsc, g_pars.expect_tsc)) { + setverdict(fail, "RSL CHANnel ACTIVation: unexpected TSC in Channel Description: expected ", + g_pars.expect_tsc, " got ", got_tsc); + mtc.stop; + } + } + } } /* When the BSC detects that LCLS is possible it will cross the diff --git a/library/RSL_Emulation.ttcn b/library/RSL_Emulation.ttcn index cb8b763d1..91fa2dbb5 100644 --- a/library/RSL_Emulation.ttcn +++ b/library/RSL_Emulation.ttcn @@ -135,18 +135,37 @@ private function f_rx_or_fail(template RSL_Message exp_rx) runs on RSL_DchanHdlr } /* establish a dedicated channel using 'ra' */ -function f_chan_est(OCT1 ra, octetstring est_l3, template RslLinkId link_id, GsmFrameNumber fn := 23) +function f_chan_est(OCT1 ra, octetstring est_l3, template RslLinkId link_id, GsmFrameNumber fn := 23, + template uint3_t tsc := ?) runs on RSL_DchanHdlr { var RSL_Message rx_rsl; var GsmRrMessage rr; /* request a channel to be established */ RSL.send(ts_RSLDC_ChanRqd(ra, fn)); + /* At this point the BSC sends a CHAN ACTIV which we always ACK. Checking it below. */ /* expect immediate assignment */ rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN); rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload); + if (not match(rr.payload.imm_ass.chan_desc.tsc, tsc)) { + setverdict(fail, "Immediate Assignment: unexpected TSC in Channel Description: expected ", tsc, " got ", + rr.payload.imm_ass.chan_desc.tsc); + mtc.stop; + } g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr; RSL.send(ts_RSL_EST_IND(g_chan_nr, valueof(link_id), est_l3)); + + /* Check above CHAN ACTIV */ + var RSL_Message chan_act := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr); + var RSL_IE_Body ie; + if (f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, ie)) { + var uint3_t got_tsc := ie.chan_ident.ch_desc.v.tsc; + if (not match(got_tsc, tsc)) { + setverdict(fail, "RSL CHANnel ACTIVation: unexpected TSC in Channel Description: expected ", + tsc, " got ", got_tsc); + mtc.stop; + } + } } function f_deact_chan(RSL_Cause cause) runs on RSL_DchanHdlr