<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Can you try over tcp? It would be the same case as for tls from
    forking point of view. It will speed up if I get the SIP trace, as I
    have quite loaded schedule for the moment to test it myself.<br>
    <br>
    Cheers,<br>
    Daniel<br>
    <br>
    <div class="moz-cite-prefix">On 24/07/14 01:41, Allen Zhang wrote:<br>
    </div>
    <blockquote
cite="mid:04588C075527D74CABD19E7C320BCB1C08047C2F@WEMAIL01.we.imgtec.org"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <meta name="Generator" content="Microsoft Word 14 (filtered
        medium)">
      <style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        color:black;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";
        color:black;
        mso-fareast-language:EN-US;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;
        mso-fareast-language:EN-US;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";
        color:black;
        mso-fareast-language:EN-US;}
span.EmailStyle21
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle22
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle23
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle24
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
      <div class="WordSection1">
        <p class="MsoNormal"><span style="color:#1F497D">After a second
            thought:<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">This shouldn’t
            be a problem since the
          </span><span
            style="font-size:10.0pt;font-family:Consolas;mso-fareast-language:EN-NZ">cleanup_uac_timers(
            t );
          </span><span style="color:#1F497D">function call should clear
            the timer on all branches and the local 408 shouldn’t be
            generated at all.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">So the problem
            now is why the local 408 were generated.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">Allen<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
        <div>
          <div style="border:none;border-top:solid #B5C4DF
            1.0pt;padding:3.0pt 0cm 0cm 0cm">
            <p class="MsoNormal"><b><span
style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext;mso-fareast-language:EN-NZ"
                  lang="EN-US">From:</span></b><span
style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext;mso-fareast-language:EN-NZ"
                lang="EN-US"> Allen Zhang <br>
                <b>Sent:</b> Thursday, 24 July 2014 11:11 a.m.<br>
                <b>To:</b> '<a class="moz-txt-link-abbreviated" href="mailto:miconda@gmail.com">miconda@gmail.com</a>'; 'Kamailio (SER) - Users
                Mailing List'<br>
                <b>Cc:</b> Shane Harrison<br>
                <b>Subject:</b> RE: [SR-Users] MESSAGE forking bug(?)<o:p></o:p></span></p>
          </div>
        </div>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><span style="color:#1F497D">Found the bug
            (I believe):<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">In t_reply.c,
            line 2411 (kamailio 4.0.0):<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span
            style="font-size:10.0pt;font-family:Consolas;mso-fareast-language:EN-NZ">done:</span><span
style="font-size:10.0pt;font-family:Consolas;color:windowtext;mso-fareast-language:EN-NZ"><o:p></o:p></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span
            style="font-size:10.0pt;font-family:Consolas;mso-fareast-language:EN-NZ">      
            tm_ctx_set_branch_index(T_BR_UNDEFINED);</span><span
style="font-size:10.0pt;font-family:Consolas;color:windowtext;mso-fareast-language:EN-NZ"><o:p></o:p></span></p>
        <p class="MsoNormal" style="text-autospace:none"><span
            style="font-size:10.0pt;font-family:Consolas;mso-fareast-language:EN-NZ">      
          </span><span
style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F;mso-fareast-language:EN-NZ">/*
            we are done with the transaction, so
            <u>unref</u> it - the reference</span><span
style="font-size:10.0pt;font-family:Consolas;color:windowtext;mso-fareast-language:EN-NZ"><o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F;mso-fareast-language:EN-NZ">      
            * was incremented by t_check() function -<u>bogdan</u>*/<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:10.0pt;font-family:Consolas;color:#3F7F5F;mso-fareast-language:EN-NZ"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">This is true
            only for INVITEs. After a 200 is received for an INVITE,
            other branches are cancelled, hence it’s save to unref the
            transaction.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">But for
            MESSAGEs, after a 200 is received, other branches may time
            out and the transaction needs to be found when locally
            generated 408 hits the server.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">Can the author
            of the TM module suggest a solution, please?<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">In the
            meantime, I’ll try to patch it myself.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">Cheers,<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">Allen<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
        <div>
          <div style="border:none;border-top:solid #B5C4DF
            1.0pt;padding:3.0pt 0cm 0cm 0cm">
            <p class="MsoNormal"><b><span
style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext;mso-fareast-language:EN-NZ"
                  lang="EN-US">From:</span></b><span
style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext;mso-fareast-language:EN-NZ"
                lang="EN-US"> Allen Zhang <br>
                <b>Sent:</b> Thursday, 24 July 2014 9:23 a.m.<br>
                <b>To:</b> '<a class="moz-txt-link-abbreviated" href="mailto:miconda@gmail.com">miconda@gmail.com</a>'; Kamailio (SER) - Users
                Mailing List<br>
                <b>Subject:</b> RE: [SR-Users] MESSAGE forking bug(?)<o:p></o:p></span></p>
          </div>
        </div>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><span style="color:#1F497D">Hi,<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">I have a
            tcpdump capture but the traffic is encrypted. So it won’t
            help you.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">I have a clue
            how it happened:<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">When the first
            200 response was received, kamailio successfully matched a
            transaction:<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">Jul 23 00:40:14
             /usr/sbin/kamailio[570]: DEBUG: tm [t_lookup.c:972]: DEBUG:
            t_reply_matching: hash 51776 label 624824282 branch 2<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">Jul 23 00:40:14
             /usr/sbin/kamailio[570]: DEBUG: tm [t_lookup.c:1032]:
            DEBUG: t_reply_matching: reply matched (T=0x7fb52d367f50)!<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">But when the
            locally generated 408 happened, kamailio failed to match a
            transaction:<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">Jul 23 00:40:44
            /usr/sbin/kamailio[583]: DEBUG: tm [t_lookup.c:972]: DEBUG:
            t_reply_matching: hash 51776 label 624824282 branch 0<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">Jul 23 00:40:44
            /usr/sbin/kamailio[583]: DEBUG: tm [t_lookup.c:1066]: DEBUG:
            t_reply_matching: no matching transaction exists<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">Because no
            transaction was matched, kamailio simply forwarded the
            response.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">I’ll modify
            this behaviour in the source code. After receiving the first
            final response, there is no reason to keep the fr_timer
            running on other branches, right?<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">Cheers,<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">Allen<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
        <div>
          <div style="border:none;border-top:solid #B5C4DF
            1.0pt;padding:3.0pt 0cm 0cm 0cm">
            <p class="MsoNormal"><b><span
style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext;mso-fareast-language:EN-NZ"
                  lang="EN-US">From:</span></b><span
style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext;mso-fareast-language:EN-NZ"
                lang="EN-US">
                <a moz-do-not-send="true"
                  href="mailto:sr-users-bounces@lists.sip-router.org">sr-users-bounces@lists.sip-router.org</a>
                [<a moz-do-not-send="true"
                  href="mailto:sr-users-bounces@lists.sip-router.org">mailto:sr-users-bounces@lists.sip-router.org</a>]
                <b>On Behalf Of </b>Daniel-Constantin Mierla<br>
                <b>Sent:</b> Wednesday, 23 July 2014 10:41 p.m.<br>
                <b>To:</b> Kamailio (SER) - Users Mailing List<br>
                <b>Subject:</b> Re: [SR-Users] MESSAGE forking bug(?)<o:p></o:p></span></p>
          </div>
        </div>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal" style="margin-bottom:12.0pt">Hello,<br>
          <br>
          can you get the sip traffic with ngrep on kamailio server? It
          can be taken with:<br>
          <br>
          ngrep -d any -qt -W byline port 5060<br>
          <br>
          Cheers,<br>
          Daniel<o:p></o:p></p>
        <div>
          <p class="MsoNormal">On 23/07/14 03:08, Allen Zhang wrote:<o:p></o:p></p>
        </div>
        <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
          <p class="MsoNormal">Hi,<o:p></o:p></p>
          <p class="MsoNormal"> <o:p></o:p></p>
          <p class="MsoNormal">I believe there is a bug on MESSAGE
            forking.<o:p></o:p></p>
          <p class="MsoNormal"> <o:p></o:p></p>
          <p class="MsoNormal">Test scenario:<o:p></o:p></p>
          <p class="MsoNormal">User A has two records in the location
            table, with different instance ids: 111 and 222.<o:p></o:p></p>
          <p class="MsoNormal">One of user A’s instance is killed, hence
            222 is not reachable.<o:p></o:p></p>
          <p class="MsoNormal"> <o:p></o:p></p>
          <p class="MsoNormal">User B send a MESSAGE to user A.<o:p></o:p></p>
          <p class="MsoNormal"> <o:p></o:p></p>
          <p class="MsoNormal">Kamailio forked the MESSAGE.<o:p></o:p></p>
          <p class="MsoNormal"> <o:p></o:p></p>
          <p class="MsoNormal">Kamailio got a ‘200 Message delivered’
            response from 111 and forwarded it to user B.<o:p></o:p></p>
          <p class="MsoNormal">The MESSAGE forked to 222 timed out.
            Kamailio send a ‘408 Time out’ to user B.<o:p></o:p></p>
          <p class="MsoNormal"> <o:p></o:p></p>
          <p class="MsoNormal">This violates RFC 3428 section 4. It
            states that the forking UAS should only send ONE final
            response to the sender UAC.<o:p></o:p></p>
          <p class="MsoNormal"> <o:p></o:p></p>
          <p class="MsoNormal">Forking is done by t_relay(), and the
            registrar parameter ‘append_branches’ is set to default
            value 1.<o:p></o:p></p>
          <p class="MsoNormal"> <o:p></o:p></p>
          <p class="MsoNormal">Did I do something wrong, or there is a
            bug?<o:p></o:p></p>
          <p class="MsoNormal"> <o:p></o:p></p>
          <p class="MsoNormal">Regards,<o:p></o:p></p>
          <p class="MsoNormal">Allen<o:p></o:p></p>
          <p class="MsoNormal"><span style="mso-fareast-language:EN-NZ"> </span><o:p></o:p></p>
          <p class="MsoNormal"> <o:p></o:p></p>
          <p class="MsoNormal" style="margin-bottom:12.0pt"><span
              style="font-size:12.0pt;font-family:"Times New
              Roman","serif";mso-fareast-language:EN-NZ"><o:p> </o:p></span></p>
          <pre>_______________________________________________<o:p></o:p></pre>
          <pre>SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<o:p></o:p></pre>
          <pre><a moz-do-not-send="true" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><o:p></o:p></pre>
          <pre><a moz-do-not-send="true" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><o:p></o:p></pre>
        </blockquote>
        <p class="MsoNormal" style="margin-bottom:12.0pt"><span
            style="font-size:12.0pt;font-family:"Times New
            Roman","serif";mso-fareast-language:EN-NZ"><o:p> </o:p></span></p>
        <pre>-- <o:p></o:p></pre>
        <pre>Daniel-Constantin Mierla - <a moz-do-not-send="true" href="http://www.asipto.com">http://www.asipto.com</a><o:p></o:p></pre>
        <pre><a moz-do-not-send="true" href="http://twitter.com/#%21/miconda">http://twitter.com/#!/miconda</a> - <a moz-do-not-send="true" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a><o:p></o:p></pre>
      </div>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla - <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a></pre>
  </body>
</html>