SlideShare a Scribd company logo
1 of 25
USB
USB stands for Universal Serial Bus. It is a standard by which data and
power can be transmitted between computing devices. Originally created
as a connector for computer peripherals such as keyboards, mouse, and
external storage devices, charging portable devices like
wireless phones and tablets
It was developed by Compaq, Intel, Microsoft and NEC, joined later by
Hewlett-Packard, Lucent and Philips
The main goal behind usb implementation is to replace all the the
various connectors of communication protocols to unique connector that
can support all the data that can transmit with better speed
USB Speeds
• High Speed - 480Mbits/s
• Full Speed - 12Mbits/s
• Low Speed - 1.5Mbits/s
• Every transaction in USB consists of 3 packets
• Token Packet
• Data Packet
• Handshake Packet
Types of USB Packets
Token Packet:
there are 3 types of token packets
IN: if the PID field contains IN token it implies that host is ready to accept data from
device
OUT: if the PID field of token packet contains OUT packet it indicates that the host is
writing some data into the endpoint of device
SETUP: this token is used to begin the control transfer while sending standard requests
Data Packet:
there are 4 types of data packets used in this stage
Data0,Data1 is used during low/full speed mode
Data2,Mdata are used while high speed mode
during low speed 8bytes of data can be transferred
during full speed mode 1023 bytes that this data stage can transfer through
with high speed data mode maximum of 1024 bytes is allowed
in this stage total size of data is transmitted as multiples of chunks of buffer size
Hand Shake Packet: there are 3 possible handshake PIDs
ACK: Acknowledgment that the packet has been successfully received.
NAK: it results in negative acknowledgement while transaction
STALL: this is received when there is intervention from the host
This is the table for PID field where it can be identified which token it is
Various Fields in each transaction
Sync field: All packets must start with a sync field. The sync field is 8 bits long
at low and full speed or 32 bits long for high speed and is used to synchronise
the clock of the receiver with that of the transmitter.
PID field: It indicates what type of packet is being sent this PID field is 8 bits
long, the first 4 bits are used to represent the type of packet being sent and rest
4 bits are the compliment of first 4 bits , for error checking as it has NZRI
decoding technique
Address field: this field indicates the address of device to which it is
transmitting, it is 7-bit long so that it can support for maximum upto 127
devices and by default address 0 is is not used for configuring, it will be the
default address during enumeration until an unique address is set that that
device.
Endpoint: for a single device there might be possibility that having various
interfaces each having multiple endpoints, it is a 4-bit long so 16 possible
endpoints.
CRC: it is the error checking mechanism for the transmitted data it is 5 bits long
with token packet and 16-bit long with data packet .
EOP: this indicates the end of packet, in that particular transaction
NOTE: every USB transaction must start with sync field and end with EOP field
End Points: Each USB device has a number of endpoints. Each endpoint is a
source or sink of data. A device can have up to 16 OUT and 16 IN endpoints.
OUT always means from host to device.
IN always means from device to host.
Endpoint 0 is a special case used for controlling the device until an unique address
is assigned for it. All devices must support endpoint zero.
Each end point is having some buffer to which the host writes the data and the
hardware collects/writes data to this particular end point,
End points are lies at the device side only.
Pipe: A logical data connection between the host and a particular endpoint,
Pipes will also have a set of parameters associated with them such as
• how much bandwidth is allocated to it
• what transfer type (Control, Bulk, Iso or Interrupt) it uses
• direction of data flow (IN or OUT)and
• maximum packet/buffer sizes.
USB defines two types of Pipes
Stream Pipe: stream pipe is unidirectional and has no defined structure, Data
flows sequentially and has a pre-defined direction, either in or out. Stream pipes
will support bulk, isochronous and interrupt transfer types. Stream pipes can either
be controlled by the host or device.
Message Pipe:
• message pipe is bi-directional and has a defined structure
• message pipe will support only control transfer types
• Message pipe will be controlled by the host only
Data Flow Types: there are 4 types of data flow in USB, it can also be defined as
end point types
• Control Transfer type
• Interrupt Transfer Type
• Isochronous transfer type
• Bulk transfer type
Control Transfer Type: control transfer is mainly used for sending
commands/requests and status signals,
control transfer comes up with 3 stages
• Setup Stage: token packet of this stage will have a setup token in PID field
indicates to the device that it is a setup request and host is requesting for
something
• Setup token packet consist of these fields
this setup token is directed to the default endpoint of endpoint0 of that
device indicating that it is a setup request , it is fallowed by data packet
• Data Packet consist of these fields
Here the address and endpoint fields are not required as bus is connected to
the destination endpoint, this data0 contains the request to the device, it is
fallowed by the handshake packet
Handshake Packet consist of these fields
Handshake packet acknowledges with status of entire transaction with
appropriate PID
SYNC PID ADDR ENDP CRC5 EOP
SYNC PID DATA0 CRC16 EOP
SYNC PID EOP
Upon completion of this transaction device will able to decode the received data
and understands what is to sent in reply ,places that data in endpoint buffer, after
receiving IN token from the host it will load the data from endpoint buffer to the
data packet and sent
the host will send an IN token to the destination of the device with data data
packet to hold that data
After this transaction bus is connected with the destination endpoint of the device
and it is fallowed by the data packet
Software loads the data of maximum of 8bytes in this data field ,if the data to be
sent is exceeding this limit the whole data will be transmitted in chunks of multiples
of 8bytes, if the last data packet is less than 8bytes then padding is done with zeros
and after this it is fallowed by handshake packet
Host acknowledges with a handshake packet with appropriate PID field
SYNC PID ADDR ENDP CRC5 EOP
SYNC PID DATA1 CRC16 EOP
SYNC PID EOP
Once the data is sent, a status transaction follows. If the transactions were successful, the
host will send a zero length packet indicating the overall transaction was successful. The
function then replies to this zero length packet indicating its status
IN token to the designated endpoint
device reply with zero length data packet
acknowledge after this status stage
Interrupt Transfer Type:
it has a limited latency to or from a device. It continuously polls from the
device to update status or coordinates of mouse with polling rate between
1ms and 255ms for full and low-speed
125μs to 4096ms for high-speed endpoints.
The maximum packet size for the interrupt endpoint data is:
64 or less bytes for full-speed
1024 or less bytes for high-speed
SYNC PID ADDR ENDP CRC5 EOP
SYNC PID DATA1 CRC16 EOP
SYNC PID EOP
Interrupt transfer type is used for updating some information or status from some
devices like mouse or keyboard etc..
Isochronous transfer type:
used for transmitting real-time information such as audio and video data, and must
be sent at a constant rate. USB isochronous data streams are allocated a dedicated
portion of USB bandwidth to ensure that data can be delivered at the desired rate.
An Isochronous pipe sends a new data packet in every frame, regardless of the
success or failure of the last packet.
The maximum packet size for the isochronous endpoint data is:
• 1023 or less bytes for full-speed
• 1024 or less bytes for high-speed
Isochronous Transfers have no error detection. Any error in electrical transmission
is not corrected.
Bulk Transfer Type:
• Used to transfer large data.
• Error detection via CRC, with guarantee of delivery.
• No guarantee of bandwidth.
• Stream Pipe is used which is unidirectional.
• Full & high speed modes only it supports.
For full speed endpoints, the maximum bulk packet size is either 8, 16, 32 or
64 bytes long.
For high speed endpoints, the maximum packet size can be up to 512 bytes
long.
If the data payload falls short of the maximum packet size, it doesn't need to
be padded with zeros.
For example if the data is sent to printer comes under bulk transfer type and
as long as data receiving it prints the whole
• USB Descriptors:
Upon plugging the device host will send few standard requests to that
particular device requesting device descriptor, configuration descriptor,
Interface Descriptor all these happens during enumeration through
which that the host able to know what kind of device it is and then a
suitable driver is loaded for that device and sets the configurations
Every control Transfer type starts with setup transaction ,These 8 bytes
define the request from the host ,there are 3 standard requests related
with control transfer type
• Standard Device Request
• Standard Interface Request
• Standard Endpoint Request
• Suitable Request can be made from host in data packet field of 8
bytes after setup token in every control transfer type
On decoding that the device will able to understand which standard
request type that host has sent
The data packet of control transfer is shown in the table below
Bmrequest Type specifies the type of request and direction transfer
and recipient type
Prefix b and w represents group of 8 bits and 2 bytes used to
represents the whole one field
• Following are the valid device requests listed below
Upon requesting the GET_STATUS device will return a 2byte of data in
that DO bit contains the status of configuration whether it is self
powered or bus powered.
GET_CONFIGURATION: upon sending this standard device request to
the destination end point of device it returns 1 byte of data in the data
packet of next IN token indicates not configured if it receives zeros, and
configured if it receives non-zero value
SET_CONFIGURATION: Set Configuration is used to enable a device. It
should contain the value of bConfigurationValue of the extracted
configuration descriptor in the lower byte of wValue to select which
configuration to enable.
Device Descriptor:
After sending a standard device request requesting GET_DESCRIPTOR command
from the Host , it results in in 18 byte descriptor It specifies some information
about the device such as the supported USB version, maximum packet size,
vendor and product IDs and the number of possible configurations the device
can have.
Configuration Descriptor:
After sending a standard device request requesting
GET_CONFIGURATION command to the device , it results in in 9 byte
descriptor The configuration descriptor specifies how the device is
powered, what the maximum power consumption is, the number of
interfaces it has. Therefore it is possible to have two configurations,
one for when the device is bus powered and another self powered.
Interface Descriptor:
After sending a standard interface request requesting GET_INTERFACE
command from the Host , it results in in 9 byte descriptor it indicates the
possible each interface number and maximum end points ,class, sub class and
protocol of each interface it passes this information to the host
Here bnumendpoints indicates how many endpoints are there for this device
And binterface number indicates current interface number.
Bnumendpoints indicates number of endpoints used by this device.
Endpoint Descriptor:
Upon requesting standard endpoint request to the device by sending
appropriate command listed in the table was sent in data packet of standard
request, during the next transaction of OUT token from that particular endpoint
data to loaded into data0/data1 packet and host decodes the received data and
able to know the status of request
this table lists the fallowing commands for appropriate standard
requests
After sending the required standard endpoint request to destination
endpoint it may result it status as shown

More Related Content

What's hot

I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)
Varun Mahajan
 
UART(universal asynchronous receiver transmitter ) PPT
UART(universal asynchronous receiver transmitter ) PPTUART(universal asynchronous receiver transmitter ) PPT
UART(universal asynchronous receiver transmitter ) PPT
Sai_praneeth
 
I2C And SPI Part-23
I2C And  SPI Part-23I2C And  SPI Part-23
I2C And SPI Part-23
Techvilla
 
Intel x86 Architecture
Intel x86 ArchitectureIntel x86 Architecture
Intel x86 Architecture
ChangWoo Min
 
Interfacing rs232
Interfacing rs232Interfacing rs232
Interfacing rs232
PRADEEP
 

What's hot (20)

USB 3.0
USB 3.0USB 3.0
USB 3.0
 
USB Universal Serial Bus
USB Universal Serial BusUSB Universal Serial Bus
USB Universal Serial Bus
 
Fpga implementation of utmi with usb 2.O
Fpga implementation of  utmi  with usb 2.O Fpga implementation of  utmi  with usb 2.O
Fpga implementation of utmi with usb 2.O
 
Usb
UsbUsb
Usb
 
Usb 2
Usb 2Usb 2
Usb 2
 
The I2C Interface
The I2C InterfaceThe I2C Interface
The I2C Interface
 
Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)
 
APB protocol v1.0
APB protocol v1.0APB protocol v1.0
APB protocol v1.0
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)
 
UART(universal asynchronous receiver transmitter ) PPT
UART(universal asynchronous receiver transmitter ) PPTUART(universal asynchronous receiver transmitter ) PPT
UART(universal asynchronous receiver transmitter ) PPT
 
utmippt
utmipptutmippt
utmippt
 
Uart
UartUart
Uart
 
Usb
UsbUsb
Usb
 
AHB To APB BRIDGE.pptx
AHB To APB BRIDGE.pptxAHB To APB BRIDGE.pptx
AHB To APB BRIDGE.pptx
 
Pcie basic
Pcie basicPcie basic
Pcie basic
 
UART Communication
UART CommunicationUART Communication
UART Communication
 
I2C And SPI Part-23
I2C And  SPI Part-23I2C And  SPI Part-23
I2C And SPI Part-23
 
Intel x86 Architecture
Intel x86 ArchitectureIntel x86 Architecture
Intel x86 Architecture
 
Interfacing rs232
Interfacing rs232Interfacing rs232
Interfacing rs232
 

Similar to USB protocol

Transmission Control Protocol_ Computer Networks
Transmission Control Protocol_ Computer NetworksTransmission Control Protocol_ Computer Networks
Transmission Control Protocol_ Computer Networks
Manimaran A
 

Similar to USB protocol (20)

Unit-4 (1).pptx
Unit-4 (1).pptxUnit-4 (1).pptx
Unit-4 (1).pptx
 
REMnux tutorial 4.1 - Datagrams, Fragmentation & Anomalies
REMnux tutorial 4.1 - Datagrams, Fragmentation & AnomaliesREMnux tutorial 4.1 - Datagrams, Fragmentation & Anomalies
REMnux tutorial 4.1 - Datagrams, Fragmentation & Anomalies
 
TRANSPORT LAYER ppt.pptx
TRANSPORT LAYER ppt.pptxTRANSPORT LAYER ppt.pptx
TRANSPORT LAYER ppt.pptx
 
tcp-ippresentation-150614172243-lva1-app6892.pptx
tcp-ippresentation-150614172243-lva1-app6892.pptxtcp-ippresentation-150614172243-lva1-app6892.pptx
tcp-ippresentation-150614172243-lva1-app6892.pptx
 
TCP - IP Presentation
TCP - IP PresentationTCP - IP Presentation
TCP - IP Presentation
 
Tcp ip presentation
Tcp ip presentationTcp ip presentation
Tcp ip presentation
 
TCP & UDP ( Transmission Control Protocol and User Datagram Protocol)
TCP & UDP ( Transmission Control Protocol and User Datagram Protocol)TCP & UDP ( Transmission Control Protocol and User Datagram Protocol)
TCP & UDP ( Transmission Control Protocol and User Datagram Protocol)
 
Transmission Control Protocol_ Computer Networks
Transmission Control Protocol_ Computer NetworksTransmission Control Protocol_ Computer Networks
Transmission Control Protocol_ Computer Networks
 
Transport layer.pptx
Transport layer.pptxTransport layer.pptx
Transport layer.pptx
 
Transport_Layer_Protocols.pptx
Transport_Layer_Protocols.pptxTransport_Layer_Protocols.pptx
Transport_Layer_Protocols.pptx
 
8251 a basic
8251 a basic8251 a basic
8251 a basic
 
Chapter 3 esy
Chapter 3 esy Chapter 3 esy
Chapter 3 esy
 
8251 USART.pptx
8251 USART.pptx8251 USART.pptx
8251 USART.pptx
 
Osi model
Osi modelOsi model
Osi model
 
8251 USART
8251 USART8251 USART
8251 USART
 
Microcontroller.pptx
Microcontroller.pptxMicrocontroller.pptx
Microcontroller.pptx
 
transport layer
transport layertransport layer
transport layer
 
QSpiders - Upper layer-protocols
QSpiders - Upper layer-protocolsQSpiders - Upper layer-protocols
QSpiders - Upper layer-protocols
 
TCP/IP
TCP/IPTCP/IP
TCP/IP
 
Transport layer protocol
Transport layer protocolTransport layer protocol
Transport layer protocol
 

Recently uploaded

一比一原版(CSUEB毕业证书)东湾分校毕业证原件一模一样
一比一原版(CSUEB毕业证书)东湾分校毕业证原件一模一样一比一原版(CSUEB毕业证书)东湾分校毕业证原件一模一样
一比一原版(CSUEB毕业证书)东湾分校毕业证原件一模一样
ayoqf
 
In Riyadh Saudi Arabia |+966572737505 | Buy Cytotec| Get Abortion pills
In Riyadh Saudi Arabia |+966572737505 | Buy Cytotec| Get Abortion pillsIn Riyadh Saudi Arabia |+966572737505 | Buy Cytotec| Get Abortion pills
In Riyadh Saudi Arabia |+966572737505 | Buy Cytotec| Get Abortion pills
Abortion pills in Riyadh +966572737505 get cytotec
 
一比一维多利亚大学毕业证(victoria毕业证)成绩单学位证如何办理
一比一维多利亚大学毕业证(victoria毕业证)成绩单学位证如何办理一比一维多利亚大学毕业证(victoria毕业证)成绩单学位证如何办理
一比一维多利亚大学毕业证(victoria毕业证)成绩单学位证如何办理
uodye
 
Abortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in Dammam
Abortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in DammamAbortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in Dammam
Abortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in Dammam
ahmedjiabur940
 
在线办理(scu毕业证)南十字星大学毕业证电子版学位证书注册证明信
在线办理(scu毕业证)南十字星大学毕业证电子版学位证书注册证明信在线办理(scu毕业证)南十字星大学毕业证电子版学位证书注册证明信
在线办理(scu毕业证)南十字星大学毕业证电子版学位证书注册证明信
oopacde
 
办理(uw学位证书)美国华盛顿大学毕业证续费收据一模一样
办理(uw学位证书)美国华盛顿大学毕业证续费收据一模一样办理(uw学位证书)美国华盛顿大学毕业证续费收据一模一样
办理(uw学位证书)美国华盛顿大学毕业证续费收据一模一样
vwymvu
 
£ HAMIL 5 BULAN £ CARA MENGGUGURKAN KANDUNGAN USIA 5 BULAN ((087776558899))
£ HAMIL 5 BULAN £ CARA MENGGUGURKAN KANDUNGAN USIA 5 BULAN ((087776558899))£ HAMIL 5 BULAN £ CARA MENGGUGURKAN KANDUNGAN USIA 5 BULAN ((087776558899))
£ HAMIL 5 BULAN £ CARA MENGGUGURKAN KANDUNGAN USIA 5 BULAN ((087776558899))
Obat Cytotec
 
Contact +971581248768 to buy 100% original and safe abortion pills in Dubai a...
Contact +971581248768 to buy 100% original and safe abortion pills in Dubai a...Contact +971581248768 to buy 100% original and safe abortion pills in Dubai a...
Contact +971581248768 to buy 100% original and safe abortion pills in Dubai a...
DUBAI (+971)581248768 BUY ABORTION PILLS IN ABU dhabi...Qatar
 
一比一定(购)坎特伯雷大学毕业证(UC毕业证)成绩单学位证
一比一定(购)坎特伯雷大学毕业证(UC毕业证)成绩单学位证一比一定(购)坎特伯雷大学毕业证(UC毕业证)成绩单学位证
一比一定(购)坎特伯雷大学毕业证(UC毕业证)成绩单学位证
wpkuukw
 
一比一定(购)国立南方理工学院毕业证(Southern毕业证)成绩单学位证
一比一定(购)国立南方理工学院毕业证(Southern毕业证)成绩单学位证一比一定(购)国立南方理工学院毕业证(Southern毕业证)成绩单学位证
一比一定(购)国立南方理工学院毕业证(Southern毕业证)成绩单学位证
wpkuukw
 
Buy Abortion pills in Riyadh |+966572737505 | Get Cytotec
Buy Abortion pills in Riyadh |+966572737505 | Get CytotecBuy Abortion pills in Riyadh |+966572737505 | Get Cytotec
Buy Abortion pills in Riyadh |+966572737505 | Get Cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 
如何办理(USYD毕业证书)悉尼大学毕业证成绩单原件一模一样
如何办理(USYD毕业证书)悉尼大学毕业证成绩单原件一模一样如何办理(USYD毕业证书)悉尼大学毕业证成绩单原件一模一样
如何办理(USYD毕业证书)悉尼大学毕业证成绩单原件一模一样
wsppdmt
 
一比一原版(RMIT毕业证书)墨尔本皇家理工大学毕业证成绩单学位证靠谱定制
一比一原版(RMIT毕业证书)墨尔本皇家理工大学毕业证成绩单学位证靠谱定制一比一原版(RMIT毕业证书)墨尔本皇家理工大学毕业证成绩单学位证靠谱定制
一比一原版(RMIT毕业证书)墨尔本皇家理工大学毕业证成绩单学位证靠谱定制
ougvy
 
Abortion pills in Dammam +966572737505 Buy Cytotec
Abortion pills in Dammam +966572737505 Buy CytotecAbortion pills in Dammam +966572737505 Buy Cytotec
Abortion pills in Dammam +966572737505 Buy Cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 
一比一原版(Otago毕业证书)奥塔哥理工学院毕业证成绩单学位证靠谱定制
一比一原版(Otago毕业证书)奥塔哥理工学院毕业证成绩单学位证靠谱定制一比一原版(Otago毕业证书)奥塔哥理工学院毕业证成绩单学位证靠谱定制
一比一原版(Otago毕业证书)奥塔哥理工学院毕业证成绩单学位证靠谱定制
uodye
 

Recently uploaded (20)

一比一原版(CSUEB毕业证书)东湾分校毕业证原件一模一样
一比一原版(CSUEB毕业证书)东湾分校毕业证原件一模一样一比一原版(CSUEB毕业证书)东湾分校毕业证原件一模一样
一比一原版(CSUEB毕业证书)东湾分校毕业证原件一模一样
 
In Riyadh Saudi Arabia |+966572737505 | Buy Cytotec| Get Abortion pills
In Riyadh Saudi Arabia |+966572737505 | Buy Cytotec| Get Abortion pillsIn Riyadh Saudi Arabia |+966572737505 | Buy Cytotec| Get Abortion pills
In Riyadh Saudi Arabia |+966572737505 | Buy Cytotec| Get Abortion pills
 
一比一维多利亚大学毕业证(victoria毕业证)成绩单学位证如何办理
一比一维多利亚大学毕业证(victoria毕业证)成绩单学位证如何办理一比一维多利亚大学毕业证(victoria毕业证)成绩单学位证如何办理
一比一维多利亚大学毕业证(victoria毕业证)成绩单学位证如何办理
 
Abortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in Dammam
Abortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in DammamAbortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in Dammam
Abortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in Dammam
 
在线办理(scu毕业证)南十字星大学毕业证电子版学位证书注册证明信
在线办理(scu毕业证)南十字星大学毕业证电子版学位证书注册证明信在线办理(scu毕业证)南十字星大学毕业证电子版学位证书注册证明信
在线办理(scu毕业证)南十字星大学毕业证电子版学位证书注册证明信
 
办理(uw学位证书)美国华盛顿大学毕业证续费收据一模一样
办理(uw学位证书)美国华盛顿大学毕业证续费收据一模一样办理(uw学位证书)美国华盛顿大学毕业证续费收据一模一样
办理(uw学位证书)美国华盛顿大学毕业证续费收据一模一样
 
£ HAMIL 5 BULAN £ CARA MENGGUGURKAN KANDUNGAN USIA 5 BULAN ((087776558899))
£ HAMIL 5 BULAN £ CARA MENGGUGURKAN KANDUNGAN USIA 5 BULAN ((087776558899))£ HAMIL 5 BULAN £ CARA MENGGUGURKAN KANDUNGAN USIA 5 BULAN ((087776558899))
£ HAMIL 5 BULAN £ CARA MENGGUGURKAN KANDUNGAN USIA 5 BULAN ((087776558899))
 
Contact +971581248768 to buy 100% original and safe abortion pills in Dubai a...
Contact +971581248768 to buy 100% original and safe abortion pills in Dubai a...Contact +971581248768 to buy 100% original and safe abortion pills in Dubai a...
Contact +971581248768 to buy 100% original and safe abortion pills in Dubai a...
 
Best CPU for gaming Intel Core i9-14900K 14th Gen Desktop CPU
Best CPU for gaming  Intel Core i9-14900K 14th Gen Desktop CPUBest CPU for gaming  Intel Core i9-14900K 14th Gen Desktop CPU
Best CPU for gaming Intel Core i9-14900K 14th Gen Desktop CPU
 
一比一定(购)坎特伯雷大学毕业证(UC毕业证)成绩单学位证
一比一定(购)坎特伯雷大学毕业证(UC毕业证)成绩单学位证一比一定(购)坎特伯雷大学毕业证(UC毕业证)成绩单学位证
一比一定(购)坎特伯雷大学毕业证(UC毕业证)成绩单学位证
 
Dell Inspiron 15 5567 BAL20 LA-D801P Rev 1.0 (A00) Schematics.pdf
Dell Inspiron 15 5567 BAL20 LA-D801P Rev 1.0 (A00) Schematics.pdfDell Inspiron 15 5567 BAL20 LA-D801P Rev 1.0 (A00) Schematics.pdf
Dell Inspiron 15 5567 BAL20 LA-D801P Rev 1.0 (A00) Schematics.pdf
 
一比一定(购)国立南方理工学院毕业证(Southern毕业证)成绩单学位证
一比一定(购)国立南方理工学院毕业证(Southern毕业证)成绩单学位证一比一定(购)国立南方理工学院毕业证(Southern毕业证)成绩单学位证
一比一定(购)国立南方理工学院毕业证(Southern毕业证)成绩单学位证
 
Abortion pills in Jeddah +966572737505 <> buy cytotec <> unwanted kit Saudi A...
Abortion pills in Jeddah +966572737505 <> buy cytotec <> unwanted kit Saudi A...Abortion pills in Jeddah +966572737505 <> buy cytotec <> unwanted kit Saudi A...
Abortion pills in Jeddah +966572737505 <> buy cytotec <> unwanted kit Saudi A...
 
Buy Abortion pills in Riyadh |+966572737505 | Get Cytotec
Buy Abortion pills in Riyadh |+966572737505 | Get CytotecBuy Abortion pills in Riyadh |+966572737505 | Get Cytotec
Buy Abortion pills in Riyadh |+966572737505 | Get Cytotec
 
如何办理(USYD毕业证书)悉尼大学毕业证成绩单原件一模一样
如何办理(USYD毕业证书)悉尼大学毕业证成绩单原件一模一样如何办理(USYD毕业证书)悉尼大学毕业证成绩单原件一模一样
如何办理(USYD毕业证书)悉尼大学毕业证成绩单原件一模一样
 
Test bank for consumer behaviour buying having and being eighth canadian edit...
Test bank for consumer behaviour buying having and being eighth canadian edit...Test bank for consumer behaviour buying having and being eighth canadian edit...
Test bank for consumer behaviour buying having and being eighth canadian edit...
 
一比一原版(RMIT毕业证书)墨尔本皇家理工大学毕业证成绩单学位证靠谱定制
一比一原版(RMIT毕业证书)墨尔本皇家理工大学毕业证成绩单学位证靠谱定制一比一原版(RMIT毕业证书)墨尔本皇家理工大学毕业证成绩单学位证靠谱定制
一比一原版(RMIT毕业证书)墨尔本皇家理工大学毕业证成绩单学位证靠谱定制
 
NON INVASIVE GLUCOSE BLODD MONITORING SYSTEM (1) (2) (1).pptx
NON INVASIVE GLUCOSE BLODD MONITORING SYSTEM (1) (2) (1).pptxNON INVASIVE GLUCOSE BLODD MONITORING SYSTEM (1) (2) (1).pptx
NON INVASIVE GLUCOSE BLODD MONITORING SYSTEM (1) (2) (1).pptx
 
Abortion pills in Dammam +966572737505 Buy Cytotec
Abortion pills in Dammam +966572737505 Buy CytotecAbortion pills in Dammam +966572737505 Buy Cytotec
Abortion pills in Dammam +966572737505 Buy Cytotec
 
一比一原版(Otago毕业证书)奥塔哥理工学院毕业证成绩单学位证靠谱定制
一比一原版(Otago毕业证书)奥塔哥理工学院毕业证成绩单学位证靠谱定制一比一原版(Otago毕业证书)奥塔哥理工学院毕业证成绩单学位证靠谱定制
一比一原版(Otago毕业证书)奥塔哥理工学院毕业证成绩单学位证靠谱定制
 

USB protocol

  • 1. USB USB stands for Universal Serial Bus. It is a standard by which data and power can be transmitted between computing devices. Originally created as a connector for computer peripherals such as keyboards, mouse, and external storage devices, charging portable devices like wireless phones and tablets It was developed by Compaq, Intel, Microsoft and NEC, joined later by Hewlett-Packard, Lucent and Philips The main goal behind usb implementation is to replace all the the various connectors of communication protocols to unique connector that can support all the data that can transmit with better speed
  • 2. USB Speeds • High Speed - 480Mbits/s • Full Speed - 12Mbits/s • Low Speed - 1.5Mbits/s
  • 3. • Every transaction in USB consists of 3 packets • Token Packet • Data Packet • Handshake Packet
  • 4. Types of USB Packets Token Packet: there are 3 types of token packets IN: if the PID field contains IN token it implies that host is ready to accept data from device OUT: if the PID field of token packet contains OUT packet it indicates that the host is writing some data into the endpoint of device SETUP: this token is used to begin the control transfer while sending standard requests Data Packet: there are 4 types of data packets used in this stage Data0,Data1 is used during low/full speed mode Data2,Mdata are used while high speed mode during low speed 8bytes of data can be transferred during full speed mode 1023 bytes that this data stage can transfer through with high speed data mode maximum of 1024 bytes is allowed in this stage total size of data is transmitted as multiples of chunks of buffer size
  • 5. Hand Shake Packet: there are 3 possible handshake PIDs ACK: Acknowledgment that the packet has been successfully received. NAK: it results in negative acknowledgement while transaction STALL: this is received when there is intervention from the host
  • 6. This is the table for PID field where it can be identified which token it is Various Fields in each transaction
  • 7. Sync field: All packets must start with a sync field. The sync field is 8 bits long at low and full speed or 32 bits long for high speed and is used to synchronise the clock of the receiver with that of the transmitter. PID field: It indicates what type of packet is being sent this PID field is 8 bits long, the first 4 bits are used to represent the type of packet being sent and rest 4 bits are the compliment of first 4 bits , for error checking as it has NZRI decoding technique Address field: this field indicates the address of device to which it is transmitting, it is 7-bit long so that it can support for maximum upto 127 devices and by default address 0 is is not used for configuring, it will be the default address during enumeration until an unique address is set that that device. Endpoint: for a single device there might be possibility that having various interfaces each having multiple endpoints, it is a 4-bit long so 16 possible endpoints.
  • 8. CRC: it is the error checking mechanism for the transmitted data it is 5 bits long with token packet and 16-bit long with data packet . EOP: this indicates the end of packet, in that particular transaction NOTE: every USB transaction must start with sync field and end with EOP field End Points: Each USB device has a number of endpoints. Each endpoint is a source or sink of data. A device can have up to 16 OUT and 16 IN endpoints. OUT always means from host to device. IN always means from device to host. Endpoint 0 is a special case used for controlling the device until an unique address is assigned for it. All devices must support endpoint zero. Each end point is having some buffer to which the host writes the data and the hardware collects/writes data to this particular end point, End points are lies at the device side only.
  • 9. Pipe: A logical data connection between the host and a particular endpoint, Pipes will also have a set of parameters associated with them such as • how much bandwidth is allocated to it • what transfer type (Control, Bulk, Iso or Interrupt) it uses • direction of data flow (IN or OUT)and • maximum packet/buffer sizes. USB defines two types of Pipes Stream Pipe: stream pipe is unidirectional and has no defined structure, Data flows sequentially and has a pre-defined direction, either in or out. Stream pipes will support bulk, isochronous and interrupt transfer types. Stream pipes can either be controlled by the host or device. Message Pipe: • message pipe is bi-directional and has a defined structure • message pipe will support only control transfer types • Message pipe will be controlled by the host only
  • 10. Data Flow Types: there are 4 types of data flow in USB, it can also be defined as end point types • Control Transfer type • Interrupt Transfer Type • Isochronous transfer type • Bulk transfer type Control Transfer Type: control transfer is mainly used for sending commands/requests and status signals, control transfer comes up with 3 stages • Setup Stage: token packet of this stage will have a setup token in PID field indicates to the device that it is a setup request and host is requesting for something
  • 11. • Setup token packet consist of these fields this setup token is directed to the default endpoint of endpoint0 of that device indicating that it is a setup request , it is fallowed by data packet • Data Packet consist of these fields Here the address and endpoint fields are not required as bus is connected to the destination endpoint, this data0 contains the request to the device, it is fallowed by the handshake packet Handshake Packet consist of these fields Handshake packet acknowledges with status of entire transaction with appropriate PID SYNC PID ADDR ENDP CRC5 EOP SYNC PID DATA0 CRC16 EOP SYNC PID EOP
  • 12. Upon completion of this transaction device will able to decode the received data and understands what is to sent in reply ,places that data in endpoint buffer, after receiving IN token from the host it will load the data from endpoint buffer to the data packet and sent the host will send an IN token to the destination of the device with data data packet to hold that data After this transaction bus is connected with the destination endpoint of the device and it is fallowed by the data packet Software loads the data of maximum of 8bytes in this data field ,if the data to be sent is exceeding this limit the whole data will be transmitted in chunks of multiples of 8bytes, if the last data packet is less than 8bytes then padding is done with zeros and after this it is fallowed by handshake packet Host acknowledges with a handshake packet with appropriate PID field SYNC PID ADDR ENDP CRC5 EOP SYNC PID DATA1 CRC16 EOP SYNC PID EOP
  • 13. Once the data is sent, a status transaction follows. If the transactions were successful, the host will send a zero length packet indicating the overall transaction was successful. The function then replies to this zero length packet indicating its status IN token to the designated endpoint device reply with zero length data packet acknowledge after this status stage Interrupt Transfer Type: it has a limited latency to or from a device. It continuously polls from the device to update status or coordinates of mouse with polling rate between 1ms and 255ms for full and low-speed 125μs to 4096ms for high-speed endpoints. The maximum packet size for the interrupt endpoint data is: 64 or less bytes for full-speed 1024 or less bytes for high-speed SYNC PID ADDR ENDP CRC5 EOP SYNC PID DATA1 CRC16 EOP SYNC PID EOP
  • 14. Interrupt transfer type is used for updating some information or status from some devices like mouse or keyboard etc.. Isochronous transfer type: used for transmitting real-time information such as audio and video data, and must be sent at a constant rate. USB isochronous data streams are allocated a dedicated portion of USB bandwidth to ensure that data can be delivered at the desired rate. An Isochronous pipe sends a new data packet in every frame, regardless of the success or failure of the last packet. The maximum packet size for the isochronous endpoint data is: • 1023 or less bytes for full-speed • 1024 or less bytes for high-speed Isochronous Transfers have no error detection. Any error in electrical transmission is not corrected.
  • 15. Bulk Transfer Type: • Used to transfer large data. • Error detection via CRC, with guarantee of delivery. • No guarantee of bandwidth. • Stream Pipe is used which is unidirectional. • Full & high speed modes only it supports. For full speed endpoints, the maximum bulk packet size is either 8, 16, 32 or 64 bytes long. For high speed endpoints, the maximum packet size can be up to 512 bytes long. If the data payload falls short of the maximum packet size, it doesn't need to be padded with zeros. For example if the data is sent to printer comes under bulk transfer type and as long as data receiving it prints the whole
  • 16. • USB Descriptors: Upon plugging the device host will send few standard requests to that particular device requesting device descriptor, configuration descriptor, Interface Descriptor all these happens during enumeration through which that the host able to know what kind of device it is and then a suitable driver is loaded for that device and sets the configurations
  • 17. Every control Transfer type starts with setup transaction ,These 8 bytes define the request from the host ,there are 3 standard requests related with control transfer type • Standard Device Request • Standard Interface Request • Standard Endpoint Request • Suitable Request can be made from host in data packet field of 8 bytes after setup token in every control transfer type On decoding that the device will able to understand which standard request type that host has sent
  • 18. The data packet of control transfer is shown in the table below Bmrequest Type specifies the type of request and direction transfer and recipient type Prefix b and w represents group of 8 bits and 2 bytes used to represents the whole one field
  • 19. • Following are the valid device requests listed below Upon requesting the GET_STATUS device will return a 2byte of data in that DO bit contains the status of configuration whether it is self powered or bus powered.
  • 20. GET_CONFIGURATION: upon sending this standard device request to the destination end point of device it returns 1 byte of data in the data packet of next IN token indicates not configured if it receives zeros, and configured if it receives non-zero value SET_CONFIGURATION: Set Configuration is used to enable a device. It should contain the value of bConfigurationValue of the extracted configuration descriptor in the lower byte of wValue to select which configuration to enable.
  • 21. Device Descriptor: After sending a standard device request requesting GET_DESCRIPTOR command from the Host , it results in in 18 byte descriptor It specifies some information about the device such as the supported USB version, maximum packet size, vendor and product IDs and the number of possible configurations the device can have.
  • 22. Configuration Descriptor: After sending a standard device request requesting GET_CONFIGURATION command to the device , it results in in 9 byte descriptor The configuration descriptor specifies how the device is powered, what the maximum power consumption is, the number of interfaces it has. Therefore it is possible to have two configurations, one for when the device is bus powered and another self powered.
  • 23. Interface Descriptor: After sending a standard interface request requesting GET_INTERFACE command from the Host , it results in in 9 byte descriptor it indicates the possible each interface number and maximum end points ,class, sub class and protocol of each interface it passes this information to the host Here bnumendpoints indicates how many endpoints are there for this device And binterface number indicates current interface number. Bnumendpoints indicates number of endpoints used by this device.
  • 24. Endpoint Descriptor: Upon requesting standard endpoint request to the device by sending appropriate command listed in the table was sent in data packet of standard request, during the next transaction of OUT token from that particular endpoint data to loaded into data0/data1 packet and host decodes the received data and able to know the status of request this table lists the fallowing commands for appropriate standard requests
  • 25. After sending the required standard endpoint request to destination endpoint it may result it status as shown