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; |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 9 | import from Misc_Helpers all; |
Harald Welte | 66110f0 | 2017-07-16 21:05:18 +0200 | [diff] [blame] | 10 | |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 11 | /* test that use exclusively only LAPDm over L1CTL */ |
| 12 | type component lapdm_test_CT { |
| 13 | port LAPDm_PT LAPDM; |
| 14 | var lapdm_CT lapdm_component; |
| 15 | }; |
| 16 | |
| 17 | /* contrary to BTS_Tests.ttcn, we use LAPDm_PT here, a convenience wrapper |
| 18 | * around L1CTL to perform encode/decode of abstract LAPDm frames */ |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 19 | |
Harald Welte | 61332c0 | 2019-05-30 16:45:15 +0200 | [diff] [blame] | 20 | /********************************************************************************* |
| 21 | * Test using only L1CTL/LAPDm |
| 22 | *********************************************************************************/ |
| 23 | |
| 24 | function f_lapdm_init() runs on lapdm_test_CT { |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 25 | /* create the LAPDm component */ |
| 26 | lapdm_component := lapdm_CT.create; |
| 27 | /* connect our own LAPDM port to the LAPDM Service Provider of the LAPDm component */ |
| 28 | connect(self:LAPDM, lapdm_component:LAPDM_SP); |
| 29 | /* connect the LAPDm compoent's lower-side port to the system L1CTL port (which is internally |
| 30 | * connected to the Unix Domain Socket test port */ |
| 31 | map(lapdm_component:L1CTL, system:L1CTL); |
| 32 | |
| 33 | /* start the LAPDm parallel component calling it's local function LAPDmStart */ |
| 34 | lapdm_component.start(LAPDmStart()); |
| 35 | } |
| 36 | |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 37 | function f_lapdm_exit() runs on lapdm_test_CT { |
| 38 | lapdm_component.stop; |
| 39 | lapdm_component.done; |
| 40 | unmap(lapdm_component:L1CTL, system:L1CTL); |
| 41 | } |
| 42 | |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 43 | /* master function establishing a dedicated radio channel (takes care of RACH/IMM.ASS handling) */ |
| 44 | function f_establish_dcch() runs on lapdm_test_CT { |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 45 | var BCCH_tune_req tune_req := { arfcn := { false, mp_trx0_arfcn }, combined_ccch := true }; |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 46 | var DCCH_establish_req est_req := { ra := 23 }; |
| 47 | |
| 48 | LAPDM.send(tune_req); |
| 49 | LAPDM.send(est_req); |
| 50 | LAPDM.receive(DCCH_establish_res:?); |
| 51 | } |
| 52 | |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 53 | /* master function switching to a dedicated radio channel */ |
| 54 | function f_switch_dcch(Arfcn arfcn, RslChannelNr chan_nr, GsmTsc tsc) runs on lapdm_test_CT { |
| 55 | var BCCH_tune_req tune_req := { arfcn := arfcn, combined_ccch := true }; |
| 56 | var DCCH_switch_req sw_req := { arfcn, chan_nr, tsc }; |
| 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(); |
| 231 | /* activate the channel on the BTS side */ |
| 232 | f_rsl_chan_act(g_pars.chan_mode, false, {}); |
| 233 | /* activate the channel on the MS side */ |
| 234 | f_switch_dcch({false, mp_trx0_arfcn}, g_chan_nr, 7); |
| 235 | } |
| 236 | |
| 237 | private function fp_common_fini() runs on ConnHdlr |
| 238 | { |
| 239 | f_release_dcch(); |
| 240 | f_rsl_chan_deact(); |
| 241 | f_lapdm_exit(); |
| 242 | } |
| 243 | |
Harald Welte | 76771f1 | 2019-06-02 22:58:58 +0200 | [diff] [blame] | 244 | /* Mobile-Originated LAPDm establishment on given Link ID */ |
| 245 | private function f_establish_mo(RslLinkId link_id) runs on ConnHdlr |
| 246 | { |
| 247 | var integer sapi := link_id.sapi; |
| 248 | var boolean is_sacch := false; |
| 249 | if (link_id.c == SACCH) { |
| 250 | is_sacch := true; |
| 251 | } |
| 252 | |
| 253 | var octetstring l3_mo := f_rnd_octstring(5); |
| 254 | |
| 255 | /* MO Establish Request via LADPm: SAPI = 0, C = 0, P = 1, M = 0, 0 ≤ L ≤ N201.. */ |
| 256 | if (is_sacch) { |
| 257 | /* no payload permitted, as this is not contention resolution */ |
| 258 | l3_mo := ''O; |
| 259 | LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, p:=true, l3:=l3_mo))); |
| 260 | RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id)); |
| 261 | } else { |
| 262 | LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, p:=true, l3:=l3_mo))); |
| 263 | RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3_mo)); |
| 264 | } |
| 265 | /* UA: SAPI = 0, R = 0, F = 1, M = 0, L = L of SABM. */ |
| 266 | LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_UA(sapi, cr_MT_RSP, f:=true, l3:=l3_mo))); |
| 267 | } |
| 268 | |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 269 | /* Verify that the BTS is re-transmitting SABM messages after T200 timeout, inspired |
| 270 | by 3GPP TS 51.010-1 25.2.1.1.2.1 + 25.2.1.2.4 */ |
| 271 | private function f_TC_sabm_retransmit_bts(charstring id) runs on ConnHdlr { |
| 272 | const integer sapi := 3; /* BTS may not establish SAPI=0 outbound */ |
| 273 | fp_common_init(); |
| 274 | |
| 275 | LAPDM.clear; |
| 276 | RSL.send(ts_RSL_EST_REQ(g_chan_nr, ts_RslLinkID_DCCH(sapi))); |
| 277 | |
| 278 | timer T := 8.0; |
| 279 | var integer sabm_received := 0; |
| 280 | T.start; |
| 281 | alt { |
| 282 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_SABM(sapi, ?, ?, ''O))) { |
| 283 | sabm_received := sabm_received + 1; |
| 284 | repeat; |
| 285 | } |
| 286 | [] LAPDM.receive { repeat; } |
| 287 | [] T.timeout { } |
| 288 | } |
| 289 | if (sabm_received == 0) { |
| 290 | setverdict(fail, "No SABM observed at all!"); |
| 291 | } else if (sabm_received != 6) { |
| 292 | setverdict(fail, "Incorrect number of SABM re-transmissions of observed: ", |
| 293 | sabm_received); |
| 294 | } else { |
| 295 | setverdict(pass, "Received ", sabm_received, " SABM"); |
| 296 | } |
| 297 | |
| 298 | fp_common_fini(); |
| 299 | } |
| 300 | testcase TC_sabm_retransmit_bts() runs on test_CT { |
| 301 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 302 | f_testmatrix_each_chan(pars, refers(f_TC_sabm_retransmit_bts)); |
| 303 | } |
| 304 | |
| 305 | |
| 306 | type record LapdmNamedFrame { |
| 307 | charstring name, |
| 308 | LapdmFrame lapdm |
| 309 | }; |
| 310 | |
| 311 | /* Test that the BTS will ignore receipt of frames other than a UA when |
| 312 | * received in response to the SABM frame, inspired from 3GPP TS 51.010-1 |
| 313 | * Section 25.2.1.1.2.3 */ |
| 314 | private function f_TC_sabm_invalid_resp2(charstring id, LapdmNamedFrame err_frame) runs on ConnHdlr { |
| 315 | var integer sapi := err_frame.lapdm.ab.addr.sapi; |
| 316 | fp_common_init(); |
| 317 | |
| 318 | /* Establish Request via RSL; Expect SABM on LAPDm side */ |
| 319 | LAPDM.clear; |
| 320 | RSL.send(ts_RSL_EST_REQ(g_chan_nr, ts_RslLinkID_DCCH(sapi))); |
| 321 | alt { |
| 322 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_SABM(sapi, ?, ?, ''O))); |
| 323 | [] LAPDM.receive { repeat; } |
| 324 | } |
| 325 | |
| 326 | /* send erroneous response to SABM */ |
| 327 | LAPDM.send(t_PH_DATA(0, false, err_frame.lapdm)); |
| 328 | |
| 329 | /* expect a SABM retransmission of the BTS */ |
| 330 | timer T := 3.0; |
| 331 | T.start; |
| 332 | alt { |
| 333 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_SABM(sapi, ?, ?, ''O))) { |
| 334 | setverdict(pass); |
| 335 | } |
| 336 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_UI(0, ?, ''O))) { repeat; } |
| 337 | [] LAPDM.receive(t_PH_DATA(0, false, ?)) { |
| 338 | setverdict(fail, "Received unexpected LAPDm frame instead of SABM after sending ", |
| 339 | err_frame.name); |
| 340 | } |
| 341 | [] LAPDM.receive { repeat; } |
| 342 | [] T.timeout { |
| 343 | setverdict(fail, "Timeout waiting for SABM retransmission after sending ", |
| 344 | err_frame.name); |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | fp_common_fini(); |
| 349 | } |
| 350 | private function f_TC_sabm_invalid_resp(charstring id) runs on ConnHdlr { |
| 351 | const integer sapi := 3; /* BTS may not establish SAPI=0 outbound */ |
| 352 | var LapdmNamedFrame err_frame[3] := { |
| 353 | { "I", valueof(ts_LAPDm_I(sapi, c_r := cr_MO_CMD, p := true, nr := 0, ns := 0, |
| 354 | l3 := '01020304'O)) }, |
| 355 | { "RR", valueof(ts_LAPDm_RR(sapi, c_r := cr_MO_CMD, p := true, nr := 0)) }, |
| 356 | { "REJ" , valueof(ts_LAPDm_REJ(sapi, c_r := cr_MO_CMD, p := true, nr := 0)) } |
| 357 | }; |
| 358 | var integer i; |
| 359 | |
| 360 | for (i := 0; i < lengthof(err_frame); i := i+1) { |
| 361 | f_TC_sabm_invalid_resp2(id, err_frame[i]) |
| 362 | } |
| 363 | } |
| 364 | testcase TC_sabm_invalid_resp() runs on test_CT { |
| 365 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 366 | f_testmatrix_each_chan(pars, refers(f_TC_sabm_invalid_resp)); |
| 367 | } |
| 368 | |
| 369 | /* Test that the BTS will not re-transmit SABM frames after receiving a DM response, |
| 370 | * inspired from 3GPP TS 51.010-1 Section 25.2.1.1.3 */ |
| 371 | private function f_TC_sabm_dm(charstring id) runs on ConnHdlr { |
| 372 | const integer sapi := 3; /* BTS may not establish SAPI=0 outbound */ |
| 373 | fp_common_init(); |
| 374 | |
| 375 | /* Establish Request via RSL; Expect SABM on LAPDm side */ |
| 376 | LAPDM.clear; |
| 377 | RSL.send(ts_RSL_EST_REQ(g_chan_nr, ts_RslLinkID_DCCH(sapi))); |
| 378 | alt { |
| 379 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_SABM(sapi, ?, ?, ''O))); |
| 380 | [] LAPDM.receive { repeat; } |
| 381 | } |
| 382 | |
| 383 | /* send DM response to SABM */ |
| 384 | RSL.clear; |
| 385 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_DM(sapi, c_r:=cr_MO_RSP, f:=true))); |
| 386 | alt { |
| 387 | [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tr_RslLinkID_DCCH(sapi))); |
| 388 | [] RSL.receive { repeat; } |
| 389 | } |
| 390 | |
| 391 | /* expect no SABM retransmission of the BTS */ |
| 392 | timer T := 3.0; |
| 393 | T.start; |
| 394 | alt { |
| 395 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_SABM(sapi, ?, ?, ''O))) { |
| 396 | setverdict(fail, "Received unexpected SABM retransmission"); |
| 397 | } |
| 398 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_UI(0, ?, ''O))) { repeat; } |
| 399 | [] LAPDM.receive(t_PH_DATA(0, false, ?)) { |
| 400 | setverdict(fail, "Received unexpected LAPDm frame"); |
| 401 | } |
| 402 | [] LAPDM.receive { repeat; } |
| 403 | [] T.timeout { |
| 404 | setverdict(pass); |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | fp_common_fini(); |
| 409 | } |
| 410 | testcase TC_sabm_dm() runs on test_CT { |
| 411 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 412 | f_testmatrix_each_chan(pars, refers(f_TC_sabm_dm)); |
| 413 | } |
| 414 | |
| 415 | /* Test the full LAPDm establishment while simulating the loss of the initial SABM or UA |
| 416 | * frame, requiring the BTS to re-transmit one SABM and then following up all the way to |
| 417 | * dedicated mode; inspired by 3GPP TS 51.010-1 25.2.1.2.2 */ |
| 418 | private function f_TC_establish_ign_first_sabm(charstring id) runs on ConnHdlr { |
| 419 | const integer sapi := 3; /* BTS may not establish SAPI=0 outbound */ |
| 420 | var integer num_sabm := 0; |
| 421 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(sapi)); |
| 422 | timer T := 3.0; |
| 423 | |
| 424 | fp_common_init(); |
| 425 | |
| 426 | /* Establish Request via RSL */ |
| 427 | LAPDM.clear; |
| 428 | RSL.send(ts_RSL_EST_REQ(g_chan_nr, link_id)); |
| 429 | /* Expect two SABM (retransmit) */ |
| 430 | T.start; |
| 431 | alt { |
| 432 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_SABM(sapi, ?, ?, ''O))) { |
| 433 | num_sabm := num_sabm + 1; |
| 434 | if (num_sabm < 2) { |
| 435 | repeat; |
| 436 | } |
| 437 | } |
| 438 | [] LAPDM.receive { repeat; } |
| 439 | } |
| 440 | |
| 441 | /* send UA response to SABM */ |
| 442 | RSL.clear; |
| 443 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_UA(sapi, c_r:=cr_MO_RSP, f:=true, l3:=''O))); |
| 444 | alt { |
| 445 | [] RSL.receive(tr_RSL_EST_CONF(g_chan_nr, link_id)); |
| 446 | [] RSL.receive { repeat; } |
| 447 | } |
| 448 | |
| 449 | /* Send I frame from BTS to MS */ |
| 450 | var octetstring l3 := f_rnd_octstring(10); |
| 451 | RSL.send(ts_RSL_DATA_REQ(g_chan_nr, link_id, l3)); |
| 452 | alt { |
| 453 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_I(sapi, c_r:=cr_MT_CMD, p:=false, |
| 454 | nr:=0, ns:=0, l3:=l3))); |
| 455 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_UI(0, ?, ''O))) { repeat; } |
| 456 | [] LAPDM.receive(t_PH_DATA(0, true, ?)) { repeat; } |
| 457 | [] LAPDM.receive { setverdict(fail, "Unexpected LAPDm received"); } |
| 458 | } |
| 459 | /* Send RR frame in response */ |
| 460 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_RR(sapi, c_r:=cr_MO_RSP, p:=false, nr:=1))); |
| 461 | |
| 462 | /* expect idle UI Frame from BTS */ |
| 463 | alt { |
| 464 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_UI(0, ?, ''O))) { |
| 465 | setverdict(pass); |
| 466 | } |
| 467 | [] LAPDM.receive(t_PH_DATA(0, true, ?)) { repeat; } |
| 468 | [] LAPDM.receive { setverdict(fail, "Unexpected LAPDm received"); } |
| 469 | } |
| 470 | |
| 471 | fp_common_fini(); |
| 472 | } |
| 473 | testcase TC_establish_ign_first_sabm() runs on test_CT { |
| 474 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 475 | f_testmatrix_each_chan(pars, refers(f_TC_establish_ign_first_sabm)); |
| 476 | } |
| 477 | |
| 478 | /* ignore all SACCH frames */ |
| 479 | private altstep as_lapdm_acch() runs on ConnHdlr { |
| 480 | [] LAPDM.receive(t_PH_DATA(0, true, ?)) { repeat; } |
| 481 | } |
Harald Welte | ef6fd44 | 2019-06-01 21:41:29 +0200 | [diff] [blame] | 482 | /* ignore all DCCH frames */ |
| 483 | private altstep as_lapdm_dcch() runs on ConnHdlr { |
| 484 | [] LAPDM.receive(t_PH_DATA(0, false, ?)) { repeat; } |
| 485 | } |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 486 | /* ignore all LAPDm idle frames (UI) */ |
| 487 | private altstep as_lapdm_idle() runs on ConnHdlr { |
Harald Welte | ef6fd44 | 2019-06-01 21:41:29 +0200 | [diff] [blame] | 488 | [] LAPDM.receive(t_PH_DATA(0, ?, tr_LAPDm_UI(?, ?, ''O))) { repeat; } |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 489 | } |
| 490 | /* ignore all measurement reports */ |
| 491 | private altstep as_rsl_meas_rep() runs on ConnHdlr { |
| 492 | [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr)) { repeat; } |
| 493 | } |
| 494 | /* fail if we receive an RSL ERROR IND */ |
| 495 | private altstep as_rsl_fail_err() runs on ConnHdlr { |
| 496 | var RSL_Message rx_rsl; |
| 497 | [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, ?, ?)) { |
| 498 | setverdict(fail, "Received RSL ERROR IND ", rx_rsl); |
| 499 | } |
| 500 | } |
| 501 | /* all of the above */ |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 502 | 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] | 503 | [want_dcch] as_lapdm_acch(); |
| 504 | [not want_dcch] as_lapdm_dcch(); |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 505 | [] as_lapdm_idle(); |
| 506 | [] as_rsl_meas_rep(); |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 507 | [not ignore_rsl_errors] as_rsl_fail_err(); |
| 508 | [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] | 509 | } |
| 510 | |
| 511 | /* Test the operation of Layer 2 sequence numbering. |
| 512 | * dedicated mode; inspired by 3GPP TS 51.010-1 25.2.2.1 */ |
| 513 | private function f_TC_iframe_seq_and_ack(charstring id) runs on ConnHdlr { |
| 514 | const integer sapi := 0; |
| 515 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(sapi)); |
| 516 | var octetstring l3 := f_rnd_octstring(18); |
| 517 | var default d; |
| 518 | timer T := 3.0; |
| 519 | |
| 520 | fp_common_init(); |
| 521 | |
| 522 | /* some common altstep for meas res and other background noise */ |
| 523 | d := activate(as_ignore_background()); |
| 524 | RSL.clear; |
| 525 | LAPDM.clear; |
| 526 | |
Harald Welte | 76771f1 | 2019-06-02 22:58:58 +0200 | [diff] [blame] | 527 | f_establish_mo(link_id); |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 528 | |
| 529 | var integer last_ns_rx := 0; |
| 530 | |
| 531 | for (var integer i := 0; i < 10; i := i+1) { |
| 532 | var octetstring l3_mo := f_rnd_octstring(12); |
| 533 | var octetstring l3_mt := f_rnd_octstring(12); |
| 534 | var LAPDm_ph_data pd; |
| 535 | |
| 536 | log("Starting iteration ", i); |
| 537 | /* MT I frame */ |
| 538 | RSL.send(ts_RSL_DATA_REQ(g_chan_nr, link_id, l3_mt)); |
| 539 | alt { |
| 540 | /* SAPI = 0, R = 1, F = 0, M = 0, L = 0. */ |
| 541 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_RR(sapi, c_r:=cr_MT_RSP, p:=false, |
| 542 | nr:=i mod 8))) { |
| 543 | log("Ignoring RR in iteration ", i); |
| 544 | repeat; |
| 545 | } |
| 546 | /* SAPI = 0, C = 1, P = 0, M = 0, 0 ≤ L ≤ N201. */ |
| 547 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_I(sapi, c_r:=cr_MT_CMD, p:=false, |
| 548 | nr:=i mod 8, ns:=i mod 8, |
| 549 | l3:=l3_mt))) -> value pd { |
| 550 | last_ns_rx := pd.lapdm.ab.ctrl.i.n_s; |
| 551 | } |
| 552 | } |
| 553 | /* respond with MO I-frame: SAPI = 0, C = 0, P = 0, M = 0, 0 <= L <= N201. */ |
| 554 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_I(sapi, c_r:=cr_MO_CMD, p:=false, |
| 555 | nr:=(last_ns_rx+1)mod 8, |
| 556 | ns:=i mod 8, l3 := l3_mo))); |
| 557 | RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3_mo)); |
| 558 | } |
| 559 | log("Completed iteration"); |
| 560 | |
| 561 | deactivate(d); |
| 562 | fp_common_fini(); |
| 563 | } |
| 564 | testcase TC_iframe_seq_and_ack() runs on test_CT { |
| 565 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 566 | f_testmatrix_each_chan(pars, refers(f_TC_iframe_seq_and_ack)); |
| 567 | } |
| 568 | |
| 569 | /* To test that the BTS is able to respond to I frames whilst in the timer recovery state. |
| 570 | * Inspired by 3GPP TS 51.010-1 25.2.2.2 */ |
| 571 | |
| 572 | /* |
| 573 | 1) The BTS is brought into the multiple frame established state |
| 574 | 2) The MS sends an L3 Request asking for IMEI to the MS. |
| 575 | 3) The BTS shall respond with a RR frame though this may be incorporated with |
| 576 | the L3 Response I frame. The MS does not respond to the I frame. |
| 577 | 4) The BTS shall wait for expiry of timer T200 and then repeat the I frame but |
| 578 | with the P bit set to 1. |
| 579 | 5) The MS then sends a valid L3 Request I frame asking for IMEI which |
| 580 | does not acknowledge receipt of the I frame from the BTS. |
| 581 | On the FACCH the BTS may send an RR frame acknowledging the I frame. |
| 582 | 6) The BTS shall repeat the I frame, this frame will acknowledge receipt of |
| 583 | the second I frame from the MS. |
| 584 | 7) The MS then acknowledges receipt of the MS I frame by sending a RR frame. |
| 585 | 8) The BTS shall send the next I frame. The MS acknowledges this I frame. |
| 586 | */ |
| 587 | private function f_TC_iframe_timer_recovery(charstring id) runs on ConnHdlr { |
| 588 | const integer sapi := 0; |
| 589 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(sapi)); |
| 590 | var default d; |
| 591 | timer T := 3.0; |
| 592 | |
| 593 | fp_common_init(); |
| 594 | |
| 595 | /* some common altstep for meas res and other background noise */ |
| 596 | d := activate(as_ignore_background()); |
| 597 | RSL.clear; |
| 598 | LAPDM.clear; |
| 599 | |
| 600 | var octetstring l3_mo := f_rnd_octstring(12); |
| 601 | var octetstring l3_mt := f_rnd_octstring(12); |
| 602 | |
| 603 | /* 1) The BTS is brought into the multiple frame established state */ |
| 604 | |
| 605 | /* MO Establish Request via LADPm: SAPI = 0, C = 0, P = 1, M = 0, 0 ≤ L ≤ N201.. */ |
| 606 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, p:=true, l3:=l3_mo))); |
| 607 | RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3_mo)); |
| 608 | /* UA: SAPI = 0, R = 0, F = 1, M = 0, L = L of SABM. */ |
| 609 | LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_UA(sapi, cr_MT_RSP, f:=true, l3:=l3_mo))); |
| 610 | |
| 611 | /* 2) The MS sends an L3 Request to the BTS */ |
| 612 | l3_mo := f_rnd_octstring(18); |
| 613 | /* SAPI = 0, C = 1, P = 0, M = 0, 0 ≤ L ≤ N201, N(S) = 0, N(R) = 0. * */ |
| 614 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_I(sapi, c_r:=cr_MO_CMD, p:=false, |
| 615 | nr:=0, ns:=0, l3:=l3_mo))); |
| 616 | RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3_mo)); |
| 617 | /* 3) The BTS shall respond with a RR frame though this may be incorporated with |
| 618 | the L3 Response I frame. The MS does not respond to the I frame. */ |
| 619 | RSL.send(ts_RSL_DATA_REQ(g_chan_nr, link_id, l3_mt)); |
| 620 | alt { |
| 621 | /* SAPI = 0, R = 1, F = 0, M = 0, L = 0, N(R) = 1. */ |
| 622 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_RR(sapi, c_r:=cr_MT_RSP, p:=false, nr:=1))) { |
| 623 | repeat; |
| 624 | } |
| 625 | /* SAPI = 0, C = 0, P = 0, M = 0, 0 ≤ L ≤ N201, N(R) = 1, N(S) = 0 */ |
| 626 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_I(sapi, c_r:=cr_MT_CMD, p:=false, |
| 627 | nr:=1, ns:=0, l3:=l3_mt))); |
| 628 | } |
| 629 | |
| 630 | /* 4) The BTS shall wait for expiry of timer T200 and then repeat the I frame but |
| 631 | with the P bit set to 1. */ |
| 632 | /* SAPI = 0, C = 0, P = 1, M = 0, 0 ≤ L ≤ N201, N(R) = 1, N(S) = 0. * */ |
| 633 | LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_I(sapi, c_r:=cr_MT_CMD, p:=true, |
| 634 | nr:=1, ns:=0, l3:=l3_mt))); |
| 635 | |
| 636 | /* 5) The MS then sends a valid L3 Request I frame asking for IMEI which |
| 637 | does not acknowledge receipt of the I frame from the BTS. */ |
| 638 | /* SAPI = 0, C = 1, P = 0, M = 0, 0 ≤ L ≤ N201, N(S) = 1, N(R) = 0. * */ |
| 639 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_I(sapi, c_r:=cr_MO_CMD, p:=false, |
| 640 | nr:=0, ns:=1, l3 := l3_mo))); |
| 641 | RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3_mo)); |
| 642 | alt { |
| 643 | /* On the FACCH the BTS may send an RR frame acknowledging the I frame. */ |
| 644 | /* SAPI = 0, R = 1, F = 0, M = 0, L = 0, N(R) = 2. */ |
| 645 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_RR(sapi, c_r:=cr_MT_RSP, p:=false, nr:=2))) { |
| 646 | repeat; |
| 647 | } |
| 648 | /* 6) The BTS shall repeat the I frame, this frame will acknowledge |
| 649 | receipt of the second I frame from the MS. */ |
| 650 | /* SAPI = 0, C = 0, P = 1, M = 0, 0 ≤ L ≤ N201, N(R) = 2, N(S) = 0. * */ |
| 651 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_I(sapi, c_r:=cr_MT_CMD, p:=true, |
| 652 | nr:=2, ns:=0, l3:=l3_mt))); |
| 653 | } |
| 654 | |
| 655 | /* 7) The MS then acknowledges receipt of the BTS I frame by sending a RR * frame. */ |
| 656 | /* SAPI = 0, R = 0, F = 1, 0, M = 0, L = 0, N(R) = 1 */ |
| 657 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_RR(sapi, c_r:=cr_MO_RSP, p:=true, nr:=1))); |
| 658 | |
| 659 | /* 8) The BTS shall send the next I frame. The MS acknowledges this I frame. */ |
| 660 | l3_mt := f_rnd_octstring(16); |
| 661 | RSL.send(ts_RSL_DATA_REQ(g_chan_nr, link_id, l3_mt)); |
| 662 | /* SAPI = 0, C = 0, P = 0, M = 0, 0 ≤ L ≤ N201, N(R) = 2, N(S) = 1 */ |
| 663 | LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_I(sapi, c_r:=cr_MT_CMD, p:=false, |
| 664 | nr:=2, ns:=1, l3:=l3_mt))); |
| 665 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_RR(sapi, c_r:=cr_MO_RSP, p:=true, nr:=2))); |
| 666 | |
| 667 | deactivate(d); |
| 668 | fp_common_fini(); |
| 669 | } |
| 670 | testcase TC_iframe_timer_recovery() runs on test_CT { |
| 671 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 672 | f_testmatrix_each_chan(pars, refers(f_TC_iframe_timer_recovery)); |
| 673 | } |
| 674 | |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 675 | /* 25.2.6.1 ns sequence error |
| 676 | sends wrong N(S), expects REJ, sends wrong N(S) with P=1, expects REJ with F=1 */ |
| 677 | private function f_TC_ns_seq_error(charstring id) runs on ConnHdlr { |
| 678 | const integer sapi := 0; |
| 679 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(sapi)); |
| 680 | var default d; |
| 681 | timer T := 3.0; |
| 682 | |
| 683 | fp_common_init(); |
| 684 | |
| 685 | /* some common altstep for meas res and other background noise */ |
| 686 | d := activate(as_ignore_background(ignore_rsl_errors := true)); |
| 687 | RSL.clear; |
| 688 | LAPDM.clear; |
| 689 | |
| 690 | var octetstring l3_mo := f_rnd_octstring(12); |
| 691 | var octetstring l3_mt := f_rnd_octstring(12); |
| 692 | |
| 693 | /* 1) The BTS is brought into the multiple frame established state */ |
| 694 | |
| 695 | /* MO Establish Request via LADPm: SAPI = 0, C = 0, P = 1, M = 0, 0 ≤ L ≤ N201.. */ |
| 696 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, p:=true, l3:=l3_mo))); |
| 697 | RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3_mo)); |
| 698 | /* UA: SAPI = 0, R = 0, F = 1, M = 0, L = L of SABM. */ |
| 699 | LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_UA(sapi, cr_MT_RSP, f:=true, l3:=l3_mo))); |
| 700 | |
| 701 | /* 2) The MS sends an L3 Request to the BTS */ |
| 702 | l3_mo := f_rnd_octstring(18); |
| 703 | /* SAPI = 0, C = 1, P = 0, M = 0, 0 ≤ L ≤ N201, N(S) = 0, N(R) = 0. * */ |
| 704 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_I(sapi, c_r:=cr_MO_CMD, p:=false, |
| 705 | nr:=0, ns:=0, l3:=l3_mo))); |
| 706 | RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3_mo)); |
| 707 | /* 3) The BTS shall respond with a RR frame though this may be incorporated with |
| 708 | the L3 Response I frame. */ |
| 709 | RSL.send(ts_RSL_DATA_REQ(g_chan_nr, link_id, l3_mt)); |
| 710 | alt { |
| 711 | /* SAPI = 0, R = 1, F = 0, M = 0, L = 0, N(R) = 1. */ |
| 712 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_RR(sapi, c_r:=cr_MT_RSP, p:=false, nr:=1))) { |
| 713 | repeat; |
| 714 | } |
| 715 | /* SAPI = 0, C = 0, P = 0, M = 0, 0 ≤ L ≤ N201, N(R) = 1, N(S) = 0 */ |
| 716 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_I(sapi, c_r:=cr_MT_CMD, p:=false, |
| 717 | nr:=1, ns:=0, l3:=l3_mt))); |
| 718 | } |
| 719 | |
| 720 | /* 4) The MS shall then send an I frame containing Identity Request with incorrect N(S) |
| 721 | but correctly acknowledging the MS's I frame; P bit set to zero. */ |
| 722 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_I(sapi, c_r:=cr_MO_CMD, p:=false, |
| 723 | nr:=1, ns:=0, l3:=l3_mo))); |
| 724 | |
| 725 | /* no rsl data ind due to wrong ns */ |
| 726 | |
| 727 | /* The BTS shall send a REJ frame. */ |
| 728 | timer T1 := 2.0; |
| 729 | T1.start; |
| 730 | alt{ |
| 731 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_REJ(sapi, c_r:=cr_MT_RSP, p:=false, nr:=1))); |
| 732 | [] T1.timeout{ setverdict(fail, "Missing first REJ")} |
| 733 | } |
| 734 | |
| 735 | f_sleep(2.0); // T200 |
| 736 | |
| 737 | /* The MS shall, after T200, send another I frame with incorrect N(S), P bit set to 1 this time. */ |
| 738 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_I(sapi, c_r:=cr_MO_CMD, p:=true, |
| 739 | nr:=1, ns:=0, l3:=l3_mo))); |
| 740 | |
| 741 | /* The BTS shall respond with a REJ, F bit set to 1. */ |
| 742 | T1.start; |
| 743 | alt{ |
| 744 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_REJ(sapi, c_r:=cr_MT_RSP, p:=true, nr:=1))); |
| 745 | [] T1.timeout{ setverdict(fail, "Missing second REJ")} |
| 746 | } |
| 747 | |
| 748 | deactivate(d); |
| 749 | fp_common_fini(); |
| 750 | setverdict(pass); |
| 751 | } |
| 752 | |
| 753 | testcase TC_ns_seq_error() runs on test_CT { |
| 754 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 755 | f_testmatrix_each_chan(pars, refers(f_TC_ns_seq_error)); |
| 756 | } |
| 757 | |
| 758 | /* 25.2.6.2 nr sequence error */ |
| 759 | private function f_TC_nr_seq_error(charstring id) runs on ConnHdlr { |
| 760 | const integer sapi := 0; |
| 761 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(sapi)); |
| 762 | var default d; |
| 763 | var integer n201 := 20; |
| 764 | if (link_id.c == SACCH) { |
| 765 | n201 := 18; |
| 766 | } |
| 767 | |
| 768 | fp_common_init(); |
| 769 | |
| 770 | /* some common altstep for meas res and other background noise */ |
| 771 | d := activate(as_ignore_background(ignore_rsl_errors := true)); |
| 772 | RSL.clear; |
| 773 | LAPDM.clear; |
| 774 | |
| 775 | var octetstring l3_mo := f_rnd_octstring(12); |
| 776 | var octetstring l3_mt := f_rnd_octstring(12); |
| 777 | |
| 778 | /* 1) The BTS is brought into the multiple frame established state */ |
| 779 | |
| 780 | /* MO Establish Request via LADPm: SAPI = 0, C = 0, P = 1, M = 0, 0 ≤ L ≤ N201.. */ |
| 781 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, p:=true, l3:=l3_mo))); |
| 782 | RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3_mo)); |
| 783 | /* UA: SAPI = 0, R = 0, F = 1, M = 0, L = L of SABM. */ |
| 784 | LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_UA(sapi, cr_MT_RSP, f:=true, l3:=l3_mo))); |
| 785 | |
| 786 | /* 2) The MS shall send an I frame containing an information field of length N201 and an |
| 787 | incorrect receive sequence number. */ |
| 788 | l3_mo := f_rnd_octstring(n201); |
| 789 | /* SAPI = 0, C = 1, P = 0, M = 0, L = N201, N(S) = 0, N(R) = 1. * */ |
| 790 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_I(sapi, c_r:=cr_MO_CMD, p:=false, |
| 791 | nr:=1, ns:=0, l3:=l3_mo))); |
| 792 | |
| 793 | /* The BTS may: a) send a DISC frame within N200×T200; */ |
| 794 | /* DISC SAPI = 0, C = 0, P = 1, M = 0, L = 0. */ |
| 795 | timer T1 := 2.0; |
| 796 | T1.start; |
| 797 | alt{ |
| 798 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_DISC(sapi, c_r:=cr_MT_CMD, p:=true))); |
| 799 | [] T1.timeout{ setverdict(fail, "Missing DISC from BTS")} |
| 800 | } |
| 801 | |
| 802 | /* a) the MS shall respond with a UA frame. |
| 803 | SAPI = 0, R = 0, F = 1, M = 0, L = 0. */ |
| 804 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_UA(sapi, c_r:=cr_MO_CMD, f:=true, l3:=l3_mo))); |
| 805 | |
| 806 | deactivate(d); |
| 807 | fp_common_fini(); |
| 808 | setverdict(pass); |
| 809 | } |
| 810 | |
| 811 | testcase TC_nr_seq_error() runs on test_CT { |
| 812 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 813 | f_testmatrix_each_chan(pars, refers(f_TC_nr_seq_error)); |
| 814 | } |
| 815 | |
| 816 | private function f_TC_rec_invalid_frame_txrx(integer sapi, LapdmFrame x) runs on ConnHdlr { |
| 817 | LAPDM.send(t_PH_DATA(0, false, x)); |
| 818 | f_sleep(2.0); // T200 |
| 819 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_RR(sapi, c_r:=cr_MO_CMD, p:=true, nr:=0))); |
| 820 | LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_RR(sapi, c_r:=cr_MT_RSP, p:=true , nr := 0))); |
| 821 | } |
| 822 | |
| 823 | /* 25.2.7 Test on receipt of invalid frames |
| 824 | sends a bunch of different invalid frames, expects the BTS to ignore all of them */ |
| 825 | private function f_TC_rec_invalid_frame(charstring id) runs on ConnHdlr { |
| 826 | const integer sapi := 0; |
| 827 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(sapi)); |
| 828 | var default d; |
| 829 | timer T := 3.0; |
| 830 | |
| 831 | fp_common_init(); |
| 832 | |
| 833 | /* some common altstep for meas res and other background noise */ |
| 834 | d := activate(as_ignore_background(ignore_rsl_errors := true)); |
| 835 | RSL.clear; |
| 836 | LAPDM.clear; |
| 837 | |
| 838 | var octetstring l3_mo := f_rnd_octstring(12); |
| 839 | var octetstring l3_mt := f_rnd_octstring(12); |
| 840 | |
| 841 | /* 1) The BTS is brought into the multiple frame established state */ |
| 842 | |
| 843 | /* MO Establish Request via LADPm: SAPI = 0, C = 0, P = 1, M = 0, 0 ≤ L ≤ N201.. */ |
| 844 | LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, p:=true, l3:=l3_mo))); |
| 845 | RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3_mo)); |
| 846 | /* UA: SAPI = 0, R = 0, F = 1, M = 0, L = L of SABM. */ |
| 847 | LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_UA(sapi, cr_MT_RSP, f:=true, l3:=l3_mo))); |
| 848 | |
| 849 | |
| 850 | /* 1: One RR frame: SAPI = 0, R = 0, F = 0, M = 0, L > 0, N(R) = 1. |
| 851 | RR frame with the Length indicator greater than zero and a faulty N(R); */ |
| 852 | var LapdmFrame x:= valueof(ts_LAPDm_RR(sapi, c_r:=cr_MO_CMD, p:=false, nr:=1)); |
| 853 | x.ab.payload := f_rnd_octstring(5); |
| 854 | f_TC_rec_invalid_frame_txrx(0, x); |
| 855 | /* 3: One REJ frame: SAPI = 0, R = 0, F = 0, M = 0, L = 0, N(R) = 1, EA = 0. |
| 856 | EJ frame with the EA bit set to zero and a faulty N(R); */ |
| 857 | x:= valueof(ts_LAPDm_REJ(sapi, c_r:=cr_MO_CMD, p:=false, nr:=1)); |
| 858 | x.ab.addr.ea := false; |
| 859 | f_TC_rec_invalid_frame_txrx(0, x); |
| 860 | /* 4: One SABM frame: SAPI = 0, C = 1, P = 1, M = 0, L = 0, EL = 0. |
| 861 | SABM frame with the EL bit set to zero; */ |
| 862 | l3_mo := ''O; |
| 863 | x:= valueof(ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, p:=true, l3:=l3_mo)); |
| 864 | x.ab.el := 0; |
| 865 | f_TC_rec_invalid_frame_txrx(0, x); |
| 866 | /* 5: One DM frame: SAPI = 0, R = 0, F = 1, M = 0, L > 0. |
| 867 | DM frame with the Length indicator greater than zero;*/ |
| 868 | x:= valueof(ts_LAPDm_DM(sapi, c_r:=cr_MO_CMD, f:=true)); |
| 869 | x.ab.payload := f_rnd_octstring(5); |
| 870 | f_TC_rec_invalid_frame_txrx(0, x); |
| 871 | /* 6: One DISC frame: SAPI = 0, C = 1, P = 1, M = 1, L = 0. |
| 872 | DISC frame with the M bit set to 1; */ |
| 873 | x:= valueof(ts_LAPDm_DISC(sapi, c_r:=cr_MO_CMD, p:=true)); |
| 874 | x.ab.m := true; |
| 875 | f_TC_rec_invalid_frame_txrx(0, x); |
| 876 | /* 7: One UA frame: SAPI = 0, R = 0, F = 0, M = 0, L = 0, EA = 0. |
| 877 | UA frame with the EA bit set to zero*/ |
| 878 | x:= valueof(ts_LAPDm_UA(sapi, c_r:=cr_MO_CMD, f:=false, l3:=''O)); |
| 879 | x.ab.addr.ea := false; |
| 880 | f_TC_rec_invalid_frame_txrx(0, x); |
| 881 | /* 8: One I frame: SAPI = 0, C = 1, P = 0, M = 0, L > N201, N(R) = 0, N(S) = 6. |
| 882 | I frame with the Length indicator greater than N201;*/ |
| 883 | x:= valueof(ts_LAPDm_I(sapi, c_r:=cr_MO_CMD, p:=true, nr := 0, ns := 6, l3 := f_rnd_octstring(25))) |
| 884 | f_TC_rec_invalid_frame_txrx(0, x); |
| 885 | /* 9: One I frame: SAPI = 0, C = 1, P = 0, M = 1, L < N201, N(R) = 0, N(S) = 7. |
| 886 | I frame with the M bit set to 1 and the Length indicator less than N201;*/ |
| 887 | x:= valueof(ts_LAPDm_I(sapi, c_r:=cr_MO_CMD, p:=true, nr := 0, ns := 7, l3 := f_rnd_octstring(5))) |
| 888 | x.ab.m := true; |
| 889 | f_TC_rec_invalid_frame_txrx(0, x); |
| 890 | /* 10: One RR frame: SAPI = 0, C = 1, P = 1, M = 0, L = 0, N(R) = 0. */ |
| 891 | x:= valueof(ts_LAPDm_RR(sapi, c_r:=cr_MO_CMD, p:=true, nr:=0)); |
| 892 | f_TC_rec_invalid_frame_txrx(0, x); |
| 893 | |
| 894 | /* command frames with correct Address and Length indicator field and a non-implemented control field */ |
| 895 | /* 12: One command frame with Control Field = xxx1 1101. */ |
| 896 | x:= valueof(ts_LAPDm_RR(sapi, c_r:=cr_MO_CMD, p:=false, nr:=1)); |
| 897 | x.ab.ctrl.other := bit2int('00011101'B); |
| 898 | f_TC_rec_invalid_frame_txrx(0, x); |
| 899 | /* 13: One command frame with Control field = xxx1 1011. */ |
| 900 | x:= valueof(ts_LAPDm_RR(sapi, c_r:=cr_MO_CMD, p:=false, nr:=1)); |
| 901 | x.ab.ctrl.other := bit2int('00011011'B); |
| 902 | f_TC_rec_invalid_frame_txrx(0, x); |
| 903 | /* 14: One command frame with Control field = xxx1 0111. */ |
| 904 | x:= valueof(ts_LAPDm_RR(sapi, c_r:=cr_MO_CMD, p:=false, nr:=1)); |
| 905 | x.ab.ctrl.other := bit2int('00010001'B); |
| 906 | f_TC_rec_invalid_frame_txrx(0, x); |
| 907 | /* 15: One command frame with Control field = 01x1 1111. */ |
| 908 | x:= valueof(ts_LAPDm_RR(sapi, c_r:=cr_MO_CMD, p:=false, nr:=1)); |
| 909 | x.ab.ctrl.other := bit2int('01011111'B); |
| 910 | f_TC_rec_invalid_frame_txrx(0, x); |
| 911 | /* 16: One command frame with Control field = 1xx1 1111. */ |
| 912 | x:= valueof(ts_LAPDm_RR(sapi, c_r:=cr_MO_CMD, p:=false, nr:=1)); |
| 913 | x.ab.ctrl.other := bit2int('10011111'B); |
| 914 | f_TC_rec_invalid_frame_txrx(0, x); |
| 915 | /* 17: One command frame with Control field = 0011 0011. */ |
| 916 | x:= valueof(ts_LAPDm_RR(sapi, c_r:=cr_MO_CMD, p:=false, nr:=1)); |
| 917 | x.ab.ctrl.other := bit2int('00110011'B); |
| 918 | f_TC_rec_invalid_frame_txrx(0, x); |
| 919 | /* 18: One command frame with Control field = 1xx1 0011. */ |
| 920 | x:= valueof(ts_LAPDm_RR(sapi, c_r:=cr_MO_CMD, p:=false, nr:=1)); |
| 921 | x.ab.ctrl.other := bit2int('10010011'B); |
| 922 | f_TC_rec_invalid_frame_txrx(0, x); |
| 923 | |
| 924 | deactivate(d); |
| 925 | fp_common_fini(); |
| 926 | setverdict(pass); |
| 927 | } |
| 928 | |
| 929 | testcase TC_rec_invalid_frame() runs on test_CT { |
| 930 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 931 | pars.t_guard := 60.0; |
| 932 | f_testmatrix_each_chan(pars, refers(f_TC_rec_invalid_frame)); |
| 933 | } |
| 934 | |
Harald Welte | 9ea918c | 2019-06-01 11:46:25 +0200 | [diff] [blame] | 935 | type record LapdmDlConfig { |
| 936 | integer n201, |
| 937 | integer t200 |
| 938 | }; |
| 939 | |
| 940 | type record LapdmDlState { |
| 941 | integer v_s, |
| 942 | integer v_a, |
| 943 | integer v_r |
| 944 | }; |
| 945 | |
| 946 | template (value) LapdmDlState t_init_LapdmDlState := { |
| 947 | v_s := 0, |
| 948 | v_a := 0, |
| 949 | v_r := 0 |
| 950 | } |
| 951 | |
| 952 | private function inc_mod8(inout integer v) |
| 953 | { |
| 954 | v := (v + 1) mod 8; |
| 955 | } |
| 956 | |
| 957 | private function f_lapdm_transceive_mo(inout LapdmDlState dls, RslLinkId link_id, octetstring l3) |
| 958 | runs on ConnHdlr { |
| 959 | var LAPDm_ph_data pd; |
| 960 | var integer offset := 0; |
| 961 | var integer n201 := 20; |
| 962 | var boolean is_sacch := false; |
| 963 | if (link_id.c == SACCH) { |
| 964 | n201 := 18; |
| 965 | is_sacch := true; |
| 966 | } |
| 967 | |
| 968 | while (offset < lengthof(l3)) { |
| 969 | var integer remain_len := lengthof(l3) - offset; |
| 970 | var integer seg_len := remain_len; |
| 971 | if (remain_len > n201) { |
| 972 | seg_len := n201; |
| 973 | } |
| 974 | var octetstring segment := substr(l3, offset, seg_len); |
| 975 | var boolean more; |
| 976 | if (offset + lengthof(segment) < lengthof(l3)) { |
| 977 | more := true; |
| 978 | } else { |
| 979 | more := false; |
| 980 | } |
| 981 | /* send the next segment */ |
| 982 | LAPDM.send(t_PH_DATA(0, is_sacch, |
| 983 | ts_LAPDm_I(link_id.sapi, c_r:=cr_MO_CMD, p:=false, |
| 984 | nr:=dls.v_a, ns:=dls.v_s, l3:=segment, m:=more))); |
| 985 | inc_mod8(dls.v_s); |
| 986 | offset := offset + lengthof(segment); |
| 987 | |
| 988 | /* wait for it to be acknowledged */ |
| 989 | alt { |
| 990 | [] LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_RR(link_id.sapi, c_r:=cr_MT_RSP, |
| 991 | p:=false, nr:=(dls.v_s) mod 8))); |
Harald Welte | ef6fd44 | 2019-06-01 21:41:29 +0200 | [diff] [blame] | 992 | [] as_ignore_background(not is_sacch); |
Harald Welte | 9ea918c | 2019-06-01 11:46:25 +0200 | [diff] [blame] | 993 | [] LAPDM.receive(t_PH_DATA(0, is_sacch, ?)) -> value pd { |
| 994 | setverdict(fail, "received unexpected LAPDm ", pd); |
| 995 | repeat; |
| 996 | } |
| 997 | [] LAPDM.receive(t_PH_DATA(0, ?, ?)) { repeat; } |
| 998 | [offset < lengthof(l3)] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, ?)) { |
| 999 | setverdict(fail, "received RSL DATA IND before message complete"); |
| 1000 | } |
| 1001 | } |
| 1002 | } |
| 1003 | |
| 1004 | timer T := 1.0; |
| 1005 | T.start; |
| 1006 | alt { |
| 1007 | [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) { |
| 1008 | setverdict(pass); |
| 1009 | } |
| 1010 | [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, ?)) { |
| 1011 | setverdict(fail, "Received RSL DATA IND with wrong payload"); |
| 1012 | } |
| 1013 | [] T.timeout { |
| 1014 | setverdict(fail, "Timeout waiting for RSL DATA IND of de-segmented message"); |
| 1015 | } |
| 1016 | } |
| 1017 | } |
| 1018 | |
| 1019 | /* Section 5.8.5 of TS 04.06 */ |
| 1020 | const integer c_TS0406_MAX_L3_OCTETS := 251; |
| 1021 | |
Harald Welte | ef6fd44 | 2019-06-01 21:41:29 +0200 | [diff] [blame] | 1022 | /* test segmentation and de-segmentation (concatenation) of a large message in uplink |
| 1023 | * on specified SAPI/channel */ |
| 1024 | private function f_TC_segm_concat(charstring id, RslLinkId link_id) runs on ConnHdlr { |
| 1025 | var integer sapi := link_id.sapi; |
| 1026 | var boolean is_sacch := false; |
| 1027 | if (link_id.c == SACCH) { |
| 1028 | is_sacch := true; |
| 1029 | } |
Harald Welte | 9ea918c | 2019-06-01 11:46:25 +0200 | [diff] [blame] | 1030 | var default d; |
| 1031 | timer T := 3.0; |
| 1032 | |
| 1033 | fp_common_init(); |
| 1034 | |
| 1035 | /* some common altstep for meas res and other background noise */ |
Harald Welte | ef6fd44 | 2019-06-01 21:41:29 +0200 | [diff] [blame] | 1036 | d := activate(as_ignore_background(not is_sacch)); |
Harald Welte | 9ea918c | 2019-06-01 11:46:25 +0200 | [diff] [blame] | 1037 | RSL.clear; |
| 1038 | LAPDM.clear; |
| 1039 | |
Harald Welte | 76771f1 | 2019-06-02 22:58:58 +0200 | [diff] [blame] | 1040 | f_establish_mo(link_id); |
Harald Welte | 9ea918c | 2019-06-01 11:46:25 +0200 | [diff] [blame] | 1041 | |
Harald Welte | 76771f1 | 2019-06-02 22:58:58 +0200 | [diff] [blame] | 1042 | var octetstring l3_mo := f_rnd_octstring(c_TS0406_MAX_L3_OCTETS); |
Harald Welte | 9ea918c | 2019-06-01 11:46:25 +0200 | [diff] [blame] | 1043 | |
| 1044 | deactivate(d); |
| 1045 | |
| 1046 | var LapdmDlState dls := valueof(t_init_LapdmDlState); |
| 1047 | f_lapdm_transceive_mo(dls, link_id, l3_mo); |
| 1048 | |
| 1049 | fp_common_fini(); |
| 1050 | } |
Harald Welte | ef6fd44 | 2019-06-01 21:41:29 +0200 | [diff] [blame] | 1051 | private function f_TC_segm_concat_dcch(charstring id) runs on ConnHdlr { |
| 1052 | f_TC_segm_concat(id, valueof(ts_RslLinkID_DCCH(0))); |
Harald Welte | 9ea918c | 2019-06-01 11:46:25 +0200 | [diff] [blame] | 1053 | } |
Harald Welte | ef6fd44 | 2019-06-01 21:41:29 +0200 | [diff] [blame] | 1054 | private function f_TC_segm_concat_sacch(charstring id) runs on ConnHdlr { |
| 1055 | f_TC_segm_concat(id, link_id :=valueof(ts_RslLinkID_SACCH(0))); |
| 1056 | } |
| 1057 | /* test mobile-originated segmentation/de-segmentation on DCCH */ |
| 1058 | testcase TC_segm_concat_dcch() runs on test_CT { |
| 1059 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 1060 | f_testmatrix_each_chan(pars, refers(f_TC_segm_concat_dcch)); |
| 1061 | } |
| 1062 | /* test mobile-originated segmentation/de-segmentation on SACCH */ |
| 1063 | testcase TC_segm_concat_sacch() runs on test_CT { |
| 1064 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 1065 | f_testmatrix_each_chan(pars, refers(f_TC_segm_concat_sacch)); |
| 1066 | } |
| 1067 | |
Harald Welte | b2a3034 | 2019-06-02 22:13:50 +0200 | [diff] [blame] | 1068 | /* TS 04.06 Section 5.8.2.1 */ |
| 1069 | private function f_n200_by_chan_nr(RslChannelNr chan_nr, RslLinkId link_id) return integer { |
| 1070 | /* SACCH irrespective of physical channel type */ |
| 1071 | if (match(link_id, tr_RslLinkID_SACCH(?))) { |
| 1072 | return 5; |
| 1073 | } |
| 1074 | /* DCCH below */ |
| 1075 | select (chan_nr) { |
| 1076 | case (t_RslChanNr_SDCCH4(?, ?)) { return 23; } |
| 1077 | case (t_RslChanNr_SDCCH8(?, ?)) { return 23; } |
| 1078 | case (t_RslChanNr_Bm(?)) { return 34; } |
| 1079 | case (t_RslChanNr_Lm(?, ?)) { return 29; } |
| 1080 | } |
| 1081 | setverdict(fail, "Unknown chan_nr ", chan_nr, " or link_id ", link_id); |
| 1082 | return -1; |
| 1083 | } |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 1084 | |
Harald Welte | b2a3034 | 2019-06-02 22:13:50 +0200 | [diff] [blame] | 1085 | /* Test if there are exactly N200+1 transmissions of I frames; inspired by 25.2.4.1 */ |
| 1086 | private function f_TC_t200_n200(charstring id) runs on ConnHdlr { |
| 1087 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 1088 | var integer sapi := link_id.sapi; |
| 1089 | var boolean is_sacch := false; |
| 1090 | if (link_id.c == SACCH) { |
| 1091 | is_sacch := true; |
| 1092 | } |
| 1093 | var integer n200 := f_n200_by_chan_nr(g_chan_nr, link_id); |
| 1094 | var integer num_retrans := 0; |
| 1095 | timer T := 3.0; |
| 1096 | var default d; |
| 1097 | |
| 1098 | fp_common_init(); |
| 1099 | |
| 1100 | /* some common altstep for meas res and other background noise */ |
| 1101 | d := activate(as_ignore_background(true)); |
| 1102 | RSL.clear; |
| 1103 | LAPDM.clear; |
| 1104 | |
Harald Welte | 76771f1 | 2019-06-02 22:58:58 +0200 | [diff] [blame] | 1105 | f_establish_mo(link_id); |
Harald Welte | b2a3034 | 2019-06-02 22:13:50 +0200 | [diff] [blame] | 1106 | |
| 1107 | var octetstring l3_mt := f_rnd_octstring(20); |
| 1108 | RSL.send(ts_RSL_DATA_REQ(g_chan_nr, link_id, l3_mt)); |
| 1109 | /* first transmission, P = 0 */ |
| 1110 | LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_I(sapi, c_r:=cr_MT_CMD, p:=false, |
| 1111 | nr:=0, ns:=0, l3:=l3_mt))); |
| 1112 | deactivate(d); |
| 1113 | |
| 1114 | alt { |
| 1115 | /* re-transmission, P = 1 */ |
| 1116 | [] LAPDM.receive(t_PH_DATA(0, is_sacch, |
| 1117 | tr_LAPDm_I(sapi, c_r:=cr_MT_CMD, p:=true, nr:=0, ns:=0, l3:=l3_mt))) { |
| 1118 | num_retrans := num_retrans + 1; |
| 1119 | if (num_retrans < n200) { |
| 1120 | repeat; |
| 1121 | } else if (num_retrans == n200) { |
| 1122 | T.start; /* wait for some more time if there are more retransmissions */ |
| 1123 | repeat; |
| 1124 | } else { |
| 1125 | /* break */ |
| 1126 | } |
| 1127 | } |
| 1128 | [] LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_I(sapi, ?, ?, ?, ?, ?))) { |
| 1129 | setverdict(fail, "Received unexpected I frame"); |
| 1130 | } |
| 1131 | [not is_sacch] as_lapdm_acch(); |
| 1132 | [is_sacch] as_lapdm_dcch(); |
| 1133 | [] as_lapdm_idle(); |
| 1134 | [] as_rsl_meas_rep(); |
| 1135 | [num_retrans == n200] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, '01'O)) { |
| 1136 | /* break */ |
| 1137 | } |
| 1138 | [] T.timeout { |
| 1139 | setverdict(fail, "Missing RSL RLL ERROR INDICATION"); |
| 1140 | } |
| 1141 | } |
| 1142 | |
| 1143 | if (num_retrans == n200) { |
| 1144 | setverdict(pass, "Received ", num_retrans, " on channel ", g_chan_nr, " link ", link_id); |
| 1145 | } else if (num_retrans < n200) { |
| 1146 | setverdict(fail, "Too few retransmissions (", num_retrans, "); N200=", n200, |
| 1147 | " on channel ", g_chan_nr, " link ", link_id); |
| 1148 | } |
| 1149 | |
| 1150 | fp_common_fini(); |
| 1151 | } |
| 1152 | testcase TC_t200_n200() runs on test_CT { |
| 1153 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 1154 | f_testmatrix_each_chan(pars, refers(f_TC_t200_n200)); |
| 1155 | } |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 1156 | |
Harald Welte | 7d9f6db | 2019-06-02 23:14:04 +0200 | [diff] [blame] | 1157 | /* Ensure BTS repeats RR frame after retransmitting I frame to emulate RR loss; |
| 1158 | Inspired by TS 51.010-1 25.2.4.3 */ |
| 1159 | private function f_TC_rr_response_frame_loss(charstring id) runs on ConnHdlr { |
| 1160 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 1161 | var integer sapi := link_id.sapi; |
| 1162 | var boolean is_sacch := false; |
| 1163 | if (link_id.c == SACCH) { |
| 1164 | is_sacch := true; |
| 1165 | } |
| 1166 | timer T := 3.0; |
| 1167 | var default d; |
| 1168 | |
| 1169 | fp_common_init(); |
| 1170 | |
| 1171 | /* some common altstep for meas res and other background noise */ |
| 1172 | d := activate(as_ignore_background(true)); |
| 1173 | RSL.clear; |
| 1174 | LAPDM.clear; |
| 1175 | |
| 1176 | f_establish_mo(link_id); |
| 1177 | |
| 1178 | var octetstring l3_mo := f_rnd_octstring(10); |
| 1179 | /* Send an I frame to the BTS: SAPI = 0, C = 1, P = 0, M = 0, L = 3, N(S) = 0, N(R) = 0 */ |
| 1180 | LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_I(sapi, c_r:=cr_MO_CMD, p:=false, nr:=0, ns:=0, |
| 1181 | l3:=l3_mo))); |
| 1182 | RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3_mo)); |
| 1183 | /* SAPI = 0, R = 1, F = 0, M = 0, L = 0, N(R) = 1. */ |
| 1184 | LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_RR(sapi, c_r:=cr_MT_RSP, p:=false, nr:=1))); |
| 1185 | |
| 1186 | /* Re-send I frame: SAPI = 0, C = 1, P = 1, M = 0, L = 3, N(S) = 0, N(R) = 0. */ |
| 1187 | LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_I(sapi, c_r:=cr_MO_CMD, p:=true, nr:=0, ns:=0, |
| 1188 | l3:=l3_mo))); |
| 1189 | |
| 1190 | T.start; |
| 1191 | alt { |
| 1192 | /* RR: SAPI = 0, R = 1, F = 1, M = 0, L = 0, N(R) = 1. */ |
| 1193 | [] LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_RR(sapi, c_r:=cr_MT_RSP, p:=true, nr:=1))) { |
| 1194 | setverdict(pass); |
| 1195 | } |
| 1196 | /* REJ: SAPI = 0, R = 1, F = 1, M = 0, L = 0, N(R) = 1. */ |
| 1197 | [] LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_REJ(sapi, c_r:=cr_MT_RSP, p:=true, nr:=1))) { |
| 1198 | setverdict(pass); |
| 1199 | } |
| 1200 | [] T.timeout { |
| 1201 | setverdict(fail, "Timeout waiting for RR or REJ"); |
| 1202 | } |
| 1203 | } |
| 1204 | |
| 1205 | deactivate(d); |
| 1206 | |
| 1207 | fp_common_fini(); |
| 1208 | } |
| 1209 | testcase TC_rr_response_frame_loss() runs on test_CT { |
| 1210 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 1211 | f_testmatrix_each_chan(pars, refers(f_TC_rr_response_frame_loss)); |
| 1212 | } |
| 1213 | |
Harald Welte | 4447978 | 2019-06-02 23:23:45 +0200 | [diff] [blame] | 1214 | /* Ensure BTS ignores I frames with wrong C/R bit; Inspired by TS 51.010-1 25.2.5.1 */ |
| 1215 | private function f_TC_incorrect_cr(charstring id) runs on ConnHdlr { |
| 1216 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 1217 | var integer sapi := link_id.sapi; |
| 1218 | var boolean is_sacch := false; |
| 1219 | if (link_id.c == SACCH) { |
| 1220 | is_sacch := true; |
| 1221 | } |
| 1222 | timer T := 3.0; |
| 1223 | var default d; |
| 1224 | |
| 1225 | fp_common_init(); |
| 1226 | |
| 1227 | /* some common altstep for meas res and other background noise */ |
| 1228 | d := activate(as_ignore_background(true)); |
| 1229 | RSL.clear; |
| 1230 | LAPDM.clear; |
| 1231 | |
| 1232 | f_establish_mo(link_id); |
| 1233 | |
| 1234 | var octetstring l3_mo := f_rnd_octstring(10); |
| 1235 | /* Send an I frame to the BTS: SAPI = 0, C = 0, P = 1, M = 0, L = 3, N(S) = 0, N(R) = 0 */ |
| 1236 | LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_I(sapi, c_r:=cr_MO_RSP, p:=true, nr:=0, ns:=0, |
| 1237 | l3:=l3_mo))); |
| 1238 | T.start; |
| 1239 | alt { |
| 1240 | [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3_mo)) { |
| 1241 | setverdict(fail, "BTS didn't ignore I frame with wrong C/R bit"); |
| 1242 | } |
| 1243 | [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, '0C'O)) { |
| 1244 | repeat; |
| 1245 | } |
| 1246 | /* ensure BTS still sends idle frames */ |
| 1247 | [] as_lapdm_idle() { |
| 1248 | setverdict(pass, "still sending idle frames"); |
| 1249 | } |
| 1250 | [] T.timeout {} |
| 1251 | } |
| 1252 | |
| 1253 | /* Send RR command P=1 */ |
| 1254 | LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_RR(sapi, c_r:=cr_MO_CMD, p:=true, nr:=0))); |
| 1255 | |
| 1256 | /* The BTS shall respond with a RR response, F bit set to 1. */ |
| 1257 | LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_RR(sapi, c_r:=cr_MT_RSP, p:=true, nr:=0))); |
| 1258 | |
| 1259 | deactivate(d); |
| 1260 | |
| 1261 | fp_common_fini(); |
| 1262 | } |
| 1263 | testcase TC_incorrect_cr() runs on test_CT { |
| 1264 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 1265 | f_testmatrix_each_chan(pars, refers(f_TC_incorrect_cr)); |
| 1266 | } |
Harald Welte | a39ac75 | 2019-06-04 21:46:07 +0200 | [diff] [blame] | 1267 | |
| 1268 | /* test that the BTS will take no action when it receives an SABM frame with the C bit set wrong (R) |
| 1269 | Inspired by TS 51.010-1 25.2.5.2 */ |
| 1270 | private function f_TC_sabm_incorrect_c(charstring id) runs on ConnHdlr { |
| 1271 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 1272 | var integer sapi := link_id.sapi; |
| 1273 | var boolean is_sacch := false; |
| 1274 | if (link_id.c == SACCH) { |
| 1275 | is_sacch := true; |
| 1276 | } |
| 1277 | timer T := 3.0; |
| 1278 | var default d; |
| 1279 | |
| 1280 | fp_common_init(); |
| 1281 | |
| 1282 | /* some common altstep for meas res and other background noise */ |
| 1283 | d := activate(as_ignore_background(true)); |
| 1284 | RSL.clear; |
| 1285 | LAPDM.clear; |
| 1286 | |
| 1287 | f_establish_mo(link_id); |
| 1288 | |
| 1289 | /* Send I-frame SAPI = 0, C = 1, P = 0, M = 0, L = 3, N(S) = 0, N(R) = 0 */ |
| 1290 | var octetstring l3_mo := '010203'O; |
| 1291 | LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_I(sapi, c_r:=cr_MO_CMD, p:=false, nr:=0, ns:=0, |
| 1292 | l3:=l3_mo))); |
| 1293 | /* Expect RR SAPI = 0, R = 1, F = 0, M = 0, L = 0, N(R) = 1 */ |
| 1294 | LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_RR(sapi, c_r:=cr_MT_RSP, p:=false, nr:=1))); |
| 1295 | RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3_mo)); |
| 1296 | /* Send SABM SAPI = 0, C = 0, P = 1, M = 0, L = 0 */ |
| 1297 | LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_SABM(sapi, c_r:=cr_MO_RSP, p:=true, l3:=''O))); |
| 1298 | /* Expect RSL ERR IND */ |
| 1299 | RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, '0C'O)); |
| 1300 | /* Expect fill frame C = 0, P = 0, M = 0, L = 0 */ |
| 1301 | LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_UI(0, ?, ''O))); |
| 1302 | /* Send RR command (P=1) SAPI = 0, C = 1, P = 1, M = 0, L = 0, N(R) = 0 */ |
| 1303 | LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_RR(sapi, c_r:=cr_MO_CMD, p:=true, nr:=0))); |
| 1304 | /* Expect RR response (F=1) SAPI = 0, R = 1, F = 1, M = 0, L = 0, N(R) = 1 */ |
| 1305 | LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_RR(sapi, c_r:=cr_MT_RSP, p:=true, nr:=1))); |
| 1306 | |
| 1307 | deactivate(d); |
| 1308 | |
| 1309 | fp_common_fini(); |
| 1310 | } |
| 1311 | testcase TC_sabm_incorrect_c() runs on test_CT { |
| 1312 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 1313 | f_testmatrix_each_chan(pars, refers(f_TC_sabm_incorrect_c)); |
| 1314 | } |
| 1315 | |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 1316 | control { |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 1317 | execute(TC_sabm_ua_dcch_sapi0()); |
| 1318 | execute(TC_sabm_ua_dcch_sapi0_nopayload()); |
| 1319 | execute(TC_sabm_ua_dcch_sapi3()); |
| 1320 | execute(TC_sabm_ua_dcch_sapi4()); |
| 1321 | execute(TC_sabm_contention()); |
| 1322 | execute(TC_sabm_retransmit()); |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 1323 | execute(TC_sabm_retransmit_bts()); |
| 1324 | execute(TC_sabm_invalid_resp()); |
| 1325 | execute(TC_sabm_dm()); |
| 1326 | execute(TC_establish_ign_first_sabm()); |
| 1327 | execute(TC_iframe_seq_and_ack()); |
| 1328 | execute(TC_iframe_timer_recovery()); |
Eric Wild | 211acc3 | 2019-06-11 19:06:38 +0200 | [diff] [blame] | 1329 | execute(TC_ns_seq_error()); |
| 1330 | execute(TC_nr_seq_error()); |
| 1331 | execute(TC_rec_invalid_frame()); |
Harald Welte | ef6fd44 | 2019-06-01 21:41:29 +0200 | [diff] [blame] | 1332 | execute(TC_segm_concat_dcch()); |
| 1333 | execute(TC_segm_concat_sacch()); |
Harald Welte | b2a3034 | 2019-06-02 22:13:50 +0200 | [diff] [blame] | 1334 | execute(TC_t200_n200()); |
Harald Welte | 7d9f6db | 2019-06-02 23:14:04 +0200 | [diff] [blame] | 1335 | execute(TC_rr_response_frame_loss()); |
Harald Welte | 4447978 | 2019-06-02 23:23:45 +0200 | [diff] [blame] | 1336 | execute(TC_incorrect_cr()); |
Harald Welte | a39ac75 | 2019-06-04 21:46:07 +0200 | [diff] [blame] | 1337 | execute(TC_sabm_incorrect_c()); |
Harald Welte | 72c81e7 | 2019-05-30 16:36:11 +0200 | [diff] [blame] | 1338 | } |
| 1339 | |
Harald Welte | f654332 | 2017-07-16 07:35:10 +0200 | [diff] [blame] | 1340 | } |