USB Hub - Protocol

Protocol

Each hub has exactly one upstream port and a number of downstream ports. The upstream port connects the hub (directly or through other hubs) to the host. Other hubs or devices can be attached to the downstream ports. During normal transmission, hubs are essentially transparent: data received from its upstream port is broadcast to all devices attached to its downstream ports; data received from a downstream port is generally forwarded to the upstream port only. This way, what is sent by the host is received by all hubs and devices, and what sent by a device is received by the host but not by the other devices (an exception is resume signaling).

Hubs are not transparent when dealing with changes in the status of downstream ports, such as insertion or removal of devices. In particular, if a downstream port of a hub changes status, this change is dealt with in an interaction between the host and this hub; the hubs between them act as transparent in this case.

To this aim, each hub has a single interrupt endpoint "1 IN" (endpoint address 1, hub-to-host direction) used to signal changes in the status of the downstream ports. When someone plugs in a device, the hub detects voltage on either D+ or D- and signals the insertion to the host via this interrupt endpoint. When the host polls this interrupt endpoint, it learns that the new device is present. It then instructs the hub (via the default control pipe) to reset the port where the new device was plugged in. This reset makes the new device assume address 0, and the host can then interact with it directly; this interaction will result in the host assigning a new (non-zero) address to the device.

Read more about this topic:  USB Hub