blob: c45b5aca4d5c67d929ee3ca7b33b858a62be2736 [file] [log] [blame]
Harald Welteb3414b22017-11-23 18:22:10 +01001module BSC_MS_Simulation {
2
3import from IPL4asp_Types all;
4
5import from IPA_Emulation all;
6
7import from SCCP_Types all;
8import from SCCPasp_Types all;
9import from SCCP_Emulation all;
10
Harald Welte004f5fb2017-12-16 17:54:40 +010011import from BSSAP_CodecPort all;
Harald Welte6811d102019-04-14 22:23:14 +020012import from RAN_Emulation all;
Harald Welteb3414b22017-11-23 18:22:10 +010013
14import from BSC_MS_ConnectionHandler all;
15
16type component BSC_CT {
17 /* component references */
18 var IPA_Emulation_CT vc_IPA;
19 var SCCP_CT vc_SCCP;
Harald Welte6811d102019-04-14 22:23:14 +020020 var RAN_Emulation_CT vc_BSSMAP;
Harald Welteb3414b22017-11-23 18:22:10 +010021 /* test port to SCCP emulation */
22 port SCCPasp_PT SCCP;
23
24 var SCCP_PAR_Address g_sccp_addr_own;
25 var SCCP_PAR_Address g_sccp_addr_remote;
Harald Weltebe620f62017-11-25 00:23:54 +010026
27 var charstring g_bsc_num_str;
Harald Welteb3414b22017-11-23 18:22:10 +010028}
29
Harald Welte2fb04792017-11-25 01:14:35 +010030modulepar {
31 integer mp_num_iterations := 10;
32}
33
Harald Welteb3414b22017-11-23 18:22:10 +010034function main(charstring remote_ip, PortNumber remote_port,
35 charstring local_ip, PortNumber local_port,
36 MSC_SCCP_MTP3_parameters sccp_pars,
37 SCCP_PAR_Address sccp_addr_own,
Harald Weltebe620f62017-11-25 00:23:54 +010038 SCCP_PAR_Address sccp_addr_remote, charstring id) runs on BSC_CT
Harald Welteb3414b22017-11-23 18:22:10 +010039{
Harald Weltebe620f62017-11-25 00:23:54 +010040 var integer i := 0;
Harald Welte2fb04792017-11-25 01:14:35 +010041 timer T := 1.0;
Daniel Willmann909523e2018-10-25 17:21:24 +020042 var IPA_CCM_Parameters ccm_pars := IPA_Emulation.c_IPA_default_ccm_pars;
43 ccm_pars.name := id;
Harald Weltebe620f62017-11-25 00:23:54 +010044
Harald Welteb3414b22017-11-23 18:22:10 +010045 g_sccp_addr_own := sccp_addr_own;
46 g_sccp_addr_remote := sccp_addr_remote;
47
Harald Welte2fb04792017-11-25 01:14:35 +010048 /* create components for IPA/SCCP/BSS[M]AP stack */
Harald Weltebe620f62017-11-25 00:23:54 +010049 vc_IPA := IPA_Emulation_CT.create(id & "-IPA");
50 vc_SCCP := SCCP_CT.create(id & "-SCCP");
Harald Welte6811d102019-04-14 22:23:14 +020051 vc_BSSMAP := RAN_Emulation_CT.create(id & "-BSSMAP");
Harald Welteb3414b22017-11-23 18:22:10 +010052
53 map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
54
55 /* connect MTP3 service provider (IPA) to lower side of SCCP */
56 connect(vc_IPA:MTP3_SP_PORT, vc_SCCP:MTP3_SCCP_PORT);
57
Harald Weltec82eef42017-11-24 20:40:12 +010058 /* connect BSSMAP dispatcher to upper side of SCCP */
Harald Welte004f5fb2017-12-16 17:54:40 +010059 connect(vc_BSSMAP:BSSAP, vc_SCCP:SCCP_SP_PORT);
Harald Welteb3414b22017-11-23 18:22:10 +010060
Harald Weltec82eef42017-11-24 20:40:12 +010061 /* connect BSSMAP dispatcher to IPA_Emulation MGCP */
62 connect(vc_BSSMAP:MGCP, vc_IPA:IPA_MGCP_PORT);
63
Harald Welte2fb04792017-11-25 01:14:35 +010064 /* start components */
Daniel Willmann909523e2018-10-25 17:21:24 +020065 vc_IPA.start(IPA_Emulation.main_client(remote_ip, remote_port, local_ip, local_port, ccm_pars));
Harald Welteb3414b22017-11-23 18:22:10 +010066 vc_SCCP.start(SCCPStart(sccp_pars));
Harald Welte6811d102019-04-14 22:23:14 +020067 vc_BSSMAP.start(RAN_Emulation.main(BSC_MS_ConnectionHandler.BSC_MS_RanOps, id));
Harald Welteb3414b22017-11-23 18:22:10 +010068
Harald Welte2fb04792017-11-25 01:14:35 +010069 /* Initial delay to wait for IPA connection establishment */
70 T.start(2.0);
71 T.timeout;
Harald Weltebe620f62017-11-25 00:23:54 +010072
Harald Welte2fb04792017-11-25 01:14:35 +010073 for (i := 0; i < mp_num_iterations; i := i+1) {
Harald Weltebe620f62017-11-25 00:23:54 +010074 f_start_BSC_MS(id & "-MS-" & int2str(i));
Harald Welteb3414b22017-11-23 18:22:10 +010075 }
76
Harald Welte2fb04792017-11-25 01:14:35 +010077 /* explicitly stop all components that we started above */
78 vc_IPA.stop;
79 vc_BSSMAP.stop;
80 vc_SCCP.stop;
Harald Welteb3414b22017-11-23 18:22:10 +010081}
82
Harald Weltebe620f62017-11-25 00:23:54 +010083function f_start_BSC_MS(charstring id) runs on BSC_CT {
Harald Welteb3414b22017-11-23 18:22:10 +010084 var BSC_MS_ConnHdlr vc_conn;
85
86 /* start new component */
Harald Weltebe620f62017-11-25 00:23:54 +010087 vc_conn := BSC_MS_ConnHdlr.create(id);
Harald Welteb3414b22017-11-23 18:22:10 +010088 /* connect client BSSAP port to BSSAP dispatcher */
89 connect(vc_conn:BSSAP, vc_BSSMAP:CLIENT);
90 /* start component */
91 vc_conn.start(BSC_MS_ConnectionHandler.main(g_sccp_addr_own, g_sccp_addr_remote));
Harald Welte2fb04792017-11-25 01:14:35 +010092 /* blocking wait until component terminates. If you want to start MSs in parallel,
93 * you have to remove this statement here */
94 vc_conn.done;
Harald Welteb3414b22017-11-23 18:22:10 +010095}
96
97}