[OpenSER-Users] Handling nated clients using non-symmetric signaling

danish.samad at vocalseeds.com danish.samad at vocalseeds.com
Fri Aug 24 17:33:00 CEST 2007


Hi,

I am testing a dialer built on top of opal sip SDK with openser and I am
having a slight issue in call disconnections.
Basically the dialer does not use symmetric signaling: it uses different
ports for Registration and call control usually with an increment of 3. So
if I register with 6000 the Invite or 200 OK will be from 6003. Whenever a
nated client is detected in the script I enable setbflag 6 and 7 which
keeps sending OPTIONS packet after every 20 seconds.

Now when a dialer makes a call, using a different port from the
registration port, to a nated callee, the callee receives the packet on
the registration port but replies back from a new port which opens a new
port on the nat public interface.
I believe these public ports are only kept open for about 30 seconds at
most after which they are closed down by the nated machine. So if the
caller sends a bye request after 30 seconds it is relayed on this new port
(from which 200 ok was received) which has closed therefore the request
times out and the calle remains, incorrectly connected. If bye is sent
earlier, it is receive by the callee and the call terminates

If openser can somehow send the bye packet to the port used for
registration by the dialer, this will solve the problem. Is there some way
I can do this in the openser script. I am attaching an excerpt of my cfg
below for reference.

Looking for your support,

Regards,
Danish

debug=3

fork=yes

log_facility=LOG_LOCAL1

disable_dns_blacklist=true





listen=a.b.c.d:5060 # IP filtered

children=4

check_via=no

dns=no

rev_dns=no


alias="a.b.c.d:5060"



loadmodule "/usr/local/lib/openser/modules/mysql.so"

loadmodule "/usr/local/lib/openser/modules/sl.so"

loadmodule "/usr/local/lib/openser/modules/tm.so"

loadmodule "/usr/local/lib/openser/modules/rr.so"

loadmodule "/usr/local/lib/openser/modules/maxfwd.so"

loadmodule "/usr/local/lib/openser/modules/usrloc.so"

loadmodule "/usr/local/lib/openser/modules/textops.so"

loadmodule "/usr/local/lib/openser/modules/registrar.so"

loadmodule "/usr/local/lib/openser/modules/auth.so"

loadmodule "/usr/local/lib/openser/modules/auth_radius.so"

loadmodule "/usr/local/lib/openser/modules/uri_radius.so"

#loadmodule "/usr/local/lib/openser/modules/auth_db.so"

loadmodule "/usr/local/lib/openser/modules/uri.so"

loadmodule "/usr/local/lib/openser/modules/uri_db.so"

loadmodule "/usr/local/lib/openser/modules/nathelper.so"

loadmodule "/usr/local/lib/openser/modules/xlog.so"

loadmodule "/usr/local/lib/openser/modules/dispatcher.so"

loadmodule "/usr/local/lib/openser/modules/mi_fifo.so"



modparam("auth_radius|uri_radius", "radius_config",
"/usr/local/etc/radiusclient-ng/radiusclient.conf")

modparam("auth_radius", "service_type", 8)



modparam("mi_fifo", "fifo_name", "/tmp/openser_fifo")



modparam("uri_db|usrloc", "db_url",
"mysql://openser:openserrw@localhost/openser")

#modparam("auth_db", "calculate_ha1", yes)

#modparam("auth_db", "password_column", "password")



modparam("nathelper", "natping_interval", 20)

modparam("nathelper", "ping_nated_only", 1)

modparam("nathelper", "rtpproxy_sock", "udp:192.168.0.239:12345")

modparam("nathelper", "received_avp", "$avp(i:42)")

modparam("nathelper", "sipping_bflag", 7)

#modparam("nathelper", "sipping_bflag", 3)

modparam("nathelper", "sipping_from", "sip:pinger at mediaroute.org")



modparam("registrar", "received_avp", "$avp(i:42)")

#modparam("registrar", "nat_flag", 6)



modparam("usrloc", "db_mode", 2)

modparam("usrloc", "nat_bflag", 6)



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





# -- tm params --

modparam("tm","fr_timer",5)



route {



# -----------------------------------------------------------------

# Sanity Check Section

# -----------------------------------------------------------------

if (!mf_process_maxfwd_header("10")) {

 sl_send_reply("483", "Too Many Hops");

 return;

};



if (msg:len > max_len) {

 sl_send_reply("513", "Message Overflow");

 return;

};



# -----------------------------------------------------------------

# 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" || method=="BYE"
|| method=="INFO")) {



  if (nat_uac_test("2")) {

  	setflag(6);

 	force_rport();

 	fix_nated_contact();

  };

  if ((is_method("INVITE")) && (dst_ip!=a.b.c.d)) {

  	setflag(7);

  }

  if ((!search("^Content-Length:[ ]*0")) && (isflagset(6)||isflagset(7))){

	force_rtp_proxy("roc");

  }

 };

route(1);

return;

};



# -----------------------------------------------------------------

# Call Type Processing Section

# -----------------------------------------------------------------

if (!uri==myself) {

 route(4);

 route(1);

 return;

};



if (method=="CANCEL") {



 if (!t_check_trans()) {

    xlog("L_WARN","---CANCEL without matching transaction ... ignore and
discard.\n");

    return;

 }

 route(1);

 return;

} else if (method =="ACK"){

	route(1);

	return;

} else if (method=="INVITE") {

  route(3);

  return;

} else if (method=="REGISTER") {

  route(2);

  return;

};



	xlog("L_NOTICE","Danish: All checks failed forward, execute default
behaviour\n");

	lookup("aliases");

	if (!uri==myself) {

		route(4);

		route(1);

		return;

	};



	if (!lookup("location")) {

		xlog("L_NOTICE","Danish: lookup(location) failed\n");

		sl_send_reply("404", "User Not Found");

		return;

	};



	route(1);

}



route[1] {



# -----------------------------------------------------------------

# Default Message Handler

# -----------------------------------------------------------------



 t_on_reply("1");



 if (!t_relay()) {



	if ((method=="INVITE") && (isflagset(6)||isflagset(7))) {

		unforce_rtp_proxy();

	};

	sl_reply_error();

 };

}



route[2] {



# -----------------------------------------------------------------

# REGISTER Message Handler

# ----------------------------------------------------------------



	xlog("L_NOTICE"," Register message IPsrcaddr [$si], RecvdIPaddr[$Ri]\n");

	if (!search("^Contact:[ ]*\*") && nat_uac_test("2")) {

		setflag(6);

		setbflag(6);

		# if you want OPTIONS natpings uncomment next

		setbflag(7);

		fix_nated_register();

		force_rport();

	};



	sl_send_reply("100", "Trying");

	if (!radius_www_authorize("a.b.c.d")) {

		www_challenge("a.b.c.d", "1");

	};

	consume_credentials();



	if (!save("location")) {

		sl_reply_error();

	};



}



route[3] {



# -----------------------------------------------------------------

# INVITE Message Handler

# -----------------------------------------------------------------





	xlog("L_NOTICE","Danish: Entering route[3]\n");



	if (nat_uac_test("2")) {

		setflag(6);

		force_rport();

	}



	if (to_uri=~"^(sip:)?[ ]*[0-9]+.*")

	{

            # PSTN call logic omitted

	};


	xlog("L_NOTICE","to_number is alphanumeric therefore treat as IP-IP call
\n");



	lookup("aliases");



	if (!lookup("location")) {

		xlog("L_NOTICE","checking if user exists in database\n");

		if (radius_does_uri_exist()) {

			xlog("L_NOTICE"," user currently not registered\n");

	                sl_send_reply("480", "Temporarily Unavailable");

        	        return;

             	};

		sl_send_reply("404", "User Not Found");

		return;

	};

	route(4);

	route(1);



}



route[4] {



# -----------------------------------------------------------------

# NAT Traversal Section

# -----------------------------------------------------------------



	xlog("L_NOTICE","Danish: Entering route[4]\n");

	if ((isflagset(6))|| (isflagset(7))) {



		force_rport();

		fix_nated_contact();

		force_rtp_proxy("roc");

	}



}





onreply_route[1] {



	xlog("L_NOTICE","Danish: Entering on_reply_route[1]\n");

	xlog("L_NOTICE","Danish on_reply_route[1]: Processing reply status
[$rs]\n");



        if ((isflagset(6)||isflagset(7)) &&
(status=~"(180)|(183)|2[0-9][0-9]")) {



	 	if (!search("^Content-Length:[ ]*0")) {

			force_rtp_proxy("roc");

		};

	};



	if (nat_uac_test("1")) {

		fix_nated_contact();

	};

}










More information about the Users mailing list