blob: ed6e92dca63d9b11b77d57335aec45f349ede312 [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;
Harald Weltebe620f62017-11-25 00:23:54 +010036
37 var charstring g_bsc_num_str;
Harald Welteb3414b22017-11-23 18:22:10 +010038}
39
Harald Welte2fb04792017-11-25 01:14:35 +010040modulepar {
41 integer mp_num_iterations := 10;
42}
43
Harald Welteb3414b22017-11-23 18:22:10 +010044function main(charstring remote_ip, PortNumber remote_port,
45 charstring local_ip, PortNumber local_port,
46 MSC_SCCP_MTP3_parameters sccp_pars,
47 SCCP_PAR_Address sccp_addr_own,
Harald Weltebe620f62017-11-25 00:23:54 +010048 SCCP_PAR_Address sccp_addr_remote, charstring id) runs on BSC_CT
Harald Welteb3414b22017-11-23 18:22:10 +010049{
Harald Weltebe620f62017-11-25 00:23:54 +010050 var integer i := 0;
Harald Welte2fb04792017-11-25 01:14:35 +010051 timer T := 1.0;
Daniel Willmann909523e2018-10-25 17:21:24 +020052 var IPA_CCM_Parameters ccm_pars := IPA_Emulation.c_IPA_default_ccm_pars;
53 ccm_pars.name := id;
Harald Weltebe620f62017-11-25 00:23:54 +010054
Harald Welteb3414b22017-11-23 18:22:10 +010055 g_sccp_addr_own := sccp_addr_own;
56 g_sccp_addr_remote := sccp_addr_remote;
57
Harald Welte2fb04792017-11-25 01:14:35 +010058 /* create components for IPA/SCCP/BSS[M]AP stack */
Harald Weltebe620f62017-11-25 00:23:54 +010059 vc_IPA := IPA_Emulation_CT.create(id & "-IPA");
60 vc_SCCP := SCCP_CT.create(id & "-SCCP");
Harald Welte6811d102019-04-14 22:23:14 +020061 vc_BSSMAP := RAN_Emulation_CT.create(id & "-BSSMAP");
Harald Welteb3414b22017-11-23 18:22:10 +010062
63 map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
64
65 /* connect MTP3 service provider (IPA) to lower side of SCCP */
66 connect(vc_IPA:MTP3_SP_PORT, vc_SCCP:MTP3_SCCP_PORT);
67
Harald Weltec82eef42017-11-24 20:40:12 +010068 /* connect BSSMAP dispatcher to upper side of SCCP */
Harald Welte004f5fb2017-12-16 17:54:40 +010069 connect(vc_BSSMAP:BSSAP, vc_SCCP:SCCP_SP_PORT);
Harald Welteb3414b22017-11-23 18:22:10 +010070
Harald Weltec82eef42017-11-24 20:40:12 +010071 /* connect BSSMAP dispatcher to IPA_Emulation MGCP */
72 connect(vc_BSSMAP:MGCP, vc_IPA:IPA_MGCP_PORT);
73
Harald Welte2fb04792017-11-25 01:14:35 +010074 /* start components */
Daniel Willmann909523e2018-10-25 17:21:24 +020075 vc_IPA.start(IPA_Emulation.main_client(remote_ip, remote_port, local_ip, local_port, ccm_pars));
Harald Welteb3414b22017-11-23 18:22:10 +010076 vc_SCCP.start(SCCPStart(sccp_pars));
Harald Welte6811d102019-04-14 22:23:14 +020077 vc_BSSMAP.start(RAN_Emulation.main(BSC_MS_ConnectionHandler.BSC_MS_RanOps, id));
Harald Welteb3414b22017-11-23 18:22:10 +010078
Harald Welte2fb04792017-11-25 01:14:35 +010079 /* Initial delay to wait for IPA connection establishment */
80 T.start(2.0);
81 T.timeout;
Harald Weltebe620f62017-11-25 00:23:54 +010082
Harald Welte2fb04792017-11-25 01:14:35 +010083 for (i := 0; i < mp_num_iterations; i := i+1) {
Harald Weltebe620f62017-11-25 00:23:54 +010084 f_start_BSC_MS(id & "-MS-" & int2str(i));
Harald Welteb3414b22017-11-23 18:22:10 +010085 }
86
Harald Welte2fb04792017-11-25 01:14:35 +010087 /* explicitly stop all components that we started above */
88 vc_IPA.stop;
89 vc_BSSMAP.stop;
90 vc_SCCP.stop;
Harald Welteb3414b22017-11-23 18:22:10 +010091}
92
Harald Weltebe620f62017-11-25 00:23:54 +010093function f_start_BSC_MS(charstring id) runs on BSC_CT {
Harald Welteb3414b22017-11-23 18:22:10 +010094 var BSC_MS_ConnHdlr vc_conn;
95
96 /* start new component */
Harald Weltebe620f62017-11-25 00:23:54 +010097 vc_conn := BSC_MS_ConnHdlr.create(id);
Harald Welteb3414b22017-11-23 18:22:10 +010098 /* connect client BSSAP port to BSSAP dispatcher */
99 connect(vc_conn:BSSAP, vc_BSSMAP:CLIENT);
100 /* start component */
101 vc_conn.start(BSC_MS_ConnectionHandler.main(g_sccp_addr_own, g_sccp_addr_remote));
Harald Welte2fb04792017-11-25 01:14:35 +0100102 /* blocking wait until component terminates. If you want to start MSs in parallel,
103 * you have to remove this statement here */
104 vc_conn.done;
Harald Welteb3414b22017-11-23 18:22:10 +0100105}
106
107}