Question regarding t_check_trans()

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Question regarding t_check_trans()

Joe Baran
Probably an elementary question, but we're relatively new at digging into the details.  We are trying to understand the following block of config code and have a question or two.  Our assumption is the t_precheck_trans() function tells us whether another packet has arrived already as a retransmission.  However, we're not clear on what the t_check_trans() is doing assuming the condition is true.  Any direction on this?

Thanks.

route[CHECK_RETRANS]
{
  # handle retransmissions
    if(t_precheck_trans()) {
        t_check_trans();
        exit;
    }
}


Joe Baran

_______________________________________________
Kamailio (SER) - Users Mailing List
[hidden email]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Question regarding t_check_trans()

Alex Balashov
Hello Joe,

On Fri, Aug 04, 2017 at 03:45:12PM -0400, Joe Baran wrote:

> Probably an elementary question, but we're relatively new at digging into
> the details.  We are trying to understand the following block of config
> code and have a question or two.  Our assumption is the t_precheck_trans()
> function tells us whether another packet has arrived already as a
> retransmission.  However, we're not clear on what the t_check_trans() is
> doing assuming the condition is true.  Any direction on this?
>
> Thanks.
>
> route[CHECK_RETRANS]
> {
>   # handle retransmissions
>     if(t_precheck_trans()) {
>         t_check_trans();
>         exit;
>     }
> }

t_check_trans() is the traditional method of retransmission dampening,
and does different things depending on what type of message is being
processed. For most requests, however, it resends the last reply (if the
transaction is known) and ends route script execution for that message.
If the transaction is not matched, it just returns false and execution
carries on. You can read more about the details here:
 
https://kamailio.org/docs/modules/5.0.x/modules/tm.html#tm.f.t_check_trans

But in order to use t_check_trans(), an actual transaction has to be
created, and that is fairly expensive from a performance point of view
(in strictly relative terms). The purpose of t_precheck_trans() is to
provide a lightweight retransmission detection mechanism which does not
require a transaction to actually be created and destroyed in order to
detect retransmissions.

You can read more about the rationale here:

http://blog.miconda.eu/2014/10/kamailio-42-tips-10-lightweight.html

Long story short: t_check_trans() only detects retransmissions if an
actual transaction was created (via t_newtran() or, most commonly, via
t_relay()). t_precheck_trans() is a lighter-weight wrapper around it
which does not require that in order to detect and suppress
retransmissions.

-- Alex

--
Alex Balashov | Principal | Evariste Systems LLC

Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free)
Web: http://www.evaristesys.com/, http://www.csrpswitch.com/

_______________________________________________
Kamailio (SER) - Users Mailing List
[hidden email]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Question regarding t_check_trans()

Daniel-Constantin Mierla-6
In reply to this post by Joe Baran

Hello,

t_precheck_trans() is returning true if a SIP worker process has received the SIP request and it is handling it at that moment. However, in case of a retransmission, that can be at the moment when the transaction was already created for the previous same requests (e.g., via t_newtran() or the execution is in a branch_route block). The specs require that a stateful proxy re-sends the last response in case of a re-transmission. t_check_trans() is used for that purpose, to see if the transaction was already created and to what specs require.

If still not clear, I will try to add more details.

Cheers,
Daniel


On 04.08.17 21:45, Joe Baran wrote:
Probably an elementary question, but we're relatively new at digging into the details.  We are trying to understand the following block of config code and have a question or two.  Our assumption is the t_precheck_trans() function tells us whether another packet has arrived already as a retransmission.  However, we're not clear on what the t_check_trans() is doing assuming the condition is true.  Any direction on this?

Thanks.

route[CHECK_RETRANS]
{
  # handle retransmissions
    if(t_precheck_trans()) {
        t_check_trans();
        exit;
    }
}


Joe Baran


_______________________________________________
Kamailio (SER) - Users Mailing List
[hidden email]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training - www.asipto.com
Kamailio World Conference - www.kamailioworld.com

_______________________________________________
Kamailio (SER) - Users Mailing List
[hidden email]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Loading...