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 | |
| 92 | |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 93 | |
Harald Welte | f7b7407 | 2019-02-20 20:48:50 +0100 | [diff] [blame] | 94 | /* PCU-originated SNS-SIZE: successful case */ |
| 95 | testcase TC_sns_po_size_success() runs on RAW_NS_CT { |
| 96 | f_init_ns_codec(); |
| 97 | f_init_pcuif(); |
| 98 | f_incoming_sns_size(); |
| 99 | f_sleep(1.0); |
| 100 | setverdict(pass); |
| 101 | } |
| 102 | |
| 103 | /* PCU-originated SNS-SIZE: NACK from our side */ |
| 104 | testcase TC_sns_po_size_nack() runs on RAW_NS_CT { |
| 105 | f_init_ns_codec(); |
| 106 | f_init_pcuif(); |
| 107 | f_incoming_sns_size(NS_CAUSE_PROTOCOL_ERROR_UNSPEIFIED); |
| 108 | /* FIXME: ensure we don't get a SNS-CONFIG */ |
| 109 | /* FIXME: ensure we get re-transmitted SNS-SIZE attempts */ |
| 110 | f_sleep(10.0); |
| 111 | setverdict(pass); |
| 112 | } |
| 113 | |
| 114 | /* PCU-originated SNS-CONFIG: successful case */ |
| 115 | testcase TC_sns_po_config_success() runs on RAW_NS_CT { |
| 116 | f_init_ns_codec(); |
| 117 | f_init_pcuif(); |
| 118 | f_incoming_sns_size(); |
| 119 | f_incoming_sns_config(); |
| 120 | f_sleep(1.0); |
| 121 | setverdict(pass); |
| 122 | } |
| 123 | |
| 124 | /* PCU-originated SNS-CONFIG: successful case */ |
| 125 | testcase TC_sns_po_config_nack() runs on RAW_NS_CT { |
| 126 | f_init_ns_codec(); |
| 127 | f_init_pcuif(); |
| 128 | f_incoming_sns_size(); |
| 129 | f_incoming_sns_config(NS_CAUSE_PROTOCOL_ERROR_UNSPEIFIED); |
| 130 | /* FIXME: ensure we get re-transmitted SNS-CONFIG attempts */ |
| 131 | f_sleep(10.0); |
| 132 | setverdict(pass); |
| 133 | } |
| 134 | |
| 135 | |
| 136 | /* SGSN-originated SNS-SIZE: successful case */ |
| 137 | testcase TC_sns_so_config_success() runs on RAW_NS_CT { |
| 138 | f_init_ns_codec(); |
| 139 | f_init_pcuif(); |
| 140 | f_incoming_sns_size(); |
| 141 | f_incoming_sns_config(); |
| 142 | f_outgoing_sns_config(); |
| 143 | |
| 144 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
| 145 | as_rx_alive_tx_ack(oneshot := true); |
| 146 | activate(as_rx_alive_tx_ack()); |
| 147 | |
| 148 | f_outgoing_ns_alive(); |
| 149 | |
| 150 | /* Expect BVC-RESET for signaling (0) and ptp BVCI */ |
| 151 | as_rx_bvc_reset_tx_ack(0, oneshot := true); |
| 152 | as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvci, oneshot := true); |
| 153 | as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvci, oneshot := true); |
| 154 | |
| 155 | /* 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^] | 156 | as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, oneshot := true, idx := 1); |
| 157 | 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] | 158 | setverdict(pass); |
| 159 | } |
| 160 | |
Harald Welte | 630d0e6 | 2019-02-22 23:26:40 +0100 | [diff] [blame^] | 161 | private function f_sns_bringup_1c1u() runs on RAW_NS_CT { |
| 162 | /* Activate two NS codec ports */ |
| 163 | f_init_ns_codec(); |
| 164 | f_init_ns_codec(1); |
| 165 | f_init_pcuif(); |
| 166 | /* Perform Size + BSS-originated config */ |
| 167 | f_incoming_sns_size(); |
| 168 | f_incoming_sns_config(); |
| 169 | /* perform SGSN-originated config using idx==0 for signalling and idx==1 for user traffic */ |
| 170 | f_outgoing_sns_config_1c1u(); |
| 171 | |
| 172 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background |
| 173 | * for both NS-VCs */ |
| 174 | as_rx_alive_tx_ack(oneshot := true, idx := 0); |
| 175 | activate(as_rx_alive_tx_ack(idx := 0)); |
| 176 | as_rx_alive_tx_ack(oneshot := true, idx := 1); |
| 177 | activate(as_rx_alive_tx_ack(idx := 1)); |
| 178 | |
| 179 | /* perform outgoing ALIVE procedure for both NS-VCs */ |
| 180 | f_outgoing_ns_alive(0); |
| 181 | f_outgoing_ns_alive(1); |
| 182 | |
| 183 | /* Expect BVC-RESET for signaling (0) and ptp BVCI */ |
| 184 | as_rx_bvc_reset_tx_ack(0, oneshot := true); |
| 185 | as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvci, oneshot := true); |
| 186 | /* Expect UNBLOCK for ptp BVCI on signaling NS-VC (idx==0) */ |
| 187 | as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvci, oneshot := true); |
| 188 | |
| 189 | /* wait for one FLOW-CONTROL BVC and then ACK any further in the future. Flow |
| 190 | * control happens on the p-t-p BVCI and hence on index 1 */ |
| 191 | as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, oneshot := true, idx := 1); |
| 192 | activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, idx := 1)); |
| 193 | } |
| 194 | |
| 195 | /* Test full IP-SNS bring-up with two NS-VCs, one sig-only and one user-only */ |
| 196 | testcase TC_sns_1c1u() runs on RAW_NS_CT { |
| 197 | f_sns_bringup_1c1u(); |
| 198 | setverdict(pass); |
| 199 | } |
| 200 | |
| 201 | /* Test adding new IP endpoints at runtime */ |
| 202 | testcase TC_sns_add() runs on RAW_NS_CT { |
| 203 | f_sns_bringup_1c1u(); |
| 204 | |
| 205 | /* crate another NS codec port on the tester side */ |
| 206 | f_init_ns_codec(2); |
| 207 | |
| 208 | f_outgoing_sns_add(idx_add := 2, w_sig := 0, w_user := 1, idx := 0); |
| 209 | |
| 210 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
| 211 | as_rx_alive_tx_ack(oneshot := true, idx := 2); |
| 212 | activate(as_rx_alive_tx_ack(idx := 2)); |
| 213 | |
| 214 | f_outgoing_ns_alive(2); |
| 215 | /* TODO: Should we expect FLOW-CONTROL BVC here too? */ |
| 216 | setverdict(pass); |
| 217 | } |
| 218 | |
| 219 | /* Test deleting IP endpoints at runtime */ |
| 220 | testcase TC_sns_del() runs on RAW_NS_CT { |
| 221 | f_sns_bringup_1c1u(); |
| 222 | |
| 223 | f_outgoing_sns_del(idx_del := 1, w_sig := 0, w_user := 1, idx := 0); |
| 224 | /* FIXME: ensure we don't receive anything on just-deleted NS-VC anymore */ |
| 225 | setverdict(pass); |
| 226 | } |
| 227 | |
| 228 | |
| 229 | |
Harald Welte | f7b7407 | 2019-02-20 20:48:50 +0100 | [diff] [blame] | 230 | control { |
| 231 | execute( TC_sns_po_size_success() ); |
| 232 | execute( TC_sns_po_size_nack() ); |
| 233 | execute( TC_sns_po_config_success() ); |
| 234 | execute( TC_sns_po_config_nack() ); |
| 235 | execute( TC_sns_so_config_success() ); |
Harald Welte | 630d0e6 | 2019-02-22 23:26:40 +0100 | [diff] [blame^] | 236 | execute( TC_sns_1c1u() ); |
| 237 | execute( TC_sns_add() ); |
| 238 | execute( TC_sns_del() ); |
Harald Welte | f7b7407 | 2019-02-20 20:48:50 +0100 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | } |