Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1 | module BTS_Tests { |
| 2 | |
| 3 | import from General_Types all; |
| 4 | import from GSM_Types all; |
| 5 | import from GSM_RR_Types all; |
| 6 | import from Osmocom_Types all; |
| 7 | import from GSM_Types all; |
| 8 | import from GSM_RR_Types all; |
| 9 | import from L1CTL_PortType all; |
| 10 | import from L1CTL_Types all; |
| 11 | import from LAPDm_Types all; |
| 12 | import from Osmocom_CTRL_Adapter all; |
| 13 | |
| 14 | import from RSL_Types all; |
| 15 | import from IPA_Emulation all; |
| 16 | import from RSL_Emulation all; |
| 17 | |
| 18 | import from IPL4asp_Types all; |
| 19 | import from TRXC_Types all; |
| 20 | import from TRXC_CodecPort all; |
| 21 | import from TRXC_CodecPort_CtrlFunct all; |
| 22 | |
| 23 | /* The tests assume a BTS with the following timeslot configuration: |
| 24 | * TS0 : Combined CCCH + SDCCH/4 |
| 25 | * TS1 .. TS 4: TCH/F |
| 26 | * TS5 : TCH/H |
| 27 | * TS6 : SDCCH/8 |
| 28 | * TS7 : PDCH |
| 29 | */ |
| 30 | |
| 31 | modulepar { |
| 32 | charstring mp_rsl_ip := "127.0.0.2"; |
| 33 | integer mp_rsl_port := 3003; |
| 34 | integer mp_trx0_arfcn := 871; |
| 35 | integer mp_bb_trxc_port := 5704; |
| 36 | } |
| 37 | |
| 38 | type component test_CT extends CTRL_Adapter_CT { |
| 39 | var IPA_Emulation_CT vc_IPA; |
| 40 | |
| 41 | var RSL_Emulation_CT vc_RSL; |
| 42 | port RSL_CCHAN_PT RSL_CCHAN; |
| 43 | } |
| 44 | |
| 45 | /* an individual call / channel */ |
| 46 | type component ConnHdlr extends RSL_DchanHdlr { |
| 47 | port L1CTL_PT L1CTL; |
| 48 | |
| 49 | port TRXC_CODEC_PT BB_TRXC; |
| 50 | var integer g_bb_trxc_conn_id; |
| 51 | |
| 52 | timer g_Tguard; |
| 53 | timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */ |
| 54 | |
| 55 | var ConnHdlrPars g_pars; |
| 56 | var uint8_t g_next_meas_res_nr := 0; |
| 57 | } |
| 58 | |
| 59 | function f_init_rsl(charstring id) runs on test_CT { |
| 60 | vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA"); |
| 61 | vc_RSL := RSL_Emulation_CT.create(id & "-RSL"); |
| 62 | |
| 63 | map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 64 | connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT); |
| 65 | connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT); |
| 66 | |
| 67 | vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port)); |
| 68 | vc_RSL.start(RSL_Emulation.main(false)); |
| 69 | } |
| 70 | |
| 71 | type record ConnHdlrPars { |
| 72 | RslChannelNr chan_nr, |
| 73 | RSL_IE_ChannelMode chan_mode, |
| 74 | float t_guard, |
| 75 | ConnL1Pars l1_pars |
| 76 | } |
| 77 | |
| 78 | |
| 79 | /* global init function */ |
| 80 | function f_init(charstring id) runs on test_CT { |
| 81 | f_init_rsl(id); |
| 82 | RSL_CCHAN.receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_UP}); |
| 83 | } |
| 84 | |
| 85 | type function void_fn(charstring id) runs on ConnHdlr; |
| 86 | |
| 87 | /* create a new test component */ |
| 88 | function f_start_handler(void_fn fn, ConnHdlrPars pars) |
| 89 | runs on test_CT return ConnHdlr { |
| 90 | var charstring id := testcasename(); |
| 91 | var ConnHdlr vc_conn; |
| 92 | |
| 93 | vc_conn := ConnHdlr.create(id); |
| 94 | /* connect to RSL Emulation main component */ |
| 95 | connect(vc_conn:RSL, vc_RSL:CLIENT_PT); |
| 96 | connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC); |
| 97 | |
| 98 | vc_conn.start(f_handler_init(fn, id, pars)); |
| 99 | return vc_conn; |
| 100 | } |
| 101 | |
| 102 | private altstep as_Tguard() runs on ConnHdlr { |
| 103 | [] g_Tguard.timeout { |
| 104 | setverdict(fail, "Tguard timeout"); |
| 105 | self.stop; |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | private function f_l1_tune() runs on ConnHdlr { |
| 110 | /* tune our virtual L1 to the right ARFCN */ |
| 111 | //var BCCH_tune_req tune_req := { arfcn := { false, mp_trx0_arfcn }, combined_ccch := true }; |
| 112 | //L1.send(tune_req); |
| 113 | f_L1CTL_FBSB(L1CTL, { false, mp_trx0_arfcn }, CCCH_MODE_COMBINED); |
| 114 | } |
| 115 | |
| 116 | private function f_trxc_connect() runs on ConnHdlr { |
| 117 | map(self:BB_TRXC, system:BB_TRXC); |
| 118 | var Result res; |
| 119 | res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BB_TRXC, "127.0.0.1", mp_bb_trxc_port, |
| 120 | "127.0.0.1", 0, -1, {udp:={}}, {}); |
| 121 | g_bb_trxc_conn_id := res.connId; |
| 122 | } |
| 123 | |
| 124 | private function f_trxc_fake_rssi(uint8_t rssi) runs on ConnHdlr { |
| 125 | BB_TRXC.send(ts_TRXC_Send(g_bb_trxc_conn_id, ts_TRXC_FAKE_RSSI(rssi))); |
| 126 | } |
| 127 | |
| 128 | private function f_trx_fake_toffs256(int16_t toffs256) runs on ConnHdlr { |
| 129 | BB_TRXC.send(ts_TRXC_Send(g_bb_trxc_conn_id, ts_TRXC_FAKE_TIMING(toffs256))); |
| 130 | } |
| 131 | |
| 132 | /* first function started in ConnHdlr component */ |
| 133 | private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars) |
| 134 | runs on ConnHdlr { |
| 135 | g_pars := pars; |
| 136 | g_chan_nr := pars.chan_nr; |
| 137 | |
| 138 | map(self:L1CTL, system:L1CTL); |
| 139 | f_connect_reset(L1CTL); |
| 140 | |
| 141 | f_trxc_connect(); |
| 142 | |
| 143 | g_Tguard.start(pars.t_guard); |
| 144 | activate(as_Tguard()); |
| 145 | |
| 146 | f_rslem_register(0, pars.chan_nr); |
| 147 | |
| 148 | /* call the user-supplied test case function */ |
| 149 | fn.apply(id); |
| 150 | } |
| 151 | |
| 152 | |
| 153 | function f_rsl_chan_act(RSL_IE_ChannelMode mode) runs on ConnHdlr { |
| 154 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, mode)); |
| 155 | alt { |
| 156 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
| 157 | g_Tmeas_exp.start; |
| 158 | } |
| 159 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 160 | setverdict(fail, "Unexpected RF CHAN ACT NACK"); |
| 161 | } |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | function f_rsl_chan_deact() runs on ConnHdlr { |
| 166 | timer T := 3.0; |
| 167 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 168 | T.start; |
| 169 | alt { |
| 170 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 171 | g_Tmeas_exp.stop; |
| 172 | } |
| 173 | [] T.timeout { |
| 174 | setverdict(fail, "Timeout waiting for RF CHAN REL ACK"); |
| 175 | } |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | |
| 180 | private template ConnHdlrPars t_Pars(template RslChannelNr chan_nr, |
| 181 | template RSL_IE_ChannelMode chan_mode, |
| 182 | float t_guard := 20.0) := { |
| 183 | chan_nr := valueof(chan_nr), |
| 184 | chan_mode := valueof(chan_mode), |
| 185 | t_guard := t_guard, |
| 186 | l1_pars := { |
| 187 | dtx_enabled := false, |
| 188 | meas_ul := { |
| 189 | full := { |
| 190 | rxlev := dbm2rxlev(-53), |
| 191 | rxqual := 0 |
| 192 | }, |
| 193 | sub := { |
| 194 | rxlev := dbm2rxlev(-53), |
| 195 | rxqual := 0 |
| 196 | } |
| 197 | }, |
| 198 | timing_offset_256syms := 0, |
| 199 | bs_power_level := 0, |
| 200 | ms_power_level := 0, |
| 201 | ms_actual_ta := 0 |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | /* Stress test: Do 500 channel activations/deactivations in rapid succession */ |
| 206 | function f_TC_chan_act_stress(charstring id) runs on ConnHdlr { |
| 207 | for (var integer i := 0; i < 500; i := i+1) { |
| 208 | f_rsl_chan_act(g_pars.chan_mode); |
| 209 | f_rsl_chan_deact(); |
| 210 | } |
| 211 | setverdict(pass); |
| 212 | } |
| 213 | testcase TC_chan_act_stress() runs on test_CT { |
| 214 | var ConnHdlr vc_conn; |
| 215 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 216 | f_init(testcasename()); |
| 217 | vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars); |
| 218 | vc_conn.done; |
| 219 | } |
| 220 | |
| 221 | /* Test if re-activation of an already active channel fails as expected */ |
| 222 | function f_TC_chan_act_react(charstring id) runs on ConnHdlr { |
| 223 | f_rsl_chan_act(g_pars.chan_mode); |
| 224 | /* attempt to activate the same lchan again -> expect reject */ |
| 225 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 226 | alt { |
| 227 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
| 228 | setverdict(fail, "Unexpected CHAN ACT ACK on double activation"); |
| 229 | } |
| 230 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 231 | setverdict(pass); |
| 232 | } |
| 233 | } |
| 234 | f_rsl_chan_deact(); |
| 235 | } |
| 236 | testcase TC_chan_act_react() runs on test_CT { |
| 237 | var ConnHdlr vc_conn; |
| 238 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 239 | f_init(testcasename()); |
| 240 | vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars); |
| 241 | vc_conn.done; |
| 242 | } |
| 243 | |
| 244 | /* Attempt to de-activate a channel that's not active */ |
| 245 | function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr { |
| 246 | timer T := 3.0; |
| 247 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 248 | T.start; |
| 249 | alt { |
| 250 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 251 | setverdict(pass); |
| 252 | } |
| 253 | [] T.timeout { |
| 254 | setverdict(fail, "Timeout expecting RF_CHAN_REL_ACK"); |
| 255 | } |
| 256 | } |
| 257 | } |
| 258 | testcase TC_chan_deact_not_active() runs on test_CT { |
| 259 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 260 | f_init(testcasename()); |
| 261 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars); |
| 262 | vc_conn.done; |
| 263 | } |
| 264 | |
| 265 | /* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */ |
| 266 | function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr { |
| 267 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 268 | alt { |
| 269 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
| 270 | setverdict(fail, "Unexpected CHAN ACT ACK"); |
| 271 | } |
| 272 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 273 | setverdict(pass); |
| 274 | } |
| 275 | } |
| 276 | } |
| 277 | private type record WrongChanNrCase { |
| 278 | RslChannelNr chan_nr, |
| 279 | charstring description |
| 280 | } |
| 281 | private type record of WrongChanNrCase WrongChanNrCases; |
| 282 | private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := { |
| 283 | chan_nr := chan_nr, |
| 284 | description := desc |
| 285 | } |
| 286 | |
| 287 | testcase TC_chan_act_wrong_nr() runs on test_CT { |
| 288 | var ConnHdlr vc_conn; |
| 289 | var ConnHdlrPars pars; |
| 290 | |
| 291 | f_init(testcasename()); |
| 292 | |
| 293 | var WrongChanNrCases wrong := { |
| 294 | valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")), |
| 295 | valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")), |
| 296 | valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")), |
| 297 | valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")), |
| 298 | valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")), |
| 299 | valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")), |
| 300 | valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")), |
| 301 | valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")), |
| 302 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")), |
| 303 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")), |
| 304 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")), |
| 305 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")), |
| 306 | valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H")) |
| 307 | }; |
| 308 | |
| 309 | for (var integer i := 0; i < sizeof(wrong); i := i+1) { |
| 310 | pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN)); |
| 311 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars); |
| 312 | vc_conn.done; |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | function f_TC_chan_req(charstring id) runs on ConnHdlr { |
| 317 | f_l1_tune(); |
| 318 | |
| 319 | RSL.clear; |
| 320 | //L1.send(DCCH_establish_req:{ra := 23}); |
| 321 | /* This arrives on CCHAN, so we cannot test here */ |
| 322 | //RSL.receive(tr_RSL_CHAN_RQD(int2oct(23,1))); |
| 323 | } |
| 324 | testcase TC_chan_req() runs on test_CT { |
| 325 | var ConnHdlr vc_conn; |
| 326 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 327 | f_init(testcasename()); |
| 328 | vc_conn := f_start_handler(refers(f_TC_chan_req), pars); |
| 329 | vc_conn.done; |
| 330 | } |
| 331 | |
| 332 | template LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, boolean c_r) := { |
| 333 | spare := '0'B, |
| 334 | lpd := 0, |
| 335 | sapi := sapi, |
| 336 | c_r := c_r, |
| 337 | ea := true |
| 338 | } |
| 339 | |
| 340 | template LapdmFrameB ts_LAPDm_B(LapdmSapi sapi, boolean c_r, boolean p, octetstring pl) := { |
| 341 | addr := ts_LapdmAddr(sapi, c_r), |
| 342 | ctrl := t_LapdmCtrlUI(p), |
| 343 | len := 0, /* overwritten */ |
| 344 | m := false, |
| 345 | el := 1, |
| 346 | payload := pl |
| 347 | } |
| 348 | |
| 349 | /* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */ |
| 350 | altstep as_l1_sacch() runs on ConnHdlr { |
| 351 | var L1ctlDlMessage l1_dl; |
| 352 | [] L1CTL.receive(t_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 353 | log("SACCH received: ", l1_dl.payload.data_ind.payload); |
| 354 | var GsmRrL3Message meas_rep := valueof(ts_MEAS_REP(true, 23, 23, 0, 0, omit)); |
| 355 | var LapdmFrameB lb := valueof(ts_LAPDm_B(0, false, false, enc_GsmRrL3Message(meas_rep))); |
| 356 | log("LAPDm: ", lb); |
| 357 | var octetstring pl := '0000'O & enc_LapdmFrameB(lb); |
| 358 | L1CTL.send(t_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_SACCH(0), pl)); |
| 359 | repeat; |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | altstep as_l1_dcch() runs on ConnHdlr { |
| 364 | var L1ctlDlMessage l1_dl; |
| 365 | [] L1CTL.receive(t_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value l1_dl { |
| 366 | log("DCCH received: ", l1_dl.payload.data_ind.payload); |
| 367 | var octetstring pl := '010301'O; |
| 368 | L1CTL.send(t_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), pl)); |
| 369 | repeat; |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | type record MeasElem { |
| 374 | uint6_t rxlev, |
| 375 | uint3_t rxqual |
| 376 | } |
| 377 | |
| 378 | type record MeasElemFS { |
| 379 | MeasElem full, |
| 380 | MeasElem sub |
| 381 | } |
| 382 | |
| 383 | type record ConnL1Pars { |
| 384 | boolean dtx_enabled, |
| 385 | MeasElemFS meas_ul, |
| 386 | int16_t timing_offset_256syms, |
| 387 | uint5_t bs_power_level, |
| 388 | uint5_t ms_power_level, |
| 389 | uint8_t ms_actual_ta |
| 390 | } |
| 391 | |
| 392 | /* Convert tiing offset from 1/256th symbol to RSL Timing Offset */ |
| 393 | private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t { |
| 394 | return 63 + (toffs256s/256); |
| 395 | } |
| 396 | |
| 397 | /* build a template for matching measurement results against */ |
| 398 | private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message { |
| 399 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 400 | var template RSL_IE_UplinkMeas ul_meas := { |
| 401 | len := 3, |
| 402 | rfu := '0'B, |
| 403 | dtx_d := l1p.dtx_enabled, |
| 404 | rxlev_f_u := l1p.meas_ul.full.rxlev, |
| 405 | reserved1 := '00'B, |
| 406 | rxlev_s_u := l1p.meas_ul.sub.rxlev, |
| 407 | reserved2 := '00'B, |
| 408 | rxq_f_u := l1p.meas_ul.full.rxqual, |
| 409 | rxq_s_u := l1p.meas_ul.sub.rxqual, |
| 410 | supp_meas_info := omit |
| 411 | }; |
| 412 | /* HACK HACK HACK FIXME HACK HACK HACK see https://osmocom.org/issues/2988 */ |
| 413 | ul_meas.rxlev_f_u := ?; |
| 414 | ul_meas.rxlev_s_u := ?; |
| 415 | ul_meas.rxq_f_u := ?; |
| 416 | ul_meas.rxq_s_u := ?; |
| 417 | var template RSL_IE_BS_Power bs_power := { |
| 418 | reserved := 0, |
| 419 | epc := false, |
| 420 | fpc := false, |
| 421 | power_level := l1p.bs_power_level |
| 422 | }; |
| 423 | var template RSL_IE_L1Info l1_info := { |
| 424 | ms_power_lvl := l1p.ms_power_level, |
| 425 | fpc := false, |
| 426 | reserved := 0, |
| 427 | actual_ta := l1p.ms_actual_ta |
| 428 | }; |
| 429 | var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms); |
| 430 | var template uint8_t t_toffs := (offs-1 .. offs+1); /* some tolerance */ |
| 431 | return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info, |
| 432 | ?, t_toffs); |
| 433 | } |
| 434 | |
| 435 | /* verify we regularly receive measurement reports with incrementing numbers */ |
| 436 | altstep as_meas_res() runs on ConnHdlr { |
| 437 | var RSL_Message rsl; |
| 438 | [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl { |
| 439 | /* increment counter of next to-be-expected meas rep */ |
| 440 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 441 | /* Re-start the timer expecting the next MEAS RES */ |
| 442 | g_Tmeas_exp.start; |
| 443 | repeat; |
| 444 | } |
| 445 | [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, g_next_meas_res_nr)) -> value rsl { |
| 446 | setverdict(fail, "Received unspecific MEAS RES ", rsl); |
| 447 | self.stop; |
| 448 | } |
| 449 | [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl { |
| 450 | setverdict(fail, "Received unexpected MEAS RES ", rsl); |
| 451 | self.stop; |
| 452 | } |
| 453 | [] g_Tmeas_exp.timeout { |
| 454 | setverdict(fail, "Didn't receive expected measurement result") |
| 455 | self.stop; |
| 456 | } |
| 457 | } |
| 458 | |
| 459 | /* Establish dedicated channel: L1CTL + RSL side */ |
| 460 | private function f_est_dchan() runs on ConnHdlr { |
| 461 | var GsmFrameNumber fn; |
| 462 | var ImmediateAssignment imm_ass; |
| 463 | var integer ra := 23; |
| 464 | |
| 465 | fn := f_L1CTL_RACH(L1CTL, ra); |
| 466 | /* This arrives on CCHAN, so we cannot test for receiving CHAN RQDhere */ |
| 467 | //RSL.receive(tr_RSL_CHAN_RQD(int2oct(23,1))); |
| 468 | |
| 469 | /* Activate channel on BTS side */ |
| 470 | f_rsl_chan_act(g_pars.chan_mode); |
| 471 | |
| 472 | /* Send IMM.ASS via CCHAN */ |
| 473 | var ChannelDescription ch_desc := { |
| 474 | chan_nr := g_pars.chan_nr, |
| 475 | tsc := 7, |
| 476 | h := false, |
| 477 | arfcn := mp_trx0_arfcn, |
| 478 | maio_hsn := omit |
| 479 | }; |
| 480 | var MobileAllocation ma := { |
| 481 | len := 0, |
| 482 | ma := ''B |
| 483 | }; |
| 484 | var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, ma)); |
| 485 | RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg))); |
| 486 | |
| 487 | /* receive IMM.ASS on MS side */ |
| 488 | var ImmediateAssignment ia_um; |
| 489 | ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn); |
| 490 | /* enable dedicated mode */ |
| 491 | f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um); |
| 492 | } |
| 493 | |
| 494 | /* establish DChan, verify existance + contents of measurement reports */ |
| 495 | function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr { |
| 496 | f_l1_tune(); |
| 497 | RSL.clear; |
| 498 | |
| 499 | g_pars.l1_pars.meas_ul.full.rxlev := dbm2rxlev(-100); |
| 500 | g_pars.l1_pars.meas_ul.sub.rxlev := g_pars.l1_pars.meas_ul.full.rxlev; |
| 501 | f_trxc_fake_rssi(100); |
| 502 | |
| 503 | g_pars.l1_pars.timing_offset_256syms := 512; /* 2 symbols */ |
| 504 | f_trx_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 505 | |
| 506 | f_est_dchan(); |
| 507 | |
| 508 | /* run for a number of seconds, send SACCH + FACCH from MS side and verify |
| 509 | * RSL measurement reports on Abis side */ |
| 510 | timer T := 8.0; |
| 511 | T.start; |
| 512 | alt { |
| 513 | [] as_l1_sacch(); |
| 514 | [] as_meas_res(); |
| 515 | [] as_l1_dcch(); |
| 516 | [] L1CTL.receive { repeat; } |
| 517 | [g_Tmeas_exp.running] T.timeout { |
| 518 | /* as_meas_res() would have done setverdict(fail) / self.stop in case |
| 519 | * of any earlier errors, so if we reach this timeout, we're good */ |
| 520 | setverdict(pass); |
| 521 | } |
| 522 | [] T.timeout { |
| 523 | setverdict(fail, "No MEAS RES received at all"); |
| 524 | } |
| 525 | } |
| 526 | f_rsl_chan_deact(); |
| 527 | } |
| 528 | testcase TC_meas_res_sign_tchf() runs on test_CT { |
| 529 | var ConnHdlr vc_conn; |
| 530 | var ConnHdlrPars pars; |
| 531 | f_init(testcasename()); |
| 532 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 533 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 534 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars); |
| 535 | vc_conn.done; |
| 536 | } |
| 537 | } |
| 538 | testcase TC_meas_res_sign_tchh() runs on test_CT { |
| 539 | var ConnHdlr vc_conn; |
| 540 | var ConnHdlrPars pars; |
| 541 | f_init(testcasename()); |
| 542 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
| 543 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN)); |
| 544 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars); |
| 545 | vc_conn.done; |
| 546 | } |
| 547 | } |
| 548 | testcase TC_meas_res_sign_sdcch4() runs on test_CT { |
| 549 | var ConnHdlr vc_conn; |
| 550 | var ConnHdlrPars pars; |
| 551 | f_init(testcasename()); |
| 552 | for (var integer ss := 0; ss <= 3; ss := ss+1) { |
| 553 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0, ss), ts_RSL_ChanMode_SIGN)); |
| 554 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars); |
| 555 | vc_conn.done; |
| 556 | } |
| 557 | } |
| 558 | testcase TC_meas_res_sign_sdcch8() runs on test_CT { |
| 559 | var ConnHdlr vc_conn; |
| 560 | var ConnHdlrPars pars; |
| 561 | f_init(testcasename()); |
| 562 | for (var integer ss := 0; ss <= 7; ss := ss+1) { |
| 563 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, ss), ts_RSL_ChanMode_SIGN)); |
| 564 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars); |
| 565 | vc_conn.done; |
| 566 | } |
| 567 | } |
| 568 | |
| 569 | /* Test if a channel without valid uplink bursts generates RSL CONN FAIL IND */ |
| 570 | private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr { |
| 571 | f_l1_tune(); |
| 572 | RSL.clear; |
| 573 | |
| 574 | f_est_dchan(); |
| 575 | f_sleep(2.0); |
| 576 | L1CTL.send(t_L1CTL_DM_REL_REQ(g_chan_nr)); |
| 577 | |
| 578 | timer T := 40.0; |
| 579 | T.start; |
| 580 | alt { |
| 581 | [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) { |
| 582 | setverdict(pass) |
| 583 | } |
| 584 | [] RSL.receive { repeat }; |
| 585 | [] T.timeout { |
| 586 | setverdict(fail, "No CONN FAIL IND received"); |
| 587 | } |
| 588 | } |
| 589 | f_rsl_chan_deact(); |
| 590 | } |
| 591 | testcase TC_conn_fail_crit() runs on test_CT { |
| 592 | var ConnHdlr vc_conn; |
| 593 | var ConnHdlrPars pars; |
| 594 | f_init(testcasename()); |
| 595 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN)); |
| 596 | pars.t_guard := 60.0; |
| 597 | vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars); |
| 598 | vc_conn.done; |
| 599 | } |
| 600 | |
| 601 | |
| 602 | |
| 603 | |
| 604 | control { |
| 605 | execute( TC_chan_act_stress() ); |
| 606 | execute( TC_chan_act_react() ); |
| 607 | execute( TC_chan_deact_not_active() ); |
| 608 | execute( TC_chan_act_wrong_nr() ); |
| 609 | execute( TC_chan_req() ); |
| 610 | execute( TC_meas_res_sign_tchf() ); |
| 611 | execute( TC_meas_res_sign_tchh() ); |
| 612 | execute( TC_meas_res_sign_sdcch4() ); |
| 613 | execute( TC_meas_res_sign_sdcch8() ); |
| 614 | execute( TC_conn_fail_crit() ); |
| 615 | } |
| 616 | |
| 617 | |
| 618 | } |