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