[Freeswitch-dev] Questions regarding the architecture

Alex Guan alex.guan at prodeasystems.com
Thu Sep 7 15:26:41 EDT 2006


Anthony,
 
Great answers indeed.  Thanks a lot!  Is there a documentation system that I can save it to ... like a wiki?  These information are too valuable to be buried in the mail archive.
 
It took me a while but I think I have come to agreement for pretty much every point you made, except one.  The only thing I felt suspicious is the busy waiting in which the originator polls check_channel_status() a million times after the originatee starts ringing but before it answers.   Can't we wait for a mutex or condition waken up by CALL_ANSWERED?  Imagine if you have a thousand incoming calls, there will be 1000 while loops spinning the processor.
 
Another issue I noticed is that hold/resume is not working properly.  There was no 200OK for the re-INVITE.  I tried to debug further but somehow couldn't get into mod_exosip.c using gdb.  (DDD and Eclipse behaved the same.  Does anybody have the same issue?)  I kind of guess the issue is what kind of SDP is the SIP phone sending for hold.  The old way is to set an all zero O field, as opposed to SENDONLY or INACTIVE.  Anyways, if mod_exopsip.c is going way, we should probably just wait for mod_sofia.
 
Two more basic questions:
1. Licensing.  A main problem I saw with Asterisk is it's GPL/Digium dual licensing scheme.  I don't see any serious business development could be possible under this license.  I think Mark and his company have made a big mistake on this subject.  (And their business model as well.)  What's the main rationale for you/other founders to choose MPL?  Do you favour/oppose to commercial development using freeswitch in their proprietary systems?
 
2. Memory usage.  I am seeing freeswitch using 25M bytes of memory with just one basic SIP call.  It's a little surprising.  Should I turn on the -Os to see if we can save some space?

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+ COMMAND
25295 root       0 -20 27040  25m 3696 S    0  2.5   0:00.12 lt-freeswitch             

Thanks,
Alex

________________________________

From: Anthony Minessale [mailto:anthmct at yahoo.com]
Sent: Wed 9/6/2006 2:01 PM
To: freeswitch-dev at lists.freeswitch.org
Subject: Re: [Freeswitch-dev] Questions regarding the architecture


1.   Thread architecture.  For a basic call, why do we need two threads for the sessions (one for each endpoint)?  While the thread in charge of originator  is in the switch_core_standard_on_execute(), the other thread is in the switch_core_session_run() while loop.    What's advantage of doing this compared to Asterisk's one thread approach?  Why do we need the thread for the originatee?
A)
 
Every session has a thread which is managed by the state machine in the core which sees it from creation to destruction.
In the case of a bridged call the existing thread of both sessions are used to move inbound audio across to the opposite session at the same time.
A one threaded approach such as asterisk will leave you doing poll's on 2 sockets at once and blocking in one direction will impeed the other as 
well as forcing you to expose something that can be polled, (not all channels have sockets)
The states of the orignatee channel are overridden from the default behaviour to perform the bridge
in this case:
CS_HOLD pauses the thread.
CS_RING moves the state to CS_HOLD where it will wait until it's moved to CS_LOOPBACK or CS_HANGUP by the originate function. 
CS_LOOPBACK runs the audio bridge code sending the audio back to the other channel.
The originator is in CS_EXECUTE meaning it's running instructions installed by a dialplan module.
At this point both channels are in the same code reading A and writing B as well as moving messages and dtmf across one another.
If either is interrupted the functions exits in both sessions and the originatee state override table 
is cleared and the session is moved to the new state where the execution continues.  if this state is hangup
the call ends.

2. What does CS_LOOPBACK really mean?  When A calls B, B is in the LOOPBACK state after the call is established.  Yet, the switch_core_on_loopback() is not really called.
A)
 
The default for loopback is to echo the audio back to the channel, 
in the case of a bridge it's overridden to send it audio to the other session instead
of itself.
 
 
3. When A calls B and before B answers, the caller session thread does busy waiting by constantly calling check_channel_status().  Is there a better approach than this?   And with this architecture how are we going to incorporate with the voice mail and other timer-based applications?
 
A)
Yes this is the best approach, the originator has created the originatee and is waiting for the endpoint module to place it into the CS_RING state 
when this happens because we overrode it we move it to CS_HOLD and wait for it to be answered or for a timeout to occur.
The point is we have waited for it to be safe for us to control.

4. When the orginatee hangs up, the exosip_kill_channel() was called 3 times just for the orginatee channel.  The same function is called twice for the originator channel.  Is this by design?
 
A)
The should be as few calls to this as possible once it's ok to have mutiple calls to it it just calls for any blocking to end
on a read or write operation such as the socket api call "shutdown()" does 
We are not using exosip anymore, we have started coding mod_sofia which is our preferred sip code.
There are several changes comming up this week you may want to study.

Thanks,

 
Anthony Minessale II

FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/

AIM: anthm
MSN:anthony_minessale at hotmail.com
JABBER:anthony.minessale at gmail.com
IRC: irc.freenode.net #freeswitch

FreeSWITCH Developer Conference
sip:888 at 66.250.68.194
iax:guest at 66.250.68.194/888
googletalk:freeswitch at gmail.com
pstn:712-432-7800


----- Original Message ----
From: Alex Guan <alex.guan at prodeasystems.com>
To: freeswitch-dev at lists.freeswitch.org
Sent: Wednesday, September 6, 2006 10:13:43 AM
Subject: [Freeswitch-dev] Questions regarding the architecture


Gang,

I am new to freeswitch and have been studying it for the last week.  A few questions regarding the architecture.  Any input will be greatly appreciated.

1.   Thread architecture.  For a basic call, why do we need two threads for the sessions (one for each endpoint)?  While the thread in charge of originator  is in the switch_core_standard_on_execute(), the other thread is in the switch_core_session_run() while loop.    What's advantage of doing this compared to Asterisk's one thread approach?  Why do we need the thread for the originatee?

2. What does CS_LOOPBACK really mean?  When A calls B, B is in the LOOPBACK state after the call is established.  Yet, the switch_core_on_loopback() is not really called.

3. When A calls B and before B answers, the caller session thread does busy waiting by constantly calling check_channel_status().  Is there a better approach than this?   And with this architecture how are we going to incorporate with the voice mail and other timer-based applications?

4. When the orginatee hangs up, the exosip_kill_channel() was called 3 times just for the orginatee channel.  The same function is called twice for the originator channel.  Is this by design?

Thanks,
Alex
_______________________________________________
Freeswitch-dev mailing list
Freeswitch-dev at lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev <http://console.mxlogic.com/redir/?5dOWbXb8USC-yejhjhdw0PVkDjDo_Z34FS9Y01MjlS67OFek7qUX7_EoBeNcKxVATvzhOYMOMyOYeodECTo_Z34FS9BQfcBO5mUm-wafBitetz_QciDoDM04Sy-yMCrhhv7fK6zBxUQsCTNNI5-Aq83iSbN_W69jIjbEupdbFEw0tLWjBm53h17OeNgB0yq89A_d46NIjBfXjrzVKvxYYmfSk3q9JASC-yejKYUr3wsm> 
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev <http://console.mxlogic.com/redir/?5dOWbXb8USC-yejhjhdw0PVkDjDo_Z34FS9Y01MjlS6lmDaIaoX7_EoBeNcKxVATvzhOYMOMyOYeodECTo_Z34FS9BQfcBO5mUm-wafBitetz_QciDoDM04Sy-yMCrhhv7fK6zBxUQsCTNNI5-Aq83iSbN_W69jIjbEupdbFEw0tLWjBm53h17OeNgB0yq89A_d46NIjBfXjrzVKvxYYmfSk3qpJASC-yejKYUr3wsm> 
http://www.freeswitch.org <http://console.mxlogic.com/redir/?5dOWbXb8USC-yejhjhdw0Do_Z34FS9Y01MTvzhOYMOMyOYeodECTo_Z34FS9BQfcBO5mUm-wafBitetz_QciDoDM04Sy-yMCrhhv7fK6zBxUQsCTNNI5-Aq83iSbN_W69jIjbEupdbFEw0tLWjBm53h17OeNgB0yq89A_d46NIjBfXjrzVKvxYYmfSk3r9JASC-yejKYUr3wsm> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 11205 bytes
Desc: not available
Url : http://lists.freeswitch.org/pipermail/freeswitch-dev/attachments/20060907/6cde6a70/attachment.bin 


More information about the Freeswitch-dev mailing list