Harald Welte | 97cca2f | 2019-05-30 16:33:38 +0200 | [diff] [blame] | 1 | module BTS_Tests_LAPDm { |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 2 | |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 3 | import from GSM_Types all; |
| 4 | import from Osmocom_Types all; |
| 5 | import from LAPDm_RAW_PT all; |
| 6 | import from LAPDm_Types all; |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 7 | import from RSL_Types all; |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 8 | import from BTS_Tests all; |
Vadim Yanitskiy | eec14f0 | 2020-07-14 19:04:18 +0700 | [diff] [blame] | 9 | import from GSM_RR_Types all; |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 10 | import from Misc_Helpers all; |
Harald Welte | 66110f0 | 2017-07-16 21:05:18 +0200 | [diff] [blame] | 11 | |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 12 | /* test that use exclusively only LAPDm over L1CTL */ |
| 13 | type component lapdm_test_CT { |
| 14 | port LAPDm_PT LAPDM; |
| 15 | var lapdm_CT lapdm_component; |
| 16 | }; |
| 17 | |
| 18 | /* contrary to BTS_Tests.ttcn, we use LAPDm_PT here, a convenience wrapper |
| 19 | * around L1CTL to perform encode/decode of abstract LAPDm frames */ |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 20 | |
Harald Welte | 61332c0 | 2019-05-30 16:45:15 +0200 | [diff] [blame] | 21 | /********************************************************************************* |
| 22 | * Test using only L1CTL/LAPDm |
| 23 | *********************************************************************************/ |
| 24 | |
| 25 | function f_lapdm_init() runs on lapdm_test_CT { |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 26 | /* create the LAPDm component */ |
| 27 | lapdm_component := lapdm_CT.create; |
| 28 | /* connect our own LAPDM port to the LAPDM Service Provider of the LAPDm component */ |
| 29 | connect(self:LAPDM, lapdm_component:LAPDM_SP); |
| 30 | /* connect the LAPDm compoent's lower-side port to the system L1CTL port (which is internally |
| 31 | * connected to the Unix Domain Socket test port */ |
| 32 | map(lapdm_component:L1CTL, system:L1CTL); |
| 33 | |
| 34 | /* start the LAPDm parallel component calling it's local function LAPDmStart */ |
| 35 | lapdm_component.start(LAPDmStart()); |
| 36 | } |
| 37 | |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 38 | function f_lapdm_exit() runs on lapdm_test_CT { |
| 39 | lapdm_component.stop; |
| 40 | lapdm_component.done; |
| 41 | unmap(lapdm_component:L1CTL, system:L1CTL); |
| 42 | } |
| 43 | |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 44 | /* master function switching to a dedicated radio channel */ |
Vadim Yanitskiy | eec14f0 | 2020-07-14 19:04:18 +0700 | [diff] [blame] | 45 | function f_switch_dcch() runs on ConnHdlr { |
| 46 | var BCCH_tune_req tune_req := { arfcn := { false, mp_trx0_arfcn }, combined_ccch := true }; |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 47 | var DCCH_switch_req sw_req; |
Vadim Yanitskiy | eec14f0 | 2020-07-14 19:04:18 +0700 | [diff] [blame] | 48 | |
| 49 | /* Craft channel description (with or without frequency hopping parameters) */ |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 50 | if (g_pars.fhp.enabled) { |
| 51 | sw_req.chan_desc := valueof(ts_ChanDescH1(g_pars.chan_nr, g_pars.fhp.maio_hsn)); |
| 52 | sw_req.ma := g_pars.fhp.ma; |
Vadim Yanitskiy | eec14f0 | 2020-07-14 19:04:18 +0700 | [diff] [blame] | 53 | } else { |
| 54 | sw_req.chan_desc := valueof(ts_ChanDescH0(g_pars.chan_nr, mp_trx0_arfcn)); |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 55 | sw_req.ma := omit; |
Vadim Yanitskiy | eec14f0 | 2020-07-14 19:04:18 +0700 | [diff] [blame] | 56 | } |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 57 | |
| 58 | LAPDM.send(tune_req); |
| 59 | LAPDM.send(sw_req); |
| 60 | LAPDM.receive(DCCH_switch_res:?); |
| 61 | } |
| 62 | |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 63 | /* helper function releasing dedicated radio channel physically (no Um signaling!) */ |
| 64 | function f_release_dcch() runs on lapdm_test_CT { |
| 65 | var DCCH_release_req rel_req := {}; |
| 66 | LAPDM.send(rel_req); |
| 67 | } |
| 68 | |
| 69 | template LAPDm_ph_data t_PH_DATA(template GsmSapi sapi, template boolean sacch, template LapdmFrame frame) := { |
| 70 | sacch := sacch, |
| 71 | sapi := sapi, |
| 72 | lapdm := frame |
| 73 | } |
Harald Welte | c38611b | 2019-05-30 16:33:58 +0200 | [diff] [blame] | 74 | |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 75 | function f_test_sabm_results_in_ua(uint8_t sapi, boolean use_sacch, octetstring payload) runs on ConnHdlr return boolean { |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 76 | var LAPDm_ph_data phd; |
| 77 | var boolean result := false; |
| 78 | timer T := 5.0; |
| 79 | |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 80 | LAPDM.send(t_PH_DATA(sapi, use_sacch, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, p:=false, l3:=payload))); |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 81 | T.start |
| 82 | alt { |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 83 | [] LAPDM.receive(t_PH_DATA(?, use_sacch, tr_LAPDm_UA(sapi, cr_MT_RSP, f:=false, l3:=payload))) { result := true; } |
| 84 | [] RSL.receive {repeat;} |
| 85 | [] LAPDM.receive { repeat; } |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 86 | [] T.timeout { } |
| 87 | } |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 88 | LAPDM.send(t_PH_DATA(sapi, use_sacch, ts_LAPDm_RR(sapi, c_r:=cr_MT_CMD, p:=false, nr:=0))); |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 89 | return result; |
| 90 | } |
| 91 | |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 92 | function f_TC_sabm_ua_dcch_sapi0(charstring id) runs on ConnHdlr { |
| 93 | fp_common_init(); |
| 94 | RSL.clear; |
| 95 | LAPDM.clear; |
| 96 | var default d := activate(as_ignore_background()); |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 97 | if (not f_test_sabm_results_in_ua(0, false, 'FEFE'O)) { |
| 98 | setverdict(fail); |
| 99 | } |
| 100 | setverdict(pass); |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 101 | deactivate(d); |
| 102 | fp_common_fini(); |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 103 | } |
| 104 | |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 105 | function f_TC_sabm_ua_dcch_sapi0_nopayload(charstring id) runs on ConnHdlr { |
| 106 | fp_common_init(); |
| 107 | RSL.clear; |
| 108 | LAPDM.clear; |
| 109 | var default d := activate(as_ignore_background()); |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 110 | if (f_test_sabm_results_in_ua(0, false, ''O)) { |
| 111 | setverdict(fail, "Initial SABM/UA must contain L3 payload but BTS accepts without"); |
| 112 | } |
| 113 | setverdict(pass); |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 114 | deactivate(d); |
| 115 | fp_common_fini(); |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 116 | } |
| 117 | |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 118 | function f_TC_sabm_ua_dcch_sapi3(charstring id) runs on ConnHdlr { |
| 119 | fp_common_init(); |
| 120 | RSL.clear; |
| 121 | LAPDM.clear; |
| 122 | var default d := activate(as_ignore_background()); |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 123 | if (f_test_sabm_results_in_ua(3, false, 'FEFE'O)) { |
| 124 | setverdict(fail, "Initial SABM/UA must be on SAPI0, but BTS accepts SAPI=3"); |
| 125 | } |
| 126 | setverdict(pass); |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 127 | deactivate(d); |
| 128 | fp_common_fini(); |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 129 | } |
| 130 | |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 131 | function f_TC_sabm_ua_dcch_sapi4(charstring id) runs on ConnHdlr { |
| 132 | fp_common_init(); |
| 133 | RSL.clear; |
| 134 | LAPDM.clear; |
| 135 | var default d := activate(as_ignore_background()); |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 136 | if (f_test_sabm_results_in_ua(4, false, 'FEFE'O)) { |
| 137 | setverdict(fail, "Initial SABM/UA must be on SAPI0, but BTS accepts SAPI=4"); |
| 138 | } |
| 139 | setverdict(pass); |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 140 | deactivate(d); |
| 141 | fp_common_fini(); |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 142 | } |
| 143 | |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 144 | testcase TC_sabm_ua_dcch_sapi0() runs on test_CT { |
| 145 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 146 | f_testmatrix_each_chan(pars, refers(f_TC_sabm_ua_dcch_sapi0)); |
| 147 | } |
| 148 | |
| 149 | testcase TC_sabm_ua_dcch_sapi0_nopayload() runs on test_CT { |
| 150 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 151 | f_testmatrix_each_chan(pars, refers(f_TC_sabm_ua_dcch_sapi0_nopayload)); |
| 152 | } |
| 153 | |
| 154 | testcase TC_sabm_ua_dcch_sapi3() runs on test_CT { |
| 155 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 156 | f_testmatrix_each_chan(pars, refers(f_TC_sabm_ua_dcch_sapi3)); |
| 157 | } |
| 158 | |
| 159 | testcase TC_sabm_ua_dcch_sapi4() runs on test_CT { |
| 160 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 161 | f_testmatrix_each_chan(pars, refers(f_TC_sabm_ua_dcch_sapi4)); |
| 162 | } |
| 163 | |
| 164 | function f_TC_sabm_contention(charstring id) runs on ConnHdlr { |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 165 | var LAPDm_ph_data phd; |
| 166 | const octetstring payload := '0102030405'O; |
| 167 | const GsmSapi sapi := 0; |
| 168 | const boolean use_sacch := false; |
| 169 | timer T := 5.0; |
| 170 | |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 171 | fp_common_init(); |
| 172 | RSL.clear; |
| 173 | LAPDM.clear; |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 174 | |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 175 | /* first frame is our real SABM */ |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 176 | LAPDM.send(t_PH_DATA(sapi, use_sacch, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, p:=false, l3:=payload))); |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 177 | /* second frame is a SABM with different payload, which BTS has to ignore according to 8.4.1.4 */ |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 178 | LAPDM.send(t_PH_DATA(sapi, use_sacch, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, p:=false, l3:='ABCDEF'O))); |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 179 | T.start |
| 180 | alt { |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 181 | [] LAPDM.receive(t_PH_DATA(?, use_sacch, tr_LAPDm_UA(sapi, cr_MT_RSP, f:=false, l3:=payload))) { setverdict(pass); repeat; } |
| 182 | [] LAPDM.receive(t_PH_DATA(?, use_sacch, tr_LAPDm_UA(sapi, cr_MT_RSP, f:=false, l3:=?))) { |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 183 | setverdict(fail, "Second SABM was responded to during contention resolution"); |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 184 | } |
| 185 | [] RSL.receive {repeat;} |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 186 | [] LAPDM.receive { repeat }; |
| 187 | [] T.timeout { } |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 188 | } |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 189 | |
| 190 | fp_common_fini(); |
| 191 | } |
| 192 | |
| 193 | testcase TC_sabm_contention() runs on test_CT { |
| 194 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 195 | f_testmatrix_each_chan(pars, refers(f_TC_sabm_contention)); |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 196 | } |
Harald Welte | 9e4725d | 2017-07-16 23:18:09 +0200 | [diff] [blame] | 197 | |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 198 | /* we test that a re-transmitted SABM with identical payload will result in the retransmission of a |
| 199 | * UA. This is required during the contention resolution procedure as specified in 8.4.1.4 */ |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 200 | function f_TC_sabm_retransmit(charstring id) runs on ConnHdlr { |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 201 | const octetstring payload := '00FEFEDEADBEEF'O; |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 202 | fp_common_init(); |
| 203 | RSL.clear; |
| 204 | LAPDM.clear; |
| 205 | var default d := activate(as_ignore_background()); |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 206 | if (not f_test_sabm_results_in_ua(0, false, payload)) { |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 207 | setverdict(fail); |
Harald Welte | 599faa1 | 2017-07-17 21:49:24 +0200 | [diff] [blame] | 208 | } |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 209 | if (not f_test_sabm_results_in_ua(0, false, payload)) { |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 210 | setverdict(fail); |
Harald Welte | d4ba7ff | 2017-07-17 21:00:48 +0200 | [diff] [blame] | 211 | } |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 212 | setverdict(pass); |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 213 | deactivate(d); |
| 214 | fp_common_fini(); |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 215 | } |
Harald Welte | d4ba7ff | 2017-07-17 21:00:48 +0200 | [diff] [blame] | 216 | |
Eric Wild | 74f25ae | 2019-06-14 11:44:29 +0200 | [diff] [blame] | 217 | testcase TC_sabm_retransmit() runs on test_CT { |
| 218 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 219 | f_testmatrix_each_chan(pars, refers(f_TC_sabm_retransmit)); |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 220 | } |
Harald Welte | d4ba7ff | 2017-07-17 21:00:48 +0200 | [diff] [blame] | 221 | |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 222 | /********************************************************************************* |
| 223 | * Test using both L1CTL/LAPDm and RSL |
| 224 | *********************************************************************************/ |
| 225 | |
| 226 | private function fp_common_init() runs on ConnHdlr |
| 227 | { |
| 228 | /* undo what f_start_handler is doing and pull LAPDm_CT into the loop */ |
| 229 | unmap(self:L1CTL, system:L1CTL); |
| 230 | f_lapdm_init(); |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 231 | |
| 232 | /* Obtain frequency hopping parameters for a given timeslot */ |
| 233 | if (mp_freq_hop_enabled and mp_transceiver_num > 1) { |
Vadim Yanitskiy | ca81392 | 2020-09-12 19:08:31 +0700 | [diff] [blame] | 234 | f_resolve_fh_params(g_pars.fhp, g_pars.chan_nr.tn); |
Vadim Yanitskiy | a989428 | 2020-07-14 01:56:15 +0700 | [diff] [blame] | 235 | } |
| 236 | |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 237 | /* activate the channel on the BTS side */ |
| 238 | f_rsl_chan_act(g_pars.chan_mode, false, {}); |
| 239 | /* activate the channel on the MS side */ |
Vadim Yanitskiy | eec14f0 | 2020-07-14 19:04:18 +0700 | [diff] [blame] | 240 | f_switch_dcch(); |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | private function fp_common_fini() runs on ConnHdlr |
| 244 | { |
| 245 | f_release_dcch(); |
| 246 | f_rsl_chan_deact(); |
| 247 | f_lapdm_exit(); |
| 248 | } |
| 249 | |
Harald Welte | 76771f1 | 2019-06-02 22:58:58 +0200 | [diff] [blame] | 250 | /* Mobile-Originated LAPDm establishment on given Link ID */ |
| 251 | private function f_establish_mo(RslLinkId link_id) runs on ConnHdlr |
| 252 | { |
| 253 | var integer sapi := link_id.sapi; |
| 254 | var boolean is_sacch := false; |
| 255 | if (link_id.c == SACCH) { |
| 256 | is_sacch := true; |
| 257 | } |
| 258 | |
| 259 | var octetstring l3_mo := f_rnd_octstring(5); |
| 260 | |
| 261 | /* MO Establish Request via LADPm: SAPI = 0, C = 0, P = 1, M = 0, 0 ≤ L ≤ N201.. */ |
| 262 | if (is_sacch) { |
| 263 | /* no payload permitted, as this is not contention resolution */ |
| 264 | l3_mo := ''O; |
| 265 | LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, p:=true, l3:=l3_mo))); |
| 266 | RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id)); |
| 267 | } else { |
| 268 | LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, p:=true, l3:=l3_mo))); |
| 269 | RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3_mo)); |
| 270 | } |
| 271 | /* UA: SAPI = 0, R = 0, F = 1, M = 0, L = L of SABM. */ |
| 272 | LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_UA(sapi, cr_MT_RSP, f:=true, l3:=l3_mo))); |
| 273 | } |
| 274 | |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 275 | /* Verify that the BTS is re-transmitting SABM messages after T200 timeout, inspired |
| 276 | by 3GPP TS 51.010-1 25.2.1.1.2.1 + 25.2.1.2.4 */ |
| 277 | private function f_TC_sabm_retransmit_bts(charstring id) runs on ConnHdlr { |
| 278 | const integer sapi := 3; /* BTS may not establish SAPI=0 outbound */ |
| 279 | fp_common_init(); |
| 280 | |
| 281 | LAPDM.clear; |
| 282 | RSL.send(ts_RSL_EST_REQ(g_chan_nr, ts_RslLinkID_DCCH(sapi))); |
| 283 | |
| 284 | timer T := 8.0; |
| 285 | var integer sabm_received := 0; |
| 286 | T.start; |
| 287 | alt { |
| 288 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_SABM(sapi, ?, ?, ''O))) { |
| 289 | sabm_received := sabm_received + 1; |
| 290 | repeat; |
| 291 | } |
| 292 | [] LAPDM.receive { repeat; } |
| 293 | [] T.timeout { } |
| 294 | } |
| 295 | if (sabm_received == 0) { |
| 296 | setverdict(fail, "No SABM observed at all!"); |
| 297 | } else if (sabm_received != 6) { |
| 298 | setverdict(fail, "Incorrect number of SABM re-transmissions of observed: ", |
| 299 | sabm_received); |
| 300 | } else { |
| 301 | setverdict(pass, "Received ", sabm_received, " SABM"); |
| 302 | } |
| 303 | |
| 304 | fp_common_fini(); |
| 305 | } |
| 306 | testcase TC_sabm_retransmit_bts() runs on test_CT { |
| 307 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 308 | f_testmatrix_each_chan(pars, refers(f_TC_sabm_retransmit_bts)); |
| 309 | } |
| 310 | |
| 311 | |
| 312 | type record LapdmNamedFrame { |
| 313 | charstring name, |
| 314 | LapdmFrame lapdm |
| 315 | }; |
| 316 | |
| 317 | /* Test that the BTS will ignore receipt of frames other than a UA when |
| 318 | * received in response to the SABM frame, inspired from 3GPP TS 51.010-1 |
| 319 | * Section 25.2.1.1.2.3 */ |
| 320 | private function f_TC_sabm_invalid_resp2(charstring id, LapdmNamedFrame err_frame) runs on ConnHdlr { |
| 321 | var integer sapi := err_frame.lapdm.ab.addr.sapi; |
| 322 | fp_common_init(); |
| 323 | |
| 324 | /* Establish Request via RSL; Expect SABM on LAPDm side */ |
| 325 | LAPDM.clear; |
| 326 | RSL.send(ts_RSL_EST_REQ(g_chan_nr, ts_RslLinkID_DCCH(sapi))); |
| 327 | alt { |
| 328 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_SABM(sapi, ?, ?, ''O))); |
| 329 | [] LAPDM.receive { repeat; } |
| 330 | } |
| 331 | |
| 332 | /* send erroneous response to SABM */ |
| 333 | LAPDM.send(t_PH_DATA(0, false, err_frame.lapdm)); |
| 334 | |
| 335 | /* expect a SABM retransmission of the BTS */ |
| 336 | timer T := 3.0; |
| 337 | T.start; |
| 338 | alt { |
| 339 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_SABM(sapi, ?, ?, ''O))) { |
| 340 | setverdict(pass); |
| 341 | } |
| 342 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_UI(0, ?, ''O))) { repeat; } |
| 343 | [] LAPDM.receive(t_PH_DATA(0, false, ?)) { |
| 344 | setverdict(fail, "Received unexpected LAPDm frame instead of SABM after sending ", |
| 345 | err_frame.name); |
| 346 | } |
| 347 | [] LAPDM.receive { repeat; } |
| 348 | [] T.timeout { |
| 349 | setverdict(fail, "Timeout waiting for SABM retransmission after sending ", |
| 350 | err_frame.name); |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | fp_common_fini(); |
| 355 | } |
| 356 | private function f_TC_sabm_invalid_resp(charstring id) runs on ConnHdlr { |
| 357 | const integer sapi := 3; /* BTS may not establish SAPI=0 outbound */ |
| 358 | var LapdmNamedFrame err_frame[3] := { |
| 359 | { "I", valueof(ts_LAPDm_I(sapi, c_r := cr_MO_CMD, p := true, nr := 0, ns := 0, |
| 360 | l3 := '01020304'O)) }, |
| 361 | { "RR", valueof(ts_LAPDm_RR(sapi, c_r := cr_MO_CMD, p := true, nr := 0)) }, |
| 362 | { "REJ" , valueof(ts_LAPDm_REJ(sapi, c_r := cr_MO_CMD, p := true, nr := 0)) } |
| 363 | }; |
| 364 | var integer i; |
| 365 | |
| 366 | for (i := 0; i < lengthof(err_frame); i := i+1) { |
| 367 | f_TC_sabm_invalid_resp2(id, err_frame[i]) |
| 368 | } |
| 369 | } |
| 370 | testcase TC_sabm_invalid_resp() runs on test_CT { |
| 371 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 372 | f_testmatrix_each_chan(pars, refers(f_TC_sabm_invalid_resp)); |
| 373 | } |
| 374 | |
| 375 | /* Test that the BTS will not re-transmit SABM frames after receiving a DM response, |
| 376 | * inspired from 3GPP TS 51.010-1 Section 25.2.1.1.3 */ |
| 377 | private function f_TC_sabm_dm(charstring id) runs on ConnHdlr { |
| 378 | const integer sapi := 3; /* BTS may not establish SAPI=0 outbound */ |
| 379 | fp_common_init(); |
| 380 | |
| 381 | /* Establish Request via RSL; Expect SABM on LAPDm side */ |
| 382 | LAPDM.clear; |
| 383 | RSL.send(ts_RSL_EST_REQ(g_chan_nr, ts_RslLinkID_DCCH(sapi))); |
| 384 | alt { |
| 385 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_SABM(sapi, ?, ?, ''O))); |
| 386 | [] LAPDM.receive { repeat; } |
| 387 | } |
| 388 | |
| 389 | /* send DM response to SABM */ |
| 390 | RSL.clear; |
| 391 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_DM(sapi, c_r:=cr_MO_RSP, f:=true))); |
| 392 | alt { |
| 393 | [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tr_RslLinkID_DCCH(sapi))); |
| 394 | [] RSL.receive { repeat; } |
| 395 | } |
| 396 | |
| 397 | /* expect no SABM retransmission of the BTS */ |
| 398 | timer T := 3.0; |
| 399 | T.start; |
| 400 | alt { |
| 401 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_SABM(sapi, ?, ?, ''O))) { |
| 402 | setverdict(fail, "Received unexpected SABM retransmission"); |
| 403 | } |
| 404 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_UI(0, ?, ''O))) { repeat; } |
| 405 | [] LAPDM.receive(t_PH_DATA(0, false, ?)) { |
| 406 | setverdict(fail, "Received unexpected LAPDm frame"); |
| 407 | } |
| 408 | [] LAPDM.receive { repeat; } |
| 409 | [] T.timeout { |
| 410 | setverdict(pass); |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | fp_common_fini(); |
| 415 | } |
| 416 | testcase TC_sabm_dm() runs on test_CT { |
| 417 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 418 | f_testmatrix_each_chan(pars, refers(f_TC_sabm_dm)); |
| 419 | } |
| 420 | |
| 421 | /* Test the full LAPDm establishment while simulating the loss of the initial SABM or UA |
| 422 | * frame, requiring the BTS to re-transmit one SABM and then following up all the way to |
| 423 | * dedicated mode; inspired by 3GPP TS 51.010-1 25.2.1.2.2 */ |
| 424 | private function f_TC_establish_ign_first_sabm(charstring id) runs on ConnHdlr { |
| 425 | const integer sapi := 3; /* BTS may not establish SAPI=0 outbound */ |
| 426 | var integer num_sabm := 0; |
| 427 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(sapi)); |
| 428 | timer T := 3.0; |
| 429 | |
| 430 | fp_common_init(); |
| 431 | |
| 432 | /* Establish Request via RSL */ |
| 433 | LAPDM.clear; |
| 434 | RSL.send(ts_RSL_EST_REQ(g_chan_nr, link_id)); |
| 435 | /* Expect two SABM (retransmit) */ |
| 436 | T.start; |
| 437 | alt { |
| 438 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_SABM(sapi, ?, ?, ''O))) { |
| 439 | num_sabm := num_sabm + 1; |
| 440 | if (num_sabm < 2) { |
| 441 | repeat; |
| 442 | } |
| 443 | } |
| 444 | [] LAPDM.receive { repeat; } |
| 445 | } |
| 446 | |
| 447 | /* send UA response to SABM */ |
| 448 | RSL.clear; |
| 449 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_UA(sapi, c_r:=cr_MO_RSP, f:=true, l3:=''O))); |
| 450 | alt { |
| 451 | [] RSL.receive(tr_RSL_EST_CONF(g_chan_nr, link_id)); |
| 452 | [] RSL.receive { repeat; } |
| 453 | } |
| 454 | |
| 455 | /* Send I frame from BTS to MS */ |
| 456 | var octetstring l3 := f_rnd_octstring(10); |
| 457 | RSL.send(ts_RSL_DATA_REQ(g_chan_nr, link_id, l3)); |
| 458 | alt { |
| 459 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_I(sapi, c_r:=cr_MT_CMD, p:=false, |
| 460 | nr:=0, ns:=0, l3:=l3))); |
| 461 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_UI(0, ?, ''O))) { repeat; } |
| 462 | [] LAPDM.receive(t_PH_DATA(0, true, ?)) { repeat; } |
| 463 | [] LAPDM.receive { setverdict(fail, "Unexpected LAPDm received"); } |
| 464 | } |
| 465 | /* Send RR frame in response */ |
| 466 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_RR(sapi, c_r:=cr_MO_RSP, p:=false, nr:=1))); |
| 467 | |
| 468 | /* expect idle UI Frame from BTS */ |
| 469 | alt { |
| 470 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_UI(0, ?, ''O))) { |
| 471 | setverdict(pass); |
| 472 | } |
| 473 | [] LAPDM.receive(t_PH_DATA(0, true, ?)) { repeat; } |
| 474 | [] LAPDM.receive { setverdict(fail, "Unexpected LAPDm received"); } |
| 475 | } |
| 476 | |
| 477 | fp_common_fini(); |
| 478 | } |
| 479 | testcase TC_establish_ign_first_sabm() runs on test_CT { |
| 480 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 481 | f_testmatrix_each_chan(pars, refers(f_TC_establish_ign_first_sabm)); |
| 482 | } |
| 483 | |
| 484 | /* ignore all SACCH frames */ |
| 485 | private altstep as_lapdm_acch() runs on ConnHdlr { |
| 486 | [] LAPDM.receive(t_PH_DATA(0, true, ?)) { repeat; } |
| 487 | } |
Harald Welte | ef6fd44 | 2019-06-01 21:41:29 +0200 | [diff] [blame] | 488 | /* ignore all DCCH frames */ |
| 489 | private altstep as_lapdm_dcch() runs on ConnHdlr { |
| 490 | [] LAPDM.receive(t_PH_DATA(0, false, ?)) { repeat; } |
| 491 | } |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 492 | /* ignore all LAPDm idle frames (UI) */ |
| 493 | private altstep as_lapdm_idle() runs on ConnHdlr { |
Harald Welte | ef6fd44 | 2019-06-01 21:41:29 +0200 | [diff] [blame] | 494 | [] LAPDM.receive(t_PH_DATA(0, ?, tr_LAPDm_UI(?, ?, ''O))) { repeat; } |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 495 | } |
| 496 | /* ignore all measurement reports */ |
| 497 | private altstep as_rsl_meas_rep() runs on ConnHdlr { |
| 498 | [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr)) { repeat; } |
| 499 | } |
| 500 | /* fail if we receive an RSL ERROR IND */ |
| 501 | private altstep as_rsl_fail_err() runs on ConnHdlr { |
| 502 | var RSL_Message rx_rsl; |
| 503 | [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, ?, ?)) { |
| 504 | setverdict(fail, "Received RSL ERROR IND ", rx_rsl); |
| 505 | } |
| 506 | } |
| 507 | /* all of the above */ |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 508 | private altstep as_ignore_background(boolean want_dcch := true, boolean ignore_rsl_errors := false) runs on ConnHdlr { |
Harald Welte | ef6fd44 | 2019-06-01 21:41:29 +0200 | [diff] [blame] | 509 | [want_dcch] as_lapdm_acch(); |
| 510 | [not want_dcch] as_lapdm_dcch(); |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 511 | [] as_lapdm_idle(); |
| 512 | [] as_rsl_meas_rep(); |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 513 | [not ignore_rsl_errors] as_rsl_fail_err(); |
| 514 | [ignore_rsl_errors] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, ?, ?)) { repeat;} |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 515 | } |
| 516 | |
| 517 | /* Test the operation of Layer 2 sequence numbering. |
| 518 | * dedicated mode; inspired by 3GPP TS 51.010-1 25.2.2.1 */ |
| 519 | private function f_TC_iframe_seq_and_ack(charstring id) runs on ConnHdlr { |
| 520 | const integer sapi := 0; |
| 521 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(sapi)); |
| 522 | var octetstring l3 := f_rnd_octstring(18); |
| 523 | var default d; |
| 524 | timer T := 3.0; |
| 525 | |
| 526 | fp_common_init(); |
| 527 | |
| 528 | /* some common altstep for meas res and other background noise */ |
| 529 | d := activate(as_ignore_background()); |
| 530 | RSL.clear; |
| 531 | LAPDM.clear; |
| 532 | |
Harald Welte | 76771f1 | 2019-06-02 22:58:58 +0200 | [diff] [blame] | 533 | f_establish_mo(link_id); |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 534 | |
| 535 | var integer last_ns_rx := 0; |
| 536 | |
| 537 | for (var integer i := 0; i < 10; i := i+1) { |
| 538 | var octetstring l3_mo := f_rnd_octstring(12); |
| 539 | var octetstring l3_mt := f_rnd_octstring(12); |
| 540 | var LAPDm_ph_data pd; |
| 541 | |
| 542 | log("Starting iteration ", i); |
| 543 | /* MT I frame */ |
| 544 | RSL.send(ts_RSL_DATA_REQ(g_chan_nr, link_id, l3_mt)); |
| 545 | alt { |
| 546 | /* SAPI = 0, R = 1, F = 0, M = 0, L = 0. */ |
| 547 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_RR(sapi, c_r:=cr_MT_RSP, p:=false, |
| 548 | nr:=i mod 8))) { |
| 549 | log("Ignoring RR in iteration ", i); |
| 550 | repeat; |
| 551 | } |
| 552 | /* SAPI = 0, C = 1, P = 0, M = 0, 0 ≤ L ≤ N201. */ |
| 553 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_I(sapi, c_r:=cr_MT_CMD, p:=false, |
| 554 | nr:=i mod 8, ns:=i mod 8, |
| 555 | l3:=l3_mt))) -> value pd { |
| 556 | last_ns_rx := pd.lapdm.ab.ctrl.i.n_s; |
| 557 | } |
| 558 | } |
| 559 | /* respond with MO I-frame: SAPI = 0, C = 0, P = 0, M = 0, 0 <= L <= N201. */ |
| 560 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_I(sapi, c_r:=cr_MO_CMD, p:=false, |
| 561 | nr:=(last_ns_rx+1)mod 8, |
| 562 | ns:=i mod 8, l3 := l3_mo))); |
| 563 | RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3_mo)); |
| 564 | } |
| 565 | log("Completed iteration"); |
| 566 | |
| 567 | deactivate(d); |
| 568 | fp_common_fini(); |
| 569 | } |
| 570 | testcase TC_iframe_seq_and_ack() runs on test_CT { |
| 571 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 572 | f_testmatrix_each_chan(pars, refers(f_TC_iframe_seq_and_ack)); |
| 573 | } |
| 574 | |
| 575 | /* To test that the BTS is able to respond to I frames whilst in the timer recovery state. |
| 576 | * Inspired by 3GPP TS 51.010-1 25.2.2.2 */ |
| 577 | |
| 578 | /* |
| 579 | 1) The BTS is brought into the multiple frame established state |
| 580 | 2) The MS sends an L3 Request asking for IMEI to the MS. |
| 581 | 3) The BTS shall respond with a RR frame though this may be incorporated with |
| 582 | the L3 Response I frame. The MS does not respond to the I frame. |
| 583 | 4) The BTS shall wait for expiry of timer T200 and then repeat the I frame but |
| 584 | with the P bit set to 1. |
| 585 | 5) The MS then sends a valid L3 Request I frame asking for IMEI which |
| 586 | does not acknowledge receipt of the I frame from the BTS. |
| 587 | On the FACCH the BTS may send an RR frame acknowledging the I frame. |
| 588 | 6) The BTS shall repeat the I frame, this frame will acknowledge receipt of |
| 589 | the second I frame from the MS. |
| 590 | 7) The MS then acknowledges receipt of the MS I frame by sending a RR frame. |
| 591 | 8) The BTS shall send the next I frame. The MS acknowledges this I frame. |
| 592 | */ |
| 593 | private function f_TC_iframe_timer_recovery(charstring id) runs on ConnHdlr { |
| 594 | const integer sapi := 0; |
| 595 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(sapi)); |
| 596 | var default d; |
| 597 | timer T := 3.0; |
| 598 | |
| 599 | fp_common_init(); |
| 600 | |
| 601 | /* some common altstep for meas res and other background noise */ |
| 602 | d := activate(as_ignore_background()); |
| 603 | RSL.clear; |
| 604 | LAPDM.clear; |
| 605 | |
| 606 | var octetstring l3_mo := f_rnd_octstring(12); |
| 607 | var octetstring l3_mt := f_rnd_octstring(12); |
| 608 | |
| 609 | /* 1) The BTS is brought into the multiple frame established state */ |
| 610 | |
| 611 | /* MO Establish Request via LADPm: SAPI = 0, C = 0, P = 1, M = 0, 0 ≤ L ≤ N201.. */ |
| 612 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, p:=true, l3:=l3_mo))); |
| 613 | RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3_mo)); |
| 614 | /* UA: SAPI = 0, R = 0, F = 1, M = 0, L = L of SABM. */ |
| 615 | LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_UA(sapi, cr_MT_RSP, f:=true, l3:=l3_mo))); |
| 616 | |
| 617 | /* 2) The MS sends an L3 Request to the BTS */ |
| 618 | l3_mo := f_rnd_octstring(18); |
| 619 | /* SAPI = 0, C = 1, P = 0, M = 0, 0 ≤ L ≤ N201, N(S) = 0, N(R) = 0. * */ |
| 620 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_I(sapi, c_r:=cr_MO_CMD, p:=false, |
| 621 | nr:=0, ns:=0, l3:=l3_mo))); |
| 622 | RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3_mo)); |
| 623 | /* 3) The BTS shall respond with a RR frame though this may be incorporated with |
| 624 | the L3 Response I frame. The MS does not respond to the I frame. */ |
| 625 | RSL.send(ts_RSL_DATA_REQ(g_chan_nr, link_id, l3_mt)); |
| 626 | alt { |
| 627 | /* SAPI = 0, R = 1, F = 0, M = 0, L = 0, N(R) = 1. */ |
| 628 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_RR(sapi, c_r:=cr_MT_RSP, p:=false, nr:=1))) { |
| 629 | repeat; |
| 630 | } |
| 631 | /* SAPI = 0, C = 0, P = 0, M = 0, 0 ≤ L ≤ N201, N(R) = 1, N(S) = 0 */ |
| 632 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_I(sapi, c_r:=cr_MT_CMD, p:=false, |
| 633 | nr:=1, ns:=0, l3:=l3_mt))); |
| 634 | } |
| 635 | |
| 636 | /* 4) The BTS shall wait for expiry of timer T200 and then repeat the I frame but |
| 637 | with the P bit set to 1. */ |
| 638 | /* SAPI = 0, C = 0, P = 1, M = 0, 0 ≤ L ≤ N201, N(R) = 1, N(S) = 0. * */ |
| 639 | LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_I(sapi, c_r:=cr_MT_CMD, p:=true, |
| 640 | nr:=1, ns:=0, l3:=l3_mt))); |
| 641 | |
| 642 | /* 5) The MS then sends a valid L3 Request I frame asking for IMEI which |
| 643 | does not acknowledge receipt of the I frame from the BTS. */ |
| 644 | /* SAPI = 0, C = 1, P = 0, M = 0, 0 ≤ L ≤ N201, N(S) = 1, N(R) = 0. * */ |
| 645 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_I(sapi, c_r:=cr_MO_CMD, p:=false, |
| 646 | nr:=0, ns:=1, l3 := l3_mo))); |
| 647 | RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3_mo)); |
| 648 | alt { |
| 649 | /* On the FACCH the BTS may send an RR frame acknowledging the I frame. */ |
| 650 | /* SAPI = 0, R = 1, F = 0, M = 0, L = 0, N(R) = 2. */ |
| 651 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_RR(sapi, c_r:=cr_MT_RSP, p:=false, nr:=2))) { |
| 652 | repeat; |
| 653 | } |
| 654 | /* 6) The BTS shall repeat the I frame, this frame will acknowledge |
| 655 | receipt of the second I frame from the MS. */ |
| 656 | /* SAPI = 0, C = 0, P = 1, M = 0, 0 ≤ L ≤ N201, N(R) = 2, N(S) = 0. * */ |
| 657 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_I(sapi, c_r:=cr_MT_CMD, p:=true, |
| 658 | nr:=2, ns:=0, l3:=l3_mt))); |
| 659 | } |
| 660 | |
| 661 | /* 7) The MS then acknowledges receipt of the BTS I frame by sending a RR * frame. */ |
| 662 | /* SAPI = 0, R = 0, F = 1, 0, M = 0, L = 0, N(R) = 1 */ |
| 663 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_RR(sapi, c_r:=cr_MO_RSP, p:=true, nr:=1))); |
| 664 | |
| 665 | /* 8) The BTS shall send the next I frame. The MS acknowledges this I frame. */ |
| 666 | l3_mt := f_rnd_octstring(16); |
| 667 | RSL.send(ts_RSL_DATA_REQ(g_chan_nr, link_id, l3_mt)); |
| 668 | /* SAPI = 0, C = 0, P = 0, M = 0, 0 ≤ L ≤ N201, N(R) = 2, N(S) = 1 */ |
| 669 | LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_I(sapi, c_r:=cr_MT_CMD, p:=false, |
| 670 | nr:=2, ns:=1, l3:=l3_mt))); |
| 671 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_RR(sapi, c_r:=cr_MO_RSP, p:=true, nr:=2))); |
| 672 | |
| 673 | deactivate(d); |
| 674 | fp_common_fini(); |
| 675 | } |
| 676 | testcase TC_iframe_timer_recovery() runs on test_CT { |
| 677 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 678 | f_testmatrix_each_chan(pars, refers(f_TC_iframe_timer_recovery)); |
| 679 | } |
| 680 | |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 681 | /* 25.2.6.1 ns sequence error |
| 682 | sends wrong N(S), expects REJ, sends wrong N(S) with P=1, expects REJ with F=1 */ |
| 683 | private function f_TC_ns_seq_error(charstring id) runs on ConnHdlr { |
| 684 | const integer sapi := 0; |
| 685 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(sapi)); |
| 686 | var default d; |
| 687 | timer T := 3.0; |
| 688 | |
| 689 | fp_common_init(); |
| 690 | |
| 691 | /* some common altstep for meas res and other background noise */ |
| 692 | d := activate(as_ignore_background(ignore_rsl_errors := true)); |
| 693 | RSL.clear; |
| 694 | LAPDM.clear; |
| 695 | |
| 696 | var octetstring l3_mo := f_rnd_octstring(12); |
| 697 | var octetstring l3_mt := f_rnd_octstring(12); |
| 698 | |
| 699 | /* 1) The BTS is brought into the multiple frame established state */ |
| 700 | |
| 701 | /* MO Establish Request via LADPm: SAPI = 0, C = 0, P = 1, M = 0, 0 ≤ L ≤ N201.. */ |
| 702 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, p:=true, l3:=l3_mo))); |
| 703 | RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3_mo)); |
| 704 | /* UA: SAPI = 0, R = 0, F = 1, M = 0, L = L of SABM. */ |
| 705 | LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_UA(sapi, cr_MT_RSP, f:=true, l3:=l3_mo))); |
| 706 | |
| 707 | /* 2) The MS sends an L3 Request to the BTS */ |
| 708 | l3_mo := f_rnd_octstring(18); |
| 709 | /* SAPI = 0, C = 1, P = 0, M = 0, 0 ≤ L ≤ N201, N(S) = 0, N(R) = 0. * */ |
| 710 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_I(sapi, c_r:=cr_MO_CMD, p:=false, |
| 711 | nr:=0, ns:=0, l3:=l3_mo))); |
| 712 | RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3_mo)); |
| 713 | /* 3) The BTS shall respond with a RR frame though this may be incorporated with |
| 714 | the L3 Response I frame. */ |
| 715 | RSL.send(ts_RSL_DATA_REQ(g_chan_nr, link_id, l3_mt)); |
| 716 | alt { |
| 717 | /* SAPI = 0, R = 1, F = 0, M = 0, L = 0, N(R) = 1. */ |
| 718 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_RR(sapi, c_r:=cr_MT_RSP, p:=false, nr:=1))) { |
| 719 | repeat; |
| 720 | } |
| 721 | /* SAPI = 0, C = 0, P = 0, M = 0, 0 ≤ L ≤ N201, N(R) = 1, N(S) = 0 */ |
| 722 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_I(sapi, c_r:=cr_MT_CMD, p:=false, |
| 723 | nr:=1, ns:=0, l3:=l3_mt))); |
| 724 | } |
| 725 | |
| 726 | /* 4) The MS shall then send an I frame containing Identity Request with incorrect N(S) |
| 727 | but correctly acknowledging the MS's I frame; P bit set to zero. */ |
| 728 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_I(sapi, c_r:=cr_MO_CMD, p:=false, |
| 729 | nr:=1, ns:=0, l3:=l3_mo))); |
| 730 | |
| 731 | /* no rsl data ind due to wrong ns */ |
| 732 | |
| 733 | /* The BTS shall send a REJ frame. */ |
| 734 | timer T1 := 2.0; |
| 735 | T1.start; |
| 736 | alt{ |
| 737 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_REJ(sapi, c_r:=cr_MT_RSP, p:=false, nr:=1))); |
| 738 | [] T1.timeout{ setverdict(fail, "Missing first REJ")} |
| 739 | } |
| 740 | |
| 741 | f_sleep(2.0); // T200 |
| 742 | |
| 743 | /* The MS shall, after T200, send another I frame with incorrect N(S), P bit set to 1 this time. */ |
| 744 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_I(sapi, c_r:=cr_MO_CMD, p:=true, |
| 745 | nr:=1, ns:=0, l3:=l3_mo))); |
| 746 | |
| 747 | /* The BTS shall respond with a REJ, F bit set to 1. */ |
| 748 | T1.start; |
| 749 | alt{ |
| 750 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_REJ(sapi, c_r:=cr_MT_RSP, p:=true, nr:=1))); |
| 751 | [] T1.timeout{ setverdict(fail, "Missing second REJ")} |
| 752 | } |
| 753 | |
| 754 | deactivate(d); |
| 755 | fp_common_fini(); |
| 756 | setverdict(pass); |
| 757 | } |
| 758 | |
| 759 | testcase TC_ns_seq_error() runs on test_CT { |
| 760 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 761 | f_testmatrix_each_chan(pars, refers(f_TC_ns_seq_error)); |
| 762 | } |
| 763 | |
| 764 | /* 25.2.6.2 nr sequence error */ |
| 765 | private function f_TC_nr_seq_error(charstring id) runs on ConnHdlr { |
| 766 | const integer sapi := 0; |
| 767 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(sapi)); |
| 768 | var default d; |
| 769 | var integer n201 := 20; |
| 770 | if (link_id.c == SACCH) { |
| 771 | n201 := 18; |
| 772 | } |
| 773 | |
| 774 | fp_common_init(); |
| 775 | |
| 776 | /* some common altstep for meas res and other background noise */ |
| 777 | d := activate(as_ignore_background(ignore_rsl_errors := true)); |
| 778 | RSL.clear; |
| 779 | LAPDM.clear; |
| 780 | |
| 781 | var octetstring l3_mo := f_rnd_octstring(12); |
| 782 | var octetstring l3_mt := f_rnd_octstring(12); |
| 783 | |
| 784 | /* 1) The BTS is brought into the multiple frame established state */ |
| 785 | |
| 786 | /* MO Establish Request via LADPm: SAPI = 0, C = 0, P = 1, M = 0, 0 ≤ L ≤ N201.. */ |
| 787 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, p:=true, l3:=l3_mo))); |
| 788 | RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3_mo)); |
| 789 | /* UA: SAPI = 0, R = 0, F = 1, M = 0, L = L of SABM. */ |
| 790 | LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_UA(sapi, cr_MT_RSP, f:=true, l3:=l3_mo))); |
| 791 | |
| 792 | /* 2) The MS shall send an I frame containing an information field of length N201 and an |
| 793 | incorrect receive sequence number. */ |
| 794 | l3_mo := f_rnd_octstring(n201); |
| 795 | /* SAPI = 0, C = 1, P = 0, M = 0, L = N201, N(S) = 0, N(R) = 1. * */ |
| 796 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_I(sapi, c_r:=cr_MO_CMD, p:=false, |
| 797 | nr:=1, ns:=0, l3:=l3_mo))); |
| 798 | |
| 799 | /* The BTS may: a) send a DISC frame within N200×T200; */ |
| 800 | /* DISC SAPI = 0, C = 0, P = 1, M = 0, L = 0. */ |
| 801 | timer T1 := 2.0; |
| 802 | T1.start; |
| 803 | alt{ |
| 804 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_DISC(sapi, c_r:=cr_MT_CMD, p:=true))); |
| 805 | [] T1.timeout{ setverdict(fail, "Missing DISC from BTS")} |
| 806 | } |
| 807 | |
| 808 | /* a) the MS shall respond with a UA frame. |
| 809 | SAPI = 0, R = 0, F = 1, M = 0, L = 0. */ |
| 810 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_UA(sapi, c_r:=cr_MO_CMD, f:=true, l3:=l3_mo))); |
| 811 | |
| 812 | deactivate(d); |
| 813 | fp_common_fini(); |
| 814 | setverdict(pass); |
| 815 | } |
| 816 | |
| 817 | testcase TC_nr_seq_error() runs on test_CT { |
| 818 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 819 | f_testmatrix_each_chan(pars, refers(f_TC_nr_seq_error)); |
| 820 | } |
| 821 | |
Pau Espin Pedrol | 26b562c | 2019-12-10 14:35:30 +0100 | [diff] [blame] | 822 | private function f_TC_rec_invalid_frame_txrx(integer sapi, LapdmFrame x, integer line_nr) runs on ConnHdlr { |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 823 | LAPDM.send(t_PH_DATA(0, false, x)); |
| 824 | f_sleep(2.0); // T200 |
| 825 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_RR(sapi, c_r:=cr_MO_CMD, p:=true, nr:=0))); |
Pau Espin Pedrol | 26b562c | 2019-12-10 14:35:30 +0100 | [diff] [blame] | 826 | timer T1 := 2.0; |
| 827 | T1.start; |
| 828 | alt { |
| 829 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_RR(sapi, c_r:=cr_MT_RSP, p:=true , nr := 0))) { T1.stop; } |
| 830 | [] T1.timeout{ Misc_Helpers.f_shutdown(__BFILE__, line_nr, fail, "Missing LAPDm_RR RSP"); } |
| 831 | } |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 832 | } |
| 833 | |
| 834 | /* 25.2.7 Test on receipt of invalid frames |
| 835 | sends a bunch of different invalid frames, expects the BTS to ignore all of them */ |
| 836 | private function f_TC_rec_invalid_frame(charstring id) runs on ConnHdlr { |
| 837 | const integer sapi := 0; |
| 838 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(sapi)); |
| 839 | var default d; |
| 840 | timer T := 3.0; |
| 841 | |
| 842 | fp_common_init(); |
| 843 | |
| 844 | /* some common altstep for meas res and other background noise */ |
| 845 | d := activate(as_ignore_background(ignore_rsl_errors := true)); |
| 846 | RSL.clear; |
| 847 | LAPDM.clear; |
| 848 | |
| 849 | var octetstring l3_mo := f_rnd_octstring(12); |
| 850 | var octetstring l3_mt := f_rnd_octstring(12); |
| 851 | |
| 852 | /* 1) The BTS is brought into the multiple frame established state */ |
| 853 | |
| 854 | /* MO Establish Request via LADPm: SAPI = 0, C = 0, P = 1, M = 0, 0 ≤ L ≤ N201.. */ |
| 855 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, p:=true, l3:=l3_mo))); |
Pau Espin Pedrol | 26b562c | 2019-12-10 14:35:30 +0100 | [diff] [blame] | 856 | T.start |
| 857 | alt { |
| 858 | [] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3_mo)) {} |
| 859 | [] T.timeout{ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Missing RSL EST IND"); } |
| 860 | } |
| 861 | alt { |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 862 | /* UA: SAPI = 0, R = 0, F = 1, M = 0, L = L of SABM. */ |
Pau Espin Pedrol | 26b562c | 2019-12-10 14:35:30 +0100 | [diff] [blame] | 863 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_UA(sapi, cr_MT_RSP, f:=true, l3:=l3_mo))) { T.stop; } |
| 864 | [] T.timeout{ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Missing LAPDm UA RSP"); } |
| 865 | } |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 866 | |
| 867 | /* 1: One RR frame: SAPI = 0, R = 0, F = 0, M = 0, L > 0, N(R) = 1. |
| 868 | RR frame with the Length indicator greater than zero and a faulty N(R); */ |
| 869 | var LapdmFrame x:= valueof(ts_LAPDm_RR(sapi, c_r:=cr_MO_CMD, p:=false, nr:=1)); |
| 870 | x.ab.payload := f_rnd_octstring(5); |
Pau Espin Pedrol | 26b562c | 2019-12-10 14:35:30 +0100 | [diff] [blame] | 871 | f_TC_rec_invalid_frame_txrx(0, x, __LINE__); |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 872 | /* 3: One REJ frame: SAPI = 0, R = 0, F = 0, M = 0, L = 0, N(R) = 1, EA = 0. |
| 873 | EJ frame with the EA bit set to zero and a faulty N(R); */ |
| 874 | x:= valueof(ts_LAPDm_REJ(sapi, c_r:=cr_MO_CMD, p:=false, nr:=1)); |
| 875 | x.ab.addr.ea := false; |
Pau Espin Pedrol | 26b562c | 2019-12-10 14:35:30 +0100 | [diff] [blame] | 876 | f_TC_rec_invalid_frame_txrx(0, x, __LINE__); |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 877 | /* 4: One SABM frame: SAPI = 0, C = 1, P = 1, M = 0, L = 0, EL = 0. |
| 878 | SABM frame with the EL bit set to zero; */ |
| 879 | l3_mo := ''O; |
| 880 | x:= valueof(ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, p:=true, l3:=l3_mo)); |
| 881 | x.ab.el := 0; |
Pau Espin Pedrol | 26b562c | 2019-12-10 14:35:30 +0100 | [diff] [blame] | 882 | f_TC_rec_invalid_frame_txrx(0, x, __LINE__); |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 883 | /* 5: One DM frame: SAPI = 0, R = 0, F = 1, M = 0, L > 0. |
| 884 | DM frame with the Length indicator greater than zero;*/ |
| 885 | x:= valueof(ts_LAPDm_DM(sapi, c_r:=cr_MO_CMD, f:=true)); |
| 886 | x.ab.payload := f_rnd_octstring(5); |
Pau Espin Pedrol | 26b562c | 2019-12-10 14:35:30 +0100 | [diff] [blame] | 887 | f_TC_rec_invalid_frame_txrx(0, x, __LINE__); |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 888 | /* 6: One DISC frame: SAPI = 0, C = 1, P = 1, M = 1, L = 0. |
| 889 | DISC frame with the M bit set to 1; */ |
| 890 | x:= valueof(ts_LAPDm_DISC(sapi, c_r:=cr_MO_CMD, p:=true)); |
| 891 | x.ab.m := true; |
Pau Espin Pedrol | 26b562c | 2019-12-10 14:35:30 +0100 | [diff] [blame] | 892 | f_TC_rec_invalid_frame_txrx(0, x, __LINE__); |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 893 | /* 7: One UA frame: SAPI = 0, R = 0, F = 0, M = 0, L = 0, EA = 0. |
| 894 | UA frame with the EA bit set to zero*/ |
| 895 | x:= valueof(ts_LAPDm_UA(sapi, c_r:=cr_MO_CMD, f:=false, l3:=''O)); |
| 896 | x.ab.addr.ea := false; |
Pau Espin Pedrol | 26b562c | 2019-12-10 14:35:30 +0100 | [diff] [blame] | 897 | f_TC_rec_invalid_frame_txrx(0, x, __LINE__); |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 898 | /* 8: One I frame: SAPI = 0, C = 1, P = 0, M = 0, L > N201, N(R) = 0, N(S) = 6. |
| 899 | I frame with the Length indicator greater than N201;*/ |
| 900 | x:= valueof(ts_LAPDm_I(sapi, c_r:=cr_MO_CMD, p:=true, nr := 0, ns := 6, l3 := f_rnd_octstring(25))) |
Pau Espin Pedrol | 26b562c | 2019-12-10 14:35:30 +0100 | [diff] [blame] | 901 | f_TC_rec_invalid_frame_txrx(0, x, __LINE__); |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 902 | /* 9: One I frame: SAPI = 0, C = 1, P = 0, M = 1, L < N201, N(R) = 0, N(S) = 7. |
| 903 | I frame with the M bit set to 1 and the Length indicator less than N201;*/ |
| 904 | x:= valueof(ts_LAPDm_I(sapi, c_r:=cr_MO_CMD, p:=true, nr := 0, ns := 7, l3 := f_rnd_octstring(5))) |
| 905 | x.ab.m := true; |
Pau Espin Pedrol | 26b562c | 2019-12-10 14:35:30 +0100 | [diff] [blame] | 906 | f_TC_rec_invalid_frame_txrx(0, x, __LINE__); |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 907 | /* 10: One RR frame: SAPI = 0, C = 1, P = 1, M = 0, L = 0, N(R) = 0. */ |
| 908 | x:= valueof(ts_LAPDm_RR(sapi, c_r:=cr_MO_CMD, p:=true, nr:=0)); |
Pau Espin Pedrol | 26b562c | 2019-12-10 14:35:30 +0100 | [diff] [blame] | 909 | f_TC_rec_invalid_frame_txrx(0, x, __LINE__); |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 910 | |
| 911 | /* command frames with correct Address and Length indicator field and a non-implemented control field */ |
| 912 | /* 12: One command frame with Control Field = xxx1 1101. */ |
| 913 | x:= valueof(ts_LAPDm_RR(sapi, c_r:=cr_MO_CMD, p:=false, nr:=1)); |
| 914 | x.ab.ctrl.other := bit2int('00011101'B); |
Pau Espin Pedrol | 26b562c | 2019-12-10 14:35:30 +0100 | [diff] [blame] | 915 | f_TC_rec_invalid_frame_txrx(0, x, __LINE__); |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 916 | /* 13: One command frame with Control field = xxx1 1011. */ |
| 917 | x:= valueof(ts_LAPDm_RR(sapi, c_r:=cr_MO_CMD, p:=false, nr:=1)); |
| 918 | x.ab.ctrl.other := bit2int('00011011'B); |
Pau Espin Pedrol | 26b562c | 2019-12-10 14:35:30 +0100 | [diff] [blame] | 919 | f_TC_rec_invalid_frame_txrx(0, x, __LINE__); |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 920 | /* 14: One command frame with Control field = xxx1 0111. */ |
| 921 | x:= valueof(ts_LAPDm_RR(sapi, c_r:=cr_MO_CMD, p:=false, nr:=1)); |
| 922 | x.ab.ctrl.other := bit2int('00010001'B); |
Pau Espin Pedrol | 26b562c | 2019-12-10 14:35:30 +0100 | [diff] [blame] | 923 | f_TC_rec_invalid_frame_txrx(0, x, __LINE__); |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 924 | /* 15: One command frame with Control field = 01x1 1111. */ |
| 925 | x:= valueof(ts_LAPDm_RR(sapi, c_r:=cr_MO_CMD, p:=false, nr:=1)); |
| 926 | x.ab.ctrl.other := bit2int('01011111'B); |
Pau Espin Pedrol | 26b562c | 2019-12-10 14:35:30 +0100 | [diff] [blame] | 927 | f_TC_rec_invalid_frame_txrx(0, x, __LINE__); |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 928 | /* 16: One command frame with Control field = 1xx1 1111. */ |
| 929 | x:= valueof(ts_LAPDm_RR(sapi, c_r:=cr_MO_CMD, p:=false, nr:=1)); |
| 930 | x.ab.ctrl.other := bit2int('10011111'B); |
Pau Espin Pedrol | 26b562c | 2019-12-10 14:35:30 +0100 | [diff] [blame] | 931 | f_TC_rec_invalid_frame_txrx(0, x, __LINE__); |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 932 | /* 17: One command frame with Control field = 0011 0011. */ |
| 933 | x:= valueof(ts_LAPDm_RR(sapi, c_r:=cr_MO_CMD, p:=false, nr:=1)); |
| 934 | x.ab.ctrl.other := bit2int('00110011'B); |
Pau Espin Pedrol | 26b562c | 2019-12-10 14:35:30 +0100 | [diff] [blame] | 935 | f_TC_rec_invalid_frame_txrx(0, x, __LINE__); |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 936 | /* 18: One command frame with Control field = 1xx1 0011. */ |
| 937 | x:= valueof(ts_LAPDm_RR(sapi, c_r:=cr_MO_CMD, p:=false, nr:=1)); |
| 938 | x.ab.ctrl.other := bit2int('10010011'B); |
Pau Espin Pedrol | 26b562c | 2019-12-10 14:35:30 +0100 | [diff] [blame] | 939 | f_TC_rec_invalid_frame_txrx(0, x, __LINE__); |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 940 | |
| 941 | deactivate(d); |
| 942 | fp_common_fini(); |
| 943 | setverdict(pass); |
| 944 | } |
| 945 | |
| 946 | testcase TC_rec_invalid_frame() runs on test_CT { |
| 947 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 948 | pars.t_guard := 60.0; |
| 949 | f_testmatrix_each_chan(pars, refers(f_TC_rec_invalid_frame)); |
| 950 | } |
| 951 | |
Harald Welte | 9ea918c | 2019-06-01 11:46:25 +0200 | [diff] [blame] | 952 | type record LapdmDlConfig { |
| 953 | integer n201, |
| 954 | integer t200 |
| 955 | }; |
| 956 | |
| 957 | type record LapdmDlState { |
| 958 | integer v_s, |
| 959 | integer v_a, |
| 960 | integer v_r |
| 961 | }; |
| 962 | |
| 963 | template (value) LapdmDlState t_init_LapdmDlState := { |
| 964 | v_s := 0, |
| 965 | v_a := 0, |
| 966 | v_r := 0 |
| 967 | } |
| 968 | |
| 969 | private function inc_mod8(inout integer v) |
| 970 | { |
| 971 | v := (v + 1) mod 8; |
| 972 | } |
| 973 | |
| 974 | private function f_lapdm_transceive_mo(inout LapdmDlState dls, RslLinkId link_id, octetstring l3) |
| 975 | runs on ConnHdlr { |
| 976 | var LAPDm_ph_data pd; |
| 977 | var integer offset := 0; |
| 978 | var integer n201 := 20; |
| 979 | var boolean is_sacch := false; |
| 980 | if (link_id.c == SACCH) { |
| 981 | n201 := 18; |
| 982 | is_sacch := true; |
| 983 | } |
| 984 | |
| 985 | while (offset < lengthof(l3)) { |
| 986 | var integer remain_len := lengthof(l3) - offset; |
| 987 | var integer seg_len := remain_len; |
| 988 | if (remain_len > n201) { |
| 989 | seg_len := n201; |
| 990 | } |
| 991 | var octetstring segment := substr(l3, offset, seg_len); |
| 992 | var boolean more; |
| 993 | if (offset + lengthof(segment) < lengthof(l3)) { |
| 994 | more := true; |
| 995 | } else { |
| 996 | more := false; |
| 997 | } |
| 998 | /* send the next segment */ |
| 999 | LAPDM.send(t_PH_DATA(0, is_sacch, |
| 1000 | ts_LAPDm_I(link_id.sapi, c_r:=cr_MO_CMD, p:=false, |
| 1001 | nr:=dls.v_a, ns:=dls.v_s, l3:=segment, m:=more))); |
| 1002 | inc_mod8(dls.v_s); |
| 1003 | offset := offset + lengthof(segment); |
| 1004 | |
| 1005 | /* wait for it to be acknowledged */ |
| 1006 | alt { |
| 1007 | [] LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_RR(link_id.sapi, c_r:=cr_MT_RSP, |
| 1008 | p:=false, nr:=(dls.v_s) mod 8))); |
Harald Welte | ef6fd44 | 2019-06-01 21:41:29 +0200 | [diff] [blame] | 1009 | [] as_ignore_background(not is_sacch); |
Harald Welte | 9ea918c | 2019-06-01 11:46:25 +0200 | [diff] [blame] | 1010 | [] LAPDM.receive(t_PH_DATA(0, is_sacch, ?)) -> value pd { |
Pau Espin Pedrol | d6d69b5 | 2020-10-20 18:46:28 +0200 | [diff] [blame^] | 1011 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("received unexpected LAPDm ", pd)); |
Harald Welte | 9ea918c | 2019-06-01 11:46:25 +0200 | [diff] [blame] | 1012 | } |
| 1013 | [] LAPDM.receive(t_PH_DATA(0, ?, ?)) { repeat; } |
| 1014 | [offset < lengthof(l3)] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, ?)) { |
Pau Espin Pedrol | d6d69b5 | 2020-10-20 18:46:28 +0200 | [diff] [blame^] | 1015 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received RSL DATA IND before message complete"); |
Harald Welte | 9ea918c | 2019-06-01 11:46:25 +0200 | [diff] [blame] | 1016 | } |
| 1017 | } |
| 1018 | } |
| 1019 | |
| 1020 | timer T := 1.0; |
| 1021 | T.start; |
| 1022 | alt { |
| 1023 | [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) { |
| 1024 | setverdict(pass); |
| 1025 | } |
| 1026 | [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, ?)) { |
Pau Espin Pedrol | d6d69b5 | 2020-10-20 18:46:28 +0200 | [diff] [blame^] | 1027 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received RSL DATA IND with wrong payload"); |
Harald Welte | 9ea918c | 2019-06-01 11:46:25 +0200 | [diff] [blame] | 1028 | } |
| 1029 | [] T.timeout { |
Pau Espin Pedrol | d6d69b5 | 2020-10-20 18:46:28 +0200 | [diff] [blame^] | 1030 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RSL DATA IND of de-segmented message"); |
Harald Welte | 9ea918c | 2019-06-01 11:46:25 +0200 | [diff] [blame] | 1031 | } |
| 1032 | } |
| 1033 | } |
| 1034 | |
| 1035 | /* Section 5.8.5 of TS 04.06 */ |
| 1036 | const integer c_TS0406_MAX_L3_OCTETS := 251; |
| 1037 | |
Harald Welte | ef6fd44 | 2019-06-01 21:41:29 +0200 | [diff] [blame] | 1038 | /* test segmentation and de-segmentation (concatenation) of a large message in uplink |
| 1039 | * on specified SAPI/channel */ |
| 1040 | private function f_TC_segm_concat(charstring id, RslLinkId link_id) runs on ConnHdlr { |
| 1041 | var integer sapi := link_id.sapi; |
| 1042 | var boolean is_sacch := false; |
| 1043 | if (link_id.c == SACCH) { |
| 1044 | is_sacch := true; |
| 1045 | } |
Harald Welte | 9ea918c | 2019-06-01 11:46:25 +0200 | [diff] [blame] | 1046 | var default d; |
| 1047 | timer T := 3.0; |
| 1048 | |
| 1049 | fp_common_init(); |
| 1050 | |
| 1051 | /* some common altstep for meas res and other background noise */ |
Harald Welte | ef6fd44 | 2019-06-01 21:41:29 +0200 | [diff] [blame] | 1052 | d := activate(as_ignore_background(not is_sacch)); |
Harald Welte | 9ea918c | 2019-06-01 11:46:25 +0200 | [diff] [blame] | 1053 | RSL.clear; |
| 1054 | LAPDM.clear; |
| 1055 | |
Harald Welte | 76771f1 | 2019-06-02 22:58:58 +0200 | [diff] [blame] | 1056 | f_establish_mo(link_id); |
Harald Welte | 9ea918c | 2019-06-01 11:46:25 +0200 | [diff] [blame] | 1057 | |
Harald Welte | 76771f1 | 2019-06-02 22:58:58 +0200 | [diff] [blame] | 1058 | var octetstring l3_mo := f_rnd_octstring(c_TS0406_MAX_L3_OCTETS); |
Harald Welte | 9ea918c | 2019-06-01 11:46:25 +0200 | [diff] [blame] | 1059 | |
| 1060 | deactivate(d); |
| 1061 | |
| 1062 | var LapdmDlState dls := valueof(t_init_LapdmDlState); |
| 1063 | f_lapdm_transceive_mo(dls, link_id, l3_mo); |
| 1064 | |
| 1065 | fp_common_fini(); |
| 1066 | } |
Harald Welte | ef6fd44 | 2019-06-01 21:41:29 +0200 | [diff] [blame] | 1067 | private function f_TC_segm_concat_dcch(charstring id) runs on ConnHdlr { |
| 1068 | f_TC_segm_concat(id, valueof(ts_RslLinkID_DCCH(0))); |
Harald Welte | 9ea918c | 2019-06-01 11:46:25 +0200 | [diff] [blame] | 1069 | } |
Harald Welte | ef6fd44 | 2019-06-01 21:41:29 +0200 | [diff] [blame] | 1070 | private function f_TC_segm_concat_sacch(charstring id) runs on ConnHdlr { |
| 1071 | f_TC_segm_concat(id, link_id :=valueof(ts_RslLinkID_SACCH(0))); |
| 1072 | } |
| 1073 | /* test mobile-originated segmentation/de-segmentation on DCCH */ |
| 1074 | testcase TC_segm_concat_dcch() runs on test_CT { |
| 1075 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 1076 | f_testmatrix_each_chan(pars, refers(f_TC_segm_concat_dcch)); |
| 1077 | } |
| 1078 | /* test mobile-originated segmentation/de-segmentation on SACCH */ |
| 1079 | testcase TC_segm_concat_sacch() runs on test_CT { |
| 1080 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 1081 | f_testmatrix_each_chan(pars, refers(f_TC_segm_concat_sacch)); |
| 1082 | } |
| 1083 | |
Harald Welte | b2a3034 | 2019-06-02 22:13:50 +0200 | [diff] [blame] | 1084 | /* TS 04.06 Section 5.8.2.1 */ |
| 1085 | private function f_n200_by_chan_nr(RslChannelNr chan_nr, RslLinkId link_id) return integer { |
| 1086 | /* SACCH irrespective of physical channel type */ |
| 1087 | if (match(link_id, tr_RslLinkID_SACCH(?))) { |
| 1088 | return 5; |
| 1089 | } |
| 1090 | /* DCCH below */ |
| 1091 | select (chan_nr) { |
| 1092 | case (t_RslChanNr_SDCCH4(?, ?)) { return 23; } |
| 1093 | case (t_RslChanNr_SDCCH8(?, ?)) { return 23; } |
| 1094 | case (t_RslChanNr_Bm(?)) { return 34; } |
| 1095 | case (t_RslChanNr_Lm(?, ?)) { return 29; } |
| 1096 | } |
| 1097 | setverdict(fail, "Unknown chan_nr ", chan_nr, " or link_id ", link_id); |
| 1098 | return -1; |
| 1099 | } |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 1100 | |
Harald Welte | b2a3034 | 2019-06-02 22:13:50 +0200 | [diff] [blame] | 1101 | /* Test if there are exactly N200+1 transmissions of I frames; inspired by 25.2.4.1 */ |
| 1102 | private function f_TC_t200_n200(charstring id) runs on ConnHdlr { |
| 1103 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 1104 | var integer sapi := link_id.sapi; |
| 1105 | var boolean is_sacch := false; |
| 1106 | if (link_id.c == SACCH) { |
| 1107 | is_sacch := true; |
| 1108 | } |
| 1109 | var integer n200 := f_n200_by_chan_nr(g_chan_nr, link_id); |
| 1110 | var integer num_retrans := 0; |
| 1111 | timer T := 3.0; |
| 1112 | var default d; |
| 1113 | |
| 1114 | fp_common_init(); |
| 1115 | |
| 1116 | /* some common altstep for meas res and other background noise */ |
| 1117 | d := activate(as_ignore_background(true)); |
| 1118 | RSL.clear; |
| 1119 | LAPDM.clear; |
| 1120 | |
Harald Welte | 76771f1 | 2019-06-02 22:58:58 +0200 | [diff] [blame] | 1121 | f_establish_mo(link_id); |
Harald Welte | b2a3034 | 2019-06-02 22:13:50 +0200 | [diff] [blame] | 1122 | |
| 1123 | var octetstring l3_mt := f_rnd_octstring(20); |
| 1124 | RSL.send(ts_RSL_DATA_REQ(g_chan_nr, link_id, l3_mt)); |
| 1125 | /* first transmission, P = 0 */ |
| 1126 | LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_I(sapi, c_r:=cr_MT_CMD, p:=false, |
| 1127 | nr:=0, ns:=0, l3:=l3_mt))); |
| 1128 | deactivate(d); |
| 1129 | |
| 1130 | alt { |
| 1131 | /* re-transmission, P = 1 */ |
| 1132 | [] LAPDM.receive(t_PH_DATA(0, is_sacch, |
| 1133 | tr_LAPDm_I(sapi, c_r:=cr_MT_CMD, p:=true, nr:=0, ns:=0, l3:=l3_mt))) { |
| 1134 | num_retrans := num_retrans + 1; |
| 1135 | if (num_retrans < n200) { |
| 1136 | repeat; |
| 1137 | } else if (num_retrans == n200) { |
| 1138 | T.start; /* wait for some more time if there are more retransmissions */ |
| 1139 | repeat; |
| 1140 | } else { |
| 1141 | /* break */ |
| 1142 | } |
| 1143 | } |
| 1144 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_I(sapi, ?, ?, ?, ?, ?))) { |
| 1145 | setverdict(fail, "Received unexpected I frame"); |
| 1146 | } |
| 1147 | [not is_sacch] as_lapdm_acch(); |
| 1148 | [is_sacch] as_lapdm_dcch(); |
| 1149 | [] as_lapdm_idle(); |
| 1150 | [] as_rsl_meas_rep(); |
| 1151 | [num_retrans == n200] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, '01'O)) { |
| 1152 | /* break */ |
| 1153 | } |
| 1154 | [] T.timeout { |
| 1155 | setverdict(fail, "Missing RSL RLL ERROR INDICATION"); |
| 1156 | } |
| 1157 | } |
| 1158 | |
| 1159 | if (num_retrans == n200) { |
| 1160 | setverdict(pass, "Received ", num_retrans, " on channel ", g_chan_nr, " link ", link_id); |
| 1161 | } else if (num_retrans < n200) { |
| 1162 | setverdict(fail, "Too few retransmissions (", num_retrans, "); N200=", n200, |
| 1163 | " on channel ", g_chan_nr, " link ", link_id); |
| 1164 | } |
| 1165 | |
| 1166 | fp_common_fini(); |
| 1167 | } |
| 1168 | testcase TC_t200_n200() runs on test_CT { |
| 1169 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 1170 | f_testmatrix_each_chan(pars, refers(f_TC_t200_n200)); |
| 1171 | } |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 1172 | |
Harald Welte | 7d9f6db | 2019-06-02 23:14:04 +0200 | [diff] [blame] | 1173 | /* Ensure BTS repeats RR frame after retransmitting I frame to emulate RR loss; |
| 1174 | Inspired by TS 51.010-1 25.2.4.3 */ |
| 1175 | private function f_TC_rr_response_frame_loss(charstring id) runs on ConnHdlr { |
| 1176 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 1177 | var integer sapi := link_id.sapi; |
| 1178 | var boolean is_sacch := false; |
| 1179 | if (link_id.c == SACCH) { |
| 1180 | is_sacch := true; |
| 1181 | } |
| 1182 | timer T := 3.0; |
| 1183 | var default d; |
| 1184 | |
| 1185 | fp_common_init(); |
| 1186 | |
| 1187 | /* some common altstep for meas res and other background noise */ |
| 1188 | d := activate(as_ignore_background(true)); |
| 1189 | RSL.clear; |
| 1190 | LAPDM.clear; |
| 1191 | |
| 1192 | f_establish_mo(link_id); |
| 1193 | |
| 1194 | var octetstring l3_mo := f_rnd_octstring(10); |
| 1195 | /* Send an I frame to the BTS: SAPI = 0, C = 1, P = 0, M = 0, L = 3, N(S) = 0, N(R) = 0 */ |
| 1196 | LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_I(sapi, c_r:=cr_MO_CMD, p:=false, nr:=0, ns:=0, |
| 1197 | l3:=l3_mo))); |
| 1198 | RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3_mo)); |
| 1199 | /* SAPI = 0, R = 1, F = 0, M = 0, L = 0, N(R) = 1. */ |
| 1200 | LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_RR(sapi, c_r:=cr_MT_RSP, p:=false, nr:=1))); |
| 1201 | |
| 1202 | /* Re-send I frame: SAPI = 0, C = 1, P = 1, M = 0, L = 3, N(S) = 0, N(R) = 0. */ |
| 1203 | LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_I(sapi, c_r:=cr_MO_CMD, p:=true, nr:=0, ns:=0, |
| 1204 | l3:=l3_mo))); |
| 1205 | |
| 1206 | T.start; |
| 1207 | alt { |
| 1208 | /* RR: SAPI = 0, R = 1, F = 1, M = 0, L = 0, N(R) = 1. */ |
| 1209 | [] LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_RR(sapi, c_r:=cr_MT_RSP, p:=true, nr:=1))) { |
| 1210 | setverdict(pass); |
| 1211 | } |
| 1212 | /* REJ: SAPI = 0, R = 1, F = 1, M = 0, L = 0, N(R) = 1. */ |
| 1213 | [] LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_REJ(sapi, c_r:=cr_MT_RSP, p:=true, nr:=1))) { |
| 1214 | setverdict(pass); |
| 1215 | } |
| 1216 | [] T.timeout { |
| 1217 | setverdict(fail, "Timeout waiting for RR or REJ"); |
| 1218 | } |
| 1219 | } |
| 1220 | |
| 1221 | deactivate(d); |
| 1222 | |
| 1223 | fp_common_fini(); |
| 1224 | } |
| 1225 | testcase TC_rr_response_frame_loss() runs on test_CT { |
| 1226 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 1227 | f_testmatrix_each_chan(pars, refers(f_TC_rr_response_frame_loss)); |
| 1228 | } |
| 1229 | |
Harald Welte | 4447978 | 2019-06-02 23:23:45 +0200 | [diff] [blame] | 1230 | /* Ensure BTS ignores I frames with wrong C/R bit; Inspired by TS 51.010-1 25.2.5.1 */ |
| 1231 | private function f_TC_incorrect_cr(charstring id) runs on ConnHdlr { |
| 1232 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 1233 | var integer sapi := link_id.sapi; |
| 1234 | var boolean is_sacch := false; |
| 1235 | if (link_id.c == SACCH) { |
| 1236 | is_sacch := true; |
| 1237 | } |
| 1238 | timer T := 3.0; |
| 1239 | var default d; |
| 1240 | |
| 1241 | fp_common_init(); |
| 1242 | |
| 1243 | /* some common altstep for meas res and other background noise */ |
| 1244 | d := activate(as_ignore_background(true)); |
| 1245 | RSL.clear; |
| 1246 | LAPDM.clear; |
| 1247 | |
| 1248 | f_establish_mo(link_id); |
| 1249 | |
| 1250 | var octetstring l3_mo := f_rnd_octstring(10); |
| 1251 | /* Send an I frame to the BTS: SAPI = 0, C = 0, P = 1, M = 0, L = 3, N(S) = 0, N(R) = 0 */ |
| 1252 | LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_I(sapi, c_r:=cr_MO_RSP, p:=true, nr:=0, ns:=0, |
| 1253 | l3:=l3_mo))); |
| 1254 | T.start; |
| 1255 | alt { |
| 1256 | [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3_mo)) { |
| 1257 | setverdict(fail, "BTS didn't ignore I frame with wrong C/R bit"); |
| 1258 | } |
| 1259 | [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, '0C'O)) { |
| 1260 | repeat; |
| 1261 | } |
| 1262 | /* ensure BTS still sends idle frames */ |
| 1263 | [] as_lapdm_idle() { |
| 1264 | setverdict(pass, "still sending idle frames"); |
| 1265 | } |
| 1266 | [] T.timeout {} |
| 1267 | } |
| 1268 | |
| 1269 | /* Send RR command P=1 */ |
| 1270 | LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_RR(sapi, c_r:=cr_MO_CMD, p:=true, nr:=0))); |
| 1271 | |
| 1272 | /* The BTS shall respond with a RR response, F bit set to 1. */ |
| 1273 | LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_RR(sapi, c_r:=cr_MT_RSP, p:=true, nr:=0))); |
| 1274 | |
| 1275 | deactivate(d); |
| 1276 | |
| 1277 | fp_common_fini(); |
| 1278 | } |
| 1279 | testcase TC_incorrect_cr() runs on test_CT { |
| 1280 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 1281 | f_testmatrix_each_chan(pars, refers(f_TC_incorrect_cr)); |
| 1282 | } |
Harald Welte | a39ac75 | 2019-06-04 21:46:07 +0200 | [diff] [blame] | 1283 | |
| 1284 | /* test that the BTS will take no action when it receives an SABM frame with the C bit set wrong (R) |
| 1285 | Inspired by TS 51.010-1 25.2.5.2 */ |
| 1286 | private function f_TC_sabm_incorrect_c(charstring id) runs on ConnHdlr { |
| 1287 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 1288 | var integer sapi := link_id.sapi; |
| 1289 | var boolean is_sacch := false; |
| 1290 | if (link_id.c == SACCH) { |
| 1291 | is_sacch := true; |
| 1292 | } |
| 1293 | timer T := 3.0; |
| 1294 | var default d; |
| 1295 | |
| 1296 | fp_common_init(); |
| 1297 | |
| 1298 | /* some common altstep for meas res and other background noise */ |
| 1299 | d := activate(as_ignore_background(true)); |
| 1300 | RSL.clear; |
| 1301 | LAPDM.clear; |
| 1302 | |
| 1303 | f_establish_mo(link_id); |
| 1304 | |
| 1305 | /* Send I-frame SAPI = 0, C = 1, P = 0, M = 0, L = 3, N(S) = 0, N(R) = 0 */ |
| 1306 | var octetstring l3_mo := '010203'O; |
| 1307 | LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_I(sapi, c_r:=cr_MO_CMD, p:=false, nr:=0, ns:=0, |
| 1308 | l3:=l3_mo))); |
| 1309 | /* Expect RR SAPI = 0, R = 1, F = 0, M = 0, L = 0, N(R) = 1 */ |
| 1310 | LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_RR(sapi, c_r:=cr_MT_RSP, p:=false, nr:=1))); |
| 1311 | RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3_mo)); |
| 1312 | /* Send SABM SAPI = 0, C = 0, P = 1, M = 0, L = 0 */ |
| 1313 | LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_SABM(sapi, c_r:=cr_MO_RSP, p:=true, l3:=''O))); |
| 1314 | /* Expect RSL ERR IND */ |
| 1315 | RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, '0C'O)); |
| 1316 | /* Expect fill frame C = 0, P = 0, M = 0, L = 0 */ |
| 1317 | LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_UI(0, ?, ''O))); |
| 1318 | /* Send RR command (P=1) SAPI = 0, C = 1, P = 1, M = 0, L = 0, N(R) = 0 */ |
| 1319 | LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_RR(sapi, c_r:=cr_MO_CMD, p:=true, nr:=0))); |
| 1320 | /* Expect RR response (F=1) SAPI = 0, R = 1, F = 1, M = 0, L = 0, N(R) = 1 */ |
| 1321 | LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_RR(sapi, c_r:=cr_MT_RSP, p:=true, nr:=1))); |
| 1322 | |
| 1323 | deactivate(d); |
| 1324 | |
| 1325 | fp_common_fini(); |
| 1326 | } |
| 1327 | testcase TC_sabm_incorrect_c() runs on test_CT { |
| 1328 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 1329 | f_testmatrix_each_chan(pars, refers(f_TC_sabm_incorrect_c)); |
| 1330 | } |
| 1331 | |
Pau Espin Pedrol | 820b474 | 2020-10-19 20:19:14 +0200 | [diff] [blame] | 1332 | /* Test procedure for normal reestablishment, as per: |
| 1333 | * OS#4819 |
| 1334 | * 3GPP TS 44.006 8.4.1.2 "Normal establishment procedure" |
| 1335 | * 3GPP TS 44.006 8.4.2.1 "General requirements" |
| 1336 | * 3GPP TS 44.006 8.6.3 "Procedures for re-establishment" |
| 1337 | * */ |
| 1338 | private function f_TC_normal_reestablishment(charstring id) runs on ConnHdlr { |
| 1339 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)) |
| 1340 | var octetstring l3_mo := f_rnd_octstring(c_TS0406_MAX_L3_OCTETS); |
| 1341 | var default d; |
| 1342 | timer T := 3.0; |
| 1343 | var boolean use_sacch := false; |
| 1344 | var boolean received_estind := false; |
| 1345 | var boolean received_ua := false; |
| 1346 | |
| 1347 | fp_common_init(); |
| 1348 | |
| 1349 | /* some common altstep for meas res and other background noise */ |
| 1350 | d := activate(as_ignore_background(true)); |
| 1351 | RSL.clear; |
| 1352 | LAPDM.clear; |
| 1353 | |
| 1354 | f_establish_mo(link_id); |
| 1355 | |
| 1356 | deactivate(d); |
| 1357 | |
| 1358 | var LapdmDlState dls := valueof(t_init_LapdmDlState); |
| 1359 | f_lapdm_transceive_mo(dls, link_id, l3_mo); |
| 1360 | |
| 1361 | LAPDM.send(t_PH_DATA(link_id.sapi, use_sacch, ts_LAPDm_SABM(link_id.sapi, c_r:=cr_MO_CMD, p:=true, l3:=''O))); |
| 1362 | T.start |
| 1363 | alt { |
| 1364 | [] LAPDM.receive(t_PH_DATA(?, use_sacch, tr_LAPDm_UA(link_id.sapi, cr_MT_RSP, f:=true, l3:=''O))) { |
| 1365 | received_ua := true; |
| 1366 | if (not received_estind) { |
| 1367 | repeat; |
| 1368 | } |
| 1369 | } |
| 1370 | [] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id)) { |
| 1371 | received_estind := true; |
| 1372 | if (not received_ua) { |
| 1373 | repeat; |
| 1374 | } |
| 1375 | } |
| 1376 | [] RSL.receive { repeat; } |
| 1377 | [] LAPDM.receive { repeat; } |
| 1378 | [] T.timeout { setverdict(fail, "Timeout waiting for UA"); } |
| 1379 | } |
| 1380 | |
| 1381 | /* Test we can still send data afterwards */ |
| 1382 | l3_mo := f_rnd_octstring(c_TS0406_MAX_L3_OCTETS); |
| 1383 | dls := valueof(t_init_LapdmDlState); |
| 1384 | f_lapdm_transceive_mo(dls, link_id, l3_mo); |
| 1385 | |
| 1386 | |
| 1387 | fp_common_fini(); |
| 1388 | } |
| 1389 | testcase TC_normal_reestablishment() runs on test_CT { |
| 1390 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 1391 | f_testmatrix_each_chan(pars, refers(f_TC_normal_reestablishment)); |
| 1392 | } |
| 1393 | |
Pau Espin Pedrol | faf9706 | 2020-10-20 13:19:33 +0200 | [diff] [blame] | 1394 | /* Test procedure for normal reestablishment in state LAPD_STATE_TIMER_RECOV (after T200, waiting for Ack), as per: |
| 1395 | * OS#4819 |
| 1396 | * 3GPP TS 44.006 8.4.1.2 "Normal establishment procedure" |
| 1397 | * 3GPP TS 44.006 8.4.2.1 "General requirements" |
| 1398 | * 3GPP TS 44.006 8.6.3 "Procedures for re-establishment" |
| 1399 | * */ |
| 1400 | private function f_TC_normal_reestablishment_state_unacked(charstring id) runs on ConnHdlr { |
| 1401 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)) |
| 1402 | var octetstring l3_mo := f_rnd_octstring(c_TS0406_MAX_L3_OCTETS); |
| 1403 | var octetstring l3_mt := f_rnd_octstring(20); |
| 1404 | var LapdmDlState dls; |
| 1405 | var default d; |
| 1406 | timer T := 3.0; |
| 1407 | var boolean use_sacch := false; |
| 1408 | var boolean received_estind := false; |
| 1409 | var boolean received_ua := false; |
| 1410 | |
| 1411 | fp_common_init(); |
| 1412 | |
| 1413 | /* some common altstep for meas res and other background noise */ |
| 1414 | d := activate(as_ignore_background(true)); |
| 1415 | RSL.clear; |
| 1416 | LAPDM.clear; |
| 1417 | |
| 1418 | f_establish_mo(link_id); |
| 1419 | RSL.send(ts_RSL_DATA_REQ(g_chan_nr, link_id, l3_mt)); |
| 1420 | /* first transmission, P = 0 */ |
| 1421 | LAPDM.receive(t_PH_DATA(0, use_sacch, tr_LAPDm_I(link_id.sapi, c_r:=cr_MT_CMD, p:=false, |
| 1422 | nr:=0, ns:=0, l3:=l3_mt))); |
| 1423 | /* re-transmission, P = 1 */ |
| 1424 | LAPDM.receive(t_PH_DATA(0, use_sacch, tr_LAPDm_I(link_id.sapi, c_r:=cr_MT_CMD, p:=true, |
| 1425 | nr:=0, ns:=0, l3:=l3_mt))); |
| 1426 | deactivate(d); |
| 1427 | |
| 1428 | /* We received one retrans, so peer is in LAPD_STATE_TIMER_RECOV state. Now send SABM: */ |
| 1429 | LAPDM.send(t_PH_DATA(link_id.sapi, use_sacch, ts_LAPDm_SABM(link_id.sapi, c_r:=cr_MO_CMD, p:=true, l3:=''O))); |
| 1430 | T.start |
| 1431 | alt { |
| 1432 | [] LAPDM.receive(t_PH_DATA(?, use_sacch, tr_LAPDm_UA(link_id.sapi, cr_MT_RSP, f:=true, l3:=''O))) { |
| 1433 | received_ua := true; |
| 1434 | if (not received_estind) { |
| 1435 | repeat; |
| 1436 | } |
| 1437 | } |
| 1438 | [] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id)) { |
| 1439 | received_estind := true; |
| 1440 | if (not received_ua) { |
| 1441 | repeat; |
| 1442 | } |
| 1443 | } |
| 1444 | [] RSL.receive { repeat; } |
| 1445 | [] LAPDM.receive { repeat; } |
| 1446 | [] T.timeout { setverdict(fail, "Timeout waiting for UA"); } |
| 1447 | } |
| 1448 | |
| 1449 | /* Test we can still send data afterwards */ |
| 1450 | l3_mo := f_rnd_octstring(c_TS0406_MAX_L3_OCTETS); |
| 1451 | dls := valueof(t_init_LapdmDlState); |
| 1452 | f_lapdm_transceive_mo(dls, link_id, l3_mo); |
| 1453 | |
| 1454 | fp_common_fini(); |
| 1455 | } |
| 1456 | testcase TC_normal_reestablishment_state_unacked() runs on test_CT { |
| 1457 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 1458 | f_testmatrix_each_chan(pars, refers(f_TC_normal_reestablishment_state_unacked)); |
| 1459 | } |
| 1460 | |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 1461 | control { |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 1462 | execute(TC_sabm_ua_dcch_sapi0()); |
| 1463 | execute(TC_sabm_ua_dcch_sapi0_nopayload()); |
| 1464 | execute(TC_sabm_ua_dcch_sapi3()); |
| 1465 | execute(TC_sabm_ua_dcch_sapi4()); |
| 1466 | execute(TC_sabm_contention()); |
| 1467 | execute(TC_sabm_retransmit()); |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 1468 | execute(TC_sabm_retransmit_bts()); |
| 1469 | execute(TC_sabm_invalid_resp()); |
| 1470 | execute(TC_sabm_dm()); |
| 1471 | execute(TC_establish_ign_first_sabm()); |
| 1472 | execute(TC_iframe_seq_and_ack()); |
| 1473 | execute(TC_iframe_timer_recovery()); |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 1474 | execute(TC_ns_seq_error()); |
| 1475 | execute(TC_nr_seq_error()); |
| 1476 | execute(TC_rec_invalid_frame()); |
Harald Welte | ef6fd44 | 2019-06-01 21:41:29 +0200 | [diff] [blame] | 1477 | execute(TC_segm_concat_dcch()); |
| 1478 | execute(TC_segm_concat_sacch()); |
Harald Welte | b2a3034 | 2019-06-02 22:13:50 +0200 | [diff] [blame] | 1479 | execute(TC_t200_n200()); |
Harald Welte | 7d9f6db | 2019-06-02 23:14:04 +0200 | [diff] [blame] | 1480 | execute(TC_rr_response_frame_loss()); |
Harald Welte | 4447978 | 2019-06-02 23:23:45 +0200 | [diff] [blame] | 1481 | execute(TC_incorrect_cr()); |
Harald Welte | a39ac75 | 2019-06-04 21:46:07 +0200 | [diff] [blame] | 1482 | execute(TC_sabm_incorrect_c()); |
Pau Espin Pedrol | 820b474 | 2020-10-19 20:19:14 +0200 | [diff] [blame] | 1483 | execute(TC_normal_reestablishment()); |
Pau Espin Pedrol | faf9706 | 2020-10-20 13:19:33 +0200 | [diff] [blame] | 1484 | execute(TC_normal_reestablishment_state_unacked()); |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 1485 | } |
| 1486 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 1487 | } |