<div dir="ltr">Hi,<div><br></div><div>I'm having a problem with routing of BYEs in my multi homed Kamailio.</div><div><br></div><div>My setup is a phone on 172.16.230.1, talking to Kamailio on 172.16.230.128.</div><div>
On the "outside" Kamailio uses 10.64.5.16 and its talking to 41.221.230.60</div><div><br></div><div>I'm using the stock Kamailio 4.0.3 kamailio.cfg, with:</div><div>  WITH_NAT defined</div><div>  mhomed=1</div>
<div>  Little change in NATMANAGE to do the rtpproxy_manage with ie or ei as appropriate, coming from my previous post and the response from Alex.</div><div><br></div><div>Here's the invite from the phone:</div><div><br>
</div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>U <a href="http://172.16.230.1:3694">172.16.230.1:3694</a> -> <a href="http://172.16.230.128:5060">172.16.230.128:5060</a></div></div>
<div><div>INVITE <a href="mailto:sip%3A7171001@vc2.connection-telecom.com">sip:7171001@vc2.connection-telecom.com</a>;transport=udp SIP/2.0.</div></div><div><div>Via: SIP/2.0/UDP 172.16.230.1:3694;branch=z9hG4bK-d8754z-6a91626ae4c3f625-1---d8754z-;rport.</div>
</div><div><div>Max-Forwards: 70.</div></div><div><div>Contact: <sip:2686959@172.16.230.1:3694;transport=udp>.</div></div><div><div>To: <<a href="mailto:sip%3A7171001@vc2.connection-telecom.com">sip:7171001@vc2.connection-telecom.com</a>>.</div>
</div><div><div>From: "vc2 2686959"<<a href="mailto:sip%3A2686959@vc2.connection-telecom.com">sip:2686959@vc2.connection-telecom.com</a>>;tag=014e3010.</div></div><div><div>Call-ID: ZDQ4YThjNzEzOTBhOTE5NGViNTFhM2Q5MTY2ZmY1ZDc.</div>
</div><div><div>CSeq: 2 INVITE.</div></div><div><div>Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO.</div></div><div><div>Content-Type: application/sdp.</div></div><div><div>Proxy-Authorization: ...some stuff...</div>
</div><div><div>Supported: replaces.</div></div><div><div>User-Agent: Bria 3 release 3.5.3 stamp 70600.</div></div><div><div>Content-Length: 256.</div></div><div><div>.</div></div><div><div>v=0.</div></div><div><div>o=- 1377005946728952 1 IN IP4 172.16.230.1.</div>
</div><div><div>s=Bria 3 release 3.5.3 stamp 70600.</div></div><div><div>c=IN IP4 172.16.230.1.</div></div><div><div>t=0 0.</div></div><div><div>m=audio 52448 RTP/AVP 8 18 101.</div></div><div><div>a=rtpmap:18 G729/8000.</div>
</div><div><div>a=fmtp:18 annexb=yes.</div></div><div><div>a=rtpmap:101 telephone-event/8000.</div></div><div><div>a=fmtp:101 0-15.</div></div><div><div>a=sendrecv.</div></div></blockquote><div><br></div><div>Kamailio forwards with double-Record-Route with both of its addresses.  I believe this is per SIP OUTBOUND RFC:</div>
<div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>U <a href="http://10.64.5.16:5060">10.64.5.16:5060</a> -> <a href="http://41.221.230.60:5060">41.221.230.60:5060</a></div></div>
<div><div>INVITE <a href="mailto:sip%3A7171001@vc2.connection-telecom.com">sip:7171001@vc2.connection-telecom.com</a>;transport=udp SIP/2.0.</div></div><div><div>Record-Route: <sip:10.64.5.16;r2=on;lr=on;ftag=014e3010;nat=yes>.</div>
</div><div><div>Record-Route: <sip:172.16.230.128;r2=on;lr=on;ftag=014e3010;nat=yes>.</div></div><div><div>Via: SIP/2.0/UDP 10.64.5.16;branch=z9hG4bKe355.e526ca52.0.</div></div><div><div>Via: SIP/2.0/UDP 172.16.230.1:3694;branch=z9hG4bK-d8754z-6a91626ae4c3f625-1---d8754z-;rport=3694.</div>
</div><div><div>Max-Forwards: 16.</div></div><div><div>Contact: <sip:2686959@172.16.230.1:3694;transport=udp>.</div></div><div><div>To: <<a href="mailto:sip%3A7171001@vc2.connection-telecom.com">sip:7171001@vc2.connection-telecom.com</a>>.</div>
</div><div><div>From: "vc2 2686959"<<a href="mailto:sip%3A2686959@vc2.connection-telecom.com">sip:2686959@vc2.connection-telecom.com</a>>;tag=014e3010.</div></div><div><div>Call-ID: ZDQ4YThjNzEzOTBhOTE5NGViNTFhM2Q5MTY2ZmY1ZDc.</div>
</div><div><div>CSeq: 2 INVITE.</div></div><div><div>Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO.</div></div><div><div>Content-Type: application/sdp.</div></div><div><div>Proxy-Authorization: ...some stuff...</div>
</div><div><div>Supported: replaces.</div></div><div><div>User-Agent: Bria 3 release 3.5.3 stamp 70600.</div></div><div><div>Content-Length: 270.</div></div><div><div>P-hint: outbound.</div></div><div><div>.</div></div><div>
<div>v=0.</div></div><div><div>o=- 1377005946728952 1 IN IP4 10.64.5.16.</div></div><div><div>s=Bria 3 release 3.5.3 stamp 70600.</div></div><div><div>c=IN IP4 10.64.5.16.</div></div><div><div>t=0 0.</div></div><div><div>
m=audio 59194 RTP/AVP 8 18 101.</div></div><div><div>a=rtpmap:18 G729/8000.</div></div><div><div>a=fmtp:18 annexb=yes.</div></div><div><div>a=rtpmap:101 telephone-event/8000.</div></div><div><div>a=fmtp:101 0-15.</div></div>
<div><div>a=sendrecv.</div></div><div><div>a=nortpproxy:yes.</div></div></blockquote><div><br></div><div>So that behaviour seems OK.  The call does get correctly established and rtpproxy is correctly setup and audio passes in both directions.</div>
<div><br></div><div><br></div><div>But when the BYE is sent (from the outside), though, things go wrong:</div><div><br></div><div>Here's what arrives from upstream.  Route: has the two entries per the RR that was sent.</div>
<div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>U <a href="http://41.221.230.60:5060">41.221.230.60:5060</a> -> <a href="http://10.64.5.16:5060">10.64.5.16:5060</a></div></div>
<div><div>BYE sip:2686959@10.64.5.16:5060;transport=udp SIP/2.0.</div></div><div><div>Record-Route: <sip:41.221.230.60;lr=on;ftag=as70703d1c>.</div></div><div><div>Via: SIP/2.0/UDP 41.221.230.60;branch=z9hG4bKbd37.4108b6b2.0.</div>
</div><div><div>Via: SIP/2.0/UDP 41.221.230.60:5070;received=41.221.230.60;branch=z9hG4bK4e6b38bf;rport=5070.</div></div><div><div>Route: <sip:10.64.5.16;r2=on;lr=on;ftag=014e3010;nat=yes>,<sip:172.16.230.128;r2=on;lr=on;ftag=014e3010;nat=yes>.</div>
</div><div><div>Max-Forwards: 69.</div></div><div><div>From: <<a href="mailto:sip%3A7171001@vc2.connection-telecom.com">sip:7171001@vc2.connection-telecom.com</a>>;tag=as70703d1c.</div></div><div><div>To: "vc2 2686959"<<a href="mailto:sip%3A2686959@vc2.connection-telecom.com">sip:2686959@vc2.connection-telecom.com</a>>;tag=014e3010.</div>
</div><div><div>Call-ID: ZDQ4YThjNzEzOTBhOTE5NGViNTFhM2Q5MTY2ZmY1ZDc.</div></div><div><div>CSeq: 102 BYE.</div></div><div><div>User-Agent: Enswitch.</div></div><div><div>X-Asterisk-HangupCause: Normal Clearing.</div></div>
<div><div>X-Asterisk-HangupCauseCode: 16.</div></div><div><div>Content-Length: 0.</div></div><div><div>X-Enswitch-RURI: sip:2686959@10.64.5.16:5060;transport=udp.</div></div><div><div>X-Enswitch-Source: <a href="http://41.221.230.60:5070">41.221.230.60:5070</a>.</div>
</div><div><div>.</div></div><div><br></div><div><br></div></blockquote>So Kamailio peels off the first route and then sends the BYE actually to itself.  With an oddly formed blank Route: header.<div><br></div><div><div>Tracing through the kamailio.cfg the BYE is processed in WITHINDLG - loose_route() succeeds</div>
<div><br></div><div>It logs that 172.16.230.128 "is loose router".</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div><div><br></div></div><div><div>U <a href="http://10.64.5.16:5060">10.64.5.16:5060</a> -> <a href="http://172.16.230.128:5060">172.16.230.128:5060</a></div></div><div><div>BYE sip:172.16.230.128;r2=on;lr=on;ftag=014e3010;nat=yes SIP/2.0.</div>
</div><div><div>Record-Route: <sip:41.221.230.60;lr=on;ftag=as70703d1c>.</div></div><div><div>Via: SIP/2.0/UDP 10.64.5.16;branch=z9hG4bKbd37.25d16bf3.0.</div></div><div><div>Via: SIP/2.0/UDP 41.221.230.60;rport=5060;branch=z9hG4bKbd37.4108b6b2.0.</div>
</div><div><div>Via: SIP/2.0/UDP 41.221.230.60:5070;received=41.221.230.60;branch=z9hG4bK4e6b38bf;rport=5070.</div></div><div><div>Route: .</div></div><div><div>Max-Forwards: 16.</div></div><div><div>From: <<a href="mailto:sip%3A7171001@vc2.connection-telecom.com">sip:7171001@vc2.connection-telecom.com</a>>;tag=as70703d1c.</div>
</div><div><div>To: "vc2 2686959"<<a href="mailto:sip%3A2686959@vc2.connection-telecom.com">sip:2686959@vc2.connection-telecom.com</a>>;tag=014e3010.</div></div><div><div>Call-ID: ZDQ4YThjNzEzOTBhOTE5NGViNTFhM2Q5MTY2ZmY1ZDc.</div>
</div><div><div>CSeq: 102 BYE.</div></div><div><div>User-Agent: Enswitch.</div></div><div><div>X-Asterisk-HangupCause: Normal Clearing.</div></div><div><div>X-Asterisk-HangupCauseCode: 16.</div></div><div><div>Content-Length: 0.</div>
</div><div><div>X-Enswitch-RURI: sip:2686959@10.64.5.16:5060;transport=udp.</div></div><div><div>X-Enswitch-Source: <a href="http://41.221.230.60:5070">41.221.230.60:5070</a>.</div></div><div><div>.</div></div><div><div><br>
</div></div></blockquote><div><br></div><div>When Kamailio receives the BYE from itself it sends a 404 Not here.  Which is forwarded back upstream.  This 404 Not here is generated in WITHINDLG too; looks like loose_route() fails (which makes sense since there is nothing in the Route header), and in that case WINTHINDLG only has code for dealing with SUBSCRIBE and ACK.<br>
</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>U <a href="http://172.16.230.128:5060">172.16.230.128:5060</a> -> <a href="http://10.64.5.16:5060">10.64.5.16:5060</a><br></div>
<div><div>SIP/2.0 404 Not here.</div></div><div><div>Via: SIP/2.0/UDP 10.64.5.16;branch=z9hG4bKbd37.25d16bf3.0;rport=5060.</div></div><div><div>Via: SIP/2.0/UDP 41.221.230.60;rport=5060;branch=z9hG4bKbd37.4108b6b2.0.</div>
</div><div><div>Via: SIP/2.0/UDP 41.221.230.60:5070;received=41.221.230.60;branch=z9hG4bK4e6b38bf;rport=5070.</div></div><div><div>From: <<a href="mailto:sip%3A7171001@vc2.connection-telecom.com">sip:7171001@vc2.connection-telecom.com</a>>;tag=as70703d1c.</div>
</div><div><div>To: "vc2 2686959"<<a href="mailto:sip%3A2686959@vc2.connection-telecom.com">sip:2686959@vc2.connection-telecom.com</a>>;tag=014e3010.</div></div><div><div>Call-ID: ZDQ4YThjNzEzOTBhOTE5NGViNTFhM2Q5MTY2ZmY1ZDc.</div>
</div><div><div>CSeq: 102 BYE.</div></div><div><div>Server: kamailio (4.0.3 (i386/linux)).</div></div><div><div>Content-Length: 0.</div></div><div><div>.</div></div><div><div><br></div></div><div><div><br></div></div><div>
<div>U <a href="http://10.64.5.16:5060">10.64.5.16:5060</a> -> <a href="http://41.221.230.60:5060">41.221.230.60:5060</a></div></div><div><div>SIP/2.0 404 Not here.</div></div><div><div>Via: SIP/2.0/UDP 41.221.230.60;rport=5060;branch=z9hG4bKbd37.4108b6b2.0.</div>
</div><div><div>Via: SIP/2.0/UDP 41.221.230.60:5070;received=41.221.230.60;branch=z9hG4bK4e6b38bf;rport=5070.</div></div><div><div>From: <<a href="mailto:sip%3A7171001@vc2.connection-telecom.com">sip:7171001@vc2.connection-telecom.com</a>>;tag=as70703d1c.</div>
</div><div><div>To: "vc2 2686959"<<a href="mailto:sip%3A2686959@vc2.connection-telecom.com">sip:2686959@vc2.connection-telecom.com</a>>;tag=014e3010.</div></div><div><div>Call-ID: ZDQ4YThjNzEzOTBhOTE5NGViNTFhM2Q5MTY2ZmY1ZDc.</div>
</div><div><div>CSeq: 102 BYE.</div></div><div><div>Server: kamailio (4.0.3 (i386/linux)).</div></div><div><div>Content-Length: 0.</div></div><div><div>.</div></div></blockquote><div><br></div><div><br></div><div>I tried with enable_double_rr as 0 and that did send only one Record-Route with the relayed INVITE, but the record route uses the inside address of the proxy and so we never even receive the BYE from the upstream system in that case.</div>
<div><br></div><div>I'm kinda lost about where this is going wrong - so pointers would be welcome!</div><div><br></div><div>Thanks,</div><div>Steve</div><div><br></div><div><br></div><div><br></div><div><br></div></div>
</div>