Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 1 | module BSC_Tests_CBSP { |
| 2 | |
| 3 | /* CBSP Integration Tests for OsmoBSC |
| 4 | * (C) 2019 by Harald Welte <laforge@gnumonks.org> |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Released under the terms of GNU General Public License, Version 2 or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 11 | * |
| 12 | * This test suite tests OsmoBSC while emulating the CBC (Cell Broadcast Centre) |
| 13 | */ |
| 14 | |
| 15 | import from General_Types all; |
| 16 | import from Osmocom_Types all; |
| 17 | import from GSM_Types all; |
| 18 | import from IPL4asp_Types all; |
| 19 | import from BSSAP_Types all; |
| 20 | import from BSSMAP_Templates all; |
| 21 | |
| 22 | import from BSC_Tests all; |
| 23 | |
| 24 | import from IPA_Emulation all; |
| 25 | import from IPA_CodecPort all; |
| 26 | import from IPA_Types all; |
| 27 | |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 28 | import from MobileL3_Types all; |
| 29 | import from MobileL3_RRM_Types all; |
| 30 | import from L3_Templates all; |
| 31 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 32 | import from RSL_Types all; |
| 33 | import from RSL_Emulation all; |
| 34 | |
| 35 | import from CBSP_Types all; |
| 36 | import from CBSP_Templates all; |
| 37 | import from CBSP_Adapter all; |
| 38 | import from CBSP_CodecPort all; |
| 39 | |
| 40 | modulepar { |
| 41 | charstring mp_cbc_ip := "0.0.0.0"; |
| 42 | integer mp_cbc_port := 48049; |
| 43 | integer mp_bsc_cbsp_port := 48050; |
| 44 | |
Harald Welte | 49a61e6 | 2020-03-30 20:13:32 +0200 | [diff] [blame] | 45 | /* BTS 0: 001-01-1-0 with CBCH |
| 46 | * BTS 1: 001-01-1-1 with CBCH |
| 47 | * BTS 2: 001-01-2-1 with CBCH |
| 48 | * BTS 3: 001-01-2-3 without CBCH */ |
| 49 | GsmCgiAbstract mp_cgi_bts0 := { '001'H, '01'H, 1, 0 }; |
| 50 | GsmCgiAbstract mp_cgi_bts1 := { '001'H, '01'H, 1, 1 }; |
| 51 | GsmCgiAbstract mp_cgi_bts2 := { '001'H, '01'H, 2, 1 }; |
| 52 | GsmCgiAbstract mp_cgi_bts3 := { '001'H, '01'H, 2, 3 }; |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | private type record GsmCgiAbstract { |
| 56 | GsmMcc mcc, |
| 57 | GsmMnc mnc, |
| 58 | GsmLac lac, |
| 59 | GsmCellId ci |
| 60 | }; |
| 61 | private template (value) BSSMAP_FIELD_CellIdentification_CGI bssmap_cgi(GsmCgiAbstract cgi) := |
| 62 | ts_BSSMAP_CI_CGI(cgi.mcc, cgi.mnc, cgi.lac, cgi.ci); |
| 63 | private template (value) BSSMAP_FIELD_CellIdentification_LAC_CI bssmap_lac_ci(GsmCgiAbstract cgi) := |
| 64 | ts_BSSMAP_CI_LAC_CI(cgi.lac, cgi.ci); |
| 65 | private template (value) BSSMAP_FIELD_CellIdentification_LAI bssmap_lai(GsmCgiAbstract cgi) := |
| 66 | ts_BSSMAP_CI_LAI(cgi.mcc, cgi.mnc, cgi.lac); |
| 67 | private template (value) OCT2 bssmap_lac(GsmCgiAbstract cgi) := ts_BSSMAP_CI_LAC(cgi.lac); |
| 68 | private template (value) OCT2 bssmap_ci(GsmCgiAbstract cgi) := ts_BSSMAP_CI_CI(cgi.ci); |
| 69 | |
| 70 | type component cbsp_test_CT extends test_CT, CBSP_Adapter_CT { |
| 71 | } |
| 72 | |
| 73 | private altstep as_IgnRSL(template RSL_Message tr) runs on cbsp_test_CT { |
| 74 | [] IPA_RSL[0].receive(tr_RSL_UD(tr)) { repeat; } |
| 75 | [] IPA_RSL[1].receive(tr_RSL_UD(tr)) { repeat; } |
| 76 | [] IPA_RSL[2].receive(tr_RSL_UD(tr)) { repeat; } |
| 77 | } |
| 78 | |
| 79 | private altstep as_FailRSL() runs on cbsp_test_CT { |
| 80 | var template RSL_Message tr := (tr_RSL_SMSCB_CMD); |
| 81 | var ASP_RSL_Unitdata rx; |
| 82 | [] IPA_RSL[0].receive(tr_RSL_UD(tr)) -> value rx { |
| 83 | setverdict(fail, "Received unexpected RSL ", rx); |
| 84 | mtc.stop; |
| 85 | } |
| 86 | [] IPA_RSL[1].receive(tr_RSL_UD(tr)) -> value rx { |
| 87 | setverdict(fail, "Received unexpected RSL ", rx); |
| 88 | mtc.stop; |
| 89 | } |
| 90 | [] IPA_RSL[2].receive(tr_RSL_UD(tr)) -> value rx { |
| 91 | setverdict(fail, "Received unexpected RSL ", rx); |
| 92 | mtc.stop; |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | private function f_init() runs on cbsp_test_CT { |
| 97 | BSC_Tests.f_init(); |
| 98 | activate(as_IgnRSL((tr_RSL_BCCH_INFO, tr_RSL_SACCH_FILL, |
| 99 | tr_RSL_NO_BCCH_INFO, tr_RSL_NO_SACCH_FILL, |
| 100 | tr_RSL_MsgTypeD(?)))); |
| 101 | activate(as_FailRSL()); |
| 102 | } |
| 103 | private function f_cbsp_init_client() runs on cbsp_test_CT { |
| 104 | f_init(); |
| 105 | CBSP_Adapter.f_connect(mp_bsc_ip, mp_bsc_cbsp_port, "", -1); |
| 106 | f_cbsp_init_tail(); |
| 107 | } |
| 108 | |
| 109 | private function f_cbsp_init_server() runs on cbsp_test_CT { |
| 110 | var ASP_Event asp_evt; |
| 111 | timer T := 10.0; |
| 112 | |
| 113 | f_init(); |
| 114 | CBSP_Adapter.f_bind(mp_cbc_ip, mp_cbc_port); |
| 115 | |
| 116 | T.start; |
| 117 | alt { |
| 118 | [] CBSP[0].receive(ASP_Event:{connOpened:=?}) -> value asp_evt { |
| 119 | g_cbsp_conn_id[0] := asp_evt.connOpened.connId; |
| 120 | } |
| 121 | [] T.timeout { |
| 122 | setverdict(fail, "Timeout waiting for incoming connection to CBSP Port"); |
| 123 | } |
| 124 | } |
| 125 | f_cbsp_init_tail(); |
| 126 | } |
| 127 | private function f_cbsp_init_tail() runs on cbsp_test_CT { |
| 128 | interleave { |
| 129 | [] CBSP[0].receive(tr_CBSP_Recv(?, tr_CBSP_RESTART(?, CBSP_BC_MSGT_CBS, CBSP_RI_DATA_LOST))); |
| 130 | /* should we also expect a restart for emergency related messages? */ |
| 131 | //[] CBSP[0].receive(tr_CBSP_Recv(?, tr_CBSP_RESTART(?, CBSP_BC_MSGT_EMERG, CBSP_RI_DATA_LOST))); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | function f_gen_page() return CBSP_IE { |
| 136 | var integer len := f_rnd_int(82); |
| 137 | var octetstring payload := f_rnd_octstring(len); |
| 138 | return valueof(ts_CbspMsgContent(payload, len)); |
| 139 | } |
| 140 | |
| 141 | function f_cbsp_reset_bss(integer idx) runs on CBSP_Adapter_CT { |
| 142 | var template (value) CBSP_PDU tx; |
| 143 | timer T := 3.0; |
| 144 | tx := ts_CBSP_RESET(cell_list := ts_BSSMAP_CIL_BSS); |
| 145 | CBSP[idx].clear; |
| 146 | CBSP[idx].send(ts_CBSP_Send(g_cbsp_conn_id[idx], tx)); |
| 147 | T.start; |
| 148 | alt { |
| 149 | [] CBSP[idx].receive(tr_CBSP_Recv(?, tr_CBSP_RESET_COMPL(cell_list := ts_BSSMAP_CIL_BSS))); |
| 150 | [] CBSP[idx].receive { |
| 151 | setverdict(fail, "received unexpected CBSP"); |
| 152 | mtc.stop; |
| 153 | } |
| 154 | [] T.timeout { |
| 155 | setverdict(fail, "timeout waiting for RESET COMPLETE"); |
| 156 | mtc.stop; |
| 157 | } |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | /* send a WRITE CBS to the BSC; expect either COMPLETE or FAILURE in response*/ |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 162 | function f_cbsp_write_emerg(uint16_t msg_id, uint16_t ser_no, |
| 163 | template (value) BSSMAP_FIELD_CellIdentificationList cell_list := ts_BSSMAP_CIL_BSS, |
| 164 | template (value) uint8_t emerg_ind := 1, |
| 165 | template (value) uint16_t warn_type := oct2int('0780'O), |
| 166 | template (value) uint16_t warn_per := 5, |
| 167 | template BSSMAP_FIELD_CellIdentificationList success_list := ?, |
| 168 | template CBSP_FailureListItems fail_list := omit) runs on cbsp_test_CT { |
| 169 | var template (value) CBSP_PDU tx; |
| 170 | var template CBSP_PDU rx; |
| 171 | var CBSP_IEs pages := {f_gen_page()}; |
| 172 | |
| 173 | tx := ts_CBSP_WRITE_EMERG(msg_id, ser_no, cell_list, emerg_ind, warn_type, warn_per); |
| 174 | CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx)); |
| 175 | if (istemplatekind(fail_list, "omit")) { |
| 176 | rx := tr_CBSP_WRITE_CBS_COMPL(msg_id, ser_no, success_list, omit); |
| 177 | } else { |
| 178 | rx := tr_CBSP_WRITE_CBS_FAIL(msg_id, ser_no, fail_list, *, success_list, omit); |
| 179 | } |
| 180 | alt { |
| 181 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx)) { |
| 182 | setverdict(pass); |
| 183 | } |
| 184 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) { |
| 185 | setverdict(fail, "Received unexpected CBSP"); |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | /* send a WRITE CBS to the BSC; expect either COMPLETE or FAILURE in response*/ |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 191 | function f_cbsp_write(uint16_t msg_id, uint16_t ser_no, |
| 192 | template (value) BSSMAP_FIELD_CellIdentificationList cell_list := ts_BSSMAP_CIL_BSS, |
| 193 | template (value) CBSP_Category category := CBSP_CATEG_NORMAL, |
| 194 | uint16_t rep_period := 10, uint16_t num_bcast_req := 1, |
| 195 | uint8_t dcs := 0, uint8_t channel_ind := 0, CBSP_IEs content, |
| 196 | template BSSMAP_FIELD_CellIdentificationList success_list := ?, |
| 197 | template CBSP_FailureListItems fail_list := omit) runs on cbsp_test_CT { |
| 198 | var template (value) CBSP_PDU tx; |
| 199 | var template CBSP_PDU rx; |
| 200 | var CBSP_IEs pages := {f_gen_page()}; |
| 201 | |
| 202 | tx := ts_CBSP_WRITE_CBS(msg_id, ser_no, cell_list, channel_ind, category, |
| 203 | rep_period, num_bcast_req, dcs, content); |
| 204 | CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx)); |
| 205 | if (istemplatekind(fail_list, "omit")) { |
| 206 | rx := tr_CBSP_WRITE_CBS_COMPL(msg_id, ser_no, success_list, channel_ind); |
| 207 | } else { |
| 208 | rx := tr_CBSP_WRITE_CBS_FAIL(msg_id, ser_no, fail_list, *, success_list, channel_ind); |
| 209 | } |
| 210 | alt { |
| 211 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx)) { |
| 212 | setverdict(pass); |
| 213 | } |
| 214 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) { |
| 215 | setverdict(fail, "Received unexpected CBSP"); |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | /* send a REPLACE CBS to the BSC; expect either COMPLETE or FAILURE in response*/ |
| 221 | function f_cbsp_replace(uint16_t msg_id, uint16_t new_ser_no, uint16_t old_ser_no, |
| 222 | template (value) BSSMAP_FIELD_CellIdentificationList cell_list := ts_BSSMAP_CIL_BSS, |
| 223 | template (value) CBSP_Category category := CBSP_CATEG_NORMAL, |
| 224 | uint16_t rep_period := 10, uint16_t num_bcast_req := 1, |
| 225 | uint8_t dcs := 0, uint8_t channel_ind := 0, CBSP_IEs content, |
| 226 | template BSSMAP_FIELD_CellIdentificationList success_list := ?, |
| 227 | template CBSP_FailureListItems fail_list := omit) runs on cbsp_test_CT { |
| 228 | var template (value) CBSP_PDU tx; |
| 229 | var template CBSP_PDU rx; |
| 230 | var CBSP_IEs pages := {f_gen_page()}; |
| 231 | |
| 232 | tx := ts_CBSP_REPLACE_CBS(msg_id, new_ser_no, old_ser_no, cell_list, channel_ind, category, |
| 233 | rep_period, num_bcast_req, dcs, content); |
| 234 | CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx)); |
| 235 | if (istemplatekind(fail_list, "omit")) { |
| 236 | rx := tr_CBSP_REPLACE_CBS_COMPL(msg_id, new_ser_no, old_ser_no, ?, success_list, |
| 237 | channel_ind); |
| 238 | } else { |
| 239 | rx := tr_CBSP_REPLACE_CBS_FAIL(msg_id, new_ser_no, old_ser_no, fail_list, *, success_list, |
| 240 | channel_ind); |
| 241 | } |
| 242 | alt { |
| 243 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx)) { |
| 244 | setverdict(pass); |
| 245 | } |
| 246 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) { |
| 247 | setverdict(fail, "Received unexpected CBSP"); |
| 248 | } |
| 249 | } |
| 250 | } |
| 251 | /* send a KILL CBS to the BSC; expect either COMPLETE or FAILURE in response*/ |
| 252 | function f_cbsp_kill(uint16_t msg_id, uint16_t ser_no, template (omit) uint8_t channel_ind := 0, |
| 253 | template (value) BSSMAP_FIELD_CellIdentificationList cell_list := ts_BSSMAP_CIL_BSS, |
| 254 | template BSSMAP_FIELD_CellIdentificationList success_list := ?, |
| 255 | template CBSP_FailureListItems fail_list := omit) runs on cbsp_test_CT |
| 256 | { |
| 257 | var template (value) CBSP_PDU tx; |
| 258 | var template CBSP_PDU rx; |
| 259 | |
| 260 | tx := ts_CBSP_KILL(msg_id, ser_no, cell_list, channel_ind); |
| 261 | CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx)); |
| 262 | if (istemplatekind(fail_list, "omit")) { |
| 263 | rx := tr_CBSP_KILL_COMPL(msg_id, ser_no, compl_list:=*, cell_list:=success_list, |
| 264 | channel_ind:=channel_ind); |
| 265 | } else { |
| 266 | rx := tr_CBSP_KILL_FAIL(msg_id, ser_no, fail_list, compl_list:=*, cell_list:=success_list, |
| 267 | channel_ind:=channel_ind); |
| 268 | } |
| 269 | alt { |
| 270 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx)) { |
| 271 | setverdict(pass); |
| 272 | } |
| 273 | [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) { |
| 274 | setverdict(fail, "Received unexpected CBSP"); |
| 275 | } |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | private template (present) ASP_RSL_Unitdata tr_RSL_UD(template (present) RSL_Message rsl) := { |
| 280 | streamId := ?, |
| 281 | rsl := rsl |
| 282 | } |
| 283 | |
| 284 | template (present) RSL_IE_CbCommandType |
| 285 | tr_RslCbCmdType(template (present) uint2_t lblock := ?, template (present) RSL_CbCommand cmd := ?) := { |
| 286 | command := cmd, |
| 287 | default_bcast_null := ?, |
| 288 | spare := ?, |
| 289 | last_block := lblock |
| 290 | } |
| 291 | |
| 292 | /* build a RSL_Message receive template from a CBSP page */ |
| 293 | private function f_page2rsl(CBSP_IE page, uint16_t msg_id, uint16_t ser_no, boolean ext_cbch := false) |
| 294 | return template (present) RSL_Message |
| 295 | { |
| 296 | var template RSL_Message tr; |
| 297 | var integer lblock := page.body.msg_content.user_len / 22; |
| 298 | var octetstring payload; |
| 299 | if (page.body.msg_content.user_len mod 22 > 0) { |
| 300 | lblock := lblock + 1; |
| 301 | } |
| 302 | payload := int2oct(ser_no, 2) & int2oct(msg_id, 2) & '0011'O & page.body.msg_content.val; |
| 303 | tr := tr_RSL_SMSCB_CMD(tr_RslCbCmdType(lblock), f_pad_oct(payload, 88, '00'O)); |
| 304 | if (ext_cbch) { |
| 305 | tr.ies[3] := tr_RSL_IE(RSL_IE_Body:{smscb_chan_ind := 1}); |
| 306 | tr.ies[4] := *; |
| 307 | } |
| 308 | return tr; |
| 309 | } |
| 310 | |
| 311 | /*********************************************************************** |
| 312 | * Test Cases |
| 313 | ***********************************************************************/ |
| 314 | |
| 315 | /* Test if BSC (server) accepts connections from CBC (client) */ |
| 316 | testcase TC_cbsp_bsc_server() runs on cbsp_test_CT { |
| 317 | f_cbsp_init_client(); |
| 318 | setverdict(pass); |
| 319 | } |
| 320 | |
| 321 | /* Test if BSC (client) is connecting to CBC (server) */ |
| 322 | testcase TC_cbsp_bsc_client() runs on cbsp_test_CT { |
| 323 | f_cbsp_init_server(); |
| 324 | setverdict(pass); |
| 325 | } |
| 326 | |
| 327 | /* Test if a BSS-global RESET is executed successfully */ |
| 328 | testcase TC_cbsp_reset_bss() runs on cbsp_test_CT { |
| 329 | f_cbsp_init_server(); |
| 330 | |
| 331 | f_cbsp_reset_bss(0); |
| 332 | setverdict(pass); |
| 333 | } |
| 334 | |
| 335 | testcase TC_cbsp_write() runs on cbsp_test_CT { |
| 336 | var template (value) CBSP_PDU tx; |
| 337 | var CBSP_IEs pages := {f_gen_page()}; |
| 338 | f_cbsp_init_server(); |
| 339 | |
| 340 | tx := ts_CBSP_WRITE_CBS(msg_id:=23, new_ser_nr:=42, cell_list:=ts_BSSMAP_CIL_BSS, |
| 341 | channel_ind:=0, category:=CBSP_CATEG_NORMAL, |
| 342 | rep_period:=10, num_bcast_req:=1, dcs := 0, |
| 343 | content:=pages); |
| 344 | |
| 345 | CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx)); |
| 346 | f_sleep(10.0); |
| 347 | } |
| 348 | |
| 349 | /* Write to entire BSS; three cells succeed; one fails (no CBCH) */ |
| 350 | testcase TC_cbsp_write_bss() runs on cbsp_test_CT { |
| 351 | var CBSP_IEs pages := {f_gen_page()}; |
| 352 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 353 | cell_list := ts_BSSMAP_CIL_BSS; |
| 354 | f_cbsp_init_server(); |
| 355 | f_cbsp_write(1, 1001, cell_list, content:=pages, |
| 356 | success_list:=tr_BSSMAP_CIL_CGI({?,?,?}), fail_list:={?}); |
| 357 | |
| 358 | var template RSL_Message tr := f_page2rsl(pages[0], 1, 1001); |
| 359 | interleave { |
| 360 | [] IPA_RSL[0].receive(tr_RSL_UD(tr)) {} |
| 361 | [] IPA_RSL[1].receive(tr_RSL_UD(tr)) {} |
| 362 | [] IPA_RSL[2].receive(tr_RSL_UD(tr)) {} |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | /* Write to single BTS supporting CBCH: success */ |
| 367 | testcase TC_cbsp_write_bts_cgi() runs on cbsp_test_CT { |
| 368 | var CBSP_IEs pages := {f_gen_page()}; |
| 369 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 370 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}); |
| 371 | f_cbsp_init_server(); |
| 372 | f_cbsp_write(2, 1002, cell_list, content:=pages, |
| 373 | success_list:=cell_list, fail_list:=omit); |
| 374 | var template RSL_Message tr := f_page2rsl(pages[0], 1, 1001); |
| 375 | IPA_RSL[0].receive(tr_RSL_UD(tr)); |
| 376 | f_sleep(5.0); |
| 377 | } |
| 378 | |
| 379 | /* Write to single BTS not supporting CBCH: failure */ |
| 380 | testcase TC_cbsp_write_bts_no_cbch() runs on cbsp_test_CT { |
| 381 | var CBSP_IEs pages := {f_gen_page()}; |
| 382 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 383 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts3)}); |
| 384 | f_cbsp_init_server(); |
| 385 | f_cbsp_write(3, 1003, cell_list, content:=pages, |
| 386 | success_list:=omit, fail_list:={?}); |
| 387 | f_sleep(5.0); |
| 388 | } |
| 389 | |
| 390 | /* Write to single non-existant BTS */ |
| 391 | testcase TC_cbsp_write_unknown_bts() runs on cbsp_test_CT { |
| 392 | var CBSP_IEs pages := {f_gen_page()}; |
| 393 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 394 | cell_list := ts_BSSMAP_CIL_CGI({ts_BSSMAP_CI_CGI(mp_cgi_bts0.mcc, mp_cgi_bts1.mnc, 22222, 33333)}); |
| 395 | f_cbsp_init_server(); |
| 396 | f_cbsp_write(4, 1004, cell_list, content:=pages, |
| 397 | success_list:=omit, fail_list:={?}); |
| 398 | f_sleep(5.0); |
| 399 | } |
| 400 | |
| 401 | /* Write to single BTS using LAC+CI */ |
| 402 | testcase TC_cbsp_write_lac_ci() runs on cbsp_test_CT { |
| 403 | var CBSP_IEs pages := {f_gen_page()}; |
| 404 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 405 | cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)}); |
| 406 | f_cbsp_init_server(); |
| 407 | f_cbsp_write(5, 1005, cell_list, content:=pages, |
| 408 | success_list:=?, fail_list:=omit); |
| 409 | IPA_RSL[0].receive(tr_RSL_UD(f_page2rsl(pages[0], 5, 1005))); |
| 410 | f_sleep(5.0); |
| 411 | } |
| 412 | |
| 413 | /* Write to single BTS using CI */ |
| 414 | testcase TC_cbsp_write_ci() runs on cbsp_test_CT { |
| 415 | var CBSP_IEs pages := {f_gen_page()}; |
| 416 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 417 | cell_list := ts_BSSMAP_CIL_CI({bssmap_ci(mp_cgi_bts0)}); |
| 418 | f_cbsp_init_server(); |
| 419 | f_cbsp_write(6, 1006, cell_list, content:=pages, |
| 420 | success_list:=?, fail_list:=omit); |
| 421 | IPA_RSL[0].receive(tr_RSL_UD(f_page2rsl(pages[0], 6, 1006))); |
| 422 | f_sleep(5.0); |
| 423 | } |
| 424 | |
| 425 | /* Write to single BTS using LAI */ |
| 426 | testcase TC_cbsp_write_lai() runs on cbsp_test_CT { |
| 427 | var CBSP_IEs pages := {f_gen_page()}; |
| 428 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 429 | cell_list := ts_BSSMAP_CIL_LAI({bssmap_lai(mp_cgi_bts0)}); |
| 430 | f_cbsp_init_server(); |
| 431 | f_cbsp_write(7, 1007, cell_list, content:=pages, |
| 432 | success_list:=?, fail_list:=omit); |
| 433 | IPA_RSL[0].receive(tr_RSL_UD(f_page2rsl(pages[0], 7, 1007))); |
| 434 | f_sleep(5.0); |
| 435 | } |
| 436 | |
| 437 | /* Write to two BTS using LAC */ |
| 438 | testcase TC_cbsp_write_lac() runs on cbsp_test_CT { |
| 439 | var CBSP_IEs pages := {f_gen_page()}; |
| 440 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 441 | cell_list := ts_BSSMAP_CIL_LAC({bssmap_lac(mp_cgi_bts0)}); |
| 442 | f_cbsp_init_server(); |
| 443 | f_cbsp_write(8, 1008, cell_list, content:=pages, |
| 444 | success_list:=?, fail_list:=omit); |
| 445 | var template RSL_Message tr := f_page2rsl(pages[0], 8, 1008); |
| 446 | interleave { |
| 447 | [] IPA_RSL[0].receive(tr_RSL_UD(tr)); |
| 448 | [] IPA_RSL[1].receive(tr_RSL_UD(tr)); |
| 449 | } |
| 450 | f_sleep(5.0); |
| 451 | } |
| 452 | |
| 453 | /* Write a message, then replace it */ |
| 454 | testcase TC_cbsp_write_then_replace() runs on cbsp_test_CT { |
| 455 | var CBSP_IEs pages := {f_gen_page()}; |
| 456 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 457 | cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)}); |
| 458 | f_cbsp_init_server(); |
| 459 | f_cbsp_write(9, 1009, cell_list, num_bcast_req:=10, content:=pages, |
| 460 | success_list:=?, fail_list:=omit); |
| 461 | f_cbsp_replace(9, 2009, 1009, cell_list, content:=pages, |
| 462 | success_list:=?, fail_list:=omit); |
| 463 | } |
| 464 | |
| 465 | /* Replace a message that doesn't exist: failure */ |
| 466 | testcase TC_cbsp_replace_nonexist() runs on cbsp_test_CT { |
| 467 | var CBSP_IEs pages := {f_gen_page()}; |
| 468 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 469 | cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)}); |
| 470 | f_cbsp_init_server(); |
| 471 | f_cbsp_replace(10, 2010, 1010, cell_list, content:=pages, |
| 472 | success_list:=omit, fail_list:=?); |
| 473 | } |
| 474 | |
| 475 | /* Write more messages than can be scheduled */ |
| 476 | testcase TC_cbsp_write_too_many() runs on cbsp_test_CT { |
| 477 | /* repeating three pages at an interval of 1 is impossible */ |
| 478 | var CBSP_IEs pages := {f_gen_page(), f_gen_page(), f_gen_page()}; |
| 479 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 480 | cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)}); |
| 481 | f_cbsp_init_server(); |
| 482 | f_cbsp_write(11, 1011, cell_list, rep_period:=1, content:=pages, |
| 483 | success_list:=omit, fail_list:=?); |
| 484 | } |
| 485 | |
| 486 | /* Kill message that doesn't exist: failure */ |
| 487 | testcase TC_cbsp_kill_nonexist() runs on cbsp_test_CT { |
| 488 | var CBSP_IEs pages := {f_gen_page()}; |
| 489 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 490 | cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)}); |
| 491 | f_cbsp_init_server(); |
| 492 | f_cbsp_kill(12, 1012, 0, cell_list, success_list:=omit, fail_list:=?); |
| 493 | } |
| 494 | /* Write a message, then kill it */ |
| 495 | testcase TC_cbsp_write_then_kill() runs on cbsp_test_CT { |
| 496 | var CBSP_IEs pages := {f_gen_page()}; |
| 497 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 498 | cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)}); |
| 499 | f_cbsp_init_server(); |
| 500 | f_cbsp_write(13, 1013, cell_list, content:=pages, success_list:=?, fail_list:=omit); |
| 501 | f_cbsp_kill(13, 1013, 0, cell_list, success_list:=?, fail_list:=omit); |
| 502 | } |
| 503 | |
| 504 | /* Write a message, then reset all messages */ |
| 505 | testcase TC_cbsp_write_then_reset() runs on cbsp_test_CT { |
| 506 | var CBSP_IEs pages := {f_gen_page()}; |
| 507 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 508 | cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)}); |
| 509 | f_cbsp_init_server(); |
| 510 | f_cbsp_write(14, 1014, cell_list, content:=pages, success_list:=?, fail_list:=omit); |
| 511 | f_cbsp_reset_bss(0); |
| 512 | } |
| 513 | |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 514 | private const octetstring c_ETWS_sec_default := |
| 515 | '00000000000000000000000000000000000000000000000000'O & |
| 516 | '00000000000000000000000000000000000000000000000000'O; |
| 517 | function f_gen_etws_pn(uint16_t ser_nr, uint16_t msg_id, OCT2 msg_type := '0780'O, |
| 518 | octetstring sec_inf := c_ETWS_sec_default) return octetstring { |
| 519 | return int2oct(ser_nr, 2) & int2oct(msg_id, 2) & msg_type & sec_inf; |
| 520 | } |
| 521 | |
| 522 | /* Write ETWS PN to single BTS; verify it arrives on DCHAN */ |
| 523 | testcase TC_cbsp_emerg_write_bts_cgi_dchan() runs on cbsp_test_CT { |
| 524 | var CBSP_IEs pages := {f_gen_page()}; |
| 525 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 526 | var ASP_RSL_Unitdata rx_rsl_ud; |
| 527 | |
| 528 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}); |
| 529 | f_cbsp_init_server(); |
| 530 | |
| 531 | /* first establish a dedicated channel */ |
| 532 | var DchanTuple dt := f_est_dchan('23'O, 23, '00010203040506'O); |
| 533 | |
| 534 | /* then send ETWS PN */ |
| 535 | f_cbsp_write_emerg(15, 1015, cell_list); |
| 536 | var template (present) octetstring tr_apdu := f_gen_etws_pn(1015, 15); |
| 537 | timer T := 5.0; |
| 538 | T.start; |
| 539 | alt { |
Vadim Yanitskiy | 9b4e356 | 2020-05-25 21:40:52 +0700 | [diff] [blame^] | 540 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_DATA_REQ(dt.rsl_chan_nr, ?, ?))) -> value rx_rsl_ud { |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 541 | var RSL_IE_Body l3_ie; |
| 542 | if (f_rsl_find_ie(rx_rsl_ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) { |
| 543 | setverdict(fail, "RSL DATA REQ without L3?"); |
| 544 | mtc.stop; |
| 545 | } |
| 546 | var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload); |
| 547 | var template (present) APDU_Flags_V tr_flags := { |
| 548 | lastSeg := '0'B, |
| 549 | firstSeg := '0'B, |
| 550 | cR := '0'B, |
| 551 | spare := '0'B |
| 552 | }; |
| 553 | if (match(l3, tr_RR_APP_INFO('0001'B, tr_apdu, tr_flags))) { |
| 554 | setverdict(pass); |
| 555 | } |
| 556 | } |
| 557 | [] IPA_RSL[0].receive { repeat; } |
| 558 | [] T.timeout { |
| 559 | setverdict(fail, "Waiting for APP INFO"); |
| 560 | } |
| 561 | } |
| 562 | } |
| 563 | |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 564 | /* Write ETWS PN to single BTS; verify it arrives on CCHAN */ |
| 565 | testcase TC_cbsp_emerg_write_bts_cgi_cchan() runs on cbsp_test_CT { |
| 566 | var CBSP_IEs pages := {f_gen_page()}; |
| 567 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 568 | var ASP_RSL_Unitdata rx_rsl_ud; |
| 569 | |
| 570 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}); |
| 571 | f_cbsp_init_server(); |
| 572 | |
| 573 | f_cbsp_write_emerg(16, 1016, cell_list); |
| 574 | var template (present) octetstring tr_apdu := f_gen_etws_pn(1016, 16); |
| 575 | timer T := 5.0; |
| 576 | T.start; |
| 577 | alt { |
Vadim Yanitskiy | 9b4e356 | 2020-05-25 21:40:52 +0700 | [diff] [blame^] | 578 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_OSMO_ETWS_CMD(t_RslChanNr_PCH_AGCH(0), tr_apdu))) { |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 579 | setverdict(pass); |
| 580 | } |
Vadim Yanitskiy | 9b4e356 | 2020-05-25 21:40:52 +0700 | [diff] [blame^] | 581 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_OSMO_ETWS_CMD(?,?))) { |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 582 | setverdict(fail, "Received unexpected OSMO_ETWS_CMD"); |
| 583 | } |
| 584 | [] IPA_RSL[0].receive { repeat; } |
| 585 | [] T.timeout { |
| 586 | setverdict(fail, "Timeout waiting for RSL_OSMO_ETWS_CMD"); |
| 587 | } |
| 588 | } |
| 589 | } |
| 590 | |
| 591 | /* Write ETWS PN to single BTS; verify it arrives on CCHAN */ |
| 592 | testcase TC_cbsp_emerg_write_bts_cgi_cchan_disable() runs on cbsp_test_CT { |
| 593 | var CBSP_IEs pages := {f_gen_page()}; |
| 594 | var template (value) BSSMAP_FIELD_CellIdentificationList cell_list; |
| 595 | var ASP_RSL_Unitdata rx_rsl_ud; |
| 596 | |
| 597 | cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)}); |
| 598 | f_cbsp_init_server(); |
| 599 | |
| 600 | f_cbsp_write_emerg(16, 1016, cell_list); |
| 601 | |
| 602 | /* first expect the PN to be enabled */ |
| 603 | var template (present) octetstring tr_apdu := f_gen_etws_pn(1016, 16); |
| 604 | timer T := 5.0; |
| 605 | T.start; |
| 606 | alt { |
Vadim Yanitskiy | 9b4e356 | 2020-05-25 21:40:52 +0700 | [diff] [blame^] | 607 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_OSMO_ETWS_CMD(t_RslChanNr_PCH_AGCH(0), tr_apdu))) { |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 608 | setverdict(pass); |
| 609 | } |
Vadim Yanitskiy | 9b4e356 | 2020-05-25 21:40:52 +0700 | [diff] [blame^] | 610 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_OSMO_ETWS_CMD(?,?))) { |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 611 | setverdict(fail, "Received unexpected OSMO_ETWS_CMD"); |
| 612 | } |
| 613 | [] IPA_RSL[0].receive { repeat; } |
| 614 | [] T.timeout { |
| 615 | setverdict(fail, "Timeout waiting for RSL_OSMO_ETWS_CMD (enable)"); |
| 616 | } |
| 617 | } |
| 618 | |
| 619 | /* then expect it to be disabled after the warning period (5s) */ |
| 620 | T.start; |
| 621 | alt { |
Vadim Yanitskiy | 9b4e356 | 2020-05-25 21:40:52 +0700 | [diff] [blame^] | 622 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_OSMO_ETWS_CMD(t_RslChanNr_PCH_AGCH(0), ''O))) { |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 623 | setverdict(pass); |
| 624 | } |
Vadim Yanitskiy | 9b4e356 | 2020-05-25 21:40:52 +0700 | [diff] [blame^] | 625 | [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_OSMO_ETWS_CMD(?,?))) { |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 626 | setverdict(fail, "Received unexpected OSMO_ETWS_CMD"); |
| 627 | } |
| 628 | [] IPA_RSL[0].receive { repeat; } |
| 629 | [] T.timeout { |
| 630 | setverdict(fail, "Timeout waiting for RSL_OSMO_ETWS_CMD (disable)"); |
| 631 | } |
| 632 | } |
| 633 | } |
| 634 | |
| 635 | |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 636 | |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 637 | control { |
| 638 | execute( TC_cbsp_bsc_server() ); |
| 639 | execute( TC_cbsp_bsc_client() ); |
| 640 | execute( TC_cbsp_reset_bss() ); |
| 641 | |
| 642 | /* test various different types of Cell Identities */ |
| 643 | execute( TC_cbsp_write_bss() ); |
| 644 | execute( TC_cbsp_write_bts_cgi() ); |
| 645 | execute( TC_cbsp_write_bts_no_cbch() ); |
| 646 | execute( TC_cbsp_write_unknown_bts() ); |
| 647 | execute( TC_cbsp_write_lac_ci() ); |
| 648 | execute( TC_cbsp_write_ci() ); |
| 649 | execute( TC_cbsp_write_lai() ); |
| 650 | execute( TC_cbsp_write_lac() ); |
| 651 | |
| 652 | execute( TC_cbsp_write_then_replace() ); |
| 653 | execute( TC_cbsp_replace_nonexist() ); |
| 654 | execute( TC_cbsp_write_too_many() ); |
| 655 | execute( TC_cbsp_kill_nonexist() ); |
| 656 | execute( TC_cbsp_write_then_kill() ); |
| 657 | execute( TC_cbsp_write_then_reset() ); |
Harald Welte | 187f7a9 | 2019-09-05 11:15:20 +0200 | [diff] [blame] | 658 | |
| 659 | execute( TC_cbsp_emerg_write_bts_cgi_dchan() ); |
Harald Welte | 0b5e0f9 | 2019-09-07 08:30:25 +0200 | [diff] [blame] | 660 | execute( TC_cbsp_emerg_write_bts_cgi_cchan() ); |
| 661 | execute( TC_cbsp_emerg_write_bts_cgi_cchan_disable() ); |
Harald Welte | 09538f8 | 2019-08-01 09:50:25 +0200 | [diff] [blame] | 662 | } |
| 663 | |
| 664 | |
| 665 | } |