SIP INVITE: Contact Header
The Contact header is mandatory to exist in the INVITE and 200 OK message, and can also be included in a REGISTER message or other responses such as 1xx, 2xx, 3xx. It consists of a display name (optional), the URI of the originator User Agent (UA) and may also contain parameters. An example of a Contact header can seen below:
Contact: A <sip:email@example.com>
where A is the display name and sip:firstname.lastname@example.org is the SIP URI of A.
But what is the use of the Contact header? The Contact header basically contains the SIP URI of the caller, that the called party can use to send future requests to. That is, requests that belong to the same dialog, such as re-INVITE, BYE and ACK messages. In other words, it says where a party can be reached. Let’s see how Contact is used within particular messages:
During a SIP session establishment process, the caller sends an INVITE, including a Contact header that contains the caller’s URI, informing in this way, the called party about where to send a future BYE request if they decide to release the call or a re-INVITE if they want to re-negotiate the session.
When the recipient receives the initial INVITE, they will process it and eventually send back a 200 OK response. In that 200 OK, the called party has the opportunity to include their own Contact header allowing the caller to know where to send future requests. Particularly, it is necessary for the caller to know the called party’s Contact information, in order to send back an ACK which acknowledges/confirms the reception of 200 OK and completes the session establishment. This ACK message, can now travel directly to the recipient bypassing all the proxies on the way. However, this behavior can be overwritten if the routing configuration or the device specifies otherwise or if a “record-route” header is used (which is added in a request by proxies that want to stay in the SIP path for future request in that dialog).
When a Back-To-Back-User-Agent (B2BUA) is used in the network, e.g. a Session Border Controller (SBC), it can be configured to re-write the Contact header of the received messages to its own URI address, so the two parties of the call will communicate only via the B2BUA device. This is usually useful for security purposes as well as for resolution of routing issues.
Note: The URI of the Contact header is used to route future requests. For the routing or SIP responses within the dialog, the VIA header is used instead.