StarTrinity.com

CallXML documentation

Logic of processing SIP calls in StarTrinity VoIP software is defined by scripts written in high-level scripting programming language "CallXML". Incoming and outgoing SIP calls are processed by an engine which reads and executes CallXML elements in sequence. The CallXML elements define basic operations with the SIP call.

CallXML elements: description, attributes, examples of usage

accept Sends "200 OK" or "1xx" provisional response to incoming SIP call. Is not applicable for outgoing calls. show details
addsipmalformer Adds SIP malformer (SIP fuzzer) into current CallXML session, before "call" and "accept" elements. Both fixed and random fuzzers are available show details
assign Sets new value to a variable. Variables are used to store intermediate data and to build complex logic in CallXML scripts. Variables can be accessed later in script using substitutions. show details
block Groups CallXML elements into single block. Is used for many purposes: "if" statements, matching strings with regular expressions, loops, simulation of random behaviour.
show details
call Initiates new outgoing call (SIP UAC session) to specified destination; optionally aborts call on time out show details
callgroup Initiates call to group of SIP phones. "parallel", "sequential", "queue" modes of calling phones are available. show details
case Is used within "switch". Defines an option which can be executed show details
checktime Checks current time, raises event if it matches to some schedule, or puts a value to a variable show details
conference Connects a call with other calls in conference room show details
controlaudio Controls currently played audio: moves position (forward/back), makes pause/resume show details
default Is used within "switch". Defines an option which is executed when no matching "case" element is found show details
dequeue Gets an element from a global queue and saves it to variables. If no element is found, empty values are saved
show details
disableuacregistration Disables UAC registration for a specified period of time, so it will not be used for calls show details
disconnect Terminates SIP call if it is created and not terminated yet. Sends BYE or CANCEL SIP message.
Does not terminate execution of CallXML script. show details
disconnectcalls Terminates all SIP calls, similar to "Abort all calls" button show details
dynamicblacklist Adds the specified number/prefix into RAM-based blacklist, checks if number of attempts or connected minutes exceed some specified threshold. show details
else Is used after "if"; is executed if the test condition is false show details
enablesipscanner Enables and starts SIP scanner (for VoIP security tests) show details
enqueue Adds an element to a global queue show details
exec Parses string as CallXML script and executes it. Is similar to "eval" in JavaScript show details
exit Terminates SIP call if it is created and not terminated yet. Sends BYE or CANCEL SIP message.
Terminates execution of CallXML script. show details
exitcli Terminates current command-line-mode SIP Tester. Is used to pass result of testing to .bat script show details
function Defines a function or subroutine. Is executed with "runfunction". show details
getaudiofilelength Reads WAV or MP3 audio file, calculates its duration, saves result to variable show details
getcallcenteragent Gets available call center agent. Is used to develop a call center with CallXML. show details
getcallgeneratorparams Saves call generator parameters into CallXML variables. show details
getcallinfo Saves RTP information into CallXML variables, for currently processed SIP call. show details
getcdrcallscount Queries CDR with specified query expression and saves number of returned records into a variable. Is used in StarTrinity Softswitch for advanced filtering. show details
getdblcallscount Queries RAM-based dynamic black list and saves number of returned records into a variable. Is used in StarTrinity softswitch for advanced filtering. show details
getfilenamefrompath Parses full file path, extracts file name show details
gethash Calculates hash of a string show details
getrtpinfo gets RTP information from media into CallXML variables show details
getrtpmeasurements Saves measured RTP quality indicators into CallXML variables show details
getsiptrace Saves information about previously sent or received SIP packet into a variable show details
getstatistics Gets statistics about processed SIP calls show details
getstringlength Calculates length of a string/number in characters/digits show details
getwg67info Saves WG-67 RTP header extension data into CallXML variables. Measures round-trip delay time if peer SIP-UA has PTT-SQU loopback connection show details
goto Performs one-way transfer of control to another CallXML element with specified "label". show details
if Executes internal CallXML elements if specified conditions are satisfied show details
ifcallexists Executes internal CallXML elements if a SIP sall with specified criteria exists in current calls or in call history show details
ifconferenceexists Executes internal CallXML elements if conference with specified ID currently exists show details
ifnumberexists Executes internal CallXML elements if a number list contains specified number (fast number lookup by prefix) show details
include Reads and executes another CallXML file. Returns control to current file after the execution. Imports functions from included file. show details
inputdigits Collects digits and saves them into variable show details
inputspeech Recognizes voice (speech) to text and saves the text into variable. Uses VOSK speech recognition server (based on Kaldi). show details
limitcps Limits number of calls per second (CPS) and concurrent calls (CC) in dialer scripts. Allows you to limit CPS and CC per destination IP. show details
log Writes a message to GUI or CLI and to file log. Is used for debugging and reporting. show details
loopbackaudio Plays received (RX stream) RTP audio back to SIP call (TX stream). Is used to verify audio path. show details
measuresignal Measures min and max audio level of RX RTP stream. Saves result to variables. show details
movingAverageGet Gets output of a "moving average", saves it to variable show details
movingAveragePut Puts a value into a "moving average", configures number of samples to store for the calculation show details
movingAverageReset Resets a "moving average", i.e. removes all previously stored values from memory show details
on Handles CallXML events. Sets variable "eventType" and "eventSubType" show details
params Declares parameters for the script show details
param Is used within "params"; defines a parameter which can be used later in script show details
performAAA Performs authentication, authorization and accounting for an incoming SIP call. Sets CallXML variables "originatorId", "tenantId", "language" show details
playaudio Plays audio file from specified WAV/MP3 file/URL. Exits on end of file or end of silence (if "maxsilence" is specified), unless "dontwait" is set to "true" show details
playdtmf Sends one or many DTMF digits to current SIP call. Returns control immediately. If "UseRFC2833ToSendDTMF" setting is set to "1", sends DTMF within RTP stream (according to RFC2833), otherwise uses SIP INFO method. If you need to send audible DTMF signals, please use "playaudio" and pre-recorded WAV files with DTMF show details
readcsv Reads a row from CSV file, stores fields into variables
show details
readdb Executes a database query, returns rows one by one, stores fields into variables show details
readnumberlist Reads a row from number list file, stores fields into variables
show details
receivefax Initiates RE-INVITE with T.38 fax SDP offer, receives T.38 fax to file. show details
recordcall Switches on/off recording for current SIP call or conference. show details
recordmessage Records audio message e.g. for voicemail, optionally detects silence show details
redirect Redirects incoming SIP call to new destination. Sends "302 Moved Temporarily" response with new contact. show details
regexsearch Searches for patterns in strings using regular expressions show details
register Sends REGISTER, waits for response, saves status to a variable. Measures delay between sending "REGISTER" request and receiving "200 OK" response show details
reinvite Sends RE-INVITE. Is used to put SIP call on hold (call parking feature) show details
reject Rejects incoming SIP call before answering. Sends response with custom SIP status code. show details
replacestring Performs text replacement show details
report Saves custom performance indicator to SIP Tester's GUI and HTML report show details
requestcsv Makes a fast (RAM-based) lookup in a CSV file show details
requestdb Executes MSSQL command (select, insert, delete statements, stored procedures). Stores fields from the first requested row into variables. If no rows returned, saves empty values show details
resetrtpmeasurements Resets RTP measurement state of current SIP call. Is used to have multiple independent RTP measurements for one SIP call show details
resetstatistics Resets global statistics of processed SIP calls; resets all moving averages show details
restartprocess Restarts a windows process show details
run Generates a new CallXML session. Copies all variables from current session to the new session. The "run" XML element should contain child XML elements to be executed by new session. show details
runfunction Executes a function show details
runprocess Runs an .exe or .bat file with custom command line arguments. Saves console output and process exit code into variables. Is used for integration with third party tools show details
runtenantscript For multitenant softswitch or PBX: runs custom tenant's script show details
say Speaks text using a Microsoft Speech API 5 engine. Waits until the engine speaks all the text. Text is set by "value" attribute or by child XML elements show details
searchfile Search for random file in a directory show details
sendemail Sends email using SMTP server, returns control immediately. Connection to SMTP server is configured on settings screen Note that subject and body text have to be escaped show details
sendevent Sends external event to another (destination) session. Sets "eventsenderId" variable to the destination session. The external event should be handled with <on event="externalevent:[subType]"> handler or "waitforevent" element. show details
sendfax Initiates RE-INVITE with T.38 fax SDP offer, sends fax from TIFF image file show details
sendhttprequest Sends HTTP/HTTPS request to a web server show details
sendsipinfo Sends SIP INFO with custom body content to current call or to other calls in conference show details
sendsipmessage Sends a custom SIP message. The message is set by content of XML element show details
sendsiprequest Sends custom SIP request for current SIP call, within current INVITE dialog. The request is set by content of XML element. Returns control immediately. Headers like Call-ID and request URI are overwritten, content-length is calculated automatically show details
sendspoofedudppacket Sends generic UDP packet with spoofed source IP address show details
sendudppackets Sends generic UDP packets via current SIP/UDP socket show details
setcallgeneratorparams Changes call generation parameters show details
setexitcode Sets exit code for SIP Tester process. Is used to pass result from CallXML script into .bat script via using command line interface show details
setimpairmentparams Configures simulated RTP loss, jitter and SIP packet loss parameters show details
setinterval Executes internal CallXML code at specified intervals, when current SIP calls is still alive show details
setrtpextension Sets or removes RTP extension data for transmitted RTP stream show details
setrtpmalformer Configures RTP malformer show details
setrtptxfields Modifies transmitted RTP stream, fields SSRC, timestamp, sequence show details
setsetting Sets a global setting value show details
settimeout Executes internal CallXML code after specified timeout show details
setuaccredentials Sets user name and password to handle 401 and 407 UAS responses. Is used for incoming calls, to authorize further BYE and RE-INVITE requests from SIP Tester to server show details
setwebapiresult Passes key-value result to web API "CreateCall_Post" show details
srand Initializes the CallXML engine's random generator with the specified seed value show details
startcallgenerator Starts generation of outgoing calls show details
stopaudio Stops audio player which was started previously show details
stopcallgenerator Stops generation of outgoing calls show details
substring Retrieves a substring from a specified value, saves result to a variable show details
switch Checks if a value matches to one of many conditions, executes an action accordingly show details
throw Raises an event show details
transfer Redirects call to another SIP URI. Is used to proxy call at server side or to send REFER show details
transfersms Redirects incoming SMS to a route (Message Center, MC, SMS provider) show details
update Sends UPDATE with new media description. show details
verifyaudio Verifies RTP audio stream of current SIP call, compares it with one or many reference audio files. Identifies matched reference file along with either a confidence score, or audio quality measurement (PESQ MOS). Also, measures the delay between the start of audio verification and the occurrence of the matched audio file. show details
wait Introduces delay with specified amount of time show details
waitforevent Waits for external event, sent by other CallXML session via "sendevent" element. Is used to synchronize CallXML scripts show details
waitforringbacktone Waits for a ringback audio tone with frequency 400..450Hz and level at least -30dB. Is used to validate SIP trunks
show details
waitforringbacktoneabsence Waits for absence of ringback audio tone with frequency 400..450Hz and level at least -30dB. Is used to skip fake SIM card answer and "welcome" announcement with GSM gateways (see sample script)
show details
waitforsilence Waits for RTP audio signal below specified level. Is used to wait for the end of IVR prompt
show details
waitforsignal Waits for RTP audio signal above specified level, measures delay. Is used to verify response times in IVR menus
show details
writecdr Saves a variable to CDR report, optionally analyses it as numeric performance indicator show details
writefile Writes a text to file. Is used to write files with custom format in CallXML script. Appends text to end of file show details

CallXML elements - common attributes

All CallXML elements may contain following common attributes:

  • enabled ("true"/"false", default "true") - is used to turn off a CallXML element.

Substitutions

Attributes in script may contain substitutions. A substitution starts with '$' and ends with ';'. It is replaced in runtime with another string depending on type of substitution.

$rand(x); is replaced by random integer value which is exponentially distributed from 0 to infinity with mean of x
$rand(x,y); is replaced by random integer value which is uniformly distributed from x (inclusive) to y (inclusive)
$randswitch(case1,case2,case3,...); is replaced by one of optional cases, selected randomly
$randswitch(numberAMin-numberAMax,numberBMin-numberBMax,...); is replaced by one of optional cases with number ranges, selected randomly. Example:
<assign var="num" value="$randswitch(252000000-252000999,252400000-252400999);" />
<playaudio value="music.wav" maxtime="$randswitch(1-600);s" />

$randdigits(number_of_digits); is replaced by a string of random digits from 0 to 9, with specified length = number_of_digits
$randfile(path\mask); is replaced by a random file from directory:
<playaudio value="$randfile(C:\StarTrinity\wav\*.wav);" />
The directory search is performed in main SIP thread, so large directories can slow down the software
$x; is replaced by value of variable with name x. Variable names are not case-sensitive. Name of variable can be computed dynamically from a prefix and another variable: $prefix$suffixVar;; or $arrayName[$arrayIndex;];
$global.x; is replaced by value of global variable with name x Name of global variable can be computed dynamically from a prefix and another variable: $global.prefix$suffixVar;; or $global.someCache[$key;];
$time();, $time(format); is replaced by current date and time:
<recordmessage value="d:\recordings\$time(yyyyMMdd_HH_mm_ss_fff);.wav" />

Note: the software uses QueryPerformanceCounter() procedure inside to get accuracy of microseconds and avoid time jumps when system clock is updated (so the "$time();" always increments without interruptions). As a drawback, there can be a small time drift between the "$time();" and system clock, it can be rset by restarting SIP Tester.

$timeMs(); is replaced by software uptime in milliseconds. Can be used to calculate delays:
<assign var="t1" value="$timeMs();"/>
<call value="sip:test@23.45.67.89:5060" />
<on event="answer">
 <assign var="delay" mathvalue="$timeMs(); - $t1;"/>
 <log value="delay = $delay;ms" />
 <exit />
</on>
$timeOfDayInMinutes(); is replaced by number of minutes between current moment and previous midnight
$timeOfHourInMinutes(); is replaced by number of minutes between current moment and beginning of current hour
$param.x; is replaced by value of parameter which is defined in <params> section inside the script
$env.x; is replaced by windows environment variable:
<log value="temp directory: $env.TMP;; user name: $env.USERNAME;; windows directory: $env.windir;; machine name: $env.COMPUTERNAME;" />
$ext(x); is replaced by 'Contact' header of registered extension (see UAC registrations)
<transfer value="$ext(100);"/>

XML escape characters

According to XML specifications of the W3C, there are 5 characters that must not appear in their literal form in an XML document. The characters must be replaced according to table:
Original character XML replacement
" &quot;
' &apos;
& &amp;
" &quot;
< &lt;
> &gt;
Example:
<call value="sip:111@10.10.10.1?user=XXX&amp;password=YYY" />
You can use this tool to escape the characters automatically

Default variables

  • answerDelay - for outgoing calls after answer: answer delay in milliseconds
  • calledId - user ID (number) in "To" SIP header
  • callerId - user ID (number) in "From" SIP header
  • callerIdName - display name in "From" SIP header
  • callerIpAddress - IP address of SIP call initiator. Is taken from IP protocol (layer 3)
  • callNumberInBurst - number of call in burst, when generating calls in burst mode, starts from 0
  • eventSubType - subtype of event which is currently handled by "on" CallXML element. Contains additional information about the event
  • eventType - type of event which is currently handled by "on" CallXML element
  • Id - CallXML session identifier. Starts with 0, increments sequentially. Is reset to 0 when call generator is started ("Start" button is clicked) if setting "ResetCallXmlSessionIdWhenStartedCallGenerator" is set to 1
  • launcherType - identifies the way how the CallXML script is launched: "cli" - SIP Tester CLI; "gui" - SIP Tester GUI; "softswitch" - Softswitch
  • originatorId - identifier of current originator. Is set by "performAAA" CallXML element
  • language - language of current originator. Is set by "performAAA" CallXML element. Is used to play IVR files from corresponding folder
  • redirectedNumber - user ID (number) in "Diversion" SIP header for incoming calls
  • sdpAttribute[name] - prefix for variables which contain attributes of remote SDP. Example: sdpAttributeptime, sdpAttributefmtp[0], sdpAttributefmtp[1], sdpAttributertpmap[2]
  • sipCallId - "Call-ID" SIP header
  • sipHeader[name] - prefix for variables which contain headers of "INVITE" packet for incoming calls and "INVITE provisional response" packet for outgoing calls. For outgoing calls the variables are accessible in "pr", "answer" and "callfailure" event handlers. Example: sipHeaderVia, sipHeaderVia[0], sipHeaderVia[1]. Note: please use CallXML element "getsiptrace" to have full access to received and transmitted SIP messages, and SIP headers, SDP attributes
  • tenantId - identifier of current tenant, in softswitch multi-tenant mode. Is set by "performAAA" CallXML element

Attributes which are common to all CallXML elements

  • enabled ("true"/"false", default is "true") - turns off execution of a CallXML element. Is used to temporarily disable and enable some parts of the CallXML script
  • label - is used to identify the destination CallXML element in "goto"

Boolean expressions

The boolean expressions are used in "if", "block" and "goto" CallXML elements and in CDR display filter. The expression contain one or many comparisons, parentheses, boolean operators, strings in single quotes. Comparison operators are:
<less than
<=less than or equal
>greater than
>=greater than or equal
=, ==equal
!=, <>inequal
startswithleft operand starts with prefix (right operand)
matchesleft operand matches to regular expression (right operand)
containsleft operand contains right operand as a substring
Boolean operators are:
&, &&, and|, ||, or
Strings which are considered as "boolean false":
false0[empty string]
Examples of boolean expressions for CallXML script:
  • $calledId; = 98764352343
  • $callerId; startswith 123 or $calledId; = 345
  • $callerId; = 123456 and $calledId; = 1345678
  • 'a=123' = 'a=123'
Examples of boolean expressions for CDR filter:
  • Answered_Duration > 1000
  • Answered_Duration > 1000 and (CalledId startswith 10 or CalledId startswith 11)
  • Disconnection_Status = 200
  • Answer_Delay > 10000
  • CalledId = 123456
  • CallerId = 123456
  • CallerId contains 456
  • SIP_CallId = asefruyhnsdfteomhu7sngd@10.10.10.20
  • MyCustomCdrField1 > 10000 and MyCustomCdrField2 != OK
List of available CDR columns (fields) is displayed in GUI (CDR - fields..)
Copyright 2011-2025 StarTrinity.com | Blog | Contact lead developer via LinkedIn | telegram