Markus
2013-Apr-16 19:19 UTC
[asterisk-users] On SIP INVITE answering to IP:port found in Contact: header.
Hi list! I'm trying to get a DID routed to me and the provider seems to have an unusual setup. Or maybe not? From looking at their SIP header they are using "BroadWorks". The problem: they're sending their SIP invite from port 36252. My Asterisk 10.7.1 is answering to that port 36252 but their BroadWorks thingie is not listening on that port, but instead on port 5060. So they want me to send my SIP responses to the IP:port they send via the Contact: header. Here's the output from tcpdump (1.1.1.1 = them; 2.2.2.2 = me): IP 1.1.1.1.36252 > 2.2.2.2.5060: UDP, length 845 [...] Contact:<sip:1.1.1.1:5060> [...] My Asterisk' reply: IP 2.2.2.2.5060 > 1.1.1.1.36252: UDP, length 602 [...] I tried the following in the peer config in sip.conf: host=1.1.1.1 type=peer insecure=port,invite port=5060 But that didn't change anything. How can I tell Asterisk to honor and use the info found in Contact: when sending its replies? Thank you! Markus
Matthew J. Roth
2013-Apr-16 23:31 UTC
[asterisk-users] On SIP INVITE answering to IP:port found in Contact: header.
Markus, I think I know what's wrong here but I did a fair amount of research while digging into your problem. I may have misinterpreted something along the way so you should also consider other responses, especially if they come from someone who claims greater expertise. I did this to help you and to learn, so I would appreciate your feedback and welcome any corrections from more knowledgeable list members. Now on with the show. My responses are inline.> I'm trying to get a DID routed to me and the provider seems to have an > unusual setup. Or maybe not? From looking at their SIP header they are > using "BroadWorks".Using BroadWorks isn't unusual, but the rest of what you described is.> The problem: they're sending their SIP invite from port 36252. My > Asterisk 10.7.1 is answering to that port 36252 but their BroadWorks > thingie is not listening on that port, but instead on port 5060. So they > want me to send my SIP responses to the IP:port they send via the > Contact: header.That's where it got weird. From RFC 3261 [1]: While the Via header field tells other elements where to send the response, the Contact header field tells other elements where to send future requests. ... The Contact header field provides a SIP or SIPS URI that can be used to contact that specific instance of the UA for subsequent requests. ... The Via header field indicates the transport used for the transaction and identifies the location where the response is to be sent. ... A Via header field value contains the transport protocol used to send the message, the client's host name or network address, and possibly the port number at which it wishes to receive responses.> Here's the output from tcpdump (1.1.1.1 = them; 2.2.2.2 = me): > > IP 1.1.1.1.36252 > 2.2.2.2.5060: UDP, length 845 > [...] > Contact:<sip:1.1.1.1:5060> > [...] > > My Asterisk' reply: > > IP 2.2.2.2.5060 > 1.1.1.1.36252: UDP, length 602 > [...]Their INVITES are requests and your Asterisk's replies (e.g. 100 Trying, 183 Session Progress, 200 OK) are responses. As the RFC specifies, the Contact header field applies to future requests. However, it is the Via header field that is used to route responses [2][3].> I tried the following in the peer config in sip.conf: > > host=1.1.1.1 > type=peer > insecure=port,invite > port=5060 > > But that didn't change anything. > > How can I tell Asterisk to honor and use the info found in Contact: when > sending its replies?I don't think that you can, because Asterisk is probably just following the specification and sending responses back to whatever IP and port are in the Via header of the INVITE. It's hard to say with certainty without seeing the entire SIP dialog, but I think the provider needs to modify their INVITE to have a Via header like the following: Via: SIP/2.0/UDP 1.1.1.1:5060;branch=z9hG4bK2e91efaf [1] http://www.ietf.org/rfc/rfc3261.txt [2] https://lists.cs.columbia.edu/pipermail/sip-implementors/2005-December/011517.html [3] http://www.sipknowledge.com/faq_child5.htm#q2.12 Regards, Matthew Roth InterMedia Marketing Solutions Software Engineer and Systems Developer
Joshua Colp
2013-Apr-16 23:34 UTC
[asterisk-users] On SIP INVITE answering to IP:port found in Contact: header.
Markus wrote:> Hi list! > > I'm trying to get a DID routed to me and the provider seems to have an > unusual setup. Or maybe not? From looking at their SIP header they are > using "BroadWorks". > > The problem: they're sending their SIP invite from port 36252. My > Asterisk 10.7.1 is answering to that port 36252 but their BroadWorks > thingie is not listening on that port, but instead on port 5060. So they > want me to send my SIP responses to the IP:port they send via the > Contact: header.If you set nat=no for that specific peer it should work as you need. 'rport' is forced on these days which works for most situations, except with some platforms and Cisco phones. >_> -- Joshua Colp Digium, Inc. | Senior Software Developer 445 Jan Davis Drive NW - Huntsville, AL 35806 - USA Check us out at: www.digium.com & www.asterisk.org