Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 1 | module BSC_MS_Simulation { |
| 2 | |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 3 | /* (C) 2017-2018 Harald Welte <laforge@gnumonks.org> |
| 4 | * (C) 2018 sysmocom - s.f.m.c. Gmbh; Author: Daniel Willmann |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Released under the terms of GNU General Public License, Version 2 or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 11 | */ |
| 12 | |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 13 | import from IPL4asp_Types all; |
| 14 | |
| 15 | import from IPA_Emulation all; |
| 16 | |
| 17 | import from SCCP_Types all; |
| 18 | import from SCCPasp_Types all; |
| 19 | import from SCCP_Emulation all; |
| 20 | |
Harald Welte | 004f5fb | 2017-12-16 17:54:40 +0100 | [diff] [blame] | 21 | import from BSSAP_CodecPort all; |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 22 | import from RAN_Emulation all; |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 23 | |
| 24 | import from BSC_MS_ConnectionHandler all; |
| 25 | |
| 26 | type component BSC_CT { |
| 27 | /* component references */ |
| 28 | var IPA_Emulation_CT vc_IPA; |
| 29 | var SCCP_CT vc_SCCP; |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 30 | var RAN_Emulation_CT vc_BSSMAP; |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 31 | /* test port to SCCP emulation */ |
| 32 | port SCCPasp_PT SCCP; |
| 33 | |
| 34 | var SCCP_PAR_Address g_sccp_addr_own; |
| 35 | var SCCP_PAR_Address g_sccp_addr_remote; |
Pau Espin Pedrol | f3c1222 | 2019-05-22 15:18:42 +0200 | [diff] [blame] | 36 | var boolean g_use_osmux; |
Harald Welte | be620f6 | 2017-11-25 00:23:54 +0100 | [diff] [blame] | 37 | |
| 38 | var charstring g_bsc_num_str; |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 39 | } |
| 40 | |
Harald Welte | 2fb0479 | 2017-11-25 01:14:35 +0100 | [diff] [blame] | 41 | modulepar { |
| 42 | integer mp_num_iterations := 10; |
| 43 | } |
| 44 | |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 45 | function main(charstring remote_ip, PortNumber remote_port, |
| 46 | charstring local_ip, PortNumber local_port, |
| 47 | MSC_SCCP_MTP3_parameters sccp_pars, |
| 48 | SCCP_PAR_Address sccp_addr_own, |
Pau Espin Pedrol | f3c1222 | 2019-05-22 15:18:42 +0200 | [diff] [blame] | 49 | SCCP_PAR_Address sccp_addr_remote, |
| 50 | boolean use_osmux, charstring id) runs on BSC_CT |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 51 | { |
Harald Welte | be620f6 | 2017-11-25 00:23:54 +0100 | [diff] [blame] | 52 | var integer i := 0; |
Harald Welte | 2fb0479 | 2017-11-25 01:14:35 +0100 | [diff] [blame] | 53 | timer T := 1.0; |
Daniel Willmann | 909523e | 2018-10-25 17:21:24 +0200 | [diff] [blame] | 54 | var IPA_CCM_Parameters ccm_pars := IPA_Emulation.c_IPA_default_ccm_pars; |
| 55 | ccm_pars.name := id; |
Harald Welte | be620f6 | 2017-11-25 00:23:54 +0100 | [diff] [blame] | 56 | |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 57 | g_sccp_addr_own := sccp_addr_own; |
| 58 | g_sccp_addr_remote := sccp_addr_remote; |
Pau Espin Pedrol | f3c1222 | 2019-05-22 15:18:42 +0200 | [diff] [blame] | 59 | g_use_osmux := use_osmux; |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 60 | |
Harald Welte | 2fb0479 | 2017-11-25 01:14:35 +0100 | [diff] [blame] | 61 | /* create components for IPA/SCCP/BSS[M]AP stack */ |
Harald Welte | be620f6 | 2017-11-25 00:23:54 +0100 | [diff] [blame] | 62 | vc_IPA := IPA_Emulation_CT.create(id & "-IPA"); |
| 63 | vc_SCCP := SCCP_CT.create(id & "-SCCP"); |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 64 | vc_BSSMAP := RAN_Emulation_CT.create(id & "-BSSMAP"); |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 65 | |
| 66 | map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 67 | |
| 68 | /* connect MTP3 service provider (IPA) to lower side of SCCP */ |
| 69 | connect(vc_IPA:MTP3_SP_PORT, vc_SCCP:MTP3_SCCP_PORT); |
| 70 | |
Harald Welte | c82eef4 | 2017-11-24 20:40:12 +0100 | [diff] [blame] | 71 | /* connect BSSMAP dispatcher to upper side of SCCP */ |
Harald Welte | 004f5fb | 2017-12-16 17:54:40 +0100 | [diff] [blame] | 72 | connect(vc_BSSMAP:BSSAP, vc_SCCP:SCCP_SP_PORT); |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 73 | |
Harald Welte | c82eef4 | 2017-11-24 20:40:12 +0100 | [diff] [blame] | 74 | /* connect BSSMAP dispatcher to IPA_Emulation MGCP */ |
| 75 | connect(vc_BSSMAP:MGCP, vc_IPA:IPA_MGCP_PORT); |
| 76 | |
Harald Welte | 2fb0479 | 2017-11-25 01:14:35 +0100 | [diff] [blame] | 77 | /* start components */ |
Daniel Willmann | 909523e | 2018-10-25 17:21:24 +0200 | [diff] [blame] | 78 | vc_IPA.start(IPA_Emulation.main_client(remote_ip, remote_port, local_ip, local_port, ccm_pars)); |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 79 | vc_SCCP.start(SCCPStart(sccp_pars)); |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 80 | vc_BSSMAP.start(RAN_Emulation.main(BSC_MS_ConnectionHandler.BSC_MS_RanOps, id)); |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 81 | |
Harald Welte | 2fb0479 | 2017-11-25 01:14:35 +0100 | [diff] [blame] | 82 | /* Initial delay to wait for IPA connection establishment */ |
| 83 | T.start(2.0); |
| 84 | T.timeout; |
Harald Welte | be620f6 | 2017-11-25 00:23:54 +0100 | [diff] [blame] | 85 | |
Harald Welte | 2fb0479 | 2017-11-25 01:14:35 +0100 | [diff] [blame] | 86 | for (i := 0; i < mp_num_iterations; i := i+1) { |
Harald Welte | be620f6 | 2017-11-25 00:23:54 +0100 | [diff] [blame] | 87 | f_start_BSC_MS(id & "-MS-" & int2str(i)); |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 88 | } |
| 89 | |
Harald Welte | 2fb0479 | 2017-11-25 01:14:35 +0100 | [diff] [blame] | 90 | /* explicitly stop all components that we started above */ |
| 91 | vc_IPA.stop; |
| 92 | vc_BSSMAP.stop; |
| 93 | vc_SCCP.stop; |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 94 | } |
| 95 | |
Harald Welte | be620f6 | 2017-11-25 00:23:54 +0100 | [diff] [blame] | 96 | function f_start_BSC_MS(charstring id) runs on BSC_CT { |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 97 | var BSC_MS_ConnHdlr vc_conn; |
| 98 | |
| 99 | /* start new component */ |
Harald Welte | be620f6 | 2017-11-25 00:23:54 +0100 | [diff] [blame] | 100 | vc_conn := BSC_MS_ConnHdlr.create(id); |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 101 | /* connect client BSSAP port to BSSAP dispatcher */ |
| 102 | connect(vc_conn:BSSAP, vc_BSSMAP:CLIENT); |
| 103 | /* start component */ |
Pau Espin Pedrol | f3c1222 | 2019-05-22 15:18:42 +0200 | [diff] [blame] | 104 | vc_conn.start(BSC_MS_ConnectionHandler.main(g_sccp_addr_own, g_sccp_addr_remote, g_use_osmux)); |
Harald Welte | 2fb0479 | 2017-11-25 01:14:35 +0100 | [diff] [blame] | 105 | /* blocking wait until component terminates. If you want to start MSs in parallel, |
| 106 | * you have to remove this statement here */ |
| 107 | vc_conn.done; |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | } |