As its name says, USB is a serial bus. This means that data is transmitted one Bit at a time in a stream over the bus. The USB bus consists of a cable carrying power and data from the host to the device. Because this "point-to-point" system only allows one device to be connected, to handle additional devices, a hub is used. Hubs are fitted in-between the computer's host port and a device to both buffer the signals and to replicate them onto one or more ports. The hub relays the upstream data to all ports at the same time to drive the additional devices. As the hub is also classed as a device, more than one hub can be used to expand the USB network as required. At every port you can place a device or another hub. The hubs broadcast all the data coming from the host upstream to all enabled ports. As only one device can be active at any time, only the hubs connected directly in line with the host and the target device will relay data back, passing it from the immediate downstream device to it's upstream port.
In a USB system all bus activities are initiated and controlled by the a single host controller. Besides defining the electrical and mechanical properties, the USB specification also defines the bus protocol and the behaviour of the system. As part of the USB standard, it provides a communication and configuration protocol between host applications and the devices they drive and strictly dictates their expected behaviour and interaction. As part of this definition, there is an attempt to create specific classes of devices and define a common set of functions/interfaces for all similar devices within the class. This makes it much easier to write drivers to give hardware and operating system independence for accessing, running and controlling such devices. Hubs are simply a special class of device used to expand the USB network. Their class properties describe how they set up routing of data transfer and how to detect if a device has been plugged in or removed from the bus. As part of this management function, they detect bus faults and usually provide power control so unused devices can be switched off - useful for saving power on a portable system. Because devices can be "hot plugged", the bus must also cope with power surges and over current conditions if the user tries to attach too many devices or a device that requires too much power to a single USB segment.
The basic concept of transfer between an application on the host and a devices is done by using pipes. A device consists of several "endpoints" which allow a pipe to be connected to facilitate communication. Before communication can begin, a pipe is always established between an application and one or more endpoints. Each pipe supports a unidirectional stream of data and either sends or receives depending on the properties of the connected endpoint. In this way, the endpoint automatically determines the direction of the data transfer. In some situations it is possible to bind both a sending and a receiving endpoint to one pipe to create a bi-directional pipe.
To support the flow of data between the host and the device, each pipe has an associated buffer where data is queued for later transmission or buffered when data is received. It is through these buffers that the device driver and application actually communicates with a device with he USB stack automatically controlling the data flow to and from them.
USB Communication Flow
The range of USB devices is growing continuously, but most of them fall within a very small range of classes.
Some examples:
mouse
keyboard
painting tablet
joystick
digital camera
web camera
digital TV receiver
interface to blue tooth devices
interface to ethernet
modem (analogue, ISDN, DSL)
external mass storage (e.g. Iomega drive)
printer
scanner
pocketbook computer
speakers.
Although a pocket computer is listed above as a device, the USB specification allows for only one bus master or host on each BUS. So it's not possible to connect two host computers together directly without some form of adaptor. These USB "bridges" usually take the form of two "back-to-back" devices which allow one host computer to leave messages for the other and visa-versa. Unfortunately it's not possible to connect two host systems to one USB bus to share the peripherals.
It must be noted that a peripheral may appear as more than one USB device with an integral hub connecting each internal device to the bus. Such multifunction products could be a fax machine which integrate a scanner to scan documents and a printer to print them out. The USB specification requires that such devices should are treated as two separate devices (i.e. a scanner and a printer device), and require two separate drivers to control them.