Harald Welte | a0895f9 | 2018-03-08 11:51:23 +0100 | [diff] [blame] | 1 | module PCU_Tests { |
Harald Welte | 3a19440 | 2017-07-22 17:07:51 +0200 | [diff] [blame] | 2 | |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 3 | /* Osmocom PCU test suite in TTCN-3 |
| 4 | * (C) 2018-2019 Harald Welte <laforge@gnumonks.org> |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Released under the terms of GNU General Public License, Version 2 or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 11 | */ |
| 12 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 13 | import from General_Types all; |
| 14 | import from Osmocom_Types all; |
| 15 | import from GSM_Types all; |
| 16 | import from GSM_RR_Types all; |
| 17 | import from Osmocom_Gb_Types all; |
| 18 | import from BSSGP_Types all; |
| 19 | import from BSSGP_Emulation all; |
| 20 | import from NS_Types all; |
| 21 | import from NS_Emulation all; |
| 22 | import from LLC_Types all; |
| 23 | import from LLC_Templates all; |
| 24 | import from RLCMAC_Types all; |
| 25 | import from RLCMAC_CSN1_Types all; |
| 26 | import from LAPDm_RAW_PT all; |
| 27 | import from GPRS_Context all; |
| 28 | import from GPRS_TBF all; |
| 29 | import from L1CTL_PortType all; |
| 30 | import from MobileL3_Types all; |
| 31 | import from MobileL3_CommonIE_Types all; |
| 32 | import from L3_Templates all; |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 33 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 34 | modulepar { |
| 35 | BssgpConfig mp_gb_cfg := { |
| 36 | nsei := 1234, |
| 37 | bvci := 1234, |
| 38 | cell_id := { |
| 39 | ra_id := { |
| 40 | lai := { |
Harald Welte | 797ab3a | 2019-03-21 21:33:28 +0100 | [diff] [blame] | 41 | mcc_mnc := '262F42'H, lac := 13135 |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 42 | }, |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 43 | rac := 0 |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 44 | }, |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 45 | cell_id := 20960 |
| 46 | }, |
Oliver Smith | aac9b9c | 2019-09-02 08:36:36 +0200 | [diff] [blame] | 47 | sgsn_role := true, |
| 48 | depth := BSSGP_DECODE_DEPTH_BSSGP |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 49 | }; |
Alexander Couzens | 2c12b24 | 2018-07-31 00:30:11 +0200 | [diff] [blame] | 50 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 51 | NSConfiguration mp_nsconfig := { |
| 52 | local_udp_port := 23000, |
| 53 | local_ip := "127.0.0.1", |
| 54 | remote_udp_port := 21000, |
| 55 | remote_ip := "127.0.0.1", |
| 56 | nsvci := 0, |
| 57 | nsei := 2342, |
| 58 | role_sgsn := true, |
| 59 | handle_sns := true |
| 60 | }; |
| 61 | } |
| 62 | |
| 63 | type component dummy_CT extends BSSGP_Client_CT { |
| 64 | var lapdm_CT lapdm_component; |
| 65 | port LAPDm_PT L1; |
| 66 | |
| 67 | var NS_CT ns_component; |
| 68 | var BSSGP_CT bssgp_component; |
| 69 | |
| 70 | var MmContext g_mmctx := { |
| 71 | tlli := 'FFFFFFFF'O, |
| 72 | n_u := 0 |
| 73 | }; |
| 74 | |
| 75 | var boolean g_initialized := false; |
| 76 | } |
| 77 | |
| 78 | function f_init() runs on dummy_CT { |
| 79 | if (g_initialized == true) { |
| 80 | return; |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 81 | } |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 82 | g_initialized := true; |
| 83 | /* create a new NS component */ |
| 84 | ns_component := NS_CT.create; |
| 85 | bssgp_component := BSSGP_CT.create; |
| 86 | /* connect our BSSGP port to the BSSGP Emulation */ |
| 87 | connect(self:BSSGP[0], bssgp_component:BSSGP_SP); |
| 88 | connect(self:BSSGP_SIG[0], bssgp_component:BSSGP_SP_SIG); |
| 89 | connect(self:BSSGP_PROC[0], bssgp_component:BSSGP_PROC); |
| 90 | /* connect lower-end of BSSGP with BSSGP_CODEC_PORT (maps to NS_PT*/ |
| 91 | connect(bssgp_component:BSCP, ns_component:NS_SP); |
| 92 | /* connect lower-end of NS emulation to NS_CODEC_PORT (on top of IPl4) */ |
| 93 | map(ns_component:NSCP, system:NS_CODEC_PORT); |
| 94 | ns_component.start(NSStart(mp_nsconfig)); |
| 95 | bssgp_component.start(BssgpStart(mp_gb_cfg)); |
Harald Welte | 5ac3149 | 2018-02-15 20:39:13 +0100 | [diff] [blame] | 96 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 97 | lapdm_component := lapdm_CT.create; |
| 98 | connect(self:L1, lapdm_component:LAPDM_SP); |
| 99 | map(lapdm_component:L1CTL, system:L1CTL); |
| 100 | lapdm_component.start(LAPDmStart()); |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 101 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 102 | f_bssgp_client_register(g_mmctx.imsi, g_mmctx.tlli, mp_gb_cfg.cell_id); |
| 103 | f_bssgp_establish(); |
| 104 | } |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 105 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 106 | function f_exit() runs on dummy_CT { |
| 107 | lapdm_component.stop; |
| 108 | ns_component.stop; |
| 109 | bssgp_component.stop; |
| 110 | } |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 111 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 112 | function f_bssgp_dec_and_log(in octetstring inp) { |
| 113 | log("BSSGP Input: ", inp); |
| 114 | var PDU_BSSGP dec := dec_PDU_BSSGP(inp); |
| 115 | log("BSSGP Decoded: ", dec); |
| 116 | } |
| 117 | |
| 118 | testcase TC_selftest_bssgp() runs on dummy_CT { |
| 119 | const octetstring c_bvc_reset_pcu := '2204820000078108088832f44000c80051e0'O; |
| 120 | const octetstring c_bvc_reset_q := '2204820000078100'O; |
| 121 | const octetstring c_status_pcu := '4107810515882204820000078103'O; |
| 122 | const octetstring c_reset_ack_q := '2304820000'O; |
| 123 | const octetstring c_reset_ack_pcu := '23048200c4'O; |
| 124 | const octetstring c_unblock_pcu := '24048200c4'O; |
| 125 | const octetstring c_unblock_ack_q := '25048200c4'O; |
| 126 | const octetstring c_fc_bvc_pcu := '261e8101058200fa038200c8018200fa1c8200c806820000'O; |
| 127 | const octetstring c_fc_bvc_ack_q := '271e8101'O; |
| 128 | const octetstring c_gmm_mo_att_req := '01bb146ddd000004088832f44000c80051e000800e003b01c001080103e5e000110a0005f4fb146ddd32f44000c8001d1b53432b37159ef9090070000dd9c6321200e00019b32c642401c0002017057bf0ec'O; |
| 129 | const octetstring c_gmm_mt_ac_req := '00bb146ddd0050001682ffff0a8204030e9c41c001081200102198c72477ea104895e8b959acc58b108182f4d045'O; |
| 130 | const octetstring c_gmm_mo_ac_resp := '01bb146ddd000004088832f44000c80051e000800e000e01c00508130122fa361f5fdd623d'O; |
| 131 | const octetstring c_gmm_mt_att_acc := '00bb146ddd0050001682ffff0a8204030e9841c005080201340432f44000c8001805f4fb146ddd0967d0'O; |
| 132 | const octetstring c_gmm_mt_det_req := '00bb146ddd0050001682ffff0a8204030e8941c00908050215f0b6'O; |
| 133 | const octetstring c_gmm_mo_att_cpl := '01fb146ddd000004088832f44000c80051e000800e000801c009080339d7bc'O; |
| 134 | |
| 135 | f_bssgp_dec_and_log(c_bvc_reset_pcu); |
| 136 | f_bssgp_dec_and_log(c_bvc_reset_q); |
| 137 | f_bssgp_dec_and_log(c_status_pcu); |
| 138 | f_bssgp_dec_and_log(c_reset_ack_q); |
| 139 | f_bssgp_dec_and_log(c_reset_ack_pcu); |
| 140 | f_bssgp_dec_and_log(c_unblock_pcu); |
| 141 | f_bssgp_dec_and_log(c_unblock_ack_q); |
| 142 | f_bssgp_dec_and_log(c_fc_bvc_pcu); |
| 143 | f_bssgp_dec_and_log(c_fc_bvc_ack_q); |
| 144 | f_bssgp_dec_and_log(c_gmm_mo_att_req); |
| 145 | f_bssgp_dec_and_log(c_gmm_mt_ac_req); |
| 146 | f_bssgp_dec_and_log(c_gmm_mo_ac_resp); |
| 147 | f_bssgp_dec_and_log(c_gmm_mt_att_acc); |
| 148 | f_bssgp_dec_and_log(c_gmm_mt_det_req); |
| 149 | f_bssgp_dec_and_log(c_gmm_mo_att_cpl); |
| 150 | |
| 151 | log(ts_BSSGP_PS_PAGING_IMSI(196, '262420123456789'H)); |
| 152 | } |
| 153 | |
| 154 | function f_ns_assert_prepr(in octetstring a, in octetstring b) { |
| 155 | log("NS Input: ", a); |
| 156 | log("NS Expected: ", b); |
| 157 | |
| 158 | if (a != b) { |
| 159 | setverdict(fail, "Values mismatch", a, b); |
| 160 | mtc.stop; |
| 161 | } else { |
| 162 | setverdict(pass); |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 163 | } |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 164 | } |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 165 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 166 | function f_ns_dec_and_log(in octetstring inp) { |
| 167 | log("NS Input: ", inp); |
| 168 | var PDU_NS dec := dec_PDU_NS(inp); |
| 169 | log("NS Decoded: ", dec); |
| 170 | } |
| 171 | |
| 172 | testcase TC_selftest_ns() runs on dummy_CT { |
| 173 | const octetstring c_ns_reset_pcu := '000000c4271e813d'O; |
| 174 | |
| 175 | /* single byte length to two byte length */ |
| 176 | f_ns_assert_prepr('04058101'O, '0405000101'O); |
| 177 | f_ns_assert_prepr('040589000102030405060708'O, '04050009000102030405060708'O); |
| 178 | /* two byte length to two byte length */ |
| 179 | f_ns_assert_prepr('0405000101'O, '0405000101'O); |
| 180 | /* special case: NS-UNITDATA */ |
| 181 | f_ns_assert_prepr('00aabbccddeeffaa29822342'O, '00aabbccddeeffaa2900022342'O); |
| 182 | /* multiple TLVs */ |
| 183 | f_ns_assert_prepr('234281aa4382bbbb'O, '23420001aa430002bbbb'O); |
| 184 | /* zero-length */ |
| 185 | f_ns_assert_prepr('230080'O, '23000000'O); |
| 186 | |
| 187 | f_ns_dec_and_log(c_ns_reset_pcu); |
| 188 | } |
| 189 | |
| 190 | const octetstring gmm_auth_req := '081200102198c72477ea104895e8b959acc58b108182'O; |
| 191 | |
| 192 | /* Wrap downlink GMM into LLC, encode + send it via BSSGP to PCU */ |
| 193 | function tx_gmm(BIT1 c_r, in octetstring gmm_pdu, BIT4 sapi := c_LLC_SAPI_LLGMM) runs on dummy_CT { |
| 194 | var PDU_LLC llc; |
| 195 | |
| 196 | //log("GMM Tx: ", dec_PDU_L3_SGSN_MS(gmm_pdu)); |
| 197 | |
| 198 | log(c_r, g_mmctx.n_u, gmm_pdu, sapi); |
| 199 | llc := valueof(ts_LLC_UI(gmm_pdu, sapi, c_r, g_mmctx.n_u)); |
| 200 | log(llc); |
| 201 | g_mmctx.n_u := g_mmctx.n_u + 1; |
| 202 | |
| 203 | log(ts_BSSGP_DL_UD(g_mmctx.tlli, enc_PDU_LLC(llc))); |
| 204 | |
| 205 | BSSGP[0].send(ts_BSSGP_DL_UD(g_mmctx.tlli, enc_PDU_LLC(llc))); |
| 206 | } |
| 207 | |
| 208 | /* Establish BSSGP connection to PCU */ |
Harald Welte | 3d1fd5f | 2019-03-21 22:12:00 +0100 | [diff] [blame] | 209 | function f_bssgp_establish() runs on BSSGP_Client_CT { |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 210 | timer T:= 10.0; |
| 211 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 212 | T.start |
| 213 | alt { |
| 214 | [] BSSGP[0].receive(t_BssgpStsInd(?, ?, BVC_S_UNBLOCKED)) { } |
| 215 | [] BSSGP[0].receive { repeat; } |
| 216 | [] T.timeout { |
| 217 | setverdict(fail, "Timeout establishing BSSGP connection"); |
| 218 | mtc.stop; |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 219 | } |
Harald Welte | 54242db | 2018-03-03 22:38:54 +0100 | [diff] [blame] | 220 | } |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 221 | T.stop |
| 222 | log("BSSGP successfully initialized"); |
| 223 | } |
Harald Welte | 54242db | 2018-03-03 22:38:54 +0100 | [diff] [blame] | 224 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 225 | function f_wait_paging_req_type1(hexstring expected_tmsi) runs on dummy_CT { |
| 226 | var LAPDm_ph_data ph_data; |
| 227 | timer T := 5.0; |
Harald Welte | 3a19440 | 2017-07-22 17:07:51 +0200 | [diff] [blame] | 228 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 229 | T.start; |
| 230 | alt { |
| 231 | [] L1.receive(LAPDm_ph_data:{sacch:=?,sapi:=0,lapdm:={bbis:=?}}) -> value ph_data { |
| 232 | var octetstring payload := substr(ph_data.lapdm.bbis.payload, 1, lengthof(ph_data.lapdm.bbis.payload) - 1); |
| 233 | var PDU_ML3_NW_MS pdu; |
Harald Welte | 3a19440 | 2017-07-22 17:07:51 +0200 | [diff] [blame] | 234 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 235 | if (dec_PDU_ML3_NW_MS_backtrack(payload, pdu) != 0) { |
| 236 | repeat; |
| 237 | } |
Harald Welte | 3a19440 | 2017-07-22 17:07:51 +0200 | [diff] [blame] | 238 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 239 | if (not ischosen(pdu.msgs.rrm)) { |
| 240 | repeat; |
| 241 | } |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 242 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 243 | if (match(pdu, tr_PAGING_REQ1(tr_PAGING_REQ1_MI1_TMSI(hex2oct(expected_tmsi))))) { |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 244 | setverdict(pass); |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 245 | } else { |
| 246 | repeat; |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 247 | } |
| 248 | } |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 249 | [] L1.receive { repeat; } |
| 250 | [] T.timeout { setverdict(fail); } |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 251 | } |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 252 | } |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 253 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 254 | /* Send PS-PAGING via BSSGP to PCU, expect it to show up on L1/Um */ |
| 255 | testcase TC_paging() runs on dummy_CT { |
| 256 | var hexstring tmsi_hex := '01234567'H; |
| 257 | var GsmTmsi tmsi := hex2int(tmsi_hex); |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 258 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 259 | g_mmctx.imsi := '262420123456789'H; |
| 260 | g_mmctx.tlli := f_random_tlli(); |
| 261 | f_init(); |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 262 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 263 | var BCCH_tune_req tune_req := { { false, 871 }, true }; |
| 264 | L1.send(tune_req); |
| 265 | /* FIXME: wait for confirm */ |
Harald Welte | 3a19440 | 2017-07-22 17:07:51 +0200 | [diff] [blame] | 266 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 267 | /* Send paging on signalling BVCI 0 since osmo-pcu does not support paging on PTP yet. */ |
| 268 | /* |
| 269 | TODO: Paging by IMSI does not work yet because osmo-pcu does not copy IMSI into paging requests. |
| 270 | BSSGP_SIG[0].send(ts_BSSGP_PS_PAGING_IMSI(0, g_mmctx.imsi)); |
| 271 | f_wait_paging_req_type1(hex2oct(g_mmctx.imsi)); |
| 272 | */ |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 273 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 274 | /* Page by TMSI */ |
| 275 | BSSGP_SIG[0].send(ts_BSSGP_PS_PAGING_PTMSI(0, g_mmctx.imsi, tmsi)); |
| 276 | f_wait_paging_req_type1(tmsi_hex); |
| 277 | } |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 278 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 279 | /* Establish an UL TBF: Tune to ARFCN, send RACH, receive AGCH, enable TBF Rx */ |
| 280 | function f_establish_ul_tbf() runs on dummy_CT { |
| 281 | timer T := 5.0; |
| 282 | var BCCH_tune_req tune_req := { { false, 871 }, true }; |
| 283 | L1.send(tune_req); |
| 284 | /* FIXME: wait for confirm */ |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 285 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 286 | var TBF_UL_establish_req est_req := { tbf_nr := 0, ra := hex2int('7B'H) }; |
| 287 | L1.send(est_req); |
| 288 | T.start; |
| 289 | /* FIXME: wait for confirm */ |
| 290 | alt { |
| 291 | [] L1.receive(TBF_UL_establish_res:?) {} |
| 292 | [] L1.receive { repeat; } |
| 293 | [] T.timeout { |
| 294 | setverdict(fail, "Timeout establishing UL TBF"); |
| 295 | mtc.stop; |
Stefan Sperling | 4c32b95 | 2018-05-29 20:51:04 +0200 | [diff] [blame] | 296 | } |
| 297 | } |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 298 | T.stop; |
| 299 | } |
Stefan Sperling | 4c32b95 | 2018-05-29 20:51:04 +0200 | [diff] [blame] | 300 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 301 | /* compute a random TLLI; FIXME: what about TLLI prefix / local/foreign/...? */ |
| 302 | function f_random_tlli() return GprsTlli { |
| 303 | var GprsTlli tlli := f_rnd_octstring(4); |
| 304 | return tlli; |
| 305 | } |
Stefan Sperling | 4c32b95 | 2018-05-29 20:51:04 +0200 | [diff] [blame] | 306 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 307 | /* Compute the frame number of the uplink block based on current fn + rrbp */ |
| 308 | function f_rrbp_fn(GsmFrameNumber fn, MacRrbp rrbp) return GsmFrameNumber { |
| 309 | var integer add; |
| 310 | select (rrbp) { |
| 311 | case (RRBP_Nplus13_mod_2715648) { |
| 312 | add := 13; |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 313 | } |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 314 | case (RRBP_Nplus17_or_18_mod_2715648) { |
| 315 | add := 17; /* FIXME: What about 'or 18'? */ |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 316 | } |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 317 | case (RRBP_Nplus21_or_22_mod_2715648) { |
| 318 | add := 21; /* FIXME: What about 'or 22'? */ |
| 319 | } |
| 320 | case (RRBP_Nplus26_mod_2715648) { |
| 321 | add := 26; |
| 322 | } |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 323 | } |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 324 | return (fn + add) mod 2715648; |
| 325 | } |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 326 | |
Harald Welte | 060e27a | 2018-03-03 20:38:19 +0100 | [diff] [blame] | 327 | |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 328 | function f_bssgp_wait_ul_ud(template PDU_BSSGP exp) runs on dummy_CT { |
Harald Welte | 060e27a | 2018-03-03 20:38:19 +0100 | [diff] [blame] | 329 | timer T := 5.0; |
| 330 | T.start; |
| 331 | alt { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 332 | [] BSSGP[0].receive(exp) { |
Harald Welte | 060e27a | 2018-03-03 20:38:19 +0100 | [diff] [blame] | 333 | log("found matching BSSGP UL-UNITDATA PDU"); |
| 334 | } |
| 335 | [] T.timeout { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 336 | setverdict(fail, "Timeout waiting for ", exp); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 337 | mtc.stop; |
Harald Welte | 060e27a | 2018-03-03 20:38:19 +0100 | [diff] [blame] | 338 | } |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | |
| 343 | function f_ul_tbf(inout UlTbfState us) runs on dummy_CT { |
| 344 | var RLCMAC_ph_data_ind dl; |
| 345 | |
| 346 | /* Establish an UL-TBF */ |
| 347 | f_establish_ul_tbf(); |
| 348 | |
| 349 | while (true) { |
| 350 | var RlcmacUlBlock blk; |
| 351 | if (f_ul_tbf_get_next_block(blk, us, g_mmctx, true) == false) { |
| 352 | break; |
| 353 | } |
| 354 | |
| 355 | /* Send the block to L1 for transmission */ |
| 356 | log("L1=", blk); |
| 357 | L1.send(RLCMAC_ph_data_req:{dyn:={tbf_id := 0, cs := us.tbf.initial_cs, block := blk}}); |
| 358 | } |
| 359 | |
| 360 | alt { |
| 361 | [] L1.receive(RLCMAC_ph_data_ind:{cs:=?, ts_nr:=?, fn:=?, block:=tr_RLCMAC_ACK_NACK(0, g_mmctx.tlli)}) -> value dl { |
| 362 | log("found matching ACK/NACK"); |
| 363 | /* send CTRL ACK in uplink */ |
| 364 | var GsmFrameNumber ul_fn := f_rrbp_fn(dl.fn, dl.block.ctrl.mac_hdr.rrbp); |
| 365 | var RlcmacUlCtrlMsg ctrl_ack := valueof(ts_RlcMacUlCtrl_PKT_CTRL_ACK(g_mmctx.tlli)); |
| 366 | var RlcmacUlBlock ul_block := valueof(ts_RLC_UL_CTRL_ACK(ctrl_ack)); |
| 367 | L1.send(ts_PH_DATA_ABS(0, CS1, dl.ts_nr, ul_fn, {false, 871}, ul_block)); |
| 368 | /* wait for the final ACK */ |
| 369 | if (dl.block.ctrl.payload.u.ul_ack_nack.gprs.ack_nack_desc.final_ack == '0'B) { |
| 370 | repeat; |
| 371 | } |
| 372 | } |
| 373 | [] L1.receive { repeat; } |
| 374 | } |
| 375 | |
| 376 | for (var integer i := 0; i < sizeof(us.tbf.llc_pdus_enc); i := i+1) { |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 377 | f_bssgp_wait_ul_ud(tr_BSSGP_UL_UD(g_mmctx.tlli, ?, us.tbf.llc_pdus_enc[i])); |
Harald Welte | 060e27a | 2018-03-03 20:38:19 +0100 | [diff] [blame] | 378 | } |
| 379 | setverdict(pass); |
Harald Welte | 54242db | 2018-03-03 22:38:54 +0100 | [diff] [blame] | 380 | |
| 381 | L1.send(DCCH_release_req:{}); |
Harald Welte | 060e27a | 2018-03-03 20:38:19 +0100 | [diff] [blame] | 382 | } |
| 383 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 384 | testcase TC_rach() runs on dummy_CT { |
| 385 | var BssgpBvci bvci := 196; |
| 386 | g_mmctx.imsi := '262420123456789'H; |
| 387 | g_mmctx.tlli := f_random_tlli(); |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 388 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 389 | f_init(); |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 390 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 391 | f_bssgp_client_register(g_mmctx.imsi, g_mmctx.tlli, mp_gb_cfg.cell_id); |
Harald Welte | 7024baa | 2018-03-02 23:37:51 +0100 | [diff] [blame] | 392 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 393 | f_bssgp_establish(); |
| 394 | } |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 395 | |
| 396 | |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 397 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 398 | function f_llc_dec_and_log(in octetstring inp) { |
| 399 | log("LLC Input: ", inp); |
| 400 | var PDU_LLC dec := dec_PDU_LLC(inp); |
| 401 | log("LLC Decoded: ", dec); |
| 402 | } |
| 403 | |
| 404 | function f_llc_assert(in octetstring a, in octetstring b) { |
| 405 | log("LLC Input: ", a); |
| 406 | log("LLC Expected: ", b); |
| 407 | |
| 408 | if (a != b) { |
| 409 | setverdict(fail, "LLC input ", b, " != expected ", a); |
| 410 | mtc.stop; |
| 411 | } else { |
| 412 | setverdict(pass); |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 413 | } |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 414 | } |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 415 | |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 416 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 417 | testcase TC_selftest_llc() runs on dummy_CT { |
| 418 | const octetstring c_gmm_att_pcu := '01c001080103e5e000210a0005f4fb146ddd32f44000c8001d1b53432b37159ef9090070000dd9c6321200e00019b32c642401c00020170580460b'O; |
| 419 | const octetstring c_gmm_att_pcu_nofcs := '01c001080103e5e000210a0005f4fb146ddd32f44000c8001d1b53432b37159ef9090070000dd9c6321200e00019b32c642401c000201705'O; |
| 420 | |
| 421 | f_llc_dec_and_log(c_gmm_att_pcu); |
| 422 | |
| 423 | //f_llc_assert(f_LLC_append_fcs(c_gmm_att_pcu_nofcs), c_gmm_att_pcu); |
| 424 | |
| 425 | log(valueof(ts_LLC_UI(gmm_auth_req, c_LLC_SAPI_LLGMM, LLC_CR_DL_CMD, g_mmctx.n_u))); |
| 426 | log(ts_LLC_UI(gmm_auth_req, c_LLC_SAPI_LLGMM, LLC_CR_DL_CMD, g_mmctx.n_u)); |
| 427 | } |
| 428 | |
| 429 | testcase TC_selftest_rlcmac() runs on dummy_CT { |
| 430 | var RlcmacDlCtrlBlock dcb; |
| 431 | var RlcmacUlCtrlBlock ucb; |
| 432 | const octetstring c_dl_ul_ack_nack := '40240080400000000000000077628dbba14b2b2b2b2b2b'O; |
| 433 | const octetstring c_dl_data := '0f00007341c001081200102198c72477ea104895e8b959acc58b108182f4d0454300'O; |
| 434 | const octetstring c_dl_data2 := '070002165dc0012b2b2b43c0012b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b00'O; |
| 435 | const octetstring c_ul_ctrl_ack := '4006ec51b7772b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b'O; |
| 436 | const octetstring c_ul_dl_ack_nack := '4008004000000000000000701000edc0000b2b2b2b2b2b'O; |
| 437 | const octetstring c_dl_ul_assign := '482857628dbbaf0126e68800082b2b2b2b2b2b2b2b2b2b'O; |
| 438 | |
| 439 | log(c_dl_ul_ack_nack); |
| 440 | dcb := dec_RlcmacDlCtrlBlock(c_dl_ul_ack_nack); |
| 441 | log(dcb); |
| 442 | //log(dec_RlcmacDlCtrlMsg(dcb.payload)); |
| 443 | |
| 444 | f_rlcmac_dld_decenc(c_dl_data); |
| 445 | |
| 446 | f_rlcmac_dld_decenc(c_dl_data2); |
| 447 | |
| 448 | log(c_ul_ctrl_ack); |
| 449 | ucb := dec_RlcmacUlCtrlBlock(c_ul_ctrl_ack); |
| 450 | log(ucb); |
| 451 | //log(dec_RlcmacUlCtrlMsg(ucb.payload)); |
| 452 | |
| 453 | log(c_ul_dl_ack_nack); |
| 454 | ucb := dec_RlcmacUlCtrlBlock(c_ul_dl_ack_nack); |
| 455 | log(ucb); |
| 456 | //log(dec_RlcmacUlCtrlMsg(ucb.payload)); |
| 457 | |
| 458 | log(c_dl_ul_assign); |
| 459 | dcb := dec_RlcmacDlCtrlBlock(c_dl_ul_assign); |
| 460 | log(dcb); |
| 461 | //log(dec_RlcmacDlCtrlMsg(dcb.payload)); |
| 462 | |
| 463 | const octetstring c_uld_tlli_noext := '080101a61cab5201c001080103e5e000310a0005f4e61cab5232f44000c8001d1b00'O; |
| 464 | f_rlcmac_uld_decenc(c_uld_tlli_noext); |
| 465 | |
| 466 | const octetstring c_uld_tlli_ext7pad := '0001041da61cab5200201705a96e102b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b00'O; |
| 467 | log("ULD_decenc"); |
| 468 | f_rlcmac_uld_decenc(c_uld_tlli_ext7pad); |
| 469 | log("UL_decenc"); |
| 470 | f_rlcmac_ul_decenc(c_uld_tlli_ext7pad); |
| 471 | |
| 472 | f_rlcmac_ul_decenc(c_ul_dl_ack_nack); |
| 473 | } |
| 474 | |
| 475 | function f_rlcmac_ul_decenc(in octetstring buf) { |
| 476 | log("=================================="); |
| 477 | log("In: ", buf); |
| 478 | var RlcmacUlBlock udb := dec_RlcmacUlBlock(buf); |
| 479 | log("Dec: ", udb); |
| 480 | var octetstring enc := enc_RlcmacUlBlock(udb); |
| 481 | log("Enc: ", enc); |
| 482 | if (enc != buf) { |
| 483 | setverdict(fail, "Re-encoded data doesn't equal input data"); |
| 484 | mtc.stop; |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 485 | } |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 486 | } |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 487 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 488 | function f_rlcmac_uld_decenc(in octetstring buf) { |
| 489 | log("=================================="); |
| 490 | log("In: ", buf); |
| 491 | var RlcmacUlDataBlock udb := dec_RlcmacUlDataBlock(buf); |
| 492 | log("Dec: ", udb); |
| 493 | var octetstring enc := enc_RlcmacUlDataBlock(udb); |
| 494 | log("Enc: ", enc); |
| 495 | if (enc != buf) { |
| 496 | setverdict(fail, "Re-encoded data doesn't equal input data"); |
| 497 | mtc.stop; |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 498 | } |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 499 | } |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 500 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 501 | function f_rlcmac_dld_decenc(in octetstring buf) { |
| 502 | log("=================================="); |
| 503 | log("In: ", buf); |
| 504 | var RlcmacDlDataBlock udb := dec_RlcmacDlDataBlock(buf); |
| 505 | log("Dec: ", udb); |
| 506 | var octetstring enc := enc_RlcmacDlDataBlock(udb); |
| 507 | log("Enc: ", enc); |
| 508 | if (enc != buf) { |
| 509 | setverdict(fail, "Re-encoded data doesn't equal input data"); |
| 510 | mtc.stop; |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 511 | } |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 512 | } |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 513 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 514 | |
| 515 | testcase TC_selftest_rr() runs on dummy_CT { |
| 516 | //const octetstring c_paging_none := '06210001F02B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O |
| 517 | const octetstring c_paging_none := '1506210001F0'O; |
| 518 | const octetstring c_ia_tbf := '2d063f100fe3677bd8440000c800100b2b2b2b2b2b2b2b'O |
| 519 | log(c_paging_none); |
| 520 | log(dec_GsmRrMessage(c_paging_none)); |
| 521 | |
| 522 | log(c_ia_tbf); |
| 523 | log(dec_GsmRrMessage(c_ia_tbf)); |
| 524 | } |
| 525 | |
| 526 | function f_seq_octstr(integer len) return octetstring { |
| 527 | var octetstring payload := ''O; |
| 528 | for (var integer i := 0; i < len; i := i+1 ) { |
| 529 | payload := payload & int2oct(i mod 256, 1); |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 530 | } |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 531 | return payload; |
| 532 | } |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 533 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 534 | testcase TC_ul_tbf_single_llc_sizes() runs on dummy_CT { |
| 535 | g_mmctx.imsi := '262420123456789'H; |
| 536 | g_mmctx.tlli := f_random_tlli(); |
| 537 | f_init(); |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 538 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 539 | for (var integer len := 1; len <= 1560; len := len+1) { |
| 540 | log("Testing Uplink TBF with single LLC-PDU of ", len, " bytes"); |
| 541 | var octetstring payload := f_seq_octstr(len); |
Harald Welte | 060e27a | 2018-03-03 20:38:19 +0100 | [diff] [blame] | 542 | var UlTbfPars ul_tbf_pars := { |
| 543 | ack_mode := true, |
| 544 | initial_cs := CS1, |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 545 | llc_pdus := { |
| 546 | valueof(ts_LLC_UI(payload, c_LLC_SAPI_LLGMM, '0'B, g_mmctx.n_u)) |
Harald Welte | 060e27a | 2018-03-03 20:38:19 +0100 | [diff] [blame] | 547 | } |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 548 | } |
Harald Welte | 060e27a | 2018-03-03 20:38:19 +0100 | [diff] [blame] | 549 | var UlTbfState ul_tbf_state; |
| 550 | f_UlTbfState_init(ul_tbf_state, ul_tbf_pars); |
| 551 | f_ul_tbf(ul_tbf_state); |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 552 | f_sleep(1.0); |
Harald Welte | 060e27a | 2018-03-03 20:38:19 +0100 | [diff] [blame] | 553 | } |
| 554 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 555 | f_exit(); |
| 556 | } |
Harald Welte | b669ee0 | 2018-03-09 12:50:02 +0100 | [diff] [blame] | 557 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 558 | testcase TC_ul_tbf() runs on dummy_CT { |
| 559 | g_mmctx.imsi := '262420123456789'H; |
| 560 | g_mmctx.tlli := f_random_tlli(); |
| 561 | f_init(); |
Harald Welte | b669ee0 | 2018-03-09 12:50:02 +0100 | [diff] [blame] | 562 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 563 | var octetstring payload := f_seq_octstr(1023); |
| 564 | var UlTbfPars ul_tbf_pars := { |
| 565 | ack_mode := true, |
| 566 | initial_cs := CS1, |
| 567 | llc_pdus := { |
| 568 | valueof(ts_LLC_UI(payload, c_LLC_SAPI_LLGMM, '0'B, g_mmctx.n_u)), |
| 569 | valueof(ts_LLC_UI(payload, c_LLC_SAPI_LLGMM, '0'B, g_mmctx.n_u+1)), |
| 570 | valueof(ts_LLC_UI(payload, c_LLC_SAPI_LLGMM, '0'B, g_mmctx.n_u+2)), |
| 571 | valueof(ts_LLC_UI(payload, c_LLC_SAPI_LLGMM, '0'B, g_mmctx.n_u+3)), |
| 572 | valueof(ts_LLC_UI(payload, c_LLC_SAPI_LLGMM, '0'B, g_mmctx.n_u+4)), |
| 573 | valueof(ts_LLC_UI(payload, c_LLC_SAPI_LLGMM, '0'B, g_mmctx.n_u+5)) |
Harald Welte | b669ee0 | 2018-03-09 12:50:02 +0100 | [diff] [blame] | 574 | } |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 575 | }; |
| 576 | var UlTbfState ul_tbf_state; |
| 577 | f_UlTbfState_init(ul_tbf_state, ul_tbf_pars); |
| 578 | f_ul_tbf(ul_tbf_state); |
| 579 | |
| 580 | f_exit(); |
| 581 | } |
| 582 | |
| 583 | testcase TC_dl_tbf() runs on dummy_CT { |
| 584 | g_mmctx.imsi := '262420123456789'H; |
| 585 | g_mmctx.tlli := f_random_tlli(); |
| 586 | f_init(); |
| 587 | |
| 588 | f_establish_dl_tbf(); |
| 589 | |
| 590 | f_exit(); |
| 591 | } |
| 592 | |
| 593 | function f_wait_tbf_dl(TbfNr tbf_nr, GprsTlli tlli) runs on dummy_CT return ImmediateAssignment { |
Vadim Yanitskiy | 6edd4f5 | 2019-09-09 01:51:09 +0200 | [diff] [blame] | 594 | var template PacketDlAssign dl_ass := tr_PacketDlAssign(tlli); |
| 595 | var template IaRestOctets rest := tr_IaRestOctets_DLAss(dl_ass); |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 596 | var LAPDm_ph_data ph_data; |
| 597 | var GsmRrMessage rr; |
| 598 | timer T := 10.0; |
| 599 | T.start; |
| 600 | alt { |
| 601 | [] L1.receive(LAPDm_ph_data:{sacch:=?,sapi:=0,lapdm:={bbis:=?}}) -> value ph_data { |
| 602 | rr := dec_GsmRrMessage(ph_data.lapdm.bbis.payload); |
| 603 | log("PCH/AGCH DL RR: ", rr); |
Vadim Yanitskiy | 6edd4f5 | 2019-09-09 01:51:09 +0200 | [diff] [blame] | 604 | if (match(rr, tr_IMM_TBF_ASS(dl := true, rest := rest))) { |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 605 | var TbfPars tbf_pars := valueof(t_TbfParsInit); |
| 606 | log("Received IMM.ASS for our TLLI!"); |
| 607 | tbf_pars.tfi[rr.payload.imm_ass.pkt_chan_desc.tn] := |
Vadim Yanitskiy | 7091e8d | 2019-09-09 01:07:37 +0200 | [diff] [blame] | 608 | rr.payload.imm_ass.rest_octets.hh.pa.uldl.ass.dl.group1.tfi_assignment; |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 609 | L1.send(TBF_DL_establish_req:{tbf_nr, tbf_pars}); |
| 610 | } else { |
| 611 | repeat; |
Harald Welte | b669ee0 | 2018-03-09 12:50:02 +0100 | [diff] [blame] | 612 | } |
Harald Welte | b669ee0 | 2018-03-09 12:50:02 +0100 | [diff] [blame] | 613 | } |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 614 | [] L1.receive { repeat }; |
| 615 | [] T.timeout { |
| 616 | setverdict(fail, "Timeout waiting for IMM ASS") |
| 617 | mtc.stop; |
Harald Welte | b669ee0 | 2018-03-09 12:50:02 +0100 | [diff] [blame] | 618 | } |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 619 | } |
| 620 | T.stop; |
| 621 | return rr.payload.imm_ass; |
| 622 | } |
Harald Welte | b669ee0 | 2018-03-09 12:50:02 +0100 | [diff] [blame] | 623 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 624 | /* Establish an UL TBF: Tune to ARFCN, send RACH, receive AGCH, enable TBF Rx */ |
| 625 | function f_establish_dl_tbf() runs on dummy_CT { |
| 626 | timer T := 5.0; |
| 627 | var BCCH_tune_req tune_req := { { false, 871 }, true }; |
| 628 | L1.send(tune_req); |
| 629 | /* FIXME: wait for confirm */ |
| 630 | |
| 631 | /* sending a GMM PDU as DL-UNITDATA should trigger Paging + DL TBF Assignment */ |
| 632 | tx_gmm('1'B, '01020304'O, c_LLC_SAPI_LLGMM); |
| 633 | |
| 634 | /* Expect an IMM.ASS for PDCH on the AGCH */ |
| 635 | f_wait_tbf_dl(0, g_mmctx.tlli); |
| 636 | |
| 637 | var RLCMAC_ph_data_ind dl; |
| 638 | alt { |
| 639 | [] L1.receive(RLCMAC_ph_data_ind:{cs:=?, ts_nr:=?, fn:=?, block:=tr_RLCMAC_DATA_RRBP}) -> value dl { |
| 640 | var uint6_t tfi := dl.block.data.mac_hdr.hdr_ext.tfi; |
| 641 | var GsmFrameNumber ul_fn := f_rrbp_fn(dl.fn, dl.block.data.mac_hdr.mac_hdr.rrbp); |
| 642 | var AckNackDescription an_desc := { /* FIXME: compute this based on state */ |
| 643 | final_ack := '1'B, |
| 644 | starting_seq_nr := 0, |
| 645 | receive_block_bitmap := '0000000000000000000000000000000000000000000000000000000000000001'B |
| 646 | } |
| 647 | var RlcmacUlCtrlMsg ctrl_ack; |
| 648 | ctrl_ack := valueof(ts_RlcMacUlCtrl_PKT_DL_ACK(tfi, an_desc)); |
| 649 | var RlcmacUlBlock ul_block := valueof(ts_RLC_UL_CTRL_ACK(ctrl_ack)); |
| 650 | L1.send(ts_PH_DATA_ABS(0, CS1, dl.ts_nr, ul_fn, {false, 871}, ul_block)); |
| 651 | log("Sent DL ACK: ", ul_block); |
| 652 | } |
| 653 | [] L1.receive { repeat; } |
Harald Welte | b669ee0 | 2018-03-09 12:50:02 +0100 | [diff] [blame] | 654 | } |
| 655 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 656 | f_sleep(10.0); |
| 657 | } |
Harald Welte | b669ee0 | 2018-03-09 12:50:02 +0100 | [diff] [blame] | 658 | |
Harald Welte | 7fd25cf | 2019-03-21 22:14:02 +0100 | [diff] [blame] | 659 | /* FIXME: merge this into BSSGP_Client_CT ? */ |
| 660 | type component bssgp_CT extends BSSGP_Client_CT { |
| 661 | var NS_CT ns_component; |
| 662 | var BSSGP_CT bssgp_component; |
| 663 | var boolean g_initialized := false; |
| 664 | } |
| 665 | |
| 666 | /* FIXME: merge this into BSSGP_Client_CT ? */ |
| 667 | function f_init_bssgp() runs on bssgp_CT { |
| 668 | var MmContext mmctx := { |
| 669 | imsi := '262420000000001'H, |
| 670 | tlli := 'FFFFFFFF'O, |
| 671 | n_u := 0 |
| 672 | }; |
| 673 | |
| 674 | |
| 675 | if (g_initialized == true) { |
| 676 | return; |
| 677 | } |
| 678 | g_initialized := true; |
| 679 | |
| 680 | /* create a new NS component */ |
| 681 | ns_component := NS_CT.create; |
| 682 | bssgp_component := BSSGP_CT.create; |
| 683 | /* connect our BSSGP port to the BSSGP Emulation */ |
| 684 | connect(self:BSSGP[0], bssgp_component:BSSGP_SP); |
| 685 | connect(self:BSSGP_SIG[0], bssgp_component:BSSGP_SP_SIG); |
| 686 | connect(self:BSSGP_PROC[0], bssgp_component:BSSGP_PROC); |
| 687 | /* connect lower-end of BSSGP with BSSGP_CODEC_PORT (maps to NS_PT*/ |
| 688 | connect(bssgp_component:BSCP, ns_component:NS_SP); |
| 689 | /* connect lower-end of NS emulation to NS_CODEC_PORT (on top of IPl4) */ |
| 690 | map(ns_component:NSCP, system:NS_CODEC_PORT); |
| 691 | ns_component.start(NSStart(mp_nsconfig)); |
| 692 | bssgp_component.start(BssgpStart(mp_gb_cfg)); |
| 693 | |
| 694 | f_bssgp_client_register(mmctx.imsi, mmctx.tlli, mp_gb_cfg.cell_id); |
| 695 | f_bssgp_establish(); |
| 696 | } |
| 697 | |
| 698 | |
Harald Welte | a419df2 | 2019-03-21 17:23:04 +0100 | [diff] [blame] | 699 | |
| 700 | control { |
| 701 | execute(TC_selftest_ns()); |
| 702 | execute(TC_ul_tbf_single_llc_sizes()); |
| 703 | execute(TC_ul_tbf()); |
| 704 | execute(TC_paging()); |
| 705 | } |
| 706 | |
Harald Welte | 3a19440 | 2017-07-22 17:07:51 +0200 | [diff] [blame] | 707 | }; |