USB Packet Decoder
Decode raw USB packet bytes and inspect PID validity, packet category, token device address, endpoint number, SOF frame number, data payload, CRC fields and handshake meaning for common USB 2.0 packet types.
—
What Is a USB Packet Decoder?
A USB Packet Decoder converts packet-level hexadecimal bytes into the fields defined by the USB protocol. The first byte is the Packet Identifier, or PID, which determines whether the packet is a token, data, handshake or special packet.
The packet format after the PID depends on that category. Token packets carry device and endpoint addressing, data packets carry payload bytes and CRC16, handshake packets usually contain only the PID, and Start-of-Frame packets carry an 11-bit frame number plus CRC5.
USB PID Byte
A USB PID byte contains a four-bit packet identifier and the one’s complement of that nibble. The complement provides a simple integrity check on the PID itself.
PID byte:
0x69
Low nibble:
0x9
High nibble:
0x6
~0x9 & 0x0F:
0x6
PID complement:
VALIDCommon USB Packet IDs
| PID Byte | Packet | Category |
|---|---|---|
| 0xE1 | OUT | Token |
| 0x69 | IN | Token |
| 0x2D | SETUP | Token |
| 0xA5 | SOF | Token / SOF |
| 0xC3 | DATA0 | Data |
| 0x4B | DATA1 | Data |
| 0x87 | DATA2 | Data |
| 0x0F | MDATA | Data |
| 0xD2 | ACK | Handshake |
| 0x5A | NAK | Handshake |
| 0x1E | STALL | Handshake |
| 0x96 | NYET | Handshake |
USB Token Packet Format
PID
+
7-bit Device Address
+
4-bit Endpoint Number
+
CRC5The address, endpoint and CRC bits occupy two bytes following the PID. The fields are packed at the bit level rather than stored as separate whole bytes.
USB IN, OUT and SETUP Tokens
An OUT token tells the selected device and endpoint that the host intends to send data. An IN token requests data from a device endpoint. A SETUP token is used to begin a control transfer’s setup stage.
The token itself does not carry the setup request or application payload. That information arrives in a following DATA packet.
USB Data Packet Format
PID
+
0 to N payload bytes
+
16-bit CRCUSB data packets include DATA0, DATA1 and, for applicable higher-speed transactions, additional DATA PIDs such as DATA2 and MDATA. The data-toggle mechanism helps the endpoints distinguish new packets from retransmissions.
USB Handshake Packets
Handshake packets communicate transaction status and normally consist of only a PID byte.
ACK
Transaction accepted successfully
NAK
Endpoint temporarily cannot complete the transfer
STALL
Endpoint is halted or request is unsupported
NYET
High-speed transaction response indicating not yet readyUSB SOF Packet
A Start-of-Frame packet carries an 11-bit frame number and a five-bit CRC. Hosts transmit SOF timing packets periodically on supported USB buses.
SOF packet:
PID
11-bit Frame Number
5-bit CRCUSB Token Address and Endpoint Packing
The two token bytes after the PID form a 16-bit little-endian bit field. The lowest seven bits contain the USB device address and the following four bits contain the endpoint number.
tokenWord =
byte1 | (byte2 << 8)
Address =
tokenWord & 0x7F
Endpoint =
(tokenWord >> 7) & 0x0F
CRC5 =
(tokenWord >> 11) & 0x1FUSB CRC5 and CRC16
USB uses CRC5 for token and SOF protection and CRC16 for data packets. This calculator can display the received CRC and optionally calculate the expected CRC from the decoded packet fields or data payload.
CRC checking is useful when working with raw packet captures, but many USB analyzers or host-controller interfaces already validate CRC in hardware and may not expose the received CRC bytes.
USB Packet vs USB Descriptor
A USB packet is a low-level bus transaction unit. A USB descriptor is a structured block of device information transferred within control-transfer data stages. They are related but are not the same format.
USB packet layer:
SETUP → DATA0 → ACK
Descriptor/application layer:
Device Descriptor bytes carried inside DATA packet(s)USB Packet Decoder FAQs
What is a USB PID?
Why does a USB PID contain complemented bits?
What does USB PID 0x69 mean?
What does PID 0xE1 mean?
What does PID 0x2D mean?
What is DATA0?
What does ACK mean in USB?
What does NAK mean?
What does STALL mean?
Does this input include USB SYNC?
Can this decode USB descriptors?
Decode USB Packet Hex Bytes
Inspect USB PIDs, token addressing, endpoint numbers, SOF frames, data payloads, handshake responses and CRC fields from raw packet-level USB hexadecimal data.