bound_addr/public_addr won't set RTP address

JH
Jakob Hirsch
Mon, Nov 26, 2012 4:39 PM

Hi,

I have a simple application for outgoing calls, using pjsip 2.0.1 and
its python bindings. The application should run on a multi-home host
with multiple IP addresses (some internal, one external) and use the
external IP address. I create my Transport with a TransportConfig and
the external IP address like that:

transport = lib.create_transport(pj.TransportType.UDP,
pj.TransportConfig(bound_addr=ext_ip, public_addr=ext_ip))

The Problem now is that the media keeps using the internal address in
the SDP's connection information and as the source address for the RTP
packets.

I tried several combinations of bound_addr and public_addr, but that did
not change anything. A strace reveals that the SIP socket is actually
bind() to the ext-ip, but the RTP (and RTCP) socket to INADDR_ANY (0.0.0.0):

9613  socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 5
9613  bind(5, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("212.xxx.xx.xxx")}, 16) = 0

...

9613  socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 7
9613  bind(7, {sa_family=AF_INET, sin_port=htons(40000), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
9613  socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 8
9613  bind(8, {sa_family=AF_INET, sin_port=htons(40001), sin_addr=inet_addr("0.0.0.0")}, 16) = 0

I found a posting to the list
(http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2011-June/012978.html)
with the same problem, but with no answer. Is there really no way to get
this right out of the box? I'm trying to go through the sources, but the
complexity is a little mind-boggling...

TIA & Regards
Jakob

Hi, I have a simple application for outgoing calls, using pjsip 2.0.1 and its python bindings. The application should run on a multi-home host with multiple IP addresses (some internal, one external) and use the external IP address. I create my Transport with a TransportConfig and the external IP address like that: transport = lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(bound_addr=ext_ip, public_addr=ext_ip)) The Problem now is that the media keeps using the internal address in the SDP's connection information and as the source address for the RTP packets. I tried several combinations of bound_addr and public_addr, but that did not change anything. A strace reveals that the SIP socket is actually bind() to the ext-ip, but the RTP (and RTCP) socket to INADDR_ANY (0.0.0.0): > 9613 socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 5 > 9613 bind(5, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("212.xxx.xx.xxx")}, 16) = 0 ... > 9613 socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 7 > 9613 bind(7, {sa_family=AF_INET, sin_port=htons(40000), sin_addr=inet_addr("0.0.0.0")}, 16) = 0 > 9613 socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 8 > 9613 bind(8, {sa_family=AF_INET, sin_port=htons(40001), sin_addr=inet_addr("0.0.0.0")}, 16) = 0 I found a posting to the list (http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2011-June/012978.html) with the same problem, but with no answer. Is there really no way to get this right out of the box? I'm trying to go through the sources, but the complexity is a little mind-boggling... TIA & Regards Jakob
OH
Omar Hussein
Mon, Nov 26, 2012 9:01 PM

Hi Jakob,

You can create another transport to be used for media with its own port
(starting port for range), public_addr and bound_addr and set it against an
account in rtp_cfg under pjsua_acc_config.  Calls for this account will
then use this transport for media.

Regards,
Omar

On Tue, Nov 27, 2012 at 3:39 AM, Jakob Hirsch jh@plonk.de wrote:

Hi,

I have a simple application for outgoing calls, using pjsip 2.0.1 and
its python bindings. The application should run on a multi-home host
with multiple IP addresses (some internal, one external) and use the
external IP address. I create my Transport with a TransportConfig and
the external IP address like that:

transport = lib.create_transport(pj.TransportType.UDP,
pj.TransportConfig(bound_addr=ext_ip, public_addr=ext_ip))

The Problem now is that the media keeps using the internal address in
the SDP's connection information and as the source address for the RTP
packets.

I tried several combinations of bound_addr and public_addr, but that did
not change anything. A strace reveals that the SIP socket is actually
bind() to the ext-ip, but the RTP (and RTCP) socket to INADDR_ANY
(0.0.0.0):

9613  socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 5
9613  bind(5, {sa_family=AF_INET, sin_port=htons(0),

sin_addr=inet_addr("212.xxx.xx.xxx")}, 16) = 0
...

9613  socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 7
9613  bind(7, {sa_family=AF_INET, sin_port=htons(40000),

sin_addr=inet_addr("0.0.0.0")}, 16) = 0

9613  socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 8
9613  bind(8, {sa_family=AF_INET, sin_port=htons(40001),

sin_addr=inet_addr("0.0.0.0")}, 16) = 0

I found a posting to the list
(
http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2011-June/012978.html
)
with the same problem, but with no answer. Is there really no way to get
this right out of the box? I'm trying to go through the sources, but the
complexity is a little mind-boggling...

TIA & Regards
Jakob


Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

Hi Jakob, You can create another transport to be used for media with its own port (starting port for range), public_addr and bound_addr and set it against an account in rtp_cfg under pjsua_acc_config. Calls for this account will then use this transport for media. Regards, Omar On Tue, Nov 27, 2012 at 3:39 AM, Jakob Hirsch <jh@plonk.de> wrote: > Hi, > > I have a simple application for outgoing calls, using pjsip 2.0.1 and > its python bindings. The application should run on a multi-home host > with multiple IP addresses (some internal, one external) and use the > external IP address. I create my Transport with a TransportConfig and > the external IP address like that: > > transport = lib.create_transport(pj.TransportType.UDP, > pj.TransportConfig(bound_addr=ext_ip, public_addr=ext_ip)) > > The Problem now is that the media keeps using the internal address in > the SDP's connection information and as the source address for the RTP > packets. > > I tried several combinations of bound_addr and public_addr, but that did > not change anything. A strace reveals that the SIP socket is actually > bind() to the ext-ip, but the RTP (and RTCP) socket to INADDR_ANY > (0.0.0.0): > > > 9613 socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 5 > > 9613 bind(5, {sa_family=AF_INET, sin_port=htons(0), > sin_addr=inet_addr("212.xxx.xx.xxx")}, 16) = 0 > ... > > 9613 socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 7 > > 9613 bind(7, {sa_family=AF_INET, sin_port=htons(40000), > sin_addr=inet_addr("0.0.0.0")}, 16) = 0 > > 9613 socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 8 > > 9613 bind(8, {sa_family=AF_INET, sin_port=htons(40001), > sin_addr=inet_addr("0.0.0.0")}, 16) = 0 > > I found a posting to the list > ( > http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2011-June/012978.html > ) > with the same problem, but with no answer. Is there really no way to get > this right out of the box? I'm trying to go through the sources, but the > complexity is a little mind-boggling... > > > TIA & Regards > Jakob > > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing list > pjsip@lists.pjsip.org > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org >
SK
Sandeep Karanth
Tue, Nov 27, 2012 4:08 AM

Hi Jacob,
I too faced a similar issue couple of months back and I found
a way to get around it.Although I don't have access to that code now,if I
can recall correctly you can do these

  1. While adding the local accounts
    pjsua_acc_add_local(transport_id, PJ_TRUE, &aid);  pjsua_acc_config
    acc_cfg;
    pjsua_acc_get_config(aid, &acc_cfg);
    acc_cfg.rtp_cfg.public_addr = pj_str("THE_IP_YOU_WISH_TO_SET");
    acc_cfg.rtp_cfg.bound_addr= pj_str("THE_IP_YOU_WISH_TO_SET");

pjsua_acc_modify(aid, &acc_cfg);

2)Before adding other accounts you can set the bound and

published addresses in acc_cfg.rtp_cfg and use pjsua_acc_add(&acc_cfg,
PJ_TRUE, NULL); to add the account.

Try these approaches.Hopefully it should solve the problem for you.

Regards,

Sandeep

On Tue, Nov 27, 2012 at 2:31 AM, Omar Hussein omarh2812@gmail.com wrote:

Hi Jakob,

You can create another transport to be used for media with its own port
(starting port for range), public_addr and bound_addr and set it against an
account in rtp_cfg under pjsua_acc_config.  Calls for this account will
then use this transport for media.

Regards,
Omar

On Tue, Nov 27, 2012 at 3:39 AM, Jakob Hirsch jh@plonk.de wrote:

Hi,

I have a simple application for outgoing calls, using pjsip 2.0.1 and
its python bindings. The application should run on a multi-home host
with multiple IP addresses (some internal, one external) and use the
external IP address. I create my Transport with a TransportConfig and
the external IP address like that:

transport = lib.create_transport(pj.TransportType.UDP,
pj.TransportConfig(bound_addr=ext_ip, public_addr=ext_ip))

The Problem now is that the media keeps using the internal address in
the SDP's connection information and as the source address for the RTP
packets.

I tried several combinations of bound_addr and public_addr, but that did
not change anything. A strace reveals that the SIP socket is actually
bind() to the ext-ip, but the RTP (and RTCP) socket to INADDR_ANY
(0.0.0.0):

9613  socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 5
9613  bind(5, {sa_family=AF_INET, sin_port=htons(0),

sin_addr=inet_addr("212.xxx.xx.xxx")}, 16) = 0
...

9613  socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 7
9613  bind(7, {sa_family=AF_INET, sin_port=htons(40000),

sin_addr=inet_addr("0.0.0.0")}, 16) = 0

9613  socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 8
9613  bind(8, {sa_family=AF_INET, sin_port=htons(40001),

sin_addr=inet_addr("0.0.0.0")}, 16) = 0

I found a posting to the list
(
http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2011-June/012978.html
)
with the same problem, but with no answer. Is there really no way to get
this right out of the box? I'm trying to go through the sources, but the
complexity is a little mind-boggling...

TIA & Regards
Jakob


Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

Hi Jacob, I too faced a similar issue couple of months back and I found a way to get around it.Although I don't have access to that code now,if I can recall correctly you can do these 1) While adding the local accounts pjsua_acc_add_local(transport_id, PJ_TRUE, &aid); pjsua_acc_config acc_cfg; pjsua_acc_get_config(aid, &acc_cfg); acc_cfg.*rtp_cfg.public_addr = pj_str("THE_IP_YOU_WISH_TO_SET");* acc_cfg.*rtp_cfg.bound_addr= pj_str("THE_IP_YOU_WISH_TO_SET");* pjsua_acc_modify(aid, &acc_cfg); 2)Before adding other accounts you can set the bound and published addresses in acc_cfg.rtp_cfg and use pjsua_acc_add(&acc_cfg, PJ_TRUE, NULL); to add the account. Try these approaches.Hopefully it should solve the problem for you. Regards, Sandeep On Tue, Nov 27, 2012 at 2:31 AM, Omar Hussein <omarh2812@gmail.com> wrote: > Hi Jakob, > > You can create another transport to be used for media with its own port > (starting port for range), public_addr and bound_addr and set it against an > account in rtp_cfg under pjsua_acc_config. Calls for this account will > then use this transport for media. > > Regards, > Omar > > > > On Tue, Nov 27, 2012 at 3:39 AM, Jakob Hirsch <jh@plonk.de> wrote: > >> Hi, >> >> I have a simple application for outgoing calls, using pjsip 2.0.1 and >> its python bindings. The application should run on a multi-home host >> with multiple IP addresses (some internal, one external) and use the >> external IP address. I create my Transport with a TransportConfig and >> the external IP address like that: >> >> transport = lib.create_transport(pj.TransportType.UDP, >> pj.TransportConfig(bound_addr=ext_ip, public_addr=ext_ip)) >> >> The Problem now is that the media keeps using the internal address in >> the SDP's connection information and as the source address for the RTP >> packets. >> >> I tried several combinations of bound_addr and public_addr, but that did >> not change anything. A strace reveals that the SIP socket is actually >> bind() to the ext-ip, but the RTP (and RTCP) socket to INADDR_ANY >> (0.0.0.0): >> >> > 9613 socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 5 >> > 9613 bind(5, {sa_family=AF_INET, sin_port=htons(0), >> sin_addr=inet_addr("212.xxx.xx.xxx")}, 16) = 0 >> ... >> > 9613 socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 7 >> > 9613 bind(7, {sa_family=AF_INET, sin_port=htons(40000), >> sin_addr=inet_addr("0.0.0.0")}, 16) = 0 >> > 9613 socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 8 >> > 9613 bind(8, {sa_family=AF_INET, sin_port=htons(40001), >> sin_addr=inet_addr("0.0.0.0")}, 16) = 0 >> >> I found a posting to the list >> ( >> http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2011-June/012978.html >> ) >> with the same problem, but with no answer. Is there really no way to get >> this right out of the box? I'm trying to go through the sources, but the >> complexity is a little mind-boggling... >> >> >> TIA & Regards >> Jakob >> >> _______________________________________________ >> Visit our blog: http://blog.pjsip.org >> >> pjsip mailing list >> pjsip@lists.pjsip.org >> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org >> > > > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing list > pjsip@lists.pjsip.org > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org > >
JH
Jakob Hirsch
Wed, Nov 28, 2012 10:01 AM

Hi!

Sandeep Karanth, 27.11.2012 05:08:

now,if I can recall correctly you can do these

...

acc_cfg.rtp_cfg.public_addr = pj_str("THE_IP_YOU_WISH_TO_SET");
acc_cfg.rtp_cfg.bound_addr= pj_str("THE_IP_YOU_WISH_TO_SET");

That's what I needed. Many thanks!

As I'm using the python module, I had to hack this in the wrapper code.
For simplicity, I added an "rtp_addr" option to the create_account()
method. The patch is attached.

Hi! Sandeep Karanth, 27.11.2012 05:08: > now,if I can recall correctly you can do these ... > acc_cfg.*rtp_cfg.public_addr = pj_str("THE_IP_YOU_WISH_TO_SET");* > acc_cfg.*rtp_cfg.bound_addr= pj_str("THE_IP_YOU_WISH_TO_SET");* That's what I needed. Many thanks! As I'm using the python module, I had to hack this in the wrapper code. For simplicity, I added an "rtp_addr" option to the create_account() method. The patch is attached.