blob: d4e37a46898dcb4a3ff101e42419e1694ea3e059 [file] [log] [blame]
Harald Welteb3414b22017-11-23 18:22:10 +01001module BSC_MS_Simulation {
2
Harald Welte34b5a952019-05-27 11:54:11 +02003/* (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 Welteb3414b22017-11-23 18:22:10 +010013import from IPL4asp_Types all;
14
15import from IPA_Emulation all;
16
17import from SCCP_Types all;
18import from SCCPasp_Types all;
19import from SCCP_Emulation all;
20
Harald Welte004f5fb2017-12-16 17:54:40 +010021import from BSSAP_CodecPort all;
Harald Welte6811d102019-04-14 22:23:14 +020022import from RAN_Emulation all;
Harald Welteb3414b22017-11-23 18:22:10 +010023
24import from BSC_MS_ConnectionHandler all;
25
26type component BSC_CT {
27 /* component references */
28 var IPA_Emulation_CT vc_IPA;
29 var SCCP_CT vc_SCCP;
Harald Welte6811d102019-04-14 22:23:14 +020030 var RAN_Emulation_CT vc_BSSMAP;
Harald Welteb3414b22017-11-23 18:22:10 +010031 /* 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 Pedrolf3c12222019-05-22 15:18:42 +020036 var boolean g_use_osmux;
Harald Weltebe620f62017-11-25 00:23:54 +010037
38 var charstring g_bsc_num_str;
Harald Welteb3414b22017-11-23 18:22:10 +010039}
40
Harald Welte2fb04792017-11-25 01:14:35 +010041modulepar {
42 integer mp_num_iterations := 10;
43}
44
Harald Welteb3414b22017-11-23 18:22:10 +010045function 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 Pedrolf3c12222019-05-22 15:18:42 +020049 SCCP_PAR_Address sccp_addr_remote,
50 boolean use_osmux, charstring id) runs on BSC_CT
Harald Welteb3414b22017-11-23 18:22:10 +010051{
Harald Weltebe620f62017-11-25 00:23:54 +010052 var integer i := 0;
Harald Welte2fb04792017-11-25 01:14:35 +010053 timer T := 1.0;
Daniel Willmann909523e2018-10-25 17:21:24 +020054 var IPA_CCM_Parameters ccm_pars := IPA_Emulation.c_IPA_default_ccm_pars;
55 ccm_pars.name := id;
Harald Weltebe620f62017-11-25 00:23:54 +010056
Harald Welteb3414b22017-11-23 18:22:10 +010057 g_sccp_addr_own := sccp_addr_own;
58 g_sccp_addr_remote := sccp_addr_remote;
Pau Espin Pedrolf3c12222019-05-22 15:18:42 +020059 g_use_osmux := use_osmux;
Harald Welteb3414b22017-11-23 18:22:10 +010060
Harald Welte2fb04792017-11-25 01:14:35 +010061 /* create components for IPA/SCCP/BSS[M]AP stack */
Harald Weltebe620f62017-11-25 00:23:54 +010062 vc_IPA := IPA_Emulation_CT.create(id & "-IPA");
63 vc_SCCP := SCCP_CT.create(id & "-SCCP");
Harald Welte6811d102019-04-14 22:23:14 +020064 vc_BSSMAP := RAN_Emulation_CT.create(id & "-BSSMAP");
Harald Welteb3414b22017-11-23 18:22:10 +010065
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 Weltec82eef42017-11-24 20:40:12 +010071 /* connect BSSMAP dispatcher to upper side of SCCP */
Harald Welte004f5fb2017-12-16 17:54:40 +010072 connect(vc_BSSMAP:BSSAP, vc_SCCP:SCCP_SP_PORT);
Harald Welteb3414b22017-11-23 18:22:10 +010073
Harald Weltec82eef42017-11-24 20:40:12 +010074 /* connect BSSMAP dispatcher to IPA_Emulation MGCP */
75 connect(vc_BSSMAP:MGCP, vc_IPA:IPA_MGCP_PORT);
76
Harald Welte2fb04792017-11-25 01:14:35 +010077 /* start components */
Daniel Willmann909523e2018-10-25 17:21:24 +020078 vc_IPA.start(IPA_Emulation.main_client(remote_ip, remote_port, local_ip, local_port, ccm_pars));
Harald Welteb3414b22017-11-23 18:22:10 +010079 vc_SCCP.start(SCCPStart(sccp_pars));
Harald Welte6811d102019-04-14 22:23:14 +020080 vc_BSSMAP.start(RAN_Emulation.main(BSC_MS_ConnectionHandler.BSC_MS_RanOps, id));
Harald Welteb3414b22017-11-23 18:22:10 +010081
Harald Welte2fb04792017-11-25 01:14:35 +010082 /* Initial delay to wait for IPA connection establishment */
83 T.start(2.0);
84 T.timeout;
Harald Weltebe620f62017-11-25 00:23:54 +010085
Harald Welte2fb04792017-11-25 01:14:35 +010086 for (i := 0; i < mp_num_iterations; i := i+1) {
Harald Weltebe620f62017-11-25 00:23:54 +010087 f_start_BSC_MS(id & "-MS-" & int2str(i));
Harald Welteb3414b22017-11-23 18:22:10 +010088 }
89
Harald Welte2fb04792017-11-25 01:14:35 +010090 /* explicitly stop all components that we started above */
91 vc_IPA.stop;
92 vc_BSSMAP.stop;
93 vc_SCCP.stop;
Harald Welteb3414b22017-11-23 18:22:10 +010094}
95
Harald Weltebe620f62017-11-25 00:23:54 +010096function f_start_BSC_MS(charstring id) runs on BSC_CT {
Harald Welteb3414b22017-11-23 18:22:10 +010097 var BSC_MS_ConnHdlr vc_conn;
98
99 /* start new component */
Harald Weltebe620f62017-11-25 00:23:54 +0100100 vc_conn := BSC_MS_ConnHdlr.create(id);
Harald Welteb3414b22017-11-23 18:22:10 +0100101 /* connect client BSSAP port to BSSAP dispatcher */
102 connect(vc_conn:BSSAP, vc_BSSMAP:CLIENT);
103 /* start component */
Pau Espin Pedrolf3c12222019-05-22 15:18:42 +0200104 vc_conn.start(BSC_MS_ConnectionHandler.main(g_sccp_addr_own, g_sccp_addr_remote, g_use_osmux));
Harald Welte2fb04792017-11-25 01:14:35 +0100105 /* 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 Welteb3414b22017-11-23 18:22:10 +0100108}
109
110}