[Users] Help needed with mediaproxy and rewritehostport configuration

Berry Bartels berry at praatpaal.com
Mon Mar 12 02:36:36 CET 2007


I’m trying to set up a SIP and RTP proxy server to provide sip trunks to
other SIP servers and PABX. The trunk to the PSTN will be provided by an
other SIP server. This server will only handle signaling and rtp streams
from our server. To test the configuration I’m using a softphone (eyebeam
1.5), a cisco 7912 with SIP IOS, both logged in on my own SIP server, and a
mobile phone as a PSTN client.

Above shown in a diagram
.

http://praatpaal.com/images/sipdiagram.jpg

The following occurs:

1. When I call from the softphone (eyebeam) the the Cisco 7912 the call is
established correct. As far as I can debug the clients are forced to use the
mediaproxy running on our server. This also works the other way around.
2. When I call from PSTN to a SIP client, I can only hear audio from the
PSTN on the SIP client.
3. When I call from a SIP client to the PSTN, I can only hear audio from the
SIP client on the PSTN client.

So, my conclusion is:

When a call is setup from or to the PSTN network, audio is only working from
the client the call is originated.

Below is the configuration from our SIP server and The Mediaserver.

Please help me out here
. Let me know if you have any questions or need more
information

Kind regards,

Berry Bartels
RoutIT B.V.

OPENSER.CFG

listen=XXX.XXX.XXX.XXX
alias=" XXX.XXX.XXX.XXX "
alias="voipit.nl"
alias="sip01.voipit.nl"
alias="sipproxy01.voipit.nl"

debug=3
fork=no
log_stderror=yes

check_via=yes   # (cmd. line: -v)
dns=no         # (cmd. line: -r)
rev_dns=no      # (cmd. line: -R)

sip_warning=yes
syn_branch=yes

server_signature=yes

port=5060
children=4
fifo="/tmp/openser_fifo"
fifo_db_url="mysql://openser:********@localhost/openser"

# --- load modules
mpath="/usr/lib/openser/modules/"
loadmodule "mysql.so"
loadmodule "auth.so"
loadmodule "auth_db.so"
loadmodule "sl.so"
loadmodule "tm.so"
loadmodule "rr.so"
loadmodule "maxfwd.so"
loadmodule "usrloc.so"
loadmodule "registrar.so"
loadmodule "textops.so"
loadmodule "domain.so"
loadmodule "nathelper.so"
loadmodule "mediaproxy.so"
loadmodule "xlog.so"
loadmodule "acc.so"

# --- module params
# rr
# add value to ;lr param to make some broken UAs happy
modparam("rr", "enable_full_lr", 1)

# mediaproxy
modparam("mediaproxy", "mediaproxy_socket", "/var/run/mediaproxy.sock")
modparam("mediaproxy", "natping_interval", 0)

modparam("nathelper", "rtpproxy_disable", 1)
modparam("nathelper", "natping_interval", 30)
modparam("nathelper", "sipping_from", "sip:ping at voipit.nl")

modparam("auth_db", "calculate_ha1", 1)
modparam("auth_db", "password_column", "password")

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

modparam("usrloc","db_url","mysql://openser:********@localhost/openser")

modparam("acc", "db_url", "mysql://openser:********@localhost/openser")
modparam("acc", "log_level", 1)
modparam("acc", "log_flag", 1)
modparam("acc", "db_flag", 1)

# request routing logic
route
{
                  xlog("L_NOTICE", "[$Ts]\t[$fu]\t[$tu]\t[$rm] :: ROUTE
script\n");
                  # sanity checks
                  if (!mf_process_maxfwd_header("10")) 
                  {
                                                xlog("L_NOTICE",
"[$Ts]\t[$fu]\t[$tu]\t[$rm] :: Too many hops\n");
                                                sl_send_reply("483","Too
Many Hops");
                                                exit;
                  }
                  if (msg:len >= max_len) 
                  {
                                                xlog("L_NOTICE",
"[$Ts]\t[$fu]\t[$tu]\t[$rm] :: Message too big\n");
                                                sl_send_reply("513",
"Message too big");
                                                exit;
                  }

                  if(loose_route()) {
                                                xlog("L_NOTICE",
"[$Ts]\t[$fu]\t[$tu]\t[$rm] :: Loose Route -> route[1]\n");
                                                t_relay();
                  }

                  if (!method=="INVITE")
                  {
                                                record_route();
                  }

                  lookup("aliases");
                  

                  if (uri==myself)
                  {
                                                xlog("L_NOTICE",
"[$Ts]\t[$fu]\t[$tu]\t[$rm] :: Registration :: URI is myself\n");
                                                if (method=="REGISTER") {
                                                              
xlog("L_NOTICE", "[$Ts]\t[$fu]\t[$tu]\t[$rm] :: Registration\n");
                                                               # Uncomment
this if you want to use digest authentication
                                                               if
(!www_authorize("voipit.nl", "subscriber")) {
                                                                            
    www_challenge("voipit.nl", "0");
                                                                            
    xlog("L_NOTICE", "[$Ts]\t[$fu]\t[$tu]\t[$rm] :: Registration ::
Failed\n");
                                                                            
    exit;
                                                               } 
                                                              
xlog("L_NOTICE", "[$Ts]\t[$fu]\t[$tu]\t[$rm] :: Registration :: Success\n");
                                                              
save("location");
                                                              
xlog("L_NOTICE", "[$Ts]\t[$fu]\t[$tu]\t[$rm] :: Registration :: Location
Saved\n");
                                                               exit;
                                                }
                                                if
(is_method("INVITE")||is_method("ACK"))
                                                {
                                                              
xlog("L_NOTICE", "[$Ts]\t[$fu]\t[$tu]\t[$rm] :: Invite\n");

                                                               if
(lookup("location") && from_uri=~".*@voipit.nl")
                                                               {
                                                                            
  xlog("L_NOTICE", "[$Ts]\t[$fu]\t[$tu]\t[$rm] :: Lookup Location :: Found
:: Internal Call\n");
                                                                            
  xlog("L_NOTICE", "[$Ts]\t[$fu]\t[$tu]\t[$rm] :: Internal Call ->
Route[1]\n");
                                                                            
  route(1);
                                                                            
  exit;
                                                               } else if
(lookup("location") && from_uri!=~".*@voipit.nl") {
                              
                                               xlog("L_NOTICE",
"[$Ts]\t[$fu]\t[$tu]\t[$rm] :: Lookup Location :: Found :: Inbound Call\n");
                                                                            
  xlog("L_NOTICE", "[$Ts]\t[$fu]\t[$tu]\t[$rm] :: Inbound Call ->
Route[1]\n");
                                                                            
  route(1);
                                                                            
  exit;
                                                               } else {
                                                                            
  xlog("L_NOTICE", "[$Ts]\t[$fu]\t[$tu]\t[$rm] :: Lookup Location :: NOT
Found :: Outbound Call\n");
#                                                                           
sl_send_reply("404","Not found :: Outbound Call");
                                                                            
  xlog("L_NOTICE", "[$Ts]\t[$fu]\t[$tu]\t[$rm] :: Outbound Call ->
Route[2]\n");
                                                                            
  route(2);
                                                                            
  exit;
                                                               }
                                                }
                                                if (is_method("SUBSCRIBE"))
                                                {
                                                              
xlog("L_NOTICE", "[$Ts]\t[$fu]\t[$tu]\t[$rm] :: Subscribe :: Subscribed in
Database\n");
                                                               exit;
                                                }
                                                append_hf("P-hint: usrloc
applied\r\n"); 
                  }

                  xlog("L_NOTICE", "[$Ts]\t[$fu]\t[$tu]\t[$rm] :: End of
script -> Route[1]\n");
                  route(1);
}

route[1]
{
                xlog("L_NOTICE", "[$Ts]\t[$fu]\t[$tu]\t[$rm] ::
route[1]\n");

                if (is_method("INVITE"))
                {
                               xlog("L_NOTICE", "[$Ts]\t[$fu]\t[$tu]\t[$rm]
:: route[1] :: INVITE\n");
                               t_on_reply("1");
#                             t_on_failure("1");
                               use_media_proxy();
                } else if (is_method("BYE|CANCEL")) {
                               xlog("L_NOTICE", "[$Ts]\t[$fu]\t[$tu]\t[$rm]
:: route[1] :: BYE OR CANCEL\n");
                               end_media_session();
                }

                  if (!t_relay()) 
                  {
                                                xlog("L_NOTICE",
"[$Ts]\t[$fu]\t[$tu]\t[$rm] :: Route[1] :: T_RELAY error\n");
                                                sl_reply_error();
                                                end_media_session();
                  } else {
                                                xlog("L_NOTICE",
"[$Ts]\t[$fu]\t[$tu]\t[$rm] :: Route[1] :: T_RELAY\n");
                  }
                  exit;
}

route[2] 
{
                xlog("L_NOTICE", "[$Ts]\t[$fu]\t[$tu]\t[$rm] ::
route[2]\n");
                if (is_method("INVITE"))
                {
                               xlog("L_NOTICE", "[$Ts]\t[$fu]\t[$tu]\t[$rm]
:: route[2] :: INVITE\n");
                               rewritehostport("YYY.YYY.YYY.YYY:5060");
                               t_on_reply("2");
                               use_media_proxy();
                } else if (is_method("BYE|CANCEL")) {
                               xlog("L_NOTICE", "[$Ts]\t[$fu]\t[$tu]\t[$rm]
:: route[2] :: BYE OR CANCEL\n");
                               end_media_session();
                }

                  if (!t_relay())
                  {
                                                xlog("L_NOTICE",
"[$Ts]\t[$fu]\t[$tu]\t[$rm] :: Route[2] :: T_RELAY error\n");
                                                sl_reply_error();
                                                end_media_session();
                  } else {
                                                xlog("L_NOTICE",
"[$Ts]\t[$fu]\t[$tu]\t[$rm] :: Route[2] :: T_RELAY\n");
                  }
                  exit;
}

onreply_route[1]
{
                  xlog("L_NOTICE", "[$Ts]\t[$fu]\t[$tu]\t[$rm] ::
onreply_route[1]\n");
                  if (status =~ "(183)|(2[0-9][0-9])")
                  {
                                                xlog("L_NOTICE",
"[$Ts]\t[$fu]\t[$tu]\t[$rm] :: onreply_route[1] :: Status is 183 or
200-299\n");
                                                if (client_nat_test("1"))
                                                {
                                                              
xlog("L_NOTICE", "[$Ts]\t[$fu]\t[$tu]\t[$rm] :: onreply_route[1] ::
nat_test(1) :: TRUE\n");
                                                              
fix_contact();
                                                } else {
                                                              
xlog("L_NOTICE", "[$Ts]\t[$fu]\t[$tu]\t[$rm] :: onreply_route[1] ::
nat_test(1) :: TRUE\n");
                                                }
                                                use_media_proxy();
                  }
}
onreply_route[2]
{
                               xlog("L_NOTICE", "[$Ts]\t[$fu]\t[$tu]\t[$rm]
:: onreply_route[2]\n");
                               if (client_nat_test("1"))
                               {
                                                xlog("L_NOTICE",
"[$Ts]\t[$fu]\t[$tu]\t[$rm] :: onreply_route[2] :: nat_test(1) :: TRUE\n");
                                                fix_contact();
                               } else {
                                                xlog("L_NOTICE",
"[$Ts]\t[$fu]\t[$tu]\t[$rm] :: onreply_route[2] :: nat_test(1) :: TRUE\n");
                               }
                               use_media_proxy();
}

MEDIAPROXY.INI

[Dispatcher]
start = yes
socket = /var/run/proxydispatcher.sock
group = openser
defaultProxy = /var/run/mediaproxy.sock

[MediaProxy]
start = yes
socket = /var/run/mediaproxy.sock
group = openser
listen = none
allow = Any
proxyIP = XXX.XXX.XXX.XXX
portRange = 60000:65000
TOS = 0xb8
idleTimeout = 60
holdTimeout = 180
forceClose = 0

[Accounting]
accounting = none

[Database]
user = openser
password = ********
host = 127.0.0.1
database = radius
table = radacct

[Radius]
secret = secret
server = localhost
authport = 1812
acctport = 1813
dictionaries = /etc/radiusclient-ng/dictionary,
/etc/openser/radius/dictionary, /usr/local/mediaproxy/dictionary
retries = 2
timeout = 3


More information about the Users mailing list