Hi all!

I'm testing some redirect scenarios with Kamailio 5.7.4 and using Astterisk 13 and SIPp for unit testing.

The kamailio's script is simple and uses TM, HTTP_ASYNC_MODULE, JSONRPC, JANSSON, RTJSON and XLog modules.

Request route is simple:
request_route {

  route(HANDLE_OPTIONS);
  route(HANDLE_RETRANS);
  route(HANDLE_CANCEL);
  route(REQINIT);
  route(HANDLE_INVITE);

}

where HANDLE_RETRANS is:

route[HANDLE_RETRANS]{
        # handle retransmissions
        xlog("L_INFO","HANDLE_RETRANS - message type is $mt for method $rm");
        if (!is_method("ACK")) {
                if(t_precheck_trans()) {
                        xlog("L_INFO","HANDLE_RETRANS - Precheck Trans");
                        t_check_trans();
                        xlog("L_INFO", "HANDLE_RETRANS - Exiting after Retransmission check - method $rm");
                        exit;
                }
                xlog("L_INFO","HANDLE_RETRANS - Check Trans");
                t_check_trans();
        }
}


and HANDLE INVITE is:

route[HANDLE_INVITE]{
        if (is_method("INVITE"))
        {
                xlog("L_INFO","MAIN - calling TO_CARRIER");
                setflag(FLT_ACC);              
                route(TO_CARRIER);
                exit;
        }
}

The HTTP requests call a REST API returning a JSON object, that is iterated and produces a CONTACT header containing multiple choices using the append_branch() command.
The RELAY route is :

route[RELAY] {
  # Sends a 300 Multiple Choices back to the proxy that requested the routing lookup
  xlog("L_INFO","REPLY_302 - send reply");
  send_reply("300", "Multiple Choices");
  xlog("L_INFO","REPLY_302 - exit");
  exit;
}

Which returns indeed a Contact header with multiple contact choices.

When using Asterisk to originate a call to Kamailio, the SIP call flow is as follows and terminates (SNGrep and TCPDump do not detect anything else):

SRC                                         DST
        INVITE (SDP)         
 ──────────────────────────> 
  100 trying -- your call is 
 <────────────────────────── 
    300 Multiple Choices     
 <────────────────────────── 
             ACK             
 ──────────────────────────> 

However when using SIPp I get some retransmissions after the final ACK. 
SRC                                         DST
        INVITE (SDP)         
 ──────────────────────────> 
  100 trying -- your call is 
 <────────────────────────── 
    300 Multiple Choices     
 <────────────────────────── 
             ACK             
 ──────────────────────────> 
    300 Multiple Choices     
 <<<──────────────────────── 
    300 Multiple Choices     
 <<<──────────────────────── 
    300 Multiple Choices     
 <<<──────────────────────── 

SIPp scenario is : 
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">

<scenario name="Basic Sipstone UAC">
<!--  In client mode (sipp placing calls), the Call-ID MUST be          -->
<!--  generated by sipp. To do so, use [call_id] keyword.                 -->
<send retrans="500" start_rtd="true" rrs="true">
<![CDATA[
INVITE sip:[call_number]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
Max-Forwards: 70
From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[call_number]
To: <sip:[call_number]@[remote_ip]:[remote_port]>
Contact: sip:sipp@[local_ip]:[local_port];transport=[transport]>
Call-ID: [call_id]
CSeq: 102 INVITE
User-Agent: SIPp
Supported: replaces, timer
Content-Type: application/sdp
Subject: Performance Test
Session-Expires: 3600;refresher=uas
Content-Length: [len]

v=0
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=SIPp
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio [media_port] RTP/AVP 0
a=rtpmap:0 PCMU/8000
]]>
</send>
<recv response="100" rss="true"> </recv>

<recv response="300" rtd="true" rss="true">
    <action>
      <ereg regexp="\&lt;([a-zA-Z0-9@.=;]+)[^&gt;]+"
            search_in="hdr"
            header="Contact: "
            assign_to="1"/>
      <log message="INFO: 300 Contact Header: [$1]" />
      <exec command="echo [$1] >> ./300_ContactHeader.txt" />
    </action>
    <action>
      <ereg regexp="sip:.*@([0-9A-Za-z\.]+):([0-9]+);transport=([A-Z]+)" search_in="hdr" header="Contact:" check_it="true" assign_to="dummy,host,port,transport" />
    </action>
</recv>

<!-- Reference variables="dummy" /-->

  <!-- Send ACK for 180 Ringing
  ACK sip:[service]@[remote_ip]:[remote_port] SIP/2.0 -->
<send rrs="true">
<![CDATA[
ACK sip:[call_number]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
Max-Forwards: 70
From: <sip:sipp@[local_ip]:[local_port]>;tag=[call_number]
To: <sip:[call_number]@[remote_ip]:[remote_port]>[peer_tag_param]
Contact: <sip:sipp@[local_ip]:[local_port]>
Call-ID: [call_id]
CSeq: 102 ACK
User-Agent: SIPp
Content-Length: 0
]]>
</send>

<!--  definition of the response time repartition table (unit is ms)    -->
<!-- ResponseTimeRepartition value="10, 50, 100, 150, 200, 500, 1000"/ -->
</scenario>



The question is : is there anything wrong with my kamailio script? or with SIPp scenario? why does kamailio have different behaviours between Asterisk and SIPp? 
Any option to disable retransmissions on Kamailio ? (using UDP)

Thanks in advance,

Sérgio Charrua