Hi All,
I have SER work together with MediaProxy and two UAs;
UA1 is NATED whereas UA2 has public IP.
I have something like this to process the INVITE
if (client_nat_test("3")) { setflag(4); }; if (isflagset(4)) { force_rport(); fix_contact(); use_media_proxy(); };
t_on_reply("1");
and on the reply_route, I have
if (client_nat_test("1")) { setflag(4); };
if (isflagset(4) && status=~"(180) || (183) || 2[0-9][0-9]") { if(search("^Content-Type: .*$")) { fix_contact(); use_media_proxy(); } };
Now, if UA1 (nated) calls UA2, it is OK ( mediaproxy is properly setup and both side can hear each other. The client_nat_test() is met and flag4 is set which caused both the invite and the on_reply to use_media_proxy).
If UA2(public) calls UA1 (nated), problem arises, UA2 can hear UA1 but not the reverse. The client_nat_test("3") is not met and thus flag4 not set. On the reply_route, although client_nat_test("1") is met, flag4 set and use_media_proxy() is executed, it return
error: use_media_proxy(): empty response from mediaproxy ERROR: on_reply processing failed
To temporary work around this problem, I forcefully set flag4 on and thus all calls route through the mediaproxy ( which is expensive in bandwidth usage).
Is there any better way to solve this?
Any suggestion?
Has anybody already looks into this and has a solution?
Thanks for any help available.
Regards,
TC Chan
Hi Tchan,
I have the same problem. So i used this "ser.cfg" (see below) to be sure that if UA1 can call UA2 without any problem (and the opposite). Like i don't know how to avoid the use of media proxy for private use only. Is there a way to use media proxy ONLY when one of the two UA comes from Internet ? How NatHelper / MediaProxy modules know which ip range concerns private network and public network ? With this config file, all RTP sessions used the media proxy module...
Thanks in advance, Chris.
' ------------------------- SER.CFG -------------------------
alias="test.ser" listen=172.20.255.192
check_via=no # (cmd. line: -v) dns=no # (cmd. line: -r) rev_dns=no # (cmd. line: -R) fifo="/tmp/ser_fifo"
# ------------------ module loading ----------------------------------
loadmodule "/usr/local/lib/ser/modules/sl.so" loadmodule "/usr/local/lib/ser/modules/tm.so" loadmodule "/usr/local/lib/ser/modules/rr.so" loadmodule "/usr/local/lib/ser/modules/maxfwd.so" loadmodule "/usr/local/lib/ser/modules/usrloc.so" loadmodule "/usr/local/lib/ser/modules/registrar.so" loadmodule "/usr/local/lib/ser/modules/textops.so"
loadmodule "/usr/local/lib/ser/modules/mysql.so" loadmodule "/usr/local/lib/ser/modules/auth.so" loadmodule "/usr/local/lib/ser/modules/auth_db.so"
loadmodule "/usr/local/lib/ser/modules/uri.so" loadmodule "/usr/local/lib/ser/modules/uri_db.so" loadmodule "/usr/local/lib/ser/modules/domain.so" loadmodule "/usr/local/lib/ser/modules/mediaproxy.so" loadmodule "/usr/local/lib/ser/modules/nathelper.so"
# ----------------- setting module-specific parameters --------------- modparam("usrloc", "db_mode", 2)
modparam("auth_db", "calculate_ha1", 1) modparam("auth_db", "password_column", "password")
modparam("rr", "enable_full_lr", 1)
modparam("registrar", "nat_flag", 6)
modparam("nathelper", "rtpproxy_disable", 1) modparam("nathelper", "natping_interval", 0)
modparam("mediaproxy", "natping_interval", 30) modparam("mediaproxy", "mediaproxy_socket", "/var/run/mediaproxy.sock") modparam("mediaproxy", "sip_asymmetrics", "/usr/local/etc/ser/asymmetrics/sip-clients") modparam("mediaproxy", "rtp_asymmetrics", "/usr/local/etc/ser/asymmetrics/rtp-clients")
# ------------------------- request routing logic -------------------
route { 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 (method=="INVITE" && client_nat_test("3") ) { record_route_preset("172.20.255.192:5060;nat=yes"); } else if (method!="REGISTER") { record_route(); };
if (method=="BYE" || method=="CANCEL") { end_media_session(); };
if (loose_route()) { if (has_totag() && (method=="INVITE" || method=="ACK")) { if (client_nat_test("3") || search("^Route:.*;nat=yes")) { setflag(6); use_media_proxy();² }; };
route(1); break; };
if (uri!=myself) { route(4); route(1); break; };
if (method=="CANCEL") { route(1); break; } else if (method=="INVITE") { route(3); break; } else if (method=="REGISTER") { route(2); break; };
lookup("aliases"); if (uri!=myself) { route(4); route(1); break; };
if (!lookup("location")) { sl_send_reply("404", "User Not Found"); break; };
route(1); }
route[1] { t_on_reply("1");
if (!t_relay()) { if (method=="INVITE" || method=="ACK") { end_media_session(); };
sl_reply_error(); }; }
route[2] { sl_send_reply("100", "Trying");
if (!search("^Contact:[ ]**") && client_nat_test("7")) { setflag(6); fix_nated_register(); force_rport(); };
if (!www_authorize("","subscriber")) { www_challenge("","0"); break; };
if (!check_to()) { sl_send_reply("401", "Unauthorized"); break; };
consume_credentials();
if (!save("location")) { sl_reply_error(); }; }
route[3] { if (!proxy_authorize("","subscriber")) { proxy_challenge("","0"); break; } else if (!check_from()) { sl_send_reply("403", "Use From=ID"); break; };
consume_credentials();
if (client_nat_test("3")) { setflag(7); force_rport(); fix_nated_contact(); };
lookup("aliases"); if (uri!=myself) { route(4); route(1); break; };
if (!lookup("location")) { sl_send_reply("404", "User Not Found"); break; };
route(4); route(1); }
route[4] { if (isflagset(6) || isflagset(7)) { use_media_proxy(); }; }
onreply_route[1] { if ((isflagset(6) || isflagset(7)) && (status=~"(180)|(183)|2[0-9][0-9]")) { if (!search("^Content-Length:[ ]*0")) { use_media_proxy(); }; }; if (client_nat_test("1")) { fix_nated_contact(); }; }
I suggest you look at the onsip.org mediaproxy file. It seems that you don't use the registered NAT flag in your tests (4). In order to save and retrieve NAT info on the callee, you need to test for the flag that is defined like this: modparam("registrar", "nat_flag", 6) g-)
----- Original Message ----- From: "tcchan" tikchoong.chan@redtone.com To: serusers@lists.iptel.org Sent: Friday, October 28, 2005 8:58 AM Subject: [Serusers] When to use MediaProxy
Hi All,
I have SER work together with MediaProxy and two UAs;
UA1 is NATED whereas UA2 has public IP.
I have something like this to process the INVITE
if (client_nat_test("3")) { setflag(4); }; if (isflagset(4)) { force_rport(); fix_contact(); use_media_proxy(); }; t_on_reply("1");
and on the reply_route, I have
if (client_nat_test("1")) { setflag(4); }; if (isflagset(4) && status=~"(180) || (183) || 2[0-9][0-9]") { if(search("^Content-Type: .*$")) {
fix_contact(); use_media_proxy(); } };
Now, if UA1 (nated) calls UA2, it is OK ( mediaproxy is properly setup and both side can hear each other. The client_nat_test() is met and flag4 is set which caused both the invite and the on_reply to use_media_proxy).
If UA2(public) calls UA1 (nated), problem arises, UA2 can hear UA1 but not the reverse. The client_nat_test("3") is not met and thus flag4 not set. On the reply_route, although client_nat_test("1") is met, flag4 set and use_media_proxy() is executed, it return
error: use_media_proxy(): empty response from mediaproxy ERROR: on_reply processing failed
To temporary work around this problem, I forcefully set flag4 on and thus all calls route through the mediaproxy ( which is expensive in bandwidth usage).
Is there any better way to solve this?
Any suggestion?
Has anybody already looks into this and has a solution?
Thanks for any help available.
Regards,
TC Chan
Serusers mailing list serusers@lists.iptel.org http://lists.iptel.org/mailman/listinfo/serusers