USB Packet Formats and types as per V2.0 and V3.2

The USB stands for Universal Serial Bus. It is interface similar to RS232 and RS485 but supports higher data rates at various distances. USB supports peer to peer communication. In this type of interface, communication takes place between host and peripheral and not between two hosts (or peripherals). The USB standard defines specifications for cables, connectors and protocols. It mentions requirements for connection, communication and PS (power supply) between PCs and peripheral devices.

There are various versions of USB which include v1.x, v2.x and V3.x. Each of these versions support different data rates viz. 60 Mbps, 625 Mbps and 1.25-2.5 Gbps respectively. USB 2.0 is known as high speed, USB 3.0 is known as superspeed and USB 3.2 is known as superspeedplus. USB standards support cables with length upto 5 meters. Beyond this, USB hubs are required to expand connectivity.

Let us explore USB packet formats, types and structure including USB Token packet, Data packet, SoF packet and handshake packet as per V2.0 and V3.2.

USB packets as per V2.0

• All the USB packets consists of "SYNC" at the beginning and "EOP" (End Of Packet) at the end. SYNC field is also known as preamble which is used for synchronization between device and host.
• PID (Packet ID): It is used to identify type of packet which is to be transmitted. There are 4 bits in PID field, however to insure it is received correctly, the 4 bits are complemented and repeated after initial 4 bits. Hence PID is total 8 bits in size.
PID = { PID0, PID1, PID2, PID3, PID0', nPID1', nPID2', nPID3 }
ADDR: This field specifies which device the packet is designated for. It is 7 bits in size.
ENDP (endpoint field): It is made up of 4 bits in size. It allows 16 possible endpoints.
CRC (Cyclic Redundancy Check): It is used to detect erroneous packets.It is 5 bits in size.
EOP: End of Packet.

USB PID types

USB (Universal Serial Bus) is a standardized communication protocol commonly used in computer systems and electronic devices for connecting peripherals. USB communication involves the exchange of information through a series of packets. Each USB transaction consists of several packet types, including Token packets, Data packets, Start of Frame (SOF) packets, and Handshake packets. Let us understand functions of each of these packet types as defined in USB 2.0.

USB Packet Types v2

USB Token Packet

• Function: Token packets initiate and manage USB transactions. They convey information about the type of transaction (e.g., read or write), the target device's address, and the endpoint within the device.
• Packet Structure: Token packets contain fields such as Sync, PID (Packet ID), ADDR (device address), ENDP (endpoint number), and CRC16 (Cyclic Redundancy Check for error detection).

USB Data Packet

• Function: Data packets carry the actual payload of information being transferred between the host and the device. The payload may include data from the host to the device or vice versa, depending on the transaction type.
• Packet Structure: Data packets include Sync, PID, DATA (payload), and CRC16. The payload size can vary depending on the endpoint's specifications.

USB Handshake Packet

• Function: Handshake packets acknowledge the successful receipt of data or indicate errors in the communication. They serve to confirm the completion of a data transfer or report any issues that may have occurred during the process.
• Packet Structure: Handshake packets include Sync, PID (ACK, NAK, or STALL), and CRC16. The PID field specifies the type of handshake response.

USB SoF Packet

• Function: SOF packets are used to keep devices synchronized in time. They are sent periodically to mark the beginning of each frame and help devices maintain proper timing for communication.
• Packet Structure: SOF packets contain Sync, PID (usually SOF), and Frame Number. The Frame Number field helps devices keep track of the current frame.

Conclusion In summary, these packet types work together to facilitate communication between USB devices and the host. Token packets initiate transactions, Data packets transfer information, SOF packets maintain synchronization, and Handshake packets confirm the success or failure of data transfers. The USB protocol ensures reliable and efficient communication by employing these different packet types in a structured and standardized manner.

USB packet types as per V3.2

The figure depicts USB packet types as per USB3.2 Standard. As it consists of following packets viz. LMP (Link Management Packet), TP (Transaction packet), DP (Data packet) and ITS (Isochronous Timestamp) packet.

USB Packet Types v3

There is "TYPE" field (of size: 5 bits) in all the packet types which determines how to interpret the packet. Following table mentions the same. CRC-16 or CRC-32 are used at the end of these packet types for error detection of the packets.

Value of Type Field Packet Type
00000 Link Management Packet
00100 Transaction Packet
01000 Data Packet Header
01100 Isochronous Timestamp Packet

Link Management Packet (LMP) Format

LMPs are used for link initialization, training, and management. They help establish and maintain a reliable communication link between USB devices.

USB LMP Packet Format

The figure mentions structure of LMP packet type. Here "TYPE" field is set to "00000b". Subtype field (size: 4 bits) indicate following.

Value of subtype field Packet Type
0000b Reserved
0001b Set Link Function
0010b U2 Inactivity Timeout
0011b Vendor Device Test
0100b Port Capability
0101b Port Configuration
0110b Port Configuration Response
0111b Precision Time Management
1000b-1111b Reserved

Transaction Packet (TP) Format

Transaction packets are a fundamental part of USB communication and consist of different types such as IN, OUT, SETUP, and PING. They initiate and control the transfer of data between USB hosts and devices.

The figure mentions structure of TP packet type. Here "TYPE" field is set to "00100b".

Data Packet (DP) Format

The Data Packet Header is used in USB 3.2 to provide additional information about the data being transferred, including the number of data bytes, the sequence number, and other parameters.

USB DP Packet Format

The figure mentions structure of DP packet type. Here "TYPE" field is set to "01000b".

Isochronous Timestamp Packet (ITP) Format

Isochronous Timestamp Packet (ITP) is used in isochronous transfers to provide timing information. Isochronous transfers are used for real-time data, such as audio and video streaming.

USB ITS Packet Format

The figure mentions structure of ITS packet type. Here "TYPE" field is set to "01100b".

Conclusion In summary, Link Management Packets (LMP) are employed for link initialization and management, ensuring a reliable communication link. Transaction Packets serve as the backbone of USB communication, initiating and controlling data transfers between hosts and devices. Data Packet Headers provide crucial information about data transfers, enhancing efficiency and reliability. Isochronous Timestamp Packets play a specialized role in isochronous transfers, ensuring accurate timing information for real-time data such as audio and video streams. Together, these packets facilitate a standardized and efficient USB communication protocol, addressing link establishment, data transfer control, data payload management, and real-time data synchronization.

Similar posts on USB interface

Useful interface types and microcontroller stuff

RF and Wireless Terminologies