A hub is the least expensive, least intelligent and least complicated. Its job is very simple – anything that comes in one port is sent out to the others. If a message comes in for computer “A”, that message is sent out all the other ports, regardless of which one computer “A” is on.
And when computer “A” responds, its response also goes out to every other port on the hub.
Every computer connected to the hub “sees” everything that every other computer on the hub sees. The computers themselves decide if they are the targeted recipient of the message and when a message should be paid attention to or not.
The hub itself is blissfully ignorant of the data being transmitted. For years, simple hubs have been quick and easy ways to connect computers in small networks.
A switch does essentially what a hub does, but more efficiently. By paying attention to the traffic that comes across it, it can “learn” where particular addresses are. Initially, a switch knows nothing and simply sends on incoming messages to all ports:
Even accepting that first message, however, the switch has learned something – it knows on which connection the sender of the message is located.
Related Blog – Functions of Network Switch
Thus, when machine “A” responds to the message, the switches only need to send that message out to the one connection:
In addition to sending the response through to the originator, the switch has now learned something else – it now knows on which connection machine “A” is located. That means that subsequent messages destined for machine “A” need only be sent to that one port:
Switches learn the location of the devices that they are connected to almost instantaneously. The net result is that most network traffic only goes where it needs to rather than to every port. On busy networks, this can make the network significantly faster.
Difference between Switch and Hub –
A detailed comparison and difference in Network Switch vs Hub is given below –
Know more about Switch vs Hub in this video