Close or Esc Key

Arduino Projects   |   Raspberry Pi   |   Electronic Circuits   |   AVR   |   PIC   |   8051   |   Electronic Projects

USB Protocol: Types of USB Packets and USB Transfers (Part 2/6)

Table of Contents:

  1. USB Protocol: Types of USB Packets and USB Transfers (Part 2/6)
  2. Types of USB Transfer

Written By: 

Amanpreet Singh
After discussing the features and architecture of USB, let’s move on to its protocol. A USB interface has several layers of protocol. Most of the time the lower level layers are single handled by host controller IC while the end designer needs to work on higher level layers. Every communication protocol involves the exchange of packets. Same is the case with USB. These packets encapsulate information in a standard-defined organized manner. These packets generally contain information related to:

Controlling the data exchange

Data exchange in the form of actual payload

Error detection and correction through status check up

USB Packet Fields

In USB the LSB of the packet is transmitted first. An USB packet contains different fields. They are:

Sync: It is a mandatory field occurring at starting of the packet. This field synchronizes the clock of the receiver with the transmitter. For low and full speed mode, this field is 8 bytes long and for high speed mode it is 32 bytes long.

PID: PID means Packet ID. It indicates the packet type that is being sent. This field is of 8 bits long. The upper four bits identifies the type of packet and lower four bits are bit-wise compliment of upper four bits. The lower four bits helps in detecting errors.

USB Packet fields

ADDR: This field contains the designation address of the USB device. It is of 7 bits, this means it can supports 27 ¬ = 127 devices.

ENDP: This field specifies the endpoint number. It is of 4 bits, this means it can indicate 2¬¬4¬¬ ¬¬= 16 possible endpoints.

CRC: CRC stands for Cyclic Redundancy Check. This field is used to check data in the packet for any error using CRC process

For token packets, 5-bit CRC is used and for data packets 16-bit CRC is used

EOP: EOP stands for End of Packet. This field signals the data lines for Single Ended Zero(SE0) for approximately 2 bit times, followed by J state(idle state) for 1 bit time

Types of USB packets

Basically there are four types of data packets:

1. Token packets: These packets are only sent by host. The packet structure contains a PID byte, 11 bits of address and a 5-bit CRC. Types of token packets :


In – This packet notifies the USB device that host wants to read information.
Out – This packet notifies the USB device that host wants to write information.
Setup – This packet is used to start the control transfer
With USB2.0, two more packets were added:
Ping – Before sending OUT/DATA packet pair, this token asks the USB device if it is ready to receive OUT/DATA packet pair.
Split – This token is used to communicate to a low/full speed device on a high speed bus

2. Data packets: Two types of data packets are there, Data0 and Data1. The packet structure contains a PID byte, data field and 16-bit CRC. The data field can carry 0- 1023 bytes of data. Data must be always sent in multiple of bytes.

USB Data packet

For low speed devices, maximum data field is of 8bytes.
For full speed devices, maximum data field is of 1023bytes.
For high speed devices, maximum data field is of 1024bytes

After USB2.0, two more types were added Data2 and MData. They are only used in high speed transfer high bandwidth isochronous transfer when there is a need to transfer more than 1024 bytes at 8192 kB/s.

3. Handshake Packets: These packets are mostly sent in response to data packets. They simply consist of a PID byte. There are three types of handshake packets :

USB Handshake packet

ACK – Acknowledgment for packet received
NAK – indicating that packets cannot be temporarily received or send. Also used to indicate that there is no data to send
STALL – indicating that the device is in error state and needs intervention from the host
With USB2.0, two more packets were added:
NYET – indicating Split transaction is not yet complete.
ERR – indicating Split transaction failed
4. Start of Frame packets (SOF): The SOF packet consists of an incrementing 11-bit frame number. On a full speed bus, this packet is sent by the host every 1ms and on a high speed bus every 125 us. This packet is used to synchronize isochronous transfer.
USB- Start of frame packet


A successful transaction consists of up-to three phases that occur in sequence. They are Token phase, Data phase and Handshake phase.

USB-Types of transfers

These phases ensured secure transfer of data. There are three types of transactions :

Types of transaction