Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 1 | module BSC_MS_Simulation { |
| 2 | |
| 3 | import from IPL4asp_Types all; |
| 4 | |
| 5 | import from IPA_Emulation all; |
| 6 | |
| 7 | import from SCCP_Types all; |
| 8 | import from SCCPasp_Types all; |
| 9 | import from SCCP_Emulation all; |
| 10 | |
Harald Welte | 004f5fb | 2017-12-16 17:54:40 +0100 | [diff] [blame] | 11 | import from BSSAP_CodecPort all; |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 12 | import from BSSMAP_Emulation all; |
| 13 | |
| 14 | import from BSC_MS_ConnectionHandler all; |
| 15 | |
| 16 | type 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 Welte | be620f6 | 2017-11-25 00:23:54 +0100 | [diff] [blame] | 26 | |
| 27 | var charstring g_bsc_num_str; |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 28 | } |
| 29 | |
Harald Welte | 2fb0479 | 2017-11-25 01:14:35 +0100 | [diff] [blame] | 30 | modulepar { |
| 31 | integer mp_num_iterations := 10; |
| 32 | } |
| 33 | |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 34 | function 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 Welte | be620f6 | 2017-11-25 00:23:54 +0100 | [diff] [blame] | 38 | SCCP_PAR_Address sccp_addr_remote, charstring id) runs on BSC_CT |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 39 | { |
Harald Welte | be620f6 | 2017-11-25 00:23:54 +0100 | [diff] [blame] | 40 | var integer i := 0; |
Harald Welte | 2fb0479 | 2017-11-25 01:14:35 +0100 | [diff] [blame] | 41 | timer T := 1.0; |
Harald Welte | be620f6 | 2017-11-25 00:23:54 +0100 | [diff] [blame] | 42 | |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 43 | g_sccp_addr_own := sccp_addr_own; |
| 44 | g_sccp_addr_remote := sccp_addr_remote; |
| 45 | |
Harald Welte | 2fb0479 | 2017-11-25 01:14:35 +0100 | [diff] [blame] | 46 | /* create components for IPA/SCCP/BSS[M]AP stack */ |
Harald Welte | be620f6 | 2017-11-25 00:23:54 +0100 | [diff] [blame] | 47 | 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 Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 50 | |
| 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 Welte | c82eef4 | 2017-11-24 20:40:12 +0100 | [diff] [blame] | 56 | /* connect BSSMAP dispatcher to upper side of SCCP */ |
Harald Welte | 004f5fb | 2017-12-16 17:54:40 +0100 | [diff] [blame] | 57 | connect(vc_BSSMAP:BSSAP, vc_SCCP:SCCP_SP_PORT); |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 58 | |
Harald Welte | c82eef4 | 2017-11-24 20:40:12 +0100 | [diff] [blame] | 59 | /* connect BSSMAP dispatcher to IPA_Emulation MGCP */ |
| 60 | connect(vc_BSSMAP:MGCP, vc_IPA:IPA_MGCP_PORT); |
| 61 | |
Harald Welte | 2fb0479 | 2017-11-25 01:14:35 +0100 | [diff] [blame] | 62 | /* start components */ |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 63 | vc_IPA.start(IPA_Emulation.main_client(remote_ip, remote_port, local_ip, local_port)); |
| 64 | vc_SCCP.start(SCCPStart(sccp_pars)); |
Harald Welte | be620f6 | 2017-11-25 00:23:54 +0100 | [diff] [blame] | 65 | vc_BSSMAP.start(BSSMAP_Emulation.main(BSC_MS_BssmapOps, id)); |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 66 | |
Harald Welte | 2fb0479 | 2017-11-25 01:14:35 +0100 | [diff] [blame] | 67 | /* Initial delay to wait for IPA connection establishment */ |
| 68 | T.start(2.0); |
| 69 | T.timeout; |
Harald Welte | be620f6 | 2017-11-25 00:23:54 +0100 | [diff] [blame] | 70 | |
Harald Welte | 2fb0479 | 2017-11-25 01:14:35 +0100 | [diff] [blame] | 71 | for (i := 0; i < mp_num_iterations; i := i+1) { |
Harald Welte | be620f6 | 2017-11-25 00:23:54 +0100 | [diff] [blame] | 72 | f_start_BSC_MS(id & "-MS-" & int2str(i)); |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 73 | } |
| 74 | |
Harald Welte | 2fb0479 | 2017-11-25 01:14:35 +0100 | [diff] [blame] | 75 | /* explicitly stop all components that we started above */ |
| 76 | vc_IPA.stop; |
| 77 | vc_BSSMAP.stop; |
| 78 | vc_SCCP.stop; |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 79 | } |
| 80 | |
Harald Welte | be620f6 | 2017-11-25 00:23:54 +0100 | [diff] [blame] | 81 | function f_start_BSC_MS(charstring id) runs on BSC_CT { |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 82 | var BSC_MS_ConnHdlr vc_conn; |
| 83 | |
| 84 | /* start new component */ |
Harald Welte | be620f6 | 2017-11-25 00:23:54 +0100 | [diff] [blame] | 85 | vc_conn := BSC_MS_ConnHdlr.create(id); |
Harald Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 86 | /* 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 Welte | 2fb0479 | 2017-11-25 01:14:35 +0100 | [diff] [blame] | 90 | /* 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 Welte | b3414b2 | 2017-11-23 18:22:10 +0100 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | } |