What is the maximum length of SIP via-branch parameter without magic cookie(=z9hG4bK). I need to get a maximum count of characters for my implementation. I tried to look for maximal length of branch parameter in RFC3261 and RFC2543, but couldn't find anything.
1 Answers
The BNF definition for the via branch parameter is shown in RFC3261:
via-branch = "branch" EQUAL token
Token has no maximum length defined so there is no maximum length for this parameter.
Paragraph 8.1.1.7 states:
The branch parameter value MUST be unique across space and time for all requests sent by the UA. [...] The branch ID inserted by an element compliant with this specification MUST always begin with the characters "z9hG4bK". [...] Beyond this requirement, the precise format of the branch token is implementation-defined.
To comply with the 'unique' requirement an implementation could opt to use a GUID (see What is the string length of a GUID?), prefixed with "z9hG4bK". If you take this as max length you're pretty safe, but there is always a chance that an implementation uses another (longer) format.