e-speak

Architectural Differences in SIP and XMPP Presence

By Nadia Ferrante

Engineers tasked with adding real-time voice, messaging, and user availability into a single infrastructure footprint frequently treat Session Initiation Protocol (SIP) and the Extensible Messaging and Presence Protocol (XMPP) as interchangeable signaling layers. They are not. Their architectural assumptions conflict because they were designed to optimize for entirely different network behaviors.

SIP was engineered to establish point-to-point and multipoint media sessions across heterogeneous network boundaries where intermediate proxies maintain no media state and minimal transaction state. XMPP was engineered to maintain long-lived, stateful XML streams between clients and servers to route asynchronous structured data, predominantly presence and short text payloads.

When voice systems fail at scale, the failure is rarely inside the RTP media pipeline itself; it is almost always caused by misapplying the signaling layer to state-synchronization problems it was never built to handle.

Session Establishment Versus Continuous Stream Primitives — what actually happens?

To understand why these protocols diverge when handling availability, you must isolate their transport and transaction lifecycles.

The Transactional Overhead of SIP

SIP, defined in RFC 3261, is an end-to-end, text-based request-response protocol explicitly modeled on HTTP. Every discrete action is modeled as an independent transaction consisting of a request method (such as INVITE, BYE, or OPTIONS) and at least one response code (such as 100 Trying or 200 OK).

The standard explicitly limits its own scope:

"SIP is not a vertically integrated communications system. SIP is rather a component that can be used with other IETF protocols to build a complete multimedia architecture." (RFC 3261, Section 2)

SIP relies on Session Description Protocol (SDP) payloads to negotiate endpoints, codecs, transport ports, and encryption parameters. A minimal SIP INVITE carrying SDP easily exceeds 800 to 1000 bytes. Because SIP frequently runs over UDP to avoid head-of-line blocking and connection setup latencies, it must implement its own retransmission timers. SIP Timer T1 defaults to 500 ms, doubling on every retransmission. If a message approaches or exceeds the path Maximum Transmission Unit (MTU)—typically 1500 bytes on standard Ethernet—IP fragmentation occurs. If a single fragment drops, the entire SIP transaction fails, causing retransmission storms across stateful proxies.

SIP state machines are memory-intensive. An intermediate SIP proxy handling a dialog must track the Call-ID, local and remote tags, the CSeq sequence number, and the Record-Route header chain. This overhead is rational when setting up a voice call that will last several minutes and exchange megabytes of media via RTP. It is disastrously inefficient for high-frequency updates.

Stream-Based Framing in XMPP

XMPP, defined in RFC 6120, does not use request-response transactions over stateless datagrams. It operates over a continuous, bidirectional XML stream negotiated over a single, long-lived TCP or TLS connection.

After initial stream negotiation—which includes TLS establishment, SASL authentication, and resource binding—the framing overhead per message drops substantially. The communication primitive is the XML stanza: , , or . There are no repeated hop-by-hop routing headers, no Via or Record-Route chains injected into each stanza, and no repeated cryptographic handshakes per transaction.

While SIP generates new transactions with full header sets for every event, XMPP pushes stanzas across an open pipe. A basic availability update in XMPP requires fewer than 100 bytes over the wire. However, XMPP couples the signaling transport to TCP. If TCP connection state drops—due to NAT timeouts or network transitions—the stream terminates, tearing down all established session bindings unless stream management mechanisms (such as XEP-0198, though I would check the specific client implementation) are explicitly implemented and supported by both endpoints.

Presence Mechanics and the Subscription Scalability Problem — what actually happens?

Presence is not merely the boolean state of being online or offline. Presence represents an entity's availability, capabilities, device state, and reachability. The mechanisms used by SIP and XMPP to distribute this state expose the fundamental divide between them.

SIP Event Notifications and State Explosion

RFC 3261 does not define presence. Presence in SIP was added via extensions: RFC 6665 (which obsoleted RFC 3265) defines the SIP-Specific Event Notification framework, and RFC 3856 defines the presence event package.

Under RFC 6665, presence requires an active dialog established via a SUBSCRIBE request sent from the watcher to the presentity (or a presence agent). The presence agent accepts the subscription with a 200 OK and immediately fires an initial NOTIFY request containing the presentity's state formatted in Presence Information Data Format (PIDF, RFC 3863). The watcher must acknowledge this NOTIFY with its own 200 OK.

Consider a system with 1,000 users. If each user maintains a contact list (roster) containing 100 other users:

If that user toggles presence rapidly, the SIP proxy infrastructure faces an $O(N)$ transaction storm per change, where $N$ is the number of watchers. The memory footprint inside stateful SIP proxies for managing tens of thousands of active dialog timers, combined with parsing multi-kilobyte XML PIDF payloads wrapped in SIP envelopes, routinely exhausts socket buffers and CPU cycles. SIP presence does not scale natively without complex, non-standard presence server aggregations and subscription throttling.

Server-Side Roster Fanout in XMPP

XMPP solves presence at the architecture layer rather than through an auxiliary request-response event package. RFC 6121 defines presence handling as a native publish-subscribe mechanism built directly into the server routing core.

In XMPP, the server maintains the user's roster (contact list). The client does not initiate separate end-to-end subscriptions to every individual peer over the wire. Instead, upon authenticating and binding a resource, the client transmits a single inbound stanza:

`xml `

The local XMPP server intercepts this stanza, queries the user's roster from persistent storage, determines the set of active JIDs authorized to observe that presence, and performs server-side broadcast fanout. If 100 contacts are online across different domains, the client still transmits only one stanza over its local C2S (client-to-server) connection. The server handles distribution over existing S2S (server-to-server) multiplexed connections.

Subscribing to a contact's presence is a discrete, asynchronous handshake () that modifies the persistent roster state. It does not construct an ephemeral signaling dialog that requires periodic refresh pings over the client link. By offloading roster state and presence broadcast logic entirely to the server infrastructure, XMPP scales presence updates to thousands of concurrent roster entries with minimal client-side bandwidth and zero end-to-end transaction overhead.

Real-Time Audio Transport and Network Degradation

While XMPP excels at continuous presence routing, SIP remains the undisputed standard for real-time voice infrastructure. Understanding why requires examining the boundary between the signaling plane and the media plane.

Voice systems do not pass media over the signaling channel. They use SIP to negotiate direct Real-time Transport Protocol (RFC 3550) streams running over UDP. A typical voice payload, such as G.711 (PCMU/PCMA), transmits a 20 ms audio frame inside every packet at a constant bitrate of 64 kbps, with an additional 40 bytes per packet consumed by IP, UDP, and RTP headers. Modern systems running Opus typically target bitrates between 16 kbps and 32 kbps, often utilizing dynamic packetization intervals.

Failure Modes Under Packet Loss and Jitter

Under network degradation, real-time voice behavior is strictly governed by UDP mechanics, jitter buffers, and codec concealment. When packet loss exceeds 5% or packet jitter swings past 30 ms over a 150 ms period, synchronous communications degrade rapidly.

If jitter exceeds the adaptive jitter buffer's dynamic threshold (usually capped around 100 ms to preserve interactive conversational latency under the ITU-T G.114 target of 150 ms one-way delay), the buffer suffers underruns. Late packets are treated as lost and discarded entirely. The audio decoder engages Packet Loss Concealment (PLC), synthesizing audio pitch periods from preceding frames.

If loss persists across 3 consecutive 20 ms frames (a 60 ms gap), PLC artifacts manifest as audible clicks, chirps, or muting. Opus mitigates this only if In-Band Forward Error Correction (in-band FEC) or Low Bitrate Redundancy (LBRR) is explicitly signaled during the SDP offer/answer exchange, requiring the encoder to append redundant data from packet $N-1$ into packet $N$ at the cost of increased bandwidth.

If signaling traffic shares this congested UDP link, SIP timers compound the failure: Timer T1 fires at 500 ms, retrying the request; if the loss is sustained, Timer B expires after 32 seconds (64 times T1), terminating the call setup entirely.

Attempting to run real-time audio through stream-oriented connections like TCP creates an immediate structural flaw. If a single audio frame is lost on a TCP connection, the receiving OS kernel halts delivery of all subsequent frames to the application until the missing segment is retransmitted and acknowledged. By the time the retransmitted audio segment arrives 200 ms later, it is completely useless for interactive human conversation, yet it has blocked the decoding of subsequent, valid speech frames.

XMPP attempted to address this with Jingle (XEP-0166), which uses XMPP's XML stream strictly for signaling and offloads the media to out-of-band UDP/RTP transport, structurally mirroring SIP's separation of concerns. However, the telecom world, carrier Session Border Controllers (SBCs), Public Switched Telephone Network (PSTN) gateways, and regulatory emergency interfaces (E911) natively speak SIP and SDP. Introducing XMPP into the carrier-interconnect voice path requires protocol conversion proxies that introduce state translation vulnerabilities and latency without solving any problem that SIP does not already solve at the session boundary.

---

The practical rule is clear: use SIP to negotiate the start, modification, and termination of real-time UDP media streams; use XMPP to distribute user presence, state synchronization, and continuous metadata across persistent connections.

Quick reference

A codec is an algorithm that compresses audio for transmission. A frame is the block of samples encoded at once. Lookahead is the delay a codec needs before it can begin encoding.