[asterisk-dev] Call numbers in IAX2 media frames

Russell Bryant russell at digium.com
Tue Nov 28 11:22:49 MST 2006


Greetings,

I have been working on an IAX2 implementation recently on my own time, and I 
have come across something interesting regarding call numbers in IAX2 media frames.

In my own IAX2 stack, I implemented mini frames and meta frames to carry the 
destination call number.  Now, I see that the RFC draft and the Asterisk 
implementation are not that way.  Asterisk sends the *source* call number on a 
mini frame or meta frame.

Since these frames are the ones that carry media, they have to be processed very 
rapidly.  To put this into context of the Asterisk IAX2 implementation, if these 
frames had the destination call number, you would immediately be able to access 
the correct iax2_pvt struct.  Instead, we have to do a very expensive lookup on 
every single incoming media frame.  We start at call number 1, and iterate 
through every possible call number, matching on the source call number, IP 
address, and port.  This requires a mutex lock and unlock on every possible call 
number until we find it, as well.  Note that the call number is 15 bits long, so 
there are 2^15 (32768) possible call numbers.  That means, if the call number 
for an IAX2 call is 25000, Asterisk would currently do 25000 mutex lock and 
unlock operations for every single media frame!!!

Of course, there are ways that we could really optimize this lookup process. 
However, I'm trying to figure out if it really has to be done at all, because 
getting rid of it all together would be the best optimization.  As it stands, 
you would still have to do some sort of lookup process on all active calls to 
find which one the frame belongs to.

I have already contacted Mark about this, and he has not been able to think of a 
reason that it is the way it is.

Aside from the obvious issue of completely breaking compatibility with every 
IAX2 implementation there is, including previous Asterisk versions, can anyone 
think of a reason that media frames should carry the source call number as 
opposed to the destination call number?


References:

chan_iax2.c:
    in 1.4 and trunk, see the functions socket_process() and find_callno().

IAX2 RFC Draft:
    http://www.ietf.org/internet-drafts/draft-guy-iax-02.txt


-- 
Russell Bryant
Software Engineer
Digium, Inc.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: russell.vcf
Type: text/x-vcard
Size: 266 bytes
Desc: not available
Url : http://lists.digium.com/pipermail/asterisk-dev/attachments/20061128/1161b6a7/russell.vcf


More information about the asterisk-dev mailing list