Discussion:
[SR-Users] rtpengine not working with append_branch
Yuriy Gorlichenko
2014-10-23 10:03:38 UTC
Permalink
Hello all. I use rtpengine and rtpproxy-ng module at kamailio for proxying
RTP and modifying SDP between endpoints. I use two types of clients - such
as WSS based and UDP based clients.

I have a trouble with append_branch and rtpengine handling for this
packets.

I try to implement this logic of my script

Logic of my script:

--checking location table for rows with needed account
--get info from contact at loop

for every step

--check technology (sip or ws)
--append_branch with existing destination for this account
--rewrite packet with rtpengine to needed technology


after loop forward packets via t_relay


At listing bellow rtpproxy_manage have no flag "b" that implement needed
functionality. It not included at the script because I tried include it but
rtpengine says that ca nnot handle this request. As i understand this flag
worked with rtpproxy and rtpproxy-ng apps only. Not with rtpengine.


At my test I have 2 endpoints with WS and UDP phones (at fist step ir WS
and 2 step it UDP). All calls going form asterisk via UDP. When I do these
steps (at my script) I see packet at TCP dump and saw that sended only one
packet to UDP but body of packet is WS. Then I saw log of kamailio. I see
that at second step packet changed body to WS body (so strange because
other steps before and after goes for UDP (as at logic of script))

If I set "b" flag I can call only UDP endpoint, but at log I see as I say
that rtpengine can not do thomething with SIP packets and send with
t_relay uncghanged UDP packet only.

sql_query("ca", "select contact from location where username='$tU'", "ra");
xlog("rows: $dbr(ra=>rows) cols: $dbr(ra=>cols)\n");
if($dbr(ra=>rows)>0){
$var(i)=0;
while($var(i)<$dbr(ra=>rows)){
xlog("L_INFO","SQL query return contact {$dbr(ra=>[$var(i),0])} for {$tU}
at step {$var(i)}\n");
if ($dbr(ra=>[$var(i),0])=~"transport=ws"){
xlog("L_INFO", "This is a Websocket call to endpoint");
sql_pvquery("ca", "select received from location where
contact='$dbr(ra=>[$var(i),0])'","$var(recieved)");
xlog("L_INFO","SQL query return recieved {$var(recieved)} for {$tU}\n");
$du=$var(recieved);
xlog("L_INFO", "Request going FROM ASTERISK to WS. Destination is {$du}\n");
xlog("L_INFO","Websocket Destination URI is {$var(recieved)} for {$tU}\n");
rtpproxy_manage("froc+SP");
t_on_reply("REPLY_FROM_WS");
append_branch("sip:$tU@$du");
$var(i) = $var(i) + 1;
}
else
{
xlog("L_INFO", "This is a classic UDP call to endpoint");
$du="sip:"+$(dbr(ra=>[$var(i),0]){s.select,1,@});
xlog("L_INFO","Classic Destination URI is {$dbr(ra=>[$var(i),0])} for
{$tU}\n");
rtpproxy_manage("co");
t_on_reply("MANAGE_CLASSIC_REPLY");
append_branch("sip:$tU@$du");
$var(i) = $var(i) + 1;
}
#append_branch("sip:$tU@$du");
}
}
return 1;


So it customised schema of standart example


seturi("sip:***@example.com
<https://e.mail.ru/compose/?mailto=mailto%3asip%253Aa-***@public.gmane.org>");
append_branch("sip:***@example.com
<https://e.mail.ru/compose/?mailto=mailto%3asip%253Ab-***@public.gmane.org>");
append_branch("sip:***@example.com
<https://e.mail.ru/compose/?mailto=mailto%3asip%253Ac-***@public.gmane.org>");
append_branch("sip:***@example.com
<https://e.mail.ru/compose/?mailto=mailto%3asip%253Ad-***@public.gmane.org>");

t_relay();

I need fro advice how to fix this may be with another applications or with
another steps. Thanks.
Richard Fuchs
2014-10-23 14:56:25 UTC
Permalink
Post by Yuriy Gorlichenko
Hello all. I use rtpengine and rtpproxy-ng module at kamailio for
proxying RTP and modifying SDP between endpoints. I use two types of
clients - such as WSS based and UDP based clients.
I have a trouble with append_branch and rtpengine handling for this
packets.
I try to implement this logic of my script
--checking location table for rows with needed account
--get info from contact at loop
for every step
--check technology (sip or ws)
--append_branch with existing destination for this account
--rewrite packet with rtpengine to needed technology
after loop forward packets via t_relay
At listing bellow rtpproxy_manage have no flag "b" that implement needed
functionality. It not included at the script because I tried include it
but rtpengine says that ca nnot handle this request. As i understand
this flag worked with rtpproxy and rtpproxy-ng apps only. Not with
rtpengine.
At my test I have 2 endpoints with WS and UDP phones (at fist step ir WS
and 2 step it UDP). All calls going form asterisk via UDP. When I do
these steps (at my script) I see packet at TCP dump and saw that sended
only one packet to UDP but body of packet is WS. Then I saw log of
kamailio. I see that at second step packet changed body to WS body (so
strange because other steps before and after goes for UDP (as at logic
of script))
If I set "b" flag I can call only UDP endpoint, but at log I see as I
say that rtpengine can not do thomething with SIP packets and send with
t_relay uncghanged UDP packet only.
If you include the full set of flags in both cases, it should work
without the "b" flag. IOW, include "-sp" when sending to an RTP endpoint
(or perhaps "+sp") and "+SP" when sending to a WebRTC endpoint.

cheers
Yuriy Gorlichenko
2014-10-23 16:17:19 UTC
Permalink
What you mean under "full set of flags"? At reply I use mirror (+/-) flags
off course. More, it work without branches fine ( i select only one
endpoint). I have issue only with branches.
Post by Richard Fuchs
Post by Yuriy Gorlichenko
Hello all. I use rtpengine and rtpproxy-ng module at kamailio for
proxying RTP and modifying SDP between endpoints. I use two types of
clients - such as WSS based and UDP based clients.
I have a trouble with append_branch and rtpengine handling for this
packets.
I try to implement this logic of my script
--checking location table for rows with needed account
--get info from contact at loop
for every step
--check technology (sip or ws)
--append_branch with existing destination for this account
--rewrite packet with rtpengine to needed technology
after loop forward packets via t_relay
At listing bellow rtpproxy_manage have no flag "b" that implement needed
functionality. It not included at the script because I tried include it
but rtpengine says that ca nnot handle this request. As i understand
this flag worked with rtpproxy and rtpproxy-ng apps only. Not with
rtpengine.
At my test I have 2 endpoints with WS and UDP phones (at fist step ir WS
and 2 step it UDP). All calls going form asterisk via UDP. When I do
these steps (at my script) I see packet at TCP dump and saw that sended
only one packet to UDP but body of packet is WS. Then I saw log of
kamailio. I see that at second step packet changed body to WS body (so
strange because other steps before and after goes for UDP (as at logic
of script))
If I set "b" flag I can call only UDP endpoint, but at log I see as I
say that rtpengine can not do thomething with SIP packets and send with
t_relay uncghanged UDP packet only.
If you include the full set of flags in both cases, it should work
without the "b" flag. IOW, include "-sp" when sending to an RTP endpoint
(or perhaps "+sp") and "+SP" when sending to a WebRTC endpoint.
cheers
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Richard Fuchs
2014-10-23 16:18:48 UTC
Permalink
Post by Yuriy Gorlichenko
What you mean under "full set of flags"? At reply I use mirror (+/-)
flags off course. More, it work without branches fine ( i select only
one endpoint). I have issue only with branches.
I mean that instead of using rtpproxy_manage("co") you should use
rtpproxy_manage("co-sp").

cheers
Yuriy Gorlichenko
2014-10-23 16:42:59 UTC
Permalink
Oh. Ok. I will try. Thanks for advice. I very hope it hepls.
Post by Richard Fuchs
Post by Yuriy Gorlichenko
What you mean under "full set of flags"? At reply I use mirror (+/-)
flags off course. More, it work without branches fine ( i select only
one endpoint). I have issue only with branches.
I mean that instead of using rtpproxy_manage("co") you should use
rtpproxy_manage("co-sp").
cheers
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Yuriy Gorlichenko
2014-10-23 19:06:08 UTC
Permalink
Still have same error...
Now rtpproxy_manage("co-sp") for classic call. At log I see that rtpproxy
wirked gine. For each step it generate write body, but t_Relay still send
strange "compinated" packet to UDP with SDP for WS...
Post by Yuriy Gorlichenko
Oh. Ok. I will try. Thanks for advice. I very hope it hepls.
Post by Richard Fuchs
Post by Yuriy Gorlichenko
What you mean under "full set of flags"? At reply I use mirror (+/-)
flags off course. More, it work without branches fine ( i select only
one endpoint). I have issue only with branches.
I mean that instead of using rtpproxy_manage("co") you should use
rtpproxy_manage("co-sp").
cheers
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Richard Fuchs
2014-10-23 19:25:38 UTC
Permalink
Post by Yuriy Gorlichenko
Still have same error...
Now rtpproxy_manage("co-sp") for classic call. At log I see that
rtpproxy wirked gine. For each step it generate write body, but t_Relay
still send strange "compinated" packet to UDP with SDP for WS...
Do you mean that the outgoing packet contains two SDP bodies? This has
been discussed and solved in this thread:
http://lists.sip-router.org/pipermail/sr-dev/2014-July/024507.html

cheers
Yuriy Gorlichenko
2014-10-23 19:36:23 UTC
Permalink
No SDP body only one. but packet like this

INVITE sip:device-***@sip:1.21.10.2:45437;rinstance=07f88c423145358e;transport=UDP
SIP/2.0
Record-Route: <sip:sip.myservice.com:5068;nat=yes;ftag=as1be940e5;lr=on>
Via: SIP/2.0/UDP sip.myservice.com:5068
;branch=z9hG4bKca7d.2d16143316e23fac46bf686bb41780b3.2
Via: SIP/2.0/UDP 17.74.28.7:50600;branch=z9hG4bK22c67800;rport=50600
Max-Forwards: 70
From: "Name" <sip:1001-O/s7hm9zc4HX/***@public.gmane.org:50600>;tag=as1be940e5
To: <sip:device-200-+bvw28C1uVVNTnL9LlKPRAC/***@public.gmane.org:5068>
Contact: <sip:1001-O/s7hm9zc4HX/***@public.gmane.org:50600>
Call-ID: 5ee58acd136888261e85d91e345e7ba1-O/s7hm9zc4HX/***@public.gmane.org:50600
CSeq: 102 INVITE
User-Agent: Asterisk PBX 12.6.1
Date: Thu, 23 Oct 2014 19:27:54 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO,
PUBLISH, MESSAGE
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 1044

v=0
o=root 1195474335 1195474335 IN IP4 2.10.39.16
s=Asterisk PBX 12.6.1
c=IN IP4 2.10.39.16
t=0 0
a=ice-lite
m=audio 30614 RTP/SAVPF 8 3 0 101
a=rtpmap:8 PCMA/8000
a=rtpmap:3 GSM/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv
a=rtcp:30615
a=crypto:1 AES_CM_128_HMAC_SHA1_80
inline:OY72ZDHa+E3avlHwschrdBMe00qDfkN0BUyOxT1C
a=setup:actpass
a=fingerprint:sha-1
07:3D:B4:B0:0E:0D:87:39:C3:83:10:E2:B8:B8:2C:0C:0D:59:EF:4C
a=ice-ufrag:Wudfwh08
a=ice-pwd:VoamuFVRrAXOhUaeD6tA3PcXhndL
a=candidate:8jYonvAy1KGkAdP3 1 UDP 213070
Post by Richard Fuchs
Post by Yuriy Gorlichenko
Still have same error...
Now rtpproxy_manage("co-sp") for classic call. At log I see that
rtpproxy wirked gine. For each step it generate write body, but t_Relay
still send strange "compinated" packet to UDP with SDP for WS...
Do you mean that the outgoing packet contains two SDP bodies? This has
http://lists.sip-router.org/pipermail/sr-dev/2014-July/024507.html
cheers
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Yuriy Gorlichenko
2014-10-23 19:39:59 UTC
Permalink
And what returns prtpengine at log when changing this packet.

Returning to SIP proxy: d3:sdp316:v=0#015#012o=root 1195474335 1195474335
IN IP4 2.10.39.16#015#012s=Asterisk PBX 12.6.1#015#012c=IN IP4
2.10.39.16#015#012t=0 0#015#012m=audio 30614 RTP/AVP 8 3 0
101#015#012a=rtpmap:8 PCMA/8000#015#012a=rtpmap:3
GSM/8000#015#012a=rtpmap:0 PCMU/8000#015#012a=rtpmap:101
telephone-event/8000#015#012a=fmtp:101
0-16#015#012a=ptime:20#015#012a=maxptime:150#015#012a=sendrecv#015#012a=rtcp:30615#015#0126:result2:oke

So it looks like that Destination sets from second append_branch at second
step (to UDP) and body sets as body of first step (for WS packet)
Post by Yuriy Gorlichenko
No SDP body only one. but packet like this
SIP/2.0
Record-Route: <sip:sip.myservice.com:5068;nat=yes;ftag=as1be940e5;lr=on>
Via: SIP/2.0/UDP sip.myservice.com:5068
;branch=z9hG4bKca7d.2d16143316e23fac46bf686bb41780b3.2
Via: SIP/2.0/UDP 17.74.28.7:50600;branch=z9hG4bK22c67800;rport=50600
Max-Forwards: 70
CSeq: 102 INVITE
User-Agent: Asterisk PBX 12.6.1
Date: Thu, 23 Oct 2014 19:27:54 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO,
PUBLISH, MESSAGE
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 1044
v=0
o=root 1195474335 1195474335 IN IP4 2.10.39.16
s=Asterisk PBX 12.6.1
c=IN IP4 2.10.39.16
t=0 0
a=ice-lite
m=audio 30614 RTP/SAVPF 8 3 0 101
a=rtpmap:8 PCMA/8000
a=rtpmap:3 GSM/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv
a=rtcp:30615
a=crypto:1 AES_CM_128_HMAC_SHA1_80
inline:OY72ZDHa+E3avlHwschrdBMe00qDfkN0BUyOxT1C
a=setup:actpass
a=fingerprint:sha-1
07:3D:B4:B0:0E:0D:87:39:C3:83:10:E2:B8:B8:2C:0C:0D:59:EF:4C
a=ice-ufrag:Wudfwh08
a=ice-pwd:VoamuFVRrAXOhUaeD6tA3PcXhndL
a=candidate:8jYonvAy1KGkAdP3 1 UDP 213070
Post by Richard Fuchs
Post by Yuriy Gorlichenko
Still have same error...
Now rtpproxy_manage("co-sp") for classic call. At log I see that
rtpproxy wirked gine. For each step it generate write body, but t_Relay
still send strange "compinated" packet to UDP with SDP for WS...
Do you mean that the outgoing packet contains two SDP bodies? This has
http://lists.sip-router.org/pipermail/sr-dev/2014-July/024507.html
cheers
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Loading...