[Serusers] Ack and Bye lost (ser+rtpproxy+nathelper)

gao gao1028 at 21cn.com
Mon Jul 18 15:55:35 CEST 2005


Hi all:
      I use ser+rtpproxy+nathelper to run as a outbound proxy.But the UAs can't receive ACK or BYE from each other before a same NAT. What's wrong with this config file?  Can anybody here help me?

#
# $Id: ser.cfg,v 1.24 2003/11/11 15:32:36 andrei Exp $
#
# simple quick-start config script
#

# ----------- global configuration parameters ------------------------

#debug=3         # debug level (cmd line: -dddddddddd)
#fork=yes
#log_stderror=no # (cmd line: -E)

/* Uncomment these lines to enter debugging mode 
*/
#log_stderror=yes
#debug=4
debug =3
fork=yes
log_stderror=yes 
check_via=no # (cmd. line: -v)
dns=no           # (cmd. line: -r)
rev_dns=no      # (cmd. line: -R)
port=5070
listen="222.44.33.59"
children=4
fifo="/tmp/ser_fifo"

# ------------------ module loading ----------------------------------


loadmodule "/home/ser-0.9.3/modules/sl/sl.so"
loadmodule "/home/ser-0.9.3/modules/tm/tm.so"
loadmodule "/home/ser-0.9.3/modules/rr/rr.so"
loadmodule "/home/ser-0.9.3/modules/maxfwd/maxfwd.so"
loadmodule "/home/ser-0.9.3/modules/usrloc/usrloc.so"
loadmodule "/home/ser-0.9.3/modules/textops/textops.so"
loadmodule "/home/ser-0.9.3/modules/registrar/registrar.so"
loadmodule "/home/ser-0.9.3/modules/nathelper/nathelper.so"
loadmodule "/home/ser-0.9.3/modules/uri/uri.so"

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

# -- usrloc params --

modparam("registrar", "nat_flag", 6)
modparam("usrloc", "db_mode",   0)

modparam("nathelper", "natping_interval", 30) # Ping interval 30 s
modparam("nathelper", "ping_nated_only", 1)   # Ping only clients behind NAT
modparam("nathelper", "rtpproxy_sock", "/var/run/rtpproxy.sock")

modparam("rr", "enable_full_lr", 1)

# -------------------------  request routing logic -------------------

route{

        # -----------------------------------------------------------------
        # Sanity Check Section
        # -----------------------------------------------------------------
        if (!mf_process_maxfwd_header("10")) {
                sl_send_reply("483", "Too Many Hops");
                break;
        };

        if (msg:len > max_len) {
                sl_send_reply("513", "Message Overflow");
                break;
        };
        #---------------
  if (! search("^Record-Route:"))
   {
   append_hf("Alex-hint: NAThelper\r\n");
   fix_nated_contact();
   if(method == "REGISTER")
   {
    fix_nated_register();
    save_noreply("location");
   };

      if (method == "INVITE") 
      {
       append_hf("Alex-hint: SDP rewritten\r\n");
       force_rtp_proxy();
            };
   force_rport();   
   setflag(6);
         };
        #---------------
        # -----------------------------------------------------------------
        # Record Route Section
        # -----------------------------------------------------------------
  if(method != "REGISTER")
  {
   record_route();
  };

        if (method=="BYE" || method=="CANCEL") {
                unforce_rtp_proxy();
        } 

        # -----------------------------------------------------------------
        # Loose Route Section
        # -----------------------------------------------------------------
        if (loose_route()) {

                if (has_totag() && (method=="INVITE" || method=="ACK")) {
                        if (nat_uac_test("19")) {
                                setflag(6);
                                force_rport();
                        };
                    force_rtp_proxy("l");
     append_hf("Alex-hint: Loose Route\r\n");
                };

                route(1);
                break;
        };

        # -----------------------------------------------------------------
        # Call Type Processing Section
        # -----------------------------------------------------------------

        if (uri!=myself) {
                route(1);
                break;
        };

        if (uri==myself) {

                if (method=="CANCEL") {
                        route(3);
                        break;
                } else if (method=="INVITE") {
               route(3);
                        break;
                } else  if (method=="REGISTER") {
                        route(2);
                        break;
                } else if (method=="ACK") {
                        route(3);
                        break;
                } else if (method=="BYE") {
                        route(3);
                        break;
                };

    lookup("aliases");
                if (uri!=myself) {
                        route(1);
                        break;
                };

    if (!lookup("location"))
    {
     sl_send_reply("404", "User Not Found,aaa");
     break;
                };
        };

        route(1);
}

route[1] {

        # -----------------------------------------------------------------
        # Default Message Handler
        # -----------------------------------------------------------------

        t_on_reply("1");

        if (!t_relay()) {
                if (method=="INVITE" && isflagset(6)) {
                  unforce_rtp_proxy();
                };
                sl_reply_error();
        };

}

route[2] {

        # -----------------------------------------------------------------
        # REGISTER Message Handler
        # ----------------------------------------------------------------

        if (!search("^Contact:\ +\*") && nat_uac_test("19")) {
                setflag(6);
                fix_nated_register();
                force_rport();
        };

        sl_send_reply("100", "Trying");

  if(!save("location"))
  {
      sl_reply_error();
  } else append_hf("Alex-hint: save location\r\n");
}

route[3] {

        # -----------------------------------------------------------------
        # CANCEL and INVITE Message Handler
        # -----------------------------------------------------------------

        if (nat_uac_test("19")) {
                setflag(6);
        };

        if (uri!=myself) {
                route(1);
                break;
        };

        if (method == "INVITE" && !lookup("location")) {
                sl_send_reply("404", "User Not Found haha");
                break;
        };

        if (isflagset(6)) {
                force_rport();
                fix_nated_contact();
                force_rtp_proxy();
        };

        t_on_reply("1");

        if (!t_relay()) {
                if(isflagset(6)) {
                        unforce_rtp_proxy();
               }
               sl_reply_error();
        };
}

onreply_route[1] {

 if (isflagset(6) || status=~"(180)|(183)|2[0-9][0-9]") {
  fix_nated_contact();
  if (!search("^Content-Length:\ +0")) {
   force_rtp_proxy();

   append_hf("NAT: 1\r\n");
  };
 };
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20050718/ace93803/attachment.htm>


More information about the sr-users mailing list