What is a Network?
If we have two computers A and B (Desktops, Laptops, VMs, Cloud, etc). How does system A reach B? We connect them to a switch and the switch creates a network containing the two systems. To connect them to a switch we need an interface on each host. Physical or Virtual depending on the host to see the interfaces for the host. The switch can only enable communication within a network which means it can receive packets from a host on the network and deliver it to other systems within the same network.
How does a system in one network reach a system in the other?
That is where a router comes in. A router helps connect two networks together. The router is just another device on the network. If the network was a room, the gateway (Default Gateway, Router) is a door to the outside world to other networks or to the internet.
What is Hub?
The purpose of a Hub is to connect all of your network devices together on an internal network. It is a device that has multiple ports that accepts Ethernet connections from network devices. The Hube is not to be intelligent because it does not filter any data or has any intelligence as to where the data is supposed to be sent. So, when a data packet arrives at one of the ports, it is copied to all of the other ports. So, all the devices on that hub see that data packet. Even if A computer only communicates with B Computer, the other computers would still receive the data. Even though the data was not intended for them. So, when this happens it not only creates security concerns, but it also creates unnecessary traffic on the network, which wastes bandwidth.
What is Switch?
The Switch is very similar to Hub. It is also a device that has multiple ports that accepts Ethernet connections from network devices. But unlike a Hub, a switch is intelligent. A switch can actually learn the physical addresses of the devices that are connected to it and it stores these physical addresses, called MAC addresses. So, when a data packet is sent to a switch, it’s only directed to the intended destination port. Thus if A computer wants to communicate with B computer, the data packet arrives at the switch, and the switch will look at its table of MAC addresses and matching ports and deliver the data to the correct port. So, as a result, switches are far more preferred over Hubs because they reduce any unnecessary traffic on the network.
PORT | DEVICE | MAC ADDRESS |
1 | DETECTED | 54-10-5A-63-AE-F3 |
2 | DETECTED | B2-10-2D-63-RF-F3 |
3 | DETECTED | C4-40-5A-73-8E-93 |
4 | DETECTED | F1-45-6F-43-ES-F3 |
Hubs and Switches are used to exchange data within a local area network. Not used to exchange data outside their own network.
To exchange data outside their own network, a device needs to be able to read IP addresses
What is Router?
A router is a device that routes or forwards data from one network to another based on their IP Address. When data is received from the router, the router inspects the data’s IP Address and determines if the packet was meant for its own network or if it’s meant for another network. If the router determines that the data packet is meant for its own network, it receives it. But if it’s not meant for its own network, it sends it off to another network.
Thus, The router is the gateway of a network.
- Hub & Switches are used to create networks
- Routers are used to connect networks.