USB HUB is used for equipment expansion connection, and all USB DEVICEs are connected to the ports of USB HUB. A USB HOST is always connected with a root HUB (USB ROOT HUB). The USB HUB provides 100mA current for each port of the device.
At the same time, the USB HUB can diagnose the plugging and unplugging operation of the device through the electrical changes of the port, and report the port status to the USB HOST by responding to the data packet of the USB HOST.
Generally speaking, the length of the connection between the USB device and the USB HUB should not exceed 5m, and the cascading of the USB system should not exceed level 5 (including ROOT HUB).
The downstream interfaces of the USB Hub will equally share the bandwidth of the upstream interface, and the USB Hub itself also needs to transmit control signals, so the bandwidth of each downstream device must be smaller than the total bandwidth of the upstream device.
The actual situation is that it is difficult for the mainstream USB 3.0 devices to occupy the total bandwidth (5Gbps). For example, the mainstream 3.0 U disk only has a transmission speed of 100MB~200MB/s, and the equivalent bandwidth is less than 2Gbps, so the actual situation is not must.
The principle of USB Hub is relatively complicated. The most complicated part of the USB protocol specification is the chapter of Hub. The principle of USB Hub is quite different from that of network equipment (Ethernet). If you really want to compare it, the complexity is about the same as that of network equipment router.
There are four modes in the USB protocol: control transfer, bulk transfer, interrupt transfer, and synchronous transfer, among which:
Control transmission is used to transmit instructions at the control equipment level;
Bulk transmission (the Chinese name may be called batch transmission) is mainly used to transmit various large blocks of USB data, such as data read and written by U disk;
Interrupt transmission, used to transmit small pieces of data, the mouse and keyboard mainly use interrupt transmission;
Synchronous transmission is used to transmit data whose real-time performance is not strong enough, that is to say, the reliability is not guaranteed, and some USB audio devices use this kind of transmission;
The USB Hub is responsible for integrating various transmission signals of downstream devices. The synchronous transmission has a certain limit. If it exceeds a certain proportion of the total bandwidth (20% in memory), the synchronous transmission exceeding the proportion will be discarded; interrupt transmission and control transmission It occupies the reserved bandwidth and is not allowed to be discarded; Bulk transmission occupies the remaining bandwidth. If there is no synchronous transmission, then Bulk transmission can account for more than 90% of the total bandwidth.
The USB Hub integrates the data and sends it to the upstream device. If there is a USB Hub upstream, the upstream device will continue to do the same operation. In addition, it should be noted that, generally speaking, the USB interface on the host itself is a Root Hub. If there are multiple interfaces on a PC, it may be that multiple interfaces share a controller, and each controller has a Root Hub. .
So USB Hub is equivalent to repackaging various data packets, similar to a router in a network device, not as simple as a switch or a hub (Hub).
At the same time, the USB Hub itself is still a USB device, which is responsible for reporting to the superior how many devices there are in its subordinates, and it also occupies some bandwidth to report its status periodically.
Since many networks such as Ethernet (common internal networks connected by shared HUBs) are based on the bus mode, they are physically broadcast, that is, when one machine sends data to another machine, the shared HUB first receives and then receives the data Then send it to every other port (the port that came from it will not be sent), so the network cards of all machines on the same network segment under the shared HUB can receive the data.
The internal single-chip program of the switching HUB can remember the MAC address of each port, and in the future, which machine should receive it and send it to that port, instead of sending it to all ports like a shared HUB, so only the received data under the switching HUB The network card of the machine can receive the data, and of course the broadcast packet is still sent to all ports.
Obviously, the working mode of the shared HUB makes the other ports of other machines also occupy when the two machines transmit data, so the shared HUB determines that only two machines can communicate with each other on the same network segment at the same time, while the two machines of the exchange HUB transmit data. The other ports are not occupied during data transmission, so other ports can also be transmitted at the same time.
These are the two differences between the shared HUB and the exchanged HUB. The shared HUB means that only one machine can send data at the same time and all machines can receive it. As long as it is not a broadcast data exchange HUB can transmit data to the machine at the same time and the data is private. of.