summaryrefslogtreecommitdiffstats
path: root/SCCP_Test/SCCP_Testcases.ttcn
blob: b659fc6b5ab8f0c1b0c97a804042bd3d806681e2 (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
///////////////////////////////////////////////////////////////////////////////
//
//
// Copyright Test Competence Center (TCC) ETH 2007
//
//
//
// The copyright to the computer  program(s) herein  is the property of TCC. //
// The program(s) may be used and/or copied only with the written permission //
// of TCC or in accordance with  the terms and conditions  stipulated in the //
// agreement/contract under which the program(s) have been supplied
//
//
//
///////////////////////////////////////////////////////////////////////////////
//
//  File: 		    SCCP_TestCases.ttcn
//  Description:  SS7 SCCP basic SEA test
//                according to specification ITU-T SS7 SCCP, ANSI ..., TCC ... 
//  References:   ITU-T: Recommendation Q.711-Q.714, 
//                ANSI  T1.112-2001, 
//                TCC   
//  Rev:          <RnXnn>
//  Updated:	    2007.04.12
//  Contact:      http://ttcn.ericsson.se
//




//Note : this has been modified to include M3UA Emulation and SCTP Test port  
//Elemer Lelik 12.04.2017



module SCCP_Testcases
{//startmodule

modulepar 
{
  hexstring tsp_own_GT := '0614377760'H;
  hexstring tsp_remote_GT := '0614375760'H;
  integer tsp_SSN := 2; //8:MSC 5:MAP see 3.4.2.2/Q.713
  octetstring tsp_SIO := '83'O;//SCCP national
  integer tsp_own_SPC := 461087; // =0x07091E 
  integer tsp_remote_SPC := 461086; // =0x07091D
  integer tsp_SLS := 0;
  charstring tsp_sccp_serviceType := "mtp3_itu";
  
  octetstring MTP3_UserPart_SIO;
  integer MTP3_UserPart_OPC,
          MTP3_UserPart_DPC,
          MTP3_UserPart_SLS


  SCTP_Association_Address tsp_address := { 0, "", 0, "" };

}//modulepar

import from General_Types all;

import from M3UA_Types all;
import from M3UA_Emulation all;

import from MTP3asp_Types all;
import from MTP3asp_PortType all;


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


import from SCTPasp_Types all;
import from SCTPasp_PortType  all;




/*************************************
*   Components
**************************************/


// Model of MSC:
type component system_CT {
 
     port SCTPasp_PT           sctp;        

   
};




// Main test component with behaviour SCCPuserA andSCCPuserB
type component MTC_CT {
  var SCCP_PAR_Address v_CalledAddress, v_CallingAddress;
  var integer v_testvalue;
  var SCCP_CT vc_SCCP_A ;

  var M3UA_CT vc_M3UA ;

  var MSC_SCCP_MTP3_parameters v_BootA;  
  var SCCP_PAR_Connection_Id v_cid_A ;
  
  port SCCPasp_PT A_PORT; //SCCPuserA   
}

function initBootParams() runs on MTC_CT 
{
  v_BootA :=
  { sio:=
    { ni:= substr(oct2bit(tsp_SIO),0,2),
      prio:= substr(oct2bit(tsp_SIO),2,2),
      si:= substr(oct2bit(tsp_SIO),4,4)
    },
    opc:=tsp_own_SPC,
    dpc:=tsp_remote_SPC, 
    sls:=tsp_SLS, 
    sccp_serviceType:=tsp_sccp_serviceType,
    ssn:= tsp_SSN
  };
  return;
} //initBootParams

function init() runs on MTC_CT //system system_CT
{
  initBootParams();
  log("v_BootA:",v_BootA);
   
  // Protocol Stack  creation & connections:
  vc_SCCP_A:=SCCP_CT.create;
  vc_M3UA:=M3UA_CT.create;

  connect(self:A_PORT,vc_SCCP_A:SCCP_SP_PORT);
  connect(vc_M3UA:MTP3_SP_PORT,vc_SCCP_A:MTP3_SCCP_PORT);
  map(vc_M3UA:SCTP_PORT,system:sctp); 
  
  vc_M3UA.start(f_M3UA_Emulation(tsp_address));
  vc_SCCP_A.start( SCCPStart( v_BootA ) ); // Bootparameters 

 
  log( "init() is done");
  
}// init

function terminate( ) runs on MTC_CT //system system_CT
{
  log( "terminate() started");
  /*while( all component.running != true )
  {
    //waits
  }*/
    all component.stop;

  unmap(vc_M3UA:SCTP_PORT,system:sctp); 
  disconnect(vc_M3UA:MTP3_SP_PORT,vc_SCCP_A:MTP3_SCCP_PORT); 
  disconnect(self:A_PORT,vc_SCCP_A:SCCP_SP_PORT);

  
    log(" all components stopped");
    self.stop;
} //terminate

// function getOddEven returns '0' 
// if even number of dec digit can be found in GT see Q.713
function getOddEven( in hexstring pl_GT) return bitstring
{
   return int2bit( (lengthof(pl_GT) mod 2) ,1);
}

function getOddEven_ansi( in hexstring pl_GT) return bitstring
{
   if( (lengthof(pl_GT) mod 2) == 0 ) { return '0010'B;} //even
   else { return '0001'B;} //odd
}

//******************************************************************
//function setAddresses_gti0001() runs on MTC_CT
// Sets CalledAddress and CallingAddress as a gti001-type address
// according to the cfg file.
//******************************************************************

function setAddresses_gti0001() runs on MTC_CT
{
    if( (tsp_sccp_serviceType == "mtp3_itu") or 
        (tsp_sccp_serviceType == "mtp3b_itu") or
        (tsp_sccp_serviceType == "mtp3_ttc") or
        (tsp_sccp_serviceType == "mtp3b_ttc")
      ) {
      v_CalledAddress :={ 
        addressIndicator  := {
          pointCodeIndic := '1'B,
          ssnIndicator := '1'B,
          globalTitleIndic := '0001'B,
          routingIndicator := '1'B
        },//addressIndicator
        signPointCode     := SCCP_SPC_int2bit(tsp_remote_SPC, tsp_sccp_serviceType, tsp_SIO), // see SCCP.ttcn 
        subsystemNumber   := tsp_SSN,
        globalTitle := {
          gti0001:= {
            natureOfAddress := '0000011'B,
            oddeven := getOddEven( tsp_remote_GT ),
            globalTitleAddress := tsp_remote_GT
          }
        }//globalTitle
      } // v_CalledAddress
    
      v_CallingAddress :={ 
        addressIndicator  := {
          pointCodeIndic := '1'B,
          ssnIndicator := '1'B,
          globalTitleIndic := '0001'B,
          routingIndicator := '1'B
        },//addressIndicator
        signPointCode     := SCCP_SPC_int2bit(tsp_own_SPC, tsp_sccp_serviceType, tsp_SIO), // see SCCP.ttcn 
        subsystemNumber   := tsp_SSN,
        globalTitle:= { 
          gti0001 := {
            natureOfAddress := '0000011'B,
            oddeven := getOddEven( tsp_own_GT ), 
            globalTitleAddress := tsp_own_GT
          }
        }//globalTitle
      } // v_CallingAddress
      
    } else if(
        (tsp_sccp_serviceType == "mtp3_ansi") or
        (tsp_sccp_serviceType == "mtp3b_ansi")          
      ) {
      
      v_CalledAddress :={ 
        addressIndicator  := {
          pointCodeIndic := '1'B,
          ssnIndicator := '1'B,
          globalTitleIndic := '0001'B,
          routingIndicator := '0'B
        },//addressIndicator
        signPointCode     := SCCP_SPC_int2bit(tsp_remote_SPC, tsp_sccp_serviceType, tsp_SIO), // see SCCP.ttcn 
        subsystemNumber   := tsp_SSN,
        globalTitle := {
          gti0011:= {
            translationType   := int2oct(7,1),
            encodingScheme    := getOddEven_ansi( tsp_remote_GT ),        
            numberingPlan     := '0111'B,  //ISDN/mobile numbering plan, see T1.112.3-2001/3.4.2.3.1            
            globalTitleAddress:= tsp_remote_GT
          }
        }//globalTitle
      } // v_CalledAddress
      
      v_CallingAddress :={ 
        addressIndicator  := {
          pointCodeIndic := '1'B,
          ssnIndicator := '1'B,
          globalTitleIndic := '0001'B,
          routingIndicator := '0'B
        },//addressIndicator
        signPointCode     := SCCP_SPC_int2bit(tsp_remote_SPC, tsp_sccp_serviceType, tsp_SIO), // see SCCP.ttcn 
        subsystemNumber   := tsp_SSN,
        globalTitle := {
          gti0011:= {
            translationType   := int2oct(7,1),
            encodingScheme    := getOddEven_ansi( tsp_own_GT ),        
            numberingPlan     := '0111'B,  //ISDN/mobile numbering plan, see T1.112.3-2001/3.4.2.3.1            
            globalTitleAddress:= tsp_own_GT
          }
        }//globalTitle
      } // v_CallingAddress
    }//if
    
}//setAddresses_gti001

function f_SendAndReceive1N_UNITDATA(in octetstring pl_userdata) runs on MTC_CT 
{
  var ASP_SCCP_N_UNITDATA_ind vl_N_UNITDATA_ind;
  timer TL_timer:= 120.0;
  TL_timer.start;
  A_PORT.send( t_ASP_N_UNITDATA_req(  v_CalledAddress,
                                      v_CallingAddress,
                                      '00000001'B, //sequence control
                                      '00000001'B, //return option
                                      pl_userdata,
                                      omit ) );
  alt { 
    [] A_PORT.receive( tr_ASP_N_UNITDATA_ind ) -> value vl_N_UNITDATA_ind
      { 

        if( (vl_N_UNITDATA_ind.calledAddress == v_CalledAddress ) and
        (vl_N_UNITDATA_ind.callingAddress == v_CallingAddress) and 
        (vl_N_UNITDATA_ind.userData == pl_userdata) )
        {
          log("Correct  CalledAddress, CallingAddress and userData received, data are correct");
          setverdict(pass);
        }
        else
        {
          log("Some data corrupted");
          setverdict( fail );
        }
      };       
    [] TL_timer.timeout 
      { 
        setverdict( fail );
        log("Timeout....");
      };                                
  } //alt  
  TL_timer.stop;
}//f_SendAndReceive1N_UNITDATA

/****************************************************
Connection Oriented Part
****************************************************/

/****************************************************
function f_connect
Establishes a connection
(Sends an ASP_SCCP_N_CONNECT_req on A_PORT and waits for 
N_CONNECT_ind on B_PORT. If it is received, 
it sends back an ASP_SCCP_N_CONNECT_res on B_PORT and waits for
N_CONNECT_cfm on A_PORT)
****************************************************/
function f_connect() runs on MTC_CT return boolean
{
  var ASP_SCCP_N_CONNECT_ind vl_N_CONNECT_ind;
  var ASP_SCCP_N_CONNECT_cfm vl_N_CONNECT_cfm;
  setverdict(none);
  v_cid_A := 13;
  timer TL_timer:= 120.0;
  TL_timer.start; 
  
  A_PORT.send( t_ASP_N_CONNECT_req( v_CalledAddress,
                                    v_CallingAddress,
                                    omit, //expeditedDataSel
                                    omit, //QoS
                                    omit, //userData
                                    v_cid_A, 
                                    omit //importance
                                    ) );

  alt {
    [] A_PORT.receive( tr_ASP_N_CONNECT_cfm ) -> value vl_N_CONNECT_cfm
      {
        setverdict( pass );
        log("f_connect finished successfully");
        return true;
      }
    [] TL_timer.timeout 
      {
        setverdict( fail );
        log("Timeout....");
        return false;
      }
  }// alt
  log("f_connect finished");
  return false;
}//f_connect

/****************************************************
function f_send
Sends an ASP_SCCP_N_DATA_req on A_PORT and waits for answer in
A_PORT
****************************************************/
function f_send(in octetstring pl_userdata) runs on MTC_CT
{
  timer TL_timer:= 120.0;
  TL_timer.start;
  A_PORT.send( t_ASP_N_DATA_req ( pl_userdata, v_cid_A, omit) ) ;
  alt {
    [] A_PORT.receive
      {
        setverdict( pass );
        log("f_connect finished successfully");
         
      }
    [] TL_timer.timeout 
      {
        setverdict( fail );
        log("Timeout....");
         
      }
      
  } //alt
}//f_send

//f_disconnect with timeout

function f_disconnect( ) runs on MTC_CT 
{
  var ASP_SCCP_N_DISCONNECT_ind vl_N_DISCONNECT_ind;
  timer TL_timer:= 25.0;
  TL_timer.start;
  A_PORT.send( t_ASP_N_DISCONNECT_req( omit, // respondingAddress
                                      0,  //reason : end user originated, see 3.11/Q.713
                                      omit, //userData
                                      v_cid_A, 
                                      omit ))
  alt {
 
    [] A_PORT.receive
      {
        repeat;
      }
    [] TL_timer.timeout 
      { 
        setverdict( pass );
        log("Timeout....");
      };           
  }//alt
  
 
}//f_disconnect

//===================================================
// Testcases
//===================================================

/****************************************************
tc_ConnlessSendingShortASP
Sends a 300 octet long userdata in one ASP_SCCP_N_UNITDATA_req
and receives it in one ASP_SCCP_N_UNITDATA_req.
SCCP transfers information 
in udp or (forced) xudp packets.
****************************************************/
testcase tc_ConnlessSendingShortASP() runs on MTC_CT 
{
  var octetstring vl_userdata;
  init();
  setAddresses_gti0001();
  vl_userdata :='12345678901234567890'O;  
  f_SendAndReceive1N_UNITDATA( vl_userdata );
  terminate(); 
 } //tc_ConnlessSendingShortASP

/****************************************************
 tc_ConnlessSendingLongASP
 Sends a 300 octet long userdata in one ASP_SCCP_N_UNITDATA_req
 and receives it in one ASP_SCCP_N_UNITDATA_req.
 It is used for segmentation and reassembly.
 SCCP transfers information 
in xudp packets 
****************************************************/
testcase tc_ConnlessSendingLongASP() runs on MTC_CT system system_CT
{
  var octetstring vl_userdata;
  var integer vl_i;  
  init();
  setAddresses_gti0001();
  vl_userdata := ''O;
  for(vl_i:=0;vl_i<30;vl_i:=vl_i+1) {
    vl_userdata := vl_userdata &'12345678901234567890'O;  
  }
  f_SendAndReceive1N_UNITDATA( vl_userdata );
  terminate(); 
}//tc_ConnlessSendingLongASP

/****************************************************
tc_ConnOrientedShortASPSending
****************************************************/
testcase tc_ConnOrientedShortASPSending() runs on MTC_CT system system_CT
{
  var octetstring vl_userdata;
  init();
  setAddresses_gti0001();
  vl_userdata := '12345678901234567890'O;
  if(f_connect())
  {
    f_send(vl_userdata);
    f_disconnect();
  }
  terminate(); 
}
/****************************************************
tc_ConnOrientedLongASPSending
****************************************************/
testcase tc_ConnOrientedLongASPSending() runs on MTC_CT 
{
  var octetstring vl_userdata;
  var integer vl_i;  
  init();
  setAddresses_gti0001();
  vl_userdata := ''O;
  for(vl_i:=0;vl_i<30;vl_i:=vl_i+1) {
    vl_userdata := vl_userdata &'12345678901234567890'O;  
  }
  if(f_connect())
  {
    f_send(vl_userdata);
    //f_SendAndReceive1N_UNITDATA( vl_userdata );
    f_disconnect();
  }
  terminate(); 
}
/****************************************************
 CONTROL
****************************************************/
control 
{
  execute( tc_ConnlessSendingShortASP() );
  execute( tc_ConnlessSendingLongASP() );
  execute( tc_ConnOrientedShortASPSending());
  execute( tc_ConnOrientedLongASPSending());
}

}//module