Networking

Ethernet

IP addresses and ports are logical — they exist as numbers in software. Something still has to physically move electrical signals down a wire (or radio waves, for Wi-Fi) from one device to the next. That's Ethernet's job: the local, one-hop delivery layer that everything else, including IP, ultimately rides on top of.

Quick reference
What it is
The physical/data-link layer that moves frames between two devices on the same local network, addressed by MAC address.
Mental model
Local hand-to-hand delivery inside one building — it has no idea what "the internet" is, only "the device next to me on this wire."
Key numbers
MAC addresses are 48 bits (6 hex byte-pairs); a standard frame carries up to 1500 bytes of payload (the MTU).
Reach for it when
You don't choose it directly — every IP packet needs an Ethernet (or Wi-Fi) frame to actually leave the device on a wired/wireless LAN.

MAC addresses

The physical cable

Everything above is about the frame; this is about the wire it actually travels down. A standard Ethernet cable carries 4 twisted pairs of copper wires — twisted specifically to cancel out electromagnetic interference between adjacent pairs — terminated in an RJ45 connector at each end.

Cat5e
Up to 1 Gbps, the long-standing baseline for most existing home/office wiring.
Cat6
Up to 10 Gbps over short runs, tighter twist rates and better shielding than Cat5e.
Cat6a / Cat8
Higher speeds and/or longer guaranteed run lengths at 10 Gbps, for data-center and future-proofed installs.
Fiber
Light instead of electricity — immune to electromagnetic interference entirely, and able to run vastly further than copper before the signal degrades, at real added cost and fragility.

A cable's category rating is a real, physical property of the copper and its twisting — plugging a 10 Gbps-capable switch and network card into each other over an old Cat5 cable still caps the link at whatever that cable's own rating actually supports.

The Ethernet frame

An Ethernet frame wraps whatever it's handed — an IP packet, almost always — with a small header in front and a checksum at the end. It never needs to understand what's inside; it just delivers the whole thing to the interface with the matching destination MAC address.

An Ethernet frame's structure: preamble, destination MAC, source MAC, type, payload, and a trailing checksum preamble dest MAC 3C:E1:A1:9B:04:7F source MAC 88:66:5A:12:C0:03 type payload (the IP packet) checksum 14 bytes of header, up to 1500 bytes of payload, 4 bytes of trailing checksum (FCS)
Ethernet doesn't care what's inside the payload — it just delivers this whole frame to the interface owning the matching destination MAC.

How a switch forwards frames

A switch learns which MAC address lives on which physical port by watching the source MAC of every frame that arrives, then builds a table (MAC address → port). Once it knows where a destination MAC lives, it forwards a frame out only that one port — not every port, the way a dumb hub would. A frame to a MAC address the switch hasn't learned yet, or a genuine broadcast, is the one case it still floods out every port.

ARP — bridging IP to MAC

A device usually only knows the destination's IP address — but Ethernet frames need a destination MAC address to actually go anywhere. Address Resolution Protocol (ARP) is the lookup that bridges the two: the sender broadcasts "who has 192.168.1.1? tell 192.168.1.42," and whichever device owns that IP replies directly with its MAC address. The answer gets cached for a while so this doesn't have to repeat for every packet. See Linux Networking Tools for inspecting a live ARP cache with ip neigh.

Unicast, broadcast, and multicast

Every frame's destination MAC address declares, at the addressing level, how many interfaces it's meant for — the same three-way split that IP addressing reuses one layer up.

Unicast — one sender, one receiver

One device sending directly to exactly one other device's specific MAC address A B dest MAC = B's own address
One specific destination MAC, one recipient — the overwhelming majority of traffic.

Broadcast — one sender, every device on the local network

One device sending to the reserved all-ones broadcast MAC address, reaching every device on the same local network A dest MAC = FF:FF:FF:FF:FF:FF
The reserved all-ones MAC address — every device on the segment receives and processes it. ARP and DHCP both depend on this.

Multicast — one sender, a subscribed group

One device sending to a multicast MAC address, reaching only devices that joined that group, while a non-member device receives nothing A joined group joined group not joined — nothing dest MAC in 01:00:5E:xx:xx:xx
A reserved MAC address range — only interfaces that explicitly joined that group process the frame. Used for things like IPTV streams and some device-discovery protocols.

Encapsulation — how IP and UDP ride inside a frame

Nothing travels naked. Application data gets wrapped in layers, each one added by a different piece of software, each one only meaningful to its matching layer on the other end — like nesting a letter inside an envelope, inside a courier bag.

Application data nested inside a UDP header, inside an IP header, inside an Ethernet frame — each outer layer wrapping the one before it Ethernet frame — MAC → MAC, local network only IP packet — IP → IP, across networks UDP segment — port → port, which program your actual data 20 B header ↑ 14 B header
Each layer only adds a small header in front of what it was handed. On arrival, the receiving machine strips them off in reverse order.
  1. An app hands raw bytes to the OS along with a destination IP and port.
  2. UDP wraps it with an 8-byte header (source port, dest port, length, checksum).
  3. IP wraps that with a 20-byte header (source/destination IP, TTL, protocol).
  4. Ethernet wraps that with source/destination MAC addresses, ready to go out on the wire.
  5. On arrival, each layer is stripped off in reverse and handed up to the next one.

Real-world applications

Gotchas

Field notes