A hub is generally a box with multiple ports. They range from very small to large depending on the requirement. Because hubs can generate a lot of unnecessary network traffic and are
capable of operating only in half-duplex mode (they cannot send and receive
data at the same time), you won’t typically see them used in most modern or
high-density networks (switches are used instead).
A hub is no more than a repeating device that operates on the physical
layer of the OSI model. It takes packets sent from one port and transmits
(repeats) them to every other port on the device. For example, if a computer
on port 1 of a 4-port hub needs to send data to a computer on port 2, the
hub sends those packets to ports 1, 2, 3, and 4. The clients connected to
ports 3 and 4 examine the destination Media Access Control (MAC) address
field in the Ethernet header of the packet, and they see that the packet is not
for them, so they drop (discard) the packet. Figure 1-5 illustrates an example
in which computer A is transmitting data to computer B. When computer A
sends this data, all computers connected to the hub receive it. Only computer B
actually accepts the data; the other computers discard it.
The best alternatives to hubs in production and high-density networksare switches, which are full-duplex devices that can send and receive datasynchronously.
Like a hub, a switch is designed to repeat packets. However, unlike a hub,
rather than broadcasting data to every port, a switch sends data to only the
computer for which the data is intended.
Switches also offer advanced functionality when it comes to handling
transmitted packets. In order to be able to communicate directly with specific
devices, switches must be able to uniquely identify devices based on their MAC
addresses, which means that they must operate on the data link layer of the
Switches store the layer 2 address of every connected device in a CAM
table, which acts as a kind of traffic cop. When a packet is transmitted, the
switch reads the layer 2 header information in the packet and, using the CAM
table as reference, determines to which port(s) to send the packet. Switches
send packets only to specific ports, thus greatly reducing network traffic.
Figure 1-7 illustrates traffic flow through a switch. In this figure, computer
A is sending data to only the intended recipient: computer B. Multiple
conversations can happen on the network at the same time, but information
is communicated directly between the switch and intended recipient, not