<html><div style='background-color:'><DIV class=RTE>
<P><FONT style="FONT-SIZE: 11px; FONT-FAMILY: tahoma,sans-serif">From:&nbsp;&nbsp;<I>Mitch Thompson &lt;mitchthompson@satx.rr.com&gt;</I><BR>&gt;I'm looking for some help from any Asterisk "heavy" who might be <BR>&gt;doing something similar to what I'm trying to do...<BR>&gt;<BR>&gt;Background:<BR>&gt;<BR>&gt;I work for a research lab, testing telephony products and tools.&nbsp;&nbsp;<BR>&gt;Historically, we used Ameritec Crescendos and Fortissimos to act as <BR>&gt;load generators and call "sinks" when testing equipment.&nbsp;&nbsp;However, <BR>&gt;the equipment we are testing gets more and more complex, and the <BR>&gt;scripted scenarios the Ameritecs give have become a limiting factor <BR>&gt;for testing.&nbsp;&nbsp;Therefore, Asterisk was chosen as a possible solution <BR>&gt;(we're a cheap lab).<BR></FONT></P>
<P><FONT style="FONT-SIZE: 11px; FONT-FAMILY: tahoma,sans-serif">Mitch,</P></FONT>
<P><FONT style="FONT-SIZE: 11px; FONT-FAMILY: tahoma,sans-serif">I had exposure to both Ameritec and Hammer, and see how Ameritec could be limiting.&nbsp; But using a PBX as a test tool doesn't sound very sound even for a cheap lab, especially for load test.&nbsp; Race condition is just one side of the problem.&nbsp; You also have to spend a lot of time programming the PBX to do what test tools are designed to do.&nbsp; Have you looked into Sprient?&nbsp; They boast the highest density per $&nbsp;in PSTN land but I don't know the scripting capability.</FONT></P>
<P><FONT style="FONT-SIZE: 11px; FONT-FAMILY: tahoma,sans-serif">Back to your condition.&nbsp; You can replace cat with test in priority 1&nbsp;to reduce time consumed by the first system call by half, thus theoretically speed up branching to priority 102.&nbsp; But the bottleneck&nbsp;is likely in Asterisk's branch codes.&nbsp; Hence even if the system call takes no time, even if you store stuff in memory,&nbsp;you are still going to run into race conditions.</FONT></P>
<P>Yuan Liu</P>
<P><FONT style="FONT-SIZE: 11px; FONT-FAMILY: tahoma,sans-serif">&gt;I've been learning Asterisk as I go, but I've learned a lot.&nbsp;&nbsp;Here's <BR>&gt;the basic scenario:<BR>&gt;<BR>&gt;We are using an Asterisk (AAH 2.8, specifically) to sink calls.&nbsp;&nbsp;I <BR>&gt;do this by taking the ${EXTEN} and breaking it down by sections <BR>&gt;until I get to the last 4 digits (i.e., 2105551212).&nbsp;&nbsp;Once I get to <BR>&gt;the 4-digit extension, I am trying to set a flag, or semaphore, to <BR>&gt;do Busy/Idle testing.&nbsp;&nbsp;Here is my extensions_custom.conf fragment:<BR>&gt;<BR>&gt;<BR>&gt;[SATX_555_Extensions]<BR>&gt;<BR>&gt;exten =&gt; 1212,1,System(cat /tmp/{orig_num})&nbsp;&nbsp;; ${orig_num} is set at <BR>&gt;the beginning of [from-trunk-custom] to the full dialed digits in <BR>&gt;${EXTEN}, before I break it down.<BR>&gt;exten =&gt; 1212,n,Busy(); if the file exists, 
someone else has already <BR>&gt;called this number, return busy<BR>&gt;<BR>&gt;exten =&gt; 1212,102,System(echo ${UNIQUEID} &gt; /tmp/${orig_num}) ; <BR>&gt;basically, create a file in /tmp whose name is the full number from <BR>&gt;the beginning.&nbsp;&nbsp;In this case, the full<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;; filename would be <BR>&gt;/tmp/2105551212.&nbsp;&nbsp;I don't really care about the contents, though.<BR>&gt;exten =&gt; 1212,103, Goto(Idle,1) ; from here, we jump to a new <BR>&gt;extension called Idle, where we do a Random to decide whether to <BR>&gt;simulate no one home (ring no answer) or<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;; we send ring 
<BR>&gt;for about 10 seconds, then Answer() and play some .wav files, then <BR>&gt;hangup.&nbsp;&nbsp;The last thing we do in either case is to delete<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;; the <BR>&gt;/tmp/${orig_num} file.<BR>&gt;<BR>&gt;The above code works very well at low call volumes.&nbsp;&nbsp;However, I'm <BR>&gt;running into race conditions at high call volumes where several <BR>&gt;calls are getting through the test in priority 1 before the file is <BR>&gt;created in priority 102 (n+101).<BR>&gt;<BR>&gt;I've tried to implement semaphores by using both local and global <BR>&gt;variables, but it 
doesn't seem to work.<BR>&gt;<BR>&gt;My ultimate question:&nbsp;&nbsp;Is anyone doing something similar, and what <BR>&gt;did you do to implement the busy/idle.<BR>&gt;<BR>&gt;I appreciate any help anyone can offer.<BR>&gt;<BR>&gt;Mitch Thompson<BR></P></DIV></FONT></div></html>