I have been writing articles for this blog since June of 2013. My goal is to cover the many different aspects of unified communications with a clear emphasis on SIP. Every once in a while I push the envelope and write about something that only has a loose connection to communications, but for the most part I stick with my game plan.
Something near and dear to my nerdy heart is SIP the protocol. I love digging through call flows and figuring out what occurred. They are my puzzles and brain teasers.
My protocol indulgence for today involves one of the least understood SIP headers – Replaces. The Replaces header wasn’t in the original definition of SIP, but its need was quickly recognized and a proposal came in the form of RFC 3891. You are welcome to find and read the RFC, but I think I can tell you everything you really need to know in far less time.
Replaces allows you to swap, or replace, one leg of a SIP call with another. This is not to be confused with transfer where you change both legs.
The most obvious application of Replaces is Call Park. Image a situation where Andrew is speaking with Ellen. Andrew decides that Ellen needs to speak with John, but Andrew isn’t sure where John is. So, instead of trying to transfer the call around until he finds John, Andrew parks the call in some form of a parking lot. The parking lot will return a token to Andrew indicating the spot where the call was moved to. For this example, let’s say that the token is 33. Andrew can now use an overhead paging system to ask John to “pick up a call at 33.” John uses the token to indicate that he is calling Ellen in the parking lot. John is connected to Ellen. Essentially, Andrew’s call to Ellen has now been replaced with a call to John.
As with all headers, Replaces must be part of a SIP request. From every example I have ever seen, that request is INVITE. Looking back at the previous example, when John picked up the parked call, an INVITE with a Replaces header was sent to the parking lot.
So, what’s inside the Replaces header? Obviously, it must be something that can uniquely identify the call in question. For SIP, uniqueness comes from the Call-ID of the target call along with its To and From tags.
For a deeper discussion on call identification, please see my article, Let’s Play (SIP) Tag.
Although you won’t see a Replaces header inside a SIP REFER message, REFER is typically involved in a replaces call flow. In my example, Andrew transferred Ellen to the parking lot. Under the covers, Andrew referred Ellen to the parking lot with, what else, a REFER message.
For a more thorough explanation of REFER and transfer, please see my article, REFER Madness.
Tying all this together we see the following:
- Andrew and Ellen are speaking
- Andrew sends a REFER to Ellen directing her to the parking lot.
- Ellen sends an INVITE to the parking lot and the parking lot answers. This essentially puts Ellen on hold.
- Andrew obtains Ellen’s parking lot token. This might be accomplished by Andrew subscribing to the parking lot and receiving a SIP NOTIFY message containing the token.
- Andrew broadcasts the fact that John has a call waiting in the parking lot. John will be informed of the token ID.
- John hears the broadcast along with the token. Through some out-of-band mechanism (perhaps a webpage that matches tokens to parked call), John retrieves Ellen’s Call-ID, To tag, and From tag.
- John sends an INVITE to the parking lot. This INVITE contains a Replaces header with the retrieved Call-ID, To tag, and From tag.
- Ellen’s parked call will be replaced by the new call from John.
Let’s assume a Call-ID of 12345678, a To tag of 7744, and a From tag of 5693. This would yield a Replaces header that looks as follows:
Besides Call Park, there are other uses of Replaces. For instance, Replaces could be used to answer a call ringing on one phone on a different phone. Again, access to the ringing call’s Call-ID and tags are necessary, but an application could be written to make them available.
That’s about it for Replaces. Thank you for sticking with me. It’s nice knowing that there other folks as nerdy as I am about this stuff. Consider yourself special.