SkillPilotAI

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

TypeDestination MACWho receives itExample
UnicastOne device's MAC (last bit of first byte = 0)Only that device; switch forwards on one portLaptop -> printer 02:42:c0:a8:19:14
Broadcastff:ff:ff:ff:ff:ff (all 48 bits = 1)Every device in the LAN; switch floods every portARP: who has 192.168.25.20?
MulticastLast bit of first byte = 1; IPv4 starts 01:00:5eOnly group members (with IGMP snooping); a simple switch floods itIPTV live stream to the subscribed TV and PC
Broadcast then unicast (ARP + ping)
  1. 1.Laptop sends ARP request to ff:ff:ff:ff:ff:ff

  2. 2.Switch floods it out every port

  3. 3.Printer: 192.168.25.20 is me, replies unicast with its MAC

  4. 4.Laptop sends the ping as a unicast frame to 02:42:c0:a8:19:14

  5. 5.Switch forwards it only to the printer's port; PC and TV never see it

5.4 Fields of an Ethernet frame

FieldSizePurpose
Preamble + SFD8 bytesReceiver sync
Destination MAC6 bytesWho it is for (comes first so the switch decides fast)
Source MAC6 bytesWho sent it
EtherType2 bytesWhat is inside: 0x0800 IPv4, 0x0806 ARP
Payload46 to 1500 bytesThe IP packet
FCS4 bytesCRC-32 error check
A frame's journey and the FCS check
  1. 1.Laptop builds frame: dst = printer MAC, src = own MAC

  2. 2.Switch reads the destination MAC and forwards to the printer

  3. 3.Noise flips one bit on the way

  4. 4.Calculated CRC does not match the frame's FCS

  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.

Terminal
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
Output
$ 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).
PowerShell
getmacipconfig /all

5.7 Practical: the MAC header in tcpdump -e

Output
$ 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

Output
$ 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.
The MAC never leaves the LAN
  1. 1.Frame 1: laptop 02:42:c0:a8:19:0a -> home router 192.168.25.1

  2. 2.Router strips the Ethernet header, writes a new one with its own MAC

  3. 3.Frame 2: router -> ISP + internet (WAN)

  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.