Tips for Kamailio migration

The page collects tips to migrate Kamailio to SIP-Router and get same behaviour. There are Kamailio functions that do not exist in SIP Router, but alternatives are available to get more or less same behaviour.

TCP Connection Lifetime

  • registrar module in Kamailio 1.5 and earlier had support to set automatically the lifetime of the TCP connection for current processed SIP REGISTER message by defining tcp_persistent_flag module parameter and then by setting the flag before save() function was called.
  • In sip-router and Kamailio 3.0 tcp_persistent_flag parameter does not exist anymore. Similar functionality can be achieved by setting tcp_connection_lifetime core config parameter just a bit higher than max registration expire. The lifetime for a TCP connection is automatically extended when a message is going through. In case of hard/soft phones, the connection is closed by client side when they shut down.

Log levels

  • the logging in sip-router uses different values for each level. You can get the corresponding level by simple subtracting "1" from the value you used in kamailio. For example the INFO level in kamailio (3) is "2" in sip-router.

Module loading

  • The mpath statement is also available in sip-router, being an alias to loadpath parameter. In addition, you can omit the ".so" from each loadmodule statement, as this is automatically appended from the sip-router.

Branch Flags Operations

  • functions are implemented now by kex module. The parameters must be enclosed in double quotes and they can be pseudo-variables with integer values:

Script Flags Operations

  • functions are implemented now by kex module. The parameters must be enclosed in double quotes and they can be pseudo-variables with integer values:

Dst URI Operations

  • functions setdsturi(uri), resetdsturi() and isdsturiset() are implemented now by kex module. The syntax is the same:

TM Extensions

Core parameters

  • avp_aliases is a parameter of PV module

  • disable_dns_blacklist is replaced by dns_cache_negative_ttl

  • disable_dns_failover is replaced by use_dns_failover

By default, use_dns_failover is currently "off". Hopefully, the default can be changed to "on" in order to be compatible with Kamailio default.

Core Functions

  • append_branch() - fully Kamailio append_branch() function is now implemented by kex module and it is named km_append_branch(). See:

Script syntax

Test operator [...]

  • test operator […] is does not exist. Same operation is supported directly in conditional expressions.

Bit tests must be written in conditions without brackets [ and ], for example,

    if ($var(a) & 4)
        log("var a has third bit set\n");

Operator :=

  • := used in Kamailio for AVPs - delete all then add - is not available in SIP Router. Same functionality is given by assignment when providing index 'all' to the right AVP. See example:
   # Kamailio: $avp(abc) := 'xyz';
   $(avp(abc)[*]) = 'xyz';
   # Kamailio: $avp(abc) := null;
   $(avp(abc)[*]) = $null;

Module parameters

  • tm onreply_avp_mode does not exist

In SIP Router, AVPs that are set in request route are always visible in branch, failure, and onreply_route. In other words, SIP Router behaves like Kamailio when onreply_avp_mode is set to value 1.

  • tm fr_timer, fr_inv_timer, and contacts_avp AVP value syntax

In SIP Router, AVP value of tm module parameters fr_timer, fr_inv_timer, and contacts_avp is currently written without $avp(), for example, "i:705". This is to be fixed.

  • tm fr_timer, fr_inv_timer, wt_timer, delete_timer, and unix_tx_timeout units

In SIP Router, time value of the above parameters is given in milliseconds, whereas in Kamailio they are given in seconds (see tm timers for more details). In order to make migration easier, perhaps a new tm module parameter could be introduced to specify, in which units time values are given.

Module functions

  • t_relay() does not accept flags parameter

Module parameter "auto_inv_100" can be used to globally turn off gneration of provisional replies (default is 1 == "on"). It is also possible to dynamically control generation of provisional replies using function t_set_auto_inv_100().

t_relay() does not send a negative reply implicitly. Negative reply is auto-generated at the end of the script if no reply was explicitly sent from the script.

Core parameter "use_dns_failover" can be used to globally turn off DNS failover (default is "off").

  • t_relay() does not generate internally a negative reply. Negative reply is can always be generated explicitly from script. If not done, it is generated implicitly at the end of the script.
  • t_was_cancelled() is replaced by t_is_canceled().

Route blocks

  • error_route is not supported

Check request sanity at the beginning of script (see sanity module).

null keyword

null keyword is not present in SIP Router. Use pseudo-variable $null instead.

In addition, the operator defined can be used to check if a value is null or not.

if( ! defined $avp(x) ) {
   # the avp is null




Personal Tools