Ethernet, MAC Addresses and Switching
How devices on the same local network find each other: Ethernet frames, MAC addresses, how a switch learns where devices are, and what a broadcast domain is.
The local link: layer 2
The last lesson showed that every IP packet is wrapped in a frame before it is sent. Frames only travel across one link at a time: from your laptop to the switch, from the switch to the router. Layer 2 is about delivery on that local link. Delivery across the world is layer 3, which comes next.
On wired local networks the dominant layer 2 technology is Ethernet, standardised by the IEEE as 802.3. Wi-Fi (IEEE 802.11) uses a similar addressing scheme with a different way of sharing the medium.
MAC addresses
Every network interface has a MAC (Media Access Control) address: 48 bits, written as six pairs of hexadecimal digits, for example 3C:22:FB:9A:10:4E.
- The first half (three bytes) is the OUI, assigned by the IEEE to the manufacturer. You can look an OUI up to see who made a device, which is useful when you find an unknown device on a network.
- The second half is assigned by the manufacturer.
- A MAC address is meant to be unique, but it is not secret and not a security control. Operating systems can change it, and many phones now randomise it per Wi-Fi network for privacy.
Special addresses: FF:FF:FF:FF:FF:FF is the broadcast address (every device on the local network). Addresses whose first byte has its lowest bit set are multicast.
The Ethernet frame
A simplified Ethernet II frame contains:
| Field | Size | Purpose |
|---|---|---|
| Destination MAC | 6 bytes | Who should receive this frame on this link |
| Source MAC | 6 bytes | Who sent it |
| EtherType | 2 bytes | What is inside (0x0800 = IPv4, 0x86DD = IPv6, 0x0806 = ARP) |
| Payload | 46 to 1500 bytes | The packet (the usual maximum, the MTU, is 1500 bytes) |
| FCS | 4 bytes | A checksum; a frame that fails it is discarded |
When a VLAN tag is used (a later topic), an extra 4 bytes sit between the source MAC and EtherType.
Hubs, switches and how a switch learns
Early Ethernet used hubs, which repeat every frame out of every port. Everyone sees everything, and only one device can talk at a time. A switch is smarter. It keeps a MAC address table (also called the CAM table or forwarding table) mapping MAC addresses to ports, and forwards each frame only where it needs to go.
The switch builds that table on its own:
- Learn: when a frame arrives, record the source MAC address against the port it arrived on.
- Forward: look up the destination MAC address. If it is in the table, send the frame out of that port only.
- Flood: if the destination is not known (or is the broadcast address), send the frame out of every port except the one it came in on.
- Age: entries that are not refreshed are removed after a timeout (five minutes is a common default).
Suppose PC A sends to PC B for the first time. The switch learns “AA is on port 1”, does not yet know BB, and floods the frame. PC B receives it and replies. The switch learns “BB is on port 2”. From now on, traffic between A and B goes only through ports 1 and 2, and PC C never sees it.
Broadcast domains
A broadcast domain is the set of devices that receive a broadcast frame sent by any one of them. All the ports of a basic switch form one broadcast domain. Routers do not forward broadcasts, so each router interface is the boundary of a broadcast domain.
Why this matters: broadcasts are needed for things like ARP and DHCP discovery, but if one domain grows very large the broadcast traffic interrupts every device. Splitting a large network into several smaller ones (with VLANs and routers) keeps it manageable and limits the blast radius of problems.
Duplex and speed
Modern switch ports and network cards normally auto-negotiate speed (10/100/1000 Mbit/s and beyond) and full duplex (send and receive at the same time). A common, hard-to-spot fault is a duplex mismatch, where one side is forced to a setting the other did not agree to. It shows up as a link that is “up” but slow, with many errors. Auto-negotiation on both ends is the usual fix.
Check your own device
Find your interface’s MAC address:
# Linux
ip link show
# Windows (PowerShell)
Get-NetAdapter | Format-Table Name, MacAddress, LinkSpeed
# macOS
ifconfig en0 | grep ether
On a switch you can usually display the MAC address table. The command name varies by vendor (for example show mac address-table on many Cisco-style systems). Look for your device’s MAC and the port it appears on.
A switch has just been powered on and has an empty MAC address table. PC A sends a frame to PC B. Describe what the switch does, and what happens when PC B replies.
The switch learns that A’s MAC address is on A’s port, then, not knowing B’s address, floods the frame out of all other ports. PC B receives it (other hosts ignore it because the destination MAC is not theirs). When B replies, the switch learns B’s MAC and port, and since A’s MAC is already in the table it forwards the reply to A’s port only. Later frames between A and B are forwarded directly.
Can You Explain It?
Close the lesson and answer these without looking back. The goal isn't the wording — it's whether you've formed a usable mental model.
- What is the difference between a hub and a switch?
- Why is a MAC address not suitable as a security control?
- What is a broadcast domain, and what device marks its boundary?
🧪 Want to practise this on your own computer? See how to set up your lab →