Call-ID and Branch tags in SIP protocol
Asked Answered
R

3

7

I am developing a SIP client. I understand SIP requests and SIP responses but, in SIP messages, how are the call id and branch tags generated? RFC3261 does not specify this.

Replica answered 15/5, 2012 at 23:27 Comment(0)
J
16

The Call-ID header value can be anything you want but does need to be unique in order to avoid requests getting classified as duplicates.

THe branch parameter on a Via header needs to start with the magic cookie value of z9hG4bK and must also be unique to avoid the request getting classified as a duplicate. For SIP Proxy's wanting to do loop detection there is also the guideline in the RFC in section 16.6 point 8 which details factors to take when constructing the branch parameter value.

Jumbala answered 16/5, 2012 at 0:5 Comment(0)
U
2

Your wording is difficult to understand. I'm going to assume you want to know how a UAC should generate a Call-ID or how a UAC or proxy server should generate a branch parameter.

The only requirement for Call-ID is that it should be unique. It is often in the form of a unique token + "@" + a host name like email's Message-ID, but it doesn't have to be. It can be just a unique token. The unique token can be anything that is reasonably certain to be unique. In order to avoid divulging private information you can just make it pseudorandom or a cryptographic hash of private unique information (time, process ID, etc...)

Similarily, the branch parameter is just a unique token, but note that it has to start with z9hG4bK as specified in the RFC.

Useful answered 15/5, 2012 at 23:54 Comment(2)
There's no requirement for Call-ID to be in the for unique token + "@" + a host name. You'll find a lit of SIP stacks use a GUID or similar for it. Putting an IP address in the Call-ID value is actually a bad idea. I've seen SIP ALG's that mangle every private IP address they find in a SIP packet and that will screw up the Call-ID header if they happen to contain a private IP address.Jumbala
@sipwiz You're right, I've certainly seen such "bare" Call-IDs myself. I edited my answer.Useful
C
0

Why re-invent the wheel?

There are open source SIP projects and their implementation may inspire you. You didn't mention what programming language you use. So I assume you can read C code.

Get the source code of kamailio server. The implementation of Call-ID is in kamailio-4.0.x/modules/tm/callid.c. I believe you are smart and can find out about branch tags yourself :o)

Carson answered 13/3, 2014 at 22:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.