Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1 | module PCU_Tests_NS { |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 2 | |
| 3 | /* Osmocom PCU test suite for IP Sub-Network-Service (SNS) 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 | |
| 13 | import from General_Types all; |
| 14 | import from Osmocom_Types all; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 15 | import from PCU_Tests all; |
Pau Espin Pedrol | 0e6ed2e | 2020-04-29 14:33:13 +0200 | [diff] [blame] | 16 | import from SGSN_Components all; |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 17 | import from Osmocom_Gb_Types all; |
| 18 | import from NS_CodecPort all; |
| 19 | import from NS_Types all; |
| 20 | import from BSSGP_Types all; |
| 21 | import from UD_Types all; |
| 22 | import from NS_CodecPort all; |
| 23 | import from NS_CodecPort_CtrlFunct all; |
| 24 | import from NS_Emulation all; |
| 25 | import from Native_Functions all; |
| 26 | import from IPL4asp_Types all; |
| 27 | import from PCUIF_Types all; |
| 28 | import from PCUIF_CodecPort all; |
Alexander Couzens | 3c268da | 2020-09-07 04:25:05 +0200 | [diff] [blame] | 29 | import from RAW_NS all; |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 30 | |
Harald Welte | 23e2749 | 2020-10-09 12:15:18 +0200 | [diff] [blame] | 31 | modulepar { |
| 32 | /* tolerate CellID absence/presence in BVC-RESET in violation to spec */ |
| 33 | boolean mp_tolerate_bvc_reset_cellid := false; |
| 34 | } |
| 35 | |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 36 | type component RAW_PCU_CT { |
| 37 | /* PCUIF (we emulate the BTS part) */ |
| 38 | port PCUIF_CODEC_PT PCU; |
| 39 | var ConnectionId g_pcu_conn_id := -1; |
| 40 | } |
| 41 | |
| 42 | type component RAW_Test_CT extends RAW_NS_CT, RAW_PCU_CT { |
| 43 | } |
| 44 | |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 45 | function f_init_pcuif() runs on RAW_PCU_CT { |
| 46 | var PCUIF_info_ind info_ind; |
| 47 | map(self:PCU, system:PCU); |
| 48 | |
| 49 | |
| 50 | info_ind := valueof(ts_PCUIF_INFO_default); |
| 51 | |
| 52 | /* Connect the Unix Domain Socket */ |
| 53 | g_pcu_conn_id := f_pcuif_listen(PCU, mp_pcu_sock_path); |
| 54 | PCU.receive(UD_connected:?); |
| 55 | |
| 56 | /* Wait for PCU_VERSION and return INFO_IND */ |
| 57 | PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TXT_IND(0, PCU_VERSION, ?))); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 58 | /* FIXME: make sure to use parameters from mp_gb_cfg.bvc[0].cell_id in the PCU INFO IND */ |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 59 | var template PCUIF_Message info_ind_msg := ts_PCUIF_INFO_IND(0, info_ind); |
| 60 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, info_ind_msg)); |
| 61 | } |
| 62 | |
| 63 | function f_pcuif_tx(template (value) PCUIF_Message msg) runs on RAW_PCU_CT { |
| 64 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, msg)); |
| 65 | } |
| 66 | |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 67 | /* ensure no matching message is received within 'tout' */ |
| 68 | function f_ensure_no_ns(template PDU_NS ns := ?, integer idx := 0, float tout := 3.0) |
| 69 | runs on RAW_Test_CT { |
| 70 | timer T := tout; |
| 71 | T.start; |
| 72 | alt { |
| 73 | [] NSCP[idx].receive(t_NS_RecvFrom(ns)) { |
| 74 | setverdict(fail, "NS-ALIVE from unconfigured (possibly initial) endpoint"); |
| 75 | } |
| 76 | [] T.timeout { |
| 77 | setverdict(pass); |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 82 | /* test the NS-RESET procedure */ |
| 83 | testcase TC_ns_reset() runs on RAW_Test_CT { |
Alexander Couzens | 2beaa20 | 2020-09-11 20:08:41 +0200 | [diff] [blame] | 84 | f_init_ns_codec(mp_nsconfig); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 85 | f_init_pcuif(); |
| 86 | |
| 87 | |
| 88 | /* Expect inbound NS-RESET procedure */ |
| 89 | as_rx_ns_reset_ack(oneshot := true); |
| 90 | setverdict(pass); |
| 91 | } |
| 92 | |
| 93 | /* ensure NS-RESET are re-transmitted */ |
| 94 | testcase TC_ns_reset_retrans() runs on RAW_Test_CT { |
Alexander Couzens | 2beaa20 | 2020-09-11 20:08:41 +0200 | [diff] [blame] | 95 | f_init_ns_codec(mp_nsconfig); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 96 | f_init_pcuif(); |
| 97 | |
| 98 | var integer i; |
| 99 | for (i := 0; i < 3; i := i+1) { |
| 100 | NSCP[0].receive(t_NS_RecvFrom(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION, |
Harald Welte | 90f1974 | 2020-11-06 19:34:40 +0100 | [diff] [blame] | 101 | g_nsconfig[0].nsvc[0].nsvci, g_nsconfig[0].nsei))); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | /* Expect inbound NS-RESET procedure */ |
| 105 | as_rx_ns_reset_ack(oneshot := true); |
| 106 | setverdict(pass); |
| 107 | } |
| 108 | |
| 109 | /* test the inbound NS-ALIVE procedure after NS-RESET */ |
| 110 | testcase TC_ns_alive() runs on RAW_Test_CT { |
Alexander Couzens | 2beaa20 | 2020-09-11 20:08:41 +0200 | [diff] [blame] | 111 | f_init_ns_codec(mp_nsconfig); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 112 | f_init_pcuif(); |
| 113 | |
| 114 | /* Expect inbound NS-RESET procedure */ |
| 115 | as_rx_ns_reset_ack(oneshot := true); |
| 116 | |
Alexander Couzens | 355ab56 | 2020-07-26 22:04:33 +0200 | [diff] [blame] | 117 | alt { |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 118 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
Alexander Couzens | 355ab56 | 2020-07-26 22:04:33 +0200 | [diff] [blame] | 119 | [] NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE)) { setverdict(pass); }; |
| 120 | [] NSCP[0].receive(t_NS_RecvFrom(t_NS_UNBLOCK)) { repeat; } |
| 121 | } |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | /* Test for NS-RESET after NS-ALIVE timeout */ |
| 125 | testcase TC_ns_alive_timeout_reset() runs on RAW_Test_CT { |
Alexander Couzens | 2beaa20 | 2020-09-11 20:08:41 +0200 | [diff] [blame] | 126 | f_init_ns_codec(mp_nsconfig, guard_secs := 100.0); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 127 | f_init_pcuif(); |
| 128 | |
| 129 | /* Expect inbound NS-RESET procedure */ |
| 130 | as_rx_ns_reset_ack(oneshot := true); |
| 131 | |
| 132 | /* wait for at least one NS-ALIVE */ |
Alexander Couzens | 355ab56 | 2020-07-26 22:04:33 +0200 | [diff] [blame] | 133 | alt { |
| 134 | [] as_rx_alive_tx_ack(oneshot := true) { }; |
| 135 | [] NSCP[0].receive(t_NS_RecvFrom(t_NS_UNBLOCK)) { repeat; } |
| 136 | } |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 137 | |
| 138 | /* wait for NS-RESET to re-appear, ignoring any NS-ALIVE until then */ |
| 139 | alt { |
| 140 | [] as_rx_ns_reset_ack(oneshot := true) { setverdict(pass); } |
| 141 | [] NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE)) { repeat; } |
Alexander Couzens | 355ab56 | 2020-07-26 22:04:33 +0200 | [diff] [blame] | 142 | [] NSCP[0].receive(t_NS_RecvFrom(t_NS_UNBLOCK)) { repeat; } |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 143 | } |
| 144 | } |
| 145 | |
| 146 | /* test for NS-RESET/NS-ALIVE/NS-UNBLOCK */ |
| 147 | testcase TC_ns_unblock() runs on RAW_Test_CT { |
Alexander Couzens | 2beaa20 | 2020-09-11 20:08:41 +0200 | [diff] [blame] | 148 | f_init_ns_codec(mp_nsconfig); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 149 | f_init_pcuif(); |
| 150 | |
| 151 | /* Expect inbound NS-RESET procedure */ |
| 152 | as_rx_ns_reset_ack(oneshot := true); |
| 153 | |
Alexander Couzens | 355ab56 | 2020-07-26 22:04:33 +0200 | [diff] [blame] | 154 | /* keep it alive */ |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 155 | activate(as_rx_alive_tx_ack()); |
| 156 | |
| 157 | as_rx_ns_unblock_ack(oneshot := true); |
| 158 | setverdict(pass); |
| 159 | } |
| 160 | |
| 161 | /* test for NS-UNBLOCK re-transmissions */ |
| 162 | testcase TC_ns_unblock_retrans() runs on RAW_Test_CT { |
Alexander Couzens | 2beaa20 | 2020-09-11 20:08:41 +0200 | [diff] [blame] | 163 | f_init_ns_codec(mp_nsconfig); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 164 | f_init_pcuif(); |
| 165 | |
| 166 | /* Expect inbound NS-RESET procedure */ |
| 167 | as_rx_ns_reset_ack(oneshot := true); |
| 168 | |
Alexander Couzens | 355ab56 | 2020-07-26 22:04:33 +0200 | [diff] [blame] | 169 | /* keep it alive */ |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 170 | activate(as_rx_alive_tx_ack()); |
| 171 | |
| 172 | /* wait for first NS-UNBLOCK, don't respond */ |
| 173 | NSCP[0].receive(t_NS_RecvFrom(t_NS_UNBLOCK)); |
| 174 | |
| 175 | /* wait for re-transmission of NS-UNBLOCK */ |
| 176 | as_rx_ns_unblock_ack(oneshot := true); |
| 177 | setverdict(pass); |
| 178 | } |
| 179 | |
| 180 | /* full bring-up of the Gb link for NS and BSSGP layer up to BVC-FC */ |
| 181 | testcase TC_ns_full_bringup() runs on RAW_Test_CT { |
Alexander Couzens | 2beaa20 | 2020-09-11 20:08:41 +0200 | [diff] [blame] | 182 | f_init_ns_codec(mp_nsconfig); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 183 | f_init_pcuif(); |
| 184 | |
| 185 | /* Expect inbound NS-RESET procedure */ |
| 186 | as_rx_ns_reset_ack(oneshot := true); |
| 187 | |
Alexander Couzens | 355ab56 | 2020-07-26 22:04:33 +0200 | [diff] [blame] | 188 | /* keep it alive */ |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 189 | activate(as_rx_alive_tx_ack()); |
| 190 | |
| 191 | as_rx_ns_unblock_ack(oneshot := true); |
| 192 | |
| 193 | f_outgoing_ns_alive(); |
| 194 | |
| 195 | /* Expect BVC-RESET for signaling (0) and ptp BVCI */ |
Harald Welte | 23e2749 | 2020-10-09 12:15:18 +0200 | [diff] [blame] | 196 | if (mp_tolerate_bvc_reset_cellid) { |
Harald Welte | e97e3af | 2020-10-09 14:56:54 +0200 | [diff] [blame] | 197 | as_rx_bvc_reset_tx_ack(0, mp_gb_cfg.bvc[0].cell_id, omit, oneshot := true); |
Harald Welte | 23e2749 | 2020-10-09 12:15:18 +0200 | [diff] [blame] | 198 | } else { |
Harald Welte | e97e3af | 2020-10-09 14:56:54 +0200 | [diff] [blame] | 199 | as_rx_bvc_reset_tx_ack(0, omit, omit, oneshot := true); |
Harald Welte | 23e2749 | 2020-10-09 12:15:18 +0200 | [diff] [blame] | 200 | } |
Harald Welte | e97e3af | 2020-10-09 14:56:54 +0200 | [diff] [blame] | 201 | as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvc[0].bvci, mp_gb_cfg.bvc[0].cell_id, omit, oneshot := true); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 202 | as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 203 | |
| 204 | /* wait for one FLOW-CONTROL BVC and then ACK any further in the future */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 205 | as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true); |
| 206 | activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci)); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 207 | setverdict(pass); |
| 208 | } |
| 209 | |
| 210 | /* test outbound (SGSN-originated) NS-BLOCK procedure */ |
| 211 | testcase TC_ns_so_block() runs on RAW_Test_CT { |
Alexander Couzens | 2beaa20 | 2020-09-11 20:08:41 +0200 | [diff] [blame] | 212 | f_init_ns_codec(mp_nsconfig); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 213 | f_init_pcuif(); |
| 214 | |
| 215 | /* Expect inbound NS-RESET procedure */ |
| 216 | as_rx_ns_reset_ack(oneshot := true); |
| 217 | |
Alexander Couzens | 355ab56 | 2020-07-26 22:04:33 +0200 | [diff] [blame] | 218 | /* keep it alive */ |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 219 | activate(as_rx_alive_tx_ack()); |
| 220 | |
| 221 | as_rx_ns_unblock_ack(oneshot := true); |
| 222 | |
| 223 | f_outgoing_ns_alive(); |
| 224 | |
| 225 | f_outgoing_ns_block(NS_CAUSE_EQUIPMENT_FAILURE); |
| 226 | setverdict(pass); |
| 227 | } |
| 228 | |
| 229 | |
| 230 | control { |
| 231 | execute( TC_ns_reset() ); |
| 232 | execute( TC_ns_reset_retrans() ); |
| 233 | execute( TC_ns_alive() ); |
| 234 | execute( TC_ns_alive_timeout_reset() ); |
| 235 | execute( TC_ns_unblock() ); |
| 236 | execute( TC_ns_unblock_retrans() ); |
| 237 | execute( TC_ns_full_bringup() ); |
| 238 | execute( TC_ns_so_block() ); |
| 239 | } |
| 240 | |
| 241 | } |