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; |
| 33 | import from IPL4asp_Types all; |
| 34 | import from NS_CodecPort all; |
| 35 | import from NS_CodecPort_CtrlFunct all; |
| 36 | import from Native_Functions all; |
| 37 | import from PCU_Tests all; |
| 38 | |
| 39 | modulepar { |
| 40 | charstring mp_pcu_sock_path := PCU_SOCK_DEFAULT; |
| 41 | } |
| 42 | |
| 43 | type component RAW_NS_CT { |
| 44 | /* UDP port towards the bottom (IUT) */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 45 | port NS_CODEC_PT NSCP[4]; |
| 46 | var ConnectionId g_ns_conn_id[4] := {-1, -1, -1, -1}; |
| 47 | var NSConfiguration g_nsconfig[4]; |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 48 | timer g_T_guard; |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 49 | } |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 50 | |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 51 | type component RAW_PCU_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 52 | /* PCUIF (we emulate the BTS part) */ |
| 53 | port PCUIF_CODEC_PT PCU; |
| 54 | var ConnectionId g_pcu_conn_id := -1; |
| 55 | } |
| 56 | |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 57 | type component RAW_Test_CT extends RAW_NS_CT, RAW_PCU_CT { |
| 58 | } |
| 59 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 60 | private altstep as_Tguard() runs on RAW_NS_CT { |
| 61 | [] g_T_guard.timeout { |
| 62 | setverdict(fail, "Timeout of T_guard"); |
| 63 | mtc.stop; |
| 64 | } |
| 65 | } |
| 66 | |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 67 | function f_init_pcuif() runs on RAW_PCU_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 68 | map(self:PCU, system:PCU); |
| 69 | |
| 70 | /* Connect the Unix Domain Socket */ |
| 71 | g_pcu_conn_id := f_pcuif_listen(PCU, mp_pcu_sock_path); |
| 72 | PCU.receive(UD_connected:?); |
| 73 | |
| 74 | /* Wait for PCU_VERSION and return INFO_IND */ |
| 75 | PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TXT_IND(0, PCU_VERSION, ?))); |
| 76 | /* FIXME: make sure to use parameters from mp_gb_cfg.cell_id in the PCU INFO IND */ |
| 77 | var template PCUIF_Message info_ind := ts_PCUIF_INFO_IND(bts_nr := 0, |
| 78 | nsei := mp_nsconfig.nsei, |
| 79 | nsvci := mp_nsconfig.nsvci, |
| 80 | bvci := mp_gb_cfg.bvci, |
| 81 | local_port := mp_nsconfig.remote_udp_port, |
| 82 | remote_port := mp_nsconfig.local_udp_port, |
| 83 | remote_ip := f_inet_haddr(mp_nsconfig.local_ip) |
| 84 | ); |
| 85 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, info_ind)); |
| 86 | } |
| 87 | |
Harald Welte | 0466d16 | 2019-03-21 21:30:21 +0100 | [diff] [blame] | 88 | function f_pcuif_tx(template (value) PCUIF_Message msg) runs on RAW_PCU_CT { |
| 89 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, msg)); |
| 90 | } |
| 91 | |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 92 | 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] | 93 | var Result res; |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 94 | |
| 95 | if (not g_T_guard.running) { |
| 96 | g_T_guard.start(guard_secs); |
| 97 | activate(as_Tguard()); |
| 98 | } |
| 99 | |
| 100 | if (not isbound(g_nsconfig) or not isbound(g_nsconfig[idx])) { |
| 101 | /* copy most parts from mp_nsconfig */ |
| 102 | g_nsconfig[idx] := mp_nsconfig; |
| 103 | /* adjust those parts different for each NS-VC */ |
| 104 | g_nsconfig[idx].nsvci := mp_nsconfig.nsvci + idx; |
| 105 | g_nsconfig[idx].local_udp_port := mp_nsconfig.local_udp_port + idx; |
| 106 | } |
| 107 | |
| 108 | map(self:NSCP[idx], system:NSCP); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 109 | /* Connect the UDP socket */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 110 | log("connecting NSCP[", idx, "] to ", g_nsconfig[idx]); |
| 111 | res := f_IPL4_connect(NSCP[idx], g_nsconfig[idx].remote_ip, g_nsconfig[idx].remote_udp_port, |
| 112 | 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] | 113 | if (not ispresent(res.connId)) { |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 114 | 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] | 115 | mtc.stop; |
| 116 | } |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 117 | g_ns_conn_id[idx] := res.connId; |
| 118 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 119 | } |
| 120 | |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 121 | 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] | 122 | var NS_RecvFrom nrf; |
| 123 | log("f_ns_exp() expecting ", exp_rx); |
| 124 | alt { |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 125 | [] NSCP[idx].receive(t_NS_RecvFrom(exp_rx)) -> value nrf { } |
| 126 | [] NSCP[idx].receive { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 127 | setverdict(fail, "Received unexpected NS: ", nrf); |
| 128 | mtc.stop; |
| 129 | } |
| 130 | } |
| 131 | return nrf.msg; |
| 132 | } |
| 133 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 134 | /* perform outbound NS-ALIVE procedure */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 135 | function f_outgoing_ns_alive(integer idx := 0) runs on RAW_NS_CT { |
| 136 | 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] | 137 | alt { |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 138 | [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE_ACK)); |
| 139 | [] NSCP[idx].receive { repeat; } |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 140 | } |
| 141 | } |
| 142 | |
Harald Welte | ecd159e | 2019-03-16 13:36:07 +0100 | [diff] [blame] | 143 | /* perform outbound NS-ALIVE procedure */ |
| 144 | function f_outgoing_ns_alive_no_ack(integer idx := 0, float tout := 10.0) runs on RAW_NS_CT { |
| 145 | timer T := tout; |
| 146 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE)); |
| 147 | T.start; |
| 148 | alt { |
| 149 | [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE_ACK)) { |
| 150 | setverdict(fail, "Received unexpected NS-ALIVE ACK"); |
| 151 | } |
| 152 | [] NSCP[idx].receive { repeat; } |
| 153 | [] T.timeout { |
| 154 | setverdict(pass); |
| 155 | } |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | /* ensure no matching message is received within 'tout' */ |
| 160 | function f_ensure_no_ns(template PDU_NS ns := ?, integer idx := 0, float tout := 3.0) |
| 161 | runs on RAW_Test_CT { |
| 162 | timer T := tout; |
| 163 | T.start; |
| 164 | alt { |
| 165 | [] NSCP[idx].receive(t_NS_RecvFrom(ns)) { |
| 166 | setverdict(fail, "NS-ALIVE from unconfigured (possibly initial) endpoint"); |
| 167 | } |
| 168 | [] T.timeout { |
| 169 | setverdict(pass); |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 174 | /* perform outbound NS-BLOCK procedure */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 175 | function f_outgoing_ns_block(NsCause cause, integer idx := 0) runs on RAW_NS_CT { |
| 176 | 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] | 177 | alt { |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 178 | [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_BLOCK_ACK(g_nsconfig[idx].nsvci))); |
| 179 | [] NSCP[idx].receive { repeat; } |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 180 | } |
| 181 | } |
| 182 | |
| 183 | /* receive NS-ALIVE and ACK it */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 184 | altstep as_rx_alive_tx_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT { |
| 185 | [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE)) { |
| 186 | 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] | 187 | if (not oneshot) { repeat; } |
| 188 | } |
| 189 | } |
| 190 | |
Harald Welte | 64d0731 | 2019-03-20 09:48:39 +0100 | [diff] [blame] | 191 | /* Transmit BSSGP RESET for given BVCI and expect ACK */ |
| 192 | function f_tx_bvc_reset_rx_ack(BssgpBvci bvci, integer idx := 0, boolean exp_ack := true) |
| 193 | runs on RAW_NS_CT { |
| 194 | var PDU_BSSGP bssgp_tx := valueof(ts_BVC_RESET(BSSGP_CAUSE_NET_SV_CAP_MOD_GT_ZERO_KBPS, bvci, |
| 195 | mp_gb_cfg.cell_id)); |
| 196 | timer T := 5.0; |
| 197 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx)))); |
| 198 | T.start; |
| 199 | alt { |
| 200 | [exp_ack] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0, |
| 201 | decmatch tr_BVC_RESET_ACK(bvci, ?)))) { |
| 202 | setverdict(pass); |
| 203 | } |
| 204 | [exp_ack] T.timeout { |
| 205 | setverdict(fail, "No response to BVC-RESET"); |
| 206 | } |
| 207 | [not exp_ack] T.timeout { |
| 208 | setverdict(pass); |
| 209 | } |
| 210 | [] NSCP[idx].receive { repeat; } |
| 211 | } |
| 212 | } |
| 213 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 214 | /* Receive a BSSGP RESET for given BVCI and ACK it */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 215 | 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] | 216 | var NS_RecvFrom ns_rf; |
| 217 | /* FIXME: nail down received cell_id in match */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 218 | [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0, |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 219 | decmatch tr_BVC_RESET(?, bvci, ?)))) |
| 220 | -> value ns_rf { |
| 221 | var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU); |
| 222 | 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] | 223 | 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] | 224 | if (not oneshot) { repeat; } |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | |
| 229 | /* Receive a BSSGP UNBLOCK for given BVCI and ACK it */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 230 | 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] | 231 | var NS_RecvFrom ns_rf; |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 232 | [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0, |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 233 | decmatch t_BVC_UNBLOCK(bvci)))) |
| 234 | -> value ns_rf { |
| 235 | var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU); |
| 236 | var PDU_BSSGP bssgp_tx := valueof(t_BVC_UNBLOCK_ACK(bvci)); |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 237 | 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] | 238 | if (not oneshot) { repeat; } |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | /* Receive a BSSGP FLOW-CONTROL-BVC and ACK it */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 243 | 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] | 244 | var NS_RecvFrom ns_rf; |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 245 | [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, bvci, |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 246 | decmatch tr_BVC_FC_BVC))) |
| 247 | -> value ns_rf { |
| 248 | var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU); |
| 249 | var OCT1 tag := bssgp_rx.pDU_BSSGP_FLOW_CONTROL_BVC.tag.unstructured_Value; |
| 250 | var PDU_BSSGP bssgp_tx := valueof(t_BVC_FC_BVC_ACK(tag)); |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 251 | 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] | 252 | if (not oneshot) { repeat; } |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | /********************************************************************************** |
| 257 | * Classic Gb/IP bring-up test cases using NS-{RESET,BLOCK,UNBLOCK} and no IP-SNS * |
| 258 | **********************************************************************************/ |
| 259 | |
| 260 | /* Receive a NS-RESET and ACK it */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 261 | 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] | 262 | var NS_RecvFrom ns_rf; |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 263 | [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION, g_nsconfig[idx].nsvci, |
| 264 | g_nsconfig[idx].nsei))) -> value ns_rf { |
| 265 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_RESET_ACK(g_nsconfig[idx].nsvci, |
| 266 | g_nsconfig[idx].nsei))); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 267 | if (not oneshot) { repeat; } |
| 268 | } |
| 269 | } |
| 270 | /* Receive a NS-UNBLOCK and ACK it */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 271 | 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] | 272 | var NS_RecvFrom ns_rf; |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 273 | [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_UNBLOCK)) -> value ns_rf { |
| 274 | 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] | 275 | if (not oneshot) { repeat; } |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | /* test the NS-RESET procedure */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 280 | testcase TC_ns_reset() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 281 | f_init_ns_codec(); |
| 282 | f_init_pcuif(); |
| 283 | |
| 284 | |
| 285 | /* Expect inbound NS-RESET procedure */ |
| 286 | as_rx_ns_reset_ack(oneshot := true); |
| 287 | setverdict(pass); |
| 288 | } |
| 289 | |
| 290 | /* ensure NS-RESET are re-transmitted */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 291 | testcase TC_ns_reset_retrans() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 292 | f_init_ns_codec(); |
| 293 | f_init_pcuif(); |
| 294 | |
| 295 | var integer i; |
| 296 | for (i := 0; i < 3; i := i+1) { |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 297 | NSCP[0].receive(t_NS_RecvFrom(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION, |
| 298 | g_nsconfig[0].nsvci, g_nsconfig[0].nsei))); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | /* Expect inbound NS-RESET procedure */ |
| 302 | as_rx_ns_reset_ack(oneshot := true); |
| 303 | setverdict(pass); |
| 304 | } |
| 305 | |
| 306 | /* test the inbound NS-ALIVE procedure after NS-RESET */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 307 | testcase TC_ns_alive() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 308 | f_init_ns_codec(); |
| 309 | f_init_pcuif(); |
| 310 | |
| 311 | /* Expect inbound NS-RESET procedure */ |
| 312 | as_rx_ns_reset_ack(oneshot := true); |
| 313 | |
| 314 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
| 315 | as_rx_alive_tx_ack(oneshot := true); |
| 316 | setverdict(pass); |
| 317 | } |
| 318 | |
| 319 | /* Test for NS-RESET after NS-ALIVE timeout */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 320 | testcase TC_ns_alive_timeout_reset() runs on RAW_Test_CT { |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 321 | f_init_ns_codec(guard_secs := 100.0); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 322 | f_init_pcuif(); |
| 323 | |
| 324 | /* Expect inbound NS-RESET procedure */ |
| 325 | as_rx_ns_reset_ack(oneshot := true); |
| 326 | |
| 327 | /* wait for at least one NS-ALIVE */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 328 | NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE)); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 329 | |
| 330 | /* wait for NS-RESET to re-appear, ignoring any NS-ALIVE until then */ |
| 331 | alt { |
| 332 | [] as_rx_ns_reset_ack(oneshot := true) { setverdict(pass); } |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 333 | [] NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE)) { repeat; } |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 334 | } |
| 335 | } |
| 336 | |
| 337 | /* test for NS-RESET/NS-ALIVE/NS-UNBLOCK */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 338 | testcase TC_ns_unblock() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 339 | f_init_ns_codec(); |
| 340 | f_init_pcuif(); |
| 341 | |
| 342 | /* Expect inbound NS-RESET procedure */ |
| 343 | as_rx_ns_reset_ack(oneshot := true); |
| 344 | |
| 345 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
| 346 | as_rx_alive_tx_ack(oneshot := true); |
| 347 | activate(as_rx_alive_tx_ack()); |
| 348 | |
| 349 | as_rx_ns_unblock_ack(oneshot := true); |
| 350 | setverdict(pass); |
| 351 | } |
| 352 | |
| 353 | /* test for NS-UNBLOCK re-transmissions */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 354 | testcase TC_ns_unblock_retrans() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 355 | f_init_ns_codec(); |
| 356 | f_init_pcuif(); |
| 357 | |
| 358 | /* Expect inbound NS-RESET procedure */ |
| 359 | as_rx_ns_reset_ack(oneshot := true); |
| 360 | |
| 361 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
| 362 | as_rx_alive_tx_ack(oneshot := true); |
| 363 | activate(as_rx_alive_tx_ack()); |
| 364 | |
| 365 | /* wait for first NS-UNBLOCK, don't respond */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 366 | NSCP[0].receive(t_NS_RecvFrom(t_NS_UNBLOCK)); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 367 | |
| 368 | /* wait for re-transmission of NS-UNBLOCK */ |
| 369 | as_rx_ns_unblock_ack(oneshot := true); |
| 370 | setverdict(pass); |
| 371 | } |
| 372 | |
| 373 | /* 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] | 374 | testcase TC_ns_full_bringup() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 375 | f_init_ns_codec(); |
| 376 | f_init_pcuif(); |
| 377 | |
| 378 | /* Expect inbound NS-RESET procedure */ |
| 379 | as_rx_ns_reset_ack(oneshot := true); |
| 380 | |
| 381 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
| 382 | as_rx_alive_tx_ack(oneshot := true); |
| 383 | activate(as_rx_alive_tx_ack()); |
| 384 | |
| 385 | as_rx_ns_unblock_ack(oneshot := true); |
| 386 | |
| 387 | f_outgoing_ns_alive(); |
| 388 | |
| 389 | /* Expect BVC-RESET for signaling (0) and ptp BVCI */ |
| 390 | as_rx_bvc_reset_tx_ack(0, oneshot := true); |
| 391 | as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvci, oneshot := true); |
| 392 | as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvci, oneshot := true); |
| 393 | |
| 394 | /* wait for one FLOW-CONTROL BVC and then ACK any further in the future */ |
| 395 | as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, oneshot := true); |
| 396 | activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci)); |
| 397 | setverdict(pass); |
| 398 | } |
| 399 | |
| 400 | /* test outbound (SGSN-originated) NS-BLOCK procedure */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 401 | testcase TC_ns_so_block() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 402 | f_init_ns_codec(); |
| 403 | f_init_pcuif(); |
| 404 | |
| 405 | /* Expect inbound NS-RESET procedure */ |
| 406 | as_rx_ns_reset_ack(oneshot := true); |
| 407 | |
| 408 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
| 409 | as_rx_alive_tx_ack(oneshot := true); |
| 410 | activate(as_rx_alive_tx_ack()); |
| 411 | |
| 412 | as_rx_ns_unblock_ack(oneshot := true); |
| 413 | |
| 414 | f_outgoing_ns_alive(); |
| 415 | |
| 416 | f_outgoing_ns_block(NS_CAUSE_EQUIPMENT_FAILURE); |
| 417 | setverdict(pass); |
| 418 | } |
| 419 | |
Harald Welte | 7fd25cf | 2019-03-21 22:14:02 +0100 | [diff] [blame] | 420 | /* Test component with PCUIF + BSSGP/NS Emulation (no L1CTL) */ |
| 421 | type component bssgp_pcuif_CT extends bssgp_CT, RAW_PCU_CT { |
| 422 | } |
| 423 | |
| 424 | testcase TC_pcuif_suspend() runs on bssgp_pcuif_CT { |
| 425 | var OCT6 ra_id := enc_RoutingAreaIdentification(mp_gb_cfg.cell_id.ra_id); |
| 426 | var GprsTlli tlli := 'FFFFFFFF'O; |
| 427 | |
| 428 | /* Initialize PCU interface side */ |
| 429 | f_init_pcuif(); |
| 430 | |
| 431 | /* Initialize NS/BSSGP side */ |
| 432 | f_init_bssgp(); |
| 433 | |
| 434 | f_sleep(1.0); |
| 435 | f_pcuif_tx(ts_PCUIF_SUSP_REQ(0, tlli, ra_id, 0)); |
Harald Welte | 955aa94 | 2019-05-03 01:29:29 +0200 | [diff] [blame] | 436 | 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] | 437 | |
| 438 | setverdict(pass); |
| 439 | } |
| 440 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 441 | |
| 442 | control { |
| 443 | execute( TC_ns_reset() ); |
| 444 | execute( TC_ns_reset_retrans() ); |
| 445 | execute( TC_ns_alive() ); |
| 446 | execute( TC_ns_alive_timeout_reset() ); |
| 447 | execute( TC_ns_unblock() ); |
| 448 | execute( TC_ns_unblock_retrans() ); |
| 449 | execute( TC_ns_full_bringup() ); |
| 450 | execute( TC_ns_so_block() ); |
Harald Welte | 7fd25cf | 2019-03-21 22:14:02 +0100 | [diff] [blame] | 451 | |
| 452 | execute( TC_pcuif_suspend() ); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 453 | } |
| 454 | |
| 455 | |
| 456 | |
| 457 | |
| 458 | |
| 459 | |
| 460 | } |