[SR-Users] Kamailio : Listening on multiple ports behind NAT

Reda Aouad reda.aouad at gmail.com
Thu Jan 19 01:00:11 CET 2012


Okay, it seems we're on the right track.. BUT

This is my code in the branch_route

        if (is_method("INVITE|SUBSCRIBE")){
                $avp(s:fs) = $fs;
                $avp(s:Rp) = $Rp;
                avp_subst("$avp(s:fs)", "/(.*):(.*):(.*)/\3/");
                #xlog("fs: $avp(s:fs) | Rp: $avp(s:Rp)");
                if ($avp(s:fs) == $avp(s:Rp)) {
                        record_route_preset("PUBLIC_IP:$avp(s:fs)");
                        return;
                }
                record_route_preset("PUBLIC_IP:$avp(s:fs)",
"PUBLIC_IP:$avp(s:Rp)");
        }
        return;

$avp(s:fs) is the outbound socket, on which I apply the avp_subst function
to extract only the outbound port number Kamailio should send from.
$avp(s:Rp) is the inbound port, the port on which Kamailio received the
INVITE.
Then if the above port numbers are equal, I do only one record route. If
not, I do double record routing, one per port number.

The problem is that for the first branch, everything works fine. But for
the subsequent branches, I get the following error :
        ERROR: rr [rr_mod.c:256]: Duble attempt to record-route

It seems that for subsequent branches, Kamailio detects that it already
record routed the first branch, so gives an error and doesn't record route.


Reda



On Wed, Jan 18, 2012 at 23:45, Ovidiu Sas <osas at voipembedded.com> wrote:

> Test them in branch_route:
> http://www.kamailio.org/wiki/cookbooks/3.2.x/core#branch_route
> and set the Record-Route header there, for each individual branch.
>
> Regards,
> Ovidiu Sas
>
> --
> VoIP Embedded, Inc.
> http://www.voipembedded.com
>
>
> On Wed, Jan 18, 2012 at 5:37 PM, Reda Aouad <reda.aouad at gmail.com> wrote:
> > Thank you for your reply. I tried what you suggested.
> >
> > The problem is when there are multiple locations/registrations per AOR on
> > different ports and doing parallel forking.
> > Accessing $fs only gives one of the sockets (first or last?), not all of
> > them.
> > Accessing $sndfrom gives all of the used outgoing sockets, because it's
> > populated in the onsedn_route route, which is called for every outgoing
> > packet, but in onsend_route I can't use record_route functions, neither
> > mangle with the SIP header anymore in any way. It's too late by the time
> I
> > get to onsend_route...
> >
> > No solution so far..
> >
> >
> > Reda
> >
> >
> >
> > On Tue, Jan 17, 2012 at 21:47, Ovidiu Sas <osas at voipembedded.com> wrote:
> >>
> >> When you route through usrloc, there is a PV that should be set - forced
> >> socket:
> >>
> http://www.kamailio.org/wiki/cookbooks/devel/pseudovariables#forced_socket
> >> You can check the socket via 'kamctl ul show' command.
> >> If the PV is not populated, check the send attributes:
> >>
> >>
> http://www.kamailio.org/wiki/cookbooks/devel/pseudovariables#send_address_attributes
> >> Based on that, you should know through which interface the INVITE
> >> should be sent and therefore you should be able to set the proper
> >> Record-Route header.
> >>
> >> Regards,
> >> Ovidiu Sas
> >>
> >> --
> >> VoIP Embedded, Inc.
> >> http://www.voipembedded.com
> >>
> >>
> >> On Tue, Jan 17, 2012 at 3:01 PM, Reda Aouad <reda.aouad at gmail.com>
> wrote:
> >> > I just tried the record_route_advertised_address("public_ip").
> >> > It doesn't add the port number of the outgoing socket.
> >> >
> >> > Any suggestions?
> >> >
> >> > RA
> >> >
> >> >
> >> >
> >> > On Mon, Jan 16, 2012 at 15:57, Reda Aouad <reda.aouad at gmail.com>
> wrote:
> >> >>
> >> >> I know about record_route_advertised_address("ip:port") function. If
> I
> >> >> understood correctly, it inserts a top-most RR header with the public
> >> >> IP if
> >> >> double RR is enabled. But that doesn't solve the multiple ports
> >> >> problem. I
> >> >> would get in the SIP header :
> >> >>
> >> >> Record-Route: <public_ip;lr=on>
> >> >> Record-Route: <private_ip:port;lr=on>
> >> >>
> >> >> If user B sees the first Record-Route header, it remembers port=5060
> >> >> for
> >> >> future requests.
> >> >> I cannot manually set the port in the config file since it depends on
> >> >> which port user B is registered, which I don't have a way to find it.
> >> >>
> >> >> RA
> >> >>
> >> >>
> >> >>
> >> >> On Mon, Jan 16, 2012 at 15:51, Andrew Pogrebennyk
> >> >> <apogrebennyk at sipwise.com> wrote:
> >> >>>
> >> >>> Hi,
> >> >>>
> >> >>> On 01/16/2012 03:41 PM, Reda Aouad wrote:
> >> >>> > I suggest that the function record_route( ) takes a public IP
> >> >>> > address
> >> >>> > as
> >> >>> > a parameter, still doing what it does (correct record routing and
> >> >>> > cookie
> >> >>> > addition did=xxx and loose route lr=on), but only replacing the
> >> >>> > private
> >> >>> > IP address on which Kamailio listens with a public IP address. Or
> >> >>> > that
> >> >>> > the record_route( ) function uses the advertised_address to
> >> >>> > construct
> >> >>> > the RR header.
> >> >>>
> >> >>> maybe you are looking for the function
> >> >>> record_route_advertised_address()
> >> >>> which is available in git master:
> >> >>> http://web.archiveorange.com/archive/v/jZFTGE0yjPqCTTcAkzuf
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20120119/80d27253/attachment-0001.htm>


More information about the sr-users mailing list