Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 1 | module PCU_Tests_RAW { |
| 2 | |
| 3 | /* "RAW" PCU tests: Talk directly to the PCU socket of OsmoPCU on the one hand side (emulating |
| 4 | the BTS/BSC side PCU socket server) and the Gb interface on the other hand side. No NS/BSSGP |
| 5 | Emulation is used; rather, we simply use the NS_CodecPort to implement both standard and non- |
| 6 | standard procedures on the NS and BSSGP level. The goal of these tests is to test exactly |
| 7 | those NS and BSSGP implementations on the BSS (PCU) side. */ |
| 8 | |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 9 | /* (C) 2018-2019 Harald Welte <laforge@gnumonks.org> |
| 10 | * All rights reserved. |
| 11 | * |
| 12 | * Released under the terms of GNU General Public License, Version 2 or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 16 | */ |
| 17 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 18 | import from General_Types all; |
| 19 | import from Osmocom_Types all; |
Harald Welte | 7fd25cf | 2019-03-21 22:14:02 +0100 | [diff] [blame] | 20 | import from GSM_Types all; |
| 21 | import from GSM_RR_Types all; |
| 22 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 23 | import from NS_Types all; |
| 24 | import from BSSGP_Types all; |
| 25 | import from Osmocom_Gb_Types all; |
| 26 | |
| 27 | import from BSSGP_Emulation all; /* BssgpConfig */ |
| 28 | import from NS_Emulation all; /* NSConfiguration */ |
| 29 | |
| 30 | import from UD_Types all; |
| 31 | import from PCUIF_Types all; |
| 32 | import from PCUIF_CodecPort all; |
Vadim Yanitskiy | f7d9c0f | 2019-09-06 00:08:17 +0200 | [diff] [blame^] | 33 | import from PCUIF_RAW_Components all; |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 34 | import from IPL4asp_Types all; |
| 35 | import from NS_CodecPort all; |
| 36 | import from NS_CodecPort_CtrlFunct all; |
| 37 | import from Native_Functions all; |
| 38 | import from PCU_Tests all; |
| 39 | |
| 40 | modulepar { |
| 41 | charstring mp_pcu_sock_path := PCU_SOCK_DEFAULT; |
| 42 | } |
| 43 | |
| 44 | type component RAW_NS_CT { |
| 45 | /* UDP port towards the bottom (IUT) */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 46 | port NS_CODEC_PT NSCP[4]; |
| 47 | var ConnectionId g_ns_conn_id[4] := {-1, -1, -1, -1}; |
| 48 | var NSConfiguration g_nsconfig[4]; |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 49 | timer g_T_guard; |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 50 | } |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 51 | |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 52 | type component RAW_PCU_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 53 | /* PCUIF (we emulate the BTS part) */ |
| 54 | port PCUIF_CODEC_PT PCU; |
| 55 | var ConnectionId g_pcu_conn_id := -1; |
| 56 | } |
| 57 | |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 58 | type component RAW_Test_CT extends RAW_NS_CT, RAW_PCU_CT { |
| 59 | } |
| 60 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 61 | private altstep as_Tguard() runs on RAW_NS_CT { |
| 62 | [] g_T_guard.timeout { |
| 63 | setverdict(fail, "Timeout of T_guard"); |
| 64 | mtc.stop; |
| 65 | } |
| 66 | } |
| 67 | |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 68 | function f_init_pcuif() runs on RAW_PCU_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 69 | map(self:PCU, system:PCU); |
| 70 | |
| 71 | /* Connect the Unix Domain Socket */ |
| 72 | g_pcu_conn_id := f_pcuif_listen(PCU, mp_pcu_sock_path); |
| 73 | PCU.receive(UD_connected:?); |
| 74 | |
| 75 | /* Wait for PCU_VERSION and return INFO_IND */ |
| 76 | PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TXT_IND(0, PCU_VERSION, ?))); |
| 77 | /* FIXME: make sure to use parameters from mp_gb_cfg.cell_id in the PCU INFO IND */ |
| 78 | var template PCUIF_Message info_ind := ts_PCUIF_INFO_IND(bts_nr := 0, |
| 79 | nsei := mp_nsconfig.nsei, |
| 80 | nsvci := mp_nsconfig.nsvci, |
| 81 | bvci := mp_gb_cfg.bvci, |
| 82 | local_port := mp_nsconfig.remote_udp_port, |
| 83 | remote_port := mp_nsconfig.local_udp_port, |
| 84 | remote_ip := f_inet_haddr(mp_nsconfig.local_ip) |
| 85 | ); |
| 86 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, info_ind)); |
| 87 | } |
| 88 | |
Harald Welte | 0466d16 | 2019-03-21 21:30:21 +0100 | [diff] [blame] | 89 | function f_pcuif_tx(template (value) PCUIF_Message msg) runs on RAW_PCU_CT { |
| 90 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, msg)); |
| 91 | } |
| 92 | |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 93 | function f_init_ns_codec(integer idx := 0, float guard_secs := 60.0) runs on RAW_NS_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 94 | var Result res; |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 95 | |
| 96 | if (not g_T_guard.running) { |
| 97 | g_T_guard.start(guard_secs); |
| 98 | activate(as_Tguard()); |
| 99 | } |
| 100 | |
| 101 | if (not isbound(g_nsconfig) or not isbound(g_nsconfig[idx])) { |
| 102 | /* copy most parts from mp_nsconfig */ |
| 103 | g_nsconfig[idx] := mp_nsconfig; |
| 104 | /* adjust those parts different for each NS-VC */ |
| 105 | g_nsconfig[idx].nsvci := mp_nsconfig.nsvci + idx; |
| 106 | g_nsconfig[idx].local_udp_port := mp_nsconfig.local_udp_port + idx; |
| 107 | } |
| 108 | |
| 109 | map(self:NSCP[idx], system:NSCP); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 110 | /* Connect the UDP socket */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 111 | log("connecting NSCP[", idx, "] to ", g_nsconfig[idx]); |
| 112 | res := f_IPL4_connect(NSCP[idx], g_nsconfig[idx].remote_ip, g_nsconfig[idx].remote_udp_port, |
| 113 | g_nsconfig[idx].local_ip, g_nsconfig[idx].local_udp_port, 0, { udp := {}}); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 114 | if (not ispresent(res.connId)) { |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 115 | setverdict(fail, "Could not connect NS UDP socket, check your configuration ", g_nsconfig[idx]); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 116 | mtc.stop; |
| 117 | } |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 118 | g_ns_conn_id[idx] := res.connId; |
| 119 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 120 | } |
| 121 | |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 122 | function f_ns_exp(template PDU_NS exp_rx, integer idx := 0) runs on RAW_NS_CT return PDU_NS { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 123 | var NS_RecvFrom nrf; |
| 124 | log("f_ns_exp() expecting ", exp_rx); |
| 125 | alt { |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 126 | [] NSCP[idx].receive(t_NS_RecvFrom(exp_rx)) -> value nrf { } |
| 127 | [] NSCP[idx].receive { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 128 | setverdict(fail, "Received unexpected NS: ", nrf); |
| 129 | mtc.stop; |
| 130 | } |
| 131 | } |
| 132 | return nrf.msg; |
| 133 | } |
| 134 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 135 | /* perform outbound NS-ALIVE procedure */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 136 | function f_outgoing_ns_alive(integer idx := 0) runs on RAW_NS_CT { |
| 137 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE)); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 138 | alt { |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 139 | [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE_ACK)); |
| 140 | [] NSCP[idx].receive { repeat; } |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 141 | } |
| 142 | } |
| 143 | |
Harald Welte | ecd159e | 2019-03-16 13:36:07 +0100 | [diff] [blame] | 144 | /* perform outbound NS-ALIVE procedure */ |
| 145 | function f_outgoing_ns_alive_no_ack(integer idx := 0, float tout := 10.0) runs on RAW_NS_CT { |
| 146 | timer T := tout; |
| 147 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE)); |
| 148 | T.start; |
| 149 | alt { |
| 150 | [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE_ACK)) { |
| 151 | setverdict(fail, "Received unexpected NS-ALIVE ACK"); |
| 152 | } |
| 153 | [] NSCP[idx].receive { repeat; } |
| 154 | [] T.timeout { |
| 155 | setverdict(pass); |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | /* ensure no matching message is received within 'tout' */ |
| 161 | function f_ensure_no_ns(template PDU_NS ns := ?, integer idx := 0, float tout := 3.0) |
| 162 | runs on RAW_Test_CT { |
| 163 | timer T := tout; |
| 164 | T.start; |
| 165 | alt { |
| 166 | [] NSCP[idx].receive(t_NS_RecvFrom(ns)) { |
| 167 | setverdict(fail, "NS-ALIVE from unconfigured (possibly initial) endpoint"); |
| 168 | } |
| 169 | [] T.timeout { |
| 170 | setverdict(pass); |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 175 | /* perform outbound NS-BLOCK procedure */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 176 | function f_outgoing_ns_block(NsCause cause, integer idx := 0) runs on RAW_NS_CT { |
| 177 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_BLOCK(cause, g_nsconfig[idx].nsvci))); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 178 | alt { |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 179 | [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_BLOCK_ACK(g_nsconfig[idx].nsvci))); |
| 180 | [] NSCP[idx].receive { repeat; } |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 181 | } |
| 182 | } |
| 183 | |
| 184 | /* receive NS-ALIVE and ACK it */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 185 | altstep as_rx_alive_tx_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT { |
| 186 | [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE)) { |
| 187 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE_ACK)); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 188 | if (not oneshot) { repeat; } |
| 189 | } |
| 190 | } |
| 191 | |
Harald Welte | 64d0731 | 2019-03-20 09:48:39 +0100 | [diff] [blame] | 192 | /* Transmit BSSGP RESET for given BVCI and expect ACK */ |
| 193 | function f_tx_bvc_reset_rx_ack(BssgpBvci bvci, integer idx := 0, boolean exp_ack := true) |
| 194 | runs on RAW_NS_CT { |
| 195 | var PDU_BSSGP bssgp_tx := valueof(ts_BVC_RESET(BSSGP_CAUSE_NET_SV_CAP_MOD_GT_ZERO_KBPS, bvci, |
| 196 | mp_gb_cfg.cell_id)); |
| 197 | timer T := 5.0; |
| 198 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx)))); |
| 199 | T.start; |
| 200 | alt { |
| 201 | [exp_ack] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0, |
| 202 | decmatch tr_BVC_RESET_ACK(bvci, ?)))) { |
| 203 | setverdict(pass); |
| 204 | } |
| 205 | [exp_ack] T.timeout { |
| 206 | setverdict(fail, "No response to BVC-RESET"); |
| 207 | } |
| 208 | [not exp_ack] T.timeout { |
| 209 | setverdict(pass); |
| 210 | } |
| 211 | [] NSCP[idx].receive { repeat; } |
| 212 | } |
| 213 | } |
| 214 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 215 | /* Receive a BSSGP RESET for given BVCI and ACK it */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 216 | altstep as_rx_bvc_reset_tx_ack(BssgpBvci bvci, boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 217 | var NS_RecvFrom ns_rf; |
| 218 | /* FIXME: nail down received cell_id in match */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 219 | [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0, |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 220 | decmatch tr_BVC_RESET(?, bvci, ?)))) |
| 221 | -> value ns_rf { |
| 222 | var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU); |
| 223 | var PDU_BSSGP bssgp_tx := valueof(ts_BVC_RESET_ACK(bvci, mp_gb_cfg.cell_id)); |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 224 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx)))); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 225 | if (not oneshot) { repeat; } |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | |
| 230 | /* Receive a BSSGP UNBLOCK for given BVCI and ACK it */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 231 | altstep as_rx_bvc_unblock_tx_ack(BssgpBvci bvci, boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 232 | var NS_RecvFrom ns_rf; |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 233 | [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0, |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 234 | decmatch t_BVC_UNBLOCK(bvci)))) |
| 235 | -> value ns_rf { |
| 236 | var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU); |
| 237 | var PDU_BSSGP bssgp_tx := valueof(t_BVC_UNBLOCK_ACK(bvci)); |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 238 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx)))); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 239 | if (not oneshot) { repeat; } |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | /* Receive a BSSGP FLOW-CONTROL-BVC and ACK it */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 244 | altstep as_rx_bvc_fc_tx_ack(BssgpBvci bvci, boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 245 | var NS_RecvFrom ns_rf; |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 246 | [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, bvci, |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 247 | decmatch tr_BVC_FC_BVC))) |
| 248 | -> value ns_rf { |
| 249 | var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU); |
| 250 | var OCT1 tag := bssgp_rx.pDU_BSSGP_FLOW_CONTROL_BVC.tag.unstructured_Value; |
| 251 | var PDU_BSSGP bssgp_tx := valueof(t_BVC_FC_BVC_ACK(tag)); |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 252 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, bvci, enc_PDU_BSSGP(bssgp_tx)))); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 253 | if (not oneshot) { repeat; } |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | /********************************************************************************** |
| 258 | * Classic Gb/IP bring-up test cases using NS-{RESET,BLOCK,UNBLOCK} and no IP-SNS * |
| 259 | **********************************************************************************/ |
| 260 | |
| 261 | /* Receive a NS-RESET and ACK it */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 262 | private altstep as_rx_ns_reset_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 263 | var NS_RecvFrom ns_rf; |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 264 | [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION, g_nsconfig[idx].nsvci, |
| 265 | g_nsconfig[idx].nsei))) -> value ns_rf { |
| 266 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_RESET_ACK(g_nsconfig[idx].nsvci, |
| 267 | g_nsconfig[idx].nsei))); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 268 | if (not oneshot) { repeat; } |
| 269 | } |
| 270 | } |
| 271 | /* Receive a NS-UNBLOCK and ACK it */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 272 | private altstep as_rx_ns_unblock_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 273 | var NS_RecvFrom ns_rf; |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 274 | [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_UNBLOCK)) -> value ns_rf { |
| 275 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_UNBLOCK_ACK)); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 276 | if (not oneshot) { repeat; } |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | /* test the NS-RESET procedure */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 281 | testcase TC_ns_reset() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 282 | f_init_ns_codec(); |
| 283 | f_init_pcuif(); |
| 284 | |
| 285 | |
| 286 | /* Expect inbound NS-RESET procedure */ |
| 287 | as_rx_ns_reset_ack(oneshot := true); |
| 288 | setverdict(pass); |
| 289 | } |
| 290 | |
| 291 | /* ensure NS-RESET are re-transmitted */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 292 | testcase TC_ns_reset_retrans() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 293 | f_init_ns_codec(); |
| 294 | f_init_pcuif(); |
| 295 | |
| 296 | var integer i; |
| 297 | for (i := 0; i < 3; i := i+1) { |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 298 | NSCP[0].receive(t_NS_RecvFrom(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION, |
| 299 | g_nsconfig[0].nsvci, g_nsconfig[0].nsei))); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | /* Expect inbound NS-RESET procedure */ |
| 303 | as_rx_ns_reset_ack(oneshot := true); |
| 304 | setverdict(pass); |
| 305 | } |
| 306 | |
| 307 | /* test the inbound NS-ALIVE procedure after NS-RESET */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 308 | testcase TC_ns_alive() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 309 | f_init_ns_codec(); |
| 310 | f_init_pcuif(); |
| 311 | |
| 312 | /* Expect inbound NS-RESET procedure */ |
| 313 | as_rx_ns_reset_ack(oneshot := true); |
| 314 | |
| 315 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
| 316 | as_rx_alive_tx_ack(oneshot := true); |
| 317 | setverdict(pass); |
| 318 | } |
| 319 | |
| 320 | /* Test for NS-RESET after NS-ALIVE timeout */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 321 | testcase TC_ns_alive_timeout_reset() runs on RAW_Test_CT { |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 322 | f_init_ns_codec(guard_secs := 100.0); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 323 | f_init_pcuif(); |
| 324 | |
| 325 | /* Expect inbound NS-RESET procedure */ |
| 326 | as_rx_ns_reset_ack(oneshot := true); |
| 327 | |
| 328 | /* wait for at least one NS-ALIVE */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 329 | NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE)); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 330 | |
| 331 | /* wait for NS-RESET to re-appear, ignoring any NS-ALIVE until then */ |
| 332 | alt { |
| 333 | [] as_rx_ns_reset_ack(oneshot := true) { setverdict(pass); } |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 334 | [] NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE)) { repeat; } |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 335 | } |
| 336 | } |
| 337 | |
| 338 | /* test for NS-RESET/NS-ALIVE/NS-UNBLOCK */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 339 | testcase TC_ns_unblock() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 340 | f_init_ns_codec(); |
| 341 | f_init_pcuif(); |
| 342 | |
| 343 | /* Expect inbound NS-RESET procedure */ |
| 344 | as_rx_ns_reset_ack(oneshot := true); |
| 345 | |
| 346 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
| 347 | as_rx_alive_tx_ack(oneshot := true); |
| 348 | activate(as_rx_alive_tx_ack()); |
| 349 | |
| 350 | as_rx_ns_unblock_ack(oneshot := true); |
| 351 | setverdict(pass); |
| 352 | } |
| 353 | |
| 354 | /* test for NS-UNBLOCK re-transmissions */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 355 | testcase TC_ns_unblock_retrans() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 356 | f_init_ns_codec(); |
| 357 | f_init_pcuif(); |
| 358 | |
| 359 | /* Expect inbound NS-RESET procedure */ |
| 360 | as_rx_ns_reset_ack(oneshot := true); |
| 361 | |
| 362 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
| 363 | as_rx_alive_tx_ack(oneshot := true); |
| 364 | activate(as_rx_alive_tx_ack()); |
| 365 | |
| 366 | /* wait for first NS-UNBLOCK, don't respond */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 367 | NSCP[0].receive(t_NS_RecvFrom(t_NS_UNBLOCK)); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 368 | |
| 369 | /* wait for re-transmission of NS-UNBLOCK */ |
| 370 | as_rx_ns_unblock_ack(oneshot := true); |
| 371 | setverdict(pass); |
| 372 | } |
| 373 | |
| 374 | /* full bring-up of the Gb link for NS and BSSGP layer up to BVC-FC */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 375 | testcase TC_ns_full_bringup() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 376 | f_init_ns_codec(); |
| 377 | f_init_pcuif(); |
| 378 | |
| 379 | /* Expect inbound NS-RESET procedure */ |
| 380 | as_rx_ns_reset_ack(oneshot := true); |
| 381 | |
| 382 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
| 383 | as_rx_alive_tx_ack(oneshot := true); |
| 384 | activate(as_rx_alive_tx_ack()); |
| 385 | |
| 386 | as_rx_ns_unblock_ack(oneshot := true); |
| 387 | |
| 388 | f_outgoing_ns_alive(); |
| 389 | |
| 390 | /* Expect BVC-RESET for signaling (0) and ptp BVCI */ |
| 391 | as_rx_bvc_reset_tx_ack(0, oneshot := true); |
| 392 | as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvci, oneshot := true); |
| 393 | as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvci, oneshot := true); |
| 394 | |
| 395 | /* wait for one FLOW-CONTROL BVC and then ACK any further in the future */ |
| 396 | as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, oneshot := true); |
| 397 | activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci)); |
| 398 | setverdict(pass); |
| 399 | } |
| 400 | |
| 401 | /* test outbound (SGSN-originated) NS-BLOCK procedure */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 402 | testcase TC_ns_so_block() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 403 | f_init_ns_codec(); |
| 404 | f_init_pcuif(); |
| 405 | |
| 406 | /* Expect inbound NS-RESET procedure */ |
| 407 | as_rx_ns_reset_ack(oneshot := true); |
| 408 | |
| 409 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
| 410 | as_rx_alive_tx_ack(oneshot := true); |
| 411 | activate(as_rx_alive_tx_ack()); |
| 412 | |
| 413 | as_rx_ns_unblock_ack(oneshot := true); |
| 414 | |
| 415 | f_outgoing_ns_alive(); |
| 416 | |
| 417 | f_outgoing_ns_block(NS_CAUSE_EQUIPMENT_FAILURE); |
| 418 | setverdict(pass); |
| 419 | } |
| 420 | |
Harald Welte | 7fd25cf | 2019-03-21 22:14:02 +0100 | [diff] [blame] | 421 | /* Test component with PCUIF + BSSGP/NS Emulation (no L1CTL) */ |
| 422 | type component bssgp_pcuif_CT extends bssgp_CT, RAW_PCU_CT { |
| 423 | } |
| 424 | |
| 425 | testcase TC_pcuif_suspend() runs on bssgp_pcuif_CT { |
| 426 | var OCT6 ra_id := enc_RoutingAreaIdentification(mp_gb_cfg.cell_id.ra_id); |
| 427 | var GprsTlli tlli := 'FFFFFFFF'O; |
| 428 | |
| 429 | /* Initialize PCU interface side */ |
| 430 | f_init_pcuif(); |
| 431 | |
| 432 | /* Initialize NS/BSSGP side */ |
| 433 | f_init_bssgp(); |
| 434 | |
| 435 | f_sleep(1.0); |
| 436 | f_pcuif_tx(ts_PCUIF_SUSP_REQ(0, tlli, ra_id, 0)); |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 437 | BSSGP_SIG[0].receive(tr_BSSGP_SUSPEND(tlli, mp_gb_cfg.cell_id.ra_id)); |
Harald Welte | 7fd25cf | 2019-03-21 22:14:02 +0100 | [diff] [blame] | 438 | |
| 439 | setverdict(pass); |
| 440 | } |
| 441 | |
Vadim Yanitskiy | f7d9c0f | 2019-09-06 00:08:17 +0200 | [diff] [blame^] | 442 | type component RAW_PCU_Test_CT extends bssgp_CT { |
| 443 | /* Connection to the BTS component (one for now) */ |
| 444 | port RAW_PCU_MSG_PT BTS; |
| 445 | /* Connection to the PCUIF component */ |
| 446 | port RAW_PCU_MSG_PT PCUIF; |
| 447 | |
| 448 | /* Guard timeout */ |
| 449 | timer g_T_guard := 60.0; |
| 450 | }; |
| 451 | |
| 452 | private altstep as_Tguard_RAW() runs on RAW_PCU_Test_CT { |
| 453 | [] g_T_guard.timeout { |
| 454 | setverdict(fail, "Timeout of T_guard"); |
| 455 | mtc.stop; |
| 456 | } |
| 457 | } |
| 458 | |
| 459 | private function f_init_raw(charstring id) |
| 460 | runs on RAW_PCU_Test_CT { |
| 461 | var PCUIF_info_ind info_ind; |
| 462 | var RAW_PCUIF_CT vc_PCUIF; |
| 463 | var RAW_PCU_BTS_CT vc_BTS; |
| 464 | |
| 465 | /* Start the guard timer */ |
| 466 | g_T_guard.start; |
| 467 | activate(as_Tguard_RAW()); |
| 468 | |
| 469 | /* Init PCU interface component */ |
| 470 | vc_PCUIF := RAW_PCUIF_CT.create("PCUIF-" & id); |
| 471 | connect(vc_PCUIF:MTC, self:PCUIF); |
| 472 | map(vc_PCUIF:PCU, system:PCU); |
| 473 | |
| 474 | /* Create one BTS component (we may want more some day) */ |
| 475 | vc_BTS := RAW_PCU_BTS_CT.create("BTS-" & id); |
| 476 | connect(vc_BTS:PCUIF, vc_PCUIF:BTS); |
| 477 | connect(vc_BTS:TC, self:BTS); |
| 478 | |
| 479 | /* FIXME: make sure to use parameters from mp_gb_cfg.cell_id in the PCU INFO IND */ |
| 480 | info_ind := { |
| 481 | version := PCU_IF_VERSION, |
| 482 | flags := c_PCUIF_Flags_default, |
| 483 | trx := valueof(ts_PCUIF_InfoTrxs_def), |
| 484 | /* TODO: make this configurable */ |
| 485 | bsic := 7, mcc := 262, mnc := 42, |
| 486 | mnc_3_digits := 0, |
| 487 | /* TODO: make this configurable */ |
| 488 | lac := 13135, rac := 0, |
| 489 | nsei := mp_nsconfig.nsei, |
| 490 | nse_timer := { 3, 3, 3, 3, 30, 3, 10 }, |
| 491 | cell_timer := { 3, 3, 3, 3, 3, 10, 3, 10, 3, 10, 3 }, |
| 492 | cell_id := 20960, |
| 493 | repeat_time := 5 * 50, |
| 494 | repeat_count := 3, |
| 495 | bvci := mp_gb_cfg.bvci, |
| 496 | t3142 := 20, |
| 497 | t3169 := 5, |
| 498 | t3191 := 5, |
| 499 | t3193_10ms := 160, |
| 500 | t3195 := 5, |
| 501 | t3101 := 10, |
| 502 | t3103 := 4, |
| 503 | t3105 := 8, |
| 504 | cv_countdown := 15, |
| 505 | dl_tbf_ext := 250 * 10, /* ms */ |
| 506 | ul_tbf_ext := 250 * 10, /* ms */ |
| 507 | initial_cs := 2, |
| 508 | initial_mcs := 6, |
| 509 | nsvci := { mp_nsconfig.nsvci, 0 }, |
| 510 | local_pprt := { mp_nsconfig.remote_udp_port, 0 }, |
| 511 | remote_port := { mp_nsconfig.local_udp_port, 0 }, |
| 512 | remote_ip := { f_inet_haddr(mp_nsconfig.local_ip), '00000000'O } |
| 513 | }; |
| 514 | |
| 515 | vc_PCUIF.start(f_PCUIF_CT_handler(mp_pcu_sock_path)); |
| 516 | vc_BTS.start(f_BTS_CT_handler(0, info_ind)); |
| 517 | |
| 518 | /* Wait until the BTS is ready (SI13 negotiated) */ |
| 519 | BTS.receive(tr_RAW_PCU_EV(BTS_EV_SI13_NEGO)); |
| 520 | } |
| 521 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 522 | |
| 523 | control { |
| 524 | execute( TC_ns_reset() ); |
| 525 | execute( TC_ns_reset_retrans() ); |
| 526 | execute( TC_ns_alive() ); |
| 527 | execute( TC_ns_alive_timeout_reset() ); |
| 528 | execute( TC_ns_unblock() ); |
| 529 | execute( TC_ns_unblock_retrans() ); |
| 530 | execute( TC_ns_full_bringup() ); |
| 531 | execute( TC_ns_so_block() ); |
Harald Welte | 7fd25cf | 2019-03-21 22:14:02 +0100 | [diff] [blame] | 532 | |
| 533 | execute( TC_pcuif_suspend() ); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 534 | } |
| 535 | |
| 536 | |
| 537 | |
| 538 | |
| 539 | |
| 540 | |
| 541 | } |