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.
- 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
- Burned into the hardware — every network interface (wired or Wi-Fi) has a 48-bit MAC address set at the factory, written as six hex byte-pairs:
3C:E1:A1:9B:04:7F. - Unlike an IP address, it doesn't change when the device joins a different network — it identifies the physical interface itself, not a position in any particular network.
- Only meaningful locally — a MAC address has no concept of "far away." It only ever needs to be unique among devices sharing the same physical link or switch.
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.
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
Broadcast — one sender, every device on the local network
Multicast — one sender, a subscribed group
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.
- An app hands raw bytes to the OS along with a destination IP and port.
- UDP wraps it with an 8-byte header (source port, dest port, length, checksum).
- IP wraps that with a 20-byte header (source/destination IP, TTL, protocol).
- Ethernet wraps that with source/destination MAC addresses, ready to go out on the wire.
- On arrival, each layer is stripped off in reverse and handed up to the next one.
Real-world applications
- Every wired/Wi-Fi-connected MCU or SBC — before it can send a single IP packet, it needs a link-layer frame and a MAC address — see the Embedded domain for the hardware side.
- DHCP — a device with no IP address yet sends its initial request as an Ethernet broadcast, since it has no unicast address to be addressed by.
- Managed switches in industrial/automotive networks — VLANs and port-based traffic isolation are built directly on Ethernet framing and MAC-based forwarding.
- mDNS/device discovery — many "zero-configuration" device-discovery protocols rely on multicast frames so a new device can announce itself without knowing anyone's address in advance.
Gotchas
- A MAC address identifies a physical interface, not a machine — a device with both Wi-Fi and Ethernet has two different MAC addresses, one per interface.
- Broadcast traffic doesn't cross a router by design — a router is exactly the boundary where "local network" ends, which is also why ARP and DHCP only ever work on the segment a device is directly attached to.
- A stale ARP cache entry (a device's IP reused by new hardware without the cache expiring) is a classic "it was working a minute ago" LAN bug — clearing/inspecting it is one of the first things worth checking, see Linux Networking Tools.
- The 1500-byte MTU isn't arbitrary — a payload larger than that either gets fragmented by IP or rejected, which is why Path MTU Discovery exists.