<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7654.12">
<TITLE>RE: [sr-dev] improving the dialog module</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>&gt; Ovidiu Sas wrote:<BR>
&gt;&gt; If not, I don't think creating two dialogs for each call were one of<BR>
&gt;&gt; them will definitely be dangling and not cleaned up until the dialog<BR>
&gt;&gt; timeout (which is quite long by default) triggers is a viable option for<BR>
&gt;&gt; large-scale environments (such as ours). The rate at which new dialogs<BR>
&gt;&gt; are created could possibly outrun the rate at which they terminate,<BR>
&gt;&gt; which isn't desirable resource-wise.<BR>
&gt;<BR>
&gt; The issue in the current design is the dialog matching algorithm.<BR>
&gt; If two dialogs are created, both of them will be chained in the same<BR>
&gt; dialog list.<BR>
&gt; When an in dialog request is received, the first dialog that matched<BR>
&gt; the callid, to/from tag is updated and the second one is just hanging<BR>
&gt; around (it will never be touched).<BR>
&gt; What we need, is a better dialog match (if an in dialog request for<BR>
&gt; the second dialog is received, then the second dialog should be<BR>
&gt; selected and updated, not the first one).&nbsp; What I'm proposing here is<BR>
&gt; that dialog matching should be done based on callid, to/from tag,<BR>
&gt; branch id, list of Route/Record-Route headers).&nbsp; This should ensure<BR>
&gt; that the proper dialog is handle for each in dialog request and no<BR>
&gt; dialog will be left over.<BR>
<BR>
Agreed that more strict matching logic will allow having multiple<BR>
dialogs to be resolved properly. Still, multiple dialogs come at a<BR>
price, please see further below.<BR>
<BR>
<BR>
&gt; Even if we have a spiral and the INVITE is going twice through the<BR>
&gt; server (and two individual transactions are created), IMHO one dialog<BR>
&gt; is not a proper representation of the call.<BR>
<BR>
Can you be more specific as to why a single dialog isn't appropriate?<BR>
<BR>
I am thinking that a single dialog could actually be helpful: It abstracts<BR>
from numerous transactions that could possibly be established for a<BR>
request that is essentially the same (i.e., except for routing information)<BR>
at several locations in spiral scenarios. From an end-to-end perspective,<BR>
it doesn't seem that important to know how many transactions a request<BR>
spawns but how the associated dialog's state changes over time. Having as<BR>
little dialogs as possible will help with observing these changes.<BR>
<BR>
<BR>
&gt; Let's assume the following scenario:<BR>
&gt; UA1 --&gt; P1 --&gt; P2 --&gt; P1 --&gt; UA2<BR>
&gt; Now, UA2 rejects the call, but P2 decides to reroute the call to an IVR<BR>
&gt; UA1 --&gt; P1 --&gt; P2 --&gt; IVR<BR>
&gt; What will be the state of the dialog on P1?<BR>
<BR>
I think this example of yours shows a potential problem of the<BR>
multiple-dialogs case while there is none in the single-dialog case.<BR>
<BR>
First, the single-dialog case: When P1 receives the request from UA1, it<BR>
establishes a new, yet unconfirmed dialog. When it receives the request<BR>
from P2, it continues the dialog and does not create a new one.<BR>
When UA2's rejection is received by P1, the dialog will be terminated.<BR>
(This is what the dialog module already does now.) When P2 decides to send<BR>
out the request to another destination (like the IVR), P1 will establish a<BR>
new dialog (since there's none to continue anymore). I cannot see any<BR>
dialog handling problems in this approach.<BR>
<BR>
Now to the multiple-dialog case. When P1 receives P2's request, instead<BR>
of continuing the first dialog, it establishes another one which is<BR>
differentiated from the first by means of improved dialog matching<BR>
capabilities (covering the additional items branch ID and record/record-<BR>
route headers that you mentioned above). Now, if I get you right, when<BR>
UA2's rejection is received by P1, it will terminate just one of its<BR>
dialogs (the second one I suppose).<BR>
The next question that I ask myself is: When P2's re-routed request is<BR>
received by P1, will it re-use the first dialog? I'm not sure if that<BR>
will definitely happen, especially not if you select the Via header as<BR>
branch ID that changes between the initial and re-routed request. In that<BR>
case, you will end up with another new dialog (a third one), and the very<BR>
first one will never have a chance to be destroyed prior to the dialog<BR>
timeout trigger.<BR>
<BR>
<BR>
&gt; I think having multiple dialogs for each branch of the spiral keeps<BR>
&gt; things clean and easy to understand.&nbsp; The key is to perform proper<BR>
&gt; matching for in-dialog requests to the corresponding dialog.<BR>
<BR>
Unless my comparison of the two approaches w.r.t. the call setup above<BR>
is wrong, it seems to me that the continuation method is easier to<BR>
grasp (you do not have to think it terms of multiple dialogs), consumes<BR>
less memory, and presumably requires less code modifications.<BR>
<BR>
Another issue from the dialog users' perspective: If you want to track<BR>
the call given above using the dialog module's callbacks, it should be<BR>
easier to do so the less dialogs of essentially the same call exist.<BR>
When there are multiple dialogs, users will need to take care themselves<BR>
not to track calls multiple times. For instance, if you want to make a<BR>
copy of the SIP messages exchanged for some reason, you'd need special<BR>
effort to avoid duplicate copies if several dialogs track the same call<BR>
data.<BR>
<BR>
<BR>
&gt;&gt;&gt; One issue that I have with one single dialog is related to how dialog<BR>
&gt;&gt;&gt; termination is handled on timeout.  When BYE on timeout needs to be<BR>
&gt;&gt;&gt; sent, where will be sent, as the single dialog will have four<BR>
&gt;&gt;&gt; endpoints:<BR>
&gt;&gt;&gt;  - UA1 (the original caller)<BR>
&gt;&gt;&gt;  - P2 (the routed destination for the initial request)<BR>
&gt;&gt;&gt;  - P2 (the incoming destination for the forwarded request)<BR>
&gt;&gt;&gt;  - UA2 (the routed destination for the forwarded request)<BR>
&gt;&gt;<BR>
&gt;&gt; I believe it's still just two endpoints no matter how long the route<BR>
&gt;&gt; path is, namely the hosts comprising the end-to-end dialog relationship<BR>
&gt;&gt; at the edge defined by the Contact header addresses.<BR>
&gt;&gt;<BR>
&gt;&gt; That's where BYE messages are sent based on a look at the dialog code.<BR>
&gt;&gt; It also seems that record-routing is honored, so even if hosts on the<BR>
&gt;&gt; route require to see the triggered or &quot;natural&quot; BYE message, they will<BR>
&gt;&gt; do so.<BR>
&gt;<BR>
&gt; If you have a single dialog, then were the BYE messages will be sent:<BR>
&gt; - to UA1 and P2<BR>
&gt; - to P2 and UA1<BR>
&gt; - to UA1 and UA2<BR>
<BR>
To UA1 and UA2: They represent the endpoints because they provide the<BR>
respective Contact headers used to send the BYE message. The Contact<BR>
addresses will never change no matter at which point in the routing path<BR>
you set up a dialog.<BR>
<BR>
<BR>
Cheers,<BR>
<BR>
--Timo</FONT>
</P>

</BODY>
</HTML>