blob: c6497045fc8c6ad2df2affeeae03e2112d7daf2b [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_selftest.ttcn
18// Description: SS7 SCCP basic test
19// according to specification ITU-T SS7 SCCP, ANSI ..., TCC ...
20// References: ITU-T: Recommendation Q.711-Q.714,
21// ANSI ,
22// TCC
23// Rev: <RnXnn>
24// Updated: 2007-04.12
25// Contact: http://ttcn.ericsson.se
26//
27
28module SCCP_selftest
29{//startmodule
30
31modulepar
32{
33 hexstring tsp_own_GT := '0614377760'H;
34 hexstring tsp_remote_GT := '0614375760'H;
35 integer tsp_SSN := 2; //8:MSC 5:MAP see 3.4.2.2/Q.713
36 octetstring tsp_SIO := '83'O;//SCCP national
37 integer tsp_own_SPC := 461087; // =0x07091E
38 integer tsp_remote_SPC := 461086; // =0x07091D
39 integer tsp_SLS := 0;
40 charstring tsp_sccp_serviceType := "mtp3_itu"
41}//modulepar
42
43import from General_Types all;
44
45import from MTP3asp_Types all;
46import from MTP3asp_PortType all;
47
48import from SCCPasp_Types all;
49import from SCCP_Types all;
50import from SCCP_Emulation all;
51
52
53//==================================================================
54// MTPsim component
55// Description: Simulates two MTP stacks for two MTP3-User
56// to implement this configuration:
57// MTPsim includes MTP3/1 and MTP3/2
58// MTPsim only receives TRANSFER_req and sends TRANSFER_ind
59// with the same content
60// +----------+ +----------+
61// |SCCP-userA| <--->|SCCP-userB| = MTC
62// +----------+ +----------+
63// | A | B
64// +----------+ +----------+
65// | SCCP A | <--->| SCCP B |
66// +----------+ +----------+
67// | A | B
68// +-----------------------------+
69// | MTP3 1. | MTP3 2.| = MTP3sim
70// +----------------------------+
71//
72//==================================================================
73
74group MTPsim
75{
76
77
78type component MTPsim_CT {
79 port MTP3asp_SP_PT MTP_A_PORT
80 port MTP3asp_SP_PT MTP_B_PORT
81}
82
83function MTPsim_EventHandler( ) runs on MTPsim_CT
84{
85 var ASP_MTP3_TRANSFERreq vl_MTP3_TRANSFERreq;
86 var ASP_MTP3_TRANSFERind vl_MTP3_TRANSFERind
87 alt{
88 [] MTP_A_PORT.receive( ASP_MTP3_TRANSFERreq:? ) -> value vl_MTP3_TRANSFERreq
89
90 {
91 MTP_B_PORT.send( t_ASP_MTP3_TRANSFERind(
92 vl_MTP3_TRANSFERreq.sio,
93 vl_MTP3_TRANSFERreq.opc,
94 vl_MTP3_TRANSFERreq.dpc,
95 vl_MTP3_TRANSFERreq.sls,
96 vl_MTP3_TRANSFERreq.data ) ) ;
97 repeat;
98 }//A.receive
99 [] MTP_B_PORT.receive( ASP_MTP3_TRANSFERreq:? ) -> value vl_MTP3_TRANSFERreq
100
101 {
102 MTP_A_PORT.send( t_ASP_MTP3_TRANSFERind (
103 vl_MTP3_TRANSFERreq.sio,
104 vl_MTP3_TRANSFERreq.opc,
105 vl_MTP3_TRANSFERreq.dpc,
106 vl_MTP3_TRANSFERreq.sls,
107 vl_MTP3_TRANSFERreq.data ));
108 repeat;
109 }//B.receive
110
111 }//alt
112
113} //MTPsim_EventHandler
114
115}//group MTPsim
116
117// Main test component with behaviour SCCPuserA andSCCPuserB
118type component MTC_CT {
119 var SCCP_PAR_Address v_CalledAddress, v_CallingAddress;
120 var integer v_testvalue;
121 var MTPsim_CT vc_MTPsim;
122 var SCCP_CT vc_SCCP_A, vc_SCCP_B;
123 var MSC_SCCP_MTP3_parameters v_BootA;
124 var MSC_SCCP_MTP3_parameters v_BootB;
125 var SCCP_PAR_Connection_Id v_cid_A, v_cid_B;
126
127 port SCCPasp_PT A_PORT; //SCCPuserA
128 port SCCPasp_PT B_PORT //SCCPuserB
129
130}
131
132function initBootParams() runs on MTC_CT
133{
134 v_BootA :=
135 { sio:=
136 { ni:= substr(oct2bit(tsp_SIO),0,2),
137 prio:= substr(oct2bit(tsp_SIO),2,2),
138 si:= substr(oct2bit(tsp_SIO),4,4)
139 },
140 opc:=tsp_own_SPC,
141 dpc:=tsp_remote_SPC,
142 sls:=tsp_SLS,
143 sccp_serviceType:=tsp_sccp_serviceType,
144 ssn:= tsp_SSN
145 };
146
147 v_BootB :=
148 { sio:=
149 { ni:= substr(oct2bit(tsp_SIO),0,2),
150 prio:= substr(oct2bit(tsp_SIO),2,2),
151 si:= substr(oct2bit(tsp_SIO),4,4)
152 },
153 opc:=tsp_remote_SPC,
154 dpc:=tsp_own_SPC,
155 sls:=tsp_SLS,
156 sccp_serviceType:=tsp_sccp_serviceType,
157 ssn:= tsp_SSN
158 };
159 return;
160} //initBootParams
161function init() runs on MTC_CT
162{
163
164
165 initBootParams();
166 log("v_BootA:",v_BootA);
167 log("v_BootB: ",v_BootB);
168 vc_MTPsim:= MTPsim_CT.create;
169
170 // Protocol Stack A creation & connections:
171 vc_SCCP_A:=SCCP_CT.create;
172 connect(vc_SCCP_A:MTP3_SCCP_PORT,vc_MTPsim:MTP_A_PORT);
173 connect(self:A_PORT,vc_SCCP_A:SCCP_SP_PORT);
174
175 // Protocol Stack B creation & connections:
176 vc_SCCP_B:=SCCP_CT.create;
177 connect(vc_SCCP_B:MTP3_SCCP_PORT,vc_MTPsim:MTP_B_PORT);
178 connect(self:B_PORT,vc_SCCP_B:SCCP_SP_PORT);
179
180 // Start stacks:
181 vc_MTPsim.start( MTPsim_EventHandler() );
182
183 vc_SCCP_A.start( SCCPStart( v_BootA ) ); // Bootparameters !!! cont here!!!
184
185 vc_SCCP_B.start( SCCPStart(v_BootB));
186 log( "init() is done");
187
188}// init
189
190function terminate( ) runs on MTC_CT
191{
192 log( "termitate() started");
193 /*while( all component.running != true )
194 {
195 //waits
196 }*/
197 all component.stop;
198 disconnect(vc_SCCP_A:MTP3_SCCP_PORT, vc_MTPsim:MTP_A_PORT);
199 disconnect(self:A_PORT,vc_SCCP_A:SCCP_SP_PORT);
200
201 disconnect(vc_SCCP_B:MTP3_SCCP_PORT,vc_MTPsim:MTP_B_PORT);
202 disconnect(self:B_PORT,vc_SCCP_B:SCCP_SP_PORT);
203 log(" all components stopped");
204 self.stop;
205} //terminate
206
207// function getOddEven returns '0'
208// if even number of dec digit can be found in GT see Q.713
209function getOddEven( in hexstring pl_GT) return bitstring
210{
211 return int2bit( (lengthof(pl_GT) mod 2) ,1);
212}
213
214function getOddEvenEnc( in hexstring pl_GT) return bitstring
215{
216 if( (lengthof(pl_GT) mod 2) == 0 ) { return '0010'B;} //even
217 else { return '0001'B;} //odd
218}
219
220//******************************************************************
221//function setAddresses_gti0001() runs on MTC_CT
222// Sets CalledAddress and CallingAddress as a gti001-type address
223// according to the cfg file.
224//******************************************************************
225
226function setAddresses_gti0001() runs on MTC_CT
227{
228 if( (tsp_sccp_serviceType == "mtp3_itu") or
229 (tsp_sccp_serviceType == "mtp3b_itu") or
230 (tsp_sccp_serviceType == "mtp3_ttc") or
231 (tsp_sccp_serviceType == "mtp3b_ttc")
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_Emulation.ttcn
241 subsystemNumber := tsp_SSN,
242 globalTitle := {
243 gti0001:= {
244 natureOfAddress := '0000011'B,
245 oddeven := getOddEven( tsp_remote_GT ),
246 globalTitleAddress := tsp_remote_GT
247 }
248 }//globalTitle
249 } // v_CalledAddress
250
251 v_CallingAddress :={
252 addressIndicator := {
253 pointCodeIndic := '1'B,
254 ssnIndicator := '1'B,
255 globalTitleIndic := '0001'B,
256 routingIndicator := '0'B
257 },//addressIndicator
258 signPointCode := SCCP_SPC_int2bit(tsp_own_SPC, tsp_sccp_serviceType, tsp_SIO), // see SCCP_Emulation.ttcn
259 subsystemNumber := tsp_SSN,
260 globalTitle:= {
261 gti0001 := {
262 natureOfAddress := '0000011'B,
263 oddeven := getOddEven( tsp_own_GT ),
264 globalTitleAddress := tsp_own_GT
265 }
266 }//globalTitle
267 } // v_CallingAddress
268
269 } else if(
270 (tsp_sccp_serviceType == "mtp3_ansi") or
271 (tsp_sccp_serviceType == "mtp3b_ansi") )
272 {
273
274 v_CalledAddress :={
275 addressIndicator := {
276 pointCodeIndic := '1'B,
277 ssnIndicator := '1'B,
278 globalTitleIndic := '0001'B,
279 routingIndicator := '0'B
280 },//addressIndicator
281 signPointCode := SCCP_SPC_int2bit(tsp_remote_SPC, tsp_sccp_serviceType, tsp_SIO), // see SCCP_Emulation.ttcn
282 subsystemNumber := tsp_SSN,
283 globalTitle := {
284 gti0011:= {
285 translationType := int2oct(7,1),
286 encodingScheme := getOddEvenEnc( tsp_remote_GT ),
287 numberingPlan := '0111'B, //ISDN/mobile numbering plan, see T1.112.3-2001/3.4.2.3.1
288 globalTitleAddress:= tsp_remote_GT
289 }
290 }//globalTitle
291 } // v_CalledAddress
292
293 v_CallingAddress :={
294 addressIndicator := {
295 pointCodeIndic := '1'B,
296 ssnIndicator := '1'B,
297 globalTitleIndic := '0001'B,
298 routingIndicator := '0'B
299 },//addressIndicator
300 signPointCode := SCCP_SPC_int2bit(tsp_remote_SPC, tsp_sccp_serviceType, tsp_SIO), // see SCCP_Emulation.ttcn
301 subsystemNumber := tsp_SSN,
302 globalTitle := {
303 gti0011:= {
304 translationType := int2oct(7,1),
305 encodingScheme := getOddEvenEnc( tsp_own_GT ),
306 numberingPlan := '0111'B, //ISDN/mobile numbering plan, see T1.112.3-2001/3.4.2.3.1
307 globalTitleAddress:= tsp_own_GT
308 }
309 }//globalTitle
310 } // v_CallingAddress
311
312 }//if
313 else
314 {
315 log( "wrong tsp_sccp_serviceType ->exit ");
316 setverdict( fail );
317 }
318}//setAddresses_gti001
319
320function f_SendAndReceive1N_UNITDATA(in octetstring pl_userdata) runs on MTC_CT
321{
322 var ASP_SCCP_N_UNITDATA_ind vl_N_UNITDATA_ind;
323 timer TL_timer:= 40.0;
324 TL_timer.start;
325 log("A_PORT.send follows");
326 log("Addresses:",v_CalledAddress, v_CallingAddress);
327 A_PORT.send( t_ASP_N_UNITDATA_req( v_CalledAddress,
328 v_CallingAddress,
329 '00000001'B, //sequence control
330 '00000001'B, //return option
331 pl_userdata,
332 omit ) );
333 log("A_PORT.send executed");
334 alt {
335 [] B_PORT.receive( tr_ASP_N_UNITDATA_ind ) -> value vl_N_UNITDATA_ind
336 {
337
338 if( (vl_N_UNITDATA_ind.calledAddress == v_CalledAddress ) and
339 (vl_N_UNITDATA_ind.callingAddress == v_CallingAddress) and
340 (vl_N_UNITDATA_ind.userData == pl_userdata) )
341 {
342 log("Correct CalledAddress, CallingAddress and userData received, data are correct");
343 setverdict(pass);
344 }
345 else
346 {
347 log("Some data corrupted");
348 log("Original data:", v_CalledAddress, v_CallingAddress, pl_userdata);
349 setverdict( fail );
350 }
351 };
352 [] TL_timer.timeout
353 {
354 setverdict( fail );
355 log("Timeout....");
356 };
357 } //alt
358 TL_timer.stop;
359}//f_SendAndReceive1N_UNITDATA
360
361/****************************************************
362Connection Oriented Part
363****************************************************/
364
365/****************************************************
366function f_connect
367Establishes a connection
368(Sends an ASP_SCCP_N_CONNECT_req on A_PORT and waits for
369N_CONNECT_ind on B_PORT. If it is received,
370it sends back an ASP_SCCP_N_CONNECT_res on B_PORT and waits for
371N_CONNECT_cfm on A_PORT)
372****************************************************/
373function f_connect() runs on MTC_CT return boolean
374{
375 var ASP_SCCP_N_CONNECT_ind vl_N_CONNECT_ind;
376 var ASP_SCCP_N_CONNECT_cfm vl_N_CONNECT_cfm;
377 setverdict(none);
378 v_cid_A := 13;
379 timer TL_timer:= 40.0;
380 TL_timer.start;
381 // A Sends ASP_SCCP_N_CONNECT_req , receives
382 A_PORT.send( t_ASP_N_CONNECT_req( v_CalledAddress,
383 v_CallingAddress,
384 omit, //expeditedDataSel
385 omit, //QoS
386 omit, //userData
387 v_cid_A,
388 omit //importance
389 ) );
390 alt {
391 [] B_PORT.receive( tr_ASP_N_CONNECT_ind ) -> value vl_N_CONNECT_ind
392 {
393 v_cid_B := vl_N_CONNECT_ind.connectionId;
394 B_PORT.send( t_ASP_N_CONNECT_res( omit,// respondingAddress
395 omit,//expeditedDataSel
396 omit,//qualityOfService
397 omit, //userData
398 v_cid_B,
399 omit //importance
400 ));
401 }
402 [] B_PORT.receive
403 {
404 log( "unexpected asp received for ASP_SCCP_N_CONNECT_req, failed");
405 setverdict( fail );
406 return false;
407 }
408 [] TL_timer.timeout
409 {
410 setverdict( pass );
411 log("Timeout....");
412 return false;
413 }
414 }
415
416 // receives ASP_SCCP_N_CONNECT_cfm
417 alt {
418 [] A_PORT.receive( tr_ASP_N_CONNECT_cfm ) -> value vl_N_CONNECT_cfm
419 {
420 setverdict( pass );
421 log("f_connect finished successfully");
422 return true;
423 }
424 [] TL_timer.timeout
425 {
426 setverdict( pass );
427 log("Timeout....");
428 return false;
429 }
430 }// alt
431 log("f_connect finished");
432 return false;
433}//f_connect
434
435/****************************************************
436function f_send
437Sends an ASP_SCCP_N_DATA_req on A_PORT and waits for answer in
438B_PORT
439****************************************************/
440function f_send(in octetstring pl_userdata) runs on MTC_CT
441{
442 var ASP_SCCP_N_DATA_ind vl_N_DATA_ind;
443 timer TL_timer:= 120.0;
444 TL_timer.start;
445 A_PORT.send( t_ASP_N_DATA_req ( pl_userdata, v_cid_A, omit) ) ;
446 alt {
447 [] B_PORT.receive( tr_ASP_N_DATA_ind ) -> value vl_N_DATA_ind
448 {
449 if( vl_N_DATA_ind.userData == pl_userdata )
450 {
451 log( "userData received correctly" );
452 setverdict( pass );
453 }
454 else
455 {
456 log("user data mismatch error in f_send()")
457 setverdict(fail);
458 }
459
460 }//B_PORT.receive( tr_ASP_N_DATA_ind )
461
462 [] B_PORT.receive
463 {
464 log( "unexpected asp received for ASP_SCCP_N_DATA_req, failed");
465 setverdict( fail );
466 }
467 [] TL_timer.timeout
468 {
469 setverdict( pass );
470 log("Timeout....");
471 }
472
473 } //alt
474}//f_send
475
476//f_disconnect with timeout
477
478function f_disconnect( ) runs on MTC_CT
479{
480 var ASP_SCCP_N_DISCONNECT_ind vl_N_DISCONNECT_ind;
481 timer TL_timer:= 5.0;
482 TL_timer.start;
483 A_PORT.send(t_ASP_N_DISCONNECT_req( omit, // respondingAddress
484 0, //reason : end user originated, see 3.11/Q.713
485 omit, //userData
486 v_cid_A,
487 omit ))
488 alt {
489 [] B_PORT.receive(tr_ASP_N_DISCONNECT_ind) -> value vl_N_DISCONNECT_ind
490 {
491 setverdict( pass );
492 }
493 [] B_PORT.receive
494 {
495 log("unexpected asp received on B_PORT instead of ASP_SCCP_N_DISCONNECT_ind");
496 //repeat;
497 setverdict(fail);
498 }
499 [] TL_timer.timeout
500 {
501 setverdict( fail );
502 log("Timeout....");
503 };
504 }//alt
505
506 //give time for inner release complete (rlc):
507 alt {
508 [] TL_timer.timeout
509 {
510 setverdict( pass );
511 log("Stopped with expected timeout");
512 };
513 }
514}//f_disconnect
515
516//===================================================
517// Testcases
518//===================================================
519
520/****************************************************
521tc_ConnlessSendingShortASP
522Sends a 300 octet long userdata in one ASP_SCCP_N_UNITDATA_req
523and receives it in one ASP_SCCP_N_UNITDATA_req.
524SCCP transfers information
525in udp or (forced) xudp packets.
526****************************************************/
527testcase tc_ConnlessSendingShortASP() runs on MTC_CT
528{
529 var octetstring vl_userdata;
530 init();
531 setAddresses_gti0001();
532 vl_userdata :='12345678901234567890'O;
533 f_SendAndReceive1N_UNITDATA( vl_userdata );
534 terminate();
535 } //tc_ConnlessSendingShortASP
536
537/****************************************************
538 tc_ConnlessSendingLongASP
539 Sends a 300 octet long userdata in one ASP_SCCP_N_UNITDATA_req
540 and receives it in one ASP_SCCP_N_UNITDATA_req.
541 It is used for segmentation and reassembly.
542 SCCP transfers information
543in xudp packets
544****************************************************/
545testcase tc_ConnlessSendingLongASP() runs on MTC_CT
546{
547 var octetstring vl_userdata;
548 var integer vl_i;
549 init();
550 setAddresses_gti0001();
551 vl_userdata := ''O;
552 for(vl_i:=0;vl_i<30;vl_i:=vl_i+1) {
553 vl_userdata := vl_userdata &'12345678901234567890'O;
554 }
555 f_SendAndReceive1N_UNITDATA( vl_userdata );
556 terminate();
557}//tc_ConnlessSendingLongASP
558
559/****************************************************
560tc_ConnOrientedShortASPSending
561****************************************************/
562testcase tc_ConnOrientedShortASPSending() runs on MTC_CT
563{
564 var octetstring vl_userdata;
565 init();
566 setAddresses_gti0001();
567 vl_userdata := '12345678901234567890'O;
568 if(f_connect( ))
569 {
570 f_send(vl_userdata);
571 f_disconnect();
572 }
573 terminate();
574}
575/****************************************************
576tc_ConnOrientedLongASPSending
577****************************************************/
578testcase tc_ConnOrientedLongASPSending() runs on MTC_CT
579{
580 var octetstring vl_userdata;
581 var integer vl_i;
582 init();
583 setAddresses_gti0001();
584 vl_userdata := ''O;
585 for(vl_i:=0;vl_i<30;vl_i:=vl_i+1) {
586 vl_userdata := vl_userdata &'12345678901234567890'O;
587 }
588 if(f_connect( ))
589 {
590 f_send(vl_userdata);
591 //f_SendAndReceive1N_UNITDATA( vl_userdata );
592 f_disconnect();
593 }
594 terminate();
595}
596/****************************************************
597 CONTROL
598****************************************************/
599control
600{
601 execute( tc_ConnlessSendingShortASP() );
602 execute( tc_ConnlessSendingLongASP() );
603 execute( tc_ConnOrientedShortASPSending());
604 execute( tc_ConnOrientedLongASPSending());
605}
606
607}//module