<div><div dir="auto">I have a question on this, since 180 arrived before the 200, shouldn’t it go out before? I.e.: FIFO? Or is this not happening because there are multiple processes and one may take the 180 and the other the 200 and they are processes independently?</div><div dir="auto"><br></div><div dir="auto">I guess setting the childs to only 1 should prove this theory.</div><div dir="auto"><br></div><div dir="auto">David</div></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 8 Apr 2020 at 16:51, Luis Rojas G. <<a href="mailto:luis.rojas@sixbell.com">luis.rojas@sixbell.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)">

  
  <div>
    <div>Hi, Henning,</div>
    <div><br>
    </div>
    <div>No need to be ironic. As I mentioned on
      my first post, I tried stateful proxy and I observed the same
      behavior. <br>
      <br>
      <i>"I tried using stateful proxy and I obtained the same result."</i><br>
      <br>
      The asynchronous sleep seems promising. I will look into it.<br>
      <br>
      Thanks,</div>
    <div><br>
    </div>
    <div>Luis</div></div><div><div><br>
      <br>
      <br>
      On 4/8/20 9:30 AM, Henning Westerholt wrote:<br>
    </div>
    <blockquote type="cite">
      
      
      
      
      <div>
        <p class="MsoNormal"><span>Hi
            Luis,<u></u><u></u></span></p>
        <p class="MsoNormal"><span><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB">I see. Well, you want to use Kamailio as a
            stateless proxy, on the other hand it should do things that
            are inherently stateful.
          </span><span lang="EN-GB">😉</span><span lang="EN-GB"><u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB">As mentioned, have a look to the dialog module
            to track the state of dialogs that you process. This will
            not work in a stateless mode, though.
            <u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB">You can also use the htable module to just
            store some data about the processed messages in a shared
            memory table and use this to enforce your ordering. There is
            also the option to do an asynchronous sleep (with the async)
            module on the message that you want to delay but still
            processing other messages during it.<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB">Cheers,<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB">Henning<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
        <div>
          <p class="MsoNormal"><span lang="EN-GB">-- <u></u>
              <u></u></span></p>
          <p class="MsoNormal"><span lang="EN-GB">Henning Westerholt –
            </span><span><a href="https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fskalatan.de%2Fblog%2F&data=02%7C01%7C%7C365ec3c445394a3b0dfa08d7dbc0fe3a%7Cab4a33c2b5614f798601bc921698ad08%7C0%7C0%7C637219494311846648&sdata=Rlxmq4vieb20HKUi4se4MfGJSuETpO%2Bd8uK0KzBTWO0%3D&reserved=0" target="_blank"><span style="color:rgb(5,99,193)" lang="EN-GB">https://skalatan.de/blog/</span></a></span><span lang="EN-GB"><u></u><u></u></span></p>
          <p class="MsoNormal"><span lang="EN-GB">Kamailio services –
            </span><span><a href="https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgilawa.com%2F&data=02%7C01%7C%7C365ec3c445394a3b0dfa08d7dbc0fe3a%7Cab4a33c2b5614f798601bc921698ad08%7C0%7C0%7C637219494311846648&sdata=nAvHd08RTXoEAFfpOuoGQJnoRmOtzQ0RSfS2RYwIyQs%3D&reserved=0" target="_blank"><span style="color:rgb(5,99,193)" lang="EN-GB">https://gilawa.com</span></a></span><span>
              <span lang="EN-GB"><u></u><u></u></span></span></p>
        </div>
        <p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
        <div>
          <div style="border-style:solid none none;border-top-width:1pt;padding:3pt 0cm 0cm;border-top-color:rgb(225,225,225)">
            <p class="MsoNormal" style="margin-left:35.4pt"><b>From:</b>
              Luis Rojas G. <a href="mailto:luis.rojas@sixbell.com" target="_blank"><luis.rojas@sixbell.com></a>
              <br>
              <b>Sent:</b> Wednesday, April 8, 2020 3:00 PM<br>
              <b>To:</b> Henning Westerholt <a href="mailto:hw@skalatan.de" target="_blank"><hw@skalatan.de></a>;
              Kamailio (SER) - Users Mailing List
              <a href="mailto:sr-users@lists.kamailio.org" target="_blank"><sr-users@lists.kamailio.org></a><br>
              <b>Subject:</b> Re: [SR-Users] Kamailio propagates 180 and
              200 OK OUT OF ORDER<u></u><u></u></p>
          </div>
        </div>
        <p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
        <div>
          <p class="MsoNormal" style="margin-left:35.4pt">Hello,
            Henning,<u></u><u></u></p>
        </div>
        <div>
          <p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
        </div>
        <div>
          <p class="MsoNormal" style="margin-left:35.4pt">I am worried
            about this scenario, because it's a symptom of what may
            happen in other cases. For instance, I've seen that this
            operator usually sends re-invites immediate after sending
            ACK.   This may create race conditions like 3.1.5 of RFC5407<br>
            <br>
            <a href="https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Ftools.ietf.org%2Fhtml%2Frfc5407%23page-22&data=02%7C01%7C%7C365ec3c445394a3b0dfa08d7dbc0fe3a%7Cab4a33c2b5614f798601bc921698ad08%7C0%7C0%7C637219494311856645&sdata=fwVfaNyZ7hCyBvYz%2BdlWBMf52MuFdhBxHpnYysjA0FA%3D&reserved=0" target="_blank">https://tools.ietf.org/html/rfc5407#page-22</a><br>
            <br>
            I'd understand that one happens because of packet loss, as
            it's in UDP's nature, but in this case it would be
            artificially created by Kamailio. if there was no problem at
            network level (packet loss, packets following different path
            on the network and arriving out of order), why Kamailio
            creates it? <br>
            <br>
            I'd expect that the shared memory is used precisely for
            this. If an instance of kamailio receives a 200 OK, it could
            check on the shm and say "hey, another instance is
            processing a 180 for this call. Let's wait for it to finish"
            (*). I know there could still be a problem, the instance
            processing the 180 undergoes a context switch just after it
            receives the message, but before writing to shm, but it
            would greatly reduce the chance.<u></u><u></u></p>
        </div>
        <div>
          <p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
        </div>
        <div>
          <p class="MsoNormal" style="margin-right:0cm;margin-bottom:12pt;margin-left:35.4pt">In
            our applications we use a SIP stack that always sends
            messages to the application in the same order it receives
            them, even though is multi-threaded and messages from the
            network are received by different threads. So, they really
            syncronize between them. Why Kamailio instances don't?<br>
            <br>
            I am evaluating kamailio to use it as a dispatcher to
            balance load against our several Application Servers, to
            present to the operator just a couple of entrance points to
            our platform (they don't want to establish connections to
            each one of our servers). This operator is very difficult to
            deal with. I am sure they will complain something like "why
            are you sending messages out of order? Fix that". The
            operator will be able to see traces and check that messages
            entered the Kamailio nodes in order and left out of order.
            They will not accept it.<br>
            <br>
            (*) Not really "wait", as it would introduce a delay in
            processing all messages. it should be like putting it on a
            queue, continue processing other messages, and go back to
            the queue later.<br>
            <br>
            Well, thanks for your answer.<br>
            <br>
            Luis<br>
            <br>
            <br>
            <u></u><u></u></p>
        </div>
        <div>
          <p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
        </div>
        <div>
          <p class="MsoNormal" style="margin-left:35.4pt"><br>
            On 4/8/20 3:01 AM, Henning Westerholt wrote:<u></u><u></u></p>
        </div>
        <blockquote style="margin-top:5pt;margin-bottom:5pt">
          <p class="MsoNormal" style="margin-left:35.4pt"><span>Hello Luis,</span><u></u><u></u></p>
          <p class="MsoNormal" style="margin-left:35.4pt"><span> </span><u></u><u></u></p>
          <p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB">as the 1xx
              responses are usually send unreliable (unless you use
              PRACK), you should not make any assumption on the order or
              even the arrival of this messages. It can also happens on
              a network level, if send by UDP.</span><u></u><u></u></p>
          <p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB"> </span><u></u><u></u></p>
          <p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB">Can you
              elaborate why you think this re-ordering is a problem for
              you?</span><u></u><u></u></p>
          <p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB"> </span><u></u><u></u></p>
          <p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB">One idea
              to enforce some ordering would be to use the dialog module
              in combination with reply routes and the textops(x) 
              module.</span><u></u><u></u></p>
          <p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB"> </span><u></u><u></u></p>
          <p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB">About the
              shared memory question – Kamailio implement its own memory
              manager (private memory and shared memory pool).</span><u></u><u></u></p>
          <p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB"> </span><u></u><u></u></p>
          <p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB">Cheers,</span><u></u><u></u></p>
          <p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB"> </span><u></u><u></u></p>
          <p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB">Henning</span><u></u><u></u></p>
          <p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB"> </span><u></u><u></u></p>
          <p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB"> </span><u></u><u></u></p>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB">--
              </span><u></u><u></u></p>
            <p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB">Henning
                Westerholt –
              </span><span><a href="https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fskalatan.de%2Fblog%2F&data=02%7C01%7C%7C365ec3c445394a3b0dfa08d7dbc0fe3a%7Cab4a33c2b5614f798601bc921698ad08%7C0%7C0%7C637219494311866648&sdata=HCaqkR5PR6BmByZVV5%2F59XWfNywkkedMaujpDOOG4dk%3D&reserved=0" target="_blank"><span style="color:rgb(5,99,193)" lang="EN-GB">https://skalatan.de/blog/</span></a></span><u></u><u></u></p>
            <p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB">Kamailio
                services –
              </span><span><a href="https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgilawa.com%2F&data=02%7C01%7C%7C365ec3c445394a3b0dfa08d7dbc0fe3a%7Cab4a33c2b5614f798601bc921698ad08%7C0%7C0%7C637219494311866648&sdata=O1BqU4CI4M6M8OUaE10JvFbJIeH32uZRuQg3ihEkxN0%3D&reserved=0" target="_blank"><span style="color:rgb(5,99,193)" lang="EN-GB">https://gilawa.com</span></a>
              </span><u></u><u></u></p>
          </div>
          <p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-GB"> </span><u></u><u></u></p>
          <div>
            <div style="border-style:solid none none;border-top-width:1pt;padding:3pt 0cm 0cm;border-top-color:rgb(225,225,225)">
              <p class="MsoNormal" style="margin-left:70.8pt"><b>From:</b>
                sr-users <a href="mailto:sr-users-bounces@lists.kamailio.org" target="_blank">
                  <sr-users-bounces@lists.kamailio.org></a> <b>On
                  Behalf Of </b>Luis Rojas G.<br>
                <b>Sent:</b> Tuesday, April 7, 2020 10:43 PM<br>
                <b>To:</b> <a href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a><br>
                <b>Subject:</b> [SR-Users] Kamailio propagates 180 and
                200 OK OUT OF ORDER<u></u><u></u></p>
            </div>
          </div>
          <p class="MsoNormal" style="margin-left:70.8pt"> <u></u><u></u></p>
          <div>
            <p style="margin-left:70.8pt">Good day,<u></u><u></u></p>
            <p style="margin-left:70.8pt">I am testing the dispatcher
              module, using Kamailio as stateless proxy. I have a pool
              of UAC (scripts in SIPP) and a pool of UAS (also scripts
              in SIPP) for the destinations. Kamailio version is
              kamailio-5.3.3-4.1.x86_64.<u></u><u></u></p>
            <p style="margin-left:70.8pt">Problem I have is, if UAS
              responds 180 and 200 OK to Invite immediately, sometimes
              they are propagated out of order. 200 OK before 180, like
              this :<u></u><u></u></p>
            <p style="margin-right:0cm;margin-bottom:12pt;margin-left:70.8pt"><img src="cid:1715a7ea85ead7999131" border="0" style="width:597px;max-width:100%"><u></u><u></u></p>
            <p style="margin-left:70.8pt">UAS is <a href="http://172.30.4.195:5061" target="_blank">172.30.4.195:5061</a>. UAC
              is <a href="http://172.30.4.195:5080" target="_blank">172.30.4.195:5080</a>. Kamailio is <a href="http://192.168.253.4:5070" target="_blank">192.168.253.4:5070</a><u></u><u></u></p>
            <p style="margin-left:70.8pt">Difference between 180 and 200
              is just about 50 microseconds.
              <u></u><u></u></p>
            <p style="margin-left:70.8pt">My guess is that both messages
              are received by different instances of Kamailio, and then
              because of context switches, even though the 180 is
              received before, that process ends after the processing of
              200. However, I had the idea that in order to avoid these
              problems the kamailio processes synchronized with each
              other using a shared memory. I tried using stateful proxy
              and I obtained the same result.<u></u><u></u></p>
            <p style="margin-left:70.8pt">By the way, anyone has any
              idea about how Kamailio's share memory is implemented? It
              clearly does not use the typical system calls shmget(),
              shmat(), because they are not shown by ipcs command.<u></u><u></u></p>
            <p style="margin-left:70.8pt">Before posting here I googled,
              but I couldn't find anything related to this. I can't
              believe I am the only one who ever had this problem, so I
              guess I am doing something wrong...<u></u><u></u></p>
            <p style="margin-left:70.8pt">Please, any help. I'm really
              stuck on this.<u></u><u></u></p>
            <p style="margin-left:70.8pt">Thanks.<u></u><u></u></p>
            <pre style="margin-left:70.8pt;font-family:monospace">-- <u style="font-family:monospace"></u><u style="font-family:monospace"></u></pre>
          </div>
        </blockquote>
        <p style="margin-left:35.4pt"><u></u> <u></u></p>
        <pre style="margin-left:35.4pt;font-family:monospace">-- <u style="font-family:monospace"></u><u style="font-family:monospace"></u></pre>
        <pre style="margin-left:35.4pt;font-family:monospace">Luis Rojas<u style="font-family:monospace"></u><u style="font-family:monospace"></u></pre>
        <pre style="margin-left:35.4pt;font-family:monospace">Software Architect<u style="font-family:monospace"></u><u style="font-family:monospace"></u></pre>
        <pre style="margin-left:35.4pt;font-family:monospace">Sixbell<u style="font-family:monospace"></u><u style="font-family:monospace"></u></pre>
        <pre style="margin-left:35.4pt;font-family:monospace"><a href="https://www.google.com/maps/search/Los+Leones+1200+%0D%0A+++++++++Providencia+%0D%0A+++++++++Santiago,+Chile?entry=gmail&source=g" style="font-family:monospace">Los Leones 1200</a><u style="font-family:monospace"></u><u style="font-family:monospace"></u></pre>
        <pre style="margin-left:35.4pt;font-family:monospace"><a href="https://www.google.com/maps/search/Los+Leones+1200+%0D%0A+++++++++Providencia+%0D%0A+++++++++Santiago,+Chile?entry=gmail&source=g" style="font-family:monospace">Providencia</a><u style="font-family:monospace"></u><u style="font-family:monospace"></u></pre><a href="https://www.google.com/maps/search/Los+Leones+1200+%0D%0A+++++++++Providencia+%0D%0A+++++++++Santiago,+Chile?entry=gmail&source=g">
        </a><pre style="margin-left:35.4pt;font-family:monospace"><a href="https://www.google.com/maps/search/Los+Leones+1200+%0D%0A+++++++++Providencia+%0D%0A+++++++++Santiago,+Chile?entry=gmail&source=g" style="font-family:monospace">Santiago, Chile</a><u style="font-family:monospace"></u><u style="font-family:monospace"></u></pre><a href="https://www.google.com/maps/search/Los+Leones+1200+%0D%0A+++++++++Providencia+%0D%0A+++++++++Santiago,+Chile?entry=gmail&source=g">
        </a><pre style="margin-left:35.4pt;font-family:monospace">Phone: (+56-2) 22001288<u style="font-family:monospace"></u><u style="font-family:monospace"></u></pre>
        <pre style="margin-left:35.4pt;font-family:monospace"><a href="mailto:luis.rojas@sixbell.com" target="_blank" style="font-family:monospace">mailto:luis.rojas@sixbell.com</a><u style="font-family:monospace"></u><u style="font-family:monospace"></u></pre>
        <pre style="margin-left:35.4pt;font-family:monospace"><a href="https://nam02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.sixbell.com%2F&data=02%7C01%7C%7C365ec3c445394a3b0dfa08d7dbc0fe3a%7Cab4a33c2b5614f798601bc921698ad08%7C0%7C0%7C637219494311876634&sdata=25KyYHDQz9BU3XDEGdjjPHgRH4MCZIFOEyXeXUoKjzI%3D&reserved=0" target="_blank" style="font-family:monospace">http://www.sixbell.com</a><u style="font-family:monospace"></u><u style="font-family:monospace"></u></pre>
      </div>
    </blockquote>
    <p><br>
    </p>
    <pre cols="72" style="font-family:monospace">-- 
Luis Rojas
Software Architect
Sixbell
<a href="https://www.google.com/maps/search/Los+Leones+1200%0D%0AProvidencia%0D%0ASantiago,+Chile?entry=gmail&source=g" style="font-family:monospace">Los Leones 1200
Providencia
Santiago, Chile</a>
Phone: (+56-2) 22001288
<a href="mailto:luis.rojas@sixbell.com" target="_blank" style="font-family:monospace">mailto:luis.rojas@sixbell.com</a>
<a href="http://www.sixbell.com" target="_blank" style="font-family:monospace">http://www.sixbell.com</a></pre>
  </div>

_______________________________________________<br>
Kamailio (SER) - Users Mailing List<br>
<a href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a><br>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</blockquote></div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Regards,</div><div><br></div>David Villasmil<div>email: <a href="mailto:david.villasmil.work@gmail.com" target="_blank">david.villasmil.work@gmail.com</a></div><div>phone: +34669448337</div></div></div>