blob: b9414a3b7fa633fb9f4c8523955d409ceb486077 [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 Welteb3414b22017-11-23 18:22:10 +010012import from BSSMAP_Emulation all;
13
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;
20 var BSSMAP_Emulation_CT vc_BSSMAP;
21 /* 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;
Harald Weltebe620f62017-11-25 00:23:54 +010042
Harald Welteb3414b22017-11-23 18:22:10 +010043 g_sccp_addr_own := sccp_addr_own;
44 g_sccp_addr_remote := sccp_addr_remote;
45
Harald Welte2fb04792017-11-25 01:14:35 +010046 /* create components for IPA/SCCP/BSS[M]AP stack */
Harald Weltebe620f62017-11-25 00:23:54 +010047 vc_IPA := IPA_Emulation_CT.create(id & "-IPA");
48 vc_SCCP := SCCP_CT.create(id & "-SCCP");
49 vc_BSSMAP := BSSMAP_Emulation_CT.create(id & "-BSSMAP");
Harald Welteb3414b22017-11-23 18:22:10 +010050
51 map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
52
53 /* connect MTP3 service provider (IPA) to lower side of SCCP */
54 connect(vc_IPA:MTP3_SP_PORT, vc_SCCP:MTP3_SCCP_PORT);
55
Harald Weltec82eef42017-11-24 20:40:12 +010056 /* connect BSSMAP dispatcher to upper side of SCCP */
Harald Welte004f5fb2017-12-16 17:54:40 +010057 connect(vc_BSSMAP:BSSAP, vc_SCCP:SCCP_SP_PORT);
Harald Welteb3414b22017-11-23 18:22:10 +010058
Harald Weltec82eef42017-11-24 20:40:12 +010059 /* connect BSSMAP dispatcher to IPA_Emulation MGCP */
60 connect(vc_BSSMAP:MGCP, vc_IPA:IPA_MGCP_PORT);
61
Harald Welte2fb04792017-11-25 01:14:35 +010062 /* start components */
Harald Welteb3414b22017-11-23 18:22:10 +010063 vc_IPA.start(IPA_Emulation.main_client(remote_ip, remote_port, local_ip, local_port));
64 vc_SCCP.start(SCCPStart(sccp_pars));
Harald Weltebe620f62017-11-25 00:23:54 +010065 vc_BSSMAP.start(BSSMAP_Emulation.main(BSC_MS_BssmapOps, id));
Harald Welteb3414b22017-11-23 18:22:10 +010066
Harald Welte2fb04792017-11-25 01:14:35 +010067 /* Initial delay to wait for IPA connection establishment */
68 T.start(2.0);
69 T.timeout;
Harald Weltebe620f62017-11-25 00:23:54 +010070
Harald Welte2fb04792017-11-25 01:14:35 +010071 for (i := 0; i < mp_num_iterations; i := i+1) {
Harald Weltebe620f62017-11-25 00:23:54 +010072 f_start_BSC_MS(id & "-MS-" & int2str(i));
Harald Welteb3414b22017-11-23 18:22:10 +010073 }
74
Harald Welte2fb04792017-11-25 01:14:35 +010075 /* explicitly stop all components that we started above */
76 vc_IPA.stop;
77 vc_BSSMAP.stop;
78 vc_SCCP.stop;
Harald Welteb3414b22017-11-23 18:22:10 +010079}
80
Harald Weltebe620f62017-11-25 00:23:54 +010081function f_start_BSC_MS(charstring id) runs on BSC_CT {
Harald Welteb3414b22017-11-23 18:22:10 +010082 var BSC_MS_ConnHdlr vc_conn;
83
84 /* start new component */
Harald Weltebe620f62017-11-25 00:23:54 +010085 vc_conn := BSC_MS_ConnHdlr.create(id);
Harald Welteb3414b22017-11-23 18:22:10 +010086 /* connect client BSSAP port to BSSAP dispatcher */
87 connect(vc_conn:BSSAP, vc_BSSMAP:CLIENT);
88 /* start component */
89 vc_conn.start(BSC_MS_ConnectionHandler.main(g_sccp_addr_own, g_sccp_addr_remote));
Harald Welte2fb04792017-11-25 01:14:35 +010090 /* blocking wait until component terminates. If you want to start MSs in parallel,
91 * you have to remove this statement here */
92 vc_conn.done;
Harald Welteb3414b22017-11-23 18:22:10 +010093}
94
95}