blob: b659fc6b5ab8f0c1b0c97a804042bd3d806681e2 [file] [log] [blame]
Harald Welteac359802017-04-12 12:13:44 +02001///////////////////////////////////////////////////////////////////////////////
2//
3//
4// Copyright Test Competence Center (TCC) ETH 2007
5//
6//
7//
8// The copyright to the computer program(s) herein is the property of TCC. //
9// The program(s) may be used and/or copied only with the written permission //
10// of TCC or in accordance with the terms and conditions stipulated in the //
11// agreement/contract under which the program(s) have been supplied
12//
13//
14//
15///////////////////////////////////////////////////////////////////////////////
16//
17// File: SCCP_TestCases.ttcn
18// Description: SS7 SCCP basic SEA test
19// according to specification ITU-T SS7 SCCP, ANSI ..., TCC ...
20// References: ITU-T: Recommendation Q.711-Q.714,
21// ANSI T1.112-2001,
22// TCC
23// Rev: <RnXnn>
24// Updated: 2007.04.12
25// Contact: http://ttcn.ericsson.se
26//
27
28
29
30
31//Note : this has been modified to include M3UA Emulation and SCTP Test port
32//Elemer Lelik 12.04.2017
33
34
35
36module SCCP_Testcases
37{//startmodule
38
39modulepar
40{
41 hexstring tsp_own_GT := '0614377760'H;
42 hexstring tsp_remote_GT := '0614375760'H;
43 integer tsp_SSN := 2; //8:MSC 5:MAP see 3.4.2.2/Q.713
44 octetstring tsp_SIO := '83'O;//SCCP national
45 integer tsp_own_SPC := 461087; // =0x07091E
46 integer tsp_remote_SPC := 461086; // =0x07091D
47 integer tsp_SLS := 0;
48 charstring tsp_sccp_serviceType := "mtp3_itu";
49
50 octetstring MTP3_UserPart_SIO;
51 integer MTP3_UserPart_OPC,
52 MTP3_UserPart_DPC,
53 MTP3_UserPart_SLS
54
55
56 SCTP_Association_Address tsp_address := { 0, "", 0, "" };
57
58}//modulepar
59
60import from General_Types all;
61
62import from M3UA_Types all;
63import from M3UA_Emulation all;
64
65import from MTP3asp_Types all;
66import from MTP3asp_PortType all;
67
68
69import from SCCPasp_Types all;
70import from SCCP_Types all;
71import from SCCP_Emulation all;
72
73
74import from SCTPasp_Types all;
75import from SCTPasp_PortType all;
76
77
78
79
80/*************************************
81* Components
82**************************************/
83
84
85// Model of MSC:
86type component system_CT {
87
88 port SCTPasp_PT sctp;
89
90
91};
92
93
94
95
96// Main test component with behaviour SCCPuserA andSCCPuserB
97type component MTC_CT {
98 var SCCP_PAR_Address v_CalledAddress, v_CallingAddress;
99 var integer v_testvalue;
100 var SCCP_CT vc_SCCP_A ;
101
102 var M3UA_CT vc_M3UA ;
103
104 var MSC_SCCP_MTP3_parameters v_BootA;
105 var SCCP_PAR_Connection_Id v_cid_A ;
106
107 port SCCPasp_PT A_PORT; //SCCPuserA
108}
109
110function initBootParams() runs on MTC_CT
111{
112 v_BootA :=
113 { sio:=
114 { ni:= substr(oct2bit(tsp_SIO),0,2),
115 prio:= substr(oct2bit(tsp_SIO),2,2),
116 si:= substr(oct2bit(tsp_SIO),4,4)
117 },
118 opc:=tsp_own_SPC,
119 dpc:=tsp_remote_SPC,
120 sls:=tsp_SLS,
121 sccp_serviceType:=tsp_sccp_serviceType,
122 ssn:= tsp_SSN
123 };
124 return;
125} //initBootParams
126
127function init() runs on MTC_CT //system system_CT
128{
129 initBootParams();
130 log("v_BootA:",v_BootA);
131
132 // Protocol Stack creation & connections:
133 vc_SCCP_A:=SCCP_CT.create;
134 vc_M3UA:=M3UA_CT.create;
135
136 connect(self:A_PORT,vc_SCCP_A:SCCP_SP_PORT);
137 connect(vc_M3UA:MTP3_SP_PORT,vc_SCCP_A:MTP3_SCCP_PORT);
138 map(vc_M3UA:SCTP_PORT,system:sctp);
139
140 vc_M3UA.start(f_M3UA_Emulation(tsp_address));
141 vc_SCCP_A.start( SCCPStart( v_BootA ) ); // Bootparameters
142
143
144 log( "init() is done");
145
146}// init
147
148function terminate( ) runs on MTC_CT //system system_CT
149{
150 log( "terminate() started");
151 /*while( all component.running != true )
152 {
153 //waits
154 }*/
155 all component.stop;
156
157 unmap(vc_M3UA:SCTP_PORT,system:sctp);
158 disconnect(vc_M3UA:MTP3_SP_PORT,vc_SCCP_A:MTP3_SCCP_PORT);
159 disconnect(self:A_PORT,vc_SCCP_A:SCCP_SP_PORT);
160
161
162 log(" all components stopped");
163 self.stop;
164} //terminate
165
166// function getOddEven returns '0'
167// if even number of dec digit can be found in GT see Q.713
168function getOddEven( in hexstring pl_GT) return bitstring
169{
170 return int2bit( (lengthof(pl_GT) mod 2) ,1);
171}
172
173function getOddEven_ansi( in hexstring pl_GT) return bitstring
174{
175 if( (lengthof(pl_GT) mod 2) == 0 ) { return '0010'B;} //even
176 else { return '0001'B;} //odd
177}
178
179//******************************************************************
180//function setAddresses_gti0001() runs on MTC_CT
181// Sets CalledAddress and CallingAddress as a gti001-type address
182// according to the cfg file.
183//******************************************************************
184
185function setAddresses_gti0001() runs on MTC_CT
186{
187 if( (tsp_sccp_serviceType == "mtp3_itu") or
188 (tsp_sccp_serviceType == "mtp3b_itu") or
189 (tsp_sccp_serviceType == "mtp3_ttc") or
190 (tsp_sccp_serviceType == "mtp3b_ttc")
191 ) {
192 v_CalledAddress :={
193 addressIndicator := {
194 pointCodeIndic := '1'B,
195 ssnIndicator := '1'B,
196 globalTitleIndic := '0001'B,
Harald Welted69f3452017-04-12 12:18:28 +0200197 routingIndicator := '1'B
Harald Welteac359802017-04-12 12:13:44 +0200198 },//addressIndicator
199 signPointCode := SCCP_SPC_int2bit(tsp_remote_SPC, tsp_sccp_serviceType, tsp_SIO), // see SCCP.ttcn
200 subsystemNumber := tsp_SSN,
201 globalTitle := {
202 gti0001:= {
203 natureOfAddress := '0000011'B,
204 oddeven := getOddEven( tsp_remote_GT ),
205 globalTitleAddress := tsp_remote_GT
206 }
207 }//globalTitle
208 } // v_CalledAddress
209
210 v_CallingAddress :={
211 addressIndicator := {
212 pointCodeIndic := '1'B,
213 ssnIndicator := '1'B,
214 globalTitleIndic := '0001'B,
Harald Welted69f3452017-04-12 12:18:28 +0200215 routingIndicator := '1'B
Harald Welteac359802017-04-12 12:13:44 +0200216 },//addressIndicator
217 signPointCode := SCCP_SPC_int2bit(tsp_own_SPC, tsp_sccp_serviceType, tsp_SIO), // see SCCP.ttcn
218 subsystemNumber := tsp_SSN,
219 globalTitle:= {
220 gti0001 := {
221 natureOfAddress := '0000011'B,
222 oddeven := getOddEven( tsp_own_GT ),
223 globalTitleAddress := tsp_own_GT
224 }
225 }//globalTitle
226 } // v_CallingAddress
227
228 } else if(
229 (tsp_sccp_serviceType == "mtp3_ansi") or
230 (tsp_sccp_serviceType == "mtp3b_ansi")
231 ) {
232
233 v_CalledAddress :={
234 addressIndicator := {
235 pointCodeIndic := '1'B,
236 ssnIndicator := '1'B,
237 globalTitleIndic := '0001'B,
238 routingIndicator := '0'B
239 },//addressIndicator
240 signPointCode := SCCP_SPC_int2bit(tsp_remote_SPC, tsp_sccp_serviceType, tsp_SIO), // see SCCP.ttcn
241 subsystemNumber := tsp_SSN,
242 globalTitle := {
243 gti0011:= {
244 translationType := int2oct(7,1),
245 encodingScheme := getOddEven_ansi( tsp_remote_GT ),
246 numberingPlan := '0111'B, //ISDN/mobile numbering plan, see T1.112.3-2001/3.4.2.3.1
247 globalTitleAddress:= tsp_remote_GT
248 }
249 }//globalTitle
250 } // v_CalledAddress
251
252 v_CallingAddress :={
253 addressIndicator := {
254 pointCodeIndic := '1'B,
255 ssnIndicator := '1'B,
256 globalTitleIndic := '0001'B,
257 routingIndicator := '0'B
258 },//addressIndicator
259 signPointCode := SCCP_SPC_int2bit(tsp_remote_SPC, tsp_sccp_serviceType, tsp_SIO), // see SCCP.ttcn
260 subsystemNumber := tsp_SSN,
261 globalTitle := {
262 gti0011:= {
263 translationType := int2oct(7,1),
264 encodingScheme := getOddEven_ansi( tsp_own_GT ),
265 numberingPlan := '0111'B, //ISDN/mobile numbering plan, see T1.112.3-2001/3.4.2.3.1
266 globalTitleAddress:= tsp_own_GT
267 }
268 }//globalTitle
269 } // v_CallingAddress
270 }//if
271
272}//setAddresses_gti001
273
274function f_SendAndReceive1N_UNITDATA(in octetstring pl_userdata) runs on MTC_CT
275{
276 var ASP_SCCP_N_UNITDATA_ind vl_N_UNITDATA_ind;
277 timer TL_timer:= 120.0;
278 TL_timer.start;
279 A_PORT.send( t_ASP_N_UNITDATA_req( v_CalledAddress,
280 v_CallingAddress,
281 '00000001'B, //sequence control
282 '00000001'B, //return option
283 pl_userdata,
284 omit ) );
285 alt {
286 [] A_PORT.receive( tr_ASP_N_UNITDATA_ind ) -> value vl_N_UNITDATA_ind
287 {
288
289 if( (vl_N_UNITDATA_ind.calledAddress == v_CalledAddress ) and
290 (vl_N_UNITDATA_ind.callingAddress == v_CallingAddress) and
291 (vl_N_UNITDATA_ind.userData == pl_userdata) )
292 {
293 log("Correct CalledAddress, CallingAddress and userData received, data are correct");
294 setverdict(pass);
295 }
296 else
297 {
298 log("Some data corrupted");
299 setverdict( fail );
300 }
301 };
302 [] TL_timer.timeout
303 {
304 setverdict( fail );
305 log("Timeout....");
306 };
307 } //alt
308 TL_timer.stop;
309}//f_SendAndReceive1N_UNITDATA
310
311/****************************************************
312Connection Oriented Part
313****************************************************/
314
315/****************************************************
316function f_connect
317Establishes a connection
318(Sends an ASP_SCCP_N_CONNECT_req on A_PORT and waits for
319N_CONNECT_ind on B_PORT. If it is received,
320it sends back an ASP_SCCP_N_CONNECT_res on B_PORT and waits for
321N_CONNECT_cfm on A_PORT)
322****************************************************/
323function f_connect() runs on MTC_CT return boolean
324{
325 var ASP_SCCP_N_CONNECT_ind vl_N_CONNECT_ind;
326 var ASP_SCCP_N_CONNECT_cfm vl_N_CONNECT_cfm;
327 setverdict(none);
328 v_cid_A := 13;
329 timer TL_timer:= 120.0;
330 TL_timer.start;
331
332 A_PORT.send( t_ASP_N_CONNECT_req( v_CalledAddress,
333 v_CallingAddress,
334 omit, //expeditedDataSel
335 omit, //QoS
336 omit, //userData
337 v_cid_A,
338 omit //importance
339 ) );
340
341 alt {
342 [] A_PORT.receive( tr_ASP_N_CONNECT_cfm ) -> value vl_N_CONNECT_cfm
343 {
344 setverdict( pass );
345 log("f_connect finished successfully");
346 return true;
347 }
348 [] TL_timer.timeout
349 {
350 setverdict( fail );
351 log("Timeout....");
352 return false;
353 }
354 }// alt
355 log("f_connect finished");
356 return false;
357}//f_connect
358
359/****************************************************
360function f_send
361Sends an ASP_SCCP_N_DATA_req on A_PORT and waits for answer in
362A_PORT
363****************************************************/
364function f_send(in octetstring pl_userdata) runs on MTC_CT
365{
366 timer TL_timer:= 120.0;
367 TL_timer.start;
368 A_PORT.send( t_ASP_N_DATA_req ( pl_userdata, v_cid_A, omit) ) ;
369 alt {
370 [] A_PORT.receive
371 {
372 setverdict( pass );
373 log("f_connect finished successfully");
374
375 }
376 [] TL_timer.timeout
377 {
378 setverdict( fail );
379 log("Timeout....");
380
381 }
382
383 } //alt
384}//f_send
385
386//f_disconnect with timeout
387
388function f_disconnect( ) runs on MTC_CT
389{
390 var ASP_SCCP_N_DISCONNECT_ind vl_N_DISCONNECT_ind;
391 timer TL_timer:= 25.0;
392 TL_timer.start;
393 A_PORT.send( t_ASP_N_DISCONNECT_req( omit, // respondingAddress
394 0, //reason : end user originated, see 3.11/Q.713
395 omit, //userData
396 v_cid_A,
397 omit ))
398 alt {
399
400 [] A_PORT.receive
401 {
402 repeat;
403 }
404 [] TL_timer.timeout
405 {
406 setverdict( pass );
407 log("Timeout....");
408 };
409 }//alt
410
411
412}//f_disconnect
413
414//===================================================
415// Testcases
416//===================================================
417
418/****************************************************
419tc_ConnlessSendingShortASP
420Sends a 300 octet long userdata in one ASP_SCCP_N_UNITDATA_req
421and receives it in one ASP_SCCP_N_UNITDATA_req.
422SCCP transfers information
423in udp or (forced) xudp packets.
424****************************************************/
425testcase tc_ConnlessSendingShortASP() runs on MTC_CT
426{
427 var octetstring vl_userdata;
428 init();
429 setAddresses_gti0001();
430 vl_userdata :='12345678901234567890'O;
431 f_SendAndReceive1N_UNITDATA( vl_userdata );
432 terminate();
433 } //tc_ConnlessSendingShortASP
434
435/****************************************************
436 tc_ConnlessSendingLongASP
437 Sends a 300 octet long userdata in one ASP_SCCP_N_UNITDATA_req
438 and receives it in one ASP_SCCP_N_UNITDATA_req.
439 It is used for segmentation and reassembly.
440 SCCP transfers information
441in xudp packets
442****************************************************/
443testcase tc_ConnlessSendingLongASP() runs on MTC_CT system system_CT
444{
445 var octetstring vl_userdata;
446 var integer vl_i;
447 init();
448 setAddresses_gti0001();
449 vl_userdata := ''O;
450 for(vl_i:=0;vl_i<30;vl_i:=vl_i+1) {
451 vl_userdata := vl_userdata &'12345678901234567890'O;
452 }
453 f_SendAndReceive1N_UNITDATA( vl_userdata );
454 terminate();
455}//tc_ConnlessSendingLongASP
456
457/****************************************************
458tc_ConnOrientedShortASPSending
459****************************************************/
460testcase tc_ConnOrientedShortASPSending() runs on MTC_CT system system_CT
461{
462 var octetstring vl_userdata;
463 init();
464 setAddresses_gti0001();
465 vl_userdata := '12345678901234567890'O;
466 if(f_connect())
467 {
468 f_send(vl_userdata);
469 f_disconnect();
470 }
471 terminate();
472}
473/****************************************************
474tc_ConnOrientedLongASPSending
475****************************************************/
476testcase tc_ConnOrientedLongASPSending() runs on MTC_CT
477{
478 var octetstring vl_userdata;
479 var integer vl_i;
480 init();
481 setAddresses_gti0001();
482 vl_userdata := ''O;
483 for(vl_i:=0;vl_i<30;vl_i:=vl_i+1) {
484 vl_userdata := vl_userdata &'12345678901234567890'O;
485 }
486 if(f_connect())
487 {
488 f_send(vl_userdata);
489 //f_SendAndReceive1N_UNITDATA( vl_userdata );
490 f_disconnect();
491 }
492 terminate();
493}
494/****************************************************
495 CONTROL
496****************************************************/
497control
498{
499 execute( tc_ConnlessSendingShortASP() );
500 execute( tc_ConnlessSendingLongASP() );
501 execute( tc_ConnOrientedShortASPSending());
502 execute( tc_ConnOrientedLongASPSending());
503}
504
505}//module