[OpenSIPS-Users] rtpproxy from external to internal network

Bogdan-Andrei Iancu bogdan at voice-system.ro
Tue Aug 18 10:57:45 CEST 2009


Hi Ghaith,

when you use RTPproxy in bridging mode, you need to explicitly indicate 
(when calling force_rtp_proxy() ) what interface to use - see the "i" 
and "e" flags :
       
http://www.opensips.org/html/docs/modules/1.5.x/nathelper.html#id271362

You need to pass these flags when you do force_rtp_proxy() for request 
and reply. So in your script you need do detect (based on signalling 
interfaces) what is the call direction and accordingly set the flags ( i 
-> e or e -> i).

Regards,
Bogdan

Ghaith ALKAYYEM wrote:
> Hello,
>
> I'm trying to test rtpproxy with nathelper module to forward RTP 
> traffic between two networks, my architecture is as follow:
>
>
> -------------------        
> --------------------------------------        --------------------
> UAC (172.23.1.22) |        |                                    
> |        | UAC (172.1.1.21) |
>                   |=======>| 172.23.1.20 (OpenSIPS) 172.1.1.166 
> |=======>|                  |
> Internal Network  |        |                                    
> |        | External Network |
> -------------------        
> --------------------------------------        --------------------
>
>
>
>
> I run rtpproxy:
> rtpproxy -fF -l 172.1.1.166/172.23.1.20
> Then I tried to establish a call from internal net (172.23.1.22) to 
> external net(172.1.1.21) and the connection established succussfully 
> with perfect RTP relay through (172.1.1.166) interface.
>
> But when I tried to call from external network towards internal, the 
> RTP traffic relay didn't work?.
>
> Following is the part related to nathelper and routing logic in my 
> configuration file:
>
>
>
> loadmodule "nathelper.so"
>
> modparam("nathelper", "natping_interval", 30)
> modparam("nathelper", "ping_nated_only", 1)
> modparam("nathelper", "rtpproxy_sock", "unix:/var/run/rtpproxy.sock")
> modparam("nathelper", "received_avp", "$avp(i:42)")
> modparam("registrar", "received_avp", "$avp(i:42)")
>
> modparam("usrloc", "nat_bflag", 6)
>
> modparam("registrar", "method_filtering", 1)
>
> mhomed=1
>
> route {
>
>   # -----------------------------------------------------------------
>   # Sanity Check Section
>   # -----------------------------------------------------------------
>   if (!mf_process_maxfwd_header("10")) {
>     sl_send_reply("483", "Too Many Hops");
>     #break;
>     return();
>   };
>
>   if (msg:len > max_len) {
>     sl_send_reply("513", "Message Overflow");
>     #break;
>     return();
>   };
>
>   # -----------------------------------------------------------------
>   # Record Route Section
>   # -----------------------------------------------------------------
>   if (method!="REGISTER") {
>     record_route();
>   };
>
>   if (method=="BYE" || method=="CANCEL") {
>     unforce_rtp_proxy();
>   }
>
>   # -----------------------------------------------------------------
>   # Loose Route Section
>   # -----------------------------------------------------------------
>
>   if (loose_route()) {
>
>     if ((method=="INVITE" || method=="REFER") && !has_totag()) {
>       sl_send_reply("403", "Forbidden");
>       #break;
>     return();
>     };
>
>     if (method=="INVITE") {
>
>       #if (!proxy_authorize("","subscriber")) {
>       #  proxy_challenge("","0");
>       #  break;
>       #} else if (!check_from()) {
>       #  sl_send_reply("403", "Use From=ID");
>       #  break;
>       #};
>
>       #consume_credentials();
>
>       if (nat_uac_test("19")) {
>         setflag(6);
>         force_rport();
>         fix_nated_contact();
>       };
>       force_rtp_proxy("l");
>     };
>
>     route(1);
>     #break;
>     return();
>   };
>
>
>   # -----------------------------------------------------------------
>   # Call Type Processing Section
>   # -----------------------------------------------------------------
>   if (uri!=myself) {
>     route(4);
>     route(1);
>     #break;
>     return();
>   };
>
>   if (method=="ACK") {
>     route(1);
>     #break;
>     return();
>   } if (method=="CANCEL") {
>     route(1);
>     #break;
>     return();
>   } else if (method=="INVITE") {
>     route(3);
>     #break;
>     return();
>   } else  if (method=="REGISTER") {
>     route(2);
>     #break;
>     return();
>   };
>
>   lookup("aliases");
>   if (uri!=myself) {
>     route(4);
>     route(1);
>     #break;
>     return();
>
>   };
>
>   if (!lookup("location")) {
>     sl_send_reply("404", "User Not Found");
>     #break;
>     return();
>   };
>
>   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 (!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] {
>
>   # -----------------------------------------------------------------
>   # INVITE Message Handler
>   # -----------------------------------------------------------------
>
>   #if (!proxy_authorize("","subscriber")) {
>   #  proxy_challenge("","0");
>   #  break;
>   #} else if (!check_from()) {
>   #  sl_send_reply("403", "Use From=ID");
>   #  break;
>   #};
>
>   #   consume_credentials();
>
>   if (nat_uac_test("19")) {
>     setflag(6);
>      }
>
>   lookup("aliases");
>   if (uri!=myself) {
>     route(4);
>     route(1);
>     #break;
>     return();
>   };
>
>   if (!lookup("location")) {
>     sl_send_reply("404", "User Not Found");
>     #break;
>     return();
>   };
>
>   route(4);
>   route(1);
> }
>
> route[4] {
>
>   # -----------------------------------------------------------------
>   # NAT Traversal Section
>   # -----------------------------------------------------------------
>
>   if (isflagset(6)) {
>     force_rport();
>     fix_nated_contact();
>     force_rtp_proxy();
>   }
> }
>
>
> onreply_route[1] {
>
>   if (isflagset(6) && status=~"(180)|(183)|2[0-9][0-9]") {
>       if (!search("^Content-Length:[ ]*0")) {
>       force_rtp_proxy();
>     };
>   };
>
>   if (nat_uac_test("1")) {
>     fix_nated_contact();
>   };
> }#end of route.
>
> branch_route[2] {
>         xlog("new branch at $ru\n");
> }
>
>
> onreply_route[2] {
>         xlog("incoming reply\n");
> }
>
>
> failure_route[1] {
>         if (t_was_cancelled()) {
>                 exit;
>         }
>
>         # uncomment the following lines if you want to block client
>         # redirect based on 3xx replies.
>         ##if (t_check_status("3[0-9][0-9]")) {
>         ##t_reply("404","Not found");
>         ##      exit;
>         ##}
>
>
>         # uncomment the following lines if you want to redirect the failed
>         # calls to a different new destination
>         ##if (t_check_status("486|408")) {
>         ##      sethostport("192.168.2.100:5060");
>         ##      # do not set the missed call flag again
>         ##      t_relay();
>         ##}
> }
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>   




More information about the Users mailing list