Gain insight into USB packets: fields, data types, and transfer modes.
USB data packet is the core component of USB communication. Understanding their construction and function is crucial to understanding how USB technology works. This article will take an in-depth look at various aspects of USB packets, including field meanings, packet types, and different transfer modes. Let’s explore the inner workings of the USB world.
The four transfer mode types of USB and their characteristics.
All data or energy transfer interactions between USB devices require specific endpoints/connectors. Each device endpoint is a receiver or transmitter, playing the role of sender or receiver. USB connector uses a set of unidirectional and bidirectional pipes to transfer user data and control information between the host and USB devices. Each device may support multiple pipes for different purposes, and data transferred in one pipe is independent from data transferred in other pipes. Different USB connector types or connector versions have different transmission rates. For more detailed USB connector types, please go to our corresponding blog to learn more. But USB data transfer modes are mainly divided into 4 types:
- Control Transfer;
- Interrupt Transfer;
- Bulk Transfer;
- Isochronous Transfer;
Control transfer:
Control transfers in the USB protocol serve two main purposes. First, before a USB device can start working normally, the host needs to configure the device and understand its properties, which includes assigning a unique address to the device, obtaining device description information, and setting up data communication channels. Secondly, when the device is running, the host needs to perform USB packet capture on the device at all times to handle problems with the device or the configuration needs to be changed in a timely manner.
To serve these two purposes, USB introduced control transfers. This non-periodic transmission rule is usually used for device configuration, command and status operations.
Each USB device must support control transmission. The endpoint with endpoint number 0 is defined as the control endpoint, which is used to handle the configuration, command and status operations of the device. Control transfer includes the following steps:
- Establish contact: The host sends request information to the device.
- Data transmission: Zero or more data packets are transmitted between the host and the device, and data is transmitted according to the direction of the command.
- Return status information: The device returns status information to the host.
Control transfer endpoints and channels are bidirectional and can send and receive packets. It provides reliable data transmission, supports error detection and data retransmission, and tries to keep the host and device synchronized. Control transfers are used to access device descriptors and perform command operations that change the state of the device.
It should be noted that the USB protocol does not clearly stipulate the frequency and bandwidth of control transmission. This is globally optimized and managed by the USB protocol software (usually the USB control program of the host operating system) to meet the needs of various devices. If you want to know more about USB protocol, please click to read.
Interrupt transfer:
Interrupt transfers are designed for devices that only occasionally send or receive small amounts of data. These devices transmit data at certain intervals, like scheduled events. Devices tell hosts when to check them for new data.
Interrupt transmission is suitable for devices that need to transmit small amounts of data regularly, such as keyboards, mice, and game controllers. All USB devices require system configuration before starting to work. Once the configuration is successful, the device can work normally. Interrupt transmission has the following characteristics:
- Services must be provided within the specified time.
- It is a reliable data transmission method.
- If an error occurs, the data will be retransmitted in the next time interval.
- The end of data is determined by the maximum size of the data packet.
- The endpoint that interrupts transmission can be used to provide feedback information on some real-time transmission rate to the host, such as an audio device.
Bulk transfer:
Bulk transfer is a method for transferring large amounts of data that is more concerned with data accuracy than timeliness. This transfer method has a lower priority and data may be delayed if the USB bus is busy with other transfers. If errors are found, the data is retransmitted to ensure accuracy. The USB host will allocate time when the bus is idle to batch devices waiting for transfers.
This transmission method is usually used for devices that require large amounts of data communication, such as printers, scanners, hard drives, etc.
Summarize the characteristics of batch transfer:
- Bus bandwidth can be used as needed.
- Provide reliable data transmission and support retransmission.
- Confirmed data transfer is provided, but transfer speed and latency cannot be guaranteed.
- Occurs only when the bus is idle, so the transmission frequency depends on the bus idle condition.
Real-time/Isochronous Transfer:
Real-time transmission is a data transmission mode used to transmit extremely time-sensitive data. In real-time transmission, data must be transmitted continuously at fixed time intervals, which requires the bus to provide sufficient bandwidth. Unlike other transmission methods, real-time transmission does not perform error checking or retransmission of data. This transmission method is typically used for devices that need to transmit data on a schedule and require reserved bandwidth and have a high tolerance for errors, such as microphones, modems, and audio devices.
Features of real-time transmission include:
- Data is transmitted within a fixed time, but it is not necessarily 100% correct and some errors can be tolerated.
- It is guaranteed to transmit a certain amount of data within a given time, as long as the data source can provide sufficient data.
- The data receiving end for real-time transmission will try its best to process the received data, even if some of the data may have errors.
- Unlike other transmission methods, real-time transmission will not stop transmission midway, and will continue to transmit data even if an error occurs.
- Real-time transfer is mainly used for full-speed and high-speed USB devices.
Regardless of the packet transmission mode, the cable requires a matching USB connector for data transmission. There are different types of USB connectors on the market, with the Type A connector being the most commonly used. The USB-C port is currently the most technologically cutting-edge, and its 24-pin supports more advanced and high-speed data transmission. Therefore, the old Mini-USB and Micro-USB connectors have gradually been replaced by USB-C ports.
What are the USB packet types?
In the USB protocol, data is first transmitted in the form of the least significant bit (LSB). They are organized into different types of data packets, which play a key role in USB communication to ensure reliable transmission of data and collaborative work of devices. There are four main USB packet types: Token, Data, Handshake and Start of the Frame.
The functions of these four data packets are as follows:
- USB Token data packet:Initiated by the host, used to determine whether the host wants to send data or receive data. It is a control packet.
- USB Data packet:Contains actual data, sent by the transmitter to the receiving device. Receiving devices can reply with NAK or Stall packets to indicate whether they are able to receive or process the data.
- USB Handshake data packet: Used to confirm the reception of data or report error conditions. It helps ensure the reliability of data transmission.
- USB Start of the Frame data packet: Used to divide the USB bus into time periods and arrange the transmission of data. It helps synchronize data transfer of USB devices.
These packets are combined together to form frames, which are then sent via USB transactions. The length and frequency of transactions depend on the transport standard specification used and the type of endpoint.
USB Protocol Packet Type | ||
---|---|---|
PID Type | PID Name | Description |
Token | OUT; | host to device; |
IN; | Device transfers to host; | |
SOF; | Frame start mark; | |
SETUP; | Host to device control transfer; | |
Data | DATA0; | Packet; |
DATA1; | Packet; | |
DATA2; | Packet; | |
MDATA; | High-speed data packet; | |
Handshake | ACK; | Data packets received correctly; |
NAK; | Receiver cannot accept data or sender cannot send data; | |
STALL; | Receiver does not support or does not support control channel requests; | |
NYET; | The receiving party has not responded yet; | |
Special | PRE; | Preface to low-speed transmission; |
ERR; | Error handshake for Split Transaction; | |
SPLIT; | Preface to high speed transmission; | |
PING; | High-speed flow control transmission detection; | |
EXT; | Protocol extension token; |
Detailed explanation of USB packet Message Format.
The USB packet format contains the following fields:
- SYNC field (synchronization field): Used to synchronize the clocks of the receiver and transmitter to ensure correct data transmission.
- PID field (Packet Identifier Field): Provides information about the type of data being sent, as well as the format of the data packet. The PID field has 8 bits, of which the high 4 bits indicate the data packet type, and the low 4 bits are the bitwise inversion of the high 4 bits.
- ADDR field (address field): Contains the address information of the device to which the data packet is sent. USB supports up to 127 devices. The address field has 7 bits. Address 0 is a reserved address for devices with no assigned address.
- ENDP field (Endpoint field): Specifies the number of the endpoint (Endpoint), which is used to address data transmission more flexibly. Typically, endpoints are used to differentiate between incoming and outgoing data, while endpoint 0 is a special control endpoint, and every device contains one.
- CRC field (cyclic redundancy check field): used to check whether there are errors in the data in the data packet. The length of the CRC field varies depending on the packet type, which can be confusing. Token packets use a 5-bit CRC, while data packets use a 16-bit CRC.
- EOP field (End of Data Packet field): Indicates the end of the data packet. In the EOP field, use SE0 (Single-Ended Zero) to represent 2-bit time, followed by J to represent 1-bit time.
To sum up, USB’s data message format includes these data fields, which together ensure reliable transmission and correct interpretation of data. The information in these fields is critical to the proper functioning of the USB protocol. It is worth noting that the transmission efficiency of data packets is related to the USB transmission standard, and the transmission rates of different USB transmission versions vary. Click to learn about the version efficiency information of different USB transmission standards.
By taking a closer look at USB packets, you now have a deeper understanding of USB technology. As a professional USB cable manufacturer, we are always committed to providing customers with high-quality USB products to ensure the reliability and performance of data transmission. If you need a custom USB cable to meet your specific needs, don’t hesitate to contact us. We have rich manufacturing experience and strict quality control to meet your requirements. Trust us to provide you with superior USB solutions to meet your needs.
What is a USB packet?
Every communication protocol involves the exchange of data packets, and this is also the case with USB. USB packets encapsulate information data units in a standard-defined organization to achieve data exchange and communication functions between USB devices and host devices.
Does USB have error detection function?
USB uses two error checking methods to ensure that data is sent correctly. A cyclic redundancy check (CRC) is sent with all data transfers to verify data integrity within the packet. Also, a toggle bit is encoded in the packet’s packet identifier (PID) to ensure that the packets are sent in the correct order.
What is the size of USB packets?
The packet length for control transfers in low-speed devices must be 8 bytes, the allowed packet size for full-speed devices is 8, 16, 32, or 64 bytes, and the packet size for high-speed devices must be 64 bytes.
Fast delivery
Fastest delivery within 22 days
Quick proofing
Fastest 3-day proofing cycle
After-sale protection
24-month long warranty
1V1Customer Service
Professional customer service follow-up