blob: eab7fe9d0df4ffb88aac218ff35d6c2427327ec7 [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
11import from BSSMAP_Emulation all;
12
13import from BSC_MS_ConnectionHandler all;
14
15type component BSC_CT {
16 /* component references */
17 var IPA_Emulation_CT vc_IPA;
18 var SCCP_CT vc_SCCP;
19 var BSSMAP_Emulation_CT vc_BSSMAP;
20 /* test port to SCCP emulation */
21 port SCCPasp_PT SCCP;
22
23 var SCCP_PAR_Address g_sccp_addr_own;
24 var SCCP_PAR_Address g_sccp_addr_remote;
Harald Weltebe620f62017-11-25 00:23:54 +010025
26 var charstring g_bsc_num_str;
Harald Welteb3414b22017-11-23 18:22:10 +010027}
28
Harald Welte2fb04792017-11-25 01:14:35 +010029modulepar {
30 integer mp_num_iterations := 10;
31}
32
Harald Welteb3414b22017-11-23 18:22:10 +010033function main(charstring remote_ip, PortNumber remote_port,
34 charstring local_ip, PortNumber local_port,
35 MSC_SCCP_MTP3_parameters sccp_pars,
36 SCCP_PAR_Address sccp_addr_own,
Harald Weltebe620f62017-11-25 00:23:54 +010037 SCCP_PAR_Address sccp_addr_remote, charstring id) runs on BSC_CT
Harald Welteb3414b22017-11-23 18:22:10 +010038{
Harald Weltebe620f62017-11-25 00:23:54 +010039 var integer i := 0;
Harald Welte2fb04792017-11-25 01:14:35 +010040 timer T := 1.0;
Harald Weltebe620f62017-11-25 00:23:54 +010041
Harald Welteb3414b22017-11-23 18:22:10 +010042 g_sccp_addr_own := sccp_addr_own;
43 g_sccp_addr_remote := sccp_addr_remote;
44
Harald Welte2fb04792017-11-25 01:14:35 +010045 /* create components for IPA/SCCP/BSS[M]AP stack */
Harald Weltebe620f62017-11-25 00:23:54 +010046 vc_IPA := IPA_Emulation_CT.create(id & "-IPA");
47 vc_SCCP := SCCP_CT.create(id & "-SCCP");
48 vc_BSSMAP := BSSMAP_Emulation_CT.create(id & "-BSSMAP");
Harald Welteb3414b22017-11-23 18:22:10 +010049
50 map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
51
52 /* connect MTP3 service provider (IPA) to lower side of SCCP */
53 connect(vc_IPA:MTP3_SP_PORT, vc_SCCP:MTP3_SCCP_PORT);
54
Harald Weltec82eef42017-11-24 20:40:12 +010055 /* connect BSSMAP dispatcher to upper side of SCCP */
Harald Welteb3414b22017-11-23 18:22:10 +010056 connect(vc_BSSMAP:SCCP, vc_SCCP:SCCP_SP_PORT);
57
Harald Weltec82eef42017-11-24 20:40:12 +010058 /* connect BSSMAP dispatcher to IPA_Emulation MGCP */
59 connect(vc_BSSMAP:MGCP, vc_IPA:IPA_MGCP_PORT);
60
Harald Welte2fb04792017-11-25 01:14:35 +010061 /* start components */
Harald Welteb3414b22017-11-23 18:22:10 +010062 vc_IPA.start(IPA_Emulation.main_client(remote_ip, remote_port, local_ip, local_port));
63 vc_SCCP.start(SCCPStart(sccp_pars));
Harald Weltebe620f62017-11-25 00:23:54 +010064 vc_BSSMAP.start(BSSMAP_Emulation.main(BSC_MS_BssmapOps, id));
Harald Welteb3414b22017-11-23 18:22:10 +010065
Harald Welte2fb04792017-11-25 01:14:35 +010066 /* Initial delay to wait for IPA connection establishment */
67 T.start(2.0);
68 T.timeout;
Harald Weltebe620f62017-11-25 00:23:54 +010069
Harald Welte2fb04792017-11-25 01:14:35 +010070 for (i := 0; i < mp_num_iterations; i := i+1) {
Harald Weltebe620f62017-11-25 00:23:54 +010071 f_start_BSC_MS(id & "-MS-" & int2str(i));
Harald Welteb3414b22017-11-23 18:22:10 +010072 }
73
Harald Welte2fb04792017-11-25 01:14:35 +010074 /* explicitly stop all components that we started above */
75 vc_IPA.stop;
76 vc_BSSMAP.stop;
77 vc_SCCP.stop;
Harald Welteb3414b22017-11-23 18:22:10 +010078}
79
Harald Weltebe620f62017-11-25 00:23:54 +010080function f_start_BSC_MS(charstring id) runs on BSC_CT {
Harald Welteb3414b22017-11-23 18:22:10 +010081 var BSC_MS_ConnHdlr vc_conn;
82
83 /* start new component */
Harald Weltebe620f62017-11-25 00:23:54 +010084 vc_conn := BSC_MS_ConnHdlr.create(id);
Harald Welteb3414b22017-11-23 18:22:10 +010085 /* connect client BSSAP port to BSSAP dispatcher */
86 connect(vc_conn:BSSAP, vc_BSSMAP:CLIENT);
87 /* start component */
88 vc_conn.start(BSC_MS_ConnectionHandler.main(g_sccp_addr_own, g_sccp_addr_remote));
Harald Welte2fb04792017-11-25 01:14:35 +010089 /* blocking wait until component terminates. If you want to start MSs in parallel,
90 * you have to remove this statement here */
91 vc_conn.done;
Harald Welteb3414b22017-11-23 18:22:10 +010092}
93
94}