StarTrinity.com

VoIP software

Sample CallXML Scripts for StarTrinity SIP Tester

The scripts should be copied from this page into SIP Tester -> Outgoing calls simulation -> XML tab, into <callxml></callxml> root element, replacing previous code.

Generation of random outgoing calls

This is a script for stress testing call centers, PBX systems, outbound dialers with SIP Tester. It generates calls with specified prefix, random caller ID (A number) and called ID (B number). Destination SIP URI is localhost:5061, it has to be replaced with actual URI.

<assign var="to" value="sip:calledIdPrefix$rand(1000,9999);@localhost:5061" />
<!-- specify destination SIP URI: prefix with 4 random digits-->

<assign var="from" value="callerIdPrefix$rand(1000,9999);" /> <!-- specify caller ID-->
<log value="calling from $from; to $to;" />
<call value="$to;" callerId="$from;"/> <!-- make a call-->
<on event="answer">
<wait value="1000ms" /> <!-- wait 1000 milliseconds -->
<exit /> <!-- terminate a call -->
</on>

Specifying custom SIP headers and SDP attributes

You can add custom SIP headers by setting attribute "headers", also add SDP attributes by setting attribute "sdpAttributes". This could be helpful for testing ED-137 SIP applications.

<!-- for outgoing calls: -->
<call value="sip:111@192.168.1.1" callerId="222"
    headers="Subject=radio|Priority=normal|WG67-Version=radio.01"
    sdpAttributes="R2S-KeepAlivePeriod:200|R2S-KeepAliveMultiplier:10|sigtime:1"
/>
<!-- for incoming calls: -->
<accept headers="WG67-Version=radio.01" sdpAttributes="R2S-KeepAlivePeriod:200|R2S-KeepAliveMultiplier:10|sigtime:1" />

Test IVR menu 1

The script reads caller ID, called ID and DTMF sequence from CSV file, creates a call and sends DTMF digits to destination.

<readcsv value="e:\list.csv" var0="destinationUri" var1="pincode" />
<!-- Read data from CSV file. The CSV file contains 2 columns: SIP URI for call and PIN code. -->
<log value="read next row from CSV and save it into variables: destinationUri = $destinationUri;, pincode=$pincode;" />
<log value="calling (sending INVITE to) $destinationUri;" />
<call maxringtime="10000ms" value="$destinationUri;" />
<on event="answer">
     <log value="destination answered (received 200 OK). making pause = 1 second (waiting for IVR message)" />
     <wait value="1000ms" />
     <log value="sending DTMF digit 1 (press 1 if you are existing customer)" />
     <playdtmf value="1" />
     <wait value="1000ms" />
    <log value="sending DTMF digits $pincode; (enter your pincode)" />
    <playdtmf value="$pincode;" />
    <wait value="3000ms" />

     <block probability="0.5" >
         <log value="50% of calls: sending additional DTMF '3'" />
         <playdtmf value="3" />
         <wait value="10000ms" />
         <log value="aborting call" />
         <exit />
     </block>

     <block probability="0.5" >
         <log value="25% of calls: sending additional DTMF '123'" />
         <playdtmf value="123" />
         <wait value="10000ms" />
         <log value="aborting call" />
         <exit />
     </block>

     <log value="25% of calls: sending additional DTMF '456'" />
     <playdtmf value="456" />
     <wait value="10000ms" />
     <log value="aborting call" />
     <exit />
</on>

Test IVR menu 2

Another script example simulates several DTMF keys and records audio into WAV file. Recording contains both debugging prompts with synthesised speech and audio from tested IVR.

<log value="calling..." />
<call value="sip:1001@192.168.56.1:5061?user=user1&password=pass1" /> <!-- make a call -->
<on event="answer"> <!-- handle 'answer' event (receiving of 200 OK) -->
<log value="answered" />
<recordcall value="100" /> <!-- record mix of RX and TX streams for verification of IVR announcements -->

<!-- we are in top-level menu -->
<wait value="$rand(3,6);s" /> <!-- make a random delay from 3 to 6 seconds -->
<assign var="dtmf" value="$rand(1,2);" /> <!-- declare variable 'dtmf' and set it to random number from 1 to 2 -->
<playdtmf value="$dtmf;" /> <!-- simulate DTMF using the variable -->
<log value="sent DTMF: $dtmf;" /> <!-- report it to log -->
<say voice="Microsoft Anna" value="pressed $dtmf;" /> <!-- report it to WAV file for further checking in recorded file -->
<wait value="$rand(10,20);s" /> <!-- make a random delay from 10 to 20 seconds -->

<block test="$dtmf;=1"> <!-- check if we have sent 1 -->
     <!-- we are in submenu for DTMF=1 -->
     <wait value="$rand(3,6);s" /> <!-- make a random delay from 3 to 6 seconds -->
     <assign var="dtmf" value="$rand(1,6);" /> <!-- set variable 'dtmf' to random number from 1 to 6 -->
     <playdtmf value="$dtmf;" /> <!-- simulate DTMF using the variable -->
     <log value="sent DTMF: $dtmf;" /> <!-- report it to log -->
     <say voice="Microsoft Anna" value="pressed $dtmf;" /> <!-- report it to WAV file for further checking in recorded file -->
     <wait value="$rand(10,20);s" /> <!-- make a random delay from 10 to 20 seconds -->
</block>

<block test="$dtmf;=2">
     <!-- we are in submenu for DTMF=2 -->
     <wait value="$rand(3,6);s" /> <!-- make a random delay from 3 to 6 seconds -->
     <assign var="dtmf" value="$rand(0,9);" /> <!-- set variable 'dtmf' to random number from 0 to 9 -->
     <playdtmf value="$dtmf;" /> <!-- simulate DTMF using the variable -->
     <log value="sent DTMF: $dtmf;" /> <!-- report it to log -->
     <say voice="Microsoft Anna" value="pressed $dtmf;" /> <!-- report it to WAV file for further checking in recorded file -->
     <wait value="$rand(10,20);s" /> <!-- make a random delay from 10 to 20 seconds -->
</block>

<wait value="5s" />
<log value="aborting call" />
<exit />
</on>

Test audio quality (PESQ MOS) in a conference server

The conference server should be tested by 2 separate instances of SIP Tester. They can run on the same server on different SIP ports ("LocalSIPPort" setting). The first instance simulates call load of about 30 concurrent calls, it plays silence to the conference. The second instance generates pairs of calls, verifies audio signal and measures PESQ MOS. A pair of calls is generated if you set "number of calls to generate at a time" = "2"

<!-- script for 1st instance of sip tester which generates main call load and plays silence to the conference -->
<!-- dial number 123456, send a call to conference server -->
<call value="sip:123456@1.10.10.10:5060" codec="G711A" maxringtime="30s" />
<on event="answer">
  <waitforsignal value="-24dB" /> <!-- when answered, wait for IVR prompt -->
  <playdtmf value="1234#" /> <!-- enter PIN code to enter a conference room -->
  <wait value="60s" /> <!-- don't do anything, play silence during 60 seconds -->
  <exit /> <!-- abort call -->
</on>


<!-- script for 2nd instance of sip tester which plays audio and measures PESQ MOS -->
<!-- dial number 123456, send a call to conference server -->
<call value="sip:123456@1.10.10.10:5060" codec="G711A" maxringtime="30s" />
<on event="answer">
  <waitforsignal value="-24dB" /> <!-- when answered, wait for IVR prompt -->
  <playdtmf value="1234#" /> <!-- enter PIN code to enter a conference room -->
  <wait value="2s" /> <!-- wait for pin code recognition -->
  <playaudio value="speech.wav" dontwait="true" /> <!-- start playing audio to the conference -->

  <verifyaudio reference="speech.wav" maxtime="12s" mosvar="mos" recognizeddelayvar="delay" />
<!-- at the same time start audio verification of signal from another call which goes through conference -->

  <log value="measured PESQ MOS = $mos;, conference audio delay = $delay;ms" />
  <writecdr header="CONFERENCE_MOS" value="$mos;" numeric="true" qualityIsAscending="true" />
  <writecdr header="CONFERENCE_DELAY" value="$delay;" numeric="true" qualityIsAscending="false" />

  <exit /> <!-- abort call -->
</on>

Here is a script to simulate the conference in SIP Tester:

<accept/>
<inputdigits value="music.wav" var="roomNumber" maxsilence="10s" maxdigits="10" />
<log value="entering room number $roomNumber;" />
<conference value="$roomNumber;" />

Test audio quality (PESQ MOS) in a conference server (long-duration calls)

SIP Tester should be configured to make N calls in burst, and to limit number of concurrent calls to N. First call in burst plays audio to the conference, secondary calls listen to audio signal from the conference server and measure audio quality

<!-- dial number 123456, send a call to conference server -->
<call value="sip:123456@192.168.10.1:5060" codec="G711A" maxringtime="30s" />
<on event="answer">
 <log value="call is answered [callNumberInBurst = $callNumberInBurst;]" />
 <assign var="measurementsPerCall" value="20" /> <!-- test call contains multiple serial measurements of audio quality -->
 <if test="$callNumberInBurst; = 0"> <!-- first call in burst: play audio + silence in loop -->
  <wait value="5s" />
  <block repeat="$measurementsPerCall;">
   <log value="playing sound [callNumberInBurst = $callNumberInBurst;]" />
   <playaudio value="speech.wav" />
   <log value="playing silence [callNumberInBurst = $callNumberInBurst;]" />
   <wait value="10s" /><!-- pause needed to complete audio verification - calculate PESQ MOS -->
  </block>
 </if>
 <else> <!-- secondary calls in burst: recognize audio from the 1st call, measure audio quality -->
  <recordcall value="100" /> <!-- record audio into wav for further analysis -->
  <assign var="minMos" value="5" />
  <block repeat="$measurementsPerCall;" var="loopCounter" >
   <log value="waiting for signal [callNumberInBurst = $callNumberInBurst;]" />
   <waitforsignal />
   <log value="recognizing audio [callNumberInBurst = $callNumberInBurst;]" />
   <verifyaudio reference="speech.wav" maxtime="12s" mosvar="mos" recognizeddelayvar="delay" />
   <log value="measured PESQ MOS = $mos;, conference audio delay = $delay;ms [callNumberInBurst = $callNumberInBurst;]" />
   <if test="$loopCounter; != 0">
    <writecdr header="CONFERENCE_measurements_count" value="$loopCounter;" numeric="true" qualityIsAscending="true" />
    <if test="$mos; < $minMos;">
     <assign var="minMos" value="$mos;" />
     <writecdr header="CONFERENCE_min_MOS" value="$minMos;" numeric="true" qualityIsAscending="true" />
    </if>
   </if>
  </block>
 </else>
</on>

Here is a script to simulate the conference in SIP Tester:

<accept/>
<conference value="01" />

Test audio quality (PESQ MOS) and DTMF capability of a VoIP route (SIP trunk) in 2 directions

The 2 scripts (incoming and outgoing) are used to make test calls via a SIP route to check its audio quality and DTMF passability in 2 ways (from A to B and from B to A)

<!-- outgoing script (for call generator) -->
<!-- change destination number and IP address to what you need -->
<call value="sip:1234567890@12.34.56.78:5060" maxringtime="30s">
 <on event="answer">
  <playaudio value="speech.wav" repeat="infinite" maxtime="30s" />

  <wait value="1s" />
  <log value="(A, step 2) verifying audio" />
  <verifyaudio reference="speech.wav" maxtime="12s" mosvar="pesq_mos" />
  <writecdr header="PESQ_MOS_BtoA" value="$pesq_mos;" numeric="true" qualityIsAscending="true" />
  <waitforsilence />

  <log value="(A, step 3) receiving DTMF" />
  <inputdigits var="received_digits" maxdigits="10" maxsilence="15s" />
  <writecdr header="DTMF_BtoA" value="$received_digits;" />

  <wait value="10s" />
  <log value="(A, step 4) sending DTMF" />
  <playdtmf value="1234567890" />
  <wait value="10s" />

  <exit />
 </on>
</call>

<!-- incoming script (for call receiver) -->
<accept />
<verifyaudio reference="speech.wav" maxtime="12s" mosvar="pesq_mos" />
<writecdr header="PESQ_MOS_AtoB" value="$pesq_mos;" numeric="true" qualityIsAscending="true" />
<waitforsilence minTimeBelowLevel="1s" />

<log value="(B, step 2) got silence, playing audio" />
<playaudio value="speech.wav" repeat="infinite" maxtime="30s" />
<wait value="2s" />

<log value="(B, step 3) sending DTMF" />
<playdtmf value="1234567890" />
<wait value="10s" />

<log value="(B, step 4) receivingDTMF" />
<inputdigits var="received_digits" maxdigits="10" maxsilence="10s" />
<writecdr header="DTMF_AtoB" value="$received_digits;" />

<exit />

Test outbound dialer

The script processes incoming calls which are generated by dialer. It makes random delays, accepts or rejects call.

<log value="received call from '$callerId;'" />
<block probability="0.05" > <!-- executes code inside this block with probability = 0.05 (for 5% of incoming calls) -->
     <log value="rejecting with 500 after delay" />
     <wait value="$rand(100000);ms" /> <!-- For 5% of calls: make random delay, 100 seconds in average -->
     <reject value="500" /> <!-- reject call with SIP status = 500 (Internal Server Error) -->
     <exit />
</block>

<!-- For remaining 95% of calls: make random delay (1 second in average) before sending 183 Session Progress with early media --> <wait value="$rand(1000);ms" />
<accept value="183" />
<log value="sent 183" />

<on event="hangup">
 <log value="call is disposed by remote side" />
</<on>

<!-- 5% of remaining calls: reject with 486 (Busy Here) -->
<block probability="0.05" >
     <log value="rejecting with 486 after pause" />
     <wait value="$rand(1000);ms" />
     <reject value="486" />
     <exit />
</block>

<!-- 5% of remaining calls: play busy tone from file for 30 seconds and reject with 486 (Busy Here) -->
<block probability="0.05" >
     <log value="rejecting with 486 after busy tone" />
     <playaudio value="busytone.wav" maxtime="30s" /> <!-- plays tone from file (please download it into your program's folder) -->
     <reject value="486" />
</block>

<accept /> send 200 OK response
<log value="sent 200" />

<block probability="0.5" > <!-- answer machine -->
     <log value="simulating answer machine" />
     <say voice="Microsoft Anna" value="Hello, please enter extension number" maxsilence="30s" />
     <inputdigits var="enteredExtension" maxdigits="4" />
     <block test="$enteredExtension; != 1234"><!-- verify entered extension -->
         <log value="ERROR: expected extension '1234' but received '$enteredExtension;'" />
         <say voice="Microsoft Anna" value="extension $enteredExtension; is not valid" />
         <exit />
     </block>
     <say voice="Microsoft Anna" value="connecting to extension $enteredExtension;" />
     <wait value="$rand(10000);ms" />
     <exit />
</block>

<!-- real live call -->
<log value="simulating live call" />
<playaudio value="music" maxtime="100s" />

Text-to-speech IVR with MSSQL request
<accept /> <!-- Accept incoming call: send 200 OK to SIP-UAC -->
<say voice="Microsoft Anna" value="This is text-to-speech announcement. Please enter some number and press pound key." />
<!-- Play text message using default text-to-speech SAPI5 engine -->
<inputdigits var="enteredNumber" maxsilence="20s" maxdigits="10" />
<!-- Collect DTMF digits from user, store in variable "enteredNumber" -->
<say voice="Microsoft Anna" value="You have entered $enteredNumber;" />

<requestdb command="select InfoMessage from Table1 where PinCode = '$enteredNumber;'"
    connection="Data Source=(local)\SQLEXPRESS;User ID=sa;Password=123;Initial Catalog=DtmfTest;Asynchronous Processing=true"
    var0="infoMessage" /> <!-- Request table from MSSQL database and store a column in variable "enteredNumber" -->
<say voice="Microsoft Anna" value="$infoMessage;" /><!-- Speak message from database -->

Sending custom SIP request after provisional response for outgoing calls
<call callerId="" value="sip:100@localhost"/> <!-- Make outgoing SIP call to 100@localhost -->
<on event="pr"> <!-- Handler for provisional responses (180, 183) -->
<sendsiprequest>
<!-- Send custom SIP request (NOTIFY) within same INVITE session. Headers like Call-ID and request URI will be overridden, content length will be calculated automatically -->
<![CDATA[
NOTIFY sip:xx.yy.zz SIP/2.0
User-Agent: XYZ
Event: message-summary
Content-Type: application/simple-message-summary

Messages-Waiting: no
Message-Account: sip:*97@10.10.10.10
Voice-Message: 0/0 (0/0)
]]>
</sendsiprequest >
</on>
<on event="answer"> <!-- Handler for final response (200 OK) -->
<playaudio value="music" repeat="10000" maxtime="10000ms" />
<exit />
</on>
custom NOTIFY request generated by <sendsiprequest> element in CallXML

Sending different SDPs in 183 and 200 response for incoming calls

The script could be used to check whether SIP caller is able to adjust RTP stream according to changed SDP response in 200 OK

<sendsipmessage>
<![CDATA[
SIP/2.0 180 Ringing
Via: $sipHeaderVia;
Call-ID: $sipCallId;
From: $sipHeaderFrom;
To: $sipHeaderTo; ;tag=b6a1c0b8e8334ef4b89f6a4d6154bbe1
CSeq: $sipHeaderCSeq;
Contact: <sip:192.168.0.13:5070>
Allow: INFO, PRACK, SUBSCRIBE, NOTIFY, REFER, INVITE, ACK, BYE, CANCEL, UPDATE
Server: StarTrinity.SIP 2014-04-28 20:20 UTC
Content-Type: application/sdp
Content-Length: 252

v=0
o=- 3607723560 3607723560 IN IP4 192.168.0.66
s=i14.proxy.stream0
t=0 0
m=audio 6666 RTP/AVP 8 101
c=IN IP4 192.168.0.66
a=rtcp:6667 IN IP4 192.168.0.66
a=rtpmap:8 PCMA/8000
a=sendrecv
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
]]>
</sendsipmessage>

<!-- at this time caller should send RTP to 192.168.0.66 -->
<wait value="3s" />

<sendsipmessage>
<![CDATA[
SIP/2.0 200 OK
Via: $sipHeaderVia;
Call-ID: $sipCallId;
From: $sipHeaderFrom;
To: $sipHeaderTo; ;tag=b6a1c0b8e8334ef4b89f6a4d6154bbe1
CSeq: $sipHeaderCSeq;
Contact: <sip:192.168.0.13:5070>
Allow: INFO, PRACK, SUBSCRIBE, NOTIFY, REFER, INVITE, ACK, BYE, CANCEL, UPDATE
Server: StarTrinity.SIP 2014-04-28 20:20 UTC
Content-Type: application/sdp
Content-Length: 252

v=0
o=- 3607723560 3607723560 IN IP4 192.168.0.77
s=i14.proxy.stream0
t=0 0
m=audio 7777 RTP/AVP 8 101
c=IN IP4 192.168.0.77
a=rtcp:7778 IN IP4 192.168.0.77
a=rtpmap:8 PCMA/8000
a=sendrecv
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
]]>
</sendsipmessage>

<!-- after this 200 OK response caller should send RTP to 192.168.0.77 -->
<wait value="100s" />
<exit/>

Sending custom SIP INVITE without initial SDP

The script sends custom SIP message to server without creating call (only for testing SIP stack). The message is specified by 'CDATA' content of XML element. Call-ID header is generated from CallXML session ID.

<sendsipmessage>
<![CDATA[
INVITE sip:192.168.206.197:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.206.197:5060;branch=z9hG4bK18171d2b3f11
From: "2000" <sip:2000@192.168.206.197>;tag=104574~6a5c17ac-9109-44e8-b315-975d70cd1b5d-22861245
To: <sip:1000@192.168.206.197>
Date: Mon, 29 Jul 2013 20:55:20 GMT
Call-ID: SipTester$Id;
Supported: timer,resource-priority,replaces
Min-SE: 1800
User-Agent: Cisco-CUCM8.6
Allow: INVITE, OPTIONS, INFO, BYE, CANCEL, ACK, PRACK, UPDATE, REFER, SUBSCRIBE, NOTIFY
CSeq: 101 INVITE
Expires: 180
Allow-Events: presence
Send-Info: conference, x-cisco-conference
Alert-Info: <file://Bellcore-dr1/>
Contact: <sip:2000@192.168.206.197:5060>
Remote-Party-ID: "2000" <sip:2000@192.168.206.197;x-cisco-callback-number=2000>;party=calling;screen=yes;privacy=off
Max-Forwards: 69

]]>
</sendsipmessage>

Sending custom SIP INVITE with 2 media streams in SDP

The script sends custom SIP message to server without creating call (only for testing SIP stack). The message is specified by 'CDATA' content of XML element. SIP Tester automatically calculates 'Content-Length' header, so only 'Content-Type' header is needed. Call-ID header is generated from CallXML session ID.

<sendsipmessage>
<![CDATA[
INVITE sip:192.168.206.197:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.206.197:5060;branch=z9hG4bK18171d2b3f11
From: "2000" <sip:2000@192.168.206.197>;tag=104574~6a5c17ac-9109-44e8-b315-975d70cd1b5d-22861245
To: <sip:1000@192.168.206.197>
Call-ID: SipTester$Id;
Supported: timer,resource-priority,replaces
User-Agent: StarTrinity SIP Tester
Allow: INVITE, OPTIONS, INFO, BYE, CANCEL, ACK, PRACK, UPDATE, REFER, SUBSCRIBE, NOTIFY
CSeq: 101 INVITE
Expires: 180
Contact: <sip:2000@192.168.206.191:5060>
Max-Forwards: 69
Content-Type: application/sdp

v=0
o=root 342983111 342983111 IN IP4 192.168.1.188
s=Asterisk PBX 1.6.2.15
c=IN IP4 192.168.1.188
t=0 0
m=audio 11568 RTP/AVP 18 8 0
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=ptime:20
a=sendrecv
m=image 4488 udptl t38
a=T38FaxVersion:0
a=T38MaxBitRate:14400
a=T38FaxRateManagement:transferredTCF
a=T38FaxMaxDatagram:397
a=T38FaxUdpEC:t38UDPRedundancy
]]>
</sendsipmessage>

Monitoring SIP server with email notifications

This script makes a call to a SIP server and sends email alarms on success and failure. The SIP Tester Tool could be configured execute script periodically. Note that interval between calls has to be large enough to avoid anti-spam protection at mail server. The sendemail element uses settings "MailSenderUserName", "MailSenderPassword", "MailSenderServer", "MailSenderFrom", they are configured in SIP Tester on settings screen.

<call callerId="123456" value="sip:7890123@192.168.1.57:5060" /> <!-- send INVITE to destination SIP server and check its availability -->
<on event="answer"> <!-- handle 'answer' event which means receiving 200 OK from destination -->
  <assign globalvar="recurringFailuresCount" value="0" />
  <block test="$global.available; != true"> <!-- don't send same email twice -->
   <assign globalvar="available" value="true" />
   <sendemail value="mailto:username@gmail.com?subject=sip testing - OK&amp;body=received 200 OK response from server" />
  </block>
  <exit />
</on>
<on event="callfailure"> <!-- handle 'callfailure' event which means receiving error response from server or not receiving response on timeout -->
  <assign globalvar="recurringFailuresCount" mathvalue="$global.recurringFailuresCount; + 1" />
 <block test="$global.recurringFailuresCount; > 3 and $global.available; != false"> <!-- alert only after 3 repetitive failures; don't send same email twice -->
  <assign globalvar="available" value="false" />
  <sendemail value="mailto:username@gmail.com?subject=sip testing - call failed with status $eventSubType;&amp;body=call failed with status $eventSubType;"/>
 </block>
 <exit/>
</on>

Simulating RE-INVITE (put SIP call on hold)

Script for call generator:

<call value="sip:2222@server.com:5060"/>
<on event="answer">
 <playaudio value="music" maxtime="5s" />
 <reinvite direction="SendOnly" />
 <playaudio value="music" maxtime="5s" />
 <reinvite direction="ReceiveOnly" />
 <playaudio value="music" maxtime="5s" />
 <reinvite direction="None" />
 <playaudio value="music" maxtime="5s" />
 <reinvite direction="Both" />
 <playaudio value="music" maxtime="5s" />
 <exit />
</on>

Script for call receiver:

<accept />
<playaudio value="music" />
<!-- at this time SIP Tester responds 200 OK to incoming RE-INVITEs and automatically adjusts media direction -->

Simulating REFER (call transfer)

Script for call generator:

<call value="sip:2222@server.com:5060"/>
<on event="answer">
 <wait value="100s" />
<!-- at this time SIP Tester receives REFER and automatically makes transfer -->
 <exit />
</on>

Script for call receiver:

<accept />
<wait value="5s" />
<block test="$calledId; != redirected">
 <transfer value="sip:redirected@server.com:5060" mode="blind" /> <!-- send REFER -->
</block>
<exit />

Identification of IVR messages

This script recognizes audio signal in RTP stream, compares it with list of predefined WAV/MP3 files. The resuts are saved into variables and to CDR report. Audio verification is used to test IVR menus and check performance of IVR servers.

<playdtmf value="1" /> <!-- simulate DTMF key "1" -->
<verifyaudio reference="c:\ivr2.wav;c:\ivr3.wav" maxtime="10s" recognizeddelayvar="delay" recognizedreferencevar="ref" confidencevar="conf" />
<!-- verify audio signal in RTP stream during 10 seconds, identify which IVR message is played (one of reference files ivr3.wav or ivr2.wav). reference files have to be in WAV or MP3 format. they should contain original IVR messages which are played by server
results are saved to variables:
recognizeddelayvar="delay" - delay in milliseconds between start of verification and start of identified IVR message
                                        - IVR server's response time to DTMF event
recognizedreferencevar="ref" - name of identified reference file
confidencevar="conf" - confidence rate of identification, from 0 to 100 -->

<log value="delay = $delay;ms, reference file = $ref;, confidence = $conf;" /> <!-- show results in "Log" tab -->
<writecdr header="IVR" value="$ref;" /> <!-- save results to CDR report -->
<writecdr header="IVRCONF" value="$conf;" />

PESQ MOS (mean opinion score) audio quality measurement

This script measures audio quality of IVR message which is played by destination server

<verifyaudio reference="speech.wav" maxtime="10s" mosvar="mos" />
<!-- verify audio signal in RTP stream during 10 seconds, measure MOS.
reference file has to be in WAV or MP3 format. it should contain original IVR message which is played by server
result is saved to 'mos' variable -->

<log value="MOS = $mos;" /> <!-- show result in "Log" tab -->
<writecdr header="MOS" value="$mos;" numeric="true" qualityIsAscending="true" /> <!-- save result to CDR report, analyze it as numeric performance indicator -->

Client-server-client audio path verification
If SIP Tester is installed on both server side and on client side, it could be configured to test IP network for ability to pass RTP audio correctly.
  • Client-side SIP Tester generates SIP calls, transmits RTP audio to the server-side SIP Tester
  • Server-side SIP Tester accepts SIP calls, receives RTP audio and plays exactly same audio back to client (creates loopback connection)
    <accept />
    <loopbackaudio />
    If there is a NAT, you should set settings "SymmetricSIP" = "1" and "SymmetricRTP" = "1" on server-side SIP Tester
  • Client-side SIP Tester verifies the received audio if it equals to what it transmitted
    <call value="sip:test@server.com" maxringtime="60s" />
    <on event="answer">
      <playaudio value="speech.wav" dontwait="true" />
      <verifyaudio reference="speech.wav" maxtime="15s" confidencevar="confidence" />
         <writecdr header="CONFIDENCE" value="$confidence;" numeric="true" qualityIsAscending="true" />
      <exit/>
    </on>

Checking availability of SIP server using command line interface (CLI)

This script makes SIP call to a server and returns SIP status code into .bat file.

CallXML file (c:\srcipt.xml)
<callxml>
<log value="calling SIP server: $serverUri;" /> <!-- writes to command line output stream -->
<call value="$serverUri;" /> <!-- get command line parameter 'serverUri' and make outgoing call to server -->
<on event="answer">
    <log value="SIP server has answered to call"/>
    <playaudio value="music" repeat="10000" maxtime="20s" />
    <setexitcode value="200"/> <!-- save result to exit code of process -->
    <exit />
</on>
<on event="callfailure">
    <log value="call failed with status = $eventSubType;" />
    <setexitcode value="$eventSubType;" /> <!-- save result to exit code of process -->
</on>
</callxml>
test.bat file launches SIP Tester via CLI, passes server SIP URI as parameter, makes 2 calls to the server and reports status of last SIP call.
StarTrinity.SIPTester.CLI.exe TotalCalls 2 serverUri sip:100@192.168.1.1:5060 OutgoingCallXmlFile "c:\script.xml"
echo SIP status code is %ERRORLEVEL%

Verifying list of accounts using SIP REGISTER

The script is used by VoIP resellers to verify millions of SIP accounts to determine which are valid and which are not. Users and passwords are read from CSV file c:\siptester_files\users.csv. Results of testing are saved to users_suceeded.csv and users_failed.csv files. You can change file names and format of files by editing the script.

For current date, SIP Tester is able to verify about 500-1000 users per second on an average i3 desktop PC.

<readcsv value="c:\siptester_files\users.csv" var0="user" var1="password" /> <!-- read a line from CSV file into 'user' and 'password' variables -->
<register value="sip:sipserver.com:5060?user=$user;&amp;password=$password;" var="result" delayvar="delay" />
<!-- send REGISTER to a server to check account credentials. save SIP result code to a variable -->
<report value="$delay;" name="REGISTER response delay" qualityIsAscending="false" />
<!-- save measured response delay to SIP Tester GUI and HTML report -->
<report value="$result;" name="REGISTER result" qualityIsAscending="false" />
<block test="$result; = 200"> <!-- check if result of registration is successful -->
    <writefile fileName="c:\siptester_files\users_suceeded.csv" newLine="true" value="$user;;$password;" />
    <!-- save user and password to CSV file -->
    <exit/>
</block>
<writefile fileName="c:\siptester_files\users_failed.csv" newLine="true" value="$user;;$password;;$result;" />
<!-- save user, password, result code to CSV file -->

Verifying list of accounts using SIP INVITE

The script reads SIP URIs line by line from a text file C:\siptester_files\sipUris.txt and sends SIP INVITE messages (generates test calls) to check accounts on one or multiple servers. Results are saved to 2 separate files for suceeded and failed calls. SIP tester is able to generate about 200-500 calls per second on an average desktop i3 PC

<readcsv value="C:\siptester_files\sipUris.txt" var0="sipUri" />
<call value="$sipUri;" sendSdpInInitialInvite="false" />
<on event="answer">
    <writefile newLine="true" fileName="C:\siptester_files\suceeded.txt" value="$sipUri;" />
    <exit />
</on>

Playing random WAV file for incoming calls
<wait value="$rand(9,50);s" /> <!-- wait random time from 9 to 50 seconds before answering to call -->
<assign var="fn" value="$rand_from_options;"> <!-- initialize variable 'fn' with one of random options -->
    <option value="wav\incoming01.wav" />
    <option value="wav\incoming02.wav" />
    <option value="wav\incoming03.wav" />
</assign>
<accept /> <!-- answer to incoming call -->
<playaudio value="$fn;" /> <!-- play audio message until end of file -->
<exit />

Writing custom CDR files for incoming calls using <writefile />
<assign var="aNumber" value="$callerId;" />
<assign var="bNumber" value="$calledId;" />
<assign var="redirectedNumber" value="$redirectedNumber;" /><!-- get redirected number from SIP Diversion header -->
<assign var="callStart" value="$time();" />

<block probability="0.2"><!-- answer to 20% of calls -->
 <accept />
 <assign var="callEnd" value="$time();" />
 <disconnect />
<!-- save record to CDR file, split the file every 10 minutes -->
 <writefile newLine="true" fileName="F:\ftproot\ACCEPTED.txt" splitInterval="10m"
   value="$callStart;;$callEnd;;$aNumber;;$bNumber;;$redirectedNumber;" />
<exit/>
</block>

<reject value="503"/><!-- reject 80% of calls with status = 503 (Service Unavailable) -->
<assign var="callEnd" value="$time();" />
<writefile newLine="true" fileName="F:\ftproot\REJECTED.txt" splitInterval="10m"
  value="$callStart;;$callEnd;;$aNumber;;$bNumber;;$redirectedNumber;" />
<exit/>

Calling list of B numbers from CSV file with regular expression filter

The script is used to verify connectivity and billing in a customer's VoIP system. A and B numbers are read from custom CSV files: a_numbers.csv - one column with A numbers; b_numbers.csv - 1st column with B numbers, 2nd column with number of call attempts for each B number. CDR reports are saved into folder F:\ftproot in custom format. The CDRs files are separate for suceeded and failed SIP calls. Additionally, SIP Tester splits the files every 10 minutes.

<readcsv value="a_numbers.csv" var0="numA" mode="random" /><!-- read A number into variable -->
<block test="$numA; matches ^509.+" >
 <log value="skipping this number because it matches pattern 509xxx" />
 <exit />
</block>
<block test="$numA; matches ^00509.+" >
 <log value="skipping this number because it matches pattern 00509xxxx" />
 <exit />
</block>

<readcsv value="b_numbers.csv" var0="numB" countsColumnIndex="1" repeat="1" mode="random" />
<!-- read B number into variable -->

<log value="calling from $numA; to $numB;" />
<call value="sip:$numB;@10.10.1.50" callerId="$numA;" maxringtime="60s" /><!-- make outgoing call using A and B variables -->

<on event="answer">
 <log value="call answered from $numA; to $numB;" />
 <wait value="$rand(1000,3000);ms" /><!-- wait random time interval from 1 to 3 seconds -->
 <assign var="callEnd" value="$time();" />

<!-- save record into CSV CDR file with custom format. -->
 <writefile newLine="true" fileName="F:\ftproot\SUCEEDED.txt" splitInterval="10m" value="$callStart;;$callEnd;;$numA;;$numB;" />
 <on event="hangup"> <!-- call is aborted by called party -->
  <assign var="callEnd" value="$time();" />
  <writefile newLine="true" fileName="ftproot\SUCEEDED.txt" splitInterval="10m" value="$callStart;;$callEnd;;$numA;;$numB;" />
 </on>
 <exit /><!-- abort outgoing call -->
</on>
<on event="callfailure"><!-- call failed: received error response from destination server -->
 <log value="call failed from $numA; to $numB;" />
 <assign var="callEnd" value="$time();" />
 <writefile newLine="true" fileName="F:\ftproot\FAILED.txt" splitInterval="10m" value="$callStart;;$callEnd;;$numA;;$numB;" />
</on>
<on event="maxringtime"><!-- call is not answered in maxtime=60sec -->
 <log value="call timed out from $numA; to $numB;" />
 <assign var="callEnd" value="$time();" />
 <writefile newLine="true" fileName="F:\ftproot\FAILED.txt" splitInterval="10m" value="$callStart;;$callEnd;;$numA;;$numB;" />
</on>

Calling list of A and B numbers from 2 CSV file (2 countries) via 2 servers

The script is used to generate test VoIP traffic to multiple countries via multiple servers (your softswitches), reading A and B numbers from separate CSV files (one CSV file per country). CSV files contain 2 columns: B number (called ID) in 1st column and A number (caller ID) in 2nd column. The scripts limits number of concurrent calls (channels) per country. When call is answered, a random audio is played from directory with wav files

<readcsv value="C:\StarTrinity\CSV\Morocco160125.csv" var0="f0_1" var1="f1_1" repeat="infinite"/>
<readcsv value="C:\StarTrinity\CSV\Lybia160125.csv" var0="f0_2" var1="f1_2" repeat="infinite"/>
<call maxringtime="35000ms" value="$rand_from_options;" codec="G729" >
 <option value="sip:$f0_1;@[ip1]?callerId=$f1_1;" maxCallsPerDestinationResource="100" destinationResourceId="server1" />
 <option value="sip:$f0_2;@[ip2]?callerId=$f1_2;" maxCallsPerDestinationResource="200" destinationResourceId="server2" />
</call>
<on event="answer">
 <playaudio value="$randfile(C:\StarTrinity\Wav Files\*.wav);" repeat="infinite" maxtime="$rand(670000);ms" />
 <exit />
</on>

Generating DTMF tones for incoming calls

The script answers to incoming calls and generates a DTMF tone signals

<accept />
<playdtmf value="1" />
<!-- sends DTMF digit using SIP INFO or RTP stream. Alternatively you can play DTMF tone from audio file using "playaudio" -->
<wait value="500ms" />
<playdtmf value="2" />
<wait value="500ms" />
<playdtmf value="3" />
<wait value="500ms" />
<exit />

Playing different IVR messages for incoming calls based on Called ID
<accept />
<if test="$calledId; startswith 44">
 <log value="Called number starts with 44" />
 <playaudio value="IVR1.wav" />
 <exit />
</if>
<if test="$calledId; startswith 1">
 <log value="Called number starts with 1" />
 <playaudio value="IVR2.wav" />
 <exit />
</if>
<playaudio value="IVR3.wav" />
<exit />

Randomly simulate T.38 fax CED tone to test auto-dialer fax machine detector
<log value="received incoming call" />
<accept />
<wait value="3s" />
<block probability="0.1">
 <log value="simulating fax for this call" />
 <writecdr header="simulated_fax" value="1" />
 <receivefax />
 <exit/>
</block>

<log value="playing audio for this call" />
<writecdr header="simulated_fax" value="0" />
<playaudio value="music.wav" maxtime="$rand(100);s" />
<exit/>

Specifying RTP port numbers explicitly for incoming and outgoing calls
<!-- script for outgoing calls: port numbers 7000..7990 -->
<assign globalvar="portCounter1" mathvalue="$global.portCounter1; + 2" />
<if test="$global.portCounter1; > 990"> <assign globalvar="portCounter1" value="0"/> </if>
<assign var="port" mathvalue="$global.portCounter1; + 7000" />
<log value="using RTP port $port; for outgoing call" />
<call value="sip:111@10.10.10.1:5060" callerId="1111" localRtpPort="$port;" />
<on event="answer"> 
 <playaudio value="music.wav" maxtime="50s" />
</on>


<!-- script for incoming calls: port numbers 8000..8990 -->
<assign globalvar="portCounter2" mathvalue="$global.portCounter2; + 2" />
<if test="$global.portCounter2; > 990"> <assign globalvar="portCounter2" value="0"/> </if>
<assign var="port" mathvalue="$global.portCounter2; + 8000" />
<log value="using RTP port $port; for incoming call" />
<accept localRtpPort="$port;" />
<playaudio value="music2.wav" repeat="infinite" maxtime="20000ms" />
<exit />

Making a pause in test if destination server fails
<movingAverageGet id="callSetupRatio" var="csr" />
<log value="current call setup ratio MA100 = $csr;" />
<if test="$csr; < 0.6">
 <log value="CSR is less than threshold (0.6): stopping call generator, waiting 20 seconds" />
 <stopcallgenerator />
 <wait value="20s" />
 <log value="starting call generator after a pause" />
 <movingAverageReset id="callSetupRatio" />
 <startcallgenerator />
 <exit />
</if>

<call value="sip:test@10.10.10.1:5060" />
<on event="answer">
 <movingAveragePut id="callSetupRatio" size="100" value="1" />
 <wait value="1s" />
 <exit />
</on>
<on event="callfailure">
 <movingAveragePut id="callSetupRatio" size="100" value="0" />
</on>

Simulating sinusoid-type variable call load
<assign var="numberOfConcurrentCalls" mathvalue="120 + 100 * sin(($timeOfDayInHours(); - 10) / 24 * 360)" />
<!-- 360 – 360 degrees in a cycle -->
<!-- 24 – 24 hours in day interval -->
<!-- 10 – 10 hours AM is 0-degree point in sinusoid -->
<!-- 120 – average channels count -->
<!-- 100 – amplitude of change for channels count -->

<setcallgeneratorparams maxconcurrentcalls="$numberOfConcurrentCalls;" />

<call value="sip:test@10.10.10.1:5060" />
<on event="answer">
 <wait value="100s" />
 <exit />
</on>

Combining SUBSCRIBE, PUBLISH, INVITE tests in a single CallXML script
<!-- example of combining 3 test cases in a single CallXML script:
send SUBSCRIBE 7 times per second (use data from CSV file)
send PUBLISH 1 time per second
send INVITE (make a SIP call) 5 times per second
total rate of CallXML sessions per second must be greater than 13 CallXML sessions per second (configured in outgoing calls - interval between calls)
-->

<block minInterval="142ms"> <!-- executes internal sub-test (sending SUBSCRIBE) 7 times per second -->
 <readcsv value=".\SubscribeList.csv" var0="Device" var1="DevName" repeat="infinite" />
 <sendsipmessage>
<![CDATA[
SUBSCRIBE sip:$Device;@sip.domain.com:5060 SIP/2.0
Via: SIP/2.0/UDP 1.2.3.4:5060;branch=z9hG4bK13054182
From: $DevName; <sip:$Device;@sip.domain.com:5060>;tag=1641318497
To: <sip:$Device;@sip.domain.com:5060>
Call-ID: 0_2505407707@1.2.3.4
CSeq: 1 SUBSCRIBE
Contact: <sip:$Device;@1.2.3.4:5060>
Accept: application/reginfo+xml
Max-Forwards: 70
User-Agent: Yealink SIP-T21P_E2 52.80.0.95
Expires: 3630
Event: dialog
Content-Length: 0
]]>
 </sendsipmessage>
 <exit/>
</block>
<block minInterval="1000ms">
 <readcsv value=".\PublishList.csv" var0="PubDevice" var1="PubDevName" repeat="infinite" />
 <sendsipmessage>
<![CDATA[
PUBLISH sip:$PubDevice;@sip.domain.com SIP/2.0
Via: SIP/2.0/UDP 1.2.3.4:5060;branch=z9hG4bK03a3d1e310f928d0
From: $PubDevName; <sip:$PubDevice;@sip.domain.com>;tag=6e52f3725c8bd4bb
To: <sip:$PubDevice;@sip.domain.com>
Supported: path
Call-ID: f477f1f9e55aa8fc@1.2.3.4
CSeq: 1 PUBLISH
User-Agent: Grandstream GXP2000 1.2.5.3
Max-Forwards: 70
Allow: INVITE,ACK,CANCEL,BYE,NOTIFY,REFER,OPTIONS,INFO,SUBSCRIBE,UPDATE,PRACK,MESSAGE
Expires: 300
Event: presence
SIP-If-Match: iK0rghih
Content-Length: 0
]]>
 </sendsipmessage>
 <exit/>
</block>
<block minInterval="200ms">
 <readcsv value=".\InviteList.csv" var0="callerIdFromCsv" var1="calledIdFromCsv" mode="random" repeat="infinite" />
 <call value="sip:$calledIdFromCsv;@sip.domain.com" callerId="$callerIdFromCsv;" />
 <exit/>
</block>

Combining INVITE and REGISTER tests in a single CallXML script
<!-- example of combining INVITE and REGISTER in a single CallXML script:
send INVITE (make a SIP call) 10 times per second
send REGISTER 5 times per second
total rate of CallXML sessions per second must be greater than 15 CallXML sessions per second (configured in outgoing calls - interval between calls)
-->


<assign var="destinationHost" value="192.168.0.216" />
<assign var="password" value="test1234" />
<assign var="extensionsCount" value="100" />
<assign var="baseExtensionId" value="3010" />
<assign var="extensionId" mathvalue="$baseExtensionId; + ($Id; % $extensionsCount;)" />
<log value="testing extension $extensionId;" />
<block minInterval="100ms"> <!-- executes internal sub-test (sending INVITE) 10 times per second -->
 <call value="sip:07042643699@$destinationHost;?user=$extensionId;&password=$password;">
  <on event="answer" > <playaudio value="music.wav" repeat="10000" maxtime="$rand(20000);ms" /> </on>
 </call>
</block>
<block minInterval="200ms"> <!-- executes internal sub-test (sending INVITE) 5 times per second -->
 <register value="sip:$extensionId;@$destinationHost;?user=$extensionId;&password=$password;" expires="3600" var="status" delayvar="delay" />
 <log value="REGISTER: received response code = $status;, delay = $delay;ms" />
</block>

OTT bypass, other international bypass fraud detection

Sample CallXML Scripts for StarTrinity Softswitch

PBX
VoIP wholesale and termination
False Answer Supervision (FAS) fraud detection (warning: usage of StarTrinity Softswitch for FAS generation is prohibited, since it steals money from caller)
Autodialer #1
Autodialer #2


Copyright 2011-2017 StarTrinity.com | Blog | Contact lead developer via LinkedIn | Support tool