Re: [asterisk-users] Help with semaphores - SOLVED

2007-02-12 Thread Mitch Thompson

Mitch Thompson wrote:
I'm looking for some help from any Asterisk heavy who might be doing 
something similar to what I'm trying to do...


Background:

I work for a research lab, testing telephony products and tools.  
Historically, we used Ameritec Crescendos and Fortissimos to act as 
load generators and call sinks when testing equipment.  However, the 
equipment we are testing gets more and more complex, and the scripted 
scenarios the Ameritecs give have become a limiting factor for 
testing.  Therefore, Asterisk was chosen as a possible solution (we're 
a cheap lab).


I've been learning Asterisk as I go, but I've learned a lot.  Here's 
the basic scenario:


We are using an Asterisk (AAH 2.8, specifically) to sink calls.  I do 
this by taking the ${EXTEN} and breaking it down by sections until I 
get to the last 4 digits (i.e., 2105551212).  Once I get to the 
4-digit extension, I am trying to set a flag, or semaphore, to do 
Busy/Idle testing.  Here is my extensions_custom.conf fragment:



[SATX_555_Extensions]

exten = 1212,1,System(cat /tmp/{orig_num})  ; ${orig_num} is set at 
the beginning of [from-trunk-custom] to the full dialed digits in 
${EXTEN}, before I break it down.
exten = 1212,n,Busy(); if the file exists, someone else has already 
called this number, return busy


exten = 1212,102,System(echo ${UNIQUEID}  /tmp/${orig_num}) ; 
basically, create a file in /tmp whose name is the full number from 
the beginning.  In this case, the full
 
; filename would be /tmp/2105551212.  I don't really care about the 
contents, though.
exten = 1212,103, Goto(Idle,1) ; from here, we jump to a new 
extension called Idle, where we do a Random to decide whether to 
simulate no one home (ring no answer) or
   ; we send ring for 
about 10 seconds, then Answer() and play some .wav files, then 
hangup.  The last thing we do in either case is to delete
   ; the 
/tmp/${orig_num} file.


The above code works very well at low call volumes.  However, I'm 
running into race conditions at high call volumes where several calls 
are getting through the test in priority 1 before the file is created 
in priority 102 (n+101).


I've tried to implement semaphores by using both local and global 
variables, but it doesn't seem to work.


My ultimate question:  Is anyone doing something similar, and what did 
you do to implement the busy/idle.


I appreciate any help anyone can offer.

Mitch Thompson
I wanted to follow-up with the solution I came up with, thanks to 
excellent feedback from this group, and Trevor Peirce in particular.


Our fix action was a blending of my solution (above) and Trevor's 
suggestion to stop using System() calls and use the DB directive.  We 
ended up with something like this:


exten = 1212,1,GotoIf(${DB_EXISTS(busy/${orig_num})}?busy:idle)
exten = 1212,n(busy),Busy()
exten = 1212,n(idle),Set(DB(busy/${orig_num})=${CALLERID(num)})
exten = 1212,n,Macro(disposition,$(orig_num}) ; Call a macro, pass 
along the original CdPN, and do something.


In the disposition macro, we have this:

[macro-disposition]
exten = s,1,Set(orig_num=${arg1})
exten = s,n,Random(25:s-rna,1)
exten = s,n,Ringing()
exten = s,n,Wait(6)
exten = s,n,Answer()
exten = s,n,Wait(1)
exten = s,n,Playback(lots-o-monkeys)
exten = s,n,Hangup()

exten = s-rna,1,Ringing()
exten = s-rna,n,Wait()
exten = s-rna,n,Hangup

exten = h,1,DBDel(busy/${orig_num})

The above gives us a very simplistic coin-toss as to whether to answer 
the phone or not.


With the above dialplan, we have successfully dialed one number with 
eight (8) T-1 PRIs worth of calls simultaneously and only have 1 answer 
(the remaining 183 calls were shown as Busy on the Fortissimo).  This 
was repeatable over a 2 hour period.  I'm sure we will have calls slip 
through, but for now we are satisfied.


Trevor, thanks again.  I learned about the DB application that day.

___
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] Help with semaphores

2007-02-01 Thread yusuf

Mitch Thompson wrote:
I'm looking for some help from any Asterisk heavy who might be doing 
something similar to what I'm trying to do...


Background:

I work for a research lab, testing telephony products and tools.  
Historically, we used Ameritec Crescendos and Fortissimos to act as load 
generators and call sinks when testing equipment.  However, the 
equipment we are testing gets more and more complex, and the scripted 
scenarios the Ameritecs give have become a limiting factor for testing.  
Therefore, Asterisk was chosen as a possible solution (we're a cheap lab).


I've been learning Asterisk as I go, but I've learned a lot.  Here's the 
basic scenario:


We are using an Asterisk (AAH 2.8, specifically) to sink calls.  I do 
this by taking the ${EXTEN} and breaking it down by sections until I get 
to the last 4 digits (i.e., 2105551212).  Once I get to the 4-digit 
extension, I am trying to set a flag, or semaphore, to do Busy/Idle 
testing.  Here is my extensions_custom.conf fragment:



[SATX_555_Extensions]

exten = 1212,1,System(cat /tmp/{orig_num})  ; ${orig_num} is set at the 
beginning of [from-trunk-custom] to the full dialed digits in ${EXTEN}, 
before I break it down.
exten = 1212,n,Busy(); if the file exists, someone else has already 
called this number, return busy


exten = 1212,102,System(echo ${UNIQUEID}  /tmp/${orig_num}) ; 
basically, create a file in /tmp whose name is the full number from the 
beginning.  In this case, the full
 
; filename would be /tmp/2105551212.  I don't really care about the 
contents, though.
exten = 1212,103, Goto(Idle,1) ; from here, we jump to a new extension 
called Idle, where we do a Random to decide whether to simulate no one 
home (ring no answer) or
   ; we send ring for 
about 10 seconds, then Answer() and play some .wav files, then hangup.  
The last thing we do in either case is to delete
   ; the 
/tmp/${orig_num} file.


The above code works very well at low call volumes.  However, I'm 
running into race conditions at high call volumes where several calls 
are getting through the test in priority 1 before the file is created in 
priority 102 (n+101).


I've tried to implement semaphores by using both local and global 
variables, but it doesn't seem to work.


My ultimate question:  Is anyone doing something similar, and what did 
you do to implement the busy/idle.


I appreciate any help anyone can offer.

Mitch Thompson


Hi,

dont know if this is what you looking for but, there is something called macroexclusive, new in 1.4, 
written by Steve Davies.

Read the file in asterisk-1.4.0/docs.

HTH


--
thanks,
Yusuf
___
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] Help with semaphores

2007-02-01 Thread Trevor Peirce

Mitch Thompson wrote:

[SATX_555_Extensions]

exten = 1212,1,System(cat /tmp/{orig_num})  ; ${orig_num} is set at 
the beginning of [from-trunk-custom] to the full dialed digits in 
${EXTEN}, before I break it down.
exten = 1212,n,Busy(); if the file exists, someone else has already 
called this number, return busy


exten = 1212,102,System(echo ${UNIQUEID}  /tmp/${orig_num}) ; 
basically, create a file in /tmp whose name is the full number from 
the beginning.  In this case, the full
 
; filename would be /tmp/2105551212.  I don't really care about the 
contents, though.
exten = 1212,103, Goto(Idle,1) ; from here, we jump to a new 
extension called Idle, where we do a Random to decide whether to 
simulate no one home (ring no answer) or
   ; we send ring for 
about 10 seconds, then Answer() and play some .wav files, then 
hangup.  The last thing we do in either case is to delete
   ; the 
/tmp/${orig_num} file.


The above code works very well at low call volumes.  However, I'm 
running into race conditions at high call volumes where several calls 
are getting through the test in priority 1 before the file is created 
in priority 102 (n+101).




Here's what I would do...

First, no System calls.  Stay within asterisk.

I doubt this will get rid of all race conditions, but I imagine it would 
at least reduce them.


exten = 1212,1,GotoIf($[${DB(/tmp/${orig_num})} != ${UNIQUEID}]?abort)
exten = 1212,1,Set(${DB(/tmp/${orig_num})}=${UNIQUEID})
exten = 1212,n,GotoIf($[${DB(/tmp/${orig_num})} != ${UNIQUEID}]?abort)
exten = 1212,n, Goto(Idle,1)

exten = 1212,n(abort),Busy()

Regards,
Trevor
___
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] Help with semaphores

2007-02-01 Thread Mitch Thompson

Trevor Peirce wrote:

Mitch Thompson wrote:

[SATX_555_Extensions]

exten = 1212,1,System(cat /tmp/{orig_num})  ; ${orig_num} is set at 
the beginning of [from-trunk-custom] to the full dialed digits in 
${EXTEN}, before I break it down.
exten = 1212,n,Busy(); if the file exists, someone else has already 
called this number, return busy


exten = 1212,102,System(echo ${UNIQUEID}  /tmp/${orig_num}) ; 
basically, create a file in /tmp whose name is the full number from 
the beginning.  In this case, the full
 
; filename would be /tmp/2105551212.  I don't really care about the 
contents, though.
exten = 1212,103, Goto(Idle,1) ; from here, we jump to a new 
extension called Idle, where we do a Random to decide whether to 
simulate no one home (ring no answer) or
   ; we send ring for 
about 10 seconds, then Answer() and play some .wav files, then 
hangup.  The last thing we do in either case is to delete
   ; the 
/tmp/${orig_num} file.


The above code works very well at low call volumes.  However, I'm 
running into race conditions at high call volumes where several calls 
are getting through the test in priority 1 before the file is created 
in priority 102 (n+101).




Here's what I would do...

First, no System calls.  Stay within asterisk.

I doubt this will get rid of all race conditions, but I imagine it 
would at least reduce them.


exten = 1212,1,GotoIf($[${DB(/tmp/${orig_num})} != 
${UNIQUEID}]?abort)

exten = 1212,1,Set(${DB(/tmp/${orig_num})}=${UNIQUEID})
exten = 1212,n,GotoIf($[${DB(/tmp/${orig_num})} != 
${UNIQUEID}]?abort)

exten = 1212,n, Goto(Idle,1)

exten = 1212,n(abort),Busy()

Regards,
Trevor

Trevor,

Thank you very much for your response.  Yes, I was worried about the 
performance hit of the System() call, but as I said, I tried doing it 
with Global and/or local variables, and just wound up confusing myself.  
I'm not a programmer by trade or nature, so I knew up front it was 
dirty code.  Your method of staying with Asterisk looks like something 
I can easily switch to in one exchange context and give it a quick try.


Thanks again!

--
Read The Patriot   It's Right -- It's Free
http://PatriotPost.US/subscribe/
--
Mitch Thompson, San Antonio, Texas//WB5UZG
Red Hat Certified Engineer

___
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users


RE: [asterisk-users] Help with semaphores

2007-01-31 Thread Yuan LIU

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

___
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] Help with semaphores

2007-01-31 Thread Mitch Thompson

Yuan LIU wrote:


From:  /Mitch Thompson [EMAIL PROTECTED]/
I'm looking for some help from any Asterisk heavy who might be
doing something similar to what I'm trying to do...

Background:

I work for a research lab, testing telephony products and tools.  
Historically, we used Ameritec Crescendos and Fortissimos to act as

load generators and call sinks when testing equipment.  However,
the equipment we are testing gets more and more complex, and the
scripted scenarios the Ameritecs give have become a limiting factor
for testing.  Therefore, Asterisk was chosen as a possible solution
(we're a cheap lab).

Mitch,

I had exposure to both Ameritec and Hammer, and see how Ameritec could 
be limiting.  But using a PBX as a test tool doesn't sound very sound 
even for a cheap lab, especially for load test.  Race condition is 
just one side of the problem.  You also have to spend a lot of time 
programming the PBX to do what test tools are designed to do.  Have 
you looked into Sprient?  They boast the highest density per $ in PSTN 
land but I don't know the scripting capability.


Back to your condition.  You can replace cat with test in priority 
1 to reduce time consumed by the first system call by half, thus 
theoretically speed up branching to priority 102.  But the 
bottleneck is likely in Asterisk's branch codes.  Hence even if the 
system call takes no time, even if you store stuff in memory, you are 
still going to run into race conditions.


Yuan Liu

I've been learning Asterisk as I go, but I've learned a lot.  Here's
the basic scenario:

We are using an Asterisk (AAH 2.8, specifically) to sink calls.  I
do this by taking the ${EXTEN} and breaking it down by sections
until I get to the last 4 digits (i.e., 2105551212).  Once I get to
the 4-digit extension, I am trying to set a flag, or semaphore, to
do Busy/Idle testing.  Here is my extensions_custom.conf fragment:


[SATX_555_Extensions]

exten = 1212,1,System(cat /tmp/{orig_num})  ; ${orig_num} is set at
the beginning of [from-trunk-custom] to the full dialed digits in
${EXTEN}, before I break it down.
exten = 1212,n,Busy(); if the file exists, someone else has already
called this number, return busy

exten = 1212,102,System(echo ${UNIQUEID}  /tmp/${orig_num}) ;
basically, create a file in /tmp whose name is the full number from
the beginning.  In this case, the full

  ; filename would be

/tmp/2105551212.  I don't really care about the contents, though.
exten = 1212,103, Goto(Idle,1) ; from here, we jump to a new
extension called Idle, where we do a Random to decide whether to
simulate no one home (ring no answer) or
; we send ring
for about 10 seconds, then Answer() and play some .wav files, then
hangup.  The last thing we do in either case is to delete
; the
/tmp/${orig_num} file.

The above code works very well at low call volumes.  However, I'm
running into race conditions at high call volumes where several
calls are getting through the test in priority 1 before the file is
created in priority 102 (n+101).

I've tried to implement semaphores by using both local and global
variables, but it doesn't seem to work.

My ultimate question:  Is anyone doing something similar, and what
did you do to implement the busy/idle.

I appreciate any help anyone can offer.

Mitch Thompson



___
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users
  
Thank you very much for the feedback.  I'll pass it on to the engineer 
(I'm the lowly tech who is doing the implementing.)  One good deal is 
that they're sending me to Asterisk Bootcamp sometime in the next few months


--
For unto you is born this day in the city of David a Saviour, which is
Christ the Lord. Luke 2:11
--
Read The Patriot   It's Right -- It's Free
http://PatriotPost.US/subscribe/
--
Mitch Thompson, San Antonio, Texas//WB5UZG
Red Hat Certified Engineer

___
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users