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