[Kamailio-Users] Kamailio and RTPProxy

Bruce McAlister bruce.mcalister at blueface.ie
Mon Dec 14 13:24:38 CET 2009


Hi All,

I am trying to setup kamailio 1.5.3-notls for use with rtpproxy 1.2.1. I
have a partially working setup, however, when I have a softphone
configured behind nat it appears that rtpproxy is using the internal ip
(prior to nat) to setup the sdp ports.

I have rtpproxy configured in bridge mode as follows:

rtpproxy -f -F -l public_ip/internal_ip -s udp:*:11211

I have kamailio's nathelper module setup as follows:

modparam("nathelper", "rtpproxy_sock", "udp:internal_ip:11211")

I then use a softphone (x-lite) behind a nat firewall (ip =
192.168.11.2) to establish a call, and the log of rtpproxy is as follows:

INFO:handle_command: new session
ZmRkNjRlNjM0NzExZjQ5MWUxYjllOTFhZWFmZGZkMjY., tag 8330585e;1 requested,
type strong
INFO:handle_command: new session on a port 52572 created, tag 8330585e;1
INFO:handle_command: pre-filling caller's address with 192.168.11.2:35498
INFO:handle_command: lookup on ports 52572/40380, session timer restarted
INFO:handle_command: pre-filling callee's address with internal_ip:11250
INFO:handle_delete: forcefully deleting session 1 on ports 52572/40380
INFO:remove_session: RTP stats: 906 in from callee, 0 in from caller,
906 relayed, 0 dropped
INFO:remove_session: RTCP stats: 3 in from callee, 0 in from caller, 3
relayed, 0 dropped
INFO:remove_session: session on ports 52572/40380 is cleaned up

In the log above it looks like rtpproxy is using 192.168.11.2:35498 as
the remote ip/port combination to contact for the sdp session of the
x-lite softphone. I would have thought that it would use the IP address
that initial request was received from to establish this connection (via
the fix_nated_contact() function).

My route logic in kamailio is a slightly modified default configuration
that is installed with kamailio :

route{

	.
	.
	.

        # NAT detection
        route(4);

	.
	.
	.

	route(1);
}

route[1]{
     if (check_route_param("nat=yes")) {
             setbflag(6);
     }
     # if (isflagset(5) || isbflagset(6)) {
             route(5);
     # }

        /* example how to enable some additional event routes */
        if (is_method("INVITE")) {
                #t_on_branch("1");
                t_on_reply("1");
                t_on_failure("1");
        }

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

route[4]{
     force_rport();
     if (nat_uac_test("19")) {
             if (method=="REGISTER") {
                     fix_nated_register();
             } else {
                     fix_nated_contact();
             }
             setflag(5);
     }
        return;
}

Would the "fix_nated_contact" function in the "nat detection" route not
fix the contact before passing over the request to rtpproxy to establish
the sdp session?

route[5] {
     if (is_method("BYE")) {
             unforce_rtp_proxy();
     } else if (is_method("INVITE")){
             # force_rtp_proxy();
             if(src_ip==internal_ip_of_media_server)
                force_rtp_proxy("ocfaei");
             else
                force_rtp_proxy("ocfaie");
     }
     if (!has_totag()) add_rr_param(";nat=yes");
        return;
}

onreply_route[1] {
        xdbg("incoming reply\n");

     # if ((isflagset(5) || isbflagset(6)) &&
status=~"(183)|(2[0-9][0-9])") {
     if (status=~"(183)|(2[0-9][0-9])") {
             # force_rtp_proxy();
             if(src_ip == internal_ip_of_media_server)
                force_rtp_proxy("ocfaei");
             else
                force_rtp_proxy("ocfaie");
     }
     if (isbflagset(6)) {
             fix_nated_contact();
     }
}

failure_route[1] {
     if (is_method("INVITE")
                     && (isbflagset(6) || isflagset(5))) {
             unforce_rtp_proxy();
     }

        if (t_was_cancelled()) {
                exit;
        }
}

Any pointers would be greatly appreciated.

Thanks
Bruce




More information about the sr-users mailing list