Thank you very much Daniel.

 

I have adjusted the parameter for nat_uac_test() to 128 without success. 

 

Then I disable NATDETECT route and only load modules nathelper and rtpproxy 
and set their parameters to

modparam("nathelper", "natping_interval", 10)

modparam("nathelper", "ping_nated_only", 0)

modparam("nathelper", "sipping_bflag", FLB_NATSIPPING)

modparam("nathelper", "sipping_method", "OPTIONS")

modparam("nathelper", "sipping_from", "sip:pinger@192.168.1.44")

 

modparam("nathelper|registrar", "received_avp", "$avp(RECEIVED)")

 

and

 

route[REGISTRAR] {

      if (is_method("REGISTER")) {

               setbflag(FLB_NATSIPPING);

               if (!save("location"))

               sl_reply_error();

               exit;

}

}

 

 

 

cflag after registration is 128 so in my opinion FLB_NATSIPPIG flag is set 
but OPTIONS pings on client's side.

 

kamailio.cfg please you find attached

 

Thank you

 

Regards

 

Petr


---------- Původní zpráva ----------
Od: Daniel-Constantin Mierla <mico...@gmail.com>
Komu: Kamailio (SER) - Users Mailing List <sr-users@lists.sip-router.org>
Datum: 10. 11. 2014 9:22:38
Předmět: Re: [SR-Users] beginner's problem with sipping

"
Hello,

if you are in a private network, you need to adjust the parameter for nat_
uac_test() function to ignore private addresses in check tests -- see the 
readme of nathelper module.

Cheers,
Daniel


On 09/11/14 19:33, Petr Wozniak wrote:

" 
Dear sr-users,

 
 
I am beginner and apologize for bothering you with such a trivial problem.

I would like to test sip UDP and TCP keepalive pinging. Kamailio and client 
 are on the same network (192.168.1.44 and 192.168.1.20) that implies not 
behind NAT. So in kamailio.cfg I have set
 
 
 
modparam("nathelper", "ping_nated_only", 0)

 
 
My simple kamailio.cfg please you find enclosed.

>From logfiles on client's side implies that neither UDP nor OPTIONS pings 
are sending from kamailio.
If somebody would be so kind to help me I will be very glad.

 
 
Thank you in advance

 
 
Regards

 
 
Petr



_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a href='mailto:sr-users@lists.sip-router.org'>sr-users@lists.sip-router.org</a>
<a 
href='http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users'>http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a>

" 

-- 
Daniel-Constantin Mierla
<a href='http://twitter.com/#!/miconda'>http://twitter.com/#!/miconda</a> - <a 
href='http://www.linkedin.com/in/miconda'>http://www.linkedin.com/in/miconda</a>
Kamailio Advanced Training, Nov 24-27, Berlin - <a 
href='http://www.asipto.com'>http://www.asipto.com</a>

_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users";
#!KAMAILIO
#
#!define WITH_MYSQL
#!define WITH_AUTH
#!define WITH_USRLOCDB


####### Defined Values #########

# *** Value defines - IDs used later in config
#!ifdef WITH_MYSQL
# - database URL - used to connect to database server by modules such
#       as: auth_db, acc, usrloc, a.s.o.
#!ifndef DBURL
#!define DBURL "mysql://kamailio:kamailiorw@localhost/kamailio"
#!endif
#!endif
#!define MULTIDOMAIN 0

# - flags
#   FLT_ - per transaction (message) flags
#       FLB_ - per branch flags
#!define FLT_ACC 1
#!define FLT_ACCMISSED 2
#!define FLT_ACCFAILED 3
#!define FLT_NATS 5

#!define FLB_NATB 6
#!define FLB_NATSIPPING 7

####### Global Parameters #########

### LOG Levels: 3=DBG, 2=INFO, 1=NOTICE, 0=WARN, -1=ERR
#!ifdef WITH_DEBUG
debug=4
log_stderror=yes
#!else
debug=2
log_stderror=no
#!endif

memdbg=5
memlog=5

log_facility=LOG_LOCAL0

fork=yes
children=4

alias="192.168.1.44"

listen=tcp:192.168.1.44:5060
listen=tcp:127.0.0.1:5060

#!ifdef WITH_TLS
enable_tls=yes
#!endif

tcp_connection_lifetime=3605

####### Modules Section ########


mpath="/usr/lib/x86_64-linux-gnu/kamailio/modules/"

#!ifdef WITH_MYSQL
loadmodule "db_mysql.so"
#!endif

loadmodule "mi_fifo.so"
loadmodule "kex.so"
loadmodule "corex.so"
loadmodule "tm.so"
loadmodule "tmx.so"
loadmodule "sl.so"
loadmodule "rr.so"
loadmodule "pv.so"
loadmodule "maxfwd.so"
loadmodule "usrloc.so"
loadmodule "registrar.so"
loadmodule "textops.so"
loadmodule "siputils.so"
loadmodule "xlog.so"
loadmodule "sanity.so"
loadmodule "ctl.so"
loadmodule "cfg_rpc.so"
loadmodule "mi_rpc.so"
loadmodule "acc.so"

#!ifdef WITH_AUTH
loadmodule "auth.so"
loadmodule "auth_db.so"
#!endif


loadmodule "nathelper.so"
loadmodule "rtpproxy.so"


#!ifdef WITH_TLS
loadmodule "tls.so"
#!endif

#!ifdef WITH_DEBUG
loadmodule "debugger.so"
#!endif

# ----------------- setting module-specific parameters ---------------

# ----- mi_fifo params -----
modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")

# ----- tm params -----
# auto-discard branches from previous serial forking leg
modparam("tm", "failure_reply_mode", 3)
# default retransmission timeout: 30sec
modparam("tm", "fr_timer", 30000)
# default invite retransmission timeout after 1xx: 120sec
modparam("tm", "fr_inv_timer", 120000)

# ----- rr params -----
# add value to ;lr param to cope with most of the UAs
modparam("rr", "enable_full_lr", 1)
# do not append from tag to the RR (no need for this script)
modparam("rr", "append_fromtag", 0)

# ----- registrar params -----
modparam("registrar", "method_filtering", 1)
/* uncomment the next line to disable parallel forking via location */
# modparam("registrar", "append_branches", 0)
/* uncomment the next line not to allow more than 10 contacts per AOR */
#modparam("registrar", "max_contacts", 10)
# max value for expires of registrations
modparam("registrar", "max_expires", 60)
# set it to 1 to enable GRUU
modparam("registrar", "gruu_enabled", 0)

# ----- usrloc params -----
/* enable DB persistency for location entries */
#!ifdef WITH_USRLOCDB
modparam("usrloc", "db_url", DBURL)
modparam("usrloc", "db_mode", 2)
modparam("usrloc", "use_domain", MULTIDOMAIN)
#!endif

# ----- auth_db params -----
#!ifdef WITH_AUTH
modparam("auth_db", "db_url", DBURL)
modparam("auth_db", "calculate_ha1", yes)
modparam("auth_db", "password_column", "password")
modparam("auth_db", "load_credentials", "")
modparam("auth_db", "use_domain", MULTIDOMAIN)

#ifdef WITH_NAT
# ----- rtpproxy params -----
modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:7722")

# ----- nathelper params -----
modparam("nathelper", "natping_interval", 10)

modparam("nathelper", "ping_nated_only", 0)
modparam("nathelper", "sipping_bflag", FLB_NATSIPPING)
modparam("nathelper", "sipping_method", "OPTIONS")
modparam("nathelper", "sipping_from", "sip:pinger@192.168.1.44")

# params needed for NAT traversal in other modules
modparam("nathelper|registrar", "received_avp", "$avp(RECEIVED)")
modparam("usrloc", "nat_bflag", FLB_NATB)
#endif


#!ifdef WITH_TLS
# ----- tls params -----
modparam("tls", "config", "/usr/local/etc/kamailio/tls.cfg")
#!endif

#!ifdef WITH_DEBUG
# ----- debugger params -----
modparam("debugger", "cfgtrace", 1)
#!endif

####### Routing Logic ########


# Main SIP request routing logic
# - processing of any incoming SIP request starts with this route
# - note: this is the same as route { ... }
request_route {

        # per request initial checks
        route(REQINIT);

        # NAT detection
#       route(NATDETECT);

        # CANCEL processing
        if (is_method("CANCEL")) {
                if (t_check_trans()) {
                        route(RELAY);
                }
                exit;
        }

        # handle requests within SIP dialogs
        route(WITHINDLG);

        ### only initial requests (no To tag)

        t_check_trans();

        # authentication
        route(AUTH);

        # record routing for dialog forming requests (in case they are routed)
        # - remove preloaded route headers
        remove_hf("Route");
        if (is_method("INVITE|SUBSCRIBE"))
                record_route();

        # account only INVITEs
        if (is_method("INVITE")) {
                setflag(FLT_ACC); # do accounting
        }

        ### requests for my local domains

        # handle registrations
        route(REGISTRAR);

        if ($rU==$null) {
                # request with no Username in RURI
                sl_send_reply("484","Address Incomplete");
                exit;
        }

        # user location service
        route(LOCATION);
}


route[RELAY] {
        # enable additional event routes for forwarded requests
        # - serial forking, RTP relaying handling, a.s.o.
        if (is_method("INVITE|BYE|SUBSCRIBE|UPDATE")) {
                if(!t_is_set("branch_route")) t_on_branch("MANAGE_BRANCH");
        }
        if (is_method("INVITE|SUBSCRIBE|UPDATE")) {
                if(!t_is_set("onreply_route")) t_on_reply("MANAGE_REPLY");
        }
        if (is_method("INVITE")) {
                if(!t_is_set("failure_route")) t_on_failure("MANAGE_FAILURE");
        }

        if (!t_relay()) {
                sl_reply_error();
        }
        exit;
}

# Per SIP request initial checks
route[REQINIT] {


        if (!mf_process_maxfwd_header("10")) {
                sl_send_reply("483","Too Many Hops");
                exit;
        }

        if(!sanity_check("1511", "7")) {
                xlog("Malformed SIP message from $si:$sp\n");
                exit;
        }
}

# Handle requests within SIP dialogs
route[WITHINDLG] {
        if (has_totag()) {
                # sequential request withing a dialog should
                # take the path determined by record-routing
                if (loose_route()) {
                        route(DLGURI);
                        if (is_method("BYE")) {
                                setflag(FLT_ACC); # do accounting ...
                                setflag(FLT_ACCFAILED); # ... even if the 
transaction fails
                        }
                        else if ( is_method("ACK") ) {
                                # ACK is forwarded statelessy
                                route(NATMANAGE);
                        }
                        else if ( is_method("NOTIFY") ) {
                                # Add Record-Route for in-dialog NOTIFY as per 
RFC 6665.
                                record_route();
                        }
                        route(RELAY);
                } else {
                        if ( is_method("ACK") ) {
                                if ( t_check_trans() ) {
                                        # no loose-route, but stateful ACK;
                                        # must be an ACK after a 487
                                        # or e.g. 404 from upstream server
                                        route(RELAY);
                                        exit;
                                } else {
                                        # ACK without matching transaction ... 
ignore and discard
                                        exit;
                                }
                        }
                        sl_send_reply("404","Not here");
                }
                exit;
        }
}

route[REGISTRAR] {
        if (is_method("REGISTER")) {
        setbflag(FLB_NATSIPPING);

                if (!save("location"))
                        sl_reply_error();

                exit;
        }
}

# USER location service
route[LOCATION] {
        if (!lookup("location")) {
                $var(rc) = $rc;
                t_newtran();
                switch ($var(rc)) {
                        case -1:
                        case -3:
                                send_reply("404", "Not Found");
                                exit;
                        case -2:
                                send_reply("405", "Method Not Allowed");
                                exit;
                }
        }

        # when routing via usrloc, log the missed calls also
        if (is_method("INVITE")) {
                setflag(FLT_ACCMISSED);
        }

        route(RELAY);
        exit;
}


# Authentication route
route[AUTH] {
#!ifdef WITH_AUTH

        if (is_method("REGISTER") || from_uri==myself) {
                # authenticate requests
                if (!auth_check("$fd", "subscriber", "1")) {
                        auth_challenge("$fd", "0");
                        exit;
                }
                # user authenticated - remove auth header
                if(!is_method("REGISTER|PUBLISH"))
                        consume_credentials();
        }
        # if caller is not local subscriber, then check if it calls
        # a local destination, otherwise deny, not an open relay here
        if (from_uri!=myself && uri!=myself) {
                sl_send_reply("403","Not relaying");
                exit;
        }

#!endif
        return;
}

# Caller NAT detection route
route[NATDETECT] {
#!ifdef WITH_NAT
        force_rport();
        if (nat_uac_test("128")) {
                if (is_method("REGISTER")) {
                        fix_nated_register();
                } else {
                        add_contact_alias();
                }
                setflag(FLT_NATS);
        }
#!endif
        return;
}

# RTPProxy control
route[NATMANAGE] {
#!ifdef WITH_NAT
        if (is_request()) {
                if(has_totag()) {
                        if(check_route_param("nat=yes")) {
                                setbflag(FLB_NATB);
                        }
                }
        }
        if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB)))
                return;

        rtpproxy_manage("co");

        if (is_request()) {
                if (!has_totag()) {
                        if(t_is_branch_route()) {
                                add_rr_param(";nat=yes");
                        }
                }
        }
        if (is_reply()) {
                if(isbflagset(FLB_NATB)) {
                        add_contact_alias();
                }
        }
#!endif
        return;
}

# URI update for dialog requests
route[DLGURI] {
#!ifdef WITH_NAT
        if(!isdsturiset()) {
                handle_ruri_alias();
        }
#!endif
        return;
}


_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

Reply via email to