Switch vs Hub
A network device that is used to connect network segments together is called a switch. Usually, switches are used at the data link layer (layer 2 of the OSI model) to process and route data. Multilayer switches are a type of switches that process data at the network layer (layer 3 of the OSI model) and above. Hub is also a device that is used to connect network devices (such as Ethernet devices) together to form a single network segment. It operates on the physical layer (layer 1 of the OSI model).
What is a Switch?
Switches are an important part of modern Ethernet Local Area Networks (LANs). While small LANs (small offices or home offices) use a single switch, large LANs contain several managed switches (managed switches provide methods such as command line interfaces for modifying the operations of the switch). Switches that operate on the data link layer allow the devices that are connected to its ports to communicate without any interference by creating separate collision domains for each port. For example, consider four computers (C1, C2, C3 and C4) connected using 4 ports in a switch. C1 and C2 can communicate with each other, while C3 and C4 are also communicating, without any interference. Switches can also operate on several layers (such as data link, network or transport) simultaneously. These switches are known as multilayer switches.
What is a Hub?
Hubs are also devices that are used to connect network devices together. It is a simple device that broadcasts the traffic coming in without any kind of management. It does not gather any information from the traffic flowing through it therefore do not know the source or the destination of the traffic. In a hub, traffic coming in to a port is sent out on all the other ports. Since the hubs pass the traffic to all the devices connected to its ports, unnecessary traffic may be sent to devices on the network. The devices themselves have to determine whether the packet is actually intended for it, by inspecting the address information on the packet. This repeating process could be a problem for a large network with lot of traffic flow, since it could cause lots of collisions. But, hubs can be used in small networks, where this repeating process could be managed.
What is the difference between Switch and Hub?
Even though both the switches and hubs could be used to interconnect network segments, there are some important differences. A hub is a simple device that sends all the traffic coming in to the hub in all the other ports. This could cause lots of unnecessary traffic flow in the network causing collisions. Switches on the other hand, collect some knowledge about the devices connecting to it and forwards the incoming traffic only through the relevant port(s). This would also allow maintaining simultaneous communications on the switch. Therefore hubs are suitable for small networks while, switches are more suitable for large networks with lots of traffic.