Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 1 | module BSC_Tests { |
| 2 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 3 | import from General_Types all; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 4 | import from Osmocom_Types all; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 5 | import from GSM_Types all; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 6 | import from IPL4asp_Types all; |
| 7 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 8 | import from BSSAP_Adapter all; |
| 9 | import from BSSAP_CodecPort all; |
| 10 | import from BSSMAP_Templates all; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 11 | import from IPA_Emulation all; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 12 | import from IPA_Types all; |
| 13 | import from RSL_Types all; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 14 | |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 15 | import from Osmocom_CTRL_Functions all; |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 16 | import from Osmocom_CTRL_Types all; |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 17 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 18 | import from RSL_Tests all; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 19 | |
Harald Welte | 696ddb6 | 2017-12-08 14:01:43 +0100 | [diff] [blame] | 20 | const integer NUM_BTS := 1; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 21 | const float T3101_MAX := 12.0; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 22 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 23 | |
| 24 | /* BSC specific CTRL helper functions */ |
| 25 | function f_ctrl_get_bts(IPA_CTRL_PT pt, integer bts_nr, charstring suffix) return CtrlValue { |
| 26 | return f_ctrl_get(pt, "bts." & int2str(bts_nr) & "." & suffix); |
| 27 | } |
| 28 | |
| 29 | template charstring ts_bts(integer bts_nr) := "bts." & int2str(bts_nr) & "."; |
| 30 | template charstring ts_bts_trx(integer bts_nr, integer trx_nr ) := |
| 31 | valueof(ts_bts(bts_nr)) & "trx." & int2str(trx_nr) & "."; |
| 32 | |
| 33 | function f_ctrl_get_exp_bts(IPA_CTRL_PT pt, integer bts_nr, CtrlVariable suffix, template CtrlValue exp) { |
| 34 | f_ctrl_get_exp(pt, valueof(ts_bts(bts_nr)) & suffix, exp); |
| 35 | } |
| 36 | |
| 37 | function f_ctrl_get_exp_trx(IPA_CTRL_PT pt, integer bts_nr, integer trx_nr, CtrlVariable suffix, |
| 38 | template CtrlValue exp) |
| 39 | { |
| 40 | f_ctrl_get_exp(pt, valueof(ts_bts_trx(bts_nr, trx_nr)) & suffix, exp); |
| 41 | } |
| 42 | |
| 43 | |
| 44 | |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 45 | type record BTS_State { |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 46 | IPA_Client rsl |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 47 | } |
| 48 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 49 | type component test_CT extends BSSAP_Adapter_CT { |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 50 | var BTS_State bts[NUM_BTS]; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 51 | port IPA_RSL_PT IPA_RSL[NUM_BTS]; |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 52 | |
| 53 | var IPA_Client ctrl; |
| 54 | port IPA_CTRL_PT IPA_CTRL; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 55 | |
| 56 | var boolean g_initialized := false; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 57 | timer T_guard := 30.0; |
| 58 | |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | modulepar { |
Harald Welte | 696ddb6 | 2017-12-08 14:01:43 +0100 | [diff] [blame] | 62 | charstring mp_bsc_ip := "127.0.0.1"; |
| 63 | integer mp_bsc_rsl_port := 3003; |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 64 | integer mp_bsc_ctrl_port := 4249; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 65 | } |
| 66 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 67 | type record IPA_Client { |
| 68 | IPA_Emulation_CT vc_IPA, |
| 69 | IPA_CCM_Parameters ccm_pars, |
| 70 | charstring id |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 71 | } |
| 72 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 73 | function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i) |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 74 | runs on test_CT { |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 75 | timer T := 10.0; |
| 76 | |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 77 | clnt.id := "IPA" & int2str(i) & "-RSL"; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 78 | clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA"); |
| 79 | clnt.ccm_pars := c_IPA_default_ccm_pars; |
| 80 | clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator"; |
| 81 | clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0"; |
| 82 | |
| 83 | map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 84 | connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]); |
| 85 | |
| 86 | clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", -1, clnt.ccm_pars)); |
| 87 | |
| 88 | /* wait for IPA RSL link to connect and send ID ACK */ |
| 89 | T.start; |
| 90 | alt { |
| 91 | [] IPA_RSL[i].receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_ID_ACK}) { |
| 92 | T.stop; |
| 93 | IPA_RSL[i].send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,ts_RSL_PAGING_LOAD_IND(23))); |
| 94 | } |
Harald Welte | 60e823a | 2017-12-10 14:10:59 +0100 | [diff] [blame] | 95 | [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 96 | [] IPA_RSL[i].receive { repeat } |
| 97 | [] T.timeout { |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 98 | setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK"); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 99 | self.stop; |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 104 | function f_ipa_ctrl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i) |
| 105 | runs on test_CT { |
| 106 | timer T := 10.0; |
| 107 | |
| 108 | clnt.id := "IPA" & int2str(i) & "-CTRL"; |
| 109 | clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA"); |
| 110 | |
| 111 | map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT); |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 112 | connect(clnt.vc_IPA:IPA_CTRL_PORT, self:IPA_CTRL); |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 113 | |
| 114 | clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", -1)); |
| 115 | |
| 116 | /* wait for IPA CTRL link to connect and send UP */ |
| 117 | T.start; |
| 118 | alt { |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 119 | [] IPA_CTRL.receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_UP}) { } |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 120 | [] T.timeout { |
| 121 | setverdict(fail, "Timeout CTRL waiting for ASP_IPA_EVENT_UP"); |
| 122 | self.stop; |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 128 | function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT { |
| 129 | timer T := secs_max; |
| 130 | T.start; |
| 131 | while (true) { |
| 132 | if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) { |
| 133 | T.stop; |
| 134 | return; |
| 135 | } |
| 136 | f_sleep(0.1); |
| 137 | if (not T.running) { |
| 138 | setverdict(fail, "Timeout waiting for oml-connection-state ", status); |
| 139 | self.stop; |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 144 | function f_sleep(float seconds) { |
| 145 | timer T := seconds; |
| 146 | T.start; |
| 147 | T.timeout; |
| 148 | } |
| 149 | |
| 150 | altstep as_Tguard() runs on test_CT { |
Harald Welte | 60e823a | 2017-12-10 14:10:59 +0100 | [diff] [blame] | 151 | var BSSAP_N_UNITDATA_ind ud_ind; |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 152 | [] T_guard.timeout { setverdict(fail, "Timeout of T_guard"); } |
Harald Welte | 60e823a | 2017-12-10 14:10:59 +0100 | [diff] [blame] | 153 | /* always respond with RESET ACK to RESET */ |
| 154 | [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset)) -> value ud_ind { |
| 155 | BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress, |
| 156 | ts_BSSMAP_ResetAck)); |
| 157 | } |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | function f_init() runs on test_CT { |
| 161 | var integer i; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 162 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 163 | if (g_initialized) { |
| 164 | return; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 165 | } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 166 | g_initialized := true; |
| 167 | |
| 168 | /* Call a function of our 'parent component' BSSAP_Adapter_CT to start the |
| 169 | * MSC-side BSSAP emulation */ |
| 170 | f_bssap_init("VirtMSC"); |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 171 | f_ipa_ctrl_start(ctrl, mp_bsc_ip, mp_bsc_ctrl_port, 0); |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 172 | |
Harald Welte | 696ddb6 | 2017-12-08 14:01:43 +0100 | [diff] [blame] | 173 | for (i := 0; i < NUM_BTS; i := i+1) { |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 174 | /* wait until osmo-bts-omldummy has respawned */ |
| 175 | f_wait_oml(i, "degraded", 5.0); |
| 176 | /* start RSL connection */ |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 177 | f_ipa_rsl_start(bts[i].rsl, mp_bsc_ip, mp_bsc_rsl_port, i); |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 178 | /* wait until BSC tells us "connected" */ |
| 179 | f_wait_oml(i, "connected", 5.0); |
Harald Welte | 696ddb6 | 2017-12-08 14:01:43 +0100 | [diff] [blame] | 180 | } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 181 | f_sleep(0.5); |
Harald Welte | 696ddb6 | 2017-12-08 14:01:43 +0100 | [diff] [blame] | 182 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 183 | T_guard.start; |
| 184 | activate(as_Tguard()); |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 185 | } |
| 186 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 187 | function f_exp_ipa_rx(integer bts_nr, template RSL_Message t_rx, float t_secs := 2.0, IpaStreamId sid := IPAC_PROTO_RSL_TRX0) |
| 188 | runs on test_CT return RSL_Message { |
| 189 | var ASP_RSL_Unitdata rx_rsl_ud; |
| 190 | timer T := t_secs; |
| 191 | |
| 192 | T.start; |
| 193 | alt { |
| 194 | [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(sid, t_rx)) -> value rx_rsl_ud { |
| 195 | T.stop; |
| 196 | } |
| 197 | [] IPA_RSL[bts_nr].receive { repeat; } |
Harald Welte | b291770 | 2017-12-10 15:48:52 +0100 | [diff] [blame] | 198 | [] T.timeout { |
| 199 | setverdict(fail, "Timeout expecting ", t_rx); |
| 200 | self.stop; |
| 201 | } |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 202 | } |
| 203 | return rx_rsl_ud.rsl; |
| 204 | } |
| 205 | |
| 206 | function f_ipa_tx(integer bts_nr, template RSL_Message t_tx, IpaStreamId sid := IPAC_PROTO_RSL_TRX0) |
| 207 | runs on test_CT { |
| 208 | IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(sid, t_tx)); |
| 209 | } |
| 210 | |
| 211 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 212 | /* verify we get a CHAN_ACT after CHAN RQD */ |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 213 | testcase TC_chan_act_noreply() runs on test_CT { |
| 214 | var BSSAP_N_UNITDATA_ind ud_ind; |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 215 | |
| 216 | f_init(); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 217 | f_bssap_reset(); |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 218 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 219 | IPA_RSL[0].send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,ts_RSL_CHAN_RQD('23'O, 23))); |
| 220 | f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV)); |
| 221 | setverdict(pass); |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 222 | } |
| 223 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 224 | /* verify if the "chreq:total" counter increments as expected */ |
| 225 | testcase TC_chan_act_counter() runs on test_CT { |
| 226 | var BSSAP_N_UNITDATA_ind ud_ind; |
| 227 | var integer chreq_total; |
| 228 | |
| 229 | f_init(); |
| 230 | f_bssap_reset(); |
| 231 | |
| 232 | chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total"); |
| 233 | IPA_RSL[0].send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,ts_RSL_CHAN_RQD('23'O, 23))); |
| 234 | f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV)); |
| 235 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1); |
| 236 | |
| 237 | setverdict(pass); |
| 238 | } |
| 239 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 240 | /* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */ |
| 241 | testcase TC_chan_act_ack_noest() runs on test_CT { |
| 242 | var RSL_Message rx_rsl; |
| 243 | |
| 244 | f_init(); |
| 245 | f_bssap_reset(); |
| 246 | |
| 247 | /* Send CHAN RQD and wait for allocation; acknowledge it */ |
| 248 | f_ipa_tx(0, ts_RSL_CHAN_RQD('23'O, 23)); |
| 249 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV)); |
| 250 | var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr; |
| 251 | f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 23)); |
| 252 | |
| 253 | /* expect BSC to disable the channel again if there's no RLL EST IND */ |
| 254 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX); |
| 255 | |
| 256 | setverdict(pass); |
| 257 | } |
| 258 | |
| 259 | /* Test behavior if MSC never answers to CR */ |
| 260 | testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT { |
| 261 | var RSL_Message rx_rsl; |
| 262 | |
| 263 | f_init(); |
| 264 | f_bssap_reset(); |
| 265 | |
| 266 | /* Send CHAN RQD and wait for allocation; acknowledge it */ |
| 267 | f_ipa_tx(0, ts_RSL_CHAN_RQD('23'O, 23)); |
| 268 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV)); |
| 269 | var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr; |
| 270 | f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 23)); |
| 271 | |
| 272 | var octetstring l3 := '00010203040506'O |
| 273 | f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3)); |
| 274 | |
| 275 | BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))); |
| 276 | |
| 277 | /* expect BSC to disable the channel again if there's no response from MSC */ |
| 278 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX); |
| 279 | |
| 280 | setverdict(pass); |
| 281 | } |
| 282 | |
| 283 | /* Test behavior if MSC answers with CREF to CR */ |
| 284 | testcase TC_chan_act_ack_est_ind_refused() runs on test_CT { |
| 285 | var BSSAP_N_CONNECT_ind rx_c_ind; |
| 286 | var RSL_Message rx_rsl; |
| 287 | |
| 288 | f_init(); |
| 289 | f_bssap_reset(); |
| 290 | |
| 291 | /* Send CHAN RQD and wait for allocation; acknowledge it */ |
| 292 | f_ipa_tx(0, ts_RSL_CHAN_RQD('23'O, 23)); |
| 293 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV)); |
| 294 | var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr; |
| 295 | f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 23)); |
| 296 | |
| 297 | var octetstring l3 := '00010203040506'O |
| 298 | f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3)); |
| 299 | |
| 300 | BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind; |
| 301 | BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0)); |
| 302 | |
| 303 | /* expect BSC to disable the channel */ |
| 304 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX); |
| 305 | |
| 306 | setverdict(pass); |
| 307 | } |
| 308 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 309 | type record DchanTuple { |
| 310 | integer sccp_conn_id, |
| 311 | RslChannelNr rsl_chan_nr |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 312 | } |
| 313 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 314 | /* helper function to establish a dedicated channel via BTS and MSC */ |
| 315 | function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3) |
| 316 | runs on test_CT return DchanTuple { |
| 317 | var BSSAP_N_CONNECT_ind rx_c_ind; |
| 318 | var RSL_Message rx_rsl; |
| 319 | var DchanTuple dt; |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 320 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 321 | /* Send CHAN RQD and wait for allocation; acknowledge it */ |
| 322 | f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn)); |
| 323 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV)); |
| 324 | dt.rsl_chan_nr := rx_rsl.ies[0].body.chan_nr; |
| 325 | f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(dt.rsl_chan_nr, fn+1)); |
| 326 | |
| 327 | f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3)); |
| 328 | |
| 329 | BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind; |
| 330 | dt.sccp_conn_id := rx_c_ind.connectionId; |
| 331 | BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id)); |
| 332 | |
| 333 | return dt; |
Harald Welte | a5d2ab2 | 2017-12-09 14:21:42 +0100 | [diff] [blame] | 334 | } |
| 335 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 336 | /* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */ |
| 337 | testcase TC_chan_rel_rll_rel_ind() runs on test_CT { |
| 338 | var RSL_Message rx_rsl; |
| 339 | var DchanTuple dt; |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 340 | |
| 341 | f_init(); |
| 342 | f_bssap_reset(); |
| 343 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 344 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 345 | |
| 346 | /* simulate RLL REL IND */ |
| 347 | f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)))); |
| 348 | |
| 349 | /* expect BSC to disable the channel */ |
| 350 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX); |
| 351 | /* respond with CHAN REL ACK */ |
| 352 | f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr)); |
| 353 | |
| 354 | /* expect DISC_IND on MSC side */ |
| 355 | BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)); |
| 356 | |
| 357 | setverdict(pass); |
| 358 | } |
| 359 | |
| 360 | /* Test behavior of channel release after CONN FAIL IND from BTS */ |
| 361 | testcase TC_chan_rel_conn_fail() runs on test_CT { |
| 362 | var BSSAP_N_DATA_ind rx_di; |
| 363 | var RSL_Message rx_rsl; |
| 364 | var DchanTuple dt; |
| 365 | |
| 366 | f_init(); |
| 367 | f_bssap_reset(); |
| 368 | |
| 369 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 370 | |
| 371 | /* simulate CONN FAIL IND */ |
| 372 | f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, 0)); |
| 373 | /* TODO: different cause values? */ |
| 374 | |
| 375 | /* expect BSC to disable the channel */ |
| 376 | rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX); |
| 377 | /* respond with CHAN REL ACK */ |
| 378 | f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr)); |
| 379 | |
| 380 | /* expect Clear Request from BSC */ |
| 381 | BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di; |
| 382 | |
| 383 | /* Instruct BSC to clear channel */ |
| 384 | var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue); |
| 385 | BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause))); |
| 386 | |
| 387 | /* expect Clear Complete from BSC */ |
| 388 | BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)); |
| 389 | |
| 390 | /* release the SCCP connection */ |
| 391 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 392 | |
| 393 | /* wait for SCCP emulation to do its job */ |
| 394 | f_sleep(1.0); |
| 395 | |
| 396 | setverdict(pass); |
| 397 | } |
| 398 | |
| 399 | /* Test behavior of channel release after hard Clear Command from MSC */ |
| 400 | testcase TC_chan_rel_hard_clear() runs on test_CT { |
| 401 | var BSSAP_N_DATA_ind rx_di; |
| 402 | var RSL_Message rx_rsl; |
| 403 | var DchanTuple dt; |
| 404 | var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0)); |
| 405 | |
| 406 | f_init(); |
| 407 | f_bssap_reset(); |
| 408 | |
| 409 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 410 | |
| 411 | /* Instruct BSC to clear channel */ |
| 412 | var BssmapCause cause := 0; |
| 413 | BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause))); |
| 414 | |
| 415 | /* expect Clear Complete from BSC on A */ |
| 416 | BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) { |
| 417 | /* release the SCCP connection */ |
| 418 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 419 | } |
| 420 | |
| 421 | /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */ |
| 422 | IPA_RSL[0].clear; |
| 423 | alt { |
| 424 | /* ignore DEACTIVATE SACCH (if any) */ |
| 425 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, |
| 426 | tr_RSL_DEACT_SACCH(dt.rsl_chan_nr))) { |
| 427 | repeat; |
| 428 | } |
| 429 | /* acknowledge RLL release (if any)*/ |
| 430 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, |
| 431 | tr_RSL_REL_REQ(dt.rsl_chan_nr, ?))) { |
| 432 | /* FIXME: Why are we getting this for LinkID SACCH? */ |
| 433 | f_ipa_tx(0, ts_RSL_REL_CONF(dt.rsl_chan_nr, main_dcch)); |
| 434 | repeat; |
| 435 | } |
| 436 | /* Expect RF channel release from BSC on Abis */ |
| 437 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, |
| 438 | tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) { |
| 439 | /* respond with CHAN REL ACK */ |
| 440 | f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr)); |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | setverdict(pass); |
| 445 | } |
| 446 | |
Harald Welte | d8c36cd | 2017-12-09 23:05:31 +0100 | [diff] [blame] | 447 | /* Test behavior of channel release after hard RLSD from MSC */ |
| 448 | testcase TC_chan_rel_hard_rlsd() runs on test_CT { |
| 449 | var RSL_Message rx_rsl; |
| 450 | var DchanTuple dt; |
| 451 | var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0)); |
| 452 | |
| 453 | f_init(); |
| 454 | f_bssap_reset(); |
| 455 | |
| 456 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 457 | |
| 458 | /* release the SCCP connection */ |
| 459 | BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0)); |
| 460 | |
| 461 | /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */ |
| 462 | IPA_RSL[0].clear; |
| 463 | alt { |
| 464 | /* ignore DEACTIVATE SACCH (if any) */ |
| 465 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, |
| 466 | tr_RSL_DEACT_SACCH(dt.rsl_chan_nr))) { |
| 467 | repeat; |
| 468 | } |
| 469 | /* acknowledge RLL release (if any)*/ |
| 470 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, |
| 471 | tr_RSL_REL_REQ(dt.rsl_chan_nr, ?))) { |
| 472 | /* FIXME: Why are we getting this for LinkID SACCH? */ |
| 473 | f_ipa_tx(0, ts_RSL_REL_CONF(dt.rsl_chan_nr, main_dcch)); |
| 474 | repeat; |
| 475 | } |
| 476 | /* Expect RF channel release from BSC on Abis */ |
| 477 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, |
| 478 | tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) { |
| 479 | /* respond with CHAN REL ACK */ |
| 480 | f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr)); |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | setverdict(pass); |
| 485 | } |
| 486 | |
Harald Welte | 85804d4 | 2017-12-10 14:11:58 +0100 | [diff] [blame] | 487 | /* Test behavior of channel release after BSSMAP RESET from MSC */ |
| 488 | testcase TC_chan_rel_a_reset() runs on test_CT { |
| 489 | var RSL_Message rx_rsl; |
| 490 | var DchanTuple dt; |
| 491 | var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0)); |
| 492 | |
| 493 | f_init(); |
| 494 | f_bssap_reset(); |
| 495 | |
| 496 | dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 497 | |
| 498 | /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */ |
| 499 | IPA_RSL[0].clear; |
| 500 | |
| 501 | /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */ |
| 502 | BSSAP.send(ts_BSSAP_UNITDATA_req(g_sccp_addr_peer, g_sccp_addr_own, ts_BSSMAP_Reset(0))); |
| 503 | interleave { |
| 504 | [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_sccp_addr_own, g_sccp_addr_peer, tr_BSSMAP_ResetAck)) { } |
| 505 | [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { } |
| 506 | } |
| 507 | |
| 508 | alt { |
| 509 | /* ignore DEACTIVATE SACCH (if any) */ |
| 510 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, |
| 511 | tr_RSL_DEACT_SACCH(dt.rsl_chan_nr))) { |
| 512 | repeat; |
| 513 | } |
| 514 | /* acknowledge RLL release (if any)*/ |
| 515 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, |
| 516 | tr_RSL_REL_REQ(dt.rsl_chan_nr, ?))) { |
| 517 | /* FIXME: Why are we getting this for LinkID SACCH? */ |
| 518 | f_ipa_tx(0, ts_RSL_REL_CONF(dt.rsl_chan_nr, main_dcch)); |
| 519 | repeat; |
| 520 | } |
| 521 | /* Expect RF channel release from BSC on Abis */ |
| 522 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, |
| 523 | tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) { |
| 524 | /* respond with CHAN REL ACK */ |
| 525 | f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr)); |
| 526 | } |
| 527 | /* ignore any user data */ |
| 528 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0, tr_RSL_MsgTypeR(?))) { |
| 529 | repeat; |
| 530 | } |
| 531 | } |
| 532 | |
| 533 | setverdict(pass); |
| 534 | } |
| 535 | |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 536 | |
| 537 | testcase TC_ctrl_msc_connection_status() runs on test_CT { |
| 538 | var charstring ctrl_resp; |
| 539 | |
| 540 | f_init(); |
| 541 | f_bssap_reset(); |
| 542 | |
| 543 | /* See https://osmocom.org/issues/2729 */ |
| 544 | f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected"); |
| 545 | setverdict(pass); |
| 546 | } |
| 547 | |
| 548 | testcase TC_ctrl() runs on test_CT { |
| 549 | var charstring ctrl_resp; |
| 550 | |
| 551 | f_init(); |
| 552 | f_bssap_reset(); |
| 553 | |
| 554 | /* all below values must match the osmo-bsc.cfg config file used */ |
| 555 | |
| 556 | f_ctrl_get_exp(IPA_CTRL, "mcc", "1"); |
| 557 | f_ctrl_get_exp(IPA_CTRL, "mnc", "1"); |
| 558 | f_ctrl_get_exp(IPA_CTRL, "short-name", "OsmoBSC"); |
| 559 | f_ctrl_get_exp(IPA_CTRL, "long-name", "OsmoBSC"); |
| 560 | f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "1"); |
| 561 | |
| 562 | var integer bts_nr := 0; |
| 563 | f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1"); |
| 564 | f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0"); |
| 565 | f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected"); |
| 566 | f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs"); |
| 567 | f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on"); |
| 568 | f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871"); |
| 569 | f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20"); |
| 570 | |
| 571 | var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")); |
| 572 | f_sleep(2.0); |
| 573 | if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) { |
| 574 | setverdict(fail, "oml-uptime not incrementing as expected"); |
| 575 | } |
| 576 | /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */ |
| 577 | |
| 578 | f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0); |
| 579 | |
| 580 | setverdict(pass); |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 581 | } |
| 582 | |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 583 | |
| 584 | |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 585 | control { |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 586 | execute( TC_ctrl_msc_connection_status() ); |
Harald Welte | 96c9441 | 2017-12-09 03:12:45 +0100 | [diff] [blame] | 587 | execute( TC_ctrl() ); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 588 | execute( TC_chan_act_noreply() ); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 589 | execute( TC_chan_act_counter() ); |
Harald Welte | ae02669 | 2017-12-09 01:03:01 +0100 | [diff] [blame] | 590 | execute( TC_chan_act_ack_noest() ); |
| 591 | execute( TC_chan_act_ack_est_ind_noreply() ); |
| 592 | execute( TC_chan_act_ack_est_ind_refused() ); |
Harald Welte | 4003d11 | 2017-12-09 22:35:39 +0100 | [diff] [blame] | 593 | execute( TC_chan_rel_rll_rel_ind() ); |
| 594 | execute( TC_chan_rel_conn_fail() ); |
| 595 | execute( TC_chan_rel_hard_clear() ); |
Harald Welte | d8c36cd | 2017-12-09 23:05:31 +0100 | [diff] [blame] | 596 | execute( TC_chan_rel_hard_rlsd() ); |
Harald Welte | 85804d4 | 2017-12-10 14:11:58 +0100 | [diff] [blame] | 597 | execute( TC_chan_rel_a_reset() ); |
Harald Welte | 28d943e | 2017-11-25 15:00:50 +0100 | [diff] [blame] | 598 | } |
| 599 | |
| 600 | } |