8

Usually, the Contact header field in the Invite request is useless. For example, the UAC and the UAS are in different LANs. The Contact field may be:

INVITE sip:bob@sipprovider SIP/2.0
Contact: Alice<alice@192.168.1.10>
.....

There is no use of the Contact field while we can still build a dialog. Then, why the Contact header field is mandatory?

DarkDust
  • 90,870
  • 19
  • 190
  • 224
Phoenix Luo
  • 123
  • 1
  • 1
  • 8

2 Answers2

11

The Contact header says where you are (or rather, where your User Agent is), while the From header says who you are.

You might have several SIP devices all registered to the same Address of Record (the URI you put in the From header).

Further, REGISTER requests use Contact headers to maintain SIP's location service: they let a user agent update a registrar's location information.

(As an aside, if Alice calls Bob, the Contact header needs to be in a 2xx response so that Alice can route the 2xx's ACK to Bob. This points to DarkDust's comment about some SIP proxies mangling Contact headers: if it doesn't, you find yourself in the uncomfortable position of having a call that's only half established: Alice thinks the call's set up because she sent her ACK, but Bob never receives it. An alternative to a Contact-mangling Proxy is using a B2BUA as a network gateway; it wouldn't need to mangle the Contact header because the header would point to the B2BUA itself.)

In response to Phoenix Luo's comments, because of the shortcomings of using LAN IPs in a Contact header, RFC 5627 describes a solution - using globally routable user agent URIs (GRUUs) in the Contact header/s.

Community
  • 1
  • 1
Frank Shearar
  • 17,012
  • 8
  • 67
  • 94
  • In the project i am engaging, the proxy for the location service adds Record-route header to the Invite request. So the call can be built successfully. However, the Bye request from the UAS can't be received by the UAC as what DarkDust said. – Phoenix Luo Mar 05 '12 at 01:17
  • Yes: the BYE is sent to the _user agent_ in the call, and that user agent is identified by the Contact header, not the From header. Which is why we had to invent stuff like RFC 5627 (Obtaining and Using Globally Routable User Agent URIs (GRUUs) in the Session Initiation Protocol (SIP)) – Frank Shearar Mar 05 '12 at 11:14
8

The contact field contains the address at which the callee can reach the caller for future requests. For example, it's necessary so that the callee can send a BYE or a re-INVITE to the caller.

DarkDust
  • 90,870
  • 19
  • 190
  • 224
  • Thank you. I have made a test in pjprojet. If the Contact field is as above, the BYE sent by the callee can't reach the caller. – Phoenix Luo Feb 29 '12 at 10:02
  • 1
    That might be because the Contact is a private LAN address. If your callee is in another network, it wouldn't be able to reach it. That's one thing that SIP proxies are used for: they sit at network boundaries and mangle the Contact headers so that the other party can reach the mentioned addresses. – DarkDust Feb 29 '12 at 10:07
  • Thank you. With your help, I have repaired the problem. – Phoenix Luo Mar 01 '12 at 02:08
  • Both BYEs and re-INVITEs are sent as in-dialog messages (since they modify a specific dialog), which means they are routed via the Route headers (or Via, for responses), not the Contact. Contact headers are only used for out-of-dialog messages, and the most common case I've seen of sending an out-of-dialog message to a UA that you know of via Contact header is when a REFER generates an INVITE with a Replaces header (attended transfer). – korvus Feb 01 '15 at 02:39
  • @korvus Your comment is wrong: Contact headers are only used for "in-dialog" request/answer and is re-used (in request-uri) for routing an in-dialog REQUEST such as re-INVITE/BYE/REFER/... for the final last hop of the route path. Additionnaly, it is also used for REGISTER. The reason is similar: a proxy will re-use it for request-uri, used for final hop again. – AymericM May 11 '16 at 12:18