StarTrinity.com

VoIP software

VoIP community

VoIP marketplace


logged in as
log out

Scripts for looped VoIP traffic generation

The scripts are used to send generated VoIP traffic to wholesale route provider(s) and receive the traffic back to same system. If the call goes to some other termination provider, it is dropped before or immediately after connection.
outgoing CallXML script (for call generator in StarTrinity softswitch)
<callxml>
 <assign var="receiverStatus" value="not received" />

 <switch> <!-- make calls to 3 countries with different probability distribution -->
  <case probability="30" > <assign var="cld" value="961$randdigits(9);" /> </case>
  <case probability="30" > <assign var="cld" value="962$randdigits(9);" /> </case>
  <case probability="40" > <assign var="cld" value="963$randdigits(9);" /> </case>
 </switch>

<!-- put correct terminator ID instead of XXX below: (terminators are configured in softswitch web UI) -->
 <call callerId="1$randdigits(9);" value="$cld;" maxringtime="45s" codec="G729" terminatorId="XXX" headers="Session-ID=testIfThisIsPassedViaRoute" />
 <on event="pr:183">
   <log value="$cld;: received 183" /> <!-- callxml log is accessible in Web UI, is used to see what happens in the script -->
   <wait value="7s" />
   <ifcallexists calledId="$cld;"> <assign var="receiverStatus" value="OK" /> </ifcallexists>
   <log value="$cld;: receiver status: $receiverStatus;" />
   
   <if test="$receiverStatus; != OK">
     <log value="$cld;: cancelling call: not received" />
     <exit />
    </if>
 </on>
 <on event="answer">
   <ifcallexists calledId="$cld;" considerThisCall="false"> <assign var="receiverStatus" value="OK" /> </ifcallexists>
   <log value="$cld;: connected call. receiver status: $receiverStatus;" />
   <if test="$receiverStatus; != OK">
     <log value="$cld;: dropping connected call: does not exist on receiver" />
     <exit />
    </if>
  <playaudio value="music.wav" repeat="infinite" maxtime="$rand(25,60);m" /> <!-- play default music wav file, you can replace it with your own file -->
  <exit />
 </on>
</callxml>
incoming CallXML script (for call receiver in StarTrinity softswitch)
<callxml>
 <performaaa/> <!-- note that you need to set up an originator in softswitch web UI to receive VoIP traffic -->
 <if test="$loop;"> <!-- the originator should have field "CallXML variables" set to "loop=true" -->
  <ifcallexists calledId="$calledId;" considerThisCall="false">
   <!-- call is generated by our system: terminate it by playing WAV audio file -->
   <accept value="183"/>
   <playaudio value="music.wav" maxtime="$rand(6,10);s" repeat="infinite"/> <!-- ringing time is random from 6 to 10 seconds -->
   <accept/>
   <playaudio value="music.wav" maxtime="$rand(3,8);m" repeat="infinite"/> <!-- connected time is random from 3 to 8 minutes -->
   <exit/>
  </ifcallexists>
 </if>
  
<!-- calls from other sources: regular termination via switch to terminators (you need to set up routing groups) -->
 <transfer terminators="routed"/>
</callxml>
outgoing CallXML script (for call generator in StarTrinity SIP Tester)
<callxml>
 <assign var="receiverStatus" value="not received" />

 <switch> <!-- make calls to 3 countries with different probability distribution -->
  <case probability="30" > <assign var="cld" value="961$randdigits(9);" /> </case>
  <case probability="30" > <assign var="cld" value="962$randdigits(9);" /> </case>
  <case probability="40" > <assign var="cld" value="963$randdigits(9);" /> </case>
 </switch>

<!-- put correct destination IP address instead of XXX -->
 <call callerId="971$randdigits(10);" value="sip:$cld;@XXX" maxringtime="45s" codec="G729" />
 <on event="pr:183">
   <log value="$cld;: received 183" /> <!-- callxml log is accessible in Web UI, is used to see what happens in the script -->
   <wait value="7s" />
   <ifcallexists calledId="$cld;"> <assign var="receiverStatus" value="OK" /> </ifcallexists>
   <log value="$cld;: receiver status: $receiverStatus;" />
   
   <if test="$receiverStatus; != OK">
     <log value="$cld;: cancelling call: not received" />
     <exit />
    </if>
 </on>
 <on event="answer">
   <ifcallexists calledId="$cld;" considerThisCall="false"> <assign var="receiverStatus" value="OK" /> </ifcallexists>
   <log value="$cld;: connected call. receiver status: $receiverStatus;" />
   <if test="$receiverStatus; != OK">
     <log value="$cld;: dropping connected call: does not exist on receiver" />
     <exit />
    </if>
  <playaudio value="music.wav" repeat="infinite" maxtime="$rand(25,60);m" /> <!-- play default music wav file, you can replace it with your own file -->
  <exit />
 </on>
</callxml>
incoming CallXML script (for call receiver in StarTrinity SIP Tester)
<callxml>
 <if test="$callerIpAddress; == XXX" > <!-- replace XXX with correct source IP address; note that SIP Tester uses SIP port 5070 by default, you can change "LocalSipPort" setting in global settings -->
  <ifcallexists calledId="$calledId;" considerThisCall="false">
   <!-- call is generated by our system: terminate it by playing WAV audio file -->
   <accept value="183"/>
   <playaudio value="music.wav" maxtime="$rand(6,10);s" repeat="infinite"/> <!-- ringing time is random from 6 to 10 seconds -->
   <accept/>
   <playaudio value="music.wav" maxtime="$rand(3,8);m" repeat="infinite"/> <!-- connected time is random from 3 to 8 minutes (ACD) -->
   <exit/>
  </ifcallexists>
  <log value="rejecting call to $calledId;: no outgoing call to this number"/>
 </if>
 <log value="rejecting call: invalid source IP address $callerIpAddress;"/>
</callxml>
Copyright 2011-2018 StarTrinity.com | Blog | Contact lead developer via LinkedIn | TeamViewer link