Summary
- RFC 2543 gave a Via branch one modest job: telling apart the parallel copies a forking proxy made. RFC 3261 made the branch mandatory and unique across space and time, which turned it into a transaction identifier.
- The prefix
z9hG4bKis a compatibility marker, not a secret. It tells a receiver to apply the compact RFC 3261 matching rule, while a multi-field fallback stays alive for older traffic. - Retransmissions keep a branch, new forwarding attempts get fresh ones, and CANCEL plus non-2xx ACK deliberately reuse one. Those exceptions draw the transaction boundary rather than blur it.
Before the cookie, a branch only separated a fork
A SIP request rarely travels alone. It crosses proxies, and each stateful hop receives one message, picks one or more next targets, and spins up a local client transaction for every attempt it makes. Responses come home stacked along the Via values the route accumulated.
The first SIP standard, RFC 2543, already carried a branch parameter. Its promise was modest. A forking proxy inserted one so responses from parallel copies could be handed to the right virtual client. A non-forking proxy was permitted to insert one but never obliged to. The token only had to be unique among the isomorphic requests inside that single fork.
So the branch was one clue among several. RFC 2543 matched responses using To, From, Call-ID, CSeq and the first Via branch, and request handling reasoned about call legs and sequence numbers. The protocol worked. What it could not do was let a server glance at an arbitrary branch and conclude, with confidence, that it was looking at a transaction identifier governed by one uniform uniqueness rule.
That gap matters the moment old and new implementations share a network. Change what a field means without marking the change, and the receiver is left guessing. The sender knows which rule it obeyed. The receiver pays for being wrong.
Seven characters selected a new matching law
RFC 3261 rewrote the contract in 2002. A user-agent client had to place a Via at the top of every request, that Via had to contain a branch, and — with defined exceptions — the value had to be unique across space and time for every request that user agent sent.
The branch also had to begin with z9hG4bK. Those characters encode nothing: no date, no vendor, no route, no identity. The specification simply picked seven unlikely symbols so that an RFC 2543 implementation would never produce them by accident. On receipt, the prefix announces that the rest of the token was built under the RFC 3261 uniqueness rule.
Which is why “magic cookie” misleads a modern reader. It is not a browser cookie, a credential or a random challenge. It is a version witness embedded in the very value whose interpretation changed. Nobody had to ask a registry whether a peer was modern. The receiver could inspect the request and choose its matching law on the spot.
A transaction became locally matchable
For a cookie-bearing request, a server transaction matches on three facts: the branch in the top Via, that Via's sent-by value, and the method. ACK gets a specific exception, because a non-success ACK belongs to the INVITE transaction it acknowledges. Sent-by is not decoration either — two clients can duplicate a branch, by accident or on purpose.
If the branch is missing or lacks the cookie, the server does not pretend the new promise exists. It falls back to the RFC 2543 compatibility procedure, comparing Request-URI, tags, Call-ID, CSeq and the top Via as applicable. Two compatibility sets, kept side by side, never confused.
Responses match on the top Via branch plus the CSeq method. The method is essential: CANCEL is a different transaction even though it shares the branch it targets. A matching token narrows the search. It never erases the meaning of the fields around it.
The examples in RFC 3665 make the layering visible. Each proxy adds its own Via and branch on the outbound path; the matching value is stripped as the response returns. The identifier is local to one adjacent client-server transaction. It is not a global name for the call.
The same attempt must reproduce the same branch
A stateful proxy hands every outgoing attempt a new branch. If one target fails and the proxy tries another address, that is a new client transaction and it needs a different token. If a request returns to the proxy after its processing inputs have changed, it can be a legitimate spiral rather than a loop — and an implementation doing loop detection can fold those inputs into a separable component of the branch.
A retransmission is the mirror case. It is another copy of the same attempt and must carry the same branch, so the server finds existing state and resends the stored response instead of executing the request twice.
That creates a subtle trap for stateless proxies, which keep no table saying which packet is a retransmission. Fresh randomness on every receipt would shatter one transaction into many. RFC 3261 therefore requires the stable part of a stateless branch to be derived from request fields and configuration that do not change between retransmissions. Uniqueness and reproducibility have to be satisfied at the same time.
CANCEL reused identity without sharing completion
CANCEL has to find the exact pending request along the same hop-by-hop route. It copies the Request-URI, Call-ID, tags, CSeq number, top Via and branch of that request, changing only the CSeq method to CANCEL. A stateless proxy can therefore make the identical forwarding choice.
Yet CANCEL is a transaction in its own right. A server may answer it with 200 while the original INVITE separately ends with 487, with another final response, or with a response that had already won the race. A successful CANCEL proves it matched and was accepted for processing. It does not retroactively rewrite the outcome of the transaction it interrupted.
RFC 3261 pulled the two apart after RFC 2543 had tangled them together. Reusing the branch is correlation, not shared fate.
ACK split at the final-response class
An ACK for a non-2xx final response stays inside the INVITE transaction. It repeats the INVITE's top Via and branch, changes the method to ACK, and is absorbed by the transaction state machine. The proxy chain that carried the failure also carries its acknowledgment.
A 2xx response behaves differently. A fork can produce more than one accepted dialog, and every success must reach the caller. The user-agent core — not each proxy transaction — acknowledges those responses end to end. The 2xx ACK sits outside the original INVITE transaction and follows the dialog route with a freshly constructed Via branch.
The split is not ceremonial. Reusing the negative-response branch lets an existing hop suppress retransmission of a single failure. Creating a new exchange for success stops an intermediate transaction from quietly hiding a second accepted destination.
Later repairs changed lifetime, not identity
Transaction identity did not cure every state-machine defect. RFC 4320 corrected non-INVITE response and timeout behaviour. RFC 6026 later added an Accepted state and Timer L, so a server retained enough INVITE transaction state to absorb retransmissions after sending a 2xx.
RFC 6026 also kept special handling for a legacy ACK whose branch lacks the RFC 3261 cookie. The detail confirms the marker's staying power: state lifetime can be repaired, but the receiver still needs to know which identity assumptions the sender actually supplied. RFC 5359 documents later service flows using the branch convention — evidence of the specified operating grammar, not a census of implementations.
What the marker never proved
Anyone can type z9hG4bK. The prefix does not authenticate a user, authorise a call, protect message integrity or prove that the rest of the branch is unique. TLS can protect a hop, digest authentication can stake a credential claim, and application policy can decide whether to accept a request. None of those duties belongs to the cookie.
Nor is a transaction a dialog. Call-ID and tags identify dialog relationships. Route sets guide later requests. Media negotiation and RTP carry their own state. A correct branch match proves exactly one thing: that a received message belongs to the local transaction state selected by the matching rules.
The historical achievement is narrower than the legend and far more durable. SIP changed a field's contract without forcing every receiver to infer the change from institutional status, vendor reputation or surrounding behaviour. Seven visible characters selected an executable rule — and the rule stopped precisely at the boundary it could actually verify.
Sources and evidence limits
The closed evidence set consists of RFC 2543, RFC 3261, RFC 3665, RFC 4320, RFC 5359 and RFC 6026. They establish protocol history, matching rules, examples and later corrections. They do not establish present deployment share, product conformance, call quality or the absence of branch collisions.
Member Briefing
Read the full trend briefing
Members read the full briefing with the source notes behind every finding.
Strategic Circle
A daily briefing in your language, built from changes we have verified.
Join for USD 20/monthCancel anytime.
Members also get the full research library, a daily briefing on the networks they follow and the private forum.






