Switches, Hubs, Bridges, and VLAN's
Published: 2021-07-26 02:10:58

*In this article, I will go over switches, hubs, and bridges. I will explain what these devices are, how they work, use-cases and advantages and disadvantages. I will also explain what a VLAN is, how it works and why we would use them*

<h1>Hub</h1>
 ![Hub Device](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vc3j4whr0dtyhjamu19h.jpg)

- This is a networking device that connects PC's to a single network. 
- This stores multiple ports, so when a packet arrives at one port, every other port also receives it.
- This uses the Bus Topology Network as seen below.
![Bus Topology](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/461lcmwygig2eyom3yy7.png)
- If Computer 1 sends data to Computer 2, Computer 3, 4, and 5 will also receive that data. 
- This is commonly used in LAN(Local Area Networks) like in an office or campus.
- This device is half-duplex. This means that PC's can not send and receive data at the same time. If this does happen, this would cause a collision. 
- This operates on the Physical Layer, also known as Layer 1.

<h2>How Does A Hub Work?</h2>

The implementation of a hub is fairly straight-forward. 

Let's say you have a 5 PC's that you want to connect to the network. 

You would plug each PC with a ethernet cable into the port of the hub. 

Once, you plugged them all in, they can communicate to each and every one of the PC's connected to the switch. 

<hr/>

<h1>Switch</h1>

![Switch Device](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1tb08rbriapbxertbv69.jpg)

- This is a networking device that connects various devices to a single computer network.
- This is commonly used in LAN (Local Area Network) as well!
- Operates in Data Link Layer, or also known as Layer 2.
- Maintains a MAC Address Table of each device. 
- Uses Frames and Packets
- Commonly used in SOHO(Small Office/Home Office) as well!
- Uses Full Duplex. This means each device can send and receive at the same time.
- Uses the star topology network as seen below.
![Star Topology Network](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qfh34gj5egcqjnb9ef8p.jpg)
- The big difference between a switch and a hub, is that when PC1 sends data to PC2, only PC2 will get it. No other devices on the network will receive that data. 
- This is super important because if that data is sensitive, we don't want anyone else to see it as well.
- Switches also allow for VLANS (Virtual Local Area Networks)

<hr/>

<h1>Bridge</h1>
![Bridge Device](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w8bv4jit3bbrz584u4jy.png)
- Bridges are used to connect two or more subnetworks. 
- It combines two LAN's to form an extended LAN.
![Bridge](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l3ivb567dltx9pae8lyc.jpg)

- It stores all the MAC Addresses of each device into a table.
- When PC1 sends data over to PC2, it will first go to the bridge.
- The bridge will determine which MAC Address it needs to go to and it will send it to the appropriate one.
- This is used to reduce network traffic and increase performance because the LAN is now divided into segments.

<hr/>

<h1>VLAN</h1>
- VLAN (Virtual Local Area Network) is when you break up a LAN into smaller subnetworks. 
- This can be accomplished by using a Switch or Router.
- VLAN's are great for security as well.

![VLAN Diagram](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vudnbvwfi1xw5k54t3gm.png)

<h2>How Does This Work?</h2>
 - Imagine we are using a LAN at an office. 
 - There are several departments: Sales, Management, 
   Engineering, Marketing, Etc.
 - We do not want the Sales department to know about any 
   network traffic or data flowing inside the Engineering 
   Department. That is only for Sales. It could have 
   sensitive data as well that only Sales should know 
   about. 
 - This is where we break the LAN up. 
 - We can designate 5 ports for Sales, 3 Ports for 
  Engineering, 7 ports for Management and 2 ports for 
  Marketing.
 - Each department basically is within it's own "virtual" 
  network. It's like they have their own independent 
  network that no one else can see. 
 - This is the idea behind VLAN's. 
 - This also reduces network traffic. You do not want to 
   see traffic from every single department. 

<hr/>

*I hope this article has helped you in understanding these various network devices and how they work along with VLAN. If you have any questions, comments, or concerns, please feel free to let me know!*