Linkethernetframemacswitchmac table

Ethernet: Delivery on One Local Network

Ethernet moves frames between interfaces that share a segment, addressed by MAC; a switch learns which port each MAC lives behind by watching source addresses, floods what it has not learned, and turns one shared cable into a set of private conversations — Wi-Fi is a different medium with the same addressing idea.

ConceptualEducational model
▶ InteractiveInterview question
Progress

The problem

Twelve machines are plugged into the same box. When one sends a frame, how does it reach exactly the right neighbour rather than all of them — and how does the box know where anyone is, given that nobody told it?

A frame on a segment

The link layer’s job is small and local: get a frame from one interface to another interface on the same physical network — the same segment — without any notion of what lies beyond. An Ethernet frame is a destination MAC, a source MAC, an EtherType saying what the payload is, 46–1500 bytes of payload, and a 4-byte CRC. Nothing in it says which network the sender or receiver is on, because on a segment there is only one.

Historically the segment was literally one cable: every station saw every frame, read the destination MAC, and kept only its own. Two stations transmitting at once produced a collision, detected by CSMA/CD and resolved by random backoff; the set of stations that could collide was the collision domain, and it shrank with every hub replaced by a switch. On modern full-duplex switched Ethernet collisions do not occur — each cable carries one station in each direction — and the term survives only in textbooks and in Wi-Fi, where the air is still shared.

What does survive is the broadcast domain: the set of interfaces that receive a frame sent to ff:ff:ff:ff:ff:ff. ARP requests, DHCP discovery and IPv6 neighbor solicitation (as multicast) all depend on it. A broadcast domain is what "local network" means at the link layer, and a router is precisely the device that ends one.

Laptop → switch → router
port 1port 2port 3port 24WANLaptop aa:..:01Desktop aa:..:02Printer aa:..:03Switch MAC tableRouter (gateway) aa:..:0aInternet
UserLLMAgentToolDataDecisionHumanGuardrail

How a switch learns

Educational model

A switch is a multi-port bridge with a MAC address table (also called the CAM table or forwarding database) mapping MAC → port. It starts empty. It fills the table by learning from source addresses: every frame that arrives on port 3 with source aa:..:03 teaches the switch that aa:..:03 is reachable via port 3. No configuration, no protocol — just observation. Entries age out (typically after 300 s of silence) so that a laptop moved to another port is relearned.

Forwarding uses the table in the other direction. A frame arrives; the switch looks up its destination MAC. If the table has it, the frame is copied out of that one port and no other — this is what makes a switch private where a hub was not. If the table does not have it, or the destination is broadcast or multicast, the switch floods the frame out of every port except the one it came in on. The reply from the unknown destination will carry its MAC as source, the switch learns it, and the next frame is unicast. Flooding is the bootstrap, not the steady state.

The table is a hash lookup on a 48-bit key, done in hardware at line rate for every frame. Enterprise switches hold tens of thousands of entries; the classic attack is MAC flooding — sending frames from millions of fake sources until the table is full and the switch degrades to flooding everything, which lets an attacker on any port see all traffic.

A switch’s table after a few frames (educational model)
MAC               port  age
aa:bb:cc:00:00:01   1    12s    laptop
aa:bb:cc:00:00:02   2    40s    desktop
aa:bb:cc:00:00:03   3    3s     printer
aa:bb:cc:00:00:0a  24    1s     router (gateway)

frame from port 1: dst aa:..:0a  → table hit → forward out port 24 only
frame from port 2: dst aa:..:77  → miss     → flood out ports 1,3,24 (not 2)
frame from port 3: dst ff:ff:..  → broadcast→ flood out ports 1,2,24

Cutting a switch into pieces: VLANs

One physical switch often needs to be several logical networks — guests must not see printers, the phone system must not share a broadcast domain with 400 laptops. A VLAN tags each port (or each frame, with an 802.1Q header inserted after the source MAC) with a 12-bit VLAN id, and the switch keeps a separate MAC table and a separate broadcast domain per VLAN. A frame in VLAN 10 is never forwarded or flooded to a VLAN 20 port. Crossing between VLANs requires a router — exactly as crossing between physical networks does — which is what a layer-3 switch does internally.

A trunk port carries several VLANs, each frame tagged, between two switches or to a router; an access port belongs to one VLAN and its frames are untagged. Most container and cloud networking (VXLAN, overlays) is this idea scaled up: a virtual segment identifier that keeps tenants’ broadcast domains apart over shared hardware.

Wi-Fi: a different link, the same addressing

802.11 is not Ethernet: the medium is shared air, half-duplex, with collisions avoided rather than detected (CSMA/CA — listen, wait a random slot, transmit, wait for an acknowledgment). Frames have up to four MAC address fields (source, destination, transmitter, receiver, because the access point relays), the header is longer, and the link layer retransmits on a missing acknowledgment — which is why a lossy Wi-Fi link shows up to IP as jitter and delay rather than loss. Rates adapt per frame to signal quality; a 1 Gbit/s label describes the best case for one client at close range with nothing else talking.

But from IP’s point of view Wi-Fi is another link with 48-bit MAC addresses, an MTU of 1500, broadcast and multicast, and ARP or Neighbor Discovery on top. The access point bridges Wi-Fi frames to Ethernet frames — same source and destination MACs, different framing — and your laptop is in the same broadcast domain as the wired desktop. The practical consequences: Wi-Fi is where most "the network is slow but nothing is dropping" complaints originate, and where MAC randomisation and roaming between access points make link-layer identity unstable.

  • Ethernet: full-duplex, no collisions, no link-layer retransmission — loss is loss.
  • Wi-Fi: shared air, CSMA/CA, link-layer acknowledgments and retries — loss becomes latency.
  • Both: 48-bit MACs, EtherType, 1500-byte MTU, one broadcast domain per SSID/VLAN.

Key points

  • Ethernet delivers frames between interfaces on one segment, addressed by MAC; it has no concept of another network.
  • A switch learns MAC → port from source addresses, forwards known destinations out one port, floods unknown, broadcast and multicast frames.
  • Flooding is the bootstrap; a full table is the steady state. A full table (MAC flooding) degrades the switch to a hub.
  • Collision domains are history on switched Ethernet; broadcast domains are alive and are what "local network" means.
  • VLANs split one switch into several broadcast domains; crossing between them needs routing.
  • Wi-Fi is a different medium with link-layer retries and adaptive rates, but the same MAC addressing and MTU — loss shows up as latency.

Why does this exist?

Mechanisms are answers to constraints. Open each question before reading the answer.

Why does a switch learn instead of being configured?

Plug-and-play was the design goal: with hundreds of devices moving between ports, a configured table would be wrong within a day. Watching source addresses is free and self-correcting.

Why flood at all — is that not a leak?

The alternative is dropping frames to unknown destinations, which would break every first contact. Flooding costs one frame per port once; the reply fixes the table. Broadcast domains are kept small (VLANs) so the cost stays small.

Why does Wi-Fi retransmit when Ethernet does not?

Air is lossy enough that without link-layer retries TCP would see loss rates of several percent and collapse its window. Wired links are clean enough that retries would be wasted machinery.

Switch forwarding

traffic
VLANs
Switch forwarding
A switch learns source MACs, floods unknown destinations, and forwards known ones out a single port.
A82:87:9bport 1B97:d9:89port 2C14:87:9bport 3D73:7a:d7port 4switch
MAC table
idle
(empty)
MAC table empty. The switch knows nothing until it sees frames.
Log: Power on
1/4 · Power on

How it fails

What the failure looks like from inside real software.

  • A switching loop with no spanning tree: a broadcast frame circulates forever, the MAC table flaps between ports, every link saturates within seconds — a "broadcast storm".
  • MAC table exhaustion: an attacker floods fake source addresses; the switch floods all traffic to all ports and a sniffer sees everything.
  • Wrong VLAN on a port: the machine gets a link, sends DHCP discover into a broadcast domain with no DHCP server, and ends up with a 169.254 address.
  • Wi-Fi retry storms: a client at the edge of range gets 10–30% frame loss, retried at the link layer, and every application sees 200 ms of jitter with zero reported packet loss.
  • Duplex mismatch (older gear): one side full-duplex, the other half; late collisions and CRC errors on a link that reports "up".