Code360 powered by Coding Ninjas X Code360 powered by Coding Ninjas X
Table of contents
Hub vs Switch
Frequently Asked Questions
What is the MAC address and IP address?
What is the OSI model? What are the various layers in the OSI model? 
What are data packets and frames?
Last Updated: Mar 27, 2024

Hub and Switch

Author Urwashi Priya
0 upvote
Master Python: Predicting weather forecasts
Ashwin Goyal
Product Manager @
Computer Networks


In this blog, we will discuss hub and switch. Both hub and switch are network connecting devices. Network devices are various hardware devices that are used to connect computers, printers, etc., to a network. These are also referred to as Networking hardware or Network equipment. These devices help to transfer data quickly, securely, and correct way over the same or different network. Each of these devices consists of a specific purpose.  For any machine to connect to the network, it first needs a network interface card or a wifi card. The network interface card is also known as ethernet card, network card, LAN card, network adapter card, network interface unit or terminal access point. It is a physical and data link layer device used by computers to connect and communicate with other devices on the LAN. A wifi card is used to connect any device to the local network wirelessly.


Network Interface Card

Source: hmhub

Also see, Message Switching in Computer Networks and Basic Networking Commands





The main purpose of a hub is to connect all present network devices together on a predefined internal network. Hub is a device consisting of multiple ports that accept ethernet connections from network devices. Hub is not considered to be an intelligent one because it doesn't filter any data present or has no intelligence to assume as to where the data is actually supposed to be sent, and that’s the reason because the only thing a hub knows is that when a device is actually connected to one of its ports. So whenever a data packet arrives at one of the ports, it is copied to all the other ports. So all the devices present on that hub see that data packet. So again, when a data packet comes into one port, the hub will just rebroadcast that data to every port that has a device connected to it.

HUB Network

                   Source: hub


So, even if only two computers among the entire group want to communicate, the other computers will also receive the data, even though it was not actually intended for them. So whenever this happens, it not only creates security concerns, but it also creates unnecessary traffic on the network, which wastes bandwidth.


  • Ability to connect to the network using various physical devices.
  • Cheaper compared to other devices.
  • Causes a minimum delay.
  • Does not affect the network’s performance.


  • Does not filter the data, hence wastage of bandwidth.
  • Makes the network insecure by sharing data to all devices present in the network.
  • Involves flooding of data.
  • Cannot connect token ring.


  • In small home networks.
  • Used to monitor various networks.
  • Used in computer laboratories for connectivity.
  • Helps in visibility of peripherals throughout.
Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job



                                                                                            Source: Switch

Now, a switch is very similar to a hub. It also has multiple ports that accept the Ethernet connections from various network devices present. But unlike our hub, a switch is the intelligent one. A switch can learn the physical addresses of the devices that are actually connected to it, and then it stores these physical addresses called MAC addresses in its table. So whenever a data packet is sent to a switch, it’s only directed to the intended destination port, unlike a hub where a hub will just rebroadcast the data to every port.

Switch Network

So as an example, if two computers here want to communicate with each other, the data packet first arrives at the switch, and then the switch will look at its table of MAC addresses and matching ports there and deliver the data to the correct port. And then, the data packet goes to the required computer.

So as a result, switch are far more preferred over hubs because they reduce any unnecessary traffic on the network.


  • Increases the bandwidth in the network.
  • Secure.
  • Lower the chances of collisions.
  • Can exchange the data simultaneously.
  • Transfers the data at different speeds.
  • Broadcast the data.


  • Expensive.
  • Potential problems may cause during broadcasting traffic.
  • Broadcasting may be troublesome.
  • Vulnerable to security attacks.
  • Proper design should be implemented.


  • Used to make connections with multiple hosts.
  • Used in data center construction.
  • Used to manage web user interface and command-line interface.
  • Used in VLAN configuration.

You can also read about the mime protocol, Layered Architecture in Computer Network, Subnetting in Computer Networks

Hub vs Switch



Only detects that a device is connected to it. Can detect specific devices that are connected to it.
Hubs only work in half-duplex mode. The switch works in full-duplex mode.
Hubs send the data in the form of packets. Switches send the data in the form of frames.
Hubs work in the physical layer of the OSI model. Switches work in the data link layer of the OSI model.

Hub and switch are used to exchange data within a local area network. They are not used to exchange the data outside their own network, such as out on the internet. Because to exchange or route data outside their own network to another network, a device needs to be able to read I.P addresses and hub, and the switch does not read I.P addresses. So that’s where the router comes in.

Till now, I assume you must have got a basic idea about hub and switch.

You can also read about the network models in computer network.

Related Article Stop and Wait Protocol 

Frequently Asked Questions

What is the MAC address and IP address?

MAC address is the physical address of the computer. It is used to identify various devices on the network. IP addresses are addresses that help uniquely identify the network's connection with the device that takes part in a network.

What is the OSI model? What are the various layers in the OSI model? 

OSI model is a model consisting of 7 layers. It helps in communication between computers. Different layers include the Physical layer, Data Link layer, Network layer, Transport layer, Session layer, Presentation layer, and Application layer.

What are data packets and frames?

In the network layer, the unit of data or information is referred to as packets. Frames are referred to in data link layer. They contain more information than packets.


This article taught us about hub and switch. We discussed individually about hub and switch and also their differences. We hope you could easily take away all critical and conceptual techniques by walking over the given examples. 

Recommended Readings:

To study more about Computer Networks, refer to disadvantages of computer network.

Also check out some of the Guided Paths on topics such as Data Structure and Algorithms, Competitive Programming, Operating Systems, Computer Networks, etc. as well as some Contests, Test Series, Interview Bundles, and some Interview Experiences curated by top Industry Experts only on Coding Ninjas Studio.


Previous article
Transmission Modes
Next article
Mesh Topology
Live masterclass