Harald Welte | f7b7407 | 2019-02-20 20:48:50 +0100 | [diff] [blame] | 1 | module PCU_Tests_RAW_SNS { |
| 2 | |
| 3 | import from Osmocom_Types all; |
| 4 | import from PCU_Tests all; |
| 5 | import from PCU_Tests_RAW all; |
Harald Welte | c4d7beb | 2019-02-21 18:21:01 +0100 | [diff] [blame] | 6 | import from Osmocom_Gb_Types all; |
| 7 | import from NS_CodecPort all; |
| 8 | import from NS_Types all; |
Harald Welte | f7b7407 | 2019-02-20 20:48:50 +0100 | [diff] [blame] | 9 | |
| 10 | /********************************************************************************** |
| 11 | * Modern Gb/IP bring-up test cases using IP Sub-Network Service (SNS) |
| 12 | **********************************************************************************/ |
| 13 | |
Harald Welte | c4d7beb | 2019-02-21 18:21:01 +0100 | [diff] [blame] | 14 | /* perform inbound SNS-SIZE procedure */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 15 | function f_incoming_sns_size(template (omit) NsCause cause := omit, integer idx := 0) |
| 16 | runs on RAW_NS_CT { |
Harald Welte | b63c3a1 | 2019-02-22 23:27:12 +0100 | [diff] [blame] | 17 | log("f_incoming_sns_size(idx=", idx, ")"); |
Harald Welte | c4d7beb | 2019-02-21 18:21:01 +0100 | [diff] [blame] | 18 | var PDU_NS rx; |
| 19 | /* expect one single SNS-SIZE with RESET flag; one remote v4 EP; no v6 EP */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 20 | rx := f_ns_exp(tr_SNS_SIZE(g_nsconfig[idx].nsei, rst_flag := true, max_nsvcs := 8, |
| 21 | num_v4 := 4, num_v6 := omit), idx); |
| 22 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_SIZE_ACK(g_nsconfig[idx].nsei, cause))); |
Harald Welte | c4d7beb | 2019-02-21 18:21:01 +0100 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | /* perform outbound SNS-SIZE procedure */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 26 | function f_outgoing_sns_size(template (omit) NsCause cause := omit, integer idx:= 0) |
| 27 | runs on RAW_NS_CT { |
Harald Welte | b63c3a1 | 2019-02-22 23:27:12 +0100 | [diff] [blame] | 28 | log("f_outgoing_sns_size(idx=", idx, ")"); |
Harald Welte | c4d7beb | 2019-02-21 18:21:01 +0100 | [diff] [blame] | 29 | var PDU_NS rx; |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 30 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_SIZE(g_nsconfig[idx].nsei, rst_flag := true, max_nsvcs := 1, |
Harald Welte | c4d7beb | 2019-02-21 18:21:01 +0100 | [diff] [blame] | 31 | num_v4 := 1, num_v6 := omit) |
| 32 | )); |
| 33 | /* expect one single SNS-SIZE with RESET flag; one remote v4 EP; no v6 EP */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 34 | rx := f_ns_exp(tr_SNS_SIZE_ACK(g_nsconfig[idx].nsei, cause), idx); |
Harald Welte | c4d7beb | 2019-02-21 18:21:01 +0100 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | /* perform inbound SNS-CONFIG procedure */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 38 | function f_incoming_sns_config(template (omit) NsCause cause := omit, integer idx := 0) |
| 39 | runs on RAW_NS_CT { |
Harald Welte | b63c3a1 | 2019-02-22 23:27:12 +0100 | [diff] [blame] | 40 | log("f_incoming_sns_config(idx=", idx, ")"); |
Harald Welte | c4d7beb | 2019-02-21 18:21:01 +0100 | [diff] [blame] | 41 | var PDU_NS rx; |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 42 | rx := f_ns_exp(tr_SNS_CONFIG(g_nsconfig[idx].nsei, end_flag := true, v4 := ?), idx); |
| 43 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CONFIG_ACK(g_nsconfig[idx].nsei, cause))); |
Harald Welte | c4d7beb | 2019-02-21 18:21:01 +0100 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | /* perform outbound SNS-CONFIG procedure */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 47 | function f_outgoing_sns_config(template (omit) NsCause cause := omit, integer idx := 0) |
| 48 | runs on RAW_NS_CT { |
Harald Welte | b63c3a1 | 2019-02-22 23:27:12 +0100 | [diff] [blame] | 49 | log("f_outgoing_sns_config(idx=", idx, ")"); |
Harald Welte | c4d7beb | 2019-02-21 18:21:01 +0100 | [diff] [blame] | 50 | var PDU_NS rx; |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 51 | var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig[idx].local_ip, |
| 52 | g_nsconfig[idx].local_udp_port) } |
| 53 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CONFIG(g_nsconfig[idx].nsei, true, v4))); |
| 54 | rx := f_ns_exp(tr_SNS_CONFIG_ACK(g_nsconfig[idx].nsei, cause), idx); |
Harald Welte | c4d7beb | 2019-02-21 18:21:01 +0100 | [diff] [blame] | 55 | } |
| 56 | |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 57 | /* perform outbound SNS-CONFIG procedure (separate endpoints: 1 for control, 1 for user */ |
| 58 | function f_outgoing_sns_config_1c1u(template (omit) NsCause cause := omit, integer idx := 0) |
| 59 | runs on RAW_NS_CT { |
Harald Welte | b63c3a1 | 2019-02-22 23:27:12 +0100 | [diff] [blame] | 60 | log("f_outgoing_sns_config_1c1u(idx=", idx, ")"); |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 61 | var PDU_NS rx; |
| 62 | var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig[0].local_ip, |
| 63 | g_nsconfig[0].local_udp_port, 1, 0), |
| 64 | ts_SNS_IPv4(g_nsconfig[1].local_ip, |
| 65 | g_nsconfig[1].local_udp_port, 0, 1) }; |
| 66 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CONFIG(g_nsconfig[idx].nsei, true, v4))); |
| 67 | rx := f_ns_exp(tr_SNS_CONFIG_ACK(g_nsconfig[idx].nsei, cause), idx); |
| 68 | } |
| 69 | |
Harald Welte | 630d0e6 | 2019-02-22 23:26:40 +0100 | [diff] [blame] | 70 | function f_outgoing_sns_add(integer idx_add, uint8_t w_sig := 1, uint8_t w_user := 1, integer idx := 0) |
| 71 | runs on RAW_NS_CT { |
| 72 | log("f_outgoing_sns_add(idx_add=", idx_add, ")"); |
| 73 | var PDU_NS rx; |
| 74 | var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig[idx_add].local_ip, |
| 75 | g_nsconfig[idx_add].local_udp_port, |
| 76 | w_sig, w_user) }; |
| 77 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_ADD(g_nsconfig[idx].nsei, 23, v4))); |
| 78 | rx := f_ns_exp(tr_SNS_ACK(g_nsconfig[idx].nsei, 23, omit, v4)); |
| 79 | } |
| 80 | |
| 81 | function f_outgoing_sns_del(integer idx_del, uint8_t w_sig := 1, uint8_t w_user := 1, integer idx := 0) |
| 82 | runs on RAW_NS_CT { |
| 83 | log("f_outgoing_sns_del(idx_del=", idx_del, ")"); |
| 84 | var PDU_NS rx; |
| 85 | var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig[idx_del].local_ip, |
| 86 | g_nsconfig[idx_del].local_udp_port, |
| 87 | w_sig, w_user) }; |
| 88 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_DEL(g_nsconfig[idx].nsei, 24, omit, v4))); |
| 89 | rx := f_ns_exp(tr_SNS_ACK(g_nsconfig[idx].nsei, 24, omit, v4)); |
| 90 | } |
| 91 | |
Harald Welte | 7209955 | 2019-02-23 15:09:22 +0100 | [diff] [blame] | 92 | function f_outgoing_sns_chg_weight(integer idx_chg, uint8_t w_sig, uint8_t w_user, integer idx := 0) |
| 93 | runs on RAW_NS_CT { |
| 94 | log("f_outgoing_sns_chg_weight(idx_chg=", idx_chg, ")"); |
| 95 | var PDU_NS rx; |
| 96 | var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig[idx_chg].local_ip, |
| 97 | g_nsconfig[idx_chg].local_udp_port, |
| 98 | w_sig, w_user) }; |
| 99 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CHG_WEIGHT(g_nsconfig[idx].nsei, 25, v4))); |
| 100 | rx := f_ns_exp(tr_SNS_ACK(g_nsconfig[idx].nsei, 25, omit, v4)); |
| 101 | } |
| 102 | |
| 103 | |
| 104 | |
Harald Welte | 630d0e6 | 2019-02-22 23:26:40 +0100 | [diff] [blame] | 105 | |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 106 | |
Harald Welte | f7b7407 | 2019-02-20 20:48:50 +0100 | [diff] [blame] | 107 | /* PCU-originated SNS-SIZE: successful case */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 108 | testcase TC_sns_po_size_success() runs on RAW_Test_CT { |
Harald Welte | f7b7407 | 2019-02-20 20:48:50 +0100 | [diff] [blame] | 109 | f_init_ns_codec(); |
| 110 | f_init_pcuif(); |
| 111 | f_incoming_sns_size(); |
| 112 | f_sleep(1.0); |
| 113 | setverdict(pass); |
| 114 | } |
| 115 | |
| 116 | /* PCU-originated SNS-SIZE: NACK from our side */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 117 | testcase TC_sns_po_size_nack() runs on RAW_Test_CT { |
Harald Welte | f7b7407 | 2019-02-20 20:48:50 +0100 | [diff] [blame] | 118 | f_init_ns_codec(); |
| 119 | f_init_pcuif(); |
| 120 | f_incoming_sns_size(NS_CAUSE_PROTOCOL_ERROR_UNSPEIFIED); |
| 121 | /* FIXME: ensure we don't get a SNS-CONFIG */ |
| 122 | /* FIXME: ensure we get re-transmitted SNS-SIZE attempts */ |
| 123 | f_sleep(10.0); |
| 124 | setverdict(pass); |
| 125 | } |
| 126 | |
| 127 | /* PCU-originated SNS-CONFIG: successful case */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 128 | testcase TC_sns_po_config_success() runs on RAW_Test_CT { |
Harald Welte | f7b7407 | 2019-02-20 20:48:50 +0100 | [diff] [blame] | 129 | f_init_ns_codec(); |
| 130 | f_init_pcuif(); |
| 131 | f_incoming_sns_size(); |
| 132 | f_incoming_sns_config(); |
| 133 | f_sleep(1.0); |
| 134 | setverdict(pass); |
| 135 | } |
| 136 | |
| 137 | /* PCU-originated SNS-CONFIG: successful case */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 138 | testcase TC_sns_po_config_nack() runs on RAW_Test_CT { |
Harald Welte | f7b7407 | 2019-02-20 20:48:50 +0100 | [diff] [blame] | 139 | f_init_ns_codec(); |
| 140 | f_init_pcuif(); |
| 141 | f_incoming_sns_size(); |
| 142 | f_incoming_sns_config(NS_CAUSE_PROTOCOL_ERROR_UNSPEIFIED); |
| 143 | /* FIXME: ensure we get re-transmitted SNS-CONFIG attempts */ |
| 144 | f_sleep(10.0); |
| 145 | setverdict(pass); |
| 146 | } |
| 147 | |
| 148 | |
| 149 | /* SGSN-originated SNS-SIZE: successful case */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 150 | testcase TC_sns_so_config_success() runs on RAW_Test_CT { |
Harald Welte | f7b7407 | 2019-02-20 20:48:50 +0100 | [diff] [blame] | 151 | f_init_ns_codec(); |
| 152 | f_init_pcuif(); |
| 153 | f_incoming_sns_size(); |
| 154 | f_incoming_sns_config(); |
| 155 | f_outgoing_sns_config(); |
| 156 | |
| 157 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
| 158 | as_rx_alive_tx_ack(oneshot := true); |
| 159 | activate(as_rx_alive_tx_ack()); |
| 160 | |
| 161 | f_outgoing_ns_alive(); |
| 162 | |
| 163 | /* Expect BVC-RESET for signaling (0) and ptp BVCI */ |
| 164 | as_rx_bvc_reset_tx_ack(0, oneshot := true); |
| 165 | as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvci, oneshot := true); |
| 166 | as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvci, oneshot := true); |
| 167 | |
| 168 | /* wait for one FLOW-CONTROL BVC and then ACK any further in the future */ |
Harald Welte | 630d0e6 | 2019-02-22 23:26:40 +0100 | [diff] [blame] | 169 | as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, oneshot := true, idx := 1); |
| 170 | activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, idx := 1)); |
Harald Welte | f7b7407 | 2019-02-20 20:48:50 +0100 | [diff] [blame] | 171 | setverdict(pass); |
| 172 | } |
| 173 | |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 174 | private function f_sns_bringup_1c1u() runs on RAW_Test_CT { |
Harald Welte | 630d0e6 | 2019-02-22 23:26:40 +0100 | [diff] [blame] | 175 | /* Activate two NS codec ports */ |
| 176 | f_init_ns_codec(); |
| 177 | f_init_ns_codec(1); |
| 178 | f_init_pcuif(); |
| 179 | /* Perform Size + BSS-originated config */ |
| 180 | f_incoming_sns_size(); |
| 181 | f_incoming_sns_config(); |
| 182 | /* perform SGSN-originated config using idx==0 for signalling and idx==1 for user traffic */ |
| 183 | f_outgoing_sns_config_1c1u(); |
| 184 | |
| 185 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background |
| 186 | * for both NS-VCs */ |
| 187 | as_rx_alive_tx_ack(oneshot := true, idx := 0); |
| 188 | activate(as_rx_alive_tx_ack(idx := 0)); |
| 189 | as_rx_alive_tx_ack(oneshot := true, idx := 1); |
| 190 | activate(as_rx_alive_tx_ack(idx := 1)); |
| 191 | |
| 192 | /* perform outgoing ALIVE procedure for both NS-VCs */ |
| 193 | f_outgoing_ns_alive(0); |
| 194 | f_outgoing_ns_alive(1); |
| 195 | |
| 196 | /* Expect BVC-RESET for signaling (0) and ptp BVCI */ |
| 197 | as_rx_bvc_reset_tx_ack(0, oneshot := true); |
| 198 | as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvci, oneshot := true); |
| 199 | /* Expect UNBLOCK for ptp BVCI on signaling NS-VC (idx==0) */ |
| 200 | as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvci, oneshot := true); |
| 201 | |
| 202 | /* wait for one FLOW-CONTROL BVC and then ACK any further in the future. Flow |
| 203 | * control happens on the p-t-p BVCI and hence on index 1 */ |
| 204 | as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, oneshot := true, idx := 1); |
| 205 | activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, idx := 1)); |
| 206 | } |
| 207 | |
| 208 | /* Test full IP-SNS bring-up with two NS-VCs, one sig-only and one user-only */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 209 | testcase TC_sns_1c1u() runs on RAW_Test_CT { |
Harald Welte | 630d0e6 | 2019-02-22 23:26:40 +0100 | [diff] [blame] | 210 | f_sns_bringup_1c1u(); |
| 211 | setverdict(pass); |
| 212 | } |
| 213 | |
| 214 | /* Test adding new IP endpoints at runtime */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 215 | testcase TC_sns_add() runs on RAW_Test_CT { |
Harald Welte | 630d0e6 | 2019-02-22 23:26:40 +0100 | [diff] [blame] | 216 | f_sns_bringup_1c1u(); |
| 217 | |
| 218 | /* crate another NS codec port on the tester side */ |
| 219 | f_init_ns_codec(2); |
| 220 | |
| 221 | f_outgoing_sns_add(idx_add := 2, w_sig := 0, w_user := 1, idx := 0); |
| 222 | |
| 223 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
| 224 | as_rx_alive_tx_ack(oneshot := true, idx := 2); |
| 225 | activate(as_rx_alive_tx_ack(idx := 2)); |
| 226 | |
| 227 | f_outgoing_ns_alive(2); |
| 228 | /* TODO: Should we expect FLOW-CONTROL BVC here too? */ |
| 229 | setverdict(pass); |
| 230 | } |
| 231 | |
| 232 | /* Test deleting IP endpoints at runtime */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 233 | testcase TC_sns_del() runs on RAW_Test_CT { |
Harald Welte | 630d0e6 | 2019-02-22 23:26:40 +0100 | [diff] [blame] | 234 | f_sns_bringup_1c1u(); |
| 235 | |
| 236 | f_outgoing_sns_del(idx_del := 1, w_sig := 0, w_user := 1, idx := 0); |
| 237 | /* FIXME: ensure we don't receive anything on just-deleted NS-VC anymore */ |
| 238 | setverdict(pass); |
| 239 | } |
| 240 | |
Harald Welte | 7209955 | 2019-02-23 15:09:22 +0100 | [diff] [blame] | 241 | /* Test changing weights at runtime */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 242 | testcase TC_sns_chg_weight() runs on RAW_Test_CT { |
Harald Welte | 7209955 | 2019-02-23 15:09:22 +0100 | [diff] [blame] | 243 | f_sns_bringup_1c1u(); |
| 244 | |
| 245 | /* change w_user from 1 to 200 */ |
| 246 | f_outgoing_sns_chg_weight(idx_chg := 1, w_sig := 0, w_user := 200, idx := 0); |
| 247 | setverdict(pass); |
| 248 | } |
| 249 | |
Harald Welte | 16e92f4 | 2019-03-02 00:03:44 +0100 | [diff] [blame] | 250 | import from PCUIF_Types all; |
| 251 | import from PCUIF_CodecPort all; |
| 252 | |
| 253 | private function f_pcuif_tx(template (value) PCUIF_Message msg) runs on RAW_PCU_CT { |
| 254 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, msg)); |
| 255 | } |
| 256 | |
| 257 | testcase TC_pcuif_rach() runs on RAW_Test_CT { |
| 258 | f_sns_bringup_1c1u(); |
| 259 | |
| 260 | f_pcuif_tx(ts_PCUIF_RACH_IND(bts_nr:=0, ra:=23, is_11bit:=0, burst_type:=BURST_TYPE_0, |
| 261 | fn:=42, arfcn:=871, qta:=0)); |
| 262 | PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 263 | tr_PCUIF_DATA_REQ(bts_nr:=0, trx_nr:=0, ts_nr:=0, block_nr:=?, fn:=?, |
| 264 | sapi:=PCU_IF_SAPI_AGCH, data:=?))); |
| 265 | setverdict(pass); |
| 266 | } |
| 267 | |
Harald Welte | 630d0e6 | 2019-02-22 23:26:40 +0100 | [diff] [blame] | 268 | |
| 269 | |
Harald Welte | f7b7407 | 2019-02-20 20:48:50 +0100 | [diff] [blame] | 270 | control { |
| 271 | execute( TC_sns_po_size_success() ); |
| 272 | execute( TC_sns_po_size_nack() ); |
| 273 | execute( TC_sns_po_config_success() ); |
| 274 | execute( TC_sns_po_config_nack() ); |
| 275 | execute( TC_sns_so_config_success() ); |
Harald Welte | 630d0e6 | 2019-02-22 23:26:40 +0100 | [diff] [blame] | 276 | execute( TC_sns_1c1u() ); |
| 277 | execute( TC_sns_add() ); |
| 278 | execute( TC_sns_del() ); |
Harald Welte | 7209955 | 2019-02-23 15:09:22 +0100 | [diff] [blame] | 279 | execute( TC_sns_chg_weight() ); |
Harald Welte | 16e92f4 | 2019-03-02 00:03:44 +0100 | [diff] [blame] | 280 | |
| 281 | execute( TC_pcuif_rach() ); |
Harald Welte | f7b7407 | 2019-02-20 20:48:50 +0100 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | } |