SBE: the message header and how a decoder picks a message
Learn how the fixed header at the start of every SBE message lets a trading decoder pick the right message layout, handle schema versions and skip unknown trailing bytes.
Simple Binary Encoding (SBE) is the FIX Trading Community's fixed-offset binary format used by exchanges and trading desks for low-latency market data and order entry (how an SBE message is laid out). One live market-data stream mixes many message types—trades, top-of-book quotes, order-book snapshots, and status updates—with no field names on the wire.
Every SBE message therefore opens with a small, fixed-size message header so the decoder can immediately tell which schema and message layout apply, which schema version the sender used, and where the fixed-size body ends. This page covers the header's four fields, the exact dispatch sequence a decoder follows, why blockLength travels on the wire, and how the SBE header differs from outer framing.
The four fields
The schema declares the header as a composite, named messageHeader unless headerType overrides it. In the bundled Binance Spot Streams sample, messageHeader is 8 bytes—four uint16 fields:
blockLength: byte size of the root block (excludes the header, repeating groups, and variable-length data).templateId: message id matching<message id="…">(10000forTradesStreamEvent).schemaId: schema id matching<messageSchema id="…">(1forbinance_stream_1_0_sbe.xml,3forbinance_spot_3_6_sbe.xml).version: schema version used by the sender (0forbinance_stream_1_0_sbe.xml,6forbinance_spot_3_6_sbe.xml).
Open the Binance streams message header in the Market Data Visualizer
How a decoder dispatches
- Read the header at byte 0 of the SBE message using the schema's byte order.
- Match
schemaIdto select the protocol schema. - Match
templateIdto select the message layout. IftemplateIdis unknown and the message may contain groups or data,blockLengthalone cannot skip it—you need the outer framing length. - Read root-block fields at their schema offsets, counted from the byte immediately after the header.
- Advance
blockLengthbytes from the start of the root block to begin reading groups and variable-length data.
Why blockLength is on the wire
The root block's size is already in the schema—18 bytes for TradesStreamEvent—but sending blockLength on the wire makes schema evolution work. When a newer sender appends fields to the root block, an older decoder advances by the received blockLength and lands cleanly on the first group instead of misreading the new bytes. When an older sender omits fields added in later versions, version tells a newer decoder which sinceVersion fields are absent (schema versioning).
| Offset | Size | Name | Type | Presence | Since |
|---|---|---|---|---|---|
| 0 | 18 | TradesStreamEvent | block | 0 | |
| 0 | 8 | eventTime | utcTimestampUs | required | 0 |
| 8 | 8 | transactTime | utcTimestampUs | required | 0 |
| 16 | 1 | priceExponent | exponent8 | required | 0 |
| 17 | 1 | qtyExponent | exponent8 | required | 0 |
| 18 | 6 | trades | group groupSizeEncoding | 0 | |
| 18 | 2 | .blockLength | uint16 | ||
| 20 | 4 | .numInGroup | uint32 | ||
| 24 | 25 | [0] | entry | ||
| 24 | 8 | .id | tradeId | required | 0 |
| 32 | 8 | .price | mantissa64 | required | 0 |
| 40 | 8 | .qty | mantissa64 | required | 0 |
| 48 | 1 | .isBuyerMaker | enum boolEnum | required | 0 |
| — | 0 | .isBestMatch | const enum boolEnum | constant | 0 |
| 49 | 1 | symbol | data varString8 | 0 |
Variations and framing
- Header layouts vary by schema. Because the schema declares the header composite, a venue can widen fields or add fields. The SBE standard recommends also including
numGroupsandnumVarDataFieldsso older decoders can skip unknown groups and data fields. Inspect each venue's header composite rather than assuming 8 bytes. - The header is not the frame. It never gives total message length. On TCP streams or packet captures, an outer frame supplies total length: either the FIX Simple Open Framing Header (SOFH) (standard SOFH is a 4-byte big-endian total length including SOFH plus a 2-byte big-endian encoding type, though venues such as CME iLink 3 and B3 Binary UMDF use a 4-byte little-endian variant: a 2-byte length and a 2-byte encoding type) or a venue-specific prefix such as CME MDP 3.0's
MsgSize. See framing. In the Market Data Visualizer, layouts start after the message header, at byte 0 of the root block, until you pick a frame in the Framing select of the pane bar; then the frame and the header are drawn as layers in front of the root block.
What to check when decoding
- Verify the header's field types and total size in the venue's schema before hard-coding an 8-byte offset.
- Check both
schemaIdandtemplateIdbefore decoding; a single connection can multiplex schemas. - Never use
blockLengthto skip an unrecognizedtemplateId; rely on the framing length prefix.
See how an SBE message is laid out for the body after the header, and reading the XML message schema for headerType and schema ids.
Sources
- https://www.fixtrading.org/what-is-the-fix-protocol/
- https://cmegroupclientsite.atlassian.net/wiki/spaces/EPICSANDBOX/pages/457638617/MDP+3.0+-+SBE+Technical+Headers
- https://www.fixtrading.org/standards/sbe/
- https://github.com/FIXTradingCommunity/fix-simple-binary-encoding/blob/master/v1-0-STANDARD/doc/03MessageStructure.md
- https://github.com/FIXTradingCommunity/fix-simple-binary-encoding/blob/master/v1-0-STANDARD/doc/05SchemaExtensionMechanism.md
- https://github.com/real-logic/simple-binary-encoding/wiki/FIX-SBE-XML-Primer
- https://github.com/real-logic/simple-binary-encoding/wiki/Message-Versioning
Reviewed by Structure on 2026-11-24. Last changed 2026-11-25.