</>
ShikshaCSLearn. Code. Grow.
๐Ÿ”
โ˜• Support Us
ShikshaCSโ€บNotesโ€บComputer Networks
Computer Networks
๐Ÿ•’ 9 min read

MAC Addressing and Switching

The permanent hardware 'ID card' every network device carries, and how switches use it.

What is a MAC Address?

A MAC (Media Access Control) address is a unique 48-bit identifier permanently burned into every network interface card (the hardware inside your device that lets it connect to a network) at the time of manufacture. Written as 6 pairs of hexadecimal digits (like 00:1A:2B:3C:4D:5E), no two devices in the world are supposed to share the same MAC address.

MAC vs IP Address

A MAC address identifies a device's HARDWARE and never changes (it's tied to the physical network card). An IP address identifies a device's LOCATION on a network and can change depending on which network you connect to. Think of MAC as your permanent fingerprint, and IP as your current mailing address โ€” both are needed for data to actually reach you correctly.

What is a Switch?

A switch is a Data Link layer device that connects multiple devices within a LAN. Unlike an older 'hub' (which blindly broadcasts every message to every connected device), a switch is smart โ€” it learns which MAC address is connected to which physical port, and sends data ONLY to the specific device it's intended for.

How a Switch Learns

When a switch first receives a frame from a device, it records that device's MAC address alongside the port it arrived on, in something called a MAC address table. For future messages TO that device, the switch checks this table and forwards the frame directly out the correct port โ€” avoiding wasteful broadcasting to devices that don't need the data.

What Happens with an Unknown MAC Address

If a switch receives a frame destined for a MAC address it hasn't learned yet, it temporarily 'floods' the frame out of every port except the one it arrived on (similar to a hub's behavior, but only for that one unknown case) โ€” once the correct device responds, the switch learns its port and stops flooding for that address.

๐ŸŒ Real-World Use

Every device connected to your home Wi-Fi router โ€” phone, laptop, smart TV โ€” has a unique MAC address. Your router's switch keeps track of these to intelligently send data only to the right device, instead of blasting every message to every connected device (which would waste bandwidth and slow everything down).

๐Ÿ’ก Pro Tip

A very common interview/exam question: 'why do we need both MAC and IP addresses if one identifies a device?' โ€” the key answer is that MAC works at the LOCAL network level (Data Link layer) for direct hardware delivery, while IP works GLOBALLY (Network layer) to route data across different networks โ€” you genuinely need both for the internet to function.

๐Ÿงช Quick Self-Test

Check what you just learned โ€” no pressure, just practice.

1. How many bits make up a standard MAC address?

2. What is the key difference between a MAC address and an IP address?

3. How does a switch decide where to send a frame?

โ† Back to all Notes