Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 1 | module BTS_Tests_SMSCB { |
| 2 | |
| 3 | /* Integration Tests for OsmoBTS |
| 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 | * |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 10 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 11 | * |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 12 | * This test suite tests the SMSCB (Cell Broadcast) related functionality of |
| 13 | * OsmoBTS by attaching to the A-bis RSL and Um interface and emulating both |
| 14 | * BSC and MS. |
| 15 | */ |
| 16 | |
| 17 | import from Misc_Helpers all; |
| 18 | import from General_Types all; |
| 19 | import from Osmocom_Types all; |
| 20 | import from GSM_Types all; |
| 21 | import from L1CTL_PortType all; |
| 22 | import from L1CTL_Types all; |
| 23 | import from LAPDm_Types all; |
Harald Welte | 4a129f8 | 2019-05-21 16:35:22 +0200 | [diff] [blame] | 24 | import from IPA_Emulation all; |
Harald Welte | 908ce54 | 2019-09-04 23:05:40 +0200 | [diff] [blame] | 25 | import from GSM_RR_Types all; |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 26 | |
| 27 | import from RSL_Types all; |
| 28 | |
Harald Welte | 11b734c | 2019-09-05 14:17:54 +0200 | [diff] [blame] | 29 | import from PCUIF_Types all; |
| 30 | import from PCUIF_CodecPort all; |
| 31 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 32 | import from Osmocom_VTY_Functions all; |
| 33 | |
| 34 | import from BTS_Tests all; |
| 35 | |
| 36 | /*********************************************************************** |
| 37 | * Cell Broadcast related tests |
| 38 | ***********************************************************************/ |
| 39 | |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 40 | /* Test parameters for one channel (e.g. Basic, Extended) */ |
| 41 | type record CbchTestParsChan { |
| 42 | /* list of "normal" (sent-once) SMSCB messages */ |
| 43 | CbchTestMsgs msgs, |
| 44 | /* default message, if any */ |
| 45 | CbchTestMsg default_msg optional |
| 46 | } |
| 47 | |
| 48 | private template (value) CbchTestParsChan |
| 49 | t_CbchPC(template (value) CbchTestMsgs msgs, template (omit) CbchTestMsg def := omit) := { |
| 50 | msgs := msgs, |
| 51 | default_msg := def |
| 52 | } |
| 53 | |
| 54 | /* CBCH test parameters for most of our tests */ |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 55 | type record CbchTestPars { |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 56 | /* should we execute on SDCCH4 (true) or SDCCH8 (false) ? */ |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 57 | boolean use_sdcch4, |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 58 | /* Parameters for BASIC CBCH */ |
| 59 | CbchTestParsChan basic, |
| 60 | /* Parameters for EXTENDED CBCH */ |
| 61 | CbchTestParsChan extended optional |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | type record CbchTestMsg { |
| 65 | /* config / input data */ |
| 66 | RSL_CbCommand rsl_cb_cmd, |
| 67 | uint2_t last_block, /* 0..3 */ |
| 68 | octetstring payload, |
| 69 | /* computed / result data */ |
| 70 | CbchBlocks blocks optional |
| 71 | }; |
| 72 | type record of CbchTestMsg CbchTestMsgs; |
| 73 | |
| 74 | /* a single 22byte block within a CbchTestMsg */ |
| 75 | type record CbchBlock { |
| 76 | uint4_t seq_nr, /* as per TS 04.12 */ |
| 77 | boolean is_last, |
| 78 | OCT22 payload, |
| 79 | boolean seen_once |
| 80 | }; |
| 81 | type record of CbchBlock CbchBlocks; |
| 82 | |
| 83 | /* compute the expected blocks for given test parameters */ |
| 84 | private function f_cbch_compute_exp_blocks(inout CbchTestPars pars) { |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 85 | f_cbch_compute_exp_blocks_chan(pars.basic); |
| 86 | if (ispresent(pars.extended)) { |
| 87 | f_cbch_compute_exp_blocks_chan(pars.extended); |
| 88 | } |
| 89 | } |
| 90 | private function f_cbch_compute_exp_blocks_chan(inout CbchTestParsChan pars_chan) { |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 91 | var integer i; |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 92 | for (i := 0; i < lengthof(pars_chan.msgs); i := i+1) { |
| 93 | pars_chan.msgs[i].blocks := f_comp_blocks(pars_chan.msgs[i]); |
| 94 | } |
| 95 | if (ispresent(pars_chan.default_msg)) { |
| 96 | pars_chan.default_msg.blocks := f_comp_blocks(pars_chan.default_msg); |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 97 | } |
| 98 | } |
| 99 | private function f_comp_blocks(in CbchTestMsg msg) return CbchBlocks { |
| 100 | var CbchBlocks blocks := {}; |
| 101 | var integer i; |
| 102 | |
| 103 | for (i := 0; i <= msg.last_block; i := i+1) { |
| 104 | var CbchBlock block := { |
| 105 | seq_nr := i, |
| 106 | is_last := false, |
| 107 | payload := substr(msg.payload, 22*i, 22), |
| 108 | seen_once := false |
| 109 | }; |
| 110 | if (msg.rsl_cb_cmd == RSL_CB_CMD_SCHEDULE and i == 0) { |
| 111 | block.seq_nr := 8; |
| 112 | } |
| 113 | if (i == msg.last_block) { |
| 114 | block.is_last := true; |
| 115 | } |
| 116 | blocks := blocks & {block}; |
| 117 | } |
| 118 | |
| 119 | return blocks; |
| 120 | }; |
| 121 | |
| 122 | /* TS 48.058 Section 9.3.41 */ |
| 123 | private function f_cbch_block_nr2rsl(uint2_t nr) return uint2_t { |
| 124 | select (nr) { |
| 125 | case (0) { return 1; } |
| 126 | case (1) { return 2; } |
| 127 | case (2) { return 3; } |
| 128 | case (3) { return 0; } |
| 129 | } |
| 130 | setverdict(fail, "Invalid block number"); |
| 131 | mtc.stop; |
| 132 | } |
| 133 | |
Harald Welte | 88e5dff | 2019-05-20 15:14:46 +0200 | [diff] [blame] | 134 | private function f_cbch_fn2tb(uint32_t fn) return integer |
| 135 | { |
| 136 | return (fn/51) mod 8; /* TS 05.02 Section 6.5.4 */ |
| 137 | } |
| 138 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 139 | /* Verify the CBCH TB scheduling rules of TS 05.02 Section 6.5.4 */ |
| 140 | private function f_cbch_fn_verify(uint32_t fn, CBCH_Block cb) |
| 141 | { |
Harald Welte | 88e5dff | 2019-05-20 15:14:46 +0200 | [diff] [blame] | 142 | var integer tb := f_cbch_fn2tb(fn); |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 143 | if (cb.block_type.seq_nr == 15 /* null */) { |
| 144 | /* always permitted */ |
| 145 | return; |
| 146 | } else if (cb.block_type.seq_nr == 8 /* schedule */) { |
| 147 | if (tb != 0) { |
| 148 | setverdict(fail, "Schedule block at TB=", tb); |
| 149 | } |
| 150 | } else if (cb.block_type.seq_nr < 4) { |
| 151 | if (cb.block_type.seq_nr != tb and cb.block_type.seq_nr+4 != tb) { |
| 152 | setverdict(fail, "Normal block at wrong TB=", tb, ": ", cb); |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | |
Harald Welte | df4d0f0 | 2019-05-20 16:04:11 +0200 | [diff] [blame] | 157 | private function f_rsl_smscb_default_null() runs on test_CT |
| 158 | { |
| 159 | var RSL_IE_CbCommandType cmd_type := |
| 160 | valueof(ts_RSL_IE_CbCmdType(RSL_CB_CMD_DEFAULT, 1, true)); |
| 161 | RSL_CCHAN.send(ts_RSL_UD(ts_RSL_SMSCB_CMD(cmd_type, ''O))); |
| 162 | } |
| 163 | |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 164 | template RSL_IE t_RSL_IE_SMSCB_EXT := t_RSL_IE(RSL_IE_SMSCB_CHAN_INDICATOR, {smscb_chan_ind := 1}); |
| 165 | |
| 166 | private function f_smscb_setup_rsl_chan(inout CbchTestParsChan pars_chan, boolean extd := false) |
| 167 | runs on test_CT { |
Harald Welte | 88e5dff | 2019-05-20 15:14:46 +0200 | [diff] [blame] | 168 | var integer i; |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 169 | var CbchTestMsg msg; |
| 170 | var uint2_t rsl_last_block; |
| 171 | var RSL_IE_CbCommandType cmd_type; |
| 172 | var RSL_Message rsl; |
| 173 | |
| 174 | /* send SMSCB[s] via RSL */ |
| 175 | for (i := 0; i < lengthof(pars_chan.msgs); i := i+1) { |
| 176 | msg := pars_chan.msgs[i]; |
| 177 | rsl_last_block := f_cbch_block_nr2rsl(msg.last_block); |
| 178 | cmd_type := valueof(ts_RSL_IE_CbCmdType(msg.rsl_cb_cmd, rsl_last_block)); |
| 179 | rsl := valueof(ts_RSL_SMSCB_CMD(cmd_type, msg.payload)); |
| 180 | if (extd) { |
| 181 | rsl.ies := rsl.ies & { valueof(t_RSL_IE_SMSCB_EXT) }; |
| 182 | } |
| 183 | RSL_CCHAN.send(ts_RSL_UD(rsl)); |
| 184 | } |
| 185 | if (ispresent(pars_chan.default_msg)) { |
| 186 | msg := pars_chan.default_msg; |
| 187 | rsl_last_block := f_cbch_block_nr2rsl(msg.last_block); |
| 188 | cmd_type := valueof(ts_RSL_IE_CbCmdType(msg.rsl_cb_cmd, rsl_last_block, false)); |
| 189 | rsl := valueof(ts_RSL_SMSCB_CMD(cmd_type, msg.payload)); |
| 190 | if (extd) { |
| 191 | rsl.ies := rsl.ies & { valueof(t_RSL_IE_SMSCB_EXT) }; |
| 192 | } |
| 193 | RSL_CCHAN.send(ts_RSL_UD(rsl)); |
| 194 | } |
| 195 | } |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 196 | |
Harald Welte | 4a129f8 | 2019-05-21 16:35:22 +0200 | [diff] [blame] | 197 | private function f_vty_cbch_setup(boolean use_sdcch4 := true) runs on test_CT { |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 198 | |
Harald Welte | 4a129f8 | 2019-05-21 16:35:22 +0200 | [diff] [blame] | 199 | if (use_sdcch4 == true) { |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 200 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 0"}, |
| 201 | "phys_chan_config CCCH+SDCCH4+CBCH"); |
| 202 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 6"}, |
| 203 | "phys_chan_config SDCCH8"); |
| 204 | } else { |
| 205 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 0"}, |
| 206 | "phys_chan_config CCCH+SDCCH4"); |
| 207 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 6"}, |
| 208 | "phys_chan_config SDCCH8+CBCH"); |
| 209 | } |
| 210 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 211 | f_sleep(2.0); |
Harald Welte | 4a129f8 | 2019-05-21 16:35:22 +0200 | [diff] [blame] | 212 | } |
| 213 | private function f_smscb_setup(inout CbchTestPars pars) runs on test_CT { |
| 214 | |
| 215 | f_cbch_compute_exp_blocks(pars); |
| 216 | |
| 217 | f_init_vty_bsc(); |
| 218 | /* ensure that a CBCH is present in channel combination */ |
| 219 | f_vty_cbch_setup(pars.use_sdcch4); |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 220 | f_init(); |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 221 | |
| 222 | f_init_l1ctl(); |
Harald Welte | 990a361 | 2019-05-27 14:02:13 +0200 | [diff] [blame] | 223 | f_l1_tune(L1CTL, ccch_mode := CCCH_MODE_COMBINED_CBCH); |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 224 | /* FIXME: switch to dedicated mode for SDCCH/8 */ |
| 225 | |
| 226 | /* send SMSCB[s] via RSL */ |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 227 | f_smscb_setup_rsl_chan(pars.basic, false); |
| 228 | if (ispresent(pars.extended)) { |
| 229 | f_smscb_setup_rsl_chan(pars.extended, true); |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 230 | } |
Harald Welte | 88e5dff | 2019-05-20 15:14:46 +0200 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | private function f_smscb_cleanup() runs on test_CT { |
| 234 | /* reset timeslot 0 channel combination to default */ |
| 235 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 0"}, |
| 236 | "phys_chan_config CCCH+SDCCH4"); |
| 237 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 6"}, |
| 238 | "phys_chan_config SDCCH8"); |
| 239 | } |
| 240 | |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 241 | /* construct a receive/match template for given block_nr in given msg */ |
| 242 | private function f_get_block_template(CbchTestMsg msg, integer block_nr) return template CBCH_Block { |
| 243 | var template CBCH_Block tr; |
| 244 | if (block_nr < lengthof(msg.blocks)) { |
| 245 | var CbchBlock b := msg.blocks[block_nr]; |
| 246 | tr := tr_CBCH_Block(b.seq_nr, b.is_last, b.payload); |
| 247 | } else { |
| 248 | tr := tr_CBCH_Block(15, ?, ?); |
| 249 | } |
| 250 | return tr; |
| 251 | } |
| 252 | |
| 253 | /* the heart of the CBCH test case matching engine for one channel (basic, extended) */ |
| 254 | private function f_cbch_match(inout CbchTestParsChan pars_chan, CBCH_Block cb, integer tb) |
| 255 | { |
| 256 | var integer block_nr := tb mod 4; |
| 257 | var integer i; |
| 258 | |
| 259 | if (not match(cb, tr_CBCH_Block)) { |
| 260 | setverdict(fail, "Illegal CBCH Block received: ", cb); |
| 261 | } else { |
| 262 | var boolean matched := false; |
| 263 | /* check if it's any of our expected blocks */ |
| 264 | for (i := 0; i < lengthof(pars_chan.msgs); i := i+1) { |
| 265 | if (block_nr < lengthof(pars_chan.msgs[i].blocks)) { |
| 266 | if (match(cb, f_get_block_template(pars_chan.msgs[i], block_nr))) { |
| 267 | log("Found block_nr ", block_nr, " of msg ", i); |
| 268 | if (not pars_chan.msgs[i].blocks[block_nr].seen_once) { |
| 269 | pars_chan.msgs[i].blocks[block_nr].seen_once := true; |
| 270 | setverdict(pass); |
| 271 | } else { |
| 272 | setverdict(fail, "Received SMSCB twice! ", cb); |
| 273 | } |
| 274 | matched := true; |
| 275 | break; |
| 276 | } |
| 277 | } |
| 278 | } |
| 279 | if (not matched) { |
| 280 | var template CBCH_Block tr; |
| 281 | if (ispresent(pars_chan.default_msg)) { |
| 282 | /* it must be a block of the default message */ |
| 283 | tr := f_get_block_template(pars_chan.default_msg, block_nr); |
| 284 | } else { |
| 285 | /* it must be a NULL block */ |
| 286 | tr := tr_CBCH_Block(15, ?, ?); |
| 287 | } |
| 288 | if (not match(cb, tr)) { |
| 289 | setverdict(fail, "Received unexpected CBCH block: ", cb); |
| 290 | } else { |
| 291 | log("Found block_nr ", block_nr, " of DEFAULT/NULL"); |
| 292 | if (ispresent(pars_chan.default_msg) and |
| 293 | block_nr < lengthof(pars_chan.default_msg.blocks)) { |
| 294 | pars_chan.default_msg.blocks[block_nr].seen_once := true; |
| 295 | } |
| 296 | } |
| 297 | } |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | /* Report/Evaluate the per-channel CBCH test results */ |
| 302 | private function f_cbch_report(CbchTestParsChan pars_chan, charstring id) |
| 303 | { |
| 304 | var integer i, j; |
| 305 | |
| 306 | /* verify that each block of each message has been seen once */ |
| 307 | for (i := 0; i < lengthof(pars_chan.msgs); i := i+1) { |
| 308 | for (j := 0; j < lengthof(pars_chan.msgs[i].blocks); j := j+1) { |
| 309 | var CbchBlock b := pars_chan.msgs[i].blocks[j]; |
| 310 | if (not b.seen_once) { |
| 311 | setverdict(fail, "Timeout waiting for ", id, " CBCH block ", |
| 312 | j, " of msg ", i); |
| 313 | } |
| 314 | } |
| 315 | } |
| 316 | if (ispresent(pars_chan.default_msg)) { |
| 317 | /* verify that each block of default message has been seen at least once */ |
| 318 | for (j := 0; j < lengthof(pars_chan.default_msg.blocks); j := j+1) { |
| 319 | var CbchBlock b := pars_chan.default_msg.blocks[j]; |
| 320 | if (not b.seen_once) { |
| 321 | setverdict(fail, "Timeout waiting for at leaset one instance of ", |
| 322 | "CBCH block ", j, " of DEFAULT msg"); |
| 323 | } |
| 324 | } |
| 325 | } |
| 326 | } |
| 327 | |
Harald Welte | 6b86b34 | 2019-05-27 17:14:36 +0200 | [diff] [blame] | 328 | private function t_cbch_chan_nr(CbchTestPars pars, template uint8_t tn) return template RslChannelNr { |
| 329 | if (pars.use_sdcch4) { |
| 330 | return t_RslChanNr_CBCH4(tn); |
| 331 | } else { |
| 332 | return t_RslChanNr_CBCH8(tn); |
| 333 | } |
| 334 | } |
| 335 | |
Harald Welte | 88e5dff | 2019-05-20 15:14:46 +0200 | [diff] [blame] | 336 | /* shared function doing the heavy lifting for most CBCH tests */ |
| 337 | private function f_TC_smscb(CbchTestPars pars) runs on test_CT { |
Harald Welte | 6b86b34 | 2019-05-27 17:14:36 +0200 | [diff] [blame] | 338 | var template RslChannelNr t_chan_nr := t_cbch_chan_nr(pars, 0); /* FIXME: TS number */ |
Harald Welte | 88e5dff | 2019-05-20 15:14:46 +0200 | [diff] [blame] | 339 | var L1ctlDlMessage dl; |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 340 | var integer msg_count; |
| 341 | timer T; |
| 342 | |
| 343 | msg_count := lengthof(pars.basic.msgs); |
| 344 | if (ispresent(pars.basic.default_msg)) { |
| 345 | msg_count := msg_count + 1; |
| 346 | } |
| 347 | if (ispresent(pars.extended)) { |
| 348 | msg_count := msg_count + lengthof(pars.extended.msgs); |
| 349 | if (ispresent(pars.extended.default_msg)) { |
| 350 | msg_count := msg_count + 1; |
| 351 | } |
| 352 | } |
Harald Welte | 88e5dff | 2019-05-20 15:14:46 +0200 | [diff] [blame] | 353 | |
| 354 | f_smscb_setup(pars); |
| 355 | |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 356 | /* dynamically adjust timeout based on number of messages */ |
| 357 | T.start(5.0 + 3.0 * int2float(msg_count)); |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 358 | /* Expect this to show up exactly once on the basic CBCH (four blocks) */ |
| 359 | alt { |
Harald Welte | 6b86b34 | 2019-05-27 17:14:36 +0200 | [diff] [blame] | 360 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_chan_nr)) -> value dl { |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 361 | var integer tb := f_cbch_fn2tb(dl.dl_info.frame_nr); |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 362 | var CBCH_Block cb := dec_CBCH_Block(dl.payload.data_ind.payload); |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 363 | log("Tb=", tb, ", CBCH: ", dl, ", block: ", cb); |
| 364 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 365 | /* detect the proper CBCH messages; check frame number */ |
| 366 | f_cbch_fn_verify(dl.dl_info.frame_nr, cb); |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 367 | |
| 368 | if (tb < 4) { |
| 369 | f_cbch_match(pars.basic, cb, tb); |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 370 | } else { |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 371 | if (not ispresent(pars.extended)) { |
| 372 | /* no parameters for ext. BCCH given: ignore */ |
| 373 | repeat; |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 374 | } |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 375 | f_cbch_match(pars.extended, cb, tb); |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 376 | } |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 377 | repeat; |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 378 | } |
| 379 | [] L1CTL.receive { repeat; } |
| 380 | [] T.timeout { |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 381 | f_cbch_report(pars.basic, "Basic"); |
| 382 | if (ispresent(pars.extended)) { |
| 383 | f_cbch_report(pars.extended, "Extended"); |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 384 | } |
| 385 | } |
| 386 | } |
| 387 | |
Harald Welte | 88e5dff | 2019-05-20 15:14:46 +0200 | [diff] [blame] | 388 | f_smscb_cleanup(); |
| 389 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, pass); |
| 390 | } |
| 391 | |
| 392 | private function f_TC_smscb_default_only(CbchTestPars pars) runs on test_CT { |
Harald Welte | 6b86b34 | 2019-05-27 17:14:36 +0200 | [diff] [blame] | 393 | var template RslChannelNr t_chan_nr := t_cbch_chan_nr(pars, 0); /* FIXME: TS number */ |
Harald Welte | 88e5dff | 2019-05-20 15:14:46 +0200 | [diff] [blame] | 394 | var L1ctlDlMessage dl; |
| 395 | timer T := 5.0; |
| 396 | |
| 397 | f_smscb_setup(pars); |
| 398 | |
| 399 | /* ensure whatever initial NULL messages have all been drained */ |
| 400 | f_sleep(5.0); |
| 401 | L1CTL.clear; |
| 402 | |
| 403 | T.start; |
| 404 | alt { |
Harald Welte | 6b86b34 | 2019-05-27 17:14:36 +0200 | [diff] [blame] | 405 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_chan_nr)) -> value dl { |
Harald Welte | 88e5dff | 2019-05-20 15:14:46 +0200 | [diff] [blame] | 406 | var integer tb := f_cbch_fn2tb(dl.dl_info.frame_nr); |
| 407 | log("CBCH: ", dl); |
| 408 | var CBCH_Block cb := dec_CBCH_Block(dl.payload.data_ind.payload); |
| 409 | /* detect the proper CBCH messages; check frame number */ |
| 410 | f_cbch_fn_verify(dl.dl_info.frame_nr, cb); |
| 411 | if (tb >= 4) { |
| 412 | /* skip extended CBCH for now */ |
| 413 | repeat; |
| 414 | } |
| 415 | if (not match(cb, tr_CBCH_Block)) { |
| 416 | setverdict(fail, "Illegal CBCH Block received: ", cb); |
| 417 | } else { |
| 418 | var uint4_t rx_seq_nr := cb.block_type.seq_nr; |
| 419 | var template CBCH_Block tr; |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 420 | if (rx_seq_nr < lengthof(pars.basic.msgs[0].blocks)) { |
| 421 | var CbchBlock b := pars.basic.msgs[0].blocks[rx_seq_nr]; |
Harald Welte | 88e5dff | 2019-05-20 15:14:46 +0200 | [diff] [blame] | 422 | tr := tr_CBCH_Block(b.seq_nr, b.is_last, b.payload); |
| 423 | } else { |
| 424 | tr := tr_CBCH_Block(15, ?, ?); |
| 425 | } |
| 426 | if (match(cb, tr)) { |
| 427 | setverdict(pass); /* FIXME: check that all blocks are received? */ |
| 428 | repeat; |
| 429 | } else { |
| 430 | setverdict(fail, "Unexpected CBCH block ", cb, ", expected ", tr); |
| 431 | } |
| 432 | } |
| 433 | } |
| 434 | [] L1CTL.receive { repeat; } |
| 435 | [] T.timeout {} |
| 436 | } |
| 437 | |
| 438 | f_smscb_cleanup(); |
| 439 | /* don't shut down; some tests still want to continue */ |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | private const CbchTestMsgs msgs_1m_1b_norm := { |
| 443 | { RSL_CB_CMD_NORMAL, 0, '001000320f1141660c344dd3cba09a0c000000000000'O, omit } |
| 444 | } |
| 445 | |
| 446 | private const CbchTestMsgs msgs_1m_2b_norm := { |
| 447 | { RSL_CB_CMD_NORMAL, 1, '001000320f1141660c344dd3cba09a0c000000000000'O & |
| 448 | '000102030405060708090a0b0c0d0e0f101213141516'O, |
| 449 | omit } |
| 450 | } |
| 451 | |
| 452 | private const CbchTestMsgs msgs_1m_3b_norm := { |
| 453 | { RSL_CB_CMD_NORMAL, 2, '001000320f1141660c344dd3cba09a0c000000000000'O & |
| 454 | '000102030405060708090a0b0c0d0e0f101213141516'O & |
| 455 | '101112131415161718191a1b1c1d1e1f202223242526'O, |
| 456 | omit } |
| 457 | } |
| 458 | |
| 459 | private const CbchTestMsgs msgs_1m_4b_norm := { |
| 460 | { RSL_CB_CMD_NORMAL, 3, '001000320f1141660c344dd3cba09a0c000000000000'O & |
| 461 | '000102030405060708090a0b0c0d0e0f101213141516'O & |
| 462 | '101112131415161718191a1b1c1d1e1f202223242526'O & |
| 463 | '202122232425262728292a2b2c2d2e2f303233343536'O, |
| 464 | omit } |
| 465 | } |
| 466 | |
| 467 | private const CbchTestMsgs msgs_1m_4b_sched := { |
| 468 | { RSL_CB_CMD_SCHEDULE, 3, '001000320f1141660c344dd3cba09a0c000000000000'O & |
| 469 | '000102030405060708090a0b0c0d0e0f101213141516'O & |
| 470 | '101112131415161718191a1b1c1d1e1f202223242526'O & |
| 471 | '202122232425262728292a2b2c2d2e2f303233343536'O, |
| 472 | omit } |
| 473 | } |
| 474 | |
Harald Welte | e0026c3 | 2019-05-20 00:27:30 +0200 | [diff] [blame] | 475 | private const CbchTestMsgs msgs_3m_4b_norm := { |
| 476 | { RSL_CB_CMD_NORMAL, 3, '001000320f1141660c344dd3cba09a0c000000000000'O & |
| 477 | '000102030405060708090a0b0c0d0e0f101213141516'O & |
| 478 | '101112131415161718191a1b1c1d1e1f202223242526'O & |
| 479 | '201122232425262728292a2b2c2d2e2f303233343536'O, |
| 480 | omit }, |
| 481 | { RSL_CB_CMD_NORMAL, 3, '002000320f1141660c344dd3cba09a0c000000000000'O & |
| 482 | '002102030405060708090a0b0c0d0e0f101213141516'O & |
| 483 | '102112131415161718191a1b1c1d1e1f202223242526'O & |
| 484 | '202122232425262728292a2b2c2d2e2f303233343536'O, |
| 485 | omit }, |
| 486 | { RSL_CB_CMD_NORMAL, 3, '003000320f1141660c344dd3cba09a0c000000000000'O & |
| 487 | '003102030405060708090a0b0c0d0e0f101213141516'O & |
| 488 | '103112131415161718191a1b1c1d1e1f202223242526'O & |
| 489 | '203122232425262728292a2b2c2d2e2f303233343536'O, |
| 490 | omit } |
| 491 | } |
| 492 | |
Harald Welte | 88e5dff | 2019-05-20 15:14:46 +0200 | [diff] [blame] | 493 | private const CbchTestMsgs msgs_1m_3b_default := { |
| 494 | { RSL_CB_CMD_DEFAULT, 2, '001000320f1141660c344dd3cba09a0c000000000000'O & |
| 495 | '000102030405060708090a0b0c0d0e0f101213141516'O & |
| 496 | '101112131415161718191a1b1c1d1e1f202223242526'O, |
| 497 | omit } |
| 498 | } |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 499 | private const CbchTestMsg msg_default := { |
| 500 | RSL_CB_CMD_DEFAULT, 0, '010203040506070708090a0b0c0d0e0f101112131415'O, |
| 501 | omit |
| 502 | } |
Harald Welte | 88e5dff | 2019-05-20 15:14:46 +0200 | [diff] [blame] | 503 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 504 | /* transmit single-block SMSCB COMMAND */ |
| 505 | testcase TC_sms_cb_cmd_sdcch4_1block() runs on test_CT { |
| 506 | var CbchTestPars pars := { |
| 507 | use_sdcch4 := true, |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 508 | basic := valueof(t_CbchPC(msgs_1m_1b_norm)), |
| 509 | extended := omit |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 510 | }; |
| 511 | f_TC_smscb(pars); |
| 512 | } |
| 513 | testcase TC_sms_cb_cmd_sdcch8_1block() runs on test_CT { |
| 514 | var CbchTestPars pars := { |
| 515 | use_sdcch4 := false, |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 516 | basic := valueof(t_CbchPC(msgs_1m_1b_norm)), |
| 517 | extended := omit |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 518 | }; |
| 519 | f_TC_smscb(pars); |
| 520 | } |
| 521 | |
| 522 | /* transmit dual-block SMSCB COMMAND */ |
| 523 | testcase TC_sms_cb_cmd_sdcch4_2block() runs on test_CT { |
| 524 | var CbchTestPars pars := { |
| 525 | use_sdcch4 := true, |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 526 | basic := valueof(t_CbchPC(msgs_1m_2b_norm)), |
| 527 | extended := omit |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 528 | }; |
| 529 | f_TC_smscb(pars); |
| 530 | } |
| 531 | testcase TC_sms_cb_cmd_sdcch8_2block() runs on test_CT { |
| 532 | var CbchTestPars pars := { |
| 533 | use_sdcch4 := false, |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 534 | basic := valueof(t_CbchPC(msgs_1m_2b_norm)), |
| 535 | extended := omit |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 536 | }; |
| 537 | f_TC_smscb(pars); |
| 538 | } |
| 539 | |
| 540 | /* transmit triple-block SMSCB COMMAND */ |
| 541 | testcase TC_sms_cb_cmd_sdcch4_3block() runs on test_CT { |
| 542 | var CbchTestPars pars := { |
| 543 | use_sdcch4 := true, |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 544 | basic := valueof(t_CbchPC(msgs_1m_3b_norm)), |
| 545 | extended := omit |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 546 | }; |
| 547 | f_TC_smscb(pars); |
| 548 | } |
| 549 | testcase TC_sms_cb_cmd_sdcch8_3block() runs on test_CT { |
| 550 | var CbchTestPars pars := { |
| 551 | use_sdcch4 := false, |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 552 | basic := valueof(t_CbchPC(msgs_1m_3b_norm)), |
| 553 | extended := omit |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 554 | }; |
| 555 | f_TC_smscb(pars); |
| 556 | } |
| 557 | |
| 558 | /* transmit quad-block SMSCB COMMAND */ |
| 559 | testcase TC_sms_cb_cmd_sdcch4_4block() runs on test_CT { |
| 560 | var CbchTestPars pars := { |
| 561 | use_sdcch4 := true, |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 562 | basic := valueof(t_CbchPC(msgs_1m_4b_norm)), |
| 563 | extended := omit |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 564 | }; |
| 565 | f_TC_smscb(pars); |
| 566 | } |
| 567 | testcase TC_sms_cb_cmd_sdcch8_4block() runs on test_CT { |
| 568 | var CbchTestPars pars := { |
| 569 | use_sdcch4 := false, |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 570 | basic := valueof(t_CbchPC(msgs_1m_4b_norm)), |
| 571 | extended := omit |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 572 | }; |
| 573 | f_TC_smscb(pars); |
| 574 | } |
| 575 | |
Harald Welte | e0026c3 | 2019-05-20 00:27:30 +0200 | [diff] [blame] | 576 | /* transmit multiple commands of each 4 blocks */ |
| 577 | testcase TC_sms_cb_cmd_sdcch4_multi() runs on test_CT { |
| 578 | var CbchTestPars pars := { |
| 579 | use_sdcch4 := true, |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 580 | basic := valueof(t_CbchPC(msgs_3m_4b_norm)), |
| 581 | extended := omit |
Harald Welte | e0026c3 | 2019-05-20 00:27:30 +0200 | [diff] [blame] | 582 | }; |
| 583 | f_TC_smscb(pars); |
| 584 | } |
| 585 | testcase TC_sms_cb_cmd_sdcch8_multi() runs on test_CT { |
| 586 | var CbchTestPars pars := { |
| 587 | use_sdcch4 := false, |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 588 | basic := valueof(t_CbchPC(msgs_3m_4b_norm)), |
| 589 | extended := omit |
Harald Welte | e0026c3 | 2019-05-20 00:27:30 +0200 | [diff] [blame] | 590 | }; |
| 591 | f_TC_smscb(pars); |
| 592 | } |
| 593 | |
Harald Welte | 60bd92b | 2019-05-20 21:42:21 +0200 | [diff] [blame] | 594 | /* transmit multiple commands of each 4 blocks on CBCH EXTD */ |
| 595 | testcase TC_sms_cb_cmd_sdcch4_extd_multi() runs on test_CT { |
| 596 | var CbchTestPars pars := { |
| 597 | use_sdcch4 := true, |
| 598 | basic := valueof(t_CbchPC({})), |
| 599 | extended := valueof(t_CbchPC(msgs_3m_4b_norm)) |
| 600 | }; |
| 601 | f_TC_smscb(pars); |
| 602 | } |
| 603 | testcase TC_sms_cb_cmd_sdcch8_extd_multi() runs on test_CT { |
| 604 | var CbchTestPars pars := { |
| 605 | use_sdcch4 := false, |
| 606 | basic := valueof(t_CbchPC({})), |
| 607 | extended := valueof(t_CbchPC(msgs_3m_4b_norm)) |
| 608 | }; |
| 609 | f_TC_smscb(pars); |
| 610 | } |
| 611 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 612 | /* transmit SMSCB COMMAND with SCHEDULE payload */ |
| 613 | testcase TC_sms_cb_cmd_sdcch4_schedule() runs on test_CT { |
| 614 | var CbchTestPars pars := { |
| 615 | use_sdcch4 := true, |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 616 | basic := valueof(t_CbchPC(msgs_1m_4b_sched)), |
| 617 | extended := omit |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 618 | }; |
| 619 | f_TC_smscb(pars); |
| 620 | } |
| 621 | testcase TC_sms_cb_cmd_sdcch8_schedule() runs on test_CT { |
| 622 | var CbchTestPars pars := { |
| 623 | use_sdcch4 := false, |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 624 | basic := valueof(t_CbchPC(msgs_1m_4b_sched)), |
| 625 | extended := omit |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 626 | }; |
| 627 | f_TC_smscb(pars); |
| 628 | } |
| 629 | |
Harald Welte | 88e5dff | 2019-05-20 15:14:46 +0200 | [diff] [blame] | 630 | /* set a DEFAULT message; verify it gets transmitted all the time */ |
| 631 | testcase TC_sms_cb_cmd_sdcch4_default_only() runs on test_CT { |
| 632 | var CbchTestPars pars := { |
| 633 | use_sdcch4 := true, |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 634 | basic := valueof(t_CbchPC(msgs_1m_3b_default)), |
| 635 | extended := omit |
Harald Welte | 88e5dff | 2019-05-20 15:14:46 +0200 | [diff] [blame] | 636 | }; |
| 637 | f_TC_smscb_default_only(pars); |
| 638 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, pass); |
| 639 | } |
| 640 | testcase TC_sms_cb_cmd_sdcch8_default_only() runs on test_CT { |
| 641 | var CbchTestPars pars := { |
| 642 | use_sdcch4 := true, |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 643 | basic := valueof(t_CbchPC(msgs_1m_3b_default)), |
| 644 | extended := omit |
Harald Welte | 88e5dff | 2019-05-20 15:14:46 +0200 | [diff] [blame] | 645 | }; |
| 646 | f_TC_smscb_default_only(pars); |
| 647 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, pass); |
| 648 | } |
| 649 | |
Harald Welte | d522ca0 | 2019-05-20 20:06:12 +0200 | [diff] [blame] | 650 | testcase TC_sms_cb_cmd_sdcch4_default_and_normal() runs on test_CT { |
| 651 | var CbchTestPars pars := { |
| 652 | use_sdcch4 := true, |
| 653 | basic := valueof(t_CbchPC(msgs_1m_3b_norm, msg_default)), |
| 654 | extended := omit |
| 655 | }; |
| 656 | f_TC_smscb(pars); |
| 657 | } |
| 658 | testcase TC_sms_cb_cmd_sdcch8_default_and_normal() runs on test_CT { |
| 659 | var CbchTestPars pars := { |
| 660 | use_sdcch4 := true, |
| 661 | basic := valueof(t_CbchPC(msgs_1m_3b_norm, msg_default)), |
| 662 | extended := omit |
| 663 | }; |
| 664 | f_TC_smscb(pars); |
| 665 | } |
| 666 | |
Harald Welte | df4d0f0 | 2019-05-20 16:04:11 +0200 | [diff] [blame] | 667 | /* first set a DEFAULT message, then disable it again */ |
| 668 | testcase TC_sms_cb_cmd_sdcch4_default_then_null() runs on test_CT { |
| 669 | var CbchTestPars pars := { |
| 670 | use_sdcch4 := true, |
Harald Welte | a3ff670 | 2019-05-20 20:03:50 +0200 | [diff] [blame] | 671 | basic := valueof(t_CbchPC(msgs_1m_3b_default)), |
| 672 | extended := omit |
Harald Welte | df4d0f0 | 2019-05-20 16:04:11 +0200 | [diff] [blame] | 673 | }; |
Harald Welte | 6b86b34 | 2019-05-27 17:14:36 +0200 | [diff] [blame] | 674 | var template RslChannelNr t_chan_nr := t_RslChanNr_CBCH4(0); |
Harald Welte | df4d0f0 | 2019-05-20 16:04:11 +0200 | [diff] [blame] | 675 | var L1ctlDlMessage dl; |
| 676 | timer T := 5.0; |
| 677 | |
| 678 | f_TC_smscb_default_only(pars); |
| 679 | |
| 680 | /* disable DEFAULT message; switch back to NULL */ |
| 681 | f_rsl_smscb_default_null(); |
| 682 | |
| 683 | /* ensure whatever initial non-NULL messages have all been drained */ |
| 684 | f_sleep(5.0); |
| 685 | L1CTL.clear; |
| 686 | |
| 687 | T.start; |
| 688 | alt { |
Harald Welte | 6b86b34 | 2019-05-27 17:14:36 +0200 | [diff] [blame] | 689 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_chan_nr)) -> value dl { |
Harald Welte | df4d0f0 | 2019-05-20 16:04:11 +0200 | [diff] [blame] | 690 | log("CBCH: ", dl); |
| 691 | var CBCH_Block cb := dec_CBCH_Block(dl.payload.data_ind.payload); |
| 692 | /* detect the proper CBCH messages; check frame number */ |
| 693 | f_cbch_fn_verify(dl.dl_info.frame_nr, cb); |
| 694 | if (not match(cb, tr_CBCH_Block)) { |
| 695 | setverdict(fail, "Illegal CBCH Block received: ", cb); |
| 696 | } else { |
| 697 | if (not match(cb, tr_CBCH_Block(15, ?, ?))) { |
| 698 | setverdict(fail, "Unexpected non-NULL CBCH block received"); |
| 699 | } |
| 700 | repeat; |
| 701 | } |
| 702 | } |
| 703 | [] L1CTL.receive { repeat; } |
| 704 | [] T.timeout { |
| 705 | setverdict(pass); |
| 706 | } |
| 707 | } |
| 708 | |
| 709 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, pass); |
| 710 | } |
| 711 | |
Harald Welte | 4a129f8 | 2019-05-21 16:35:22 +0200 | [diff] [blame] | 712 | /* Verify there are no CBCH load indications if no CBCH is present */ |
| 713 | testcase TC_cbch_load_idle_no_cbch() runs on test_CT { |
| 714 | var ASP_RSL_Unitdata rx_ud; |
| 715 | timer T := 10.0; |
| 716 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 717 | f_init(); |
Harald Welte | 4a129f8 | 2019-05-21 16:35:22 +0200 | [diff] [blame] | 718 | f_init_vty_bsc(); |
| 719 | |
| 720 | T.start; |
| 721 | alt { |
| 722 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CBCH_LOAD_IND_BASIC)) -> value rx_ud { |
| 723 | setverdict(fail, "Received unexpected CBCH LOAD IND: ", rx_ud); |
| 724 | } |
| 725 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CBCH_LOAD_IND_EXTD)) -> value rx_ud { |
| 726 | setverdict(fail, "Received unexpected CBCH LOAD IND: ", rx_ud); |
| 727 | } |
| 728 | [] RSL_CCHAN.receive { repeat; } |
| 729 | [] T.timeout { |
| 730 | setverdict(pass); |
| 731 | } |
| 732 | } |
| 733 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 734 | } |
| 735 | |
| 736 | /* Verify the CBCH load indications of an idle cell (without CBCH load) */ |
| 737 | function f_TC_cbc_load_idle() runs on test_CT { |
| 738 | template integer tr_slot_count := (2 .. 15); |
| 739 | const integer min_load_ind := 4; |
| 740 | var integer basic_count := 0; |
| 741 | var integer extd_count := 0; |
| 742 | var ASP_RSL_Unitdata rx_ud; |
| 743 | timer T := 10.0; |
| 744 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 745 | f_init(); |
Harald Welte | 4a129f8 | 2019-05-21 16:35:22 +0200 | [diff] [blame] | 746 | |
| 747 | RSL_CCHAN.clear; |
| 748 | T.start; |
| 749 | alt { |
| 750 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CBCH_LOAD_IND_BASIC(false, tr_slot_count))) { |
| 751 | basic_count := basic_count + 1; |
| 752 | repeat; |
| 753 | } |
| 754 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CBCH_LOAD_IND_EXTD(false, tr_slot_count))) -> value rx_ud { |
| 755 | extd_count := extd_count + 1; |
| 756 | repeat; |
| 757 | } |
| 758 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CBCH_LOAD_IND_BASIC)) -> value rx_ud { |
| 759 | setverdict(fail, "Received unexpected CBCH LOAD IND: ", rx_ud); |
| 760 | } |
| 761 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CBCH_LOAD_IND_EXTD)) -> value rx_ud { |
| 762 | setverdict(fail, "Received unexpected CBCH LOAD IND: ", rx_ud); |
| 763 | } |
| 764 | [] RSL_CCHAN.receive { repeat; } |
| 765 | [] T.timeout { |
| 766 | if ((basic_count >= min_load_ind) and (extd_count >= min_load_ind)) { |
| 767 | setverdict(pass); |
| 768 | } else { |
| 769 | setverdict(fail, "Insufficient number of CBCH LOAD IND: ", |
| 770 | "BASIC=", basic_count, " EXTD=", extd_count); |
| 771 | } |
| 772 | } |
| 773 | } |
| 774 | f_smscb_cleanup(); |
| 775 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 776 | } |
| 777 | testcase TC_cbc_sdcch4_load_idle() runs on test_CT { |
| 778 | f_init_vty_bsc(); |
| 779 | f_vty_cbch_setup(use_sdcch4 := true); |
| 780 | f_TC_cbc_load_idle(); |
| 781 | } |
| 782 | testcase TC_cbc_sdcch8_load_idle() runs on test_CT { |
| 783 | f_init_vty_bsc(); |
| 784 | f_vty_cbch_setup(use_sdcch4 := false); |
| 785 | f_TC_cbc_load_idle(); |
| 786 | } |
| 787 | |
| 788 | /* Verify CBCH overload indications are sent when sending too many SMS CB CMD */ |
| 789 | function f_TC_cbc_load_overload(CbchTestPars pars) runs on test_CT { |
| 790 | template integer tr_slot_count_basic := (11 .. 13); |
| 791 | template integer tr_slot_count_extd := (2 .. 15); |
| 792 | const integer min_load_ind := 4; |
| 793 | var integer basic_count := 0; |
| 794 | var integer extd_count := 0; |
| 795 | var ASP_RSL_Unitdata rx_ud; |
| 796 | timer T_total := 10.0; |
| 797 | timer T_retransmit := 0.2; |
| 798 | timer T_initial_guard := 2.0; |
| 799 | var integer i; |
| 800 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 801 | f_init(); |
Harald Welte | 4a129f8 | 2019-05-21 16:35:22 +0200 | [diff] [blame] | 802 | |
| 803 | /* send tons of SMSCB Command */ |
| 804 | for (i := 0; i < 30; i := i+1) { |
| 805 | f_smscb_setup_rsl_chan(pars.basic); |
| 806 | } |
| 807 | |
| 808 | /* keep sending SMSCB Commands for another two seconds */ |
| 809 | T_initial_guard.start; |
| 810 | T_retransmit.start; |
| 811 | alt { |
| 812 | [] T_retransmit.timeout { |
| 813 | f_smscb_setup_rsl_chan(pars.basic); |
| 814 | T_retransmit.start; |
| 815 | repeat; |
| 816 | } |
| 817 | [] T_initial_guard.timeout { } |
| 818 | } |
| 819 | /* clear any pending messages (where load may not have peaked yet) */ |
| 820 | RSL_CCHAN.clear; |
| 821 | |
| 822 | /* keep sending SMSCB Commands while verifying LOAD INDICATIONS */ |
| 823 | T_total.start; |
| 824 | T_retransmit.start; |
| 825 | alt { |
| 826 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CBCH_LOAD_IND_BASIC(true, tr_slot_count_basic))) { |
| 827 | basic_count := basic_count + 1; |
| 828 | repeat; |
| 829 | } |
| 830 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CBCH_LOAD_IND_EXTD(false, tr_slot_count_extd))) { |
| 831 | extd_count := extd_count + 1; |
| 832 | repeat; |
| 833 | } |
| 834 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CBCH_LOAD_IND_BASIC)) -> value rx_ud { |
| 835 | setverdict(fail, "Received unexpected CBCH LOAD IND: ", rx_ud); |
| 836 | } |
| 837 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CBCH_LOAD_IND_EXTD)) -> value rx_ud { |
| 838 | setverdict(fail, "Received unexpected CBCH LOAD IND: ", rx_ud); |
| 839 | } |
| 840 | [] RSL_CCHAN.receive { repeat; } |
| 841 | [] T_retransmit.timeout { |
| 842 | f_smscb_setup_rsl_chan(pars.basic); |
| 843 | T_retransmit.start; |
| 844 | repeat; |
| 845 | } |
| 846 | [] T_total.timeout { |
| 847 | if ((basic_count >= min_load_ind) and (extd_count >= min_load_ind)) { |
| 848 | setverdict(pass); |
| 849 | } else { |
| 850 | setverdict(fail, "Insufficient number of CBCH LOAD IND: ", |
| 851 | "BASIC=", basic_count, " EXTD=", extd_count); |
| 852 | } |
| 853 | } |
| 854 | } |
| 855 | f_smscb_cleanup(); |
| 856 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 857 | } |
| 858 | testcase TC_cbc_sdcch4_load_overload() runs on test_CT { |
| 859 | var CbchTestPars pars := { |
| 860 | use_sdcch4 := true, |
| 861 | basic := valueof(t_CbchPC(msgs_1m_3b_norm)), |
| 862 | extended := omit |
| 863 | }; |
| 864 | |
| 865 | f_init_vty_bsc(); |
| 866 | f_vty_cbch_setup(use_sdcch4 := true); |
| 867 | f_TC_cbc_load_overload(pars); |
| 868 | } |
| 869 | testcase TC_cbc_sdcch8_load_overload() runs on test_CT { |
| 870 | var CbchTestPars pars := { |
| 871 | use_sdcch4 := true, |
| 872 | basic := valueof(t_CbchPC(msgs_1m_3b_norm)), |
| 873 | extended := omit |
| 874 | }; |
| 875 | |
| 876 | f_init_vty_bsc(); |
| 877 | f_vty_cbch_setup(use_sdcch4 := true); |
| 878 | f_TC_cbc_load_overload(pars); |
| 879 | } |
Harald Welte | df4d0f0 | 2019-05-20 16:04:11 +0200 | [diff] [blame] | 880 | |
Harald Welte | 88e5dff | 2019-05-20 15:14:46 +0200 | [diff] [blame] | 881 | |
Harald Welte | 908ce54 | 2019-09-04 23:05:40 +0200 | [diff] [blame] | 882 | private template GsmRrMessage tr_PagingType1 := { |
| 883 | header := t_RrHeader(PAGING_REQUEST_TYPE_1, ?), |
| 884 | payload :=? |
| 885 | }; |
| 886 | |
| 887 | private template GsmRrMessage tr_PagingType1_empty := { |
| 888 | header := t_RrHeader(PAGING_REQUEST_TYPE_1, 5), |
| 889 | payload := { |
| 890 | pag_req_1 := { |
| 891 | chan_needed := { |
| 892 | second := CHAN_NEED_ANY, |
| 893 | first := CHAN_NEED_ANY |
| 894 | }, |
| 895 | page_mode := PAGE_MODE_NORMAL, |
| 896 | mi1 := { |
Vadim Yanitskiy | 98bb2d5 | 2020-03-28 00:57:21 +0700 | [diff] [blame] | 897 | lengthIndicator := 1, |
| 898 | mobileIdentityV := { |
| 899 | typeOfIdentity := '000'B, |
| 900 | oddEvenInd_identity := { |
| 901 | no_identity := { |
| 902 | oddevenIndicator := '0'B, |
| 903 | fillerDigits := 'F'H |
| 904 | } |
Harald Welte | 908ce54 | 2019-09-04 23:05:40 +0200 | [diff] [blame] | 905 | } |
| 906 | } |
| 907 | }, |
| 908 | mi2 := omit, |
| 909 | rest_octets := ? |
| 910 | } |
| 911 | } |
| 912 | }; |
| 913 | |
| 914 | /* we expect four blocks of 14 bytes, let's fill them with content easily distinguishable */ |
| 915 | const octetstring c_etws_seg0 := '000102030405060708090a0b0c0d'O; |
| 916 | const octetstring c_etws_seg1 := '101112131415161718191a1b1c1d'O; |
| 917 | const octetstring c_etws_seg2 := '202122232425262728292a2b2c2d'O; |
| 918 | const octetstring c_etws_seg3 := '303132333435363738393a3b3c3d'O; |
| 919 | const octetstring c_etws := c_etws_seg0 & c_etws_seg1 & c_etws_seg2 & c_etws_seg3; |
| 920 | |
| 921 | /* Ensure only Paging Type 1 with segmented ETWS Primary Notification are sent after RSL_OSMO_ETWS_CMD */ |
| 922 | testcase TC_etws_p1ro() runs on test_CT { |
| 923 | var template RslChannelNr t_chan_nr := ts_RslChanNr_PCH_AGCH(0); |
| 924 | /* decoding the actual entire P1 rest octets by manually generated code is |
| 925 | * too much effort; instead simply do a binary compare to this constant */ |
| 926 | const bitstring c_P1RO_hdr := '00101011101'B; |
| 927 | var integer seg_received[4] := { 0, 0, 0, 0 }; |
| 928 | var L1ctlDlMessage dl; |
| 929 | timer T := 10.0; |
| 930 | |
| 931 | f_init(); |
| 932 | f_init_l1ctl(); |
| 933 | f_l1_tune(L1CTL, ccch_mode := CCCH_MODE_COMBINED_CBCH); |
| 934 | |
| 935 | RSL_CCHAN.send(ts_RSL_UD(ts_RSL_OSMO_ETWS_CMD(c_etws))); |
| 936 | /* wait for a bit until old non-ETWS Paging messages are gone */ |
| 937 | f_sleep(1.0); |
| 938 | L1CTL.clear; |
| 939 | T.start; |
| 940 | alt { |
| 941 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_chan_nr)) -> value dl { |
| 942 | var GsmRrMessage l3 := dec_GsmRrMessage(dl.payload.data_ind.payload); |
| 943 | select (l3) { |
| 944 | case (tr_PagingType1_empty) { |
| 945 | var octetstring p1ro := l3.payload.pag_req_1.rest_octets; |
| 946 | var bitstring midamble := oct2bit(substr(p1ro, 0, 3)); |
| 947 | var octetstring segment := substr(p1ro, 3, lengthof(p1ro)-3); |
| 948 | var BIT1 not_first := substr(midamble, 11, 1); |
| 949 | var integer seg_nr := bit2int(substr(midamble, 12, 4)); |
| 950 | var boolean err := false; |
| 951 | if (substr(midamble, 0, 11) != c_P1RO_hdr) { |
| 952 | setverdict(fail, "Received unexpected P1 RO header ", midamble); |
| 953 | } |
| 954 | if (not_first == '1'B) { |
| 955 | select (seg_nr) { |
| 956 | case (2) { |
| 957 | if (segment != c_etws_seg1) { |
| 958 | err := true |
| 959 | } else { |
| 960 | seg_received[1] := seg_received[1] + 1; |
| 961 | }} |
| 962 | case (3) { |
| 963 | if (segment != c_etws_seg2) { |
| 964 | err := true |
| 965 | } else { |
| 966 | seg_received[2] := seg_received[2] + 1; |
| 967 | }} |
| 968 | case (4) { |
| 969 | if (segment != c_etws_seg3) { |
| 970 | err := true |
| 971 | } else { |
| 972 | seg_received[3] := seg_received[3] + 1; |
| 973 | }} |
| 974 | case else { setverdict(fail, "Unknown segment Nr ", seg_nr); } |
| 975 | } |
| 976 | if (err) { |
| 977 | setverdict(fail, "Unexpected segment ", seg_nr, ": ", segment); |
| 978 | } |
| 979 | } else { |
| 980 | if (seg_nr != 4) { |
| 981 | setverdict(fail, "Invalid number of segments ", seg_nr); |
| 982 | err := true; |
| 983 | } |
| 984 | if (segment != c_etws_seg0) { |
| 985 | setverdict(fail, "Invalid first segment ", segment); |
| 986 | err := true; |
| 987 | } |
| 988 | if (not err) { |
| 989 | seg_received[0] := seg_received[0] + 1; |
| 990 | } |
| 991 | } |
| 992 | } |
| 993 | case (tr_PagingType1) { |
| 994 | setverdict(fail, "Received unexpected PAGING TYPE 1: ", l3); |
| 995 | } |
| 996 | } |
| 997 | repeat; |
| 998 | } |
| 999 | [] L1CTL.receive { repeat; } |
| 1000 | [] T.timeout { |
| 1001 | setverdict(pass); |
| 1002 | } |
| 1003 | } |
| 1004 | log("Quantity of received ETWS PN segments: ", seg_received); |
| 1005 | var integer i; |
| 1006 | for (i := 0; i < 4; i := i+1) { |
| 1007 | if (seg_received[i] < 15) { |
| 1008 | setverdict(fail, "Segment ", i, " not received often enough"); |
| 1009 | } |
| 1010 | } |
| 1011 | } |
| 1012 | |
| 1013 | /* Ensure only Paging Type 1 without ETWS Primary Notification are sent after disabling them */ |
| 1014 | testcase TC_etws_p1ro_end() runs on test_CT { |
| 1015 | var template RslChannelNr t_chan_nr := ts_RslChanNr_PCH_AGCH(0); |
| 1016 | /* we expect four blocks of 14 bytes, let's fill them with content easily |
| 1017 | * distinguishable */ |
| 1018 | /* decoding the actual entire P1 rest octets by manually generated code is |
| 1019 | * too much effort; instead simply do a binary compare to this constant */ |
| 1020 | const bitstring c_P1RO_hdr := '00101011101'B; |
| 1021 | var L1ctlDlMessage dl; |
| 1022 | timer T := 10.0; |
| 1023 | |
| 1024 | f_init(); |
| 1025 | f_init_l1ctl(); |
| 1026 | f_l1_tune(L1CTL, ccch_mode := CCCH_MODE_COMBINED_CBCH); |
| 1027 | |
| 1028 | RSL_CCHAN.send(ts_RSL_UD(ts_RSL_OSMO_ETWS_CMD(c_etws))); |
| 1029 | /* wait for a bit until old non-ETWS Paging messages are gone */ |
| 1030 | f_sleep(3.0); |
| 1031 | /* disable the ETWS PN again */ |
| 1032 | RSL_CCHAN.send(ts_RSL_UD(ts_RSL_OSMO_ETWS_CMD(''O))); |
| 1033 | f_sleep(2.0); |
| 1034 | T.start; |
| 1035 | L1CTL.clear; |
| 1036 | alt { |
| 1037 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_chan_nr)) -> value dl { |
| 1038 | var GsmRrMessage l3 := dec_GsmRrMessage(dl.payload.data_ind.payload); |
| 1039 | select (l3) { |
| 1040 | case (tr_PagingType1_empty) { repeat; } |
| 1041 | case (tr_PagingType1) { |
| 1042 | setverdict(fail, "Received non-empty PT1 after disabling ETWS PN: ", l3); |
| 1043 | } |
| 1044 | } |
| 1045 | repeat; |
| 1046 | } |
| 1047 | [] L1CTL.receive { repeat; } |
| 1048 | [] T.timeout { |
| 1049 | setverdict(pass); |
| 1050 | } |
| 1051 | } |
| 1052 | } |
| 1053 | |
Harald Welte | 11b734c | 2019-09-05 14:17:54 +0200 | [diff] [blame] | 1054 | /* Ensure ETWS Primary Notification is passed from RSL to PCU interface */ |
| 1055 | testcase TC_etws_pcu() runs on test_CT { |
| 1056 | timer T := 10.0; |
| 1057 | |
| 1058 | f_init(); |
| 1059 | f_init_l1ctl(); |
| 1060 | f_l1_tune(L1CTL, ccch_mode := CCCH_MODE_COMBINED_CBCH); |
| 1061 | |
| 1062 | RSL_CCHAN.send(ts_RSL_UD(ts_RSL_OSMO_ETWS_CMD(c_etws))); |
| 1063 | |
| 1064 | T.start; |
| 1065 | alt { |
| 1066 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_APP_INFO_REQ(0, 0, c_etws))) { |
| 1067 | setverdict(pass); |
| 1068 | } |
| 1069 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_APP_INFO_REQ(?, ?, ?))) { |
| 1070 | setverdict(fail, "PCU socket received invalid APP INFO"); |
| 1071 | } |
| 1072 | [] PCU.receive { repeat; } |
| 1073 | [] T.timeout { |
| 1074 | setverdict(fail, "PCU socket timeout receiving APP INFO (ETWS)"); |
| 1075 | } |
| 1076 | } |
| 1077 | } |
| 1078 | |
| 1079 | |
Harald Welte | 908ce54 | 2019-09-04 23:05:40 +0200 | [diff] [blame] | 1080 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 1081 | /* SMSCB TODO: |
| 1082 | * multiple SMS BC CMD at the same time: Ensure all of them are sent exactly once |
| 1083 | * extended CBCH vs. normal CBCH |
| 1084 | * |
| 1085 | */ |
| 1086 | |
| 1087 | control { |
Harald Welte | 4a129f8 | 2019-05-21 16:35:22 +0200 | [diff] [blame] | 1088 | execute( TC_cbch_load_idle_no_cbch() ); |
| 1089 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 1090 | execute( TC_sms_cb_cmd_sdcch4_1block() ); |
| 1091 | execute( TC_sms_cb_cmd_sdcch4_2block() ); |
| 1092 | execute( TC_sms_cb_cmd_sdcch4_3block() ); |
| 1093 | execute( TC_sms_cb_cmd_sdcch4_4block() ); |
Harald Welte | e0026c3 | 2019-05-20 00:27:30 +0200 | [diff] [blame] | 1094 | execute( TC_sms_cb_cmd_sdcch4_multi() ); |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 1095 | execute( TC_sms_cb_cmd_sdcch4_schedule() ); |
Harald Welte | 88e5dff | 2019-05-20 15:14:46 +0200 | [diff] [blame] | 1096 | execute( TC_sms_cb_cmd_sdcch4_default_only() ); |
Harald Welte | d522ca0 | 2019-05-20 20:06:12 +0200 | [diff] [blame] | 1097 | execute( TC_sms_cb_cmd_sdcch4_default_and_normal() ); |
Harald Welte | df4d0f0 | 2019-05-20 16:04:11 +0200 | [diff] [blame] | 1098 | execute( TC_sms_cb_cmd_sdcch4_default_then_null() ); |
Harald Welte | 4a129f8 | 2019-05-21 16:35:22 +0200 | [diff] [blame] | 1099 | execute( TC_cbc_sdcch4_load_idle() ); |
| 1100 | execute( TC_cbc_sdcch4_load_overload() ); |
| 1101 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 1102 | if (false) { /* FIXME: SDCCH/8 support broken, needs trxcon + L1CTL work */ |
| 1103 | execute( TC_sms_cb_cmd_sdcch8_1block() ); |
| 1104 | execute( TC_sms_cb_cmd_sdcch8_2block() ); |
| 1105 | execute( TC_sms_cb_cmd_sdcch8_3block() ); |
| 1106 | execute( TC_sms_cb_cmd_sdcch8_4block() ); |
Harald Welte | e0026c3 | 2019-05-20 00:27:30 +0200 | [diff] [blame] | 1107 | execute( TC_sms_cb_cmd_sdcch8_multi() ); |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 1108 | execute( TC_sms_cb_cmd_sdcch8_schedule() ); |
Harald Welte | 88e5dff | 2019-05-20 15:14:46 +0200 | [diff] [blame] | 1109 | execute( TC_sms_cb_cmd_sdcch8_default_only() ); |
Harald Welte | d522ca0 | 2019-05-20 20:06:12 +0200 | [diff] [blame] | 1110 | execute( TC_sms_cb_cmd_sdcch8_default_and_normal() ); |
Harald Welte | 4a129f8 | 2019-05-21 16:35:22 +0200 | [diff] [blame] | 1111 | execute( TC_cbc_sdcch8_load_idle() ); |
| 1112 | execute( TC_cbc_sdcch8_load_overload() ); |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 1113 | } |
Harald Welte | 908ce54 | 2019-09-04 23:05:40 +0200 | [diff] [blame] | 1114 | |
| 1115 | execute( TC_etws_p1ro() ); |
| 1116 | execute( TC_etws_p1ro_end() ); |
Harald Welte | 11b734c | 2019-09-05 14:17:54 +0200 | [diff] [blame] | 1117 | execute( TC_etws_pcu() ); |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 1118 | } |
| 1119 | |
| 1120 | |
| 1121 | } |