MAC address and the Ethernet frame
The MAC address is the 48-bit hardware address of a network card, and the Ethernet frame is the Layer 2 envelope that carries it. A switch looks at the destination MAC to deliver the frame to the right device inside a LAN.
5.1 Why is it used?
- A switch has many ports: when the laptop sends a file to the printer, how does the switch pick the port?
- Every NIC has a unique hardware address, the MAC address; the switch reads the destination MAC and forwards the frame to that device.
- Your IP changes with the network, but the MAC usually stays the same.
5.2 MAC address format and OUI
- 48 bits = 6 bytes, written as 12 hex digits.
- Linux/macOS: 02:42:c0:a8:19:0a. Windows: 02-42-C0-A8-19-0A. Same address, different separator.
- Burned into the NIC by the manufacturer, so also called the physical or hardware address.
- First 3 bytes = OUI (Organizationally Unique Identifier), assigned by IEEE to the manufacturer. E.g. 00:50:56 = VMware, B8:27:EB = Raspberry Pi.
- Last 3 bytes = the card's unique number, given by the manufacturer.
- Second-last bit of the first byte = locally administered. 02:xx (our Docker lab, a phone's random Wi-Fi MAC) has this bit on.
5.3 Unicast, multicast and broadcast MAC
| Type | Destination MAC | Who receives it | Example |
|---|---|---|---|
| Unicast | One device's MAC (last bit of first byte = 0) | Only that device; switch forwards on one port | Laptop -> printer 02:42:c0:a8:19:14 |
| Broadcast | ff:ff:ff:ff:ff:ff (all 48 bits = 1) | Every device in the LAN; switch floods every port | ARP: who has 192.168.25.20? |
| Multicast | Last bit of first byte = 1; IPv4 starts 01:00:5e | Only group members (with IGMP snooping); a simple switch floods it | IPTV live stream to the subscribed TV and PC |
- Step 1
1.Laptop sends ARP request to ff:ff:ff:ff:ff:ff
- Step 2
2.Switch floods it out every port
- Step 3
3.Printer: 192.168.25.20 is me, replies unicast with its MAC
- Step 4
4.Laptop sends the ping as a unicast frame to 02:42:c0:a8:19:14
- Step 5
5.Switch forwards it only to the printer's port; PC and TV never see it
5.4 Fields of an Ethernet frame
| Field | Size | Purpose |
|---|---|---|
| Preamble + SFD | 8 bytes | Receiver sync |
| Destination MAC | 6 bytes | Who it is for (comes first so the switch decides fast) |
| Source MAC | 6 bytes | Who sent it |
| EtherType | 2 bytes | What is inside: 0x0800 IPv4, 0x0806 ARP |
| Payload | 46 to 1500 bytes | The IP packet |
| FCS | 4 bytes | CRC-32 error check |
- Step 1
1.Laptop builds frame: dst = printer MAC, src = own MAC
- Step 2
2.Switch reads the destination MAC and forwards to the printer
- Step 3
3.Noise flips one bit on the way
- Step 4
4.Calculated CRC does not match the frame's FCS
- Step 5
5.Frame silently dropped (no error message); TCP above recovers
5.5 MTU 1500 and jumbo frames
- MTU (Maximum Transmission Unit) = max payload; Ethernet default is 1500 bytes.
- Ping data max = 1500 - 20 (IP header) - 8 (ICMP header) = 1472 bytes.
- Jumbo frames: MTU up to 9000, used in data centers and storage networks; more data per frame, less overhead.
- Every device on the path must use the same MTU, or the big frames are dropped.
5.6 Practical: the laptop's MAC and MTU
Docker LAN: laptop 192.168.25.10, printer 192.168.25.20.
ip link show eth0ip maddr show dev eth0tcpdump -e -n -i eth0 -c 6 arp or icmpping -c 1 192.168.25.20ping -c 1 -M do -s 1472 192.168.25.20ping -c 1 -M do -s 1473 192.168.25.20ip link set dev eth0 mtu 9000$ ip link show eth02: eth0@if203: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 link/ether 02:42:c0:a8:19:0a brd ff:ff:ff:ff:ff:ff$ ip maddr show dev eth02: eth0 link 33:33:00:00:00:01 link 01:00:5e:00:00:01 inet 224.0.0.1- link/ether 02:42:c0:a8:19:0a = the laptop's MAC; brd ff:ff:ff:ff:ff:ff = broadcast address; mtu 1500.
- ip maddr: multicast groups the NIC joined; 01:00:5e:00:00:01 is the IPv4 multicast MAC for 224.0.0.1.
- On Windows the MAC is in getmac or ipconfig /all (Physical Address).
getmacipconfig /all5.7 Practical: the MAC header in tcpdump -e
$ tcpdump -e -n -i eth0 -c 6 arp or icmplistening on eth0, link-type EN10MB (Ethernet)02:42:c0:a8:19:0a > ff:ff:ff:ff:ff:ff, ethertype ARP Request who-has 192.168.25.20 tell 192.168.25.1002:42:c0:a8:19:14 > 02:42:c0:a8:19:0a, ethertype ARP Reply 192.168.25.20 is-at 02:42:c0:a8:19:1402:42:c0:a8:19:0a > 02:42:c0:a8:19:14, ethertype IPv4 192.168.25.10 > 192.168.25.20: ICMP echo request02:42:c0:a8:19:14 > 02:42:c0:a8:19:0a, ethertype IPv4 192.168.25.20 > 192.168.25.10: ICMP echo reply- -e prints each packet with its Ethernet header (MAC addresses).
- Frame 1: ARP request from the laptop's MAC to the ff:ff broadcast.
- Frame 2: ARP reply from the printer, unicast: 192.168.25.20 is-at 02:42:c0:a8:19:14.
- Ping request and reply are unicast frames with ethertype IPv4.
5.8 Practical: the 1500 limit and jumbo frames
$ ping -c 1 -M do -s 1472 192.168.25.20PING 192.168.25.20 (192.168.25.20) 1472(1500) bytes of data.1480 bytes from 192.168.25.20: icmp_seq=1 ttl=641 packets transmitted, 1 received, 0% packet loss$ ping -c 1 -M do -s 1473 192.168.25.20ping: local error: message too long, mtu=15001 packets transmitted, 0 received, +1 errors$ ip link set dev eth0 mtu 9000$ ip link show eth02: eth0@if203: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000- -M do = don't fragment; -s 1472 makes the IP packet exactly 1500 bytes, so the reply comes back.
- -s 1473 is one byte too many: message too long, mtu=1500.
- ip link set dev eth0 mtu 9000 sets a jumbo MTU; on a real network the switch and receiver must also support 9000.
5.9 Common mistakes
- Myth: your MAC travels across the internet and websites can see it. A MAC only works inside one LAN.
- The router removes the old Ethernet header and adds a new one with its own MAC; the IP stays the same end to end.
- Thinking 01:xx is unicast: a last bit of 1 in the first byte means a group (multicast) address; ff:ff... broadcast is technically a group address too.
- Enabling jumbo frames on one device only: big frames get dropped.
- Step 1
1.Frame 1: laptop 02:42:c0:a8:19:0a -> home router 192.168.25.1
- Step 2
2.Router strips the Ethernet header, writes a new one with its own MAC
- Step 3
3.Frame 2: router -> ISP + internet (WAN)
- Step 4
4.Google DNS 8.8.8.8 receives the packet: the laptop's MAC is unknown to it
IP is end to end, MAC changes at every hop
5.10 Interview tips
- MAC vs IP: MAC is 48-bit, Layer 2, burned into the NIC, used only inside the LAN; IP is 32-bit, Layer 3, logical, used for end-to-end routing. ARP finds the MAC for an IP.
- OUI = first 3 bytes, identifies the manufacturer.
- Frame fields: preamble/SFD, dst MAC, src MAC, EtherType, payload (46-1500), FCS.
- MTU 1500, max ping payload 1472 with DF set; jumbo = 9000 and must match end to end.
- Bad FCS = frame silently dropped.