The SIP URI in the “Contact” header field of the SIP message, refers to a specific device. This URI should be global (can be used by anyone on the internet) otherwise the call will not be established to that device. This address will be mapped to what is called Address of Record (AOR) after the registration of the user. This mapping will be stored in a database accessed by the registrar/proxy.
Address of Record (AOR): This address represents the user. This address does not have a dependency on any device. So this address can move between devices and can be associated with multiple devices at the same time. Example: firstname.lastname@example.org. This is seen in the From, To, and (generally) Request-URI header field.
Contact Address: This address is associated with a particular device (<=> user agent). Examples: sip:email@example.com, sip:binan@IP-Address, or just sip:IP-Address. This address is seen in the Contact header field of the SIP message. If the client is behind a NAT, then a client-based or server-based procedure must be taken to fix the IP address.
Association between AOR and Contact Addresses
The SIP client sends REGISTER SIP Request to the registrar/proxy to temporarily associate its contact address with the user AOR. In this way the proxy can route the SIP requests (that are sent to the AOR) to the associated device. The mapping between AOR and the device is stored in the database of the registrar/proxy. The user needs to periodically send REGISTER Request to maintain this association or update it. In SIP a single user (<=> one AOR) can have a number of user agents (<=> number of contact addresses).
Why GRUU ?
GRUU is a SIP URI points to specific user agent. In this way we can route a call (sent to an AOR) to a specific user agent. For example a call with Request-URI = sip:firstname.lastname@example.org ;gr=urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6 will be routed to the contact address associated with gr parameter . The gr parameter is an index points to the contact address of the user agent who is registered for this GRUU.
Creation of a GRUU URI -Example
The GRUU is a SIP URI created by the Registrar/Proxy of the domain.The UAC includes “Supported:gruu” header field in a REGISTER request and provides an instance ID in the “+sip.instance” Contact header field parameter. For example the REGISTER SIP request can look like:
REGISTER sip:example.com SIP/2.0 Via: SIP/2.0/UDP 192.0.2.1;branch=z9hG4bKnashds7 Max-Forwards: 70 From: binan <sip:email@example.com>;tag=a73kszlfl Supported: gruu To: binan <sip:firstname.lastname@example.org> Call-ID: 1j9FpLxk3uxtm8tn@192.0.2.1 CSeq: 1 REGISTER Contact: <sip:email@example.com> ;+sip.instance="<urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6>" Content-Length: 0
The proxy/registrar uses the Instance-ID , generates the gruu, and send it in the response. This is the response:
SIP/2.0 200 OK Via: SIP/2.0/UDP 192.0.2.1;branch=z9hG4bKnashds7 From: binan <sip:firstname.lastname@example.org>;tag=a73kszlfl To: binan <sip:email@example.com> ;tag=b88sn Call-ID: 1j9FpLxk3uxtm8tn@192.0.2.1 CSeq: 1 REGISTER <allOneLine> Contact: <sip:firstname.lastname@example.org> ;pub-gruu="sip:email@example.com;gr=urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6" ;temp-gruu="sip:firstname.lastname@example.org;gr" ;+sip.instance="<urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6>" ;expires=3600 </allOneLine> Content-Length: 0
The “temp-gruu” and “pub-gruu” are “Contact” header field parameters.
- The “pub-gruu” It exposes the underlying AOR. Constructed by setting the Instance-ID as a value of the “gr” parameter. It is valid as long as the registration is refreshed.
- The “temp-gruu” changes each time the registration is refreshed. It hides the underlying AOR.
OpenSIPS GRUU Support
OpenSIPS Registrar module includes GRUU support. I would like to mention two important issues:
- When OpenSIPS receives a SIP REGISTER Request like the one in the example above, the function save() will be called. Upon calling this function, the Instance-ID (f81d4fae-7dec-11d0-a765-00a0c91e6bf6) and the contact address (sip:email@example.com) in the user Location table. Then it generates the gruu, and send it in the response.
- When OpenSIPS receives a call (INVITE Request) in its domain, it checks the Request-URI. If the Request-URI is a GRUU (pub-gruu or temp-gruu), the proxy will route the request just to the contact address indexed by the Instance-ID. Using gr parameter as an index for user location table.