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> |
Vadim Yanitskiy | 3e1d318 | 2019-09-11 16:53:45 +0200 | [diff] [blame] | 10 | * (C) 2019 Vadim Yanitskiy <axilirator@gmail.com> |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 11 | * All rights reserved. |
| 12 | * |
| 13 | * Released under the terms of GNU General Public License, Version 2 or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 17 | */ |
| 18 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 19 | import from General_Types all; |
| 20 | import from Osmocom_Types all; |
Harald Welte | 7fd25cf | 2019-03-21 22:14:02 +0100 | [diff] [blame] | 21 | import from GSM_Types all; |
| 22 | import from GSM_RR_Types all; |
| 23 | |
Pau Espin Pedrol | 2a45a50 | 2019-11-29 12:48:16 +0100 | [diff] [blame] | 24 | import from Osmocom_VTY_Functions all; |
| 25 | import from TELNETasp_PortType all; |
| 26 | |
Vadim Yanitskiy | 0eb2662 | 2019-09-14 20:35:28 +0200 | [diff] [blame] | 27 | import from RLCMAC_CSN1_Types all; |
| 28 | import from RLCMAC_Types all; |
| 29 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 30 | import from NS_Types all; |
| 31 | import from BSSGP_Types all; |
| 32 | import from Osmocom_Gb_Types all; |
| 33 | |
| 34 | import from BSSGP_Emulation all; /* BssgpConfig */ |
| 35 | import from NS_Emulation all; /* NSConfiguration */ |
| 36 | |
| 37 | import from UD_Types all; |
| 38 | import from PCUIF_Types all; |
| 39 | import from PCUIF_CodecPort all; |
Vadim Yanitskiy | f7d9c0f | 2019-09-06 00:08:17 +0200 | [diff] [blame] | 40 | import from PCUIF_RAW_Components all; |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 41 | import from IPL4asp_Types all; |
| 42 | import from NS_CodecPort all; |
| 43 | import from NS_CodecPort_CtrlFunct all; |
| 44 | import from Native_Functions all; |
| 45 | import from PCU_Tests all; |
| 46 | |
| 47 | modulepar { |
| 48 | charstring mp_pcu_sock_path := PCU_SOCK_DEFAULT; |
Pau Espin Pedrol | a3f0a85 | 2019-12-02 19:16:26 +0100 | [diff] [blame] | 49 | |
| 50 | float X2002 := 0.2; /* Timer -2002, IMM ASSIGN confirm delay */ |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | type component RAW_NS_CT { |
| 54 | /* UDP port towards the bottom (IUT) */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 55 | port NS_CODEC_PT NSCP[4]; |
| 56 | var ConnectionId g_ns_conn_id[4] := {-1, -1, -1, -1}; |
| 57 | var NSConfiguration g_nsconfig[4]; |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 58 | timer g_T_guard; |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 59 | } |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 60 | |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 61 | type component RAW_PCU_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 62 | /* PCUIF (we emulate the BTS part) */ |
| 63 | port PCUIF_CODEC_PT PCU; |
| 64 | var ConnectionId g_pcu_conn_id := -1; |
| 65 | } |
| 66 | |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 67 | type component RAW_Test_CT extends RAW_NS_CT, RAW_PCU_CT { |
| 68 | } |
| 69 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 70 | private altstep as_Tguard() runs on RAW_NS_CT { |
| 71 | [] g_T_guard.timeout { |
| 72 | setverdict(fail, "Timeout of T_guard"); |
| 73 | mtc.stop; |
| 74 | } |
| 75 | } |
| 76 | |
Pau Espin Pedrol | f787b09 | 2019-10-04 18:34:05 +0200 | [diff] [blame] | 77 | /* FIXME: make sure to use parameters from mp_gb_cfg.cell_id in the PCU INFO IND */ |
| 78 | template (value) PCUIF_info_ind ts_PCUIF_INFO_default := { |
| 79 | version := PCU_IF_VERSION, |
| 80 | flags := c_PCUIF_Flags_default, |
| 81 | trx := valueof(ts_PCUIF_InfoTrxs_def), |
| 82 | bsic := 7, |
| 83 | mcc := 262, |
| 84 | mnc := 42, |
| 85 | mnc_3_digits := 0, |
| 86 | lac := 13135, |
| 87 | rac := 0, |
| 88 | nsei := mp_nsconfig.nsei, |
| 89 | nse_timer := { 3, 3, 3, 3, 30, 3, 10 }, |
| 90 | cell_timer := { 3, 3, 3, 3, 3, 10, 3, 10, 3, 10, 3 }, |
| 91 | cell_id := 20960, |
| 92 | repeat_time := 5 * 50, |
| 93 | repeat_count := 3, |
| 94 | bvci := mp_gb_cfg.bvci, |
| 95 | t3142 := 20, |
| 96 | t3169 := 5, |
| 97 | t3191 := 5, |
| 98 | t3193_10ms := 160, |
| 99 | t3195 := 5, |
| 100 | t3101 := 10, |
| 101 | t3103 := 4, |
| 102 | t3105 := 8, |
| 103 | cv_countdown := 15, |
| 104 | dl_tbf_ext := 250 * 10, /* ms */ |
| 105 | ul_tbf_ext := 250 * 10, /* ms */ |
| 106 | initial_cs := 2, |
| 107 | initial_mcs := 6, |
| 108 | nsvci := { mp_nsconfig.nsvci, 0 }, |
| 109 | local_pprt := { mp_nsconfig.remote_udp_port, 0 }, |
| 110 | remote_port := { mp_nsconfig.local_udp_port, 0 }, |
| 111 | remote_ip := { f_inet_haddr(mp_nsconfig.local_ip) , '00000000'O } |
| 112 | } |
| 113 | |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 114 | function f_init_pcuif() runs on RAW_PCU_CT { |
Pau Espin Pedrol | f787b09 | 2019-10-04 18:34:05 +0200 | [diff] [blame] | 115 | var PCUIF_info_ind info_ind; |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 116 | map(self:PCU, system:PCU); |
| 117 | |
Pau Espin Pedrol | f787b09 | 2019-10-04 18:34:05 +0200 | [diff] [blame] | 118 | |
| 119 | info_ind := valueof(ts_PCUIF_INFO_default); |
| 120 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 121 | /* Connect the Unix Domain Socket */ |
| 122 | g_pcu_conn_id := f_pcuif_listen(PCU, mp_pcu_sock_path); |
| 123 | PCU.receive(UD_connected:?); |
| 124 | |
| 125 | /* Wait for PCU_VERSION and return INFO_IND */ |
| 126 | PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TXT_IND(0, PCU_VERSION, ?))); |
| 127 | /* FIXME: make sure to use parameters from mp_gb_cfg.cell_id in the PCU INFO IND */ |
Pau Espin Pedrol | f787b09 | 2019-10-04 18:34:05 +0200 | [diff] [blame] | 128 | var template PCUIF_Message info_ind_msg := ts_PCUIF_INFO_IND(0, info_ind); |
| 129 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, info_ind_msg)); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 130 | } |
| 131 | |
Harald Welte | 0466d16 | 2019-03-21 21:30:21 +0100 | [diff] [blame] | 132 | function f_pcuif_tx(template (value) PCUIF_Message msg) runs on RAW_PCU_CT { |
| 133 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, msg)); |
| 134 | } |
| 135 | |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 136 | 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] | 137 | var Result res; |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 138 | |
| 139 | if (not g_T_guard.running) { |
| 140 | g_T_guard.start(guard_secs); |
| 141 | activate(as_Tguard()); |
| 142 | } |
| 143 | |
| 144 | if (not isbound(g_nsconfig) or not isbound(g_nsconfig[idx])) { |
| 145 | /* copy most parts from mp_nsconfig */ |
| 146 | g_nsconfig[idx] := mp_nsconfig; |
| 147 | /* adjust those parts different for each NS-VC */ |
| 148 | g_nsconfig[idx].nsvci := mp_nsconfig.nsvci + idx; |
| 149 | g_nsconfig[idx].local_udp_port := mp_nsconfig.local_udp_port + idx; |
| 150 | } |
| 151 | |
| 152 | map(self:NSCP[idx], system:NSCP); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 153 | /* Connect the UDP socket */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 154 | log("connecting NSCP[", idx, "] to ", g_nsconfig[idx]); |
| 155 | res := f_IPL4_connect(NSCP[idx], g_nsconfig[idx].remote_ip, g_nsconfig[idx].remote_udp_port, |
| 156 | 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] | 157 | if (not ispresent(res.connId)) { |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 158 | 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] | 159 | mtc.stop; |
| 160 | } |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 161 | g_ns_conn_id[idx] := res.connId; |
| 162 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 163 | } |
| 164 | |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 165 | 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] | 166 | var NS_RecvFrom nrf; |
| 167 | log("f_ns_exp() expecting ", exp_rx); |
| 168 | alt { |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 169 | [] NSCP[idx].receive(t_NS_RecvFrom(exp_rx)) -> value nrf { } |
| 170 | [] NSCP[idx].receive { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 171 | setverdict(fail, "Received unexpected NS: ", nrf); |
| 172 | mtc.stop; |
| 173 | } |
| 174 | } |
| 175 | return nrf.msg; |
| 176 | } |
| 177 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 178 | /* perform outbound NS-ALIVE procedure */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 179 | function f_outgoing_ns_alive(integer idx := 0) runs on RAW_NS_CT { |
| 180 | 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] | 181 | alt { |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 182 | [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE_ACK)); |
| 183 | [] NSCP[idx].receive { repeat; } |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 184 | } |
| 185 | } |
| 186 | |
Harald Welte | ecd159e | 2019-03-16 13:36:07 +0100 | [diff] [blame] | 187 | /* perform outbound NS-ALIVE procedure */ |
| 188 | function f_outgoing_ns_alive_no_ack(integer idx := 0, float tout := 10.0) runs on RAW_NS_CT { |
| 189 | timer T := tout; |
| 190 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE)); |
| 191 | T.start; |
| 192 | alt { |
| 193 | [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE_ACK)) { |
| 194 | setverdict(fail, "Received unexpected NS-ALIVE ACK"); |
| 195 | } |
| 196 | [] NSCP[idx].receive { repeat; } |
| 197 | [] T.timeout { |
| 198 | setverdict(pass); |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | /* ensure no matching message is received within 'tout' */ |
| 204 | function f_ensure_no_ns(template PDU_NS ns := ?, integer idx := 0, float tout := 3.0) |
| 205 | runs on RAW_Test_CT { |
| 206 | timer T := tout; |
| 207 | T.start; |
| 208 | alt { |
| 209 | [] NSCP[idx].receive(t_NS_RecvFrom(ns)) { |
| 210 | setverdict(fail, "NS-ALIVE from unconfigured (possibly initial) endpoint"); |
| 211 | } |
| 212 | [] T.timeout { |
| 213 | setverdict(pass); |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 218 | /* perform outbound NS-BLOCK procedure */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 219 | function f_outgoing_ns_block(NsCause cause, integer idx := 0) runs on RAW_NS_CT { |
| 220 | 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] | 221 | alt { |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 222 | [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_BLOCK_ACK(g_nsconfig[idx].nsvci))); |
| 223 | [] NSCP[idx].receive { repeat; } |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 224 | } |
| 225 | } |
| 226 | |
| 227 | /* receive NS-ALIVE and ACK it */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 228 | altstep as_rx_alive_tx_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT { |
| 229 | [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE)) { |
| 230 | 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] | 231 | if (not oneshot) { repeat; } |
| 232 | } |
| 233 | } |
| 234 | |
Harald Welte | 64d0731 | 2019-03-20 09:48:39 +0100 | [diff] [blame] | 235 | /* Transmit BSSGP RESET for given BVCI and expect ACK */ |
| 236 | function f_tx_bvc_reset_rx_ack(BssgpBvci bvci, integer idx := 0, boolean exp_ack := true) |
| 237 | runs on RAW_NS_CT { |
| 238 | var PDU_BSSGP bssgp_tx := valueof(ts_BVC_RESET(BSSGP_CAUSE_NET_SV_CAP_MOD_GT_ZERO_KBPS, bvci, |
| 239 | mp_gb_cfg.cell_id)); |
| 240 | timer T := 5.0; |
| 241 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx)))); |
| 242 | T.start; |
| 243 | alt { |
| 244 | [exp_ack] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0, |
| 245 | decmatch tr_BVC_RESET_ACK(bvci, ?)))) { |
| 246 | setverdict(pass); |
| 247 | } |
| 248 | [exp_ack] T.timeout { |
| 249 | setverdict(fail, "No response to BVC-RESET"); |
| 250 | } |
| 251 | [not exp_ack] T.timeout { |
| 252 | setverdict(pass); |
| 253 | } |
| 254 | [] NSCP[idx].receive { repeat; } |
| 255 | } |
| 256 | } |
| 257 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 258 | /* Receive a BSSGP RESET for given BVCI and ACK it */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 259 | 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] | 260 | var NS_RecvFrom ns_rf; |
| 261 | /* FIXME: nail down received cell_id in match */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 262 | [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0, |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 263 | decmatch tr_BVC_RESET(?, bvci, ?)))) |
| 264 | -> value ns_rf { |
| 265 | var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU); |
| 266 | 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] | 267 | 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] | 268 | if (not oneshot) { repeat; } |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | |
| 273 | /* Receive a BSSGP UNBLOCK for given BVCI and ACK it */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 274 | 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] | 275 | var NS_RecvFrom ns_rf; |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 276 | [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0, |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 277 | decmatch t_BVC_UNBLOCK(bvci)))) |
| 278 | -> value ns_rf { |
| 279 | var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU); |
| 280 | var PDU_BSSGP bssgp_tx := valueof(t_BVC_UNBLOCK_ACK(bvci)); |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 281 | 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] | 282 | if (not oneshot) { repeat; } |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | /* Receive a BSSGP FLOW-CONTROL-BVC and ACK it */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 287 | 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] | 288 | var NS_RecvFrom ns_rf; |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 289 | [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, bvci, |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 290 | decmatch tr_BVC_FC_BVC))) |
| 291 | -> value ns_rf { |
| 292 | var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU); |
| 293 | var OCT1 tag := bssgp_rx.pDU_BSSGP_FLOW_CONTROL_BVC.tag.unstructured_Value; |
| 294 | var PDU_BSSGP bssgp_tx := valueof(t_BVC_FC_BVC_ACK(tag)); |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 295 | 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] | 296 | if (not oneshot) { repeat; } |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | /********************************************************************************** |
| 301 | * Classic Gb/IP bring-up test cases using NS-{RESET,BLOCK,UNBLOCK} and no IP-SNS * |
| 302 | **********************************************************************************/ |
| 303 | |
| 304 | /* Receive a NS-RESET and ACK it */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 305 | 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] | 306 | var NS_RecvFrom ns_rf; |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 307 | [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION, g_nsconfig[idx].nsvci, |
| 308 | g_nsconfig[idx].nsei))) -> value ns_rf { |
| 309 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_RESET_ACK(g_nsconfig[idx].nsvci, |
| 310 | g_nsconfig[idx].nsei))); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 311 | if (not oneshot) { repeat; } |
| 312 | } |
| 313 | } |
| 314 | /* Receive a NS-UNBLOCK and ACK it */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 315 | 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] | 316 | var NS_RecvFrom ns_rf; |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 317 | [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_UNBLOCK)) -> value ns_rf { |
| 318 | 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] | 319 | if (not oneshot) { repeat; } |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | /* test the NS-RESET procedure */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 324 | testcase TC_ns_reset() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 325 | f_init_ns_codec(); |
| 326 | f_init_pcuif(); |
| 327 | |
| 328 | |
| 329 | /* Expect inbound NS-RESET procedure */ |
| 330 | as_rx_ns_reset_ack(oneshot := true); |
| 331 | setverdict(pass); |
| 332 | } |
| 333 | |
| 334 | /* ensure NS-RESET are re-transmitted */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 335 | testcase TC_ns_reset_retrans() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 336 | f_init_ns_codec(); |
| 337 | f_init_pcuif(); |
| 338 | |
| 339 | var integer i; |
| 340 | for (i := 0; i < 3; i := i+1) { |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 341 | NSCP[0].receive(t_NS_RecvFrom(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION, |
| 342 | g_nsconfig[0].nsvci, g_nsconfig[0].nsei))); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | /* Expect inbound NS-RESET procedure */ |
| 346 | as_rx_ns_reset_ack(oneshot := true); |
| 347 | setverdict(pass); |
| 348 | } |
| 349 | |
| 350 | /* test the inbound NS-ALIVE procedure after NS-RESET */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 351 | testcase TC_ns_alive() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 352 | f_init_ns_codec(); |
| 353 | f_init_pcuif(); |
| 354 | |
| 355 | /* Expect inbound NS-RESET procedure */ |
| 356 | as_rx_ns_reset_ack(oneshot := true); |
| 357 | |
| 358 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
| 359 | as_rx_alive_tx_ack(oneshot := true); |
| 360 | setverdict(pass); |
| 361 | } |
| 362 | |
| 363 | /* Test for NS-RESET after NS-ALIVE timeout */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 364 | testcase TC_ns_alive_timeout_reset() runs on RAW_Test_CT { |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 365 | f_init_ns_codec(guard_secs := 100.0); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 366 | f_init_pcuif(); |
| 367 | |
| 368 | /* Expect inbound NS-RESET procedure */ |
| 369 | as_rx_ns_reset_ack(oneshot := true); |
| 370 | |
| 371 | /* wait for at least one NS-ALIVE */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 372 | NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE)); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 373 | |
| 374 | /* wait for NS-RESET to re-appear, ignoring any NS-ALIVE until then */ |
| 375 | alt { |
| 376 | [] as_rx_ns_reset_ack(oneshot := true) { setverdict(pass); } |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 377 | [] NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE)) { repeat; } |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 378 | } |
| 379 | } |
| 380 | |
| 381 | /* test for NS-RESET/NS-ALIVE/NS-UNBLOCK */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 382 | testcase TC_ns_unblock() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 383 | f_init_ns_codec(); |
| 384 | f_init_pcuif(); |
| 385 | |
| 386 | /* Expect inbound NS-RESET procedure */ |
| 387 | as_rx_ns_reset_ack(oneshot := true); |
| 388 | |
| 389 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
| 390 | as_rx_alive_tx_ack(oneshot := true); |
| 391 | activate(as_rx_alive_tx_ack()); |
| 392 | |
| 393 | as_rx_ns_unblock_ack(oneshot := true); |
| 394 | setverdict(pass); |
| 395 | } |
| 396 | |
| 397 | /* test for NS-UNBLOCK re-transmissions */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 398 | testcase TC_ns_unblock_retrans() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 399 | f_init_ns_codec(); |
| 400 | f_init_pcuif(); |
| 401 | |
| 402 | /* Expect inbound NS-RESET procedure */ |
| 403 | as_rx_ns_reset_ack(oneshot := true); |
| 404 | |
| 405 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
| 406 | as_rx_alive_tx_ack(oneshot := true); |
| 407 | activate(as_rx_alive_tx_ack()); |
| 408 | |
| 409 | /* wait for first NS-UNBLOCK, don't respond */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 410 | NSCP[0].receive(t_NS_RecvFrom(t_NS_UNBLOCK)); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 411 | |
| 412 | /* wait for re-transmission of NS-UNBLOCK */ |
| 413 | as_rx_ns_unblock_ack(oneshot := true); |
| 414 | setverdict(pass); |
| 415 | } |
| 416 | |
| 417 | /* 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] | 418 | testcase TC_ns_full_bringup() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 419 | f_init_ns_codec(); |
| 420 | f_init_pcuif(); |
| 421 | |
| 422 | /* Expect inbound NS-RESET procedure */ |
| 423 | as_rx_ns_reset_ack(oneshot := true); |
| 424 | |
| 425 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
| 426 | as_rx_alive_tx_ack(oneshot := true); |
| 427 | activate(as_rx_alive_tx_ack()); |
| 428 | |
| 429 | as_rx_ns_unblock_ack(oneshot := true); |
| 430 | |
| 431 | f_outgoing_ns_alive(); |
| 432 | |
| 433 | /* Expect BVC-RESET for signaling (0) and ptp BVCI */ |
| 434 | as_rx_bvc_reset_tx_ack(0, oneshot := true); |
| 435 | as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvci, oneshot := true); |
| 436 | as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvci, oneshot := true); |
| 437 | |
| 438 | /* wait for one FLOW-CONTROL BVC and then ACK any further in the future */ |
| 439 | as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, oneshot := true); |
| 440 | activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci)); |
| 441 | setverdict(pass); |
| 442 | } |
| 443 | |
| 444 | /* test outbound (SGSN-originated) NS-BLOCK procedure */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 445 | testcase TC_ns_so_block() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 446 | f_init_ns_codec(); |
| 447 | f_init_pcuif(); |
| 448 | |
| 449 | /* Expect inbound NS-RESET procedure */ |
| 450 | as_rx_ns_reset_ack(oneshot := true); |
| 451 | |
| 452 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
| 453 | as_rx_alive_tx_ack(oneshot := true); |
| 454 | activate(as_rx_alive_tx_ack()); |
| 455 | |
| 456 | as_rx_ns_unblock_ack(oneshot := true); |
| 457 | |
| 458 | f_outgoing_ns_alive(); |
| 459 | |
| 460 | f_outgoing_ns_block(NS_CAUSE_EQUIPMENT_FAILURE); |
| 461 | setverdict(pass); |
| 462 | } |
| 463 | |
Pau Espin Pedrol | 2a45a50 | 2019-11-29 12:48:16 +0100 | [diff] [blame] | 464 | type record lqual_range { |
| 465 | /* component reference to the IPA_Client component used for RSL */ |
| 466 | uint8_t low, |
| 467 | uint8_t high |
| 468 | } |
| 469 | |
Vadim Yanitskiy | f7d9c0f | 2019-09-06 00:08:17 +0200 | [diff] [blame] | 470 | type component RAW_PCU_Test_CT extends bssgp_CT { |
| 471 | /* Connection to the BTS component (one for now) */ |
| 472 | port RAW_PCU_MSG_PT BTS; |
| 473 | /* Connection to the PCUIF component */ |
| 474 | port RAW_PCU_MSG_PT PCUIF; |
Pau Espin Pedrol | 2a45a50 | 2019-11-29 12:48:16 +0100 | [diff] [blame] | 475 | /* VTY connection to the PCU */ |
| 476 | port TELNETasp_PT PCUVTY; |
| 477 | |
| 478 | /* Uplink CS/MCS thresholds, default from pcu_main.c: */ |
| 479 | var lqual_range g_cs_lqual_ranges[4] := {{low := 0, high := 6}, |
| 480 | {low := 5, high := 8}, |
| 481 | {low := 7, high := 13}, |
| 482 | {low := 12,high := 35}}; |
| 483 | var lqual_range g_mcs_lqual_ranges[9] := {{low := 0, high := 6}, |
| 484 | {low := 5, high := 8}, |
| 485 | {low := 7, high := 13}, |
| 486 | {low := 12,high := 15}, |
| 487 | {low := 14, high := 17}, |
| 488 | {low := 16, high := 18}, |
| 489 | {low := 17,high := 20}, |
| 490 | {low := 19, high := 24}, |
| 491 | {low := 23,high := 35}}; |
| 492 | var uint8_t g_cs_initial_dl := 1; |
| 493 | var uint8_t g_cs_initial_ul := 1; |
| 494 | var uint8_t g_mcs_initial_dl := 1; |
| 495 | var uint8_t g_mcs_initial_ul := 1; |
| 496 | var uint8_t g_cs_max_dl := 4; |
| 497 | var uint8_t g_cs_max_ul := 4; |
| 498 | var uint8_t g_mcs_max_dl := 9; |
| 499 | var uint8_t g_mcs_max_ul := 9; |
Vadim Yanitskiy | f7d9c0f | 2019-09-06 00:08:17 +0200 | [diff] [blame] | 500 | |
| 501 | /* Guard timeout */ |
| 502 | timer g_T_guard := 60.0; |
| 503 | }; |
| 504 | |
| 505 | private altstep as_Tguard_RAW() runs on RAW_PCU_Test_CT { |
| 506 | [] g_T_guard.timeout { |
| 507 | setverdict(fail, "Timeout of T_guard"); |
| 508 | mtc.stop; |
| 509 | } |
| 510 | } |
| 511 | |
Pau Espin Pedrol | 2a45a50 | 2019-11-29 12:48:16 +0100 | [diff] [blame] | 512 | private function f_pcuvty_set_allowed_cs_mcs() runs on RAW_PCU_Test_CT { |
| 513 | f_vty_config2(PCUVTY, {"pcu"}, "cs " & int2str(g_cs_initial_dl) & " " & int2str(g_cs_initial_ul)); |
| 514 | f_vty_config2(PCUVTY, {"pcu"}, "cs max " & int2str(g_cs_max_dl) & " " & int2str(g_cs_max_ul)); |
| 515 | |
| 516 | f_vty_config2(PCUVTY, {"pcu"}, "mcs " & int2str(g_mcs_initial_dl) & " " & int2str(g_mcs_initial_ul)); |
| 517 | f_vty_config2(PCUVTY, {"pcu"}, "mcs max " & int2str(g_mcs_max_dl) & " " & int2str(g_mcs_max_ul)); |
| 518 | } |
| 519 | |
| 520 | private function f_pcuvty_set_link_quality_ranges() runs on RAW_PCU_Test_CT { |
| 521 | var charstring cmd; |
| 522 | |
| 523 | cmd := "cs link-quality-ranges" & |
| 524 | " cs1 " & int2str(g_cs_lqual_ranges[0].high) & |
| 525 | " cs2 " & int2str(g_cs_lqual_ranges[1].low) & " " & int2str(g_cs_lqual_ranges[1].high) & |
| 526 | " cs3 " & int2str(g_cs_lqual_ranges[2].low) & " " & int2str(g_cs_lqual_ranges[2].high) & |
| 527 | " cs4 " & int2str(g_cs_lqual_ranges[3].low); |
| 528 | f_vty_config2(PCUVTY, {"pcu"}, cmd); |
| 529 | |
| 530 | cmd := "mcs link-quality-ranges" & |
| 531 | " mcs1 " & int2str(g_mcs_lqual_ranges[0].high) & |
| 532 | " mcs2 " & int2str(g_mcs_lqual_ranges[1].low) & " " & int2str(g_mcs_lqual_ranges[1].high) & |
| 533 | " mcs3 " & int2str(g_mcs_lqual_ranges[2].low) & " " & int2str(g_mcs_lqual_ranges[2].high) & |
| 534 | " mcs4 " & int2str(g_mcs_lqual_ranges[3].low) & " " & int2str(g_mcs_lqual_ranges[3].high) & |
| 535 | " mcs5 " & int2str(g_mcs_lqual_ranges[4].low) & " " & int2str(g_mcs_lqual_ranges[4].high) & |
| 536 | " mcs6 " & int2str(g_mcs_lqual_ranges[5].low) & " " & int2str(g_mcs_lqual_ranges[5].high) & |
| 537 | " mcs7 " & int2str(g_mcs_lqual_ranges[6].low) & " " & int2str(g_mcs_lqual_ranges[6].high) & |
| 538 | " mcs8 " & int2str(g_mcs_lqual_ranges[7].low) & " " & int2str(g_mcs_lqual_ranges[7].high) & |
| 539 | " mcs9 " & int2str(g_mcs_lqual_ranges[8].low); |
| 540 | f_vty_config2(PCUVTY, {"pcu"}, cmd); |
| 541 | } |
| 542 | |
| 543 | private function f_init_vty(charstring id) runs on RAW_PCU_Test_CT { |
| 544 | map(self:PCUVTY, system:PCUVTY); |
| 545 | f_vty_set_prompts(PCUVTY); |
| 546 | f_vty_transceive(PCUVTY, "enable"); |
| 547 | } |
| 548 | |
Pau Espin Pedrol | f787b09 | 2019-10-04 18:34:05 +0200 | [diff] [blame] | 549 | private function f_init_raw(charstring id, template (value) PCUIF_info_ind info_ind := ts_PCUIF_INFO_default) |
Vadim Yanitskiy | f7d9c0f | 2019-09-06 00:08:17 +0200 | [diff] [blame] | 550 | runs on RAW_PCU_Test_CT { |
Vadim Yanitskiy | f7d9c0f | 2019-09-06 00:08:17 +0200 | [diff] [blame] | 551 | var RAW_PCUIF_CT vc_PCUIF; |
| 552 | var RAW_PCU_BTS_CT vc_BTS; |
| 553 | |
| 554 | /* Start the guard timer */ |
| 555 | g_T_guard.start; |
| 556 | activate(as_Tguard_RAW()); |
| 557 | |
| 558 | /* Init PCU interface component */ |
| 559 | vc_PCUIF := RAW_PCUIF_CT.create("PCUIF-" & id); |
| 560 | connect(vc_PCUIF:MTC, self:PCUIF); |
| 561 | map(vc_PCUIF:PCU, system:PCU); |
| 562 | |
| 563 | /* Create one BTS component (we may want more some day) */ |
| 564 | vc_BTS := RAW_PCU_BTS_CT.create("BTS-" & id); |
| 565 | connect(vc_BTS:PCUIF, vc_PCUIF:BTS); |
| 566 | connect(vc_BTS:TC, self:BTS); |
| 567 | |
Pau Espin Pedrol | 2a45a50 | 2019-11-29 12:48:16 +0100 | [diff] [blame] | 568 | f_init_vty(id); |
| 569 | |
Vadim Yanitskiy | f7d9c0f | 2019-09-06 00:08:17 +0200 | [diff] [blame] | 570 | vc_PCUIF.start(f_PCUIF_CT_handler(mp_pcu_sock_path)); |
Pau Espin Pedrol | f787b09 | 2019-10-04 18:34:05 +0200 | [diff] [blame] | 571 | vc_BTS.start(f_BTS_CT_handler(0, valueof(info_ind))); |
Vadim Yanitskiy | f7d9c0f | 2019-09-06 00:08:17 +0200 | [diff] [blame] | 572 | |
| 573 | /* Wait until the BTS is ready (SI13 negotiated) */ |
| 574 | BTS.receive(tr_RAW_PCU_EV(BTS_EV_SI13_NEGO)); |
| 575 | } |
| 576 | |
Vadim Yanitskiy | 3e1d318 | 2019-09-11 16:53:45 +0200 | [diff] [blame] | 577 | /* FIXME: properly encode RA (see TS 24.060, table 11.2.5.2) */ |
| 578 | private function f_establish_tbf(out GsmRrMessage rr_imm_ass, uint8_t bts_nr := 0, |
| 579 | uint16_t ra := oct2int('3A'O), uint8_t is_11bit := 0, |
| 580 | PCUIF_BurstType burst_type := BURST_TYPE_0, |
| 581 | TimingAdvance ta := 0) |
| 582 | runs on RAW_PCU_Test_CT return boolean { |
| 583 | var PCUIF_Message pcu_msg; |
| 584 | var GsmRrMessage rr_msg; |
| 585 | var uint32_t fn; |
| 586 | timer T; |
| 587 | |
| 588 | /* FIXME: ask the BTS component to give us the current TDMA fn */ |
| 589 | fn := 1337 + ta; |
| 590 | |
| 591 | /* Send RACH.ind */ |
| 592 | log("Sending RACH.ind on fn=", fn, " with RA=", ra, ", TA=", ta); |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 593 | BTS.send(ts_PCUIF_RACH_IND(bts_nr := bts_nr, trx_nr := 0, ts_nr := 0, |
Vadim Yanitskiy | 3e1d318 | 2019-09-11 16:53:45 +0200 | [diff] [blame] | 594 | ra := ra, is_11bit := is_11bit, |
| 595 | burst_type := burst_type, |
| 596 | fn := fn, arfcn := 871, |
| 597 | qta := ta * 4)); |
| 598 | |
| 599 | /* Expect Immediate (TBF) Assignment on TS0/AGCH */ |
| 600 | T.start(2.0); |
| 601 | alt { |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 602 | [] BTS.receive(tr_PCUIF_DATA_REQ(bts_nr := bts_nr, trx_nr := 0, ts_nr := 0, |
Vadim Yanitskiy | 3e1d318 | 2019-09-11 16:53:45 +0200 | [diff] [blame] | 603 | sapi := PCU_IF_SAPI_AGCH, data := ?)) |
| 604 | -> value pcu_msg { |
| 605 | rr_imm_ass := dec_GsmRrMessage(pcu_msg.u.data_req.data); |
| 606 | log("Rx Immediate Assignment: ", rr_imm_ass); |
| 607 | |
| 608 | /* Make sure this assignment is for us |
| 609 | * TODO: Uplink or Downlink TBF? */ |
| 610 | if (match(rr_imm_ass, tr_IMM_TBF_ASS(?, ra, fn))) { |
| 611 | setverdict(pass); |
| 612 | return true; |
| 613 | } |
| 614 | |
| 615 | /* Not for us? Wait for more. */ |
| 616 | repeat; |
| 617 | } |
| 618 | [] BTS.receive { repeat; } |
| 619 | [] T.timeout { |
| 620 | setverdict(fail, "Timeout waiting for Immediate Assignment"); |
| 621 | } |
| 622 | } |
| 623 | |
| 624 | return false; |
| 625 | } |
| 626 | |
Pau Espin Pedrol | 6c1b4be | 2019-10-04 19:31:02 +0200 | [diff] [blame] | 627 | private function f_imm_ass_verify_ul_tbf_ass(GsmRrMessage rr_imm_ass, out PacketUlAssign ul_tbf_ass) |
| 628 | runs on RAW_PCU_Test_CT return boolean { |
| 629 | |
| 630 | /* Make sure we received an UL TBF Assignment */ |
| 631 | if (match(rr_imm_ass, tr_IMM_TBF_ASS(dl := false, rest := tr_IaRestOctets_ULAss(?)))) { |
| 632 | ul_tbf_ass := rr_imm_ass.payload.imm_ass.rest_octets.hh.pa.uldl.ass.ul; |
| 633 | log("Rx Uplink TBF assignment: ", ul_tbf_ass); |
| 634 | setverdict(pass); |
| 635 | } else { |
| 636 | setverdict(fail, "Failed to match UL TBF Assignment"); |
| 637 | return false; |
| 638 | } |
| 639 | |
| 640 | /* Make sure we have got a TBF with Dynamic Block Allocation */ |
| 641 | if (ul_tbf_ass.dynamic == omit) { |
| 642 | setverdict(fail, "Single Block Allocation is not handled by ", testcasename()); |
| 643 | return false; |
| 644 | } |
| 645 | |
| 646 | return true; |
| 647 | } |
| 648 | |
Pau Espin Pedrol | 1755fab | 2019-10-08 11:18:54 +0200 | [diff] [blame] | 649 | private function f_imm_ass_verify_dl_tbf_ass(GsmRrMessage rr_imm_ass, out PacketDlAssign dl_tbf_ass) |
| 650 | runs on RAW_PCU_Test_CT return boolean { |
| 651 | |
| 652 | /* Make sure we received a DL TBF Assignment */ |
| 653 | if (match(rr_imm_ass, tr_IMM_TBF_ASS(dl := true, rest := tr_IaRestOctets_DLAss(?)))) { |
| 654 | dl_tbf_ass := rr_imm_ass.payload.imm_ass.rest_octets.hh.pa.uldl.ass.dl; |
| 655 | log("Rx Downlink TBF assignment: ", dl_tbf_ass); |
| 656 | setverdict(pass); |
| 657 | } else { |
| 658 | setverdict(fail, "Failed to match DL TBF Assignment"); |
| 659 | return false; |
| 660 | } |
| 661 | |
| 662 | return true; |
| 663 | } |
| 664 | |
Pau Espin Pedrol | c3a7732 | 2019-10-03 19:40:08 +0200 | [diff] [blame] | 665 | /* Enqueue DATA.ind (both TDMA frame and block numbers to be patched) */ |
| 666 | private function f_pcuif_tx_data_ind(octetstring data, int16_t lqual_cb := 0) |
| 667 | runs on RAW_PCU_Test_CT { |
| 668 | |
| 669 | BTS.send(ts_PCUIF_DATA_IND(bts_nr := 0, trx_nr := 0, ts_nr := 7, block_nr := 0, |
| 670 | sapi := PCU_IF_SAPI_PDTCH, data := data, |
| 671 | fn := 0, arfcn := 871, lqual_cb := lqual_cb)); |
| 672 | BTS.receive(tr_RAW_PCU_EV(TDMA_EV_PDTCH_BLOCK_SENT)); |
| 673 | } |
| 674 | |
| 675 | /* Enqueue RTS.req, expect DATA.req with UL ACK from the PCU */ |
| 676 | private function f_pcuif_rx_data_req(out PCUIF_Message pcu_msg) |
| 677 | runs on RAW_PCU_Test_CT { |
| 678 | BTS.send(ts_PCUIF_RTS_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7, |
| 679 | sapi := PCU_IF_SAPI_PDTCH, fn := 0, |
| 680 | arfcn := 871, block_nr := 0)); |
| 681 | BTS.receive(tr_PCUIF_DATA_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7, |
| 682 | sapi := PCU_IF_SAPI_PDTCH)) -> value pcu_msg; |
| 683 | } |
| 684 | |
Pau Espin Pedrol | 1755fab | 2019-10-08 11:18:54 +0200 | [diff] [blame] | 685 | /* Expect an Immediate Assignment (paging) from PCU on PCUIF on specified sapi. */ |
| 686 | private function f_pcuif_rx_pch_imm_tbf_ass(out GsmRrMessage rr_imm_ass) |
| 687 | runs on RAW_PCU_Test_CT { |
| 688 | var PCUIF_Message pcu_msg; |
| 689 | var octetstring macblock; |
| 690 | BTS.receive(tr_PCUIF_DATA_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 0, |
| 691 | sapi := PCU_IF_SAPI_PCH)) -> value pcu_msg; |
| 692 | /* First 3 bytes contain paging group: */ |
| 693 | macblock := substr(pcu_msg.u.data_req.data, 3, pcu_msg.u.data_req.len - 3); |
| 694 | rr_imm_ass := dec_GsmRrMessage(macblock); |
| 695 | if (not match(rr_imm_ass, tr_IMM_TBF_ASS())) { |
| 696 | setverdict(fail, "Failed to match Immediate Assignment: ", rr_imm_ass); |
| 697 | mtc.stop; |
| 698 | } |
| 699 | BTS.send(ts_PCUIF_DATA_CNF(bts_nr := 0, trx_nr := 0, ts_nr := 0, block_nr := 0, |
| 700 | fn := 0, arfcn := 871, sapi := PCU_IF_SAPI_PCH, data := macblock)); |
| 701 | } |
| 702 | |
Pau Espin Pedrol | c3a7732 | 2019-10-03 19:40:08 +0200 | [diff] [blame] | 703 | private function f_tx_rlcmac_ul_block(template (value) RlcmacUlBlock ul_data, int16_t lqual_cb := 0) |
| 704 | runs on RAW_PCU_Test_CT { |
| 705 | var octetstring data; |
| 706 | /* Encode the payload of DATA.ind */ |
| 707 | data := enc_RlcmacUlBlock(valueof(ul_data)); |
| 708 | data := f_pad_oct(data, 23, '00'O); /* CS-1 */ |
| 709 | |
| 710 | /* Enqueue DATA.ind (both TDMA frame and block numbers to be patched) */ |
| 711 | f_pcuif_tx_data_ind(data, lqual_cb); |
| 712 | } |
| 713 | |
Pau Espin Pedrol | 596faa4 | 2019-10-04 19:31:29 +0200 | [diff] [blame] | 714 | private function f_tx_rlcmac_ul_n_blocks(PacketUlAssign ul_tbf_ass, integer num_blocks := 1) |
| 715 | runs on RAW_PCU_Test_CT { |
| 716 | var template (value) RlcmacUlBlock ul_data := t_RLCMAC_UL_DATA( |
| 717 | tfi := ul_tbf_ass.dynamic.tfi_assignment, |
| 718 | cv := num_blocks - 1, /* num UL blocks to be sent (to be overridden in loop) */ |
| 719 | bsn := 0, /* TODO: what should be here? */ |
| 720 | blocks := { /* To be generated in loop */ }); |
| 721 | |
| 722 | /* HACK: patch missing TLLI; otherwise OsmoPCU rejects DATA.req */ |
| 723 | ul_data.data.tlli := '00000001'O; |
| 724 | |
| 725 | for (var integer i := 0; i < num_blocks; i := i + 1) { |
| 726 | /* Prepare a new UL block (CV, random payload) */ |
| 727 | ul_data.data.mac_hdr.countdown := (num_blocks - i - 1); |
| 728 | ul_data.data.blocks := { valueof(t_RLCMAC_LLCBLOCK(f_rnd_octstring(10))) }; |
| 729 | f_tx_rlcmac_ul_block(ul_data); |
| 730 | } |
| 731 | } |
| 732 | |
Pau Espin Pedrol | c3a7732 | 2019-10-03 19:40:08 +0200 | [diff] [blame] | 733 | private function f_rx_rlcmac_dl_block(out RlcmacDlBlock dl_block) |
| 734 | runs on RAW_PCU_Test_CT { |
| 735 | var PCUIF_Message pcu_msg; |
| 736 | f_pcuif_rx_data_req(pcu_msg); |
| 737 | dl_block := dec_RlcmacDlBlock(pcu_msg.u.data_req.data); |
| 738 | } |
| 739 | |
| 740 | private function f_rx_rlcmac_dl_block_exp_ack_nack(out RlcmacDlBlock dl_block) |
| 741 | runs on RAW_PCU_Test_CT { |
| 742 | f_rx_rlcmac_dl_block(dl_block); |
Pau Espin Pedrol | 2165963 | 2019-12-02 19:12:08 +0100 | [diff] [blame] | 743 | if (not match(dl_block, tr_RLCMAC_UL_ACK_NACK(ul_tfi := ?, tlli := ?))) { |
Pau Espin Pedrol | c3a7732 | 2019-10-03 19:40:08 +0200 | [diff] [blame] | 744 | setverdict(fail, "Failed to match Packet Uplink ACK / NACK"); |
| 745 | mtc.stop; |
| 746 | } |
| 747 | } |
| 748 | |
Pau Espin Pedrol | 596faa4 | 2019-10-04 19:31:29 +0200 | [diff] [blame] | 749 | private function f_rx_rlcmac_dl_block_exp_dummy(out RlcmacDlBlock dl_block) |
| 750 | runs on RAW_PCU_Test_CT { |
| 751 | f_rx_rlcmac_dl_block(dl_block); |
| 752 | if (not match(dl_block, tr_RLCMAC_DUMMY_CTRL())) { |
| 753 | setverdict(fail, "Failed to match Packet DUMMY DL"); |
| 754 | mtc.stop; |
| 755 | } |
| 756 | } |
| 757 | |
Pau Espin Pedrol | a3f0a85 | 2019-12-02 19:16:26 +0100 | [diff] [blame] | 758 | private function f_rx_rlcmac_dl_block_exp_data(out RlcmacDlBlock dl_block, octetstring data) |
| 759 | runs on RAW_PCU_Test_CT { |
| 760 | var template RlcmacDlBlock dl_template := tr_RLCMAC_DATA_RRBP; |
| 761 | dl_template.data.blocks := ?; |
| 762 | /* TODO: match data correctly: { valueof(t_RLCMAC_LLCBLOCK(data)) }; */ |
| 763 | |
| 764 | f_rx_rlcmac_dl_block(dl_block); |
| 765 | if (not match(dl_block, dl_template)) { |
| 766 | setverdict(fail, "Failed to match Packet data: ", dl_block, " vs ", dl_template); |
| 767 | mtc.stop; |
| 768 | } |
| 769 | } |
| 770 | |
Vadim Yanitskiy | 740ae76 | 2019-09-29 16:13:41 +0700 | [diff] [blame] | 771 | testcase TC_pcuif_suspend() runs on RAW_PCU_Test_CT { |
| 772 | var octetstring ra_id := enc_RoutingAreaIdentification(mp_gb_cfg.cell_id.ra_id); |
| 773 | var GprsTlli tlli := 'FFFFFFFF'O; |
| 774 | timer T; |
| 775 | |
| 776 | /* Initialize NS/BSSGP side */ |
| 777 | f_init_bssgp(); |
| 778 | |
| 779 | /* Initialize the PCU interface abstraction */ |
| 780 | f_init_raw(testcasename()); |
| 781 | |
| 782 | /* Establish BSSGP connection to the PCU */ |
| 783 | f_bssgp_establish(); |
| 784 | |
| 785 | BTS.send(ts_PCUIF_SUSP_REQ(0, tlli, ra_id, 0)); |
| 786 | |
| 787 | T.start(2.0); |
| 788 | alt { |
| 789 | [] BSSGP_SIG[0].receive(tr_BSSGP_SUSPEND(tlli, mp_gb_cfg.cell_id.ra_id)) { |
| 790 | setverdict(pass); |
| 791 | } |
| 792 | [] T.timeout { |
| 793 | setverdict(fail, "Timeout waiting for BSSGP SUSPEND"); |
| 794 | } |
| 795 | } |
| 796 | } |
| 797 | |
Vadim Yanitskiy | 3e1d318 | 2019-09-11 16:53:45 +0200 | [diff] [blame] | 798 | /* Test of correct Timing Advance at the time of TBF establishment |
| 799 | * (derived from timing offset of the Access Burst). */ |
| 800 | testcase TC_ta_rach_imm_ass() runs on RAW_PCU_Test_CT { |
| 801 | var GsmRrMessage rr_msg; |
| 802 | var boolean ok; |
| 803 | |
| 804 | /* Initialize the PCU interface abstraction */ |
| 805 | f_init_raw(testcasename()); |
| 806 | |
| 807 | /* We cannot send too many TBF requests in a short time because |
| 808 | * at some point the PCU will fail to allocate a new TBF. */ |
| 809 | for (var TimingAdvance ta := 0; ta < 64; ta := ta + 16) { |
| 810 | /* Establish an Uplink TBF (send RACH.ind with current TA) */ |
| 811 | ok := f_establish_tbf(rr_msg, bts_nr := 0, ta := ta); |
| 812 | if (not ok) { |
| 813 | setverdict(fail, "Failed to establish an Uplink TBF"); |
| 814 | mtc.stop; |
| 815 | } |
| 816 | |
| 817 | /* Make sure Timing Advance IE matches out expectations */ |
| 818 | if (match(rr_msg, tr_IMM_TBF_ASS(dl := false, ta := ta))) { |
| 819 | setverdict(pass); |
| 820 | } |
| 821 | } |
| 822 | } |
| 823 | |
Vadim Yanitskiy | 1f72b0a | 2019-10-01 05:58:45 +0700 | [diff] [blame] | 824 | /* Verify that the PCU generates valid PTCCH/D messages |
| 825 | * while neither Uplink nor Downlink TBF is established. */ |
| 826 | testcase TC_ta_ptcch_idle() runs on RAW_PCU_Test_CT { |
| 827 | var PTCCHDownlinkMsg ptcch_msg; |
| 828 | var PCUIF_Message pcu_msg; |
| 829 | timer T; |
| 830 | |
| 831 | /* Initialize the PCU interface abstraction */ |
| 832 | f_init_raw(testcasename()); |
| 833 | |
| 834 | /* Sent an RTS.req for PTCCH/D */ |
| 835 | BTS.send(ts_PCUIF_RTS_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7, |
| 836 | sapi := PCU_IF_SAPI_PTCCH, fn := 0, |
| 837 | arfcn := 871, block_nr := 0)); |
| 838 | T.start(5.0); |
| 839 | alt { |
| 840 | [] BTS.receive(tr_PCUIF_DATA_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7, |
| 841 | sapi := PCU_IF_SAPI_PTCCH)) -> value pcu_msg { |
| 842 | log("Rx DATA.req message: ", pcu_msg); |
| 843 | setverdict(pass); |
| 844 | } |
| 845 | [] BTS.receive(PCUIF_Message:?) { repeat; } |
| 846 | [] T.timeout { |
| 847 | setverdict(fail, "Timeout waiting for a PTCCH/D block"); |
| 848 | mtc.stop; |
| 849 | } |
| 850 | } |
| 851 | |
| 852 | ptcch_msg := dec_PTCCHDownlinkMsg(pcu_msg.u.data_req.data); |
| 853 | log("Decoded PTCCH/D message: ", ptcch_msg); |
| 854 | |
| 855 | /* Make sure the message is encoded correctly |
| 856 | * TODO: do we expect all TA values to be equal '1111111'B? */ |
| 857 | if (not match(ptcch_msg, tr_PTCCHDownlinkMsg)) { |
| 858 | setverdict(fail, "Malformed PTCCH/D message"); |
| 859 | mtc.stop; |
| 860 | } |
| 861 | } |
| 862 | |
Vadim Yanitskiy | 02f77d8 | 2019-10-04 17:12:35 +0700 | [diff] [blame] | 863 | /* Test of correct Timing Advance during an active Uplink TBF. |
| 864 | * |
| 865 | * Unlike the circuit-switched domain, Uplink transmissions on PDCH time-slots |
| 866 | * are not continuous and there can be long time gaps between them. This happens |
| 867 | * due to a bursty nature of packet data. The actual Timing Advance of a MS may |
| 868 | * significantly change between such rare Uplink transmissions, so GPRS introduces |
| 869 | * additional mechanisms to control Timing Advance, and thus reduce interference |
| 870 | * between neighboring TDMA time-slots. |
| 871 | * |
| 872 | * At the moment of Uplink TBF establishment, initial Timing Advance is measured |
| 873 | * from ToA (Timing of Arrival) of an Access Burst. This is covered by another |
| 874 | * test case - TC_ta_rach_imm_ass. In response to that Access Burst the network |
| 875 | * sends Immediate Assignment on AGCH, which _may_ contain Timing Advance Index |
| 876 | * among with the initial Timing Advance value. And here PTCCH comes to play. |
| 877 | * |
| 878 | * PTCCH is a unidirectional channel on which the network can instruct a sub-set |
| 879 | * of 16 MS (whether TBFs are active or not) to adjust their Timing Advance |
| 880 | * continuously. To ensure continuous measurements of the signal propagation |
| 881 | * delay, the MSs shall transmit Access Bursts on Uplink (PTCCH/U) on sub-slots |
| 882 | * defined by an assigned Timing Advance Index (see 3GPP TS 45.002). |
| 883 | * |
| 884 | * The purpose of this test case is to verify the assignment of Timing Advance |
| 885 | * Index, and the process of Timing Advance notification on PTCCH/D. The MTC |
| 886 | * first establishes several Uplink TBFs, but does not transmit any Uplink |
| 887 | * blocks on them. During 4 TDMA multi-frame periods the MTC is sending RACH |
| 888 | * indications to the PCU, checking the correctness of two received PTCCH/D |
| 889 | * messages (period of PTCCH/D is two multi-frames). |
| 890 | */ |
Vadim Yanitskiy | 20f8700 | 2019-10-06 00:51:50 +0700 | [diff] [blame] | 891 | |
| 892 | /* List of ToA values for Access Bursts to be sent on PTCCH/U, |
| 893 | * each ToA (Timing of Arrival) value is in units of 1/4 of |
| 894 | * a symbol (i.e. 1 symbol is 4 QTA units). */ |
| 895 | type record length(16) of int16_t PTCCH_TAI_ToA_MAP; |
| 896 | const PTCCH_TAI_ToA_MAP ptcch_toa_map_def := { |
| 897 | 0, 0, 0, 0, |
| 898 | 0, 0, 0, 0, |
| 899 | 0, 0, 0, 0, |
| 900 | 0, 0, 0, 0 |
| 901 | }; |
| 902 | |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 903 | private altstep as_ta_ptcch(uint8_t bts_nr := 0, uint8_t trx_nr := 0, uint8_t ts_nr := 7, |
Vadim Yanitskiy | 20f8700 | 2019-10-06 00:51:50 +0700 | [diff] [blame] | 904 | in PTCCH_TAI_ToA_MAP toa_map := ptcch_toa_map_def) |
Vadim Yanitskiy | 02f77d8 | 2019-10-04 17:12:35 +0700 | [diff] [blame] | 905 | runs on RAW_PCU_Test_CT { |
Vadim Yanitskiy | 02f77d8 | 2019-10-04 17:12:35 +0700 | [diff] [blame] | 906 | var RAW_PCU_Event event; |
Vadim Yanitskiy | 20f8700 | 2019-10-06 00:51:50 +0700 | [diff] [blame] | 907 | var integer ss; |
Vadim Yanitskiy | 02f77d8 | 2019-10-04 17:12:35 +0700 | [diff] [blame] | 908 | |
| 909 | /* Send Access Bursts on PTCCH/U for every TA Index */ |
| 910 | [] BTS.receive(tr_RAW_PCU_EV(TDMA_EV_PTCCH_UL_BURST)) -> value event { |
Vadim Yanitskiy | 20f8700 | 2019-10-06 00:51:50 +0700 | [diff] [blame] | 911 | ss := f_tdma_ptcch_fn2ss(event.data.tdma_fn); |
| 912 | if (ss < 0) { mtc.stop; } /* Shall not happen */ |
| 913 | |
Vadim Yanitskiy | 02f77d8 | 2019-10-04 17:12:35 +0700 | [diff] [blame] | 914 | log("Sending an Access Burst on PTCCH/U", |
Vadim Yanitskiy | 20f8700 | 2019-10-06 00:51:50 +0700 | [diff] [blame] | 915 | ", sub-slot=", ss, " (TAI)", |
Vadim Yanitskiy | 02f77d8 | 2019-10-04 17:12:35 +0700 | [diff] [blame] | 916 | ", fn=", event.data.tdma_fn, |
Vadim Yanitskiy | 20f8700 | 2019-10-06 00:51:50 +0700 | [diff] [blame] | 917 | ", ToA=", toa_map[ss], " (QTA)"); |
Vadim Yanitskiy | 02f77d8 | 2019-10-04 17:12:35 +0700 | [diff] [blame] | 918 | /* TODO: do we care about RA and burst format? */ |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 919 | BTS.send(ts_PCUIF_RACH_IND(bts_nr, trx_nr, ts_nr, |
Vadim Yanitskiy | 02f77d8 | 2019-10-04 17:12:35 +0700 | [diff] [blame] | 920 | ra := oct2int('3A'O), |
| 921 | is_11bit := 0, |
| 922 | burst_type := BURST_TYPE_0, |
| 923 | fn := event.data.tdma_fn, |
| 924 | arfcn := 871, |
Vadim Yanitskiy | 20f8700 | 2019-10-06 00:51:50 +0700 | [diff] [blame] | 925 | qta := toa_map[ss], |
Vadim Yanitskiy | 02f77d8 | 2019-10-04 17:12:35 +0700 | [diff] [blame] | 926 | sapi := PCU_IF_SAPI_PTCCH)); |
Vadim Yanitskiy | 02f77d8 | 2019-10-04 17:12:35 +0700 | [diff] [blame] | 927 | repeat; |
| 928 | } |
| 929 | } |
| 930 | |
Vadim Yanitskiy | 20f8700 | 2019-10-06 00:51:50 +0700 | [diff] [blame] | 931 | private function f_TC_ta_ptcch_ul_multi_tbf(in PTCCH_TAI_ToA_MAP ptcch_toa_map, |
| 932 | template PTCCHDownlinkMsg t_ta_msg) |
Vadim Yanitskiy | 02f77d8 | 2019-10-04 17:12:35 +0700 | [diff] [blame] | 933 | runs on RAW_PCU_Test_CT { |
| 934 | var PTCCHDownlinkMsg ta_msg; |
| 935 | var PCUIF_Message pcu_msg; |
| 936 | timer T; |
| 937 | |
| 938 | /* First, send an RTS.req for the upcoming PTCCH/D block */ |
| 939 | BTS.send(ts_PCUIF_RTS_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7, |
| 940 | sapi := PCU_IF_SAPI_PTCCH, fn := 0, |
| 941 | arfcn := 871, block_nr := 0)); |
| 942 | T.start(2.0); |
| 943 | alt { |
| 944 | /* Keep sending of Access Bursts during two multi-frames (period of PTCCH/D) |
| 945 | * with increasing ToA (Timing of Arrival) values: 0, 7, 14, 28, 35... */ |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 946 | [] as_ta_ptcch(bts_nr := 0, trx_nr := 0, ts_nr := 7, toa_map := ptcch_toa_map); |
Vadim Yanitskiy | 02f77d8 | 2019-10-04 17:12:35 +0700 | [diff] [blame] | 947 | /* In the end of 2nd multi-frame we should receive a PTCCH/D block */ |
| 948 | [] BTS.receive(tr_PCUIF_DATA_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7, |
| 949 | sapi := PCU_IF_SAPI_PTCCH)) -> value pcu_msg { |
| 950 | ta_msg := dec_PTCCHDownlinkMsg(pcu_msg.u.data_req.data); |
| 951 | log("Rx PTCCH/D message: ", ta_msg); |
| 952 | |
| 953 | /* Make sure Timing Advance values match our expectations */ |
| 954 | if (match(ta_msg, t_ta_msg)) { |
| 955 | setverdict(pass); |
| 956 | } else { |
| 957 | setverdict(fail, "PTCCH/D message does not match: ", t_ta_msg); |
| 958 | } |
| 959 | } |
| 960 | [] BTS.receive { repeat; } |
| 961 | [] T.timeout { |
| 962 | setverdict(fail, "Timeout waiting for a PTCCH/D block"); |
| 963 | mtc.stop; |
| 964 | } |
| 965 | } |
| 966 | } |
| 967 | |
| 968 | testcase TC_ta_ptcch_ul_multi_tbf() runs on RAW_PCU_Test_CT { |
| 969 | var template PacketUlAssign t_ul_tbf_ass; |
| 970 | var PacketUlAssign ul_tbf_ass[7]; |
| 971 | var GsmRrMessage rr_msg[7]; |
| 972 | var boolean ok; |
| 973 | |
| 974 | /* Initialize the PCU interface abstraction */ |
| 975 | f_init_raw(testcasename()); |
| 976 | |
| 977 | /* Enable forwarding of PTCCH/U TDMA events to us */ |
| 978 | BTS.send(ts_RAW_PCU_CMD(TDMA_CMD_ENABLE_PTCCH_UL_FWD)); |
| 979 | |
| 980 | /* Establish 7 Uplink TBFs (USF flag is 3 bits long, '111'B is reserved) */ |
| 981 | for (var integer i := 0; i < 7; i := i + 1) { |
| 982 | ok := f_establish_tbf(rr_msg[i], ta := 0); |
| 983 | if (not ok) { |
| 984 | setverdict(fail, "Failed to establish an Uplink TBF #", i); |
| 985 | mtc.stop; |
| 986 | } |
| 987 | |
| 988 | /* Make sure we received an UL TBF Assignment */ |
| 989 | if (match(rr_msg[i], tr_IMM_TBF_ASS(dl := false, rest := tr_IaRestOctets_ULAss(?)))) { |
| 990 | ul_tbf_ass[i] := rr_msg[i].payload.imm_ass.rest_octets.hh.pa.uldl.ass.ul; |
| 991 | log("Rx Uplink TBF assignment for #", i, ": ", ul_tbf_ass[i]); |
| 992 | } else { |
| 993 | setverdict(fail, "Failed to match UL TBF Assignment for #", i); |
| 994 | mtc.stop; |
| 995 | } |
| 996 | |
| 997 | /* We expect incremental TFI/USF assignment (dynamic allocation) */ |
| 998 | t_ul_tbf_ass := tr_PacketUlDynAssign(tfi := i, usf := i); |
| 999 | if (not match(ul_tbf_ass[i], t_ul_tbf_ass)) { |
| 1000 | setverdict(fail, "Failed to match Packet Uplink Assignment for #", i); |
| 1001 | mtc.stop; |
| 1002 | } |
| 1003 | |
| 1004 | /* We also expect Timing Advance Index to be a part of the assignment */ |
| 1005 | if (ul_tbf_ass[i].dynamic.ta_index != i) { |
| 1006 | setverdict(fail, "Failed to match Timing Advance Index for #", i); |
| 1007 | /* Keep going, the current OsmoPCU does not assign TA Index */ |
| 1008 | } |
| 1009 | } |
| 1010 | |
Vadim Yanitskiy | 20f8700 | 2019-10-06 00:51:50 +0700 | [diff] [blame] | 1011 | /* Prepare a list of ToA values for Access Bursts to be sent on PTCCH/U */ |
| 1012 | var PTCCH_TAI_ToA_MAP toa_map := ptcch_toa_map_def; |
| 1013 | for (var integer i := 0; i < 7; i := i + 1) { |
| 1014 | /* ToA in units of 1/4 of a symbol */ |
| 1015 | toa_map[i] := (i + 1) * 7 * 4; |
| 1016 | } |
| 1017 | |
Vadim Yanitskiy | 02f77d8 | 2019-10-04 17:12:35 +0700 | [diff] [blame] | 1018 | /* Now we have all 7 TBFs established in one-phase access mode, |
| 1019 | * however we will not be sending any data on them. Instead, we |
| 1020 | * will be sending RACH.ind on PTCCH/U during 4 multi-frame |
| 1021 | * periods (TAI 0..8), and then will check two PTCCH/D blocks. |
| 1022 | * |
| 1023 | * Why not 4 TBFs at once? Because Uplink is delayed by 3 TDMA |
| 1024 | * time-slots, so at the moment of scheduling a PTCCH/D block |
| 1025 | * the PCU has odd number of PTCCH/U Access Bursts received. */ |
Vadim Yanitskiy | 20f8700 | 2019-10-06 00:51:50 +0700 | [diff] [blame] | 1026 | f_TC_ta_ptcch_ul_multi_tbf(toa_map, tr_PTCCHDownlinkMsg( |
Vadim Yanitskiy | 02f77d8 | 2019-10-04 17:12:35 +0700 | [diff] [blame] | 1027 | tai0_ta := 7, tai1_ta := 14, tai2_ta := 21, |
| 1028 | /* Other values are not known (yet) */ |
| 1029 | tai3_ta := ?)); |
Vadim Yanitskiy | 20f8700 | 2019-10-06 00:51:50 +0700 | [diff] [blame] | 1030 | f_TC_ta_ptcch_ul_multi_tbf(toa_map, tr_PTCCHDownlinkMsg( |
Vadim Yanitskiy | 02f77d8 | 2019-10-04 17:12:35 +0700 | [diff] [blame] | 1031 | tai0_ta := 7, tai1_ta := 14, tai2_ta := 21, |
| 1032 | tai3_ta := 28, tai4_ta := 35, tai5_ta := 42, |
Vadim Yanitskiy | 20f8700 | 2019-10-06 00:51:50 +0700 | [diff] [blame] | 1033 | /* Other values are out of our interest */ |
Vadim Yanitskiy | 02f77d8 | 2019-10-04 17:12:35 +0700 | [diff] [blame] | 1034 | tai6_ta := ?)); |
| 1035 | } |
| 1036 | |
Vadim Yanitskiy | 26cd244 | 2019-11-08 05:39:06 +0700 | [diff] [blame] | 1037 | /* Default link quality adaptation (Coding Scheme) ranges (inclusive). |
| 1038 | * OsmoPCU (VTY): cs link-quality-ranges cs1 6 cs2 5 8 cs3 7 13 cs4 12 |
| 1039 | * |
| 1040 | * NOTE: the ranges are intentionally overlapping because OsmoPCU |
| 1041 | * does not change CS/MCS on the range borders (5-6, 7-8, 12-13). */ |
Vadim Yanitskiy | 0eb2662 | 2019-09-14 20:35:28 +0200 | [diff] [blame] | 1042 | private template integer CS1_lqual_dB_range := (-infinity .. 6); |
| 1043 | private template integer CS2_lqual_dB_range := (5 .. 8); |
| 1044 | private template integer CS3_lqual_dB_range := (7 .. 13); |
| 1045 | private template integer CS4_lqual_dB_range := (12 .. infinity); |
| 1046 | |
| 1047 | testcase TC_cs_lqual_ul_tbf() runs on RAW_PCU_Test_CT { |
Pau Espin Pedrol | 6c1b4be | 2019-10-04 19:31:02 +0200 | [diff] [blame] | 1048 | var GsmRrMessage rr_imm_ass; |
Vadim Yanitskiy | 0eb2662 | 2019-09-14 20:35:28 +0200 | [diff] [blame] | 1049 | var PacketUlAssign ul_tbf_ass; |
| 1050 | var RlcmacDlBlock dl_block; |
| 1051 | var PCUIF_Message pcu_msg; |
Vadim Yanitskiy | 0eb2662 | 2019-09-14 20:35:28 +0200 | [diff] [blame] | 1052 | var octetstring data; |
| 1053 | var boolean ok; |
| 1054 | |
| 1055 | /* Initialize the PCU interface abstraction */ |
| 1056 | f_init_raw(testcasename()); |
| 1057 | |
Pau Espin Pedrol | 2a45a50 | 2019-11-29 12:48:16 +0100 | [diff] [blame] | 1058 | f_pcuvty_set_allowed_cs_mcs(); |
| 1059 | f_pcuvty_set_link_quality_ranges(); |
| 1060 | |
Vadim Yanitskiy | 0eb2662 | 2019-09-14 20:35:28 +0200 | [diff] [blame] | 1061 | /* Establish an Uplink TBF */ |
Pau Espin Pedrol | 6c1b4be | 2019-10-04 19:31:02 +0200 | [diff] [blame] | 1062 | ok := f_establish_tbf(rr_imm_ass); |
Vadim Yanitskiy | 0eb2662 | 2019-09-14 20:35:28 +0200 | [diff] [blame] | 1063 | if (not ok) { |
Pau Espin Pedrol | 6c1b4be | 2019-10-04 19:31:02 +0200 | [diff] [blame] | 1064 | setverdict(fail, "Failed to establish TBF"); |
Vadim Yanitskiy | 0eb2662 | 2019-09-14 20:35:28 +0200 | [diff] [blame] | 1065 | mtc.stop; |
| 1066 | } |
| 1067 | |
Pau Espin Pedrol | 6c1b4be | 2019-10-04 19:31:02 +0200 | [diff] [blame] | 1068 | ok := f_imm_ass_verify_ul_tbf_ass(rr_imm_ass, ul_tbf_ass); |
| 1069 | if (not ok) { |
| 1070 | setverdict(fail, "Immediate Assignment not an Uplink TBF"); |
Vadim Yanitskiy | 6276b6c | 2019-09-29 19:48:26 +0700 | [diff] [blame] | 1071 | mtc.stop; |
| 1072 | } |
| 1073 | |
Vadim Yanitskiy | 0eb2662 | 2019-09-14 20:35:28 +0200 | [diff] [blame] | 1074 | var template (value) RlcmacUlBlock ul_data := t_RLCMAC_UL_DATA( |
| 1075 | tfi := ul_tbf_ass.dynamic.tfi_assignment, |
Pau Espin Pedrol | 3eef95c | 2019-11-29 14:07:24 +0100 | [diff] [blame] | 1076 | cv := 15, /* 16 UL blocks to be sent (to be overridden in loop) */ |
Vadim Yanitskiy | 0eb2662 | 2019-09-14 20:35:28 +0200 | [diff] [blame] | 1077 | bsn := 0, /* TODO: what should be here? */ |
| 1078 | blocks := { /* To be generated in loop */ }); |
| 1079 | |
| 1080 | /* HACK: patch missing TLLI; otherwise OsmoPCU rejects DATA.req */ |
| 1081 | ul_data.data.tlli := '00000001'O; |
| 1082 | |
Vadim Yanitskiy | 26cd244 | 2019-11-08 05:39:06 +0700 | [diff] [blame] | 1083 | /* The actual / old link quality values. We need to keep track of the old |
| 1084 | * (basically previous) link quality value, because OsmoPCU actually |
| 1085 | * changes the coding scheme if not only the actual, but also the old |
| 1086 | * value leaves the current link quality range (window). */ |
| 1087 | var integer lqual := 0; |
| 1088 | var integer lqual_old; |
| 1089 | |
| 1090 | /* 16 UL blocks (0 .. 15 dB, step = 1 dB) */ |
Vadim Yanitskiy | 0eb2662 | 2019-09-14 20:35:28 +0200 | [diff] [blame] | 1091 | for (var integer i := 0; i < 16; i := i + 1) { |
| 1092 | /* Prepare a new UL block (CV, random payload) */ |
| 1093 | ul_data.data.mac_hdr.countdown := (15 - i); |
| 1094 | ul_data.data.blocks := { valueof(t_RLCMAC_LLCBLOCK(f_rnd_octstring(10))) }; |
| 1095 | |
Vadim Yanitskiy | 26cd244 | 2019-11-08 05:39:06 +0700 | [diff] [blame] | 1096 | /* Update the old / actual link quality */ |
| 1097 | lqual_old := lqual; |
| 1098 | lqual := i; |
Vadim Yanitskiy | 0eb2662 | 2019-09-14 20:35:28 +0200 | [diff] [blame] | 1099 | |
| 1100 | /* Enqueue DATA.ind (both TDMA frame and block numbers to be patched) */ |
| 1101 | log("Sending DATA.ind with link quality (dB): ", lqual); |
Pau Espin Pedrol | c3a7732 | 2019-10-03 19:40:08 +0200 | [diff] [blame] | 1102 | f_tx_rlcmac_ul_block(ul_data, lqual * 10); |
Vadim Yanitskiy | 0eb2662 | 2019-09-14 20:35:28 +0200 | [diff] [blame] | 1103 | |
| 1104 | /* Enqueue RTS.req, expect DATA.req with UL ACK from the PCU */ |
Pau Espin Pedrol | c3a7732 | 2019-10-03 19:40:08 +0200 | [diff] [blame] | 1105 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block); |
Vadim Yanitskiy | 0eb2662 | 2019-09-14 20:35:28 +0200 | [diff] [blame] | 1106 | |
| 1107 | log("Rx Packet Uplink ACK / NACK with Channel Coding Command: ", |
| 1108 | dl_block.ctrl.payload.u.ul_ack_nack.gprs.ch_coding_cmd); |
| 1109 | |
Vadim Yanitskiy | 26cd244 | 2019-11-08 05:39:06 +0700 | [diff] [blame] | 1110 | /* Match the received Channel Coding Command. Since we are increasing |
| 1111 | * the link quality value on each iteration and not decreasing, there |
| 1112 | * is no need to check the both old and current link quality values. */ |
Vadim Yanitskiy | 0eb2662 | 2019-09-14 20:35:28 +0200 | [diff] [blame] | 1113 | var template ChCodingCommand ch_coding; |
Vadim Yanitskiy | 26cd244 | 2019-11-08 05:39:06 +0700 | [diff] [blame] | 1114 | select (lqual_old) { |
Vadim Yanitskiy | 0eb2662 | 2019-09-14 20:35:28 +0200 | [diff] [blame] | 1115 | case (CS1_lqual_dB_range) { ch_coding := CH_CODING_CS1; } |
| 1116 | case (CS2_lqual_dB_range) { ch_coding := CH_CODING_CS2; } |
| 1117 | case (CS3_lqual_dB_range) { ch_coding := CH_CODING_CS3; } |
| 1118 | case (CS4_lqual_dB_range) { ch_coding := CH_CODING_CS4; } |
| 1119 | } |
| 1120 | |
| 1121 | if (not match(dl_block.ctrl.payload.u.ul_ack_nack.gprs.ch_coding_cmd, ch_coding)) { |
| 1122 | setverdict(fail, "Channel Coding does not match our expectations: ", ch_coding); |
| 1123 | } else { |
| 1124 | setverdict(pass); |
| 1125 | } |
| 1126 | } |
| 1127 | } |
| 1128 | |
Pau Espin Pedrol | 3eef95c | 2019-11-29 14:07:24 +0100 | [diff] [blame] | 1129 | /* Test the max UL CS set by VTY works fine */ |
| 1130 | testcase TC_cs_initial_ul() runs on RAW_PCU_Test_CT { |
| 1131 | var GsmRrMessage rr_imm_ass; |
| 1132 | var PacketUlAssign ul_tbf_ass; |
| 1133 | var RlcmacDlBlock dl_block; |
| 1134 | var boolean ok; |
| 1135 | var integer lqual_cb; |
| 1136 | var ChCodingCommand last_ch_coding; |
| 1137 | |
| 1138 | /* Initialize the PCU interface abstraction */ |
| 1139 | f_init_raw(testcasename()); |
| 1140 | |
| 1141 | /* Set initial UL CS to 3 */ |
| 1142 | g_cs_initial_ul := 3; |
| 1143 | f_pcuvty_set_allowed_cs_mcs(); |
| 1144 | f_pcuvty_set_link_quality_ranges(); |
| 1145 | |
| 1146 | /* Take lqual (dB->cB) so that we stay in that CS */ |
| 1147 | lqual_cb := g_cs_lqual_ranges[2].low * 10; |
| 1148 | |
| 1149 | /* Establish an Uplink TBF */ |
| 1150 | ok := f_establish_tbf(rr_imm_ass); |
| 1151 | if (not ok) { |
| 1152 | setverdict(fail, "Failed to establish TBF"); |
| 1153 | mtc.stop; |
| 1154 | } |
| 1155 | |
| 1156 | ok := f_imm_ass_verify_ul_tbf_ass(rr_imm_ass, ul_tbf_ass); |
| 1157 | if (not ok) { |
| 1158 | setverdict(fail, "Immediate Assignment not an Uplink TBF"); |
| 1159 | mtc.stop; |
| 1160 | } |
| 1161 | |
| 1162 | var template (value) RlcmacUlBlock ul_data := t_RLCMAC_UL_DATA( |
| 1163 | tfi := ul_tbf_ass.dynamic.tfi_assignment, |
| 1164 | cv := 3, /* 8 UL blocks to be sent (to be overridden in loop) */ |
| 1165 | bsn := 0, /* TODO: what should be here? */ |
| 1166 | blocks := { /* To be generated in loop */ }); |
| 1167 | |
| 1168 | /* HACK: patch missing TLLI; otherwise OsmoPCU rejects DATA.req */ |
| 1169 | ul_data.data.tlli := '00000001'O; |
| 1170 | |
| 1171 | /* 3 UL blocks, check we are in same initial CS: */ |
| 1172 | for (var integer i := 0; i < 3; i := i + 1) { |
| 1173 | /* Prepare a new UL block (CV, random payload) */ |
| 1174 | ul_data.data.mac_hdr.countdown := (7 - i); |
| 1175 | ul_data.data.blocks := { valueof(t_RLCMAC_LLCBLOCK(f_rnd_octstring(10))) }; |
| 1176 | |
| 1177 | /* Enqueue DATA.ind (both TDMA frame and block numbers to be patched) */ |
| 1178 | f_tx_rlcmac_ul_block(ul_data, lqual_cb); |
| 1179 | |
| 1180 | /* Enqueue RTS.req, expect DATA.req with UL ACK from the PCU */ |
| 1181 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block); |
| 1182 | last_ch_coding := dl_block.ctrl.payload.u.ul_ack_nack.gprs.ch_coding_cmd; |
| 1183 | } |
| 1184 | |
| 1185 | if (last_ch_coding != CH_CODING_CS3) { |
| 1186 | setverdict(fail, "Channel Coding does not match our expectations (CS-3): ", last_ch_coding); |
| 1187 | mtc.stop; |
| 1188 | } |
| 1189 | |
| 1190 | setverdict(pass); |
| 1191 | |
| 1192 | /* Remaining UL blocks are used to make sure regardless of initial |
| 1193 | /* lqual, we can go lower at any time */ |
| 1194 | |
| 1195 | /* 5 UL blocks, check we are in same initial CS: */ |
| 1196 | for (var integer i := 3; i < 8; i := i + 1) { |
| 1197 | /* Prepare a new UL block (CV, random payload) */ |
| 1198 | ul_data.data.mac_hdr.countdown := (7 - i); |
| 1199 | ul_data.data.blocks := { valueof(t_RLCMAC_LLCBLOCK(f_rnd_octstring(10))) }; |
| 1200 | |
| 1201 | /* Enqueue DATA.ind (both TDMA frame and block numbers to be patched) */ |
| 1202 | f_tx_rlcmac_ul_block(ul_data, 0); /* 0 dB, make sure we downgrade CS */ |
| 1203 | |
| 1204 | /* Enqueue RTS.req, expect DATA.req with UL ACK from the PCU */ |
| 1205 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block); |
| 1206 | |
| 1207 | last_ch_coding := dl_block.ctrl.payload.u.ul_ack_nack.gprs.ch_coding_cmd; |
| 1208 | } |
| 1209 | |
| 1210 | if (last_ch_coding != CH_CODING_CS1) { |
| 1211 | setverdict(fail, "Channel Coding does not match our expectations (CS-1): ", last_ch_coding); |
| 1212 | } else { |
| 1213 | setverdict(pass); |
| 1214 | } |
| 1215 | } |
| 1216 | |
| 1217 | /* Test the max UL CS set by VTY works fine */ |
| 1218 | testcase TC_cs_max_ul() runs on RAW_PCU_Test_CT { |
| 1219 | var GsmRrMessage rr_imm_ass; |
| 1220 | var PacketUlAssign ul_tbf_ass; |
| 1221 | var RlcmacDlBlock dl_block; |
| 1222 | var boolean ok; |
| 1223 | var ChCodingCommand last_ch_coding; |
| 1224 | |
| 1225 | /* Initialize the PCU interface abstraction */ |
| 1226 | f_init_raw(testcasename()); |
| 1227 | |
| 1228 | /* Set maximum allowed UL CS to 3 */ |
| 1229 | g_cs_max_ul := 3; |
| 1230 | f_pcuvty_set_allowed_cs_mcs(); |
| 1231 | f_pcuvty_set_link_quality_ranges(); |
| 1232 | |
| 1233 | /* Establish an Uplink TBF */ |
| 1234 | ok := f_establish_tbf(rr_imm_ass); |
| 1235 | if (not ok) { |
| 1236 | setverdict(fail, "Failed to establish TBF"); |
| 1237 | mtc.stop; |
| 1238 | } |
| 1239 | |
| 1240 | ok := f_imm_ass_verify_ul_tbf_ass(rr_imm_ass, ul_tbf_ass); |
| 1241 | if (not ok) { |
| 1242 | setverdict(fail, "Immediate Assignment not an Uplink TBF"); |
| 1243 | mtc.stop; |
| 1244 | } |
| 1245 | |
| 1246 | var template (value) RlcmacUlBlock ul_data := t_RLCMAC_UL_DATA( |
| 1247 | tfi := ul_tbf_ass.dynamic.tfi_assignment, |
| 1248 | cv := 15, /* 16 UL blocks to be sent (to be overridden in loop) */ |
| 1249 | bsn := 0, /* TODO: what should be here? */ |
| 1250 | blocks := { /* To be generated in loop */ }); |
| 1251 | |
| 1252 | /* HACK: patch missing TLLI; otherwise OsmoPCU rejects DATA.req */ |
| 1253 | ul_data.data.tlli := '00000001'O; |
| 1254 | |
| 1255 | /* 16 UL blocks */ |
| 1256 | for (var integer i := 0; i < 16; i := i + 1) { |
| 1257 | /* Prepare a new UL block (CV, random payload) */ |
| 1258 | ul_data.data.mac_hdr.countdown := (15 - i); |
| 1259 | ul_data.data.blocks := { valueof(t_RLCMAC_LLCBLOCK(f_rnd_octstring(10))) }; |
| 1260 | |
| 1261 | /* Enqueue DATA.ind (both TDMA frame and block numbers to be patched) */ |
| 1262 | f_tx_rlcmac_ul_block(ul_data, 40*10); /* 40 dB */ |
| 1263 | |
| 1264 | /* Enqueue RTS.req, expect DATA.req with UL ACK from the PCU */ |
| 1265 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block); |
| 1266 | |
| 1267 | last_ch_coding := dl_block.ctrl.payload.u.ul_ack_nack.gprs.ch_coding_cmd; |
| 1268 | } |
| 1269 | |
| 1270 | if (last_ch_coding != CH_CODING_CS3) { |
| 1271 | setverdict(fail, "Channel Coding does not match our expectations (CS-3): ", last_ch_coding); |
| 1272 | } else { |
| 1273 | setverdict(pass); |
| 1274 | } |
| 1275 | } |
| 1276 | |
Pau Espin Pedrol | 596faa4 | 2019-10-04 19:31:29 +0200 | [diff] [blame] | 1277 | /* Verify PCU drops TBF after some time of inactivity. */ |
| 1278 | testcase TC_t3169() runs on RAW_PCU_Test_CT { |
| 1279 | var PCUIF_info_ind info_ind; |
| 1280 | var GsmRrMessage rr_imm_ass; |
| 1281 | var PacketUlAssign ul_tbf_ass; |
| 1282 | var RlcmacDlBlock dl_block; |
| 1283 | var PCUIF_Message pcu_msg; |
| 1284 | var octetstring data; |
| 1285 | var boolean ok; |
Pau Espin Pedrol | cf47a92 | 2019-10-07 15:26:52 +0200 | [diff] [blame] | 1286 | var OCT4 tlli := '00000001'O; |
| 1287 | |
| 1288 | /* Initialize NS/BSSGP side */ |
| 1289 | f_init_bssgp(); |
Pau Espin Pedrol | 596faa4 | 2019-10-04 19:31:29 +0200 | [diff] [blame] | 1290 | |
| 1291 | info_ind := valueof(ts_PCUIF_INFO_default); |
| 1292 | /* Set timer to 1 sec (default 5) to speedup test: */ |
| 1293 | info_ind.t3169 := 1; |
| 1294 | |
| 1295 | /* Initialize the PCU interface abstraction */ |
| 1296 | f_init_raw(testcasename(), info_ind); |
| 1297 | |
Pau Espin Pedrol | cf47a92 | 2019-10-07 15:26:52 +0200 | [diff] [blame] | 1298 | /* Establish BSSGP connection to the PCU */ |
| 1299 | f_bssgp_establish(); |
| 1300 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, tlli); |
| 1301 | |
Pau Espin Pedrol | 596faa4 | 2019-10-04 19:31:29 +0200 | [diff] [blame] | 1302 | /* Establish an Uplink TBF */ |
| 1303 | ok := f_establish_tbf(rr_imm_ass); |
| 1304 | if (not ok) { |
| 1305 | setverdict(fail, "Failed to establish TBF"); |
| 1306 | mtc.stop; |
| 1307 | } |
| 1308 | |
| 1309 | ok := f_imm_ass_verify_ul_tbf_ass(rr_imm_ass, ul_tbf_ass); |
| 1310 | if (not ok) { |
| 1311 | setverdict(fail, "Immediate Assignment not an Uplink TBF"); |
| 1312 | mtc.stop; |
| 1313 | } |
| 1314 | |
| 1315 | /* Send one UL block and make sure it is ACKED fine */ |
| 1316 | f_tx_rlcmac_ul_n_blocks(ul_tbf_ass, 1); |
| 1317 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block); |
Pau Espin Pedrol | cf47a92 | 2019-10-07 15:26:52 +0200 | [diff] [blame] | 1318 | /* UL block should be received in SGSN */ |
| 1319 | BSSGP[0].receive(tr_BSSGP_UL_UD(tlli, mp_gb_cfg.cell_id)); |
Pau Espin Pedrol | 596faa4 | 2019-10-04 19:31:29 +0200 | [diff] [blame] | 1320 | |
| 1321 | /* Wait until T3169 fires (plus 1 extra sec to make sure) */ |
| 1322 | f_sleep(int2float(info_ind.t3169) + 1.0); |
| 1323 | |
| 1324 | /* Send an UL block once again, the TBF should be gone by now so no ACK */ |
| 1325 | f_tx_rlcmac_ul_n_blocks(ul_tbf_ass, 1); |
| 1326 | f_rx_rlcmac_dl_block_exp_dummy(dl_block); |
| 1327 | } |
| 1328 | |
Pau Espin Pedrol | 1755fab | 2019-10-08 11:18:54 +0200 | [diff] [blame] | 1329 | /* Test scenario where MS wants to send some data on PDCH against SGSN and it is |
| 1330 | * answered, so TBFs for uplink and later for downlink are created. |
| 1331 | */ |
| 1332 | testcase TC_mo_ping_pong() runs on RAW_PCU_Test_CT { |
| 1333 | var GsmRrMessage rr_imm_ass; |
| 1334 | var PacketUlAssign ul_tbf_ass; |
| 1335 | var PacketDlAssign dl_tbf_ass; |
| 1336 | var RlcmacDlBlock dl_block; |
| 1337 | var PCUIF_Message pcu_msg; |
Pau Espin Pedrol | a3f0a85 | 2019-12-02 19:16:26 +0100 | [diff] [blame] | 1338 | var octetstring data := f_rnd_octstring(10); |
Pau Espin Pedrol | 1755fab | 2019-10-08 11:18:54 +0200 | [diff] [blame] | 1339 | var boolean ok; |
| 1340 | var OCT4 tlli := '00000001'O; |
Pau Espin Pedrol | a3f0a85 | 2019-12-02 19:16:26 +0100 | [diff] [blame] | 1341 | var AckNackDescription ack_nack_desc; |
| 1342 | |
| 1343 | ack_nack_desc.final_ack := '0'B; |
| 1344 | ack_nack_desc.starting_seq_nr := 0; |
| 1345 | ack_nack_desc.receive_block_bitmap := '0000000000000000000000000000000000000000000000000000000000000000'B; |
| 1346 | |
Pau Espin Pedrol | 1755fab | 2019-10-08 11:18:54 +0200 | [diff] [blame] | 1347 | |
| 1348 | /* Initialize NS/BSSGP side */ |
| 1349 | f_init_bssgp(); |
| 1350 | |
| 1351 | /* Initialize the PCU interface abstraction */ |
| 1352 | f_init_raw(testcasename()); |
| 1353 | |
| 1354 | /* Establish BSSGP connection to the PCU */ |
| 1355 | f_bssgp_establish(); |
| 1356 | f_bssgp_client_llgmm_assign('FFFFFFFF'O, tlli); |
| 1357 | |
| 1358 | /* Establish an Uplink TBF */ |
| 1359 | ok := f_establish_tbf(rr_imm_ass); |
| 1360 | if (not ok) { |
| 1361 | setverdict(fail, "Failed to establish TBF"); |
| 1362 | mtc.stop; |
| 1363 | } |
| 1364 | ok := f_imm_ass_verify_ul_tbf_ass(rr_imm_ass, ul_tbf_ass); |
| 1365 | if (not ok) { |
| 1366 | setverdict(fail, "Immediate Assignment not an Uplink TBF"); |
| 1367 | mtc.stop; |
| 1368 | } |
| 1369 | |
| 1370 | /* Send one UL block and make sure it is ACKED fine */ |
| 1371 | f_tx_rlcmac_ul_n_blocks(ul_tbf_ass, 1); |
| 1372 | f_rx_rlcmac_dl_block_exp_ack_nack(dl_block); |
| 1373 | |
| 1374 | /* UL block should be received in SGSN */ |
| 1375 | BSSGP[0].receive(tr_BSSGP_UL_UD(tlli, mp_gb_cfg.cell_id)); |
| 1376 | |
| 1377 | /* Now SGSN sends some DL data, PCU will page on CCCH (PCH) */ |
Pau Espin Pedrol | a3f0a85 | 2019-12-02 19:16:26 +0100 | [diff] [blame] | 1378 | BSSGP[0].send(ts_BSSGP_DL_UD(tlli, data)); |
Pau Espin Pedrol | 1755fab | 2019-10-08 11:18:54 +0200 | [diff] [blame] | 1379 | f_pcuif_rx_pch_imm_tbf_ass(rr_imm_ass); |
| 1380 | |
| 1381 | ok := f_imm_ass_verify_dl_tbf_ass(rr_imm_ass, dl_tbf_ass); |
| 1382 | if (not ok) { |
| 1383 | setverdict(fail, "Immediate Assignment not a Downlink TBF"); |
| 1384 | mtc.stop; |
| 1385 | } |
| 1386 | |
Pau Espin Pedrol | a3f0a85 | 2019-12-02 19:16:26 +0100 | [diff] [blame] | 1387 | /* Wait timer X2002 and DL block is available after CCCH IMM ASS: */ |
| 1388 | f_sleep(X2002); |
| 1389 | f_rx_rlcmac_dl_block_exp_data(dl_block, data); |
| 1390 | |
| 1391 | /* ACK the DL block */ |
| 1392 | f_tx_rlcmac_ul_block(ts_RLCMAC_DL_ACK_NACK(dl_block.data.mac_hdr.hdr_ext.tfi, ack_nack_desc)); |
Pau Espin Pedrol | 1755fab | 2019-10-08 11:18:54 +0200 | [diff] [blame] | 1393 | } |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 1394 | |
| 1395 | control { |
| 1396 | execute( TC_ns_reset() ); |
| 1397 | execute( TC_ns_reset_retrans() ); |
| 1398 | execute( TC_ns_alive() ); |
| 1399 | execute( TC_ns_alive_timeout_reset() ); |
| 1400 | execute( TC_ns_unblock() ); |
| 1401 | execute( TC_ns_unblock_retrans() ); |
| 1402 | execute( TC_ns_full_bringup() ); |
| 1403 | execute( TC_ns_so_block() ); |
Harald Welte | 7fd25cf | 2019-03-21 22:14:02 +0100 | [diff] [blame] | 1404 | |
| 1405 | execute( TC_pcuif_suspend() ); |
Vadim Yanitskiy | 1f72b0a | 2019-10-01 05:58:45 +0700 | [diff] [blame] | 1406 | execute( TC_ta_ptcch_idle() ); |
Vadim Yanitskiy | 3e1d318 | 2019-09-11 16:53:45 +0200 | [diff] [blame] | 1407 | execute( TC_ta_rach_imm_ass() ); |
Vadim Yanitskiy | 02f77d8 | 2019-10-04 17:12:35 +0700 | [diff] [blame] | 1408 | execute( TC_ta_ptcch_ul_multi_tbf() ); |
Vadim Yanitskiy | 0eb2662 | 2019-09-14 20:35:28 +0200 | [diff] [blame] | 1409 | execute( TC_cs_lqual_ul_tbf() ); |
Pau Espin Pedrol | 3eef95c | 2019-11-29 14:07:24 +0100 | [diff] [blame] | 1410 | execute( TC_cs_initial_ul() ); |
| 1411 | execute( TC_cs_max_ul() ); |
Pau Espin Pedrol | 596faa4 | 2019-10-04 19:31:29 +0200 | [diff] [blame] | 1412 | execute( TC_t3169() ); |
Pau Espin Pedrol | 1755fab | 2019-10-08 11:18:54 +0200 | [diff] [blame] | 1413 | execute( TC_mo_ping_pong() ); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 1414 | } |
| 1415 | |
| 1416 | |
| 1417 | |
| 1418 | |
| 1419 | |
| 1420 | |
| 1421 | } |