Harald Welte | 3a19440 | 2017-07-22 17:07:51 +0200 | [diff] [blame] | 1 | module Test { |
| 2 | |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 3 | import from General_Types all; |
| 4 | import from Osmocom_Types all; |
| 5 | import from GSM_Types all; |
| 6 | import from GSM_RR_Types all; |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 7 | import from Osmocom_Gb_Types all; |
Harald Welte | 3a19440 | 2017-07-22 17:07:51 +0200 | [diff] [blame] | 8 | import from BSSGP_Types all; |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 9 | import from BSSGP_Emulation all; |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 10 | import from NS_Types all; |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 11 | import from NS_Emulation all; |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 12 | import from LLC_Types all; |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 13 | import from RLCMAC_Types all; |
| 14 | import from RLCMAC_CSN1_Types all; |
| 15 | import from LAPDm_RAW_PT all; |
| 16 | |
| 17 | type record MmContext { |
| 18 | octetstring imsi optional, |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 19 | GprsTlli tlli, |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 20 | uint9_t n_u |
| 21 | }; |
Harald Welte | 3a19440 | 2017-07-22 17:07:51 +0200 | [diff] [blame] | 22 | |
| 23 | type component dummy_CT { |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 24 | var lapdm_CT lapdm_component; |
| 25 | port LAPDm_PT L1; |
| 26 | |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 27 | port BSSGP_PT BSSGP; |
| 28 | var NS_CT ns_component; |
| 29 | var BSSGP_CT bssgp_component; |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 30 | |
| 31 | var MmContext g_mmctx := { |
| 32 | tlli := 0, |
| 33 | n_u := 0 |
| 34 | }; |
| 35 | |
| 36 | var boolean g_initialized := false; |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | function f_init() runs on dummy_CT { |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 40 | if (g_initialized == true) { |
| 41 | return; |
| 42 | } |
| 43 | g_initialized := true; |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 44 | /* create a new NS component */ |
| 45 | ns_component := NS_CT.create; |
| 46 | bssgp_component := BSSGP_CT.create; |
| 47 | /* connect our BSSGP port to the BSSGP Emulation */ |
| 48 | connect(self:BSSGP, bssgp_component:BSSGP_SP); |
| 49 | /* connect lower-end of BSSGP with BSSGP_CODEC_PORT (maps to NS_PT*/ |
| 50 | connect(bssgp_component:BSCP, ns_component:NS_SP); |
| 51 | /* connect lower-end of NS emulation to NS_CODEC_PORT (on top of IPl4) */ |
| 52 | map(ns_component:NSCP, system:NS_CODEC_PORT); |
| 53 | ns_component.start(NSStart()); |
| 54 | bssgp_component.start(BssgpStart()); |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 55 | |
| 56 | lapdm_component := lapdm_CT.create; |
| 57 | connect(self:L1, lapdm_component:LAPDM_SP); |
| 58 | map(lapdm_component:L1CTL, system:L1CTL); |
| 59 | lapdm_component.start(LAPDmStart()); |
Harald Welte | 3a19440 | 2017-07-22 17:07:51 +0200 | [diff] [blame] | 60 | } |
| 61 | |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 62 | function f_bssgp_dec_and_log(in octetstring inp) { |
| 63 | log("BSSGP Input: ", inp); |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 64 | var PDU_BSSGP dec := dec_PDU_BSSGP(inp); |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 65 | log("BSSGP Decoded: ", dec); |
Harald Welte | 3a19440 | 2017-07-22 17:07:51 +0200 | [diff] [blame] | 66 | } |
| 67 | |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 68 | testcase TC_selftest_bssgp() runs on dummy_CT { |
Harald Welte | 3a19440 | 2017-07-22 17:07:51 +0200 | [diff] [blame] | 69 | const octetstring c_bvc_reset_pcu := '2204820000078108088832f44000c80051e0'O; |
| 70 | const octetstring c_bvc_reset_q := '2204820000078100'O; |
| 71 | const octetstring c_status_pcu := '4107810515882204820000078103'O; |
| 72 | const octetstring c_reset_ack_q := '2304820000'O; |
| 73 | const octetstring c_reset_ack_pcu := '23048200c4'O; |
| 74 | const octetstring c_unblock_pcu := '24048200c4'O; |
| 75 | const octetstring c_unblock_ack_q := '25048200c4'O; |
| 76 | const octetstring c_fc_bvc_pcu := '261e8101058200fa038200c8018200fa1c8200c806820000'O; |
| 77 | const octetstring c_fc_bvc_ack_q := '271e8101'O; |
| 78 | const octetstring c_gmm_mo_att_req := '01bb146ddd000004088832f44000c80051e000800e003b01c001080103e5e000110a0005f4fb146ddd32f44000c8001d1b53432b37159ef9090070000dd9c6321200e00019b32c642401c0002017057bf0ec'O; |
| 79 | const octetstring c_gmm_mt_ac_req := '00bb146ddd0050001682ffff0a8204030e9c41c001081200102198c72477ea104895e8b959acc58b108182f4d045'O; |
| 80 | const octetstring c_gmm_mo_ac_resp := '01bb146ddd000004088832f44000c80051e000800e000e01c00508130122fa361f5fdd623d'O; |
| 81 | const octetstring c_gmm_mt_att_acc := '00bb146ddd0050001682ffff0a8204030e9841c005080201340432f44000c8001805f4fb146ddd0967d0'O; |
| 82 | const octetstring c_gmm_mt_det_req := '00bb146ddd0050001682ffff0a8204030e8941c00908050215f0b6'O; |
| 83 | const octetstring c_gmm_mo_att_cpl := '01fb146ddd000004088832f44000c80051e000800e000801c009080339d7bc'O; |
| 84 | |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 85 | f_bssgp_dec_and_log(c_bvc_reset_pcu); |
| 86 | f_bssgp_dec_and_log(c_bvc_reset_q); |
| 87 | f_bssgp_dec_and_log(c_status_pcu); |
| 88 | f_bssgp_dec_and_log(c_reset_ack_q); |
| 89 | f_bssgp_dec_and_log(c_reset_ack_pcu); |
| 90 | f_bssgp_dec_and_log(c_unblock_pcu); |
| 91 | f_bssgp_dec_and_log(c_unblock_ack_q); |
| 92 | f_bssgp_dec_and_log(c_fc_bvc_pcu); |
| 93 | f_bssgp_dec_and_log(c_fc_bvc_ack_q); |
| 94 | f_bssgp_dec_and_log(c_gmm_mo_att_req); |
| 95 | f_bssgp_dec_and_log(c_gmm_mt_ac_req); |
| 96 | f_bssgp_dec_and_log(c_gmm_mo_ac_resp); |
| 97 | f_bssgp_dec_and_log(c_gmm_mt_att_acc); |
| 98 | f_bssgp_dec_and_log(c_gmm_mt_det_req); |
| 99 | f_bssgp_dec_and_log(c_gmm_mo_att_cpl); |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 100 | |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 101 | log(ts_BSSGP_PS_PAGING_IMSI(196, '262420123456789'H)); |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | function f_ns_assert_prepr(in octetstring a, in octetstring b) { |
| 105 | log("NS Input: ", a); |
| 106 | log("NS Expected: ", b); |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 107 | |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 108 | if (a != b) { |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 109 | setverdict(fail); |
| 110 | } else { |
| 111 | setverdict(pass); |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | function f_ns_dec_and_log(in octetstring inp) { |
| 116 | log("NS Input: ", inp); |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 117 | var PDU_NS dec := dec_PDU_NS(inp); |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 118 | log("NS Decoded: ", dec); |
| 119 | } |
| 120 | |
| 121 | testcase TC_selftest_ns() runs on dummy_CT { |
| 122 | const octetstring c_ns_reset_pcu := '000000c4271e813d'O; |
| 123 | |
| 124 | /* single byte length to two byte length */ |
| 125 | f_ns_assert_prepr('04058101'O, '0405000101'O); |
| 126 | f_ns_assert_prepr('040589000102030405060708'O, '04050009000102030405060708'O); |
| 127 | /* two byte length to two byte length */ |
| 128 | f_ns_assert_prepr('0405000101'O, '0405000101'O); |
| 129 | /* special case: NS-UNITDATA */ |
| 130 | f_ns_assert_prepr('00aabbccddeeffaa29822342'O, '00aabbccddeeffaa2900022342'O); |
| 131 | /* multiple TLVs */ |
| 132 | f_ns_assert_prepr('234281aa4382bbbb'O, '23420001aa430002bbbb'O); |
| 133 | /* zero-length */ |
| 134 | f_ns_assert_prepr('230080'O, '23000000'O); |
| 135 | |
| 136 | f_ns_dec_and_log(c_ns_reset_pcu); |
Harald Welte | 3a19440 | 2017-07-22 17:07:51 +0200 | [diff] [blame] | 137 | } |
| 138 | |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 139 | const octetstring gmm_auth_req := '081200102198c72477ea104895e8b959acc58b108182'O; |
| 140 | |
| 141 | function tx_gmm(boolean c_r, in octetstring gmm_pdu, LlcSapi sapi := LLC_SAPI_GMM) runs on dummy_CT { |
| 142 | var LlcPdu llc; |
| 143 | |
Harald Welte | 0e23a8f | 2017-12-12 16:47:48 +0100 | [diff] [blame] | 144 | //log("GMM Tx: ", dec_PDU_L3_SGSN_MS(gmm_pdu)); |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 145 | |
| 146 | log(c_r, g_mmctx.n_u, gmm_pdu, sapi); |
| 147 | log(t_LLC_UI(c_r, g_mmctx.n_u, gmm_pdu, sapi)); |
| 148 | llc := valueof(t_LLC_UI(c_r, g_mmctx.n_u, gmm_pdu, sapi)); |
| 149 | log(llc); |
| 150 | g_mmctx.n_u := g_mmctx.n_u + 1; |
| 151 | |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 152 | log(ts_BSSGP_DL_UD(g_mmctx.tlli, enc_LlcPdu(llc))); |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 153 | |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 154 | BSSGP.send(ts_BSSGP_DL_UD(g_mmctx.tlli, enc_LlcPdu(llc))); |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | function f_bssgp_establish() runs on dummy_CT { |
Harald Welte | 13d391e | 2017-07-23 19:52:33 +0200 | [diff] [blame] | 158 | timer T:= 60.0; |
| 159 | |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 160 | f_init(); |
Harald Welte | 13d391e | 2017-07-23 19:52:33 +0200 | [diff] [blame] | 161 | T.start |
| 162 | alt { |
| 163 | [] BSSGP.receive(t_BssgpStsInd(?, ?, BVC_S_UNBLOCKED)) { } |
| 164 | [] BSSGP.receive { repeat; } |
| 165 | [] T.timeout { setverdict(fail); } |
| 166 | } |
| 167 | T.stop |
| 168 | log("BSSGP successfully initialized"); |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | testcase TC_paging() runs on dummy_CT { |
| 172 | var hexstring imsi := '262420123456789'H; |
| 173 | var BssgpBvci bvci := 196; |
| 174 | var GsmTmsi tmsi := hex2int('01234567'H); |
| 175 | |
| 176 | f_bssgp_establish(); |
| 177 | |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 178 | BSSGP.send(ts_BSSGP_PS_PAGING_IMSI(bvci, imsi)); |
| 179 | BSSGP.send(ts_BSSGP_PS_PAGING_PTMSI(bvci, imsi, tmsi)); |
Harald Welte | 13d391e | 2017-07-23 19:52:33 +0200 | [diff] [blame] | 180 | |
| 181 | while (true) { |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 182 | var PDU_BSSGP pdu; |
Harald Welte | 13d391e | 2017-07-23 19:52:33 +0200 | [diff] [blame] | 183 | alt { |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 184 | [] BSSGP.receive(PDU_BSSGP:?) -> value pdu { |
Harald Welte | 13d391e | 2017-07-23 19:52:33 +0200 | [diff] [blame] | 185 | log("BSSGP Rx: ", pdu); |
| 186 | } |
| 187 | [] BSSGP.receive(t_BssgpStsInd(?, ?, BVC_S_UNBLOCKED)) { repeat; } |
| 188 | [] BSSGP.receive { repeat; } |
| 189 | } |
| 190 | } |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 191 | } |
| 192 | |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 193 | function f_establish_ul_tbf() runs on dummy_CT { |
| 194 | timer T := 5.0; |
| 195 | var BCCH_tune_req tune_req := { { false, 871 }, true }; |
| 196 | L1.send(tune_req); |
| 197 | /* FIXME: wait for confirm */ |
| 198 | |
| 199 | var TBF_establish_req est_req := { ra := hex2int('7B'H) }; |
| 200 | L1.send(est_req); |
| 201 | T.start; |
| 202 | /* FIXME: wait for confirm */ |
| 203 | alt { |
| 204 | [] L1.receive(TBF_establish_res:?) {} |
| 205 | [] L1.receive { repeat; } |
| 206 | [] T.timeout { setverdict(fail); } |
| 207 | } |
| 208 | T.stop; |
| 209 | } |
| 210 | |
| 211 | template RlcmacUlBlock t_RLCMAC_UL_DATA(template uint5_t tfi, template uint4_t cv, template uint7_t bsn, |
| 212 | template LlcBlocks blocks := {}, template boolean stall := false) := { |
| 213 | data := { |
| 214 | mac_hdr := { |
| 215 | payload_type := MAC_PT_RLC_DATA, |
| 216 | countdown := cv, |
| 217 | stall_ind := false, |
| 218 | retry := false, |
| 219 | spare := '0'B, |
| 220 | pfi_ind := false, |
| 221 | tfi := tfi, |
| 222 | tlli_ind := false, |
| 223 | bsn := bsn, |
| 224 | e := false |
| 225 | }, |
| 226 | tlli := omit, |
| 227 | pfi := omit, |
| 228 | blocks := blocks |
| 229 | } |
| 230 | } |
| 231 | template RlcmacUlBlock t_RLCMAC_UL_DATA_TLLI(template uint5_t tfi, template uint4_t cv, template uint7_t bsn, |
| 232 | template LlcBlocks blocks := {}, template boolean stall := false, template GprsTlli tlli) modifies t_RLCMAC_UL_DATA := { |
| 233 | data := { |
| 234 | tlli := tlli |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | template DlMacHeader t_RLCMAC_DlMacH(template MacPayloadType pt, template MacRrbp rrbp, template |
| 239 | uint3_t usf) := { |
| 240 | payload_type := pt, |
| 241 | rrbp := rrbp, |
Harald Welte | 0e23a8f | 2017-12-12 16:47:48 +0100 | [diff] [blame] | 242 | rrbp_valid := ispresent(rrbp), |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 243 | usf := usf |
| 244 | } |
| 245 | |
| 246 | template RlcmacDlBlock tr_RLCMAC_ACK_NACK(template uint5_t ul_tfi, template GprsTlli tlli := ?) := { |
| 247 | ctrl := { |
| 248 | mac_hdr := { |
| 249 | payload_type := (MAC_PT_RLCMAC_NO_OPT, MAC_PT_RLCMAC_OPT), |
| 250 | rrbp:= ?, |
| 251 | rrbp_valid := true, |
| 252 | usf := ? |
| 253 | }, |
| 254 | opt := *, |
| 255 | payload := { |
| 256 | msg_type := PACKET_UL_ACK_NACK, |
| 257 | u := { |
| 258 | ul_ack_nack := { |
| 259 | page_mode := ?, |
| 260 | msg_excape := ?, |
| 261 | uplink_tfi := ul_tfi, |
| 262 | is_egprs := '0'B, |
| 263 | gprs := { |
| 264 | ch_coding_cmd := ?, |
| 265 | ack_nack_desc := ?, |
| 266 | cont_res_tlli_present := ?, |
| 267 | cont_res_tlli := tlli, |
| 268 | pkt_ta_present := ?, |
| 269 | pkt_ta := *, |
| 270 | pwr_ctrl_present := ?, |
| 271 | pwr_ctrl := * |
| 272 | } |
| 273 | } |
| 274 | } |
| 275 | } |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | template UlMacCtrlHeader t_RLCMAC_UlMacCtrlH(template MacPayloadType pt, template boolean retry := false) := { |
| 280 | payload_type := pt, |
| 281 | spare := '00000'B, |
| 282 | retry := retry |
| 283 | } |
| 284 | |
| 285 | template RlcmacUlBlock ts_RLCMAC_CTRL_ACK(GprsTlli tlli, CtrlAck ack := MS_RCVD_TWO_RLC_SAME_RTI_DIFF_RBSN) := { |
| 286 | ctrl := { |
| 287 | mac_hdr := t_RLCMAC_UlMacCtrlH(MAC_PT_RLCMAC_NO_OPT), |
| 288 | payload := { |
| 289 | msg_type := PACKET_CONTROL_ACK, |
| 290 | u := { |
| 291 | ctrl_ack := { |
| 292 | tlli := tlli, |
| 293 | ctrl_ack := ack |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | template LlcBlock t_RLCMAC_LLCBLOCK(octetstring data, BIT1 more := '0'B, boolean e := true) := { |
| 301 | hdr := { |
| 302 | length_ind := lengthof(data), |
| 303 | more := more, |
| 304 | e := e |
| 305 | }, |
| 306 | payload := data |
| 307 | } |
| 308 | |
| 309 | function f_random_tlli() return GprsTlli { |
| 310 | var GprsTlli tlli := float2int(rnd()* 4294967295.0); |
| 311 | return tlli; |
| 312 | } |
| 313 | |
| 314 | function f_single_ul_block(GprsCodingScheme cs) runs on dummy_CT { |
| 315 | var GprsTlli tlli := f_random_tlli(); |
| 316 | var octetstring payload := '01020304'O; |
| 317 | |
| 318 | /* establish upling TBF */ |
| 319 | f_establish_ul_tbf(); |
| 320 | |
| 321 | /* Generate LLC PDU consisting of single RLC block and send it via simulated MS */ |
| 322 | var template RlcmacUlBlock blk := t_RLCMAC_UL_DATA_TLLI(0, 0, 0, {t_RLCMAC_LLCBLOCK(payload)}, false, tlli); |
| 323 | L1.send(RLCMAC_ph_data_req:{tbf_id := 0, cs := cs, block := blk}); |
| 324 | /* ensure that this LLC-PDU arrives from the right TLLI at the (simulated) SGSN */ |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 325 | BSSGP.receive(tr_BSSGP_UL_UD(tlli, ?, payload)); |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 326 | |
| 327 | /* ensure the MS eceives an UL_ACK_NACK */ |
| 328 | alt { |
| 329 | [] L1.receive(RLCMAC_ph_data_ind:{cs:=?, block:=tr_RLCMAC_ACK_NACK(0, tlli)}) { }; |
| 330 | [] L1.receive { repeat; }; |
| 331 | } |
| 332 | log("found matching ACK/NACK"); |
| 333 | /* send CTRL ACK in uplink */ |
| 334 | //L1.send(FIXME); |
| 335 | } |
| 336 | |
| 337 | testcase TC_rach() runs on dummy_CT { |
| 338 | var hexstring imsi := '262420123456789'H; |
| 339 | var BssgpBvci bvci := 196; |
| 340 | var GsmTmsi tmsi := hex2int('01234567'H); |
| 341 | |
| 342 | f_init(); |
| 343 | |
| 344 | f_bssgp_establish(); |
| 345 | |
| 346 | f_single_ul_block(CS1); |
| 347 | |
| 348 | while (true) { |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 349 | var PDU_BSSGP pdu; |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 350 | var RLCMAC_ph_data_ind dl_msg; |
| 351 | alt { |
| 352 | |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 353 | [] BSSGP.receive(PDU_BSSGP:?) -> value pdu { |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 354 | log("BSSGP Rx: ", pdu); |
| 355 | } |
| 356 | [] BSSGP.receive(t_BssgpStsInd(?, ?, BVC_S_UNBLOCKED)) { repeat; } |
| 357 | [] BSSGP.receive { repeat; } |
| 358 | |
| 359 | [] L1.receive(RLCMAC_ph_data_ind:?) -> value dl_msg { |
| 360 | log("L1 DL: ", dl_msg); |
| 361 | } |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | |
| 367 | testcase TC_nsem() runs on dummy_CT { |
| 368 | |
| 369 | f_bssgp_establish(); |
| 370 | |
| 371 | while (true) { |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 372 | var PDU_BSSGP pdu; |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 373 | alt { |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 374 | [] BSSGP.receive(PDU_BSSGP:?) -> value pdu { |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 375 | log("BSSGP Rx: ", pdu); |
| 376 | //log("GMM Rx: ", dec_PDU_L3_MS_SGSN(pdu.payload)); |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 377 | g_mmctx.tlli := oct2int(pdu.pDU_BSSGP_UL_UNITDATA.tLLI); |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 378 | tx_gmm(LLC_CR_DL_CMD, gmm_auth_req); |
| 379 | } |
| 380 | [] BSSGP.receive(t_BssgpStsInd(?, ?, BVC_S_UNBLOCKED)) { repeat; } |
| 381 | [] BSSGP.receive { repeat; } |
| 382 | } |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | |
| 387 | function f_llc_dec_and_log(in octetstring inp) { |
| 388 | log("LLC Input: ", inp); |
| 389 | var LlcPdu dec := dec_LlcPdu(inp); |
| 390 | log("LLC Decoded: ", dec); |
| 391 | } |
| 392 | |
| 393 | function f_llc_assert(in octetstring a, in octetstring b) { |
| 394 | log("LLC Input: ", a); |
| 395 | log("LLC Expected: ", b); |
| 396 | |
| 397 | if (a != b) { |
| 398 | setverdict(fail); |
| 399 | } else { |
| 400 | setverdict(pass); |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | |
| 405 | testcase TC_selftest_llc() runs on dummy_CT { |
| 406 | const octetstring c_gmm_att_pcu := '01c001080103e5e000210a0005f4fb146ddd32f44000c8001d1b53432b37159ef9090070000dd9c6321200e00019b32c642401c00020170580460b'O; |
| 407 | const octetstring c_gmm_att_pcu_nofcs := '01c001080103e5e000210a0005f4fb146ddd32f44000c8001d1b53432b37159ef9090070000dd9c6321200e00019b32c642401c000201705'O; |
| 408 | const octetstring c_ctrl_ui := 'c001'O; |
| 409 | |
| 410 | log(dec_LlcCtrlUnion(c_ctrl_ui)); |
| 411 | f_llc_assert(enc_LlcCtrlUnion({ ui := { presence := '110'B, spare := '00'B, n_u := 0, e := false, pm := true } }), c_ctrl_ui); |
| 412 | |
| 413 | f_llc_dec_and_log(c_gmm_att_pcu); |
| 414 | |
Harald Welte | e0abc47 | 2018-02-05 09:13:31 +0100 | [diff] [blame] | 415 | //f_llc_assert(f_LLC_append_fcs(c_gmm_att_pcu_nofcs), c_gmm_att_pcu); |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 416 | |
| 417 | log(valueof(t_LLC_UI(LLC_CR_DL_CMD, g_mmctx.n_u, gmm_auth_req, LLC_SAPI_GMM))); |
| 418 | log(t_LLC_UI(LLC_CR_DL_CMD, g_mmctx.n_u, gmm_auth_req, LLC_SAPI_GMM)); |
| 419 | } |
| 420 | |
| 421 | testcase TC_selftest_rlcmac() runs on dummy_CT { |
| 422 | var RlcmacDlCtrlBlock dcb; |
| 423 | var RlcmacUlCtrlBlock ucb; |
| 424 | const octetstring c_dl_ul_ack_nack := '40240080400000000000000077628dbba14b2b2b2b2b2b'O; |
| 425 | const octetstring c_dl_data := '0f00007341c001081200102198c72477ea104895e8b959acc58b108182f4d0454300'O; |
| 426 | const octetstring c_dl_data2 := '070002165dc0012b2b2b43c0012b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b00'O; |
| 427 | const octetstring c_ul_ctrl_ack := '4006ec51b7772b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b'O; |
| 428 | const octetstring c_ul_dl_ack_nack := '4008004000000000000000701000edc0000b2b2b2b2b2b'O; |
| 429 | const octetstring c_dl_ul_assign := '482857628dbbaf0126e68800082b2b2b2b2b2b2b2b2b2b'O; |
| 430 | |
| 431 | log(c_dl_ul_ack_nack); |
| 432 | dcb := dec_RlcmacDlCtrlBlock(c_dl_ul_ack_nack); |
| 433 | log(dcb); |
| 434 | //log(dec_RlcmacDlCtrlMsg(dcb.payload)); |
| 435 | |
| 436 | f_rlcmac_dld_decenc(c_dl_data); |
| 437 | |
| 438 | f_rlcmac_dld_decenc(c_dl_data2); |
| 439 | |
| 440 | log(c_ul_ctrl_ack); |
| 441 | ucb := dec_RlcmacUlCtrlBlock(c_ul_ctrl_ack); |
| 442 | log(ucb); |
| 443 | //log(dec_RlcmacUlCtrlMsg(ucb.payload)); |
| 444 | |
| 445 | log(c_ul_dl_ack_nack); |
| 446 | ucb := dec_RlcmacUlCtrlBlock(c_ul_dl_ack_nack); |
| 447 | log(ucb); |
| 448 | //log(dec_RlcmacUlCtrlMsg(ucb.payload)); |
| 449 | |
| 450 | log(c_dl_ul_assign); |
| 451 | dcb := dec_RlcmacDlCtrlBlock(c_dl_ul_assign); |
| 452 | log(dcb); |
| 453 | //log(dec_RlcmacDlCtrlMsg(dcb.payload)); |
| 454 | |
| 455 | const octetstring c_uld_tlli_noext := '080101a61cab5201c001080103e5e000310a0005f4e61cab5232f44000c8001d1b00'O; |
| 456 | f_rlcmac_uld_decenc(c_uld_tlli_noext); |
| 457 | |
| 458 | const octetstring c_uld_tlli_ext7pad := '0001041da61cab5200201705a96e102b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b00'O; |
| 459 | log("ULD_decenc"); |
| 460 | f_rlcmac_uld_decenc(c_uld_tlli_ext7pad); |
| 461 | log("UL_decenc"); |
| 462 | f_rlcmac_ul_decenc(c_uld_tlli_ext7pad); |
| 463 | |
| 464 | f_rlcmac_ul_decenc(c_ul_dl_ack_nack); |
| 465 | } |
| 466 | |
| 467 | function f_rlcmac_ul_decenc(in octetstring buf) { |
| 468 | log("=================================="); |
| 469 | log("In: ", buf); |
| 470 | var RlcmacUlBlock udb := dec_RlcmacUlBlock(buf); |
| 471 | log("Dec: ", udb); |
| 472 | var octetstring enc := enc_RlcmacUlBlock(udb); |
| 473 | log("Enc: ", enc); |
| 474 | if (enc != buf) { setverdict(fail, "Re-encoded data doesn't equal input data"); } |
| 475 | } |
| 476 | |
| 477 | function f_rlcmac_uld_decenc(in octetstring buf) { |
| 478 | log("=================================="); |
| 479 | log("In: ", buf); |
| 480 | var RlcmacUlDataBlock udb := dec_RlcmacUlDataBlock(buf); |
| 481 | log("Dec: ", udb); |
| 482 | var octetstring enc := enc_RlcmacUlDataBlock(udb); |
| 483 | log("Enc: ", enc); |
| 484 | if (enc != buf) { setverdict(fail, "Re-encoded data doesn't equal input data"); } |
| 485 | } |
| 486 | |
| 487 | function f_rlcmac_dld_decenc(in octetstring buf) { |
| 488 | log("=================================="); |
| 489 | log("In: ", buf); |
| 490 | var RlcmacDlDataBlock udb := dec_RlcmacDlDataBlock(buf); |
| 491 | log("Dec: ", udb); |
| 492 | var octetstring enc := enc_RlcmacDlDataBlock(udb); |
| 493 | log("Enc: ", enc); |
| 494 | if (enc != buf) { setverdict(fail, "Re-encoded data doesn't equal input data"); } |
| 495 | } |
| 496 | |
| 497 | |
| 498 | testcase TC_selftest_rr() runs on dummy_CT { |
| 499 | //const octetstring c_paging_none := '06210001F02B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O |
| 500 | const octetstring c_paging_none := '1506210001F0'O; |
| 501 | const octetstring c_ia_tbf := '2d063f100fe3677bd8440000c800100b2b2b2b2b2b2b2b'O |
| 502 | log(c_paging_none); |
| 503 | log(dec_GsmRrMessage(c_paging_none)); |
| 504 | |
| 505 | log(c_ia_tbf); |
| 506 | log(dec_GsmRrMessage(c_ia_tbf)); |
| 507 | } |
| 508 | |
Harald Welte | 3a19440 | 2017-07-22 17:07:51 +0200 | [diff] [blame] | 509 | control { |
Harald Welte | 6fff364 | 2017-07-22 21:36:13 +0200 | [diff] [blame] | 510 | execute(TC_selftest_bssgp()); |
| 511 | execute(TC_selftest_ns()); |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 512 | execute(TC_selftest_llc()); |
| 513 | execute(TC_selftest_rr()); |
| 514 | execute(TC_selftest_rlcmac()); |
Harald Welte | 6e594f2 | 2017-07-23 16:19:35 +0200 | [diff] [blame] | 515 | execute(TC_nsem()); |
Harald Welte | 244cd8a | 2017-08-26 09:25:20 +0200 | [diff] [blame] | 516 | execute(TC_paging()); |
Harald Welte | 3a19440 | 2017-07-22 17:07:51 +0200 | [diff] [blame] | 517 | } |
| 518 | }; |