summaryrefslogtreecommitdiffstats
path: root/bsc-nat/BSC_MS_Simulation.ttcn
blob: c45b5aca4d5c67d929ee3ca7b33b858a62be2736 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
module BSC_MS_Simulation {

import from IPL4asp_Types all;

import from IPA_Emulation all;

import from SCCP_Types all;
import from SCCPasp_Types all;
import from SCCP_Emulation all;

import from BSSAP_CodecPort all;
import from RAN_Emulation all;

import from BSC_MS_ConnectionHandler all;

type component BSC_CT {
	/* component references */
	var IPA_Emulation_CT vc_IPA;
	var SCCP_CT vc_SCCP;
	var RAN_Emulation_CT vc_BSSMAP;
	/* test port to SCCP emulation */
	port SCCPasp_PT SCCP;

	var SCCP_PAR_Address g_sccp_addr_own;
	var SCCP_PAR_Address g_sccp_addr_remote;

	var charstring g_bsc_num_str;
}

modulepar {
	integer mp_num_iterations := 10;
}

function main(charstring remote_ip, PortNumber remote_port,
		charstring local_ip, PortNumber local_port,
		MSC_SCCP_MTP3_parameters sccp_pars,
		SCCP_PAR_Address sccp_addr_own,
		SCCP_PAR_Address sccp_addr_remote, charstring id) runs on BSC_CT
{
	var integer i := 0;
	timer T := 1.0;
	var IPA_CCM_Parameters ccm_pars := IPA_Emulation.c_IPA_default_ccm_pars;
	ccm_pars.name := id;

	g_sccp_addr_own := sccp_addr_own;
	g_sccp_addr_remote := sccp_addr_remote;

	/* create components for IPA/SCCP/BSS[M]AP stack */
	vc_IPA := IPA_Emulation_CT.create(id & "-IPA");
	vc_SCCP := SCCP_CT.create(id & "-SCCP");
	vc_BSSMAP := RAN_Emulation_CT.create(id & "-BSSMAP");

	map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT);

	/* connect MTP3 service provider (IPA) to lower side of SCCP */
	connect(vc_IPA:MTP3_SP_PORT, vc_SCCP:MTP3_SCCP_PORT);

	/* connect BSSMAP dispatcher to upper side of SCCP */
	connect(vc_BSSMAP:BSSAP, vc_SCCP:SCCP_SP_PORT);

	/* connect BSSMAP dispatcher to IPA_Emulation MGCP */
	connect(vc_BSSMAP:MGCP, vc_IPA:IPA_MGCP_PORT);

	/* start components */
	vc_IPA.start(IPA_Emulation.main_client(remote_ip, remote_port, local_ip, local_port, ccm_pars));
	vc_SCCP.start(SCCPStart(sccp_pars));
	vc_BSSMAP.start(RAN_Emulation.main(BSC_MS_ConnectionHandler.BSC_MS_RanOps, id));

	/* Initial delay to wait for IPA connection establishment */
	T.start(2.0);
	T.timeout;

	for (i := 0; i < mp_num_iterations; i := i+1) {
		f_start_BSC_MS(id & "-MS-" & int2str(i));
	}

	/* explicitly stop all components that we started above */
	vc_IPA.stop;
	vc_BSSMAP.stop;
	vc_SCCP.stop;
}

function f_start_BSC_MS(charstring id) runs on BSC_CT {
	var BSC_MS_ConnHdlr vc_conn;

	/* start new component */
	vc_conn := BSC_MS_ConnHdlr.create(id);
	/* connect client BSSAP port to BSSAP dispatcher */
	connect(vc_conn:BSSAP, vc_BSSMAP:CLIENT);
	/* start component */
	vc_conn.start(BSC_MS_ConnectionHandler.main(g_sccp_addr_own, g_sccp_addr_remote));
	/* blocking wait until component terminates.  If you want to start MSs in parallel,
	 * you have to remove this statement here */
	vc_conn.done;
}

}