Support Overview

Tutorials

Usage Examples

Upgrade Information

FAQ

New Release History

You are here:   Visualware >   MyConnection Server >   Support >   Usage Examples >   Custom VoIP Test (PHP and JavaScript)

Custom VoIP Test (PHP and JavaScript)

The example below shows how a VoIP test can be published that allows the user to make various options based on their needs. For this example the choices are number of VoIP lines to simulate, length of test and which codec to simulate.

This exact example is achieved using PHP and JavaScript.


Number of VoIP Lines (1-50)
Test length (secs)  
Codec  
   

Current Settings

VoIP Lines Simulated: 1
Test Length: 15
Codec:

Code Required

The code below can be added to a PHP ready web page to mimic the example above.

Copy and paste the code below just under the "body" tag in the web page. This code is responsible for grabbing the parameters from the address bar in the browser and setting up the codec values. The JavaScript section is what limits the number of VoIP lines that can be simulated.

<?php

if(isset($_GET['codec'])) { $codec = $_GET['codec']; }
else { $codec = 'G.711 (64 Kbps)'; }

if(isset($_GET['voiplines'])) { $lines = $_GET['voiplines']; }
else { $lines = '1'; }

if(isset($_GET['testlength'])) { $time = $_GET['testlength']; }
else { $time = '15'; }

$g711 = " <param name=\"voip_packetspersecond\" value=\"50\"></param><param name=\"voip_bytesperpacket\" value=\"160\"></param>";
$g729 = " <param name=\"voip_packetspersecond\" value=\"50\"></param><param name=\"voip_bytesperpacket\" value=\"20\"></param>";
$g72316 = " <param name=\"voip_packetspersecond\" value=\"34\"></param><param name=\"voip_bytesperpacket\" value=\"24\"></param>";
$g72315 = " <param name=\"voip_packetspersecond\" value=\"34\"></param><param name=\"voip_bytesperpacket\" value=\"20\"></param>";
$g72632 = " <param name=\"voip_packetspersecond\" value=\"50\"></param><param name=\"voip_bytesperpacket\" value=\"80\"></param>";
$g72624 = " <param name=\"voip_packetspersecond\" value=\"50\"></param><param name=\"voip_bytesperpacket\" value=\"60\"></param>";
$g728 = " <param name=\"voip_packetspersecond\" value=\"34\"></param><param name=\"voip_bytesperpacket\" value=\"60\"></param>";

$nameg711 = "G.711 (64 Kbps)";
$nameg729 = "G.729 (8 Kbps)";
$nameg72316 = "G.723.1 (6.3 Kbps)";
$nameg72315 = "G.723.1 (5.3 Kbps)";
$nameg72632 = "G.726 (32 Kbps)";
$nameg72624 = "G.726 (24 Kbps)";
$nameg728 = "G.728 (16 Kbps)";

?>

<script>
function linelimit(){

if (document.getElementById("voiplines").value > 50){
document.getElementById("voiplines").value = 50;
document.getElementById("limit").innerHTML = "The maximum number of lines that can be simulated is 50."
}

}
</script>


Now copy and paste the code below where you want the choices to go (how many VoIP lines, codec etc). Note the table widths etc may need adjusting to fit in with the web page being copied to.

<form method="get" action="voip.php">

<table width="100%" cellpadding="5" cellspacing="0"><tr>
<td width="22%">Number of VoIP Lines (1-50)</td>
<td width="8">
<?php
echo "<input type=\"text\" id=\"voiplines\" name=\"voiplines\" maxlength=\"2\" size=\"3\" onChange=\"linelimit()\" value=\"$lines\">";
?>
</td>
<td width="70%"><div id="limit" style="font-size:10px; font-family:Tahoma, Geneva, sans-serif; font-weight:bold;"></div></td>
</tr>
<tr>
<td>Test length (secs)</td>
<td><select name="testlength">

<?php

echo "<option id=\"length15\" value=\"15\""; if ($time == 15) { echo "selected"; };echo">15</option>";
echo "<option id=\"length30\" value=\"30\""; if ($time == 30) { echo "selected"; };echo">30</option>";
echo "<option id=\"length45\" value=\"45\""; if ($time == 45) { echo "selected"; };echo">45</option>";
echo "<option id=\"lenght60\" value=\"60\""; if ($time == 60) { echo "selected"; };echo">60</option>";
echo "</select>";

?>

</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Codec</td>
<td><select name="codec">

<?php

echo "<option id=\"g711\" value=\"g711\""; if ($codec == "g711") { echo "selected"; };echo">G.711 (64 Kbps)</option>";
echo "<option id=\"g729\" value=\"g729\""; if ($codec == "g729") { echo "selected"; };echo">G.729 (8 Kbps)</option>";
echo "<option id=\"g72316\" value=\"g72316\""; if ($codec == "g72316") { echo "selected"; };echo">G.723.1 (6.3 Kbps)</option>";
echo "<option id=\"g72315\" value=\"g72315\""; if ($codec == "g72315") { echo "selected"; };echo">G.723.1 (5.3 Kbps)</option>";
echo "<option id=\"g72632\" value=\"g72632\""; if ($codec == "g72632") { echo "selected"; };echo">G.726 (32 Kbps)</option>";
echo "<option id=\"g72624\" value=\"g72624\""; if ($codec == "g72624") { echo "selected"; };echo">G.726 (24 Kbps)</option>";
echo "<option id=\"g728\" value=\"g728\""; if ($codec == "g728") { echo "selected"; };echo">G.728 (16 Kbps)</option>";
echo "</select>";


?>


</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><input type="submit" value=" Apply "></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>

</form>


Now copy and paste the code below where you want the current settings text and applet to appear. The only change that will be needed is the codebase, highligted in blue below. This should be changed to the address of your MyConnection Server installation.

<table width="100%" cellpadding="5" cellspacing="0">
<tr><td width="30%" valign="top">
<?php

echo "<b>Current Settings</b>
<br><br><b>VoIP Lines Simulated</b>: $lines<br>
<b>Test Length</b>: $time<br>
<b>Codec</b>: ";

if ($codec == "g711") { echo "$nameg711"; };
if ($codec == "g729") { echo "$nameg729"; };
if ($codec == "g72316") { echo "$nameg72316"; };
if ($codec == "g72315") { echo "$nameg72315"; };
if ($codec == "g72632") { echo "$nameg72632"; };
if ($codec == "g72624") { echo "$nameg72624"; };
if ($codec == "g728") { echo "$nameg728"; };


?>


</td>
<td width="70%" align="left">
<p align="center">


<applet mayscript name="mcs" code="myspeedserver/applet/myspeed.class" archive="/myspeed/myspeed_s_8.jar,/myspeed/plugins_s_8.jar" codebase="http://mcsiad.visualware.com/myspeed" width=600 height=400>
<param name="testspecid" value="-1">
<param name="permissions" value="all-permissions">
<?php

echo "<param name=\"voip_lines\" value=\"$lines\">";
echo "<param name=\"voip_simulationseconds\" value=\"$time\">";
echo "<param name=\"permissions\" value=\"sandbox\">";

if ($codec == "g711") { echo "$g711"; };
if ($codec == "g729") { echo "$g729"; };
if ($codec == "g72316") { echo "$g72316"; };
if ($codec == "g72315") { echo "$g72315"; };
if ($codec == "g72632") { echo "$g72632"; };
if ($codec == "g72624") { echo "$g72624"; };
if ($codec == "g728") { echo "$g728"; };

?>


</applet>


</p></td></tr></table>

 

MyConnection Server

Home
Online Testing Portal
Download
Purchase
Resources
Support

Visualware Products

VisualRoute
eMailTrackerPro
Visual IP Trace

   

© Visualware Inc. 2014 - All Rights Reserved