š Switches Explained
Everything Switches Do ā Part 1 & Part 2
Series: Networking Fundamentals for Cloud & DevOps ā Part 4 of 6
We already know that Layer 2 is responsible for hop-to-hop communication and that MAC addresses identify devices on a local network. Now we can look at the device that actually uses those MAC addresses to move frames around: the switch.
Switches ā Simple Explanation
A switch connects devices within the same network and moves data between them.
The key points:
- A switch is mainly a Layer 2 device.
- It mainly looks at MAC addresses, not IP addresses.
- It maintains a MAC Address Table.
Think of the switch as maintaining a map:
Switch Port ā MAC Address
Port 5 ā a1a1 (Host A)
Port 6 ā c3c3 (Host C)
Port 7 ā b2b2 (Host B)
Port 8 ā d4d4 (Host D)
The switch uses this table to determine which port should receive a frame.
How a Switch Handles a Frame
Suppose A wants to send data to D:
A (a1a1) āāā Switch āāā D (d4d4)
The frame arrives at the switch:
SRC MAC = a1a1
DST MAC = d4d4
The switch performs three important actions.
1. Learn
The switch sees the source MAC arriving on Port 5:
a1a1 ā Port 5
So it records:
Port 5 ā a1a1
This is how the switch learns where devices are.
2. Forward
The switch looks at the destination MAC:
d4d4
It checks its MAC address table and finds:
d4d4 ā Port 8
3. Send
The switch sends the frame only through Port 8 to D.
A āāā Switch āāāāāāāāāā D
Port 8
It does not send the frame to every connected device when it already knows the correct destination port.
What If the Destination MAC Is Unknown?
Suppose the switch receives a frame on Port 5, but it doesn't yet know where the destination MAC exists.
For example:
Incoming Port = 5
Destination MAC = d4d4
If d4d4 is not in the MAC address table, the switch floods the frame.
Incoming
Port 5
ā
āāāāāāāāāāāāā
ā Switch ā
āāāāāāāāāāāāā
ā ā ā
Port 6 Port 7 Port 8
The frame is sent out all relevant ports except the port it arrived on.
Once the switch learns where a MAC address is, future frames can be forwarded directly.
So remember:
Known destination ā Forward to the correct port.
Unknown destination ā Flood.
Switch vs Router
This distinction is extremely important.
| Device | Main Job | Looks At |
|---|---|---|
| Switch | Move data within a network | MAC address (L2) |
| Router | Move data between networks | IP address (L3) |
Think of it this way:
Same network
A āāāāā Switch āāāāā B
Different networks
A āāāāā Switch āāāāā Router āāāāā Switch āāāāā B
The switch handles Layer 2 forwarding inside a network.
The router handles Layer 3 forwarding between networks.
One Important Detail ā A Switch Can Have an IP Address
For normal traffic passing through a switch:
Frame ā Switch ā Destination
The switch forwards the frame using MAC addresses.
But the switch itself can also have:
IP + MAC
for management.
In that situation, it behaves like a host:
A āāāāā Switch
A may need to use ARP to discover the switch's MAC address when communicating with the switch's management IP.
So don't think:
"A switch never has an IP address."
A better rule is:
A switch forwards normal Layer 2 traffic using MAC addresses, but it can have an IP address for management.
Part 2 ā Unicast, Broadcast, VLANs, and Multiple Switches
Now that we understand the basic Learn ā Forward ā Flood behavior, we can look at the situations where switching becomes more interesting.
The main concepts here are:
- Unicast vs Broadcast
- VLANs
- Multiple switches
1. Unicast vs Broadcast
The easiest way to understand this distinction is:
Unicast = one specific receiver
Broadcast = everyone in the relevant network/VLAN
Unicast
One sender communicates with one specific receiver.
Example:
A āāāāāāāāāāāāāāāāāā D
Suppose:
SRC MAC = a1a1
DST MAC = d4d4
If d4d4 is already in the switch's MAC table:
d4d4 ā Port 8
The switch forwards the frame only to D's port.
If d4d4 is not in the MAC table, the switch floods the frame to all relevant ports except the incoming port.
So:
Known unicast
ā Forward only to the destination port
Unknown unicast
ā Flood because the destination is unknown
Broadcast
A broadcast is intended for everyone in the network/VLAN.
The Ethernet broadcast MAC address is:
ff:ff:ff:ff:ff:ff
A classic example is an ARP Request:
A āāāāā Switch
āāā B
āāā C
āāā D
The switch floods the broadcast frame within the relevant VLAN.
So remember:
Broadcast = type of frame
Flood = action performed by the switch
These are not the same thing.
A broadcast frame is flooded by the switch because its purpose is to reach everyone in the relevant Layer 2 domain.
2. VLAN
VLAN = Virtual Local Area Network
A VLAN logically divides one physical switch into separate networks/groups.
Imagine:
One Physical Switch
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā ā
ā VLAN 20 VLAN 30 ā
ā āāāāāāā āāāāāāā ā
ā ā A B ā ā C D ā ā
ā āāāāāāā āāāāāāā ā
ā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Even though A, B, C and D are connected to the same physical switch:
A, B ā VLAN 20
C, D ā VLAN 30
A and C cannot directly communicate at Layer 2 because they are in different VLANs.
Think of a VLAN as turning one physical switch into multiple logical mini-networks.
Broadcasts and VLANs
The switch performs:
Learn ā Flood ā Forward
independently within each VLAN.
So if A sends a broadcast:
A ā VLAN 20
āāā B ā
āāā C ā
āāā D ā
The broadcast stays inside VLAN 20.
This is one of the important reasons VLANs are useful: they create separate Layer 2 broadcast domains.
3. Multiple Switches
A network can contain more than one switch:
A āāā Switch 1 āāā Switch 2 āāā B
Each switch has its own MAC Address Table.
They do not share one common MAC table.
Suppose A sends a frame:
A
MAC = aaaa.aaaa.aaaa
ā
Switch 1
ā
Switch 2
ā
B
Switch 1
Switch 1 receives the frame on Port 1:
Port 1 ā aaaa.aaaa.aaaa
So Switch 1 learns:
1 ā A
It doesn't necessarily know where B is yet, so it may flood the frame.
Switch 2
When the frame reaches Switch 2, Switch 2 independently learns the source MAC:
Port 4 ā aaaa.aaaa.aaaa
Notice the important point:
Switch 1:
1 ā A
Switch 2:
4 ā A
The same MAC address can appear on different ports on different switches.
That's because each switch maintains its own local MAC Address Table.
4. How the Switches Eventually Learn the Path
Suppose B replies to A:
B āāā Switch 2 āāā Switch 1 āāā A
Switch 2 receives B's frame.
Suppose B's MAC is:
bbbb.bbbb.bbbb
Switch 2 learns:
6 ā B
When Switch 1 receives that same frame through its inter-switch port, it independently learns:
3 ā B
Now both switches know where B is.
Later, if B sends to A:
Switch 2
A is on Port 4
ā forward to Port 4
Switch 1
A is on Port 1
ā forward to Port 1
So the frame travels only along the required path.
B āāā Switch 2 āāā Switch 1 āāā A
Port 4 Port 1
The important idea is:
Switches learn locally. They don't need one shared MAC table.
The Complete Switch Picture
This is the mental model to remember:
SWITCH
ā
āāā MAC Address Table
ā
āāā Learn
ā āāā Source MAC ā Incoming Port
ā
āāā Forward
ā āāā Known Destination MAC ā Correct Port
ā
āāā Flood
ā āāā Unknown Destination / Broadcast
ā
āāā VLAN
ā āāā Separates one physical switch into logical networks
ā
āāā Multiple Switches
āāā Each switch has its own MAC table
One-line revision
A switch learns source MACs, forwards known unicast frames, floods unknown/broadcast frames, and maintains a separate MAC table for each switch/VLAN context.
The Core Idea to Carry Forward
Everything here connects back to the Layer 2 concepts from the OSI Model:
L2 ā MAC
ā Switching
ā Hop-to-hop
So when you see a switch, think:
MAC Address
ā
MAC Address Table
ā
Learn ā Forward / Flood
ā
Move the frame within the Layer 2 network
And the simple distinction remains:
Switch ā MAC-based forwarding inside a network
Router ā IP-based forwarding between networks
This foundation becomes directly useful when we later work with VPCs, subnets, route tables, security groups, NACLs, load balancers, and connectivity troubleshooting in AWS.
Part 4 of 6 ā Networking Fundamentals for Cloud & DevOps
Next: Routers ā how Layer 3 devices move packets between different networks.
Top comments (0)