We’re Officially Live β€” Lifetime Founding Membership Available for a Limited Time
Free preview

Ethernet Basics

The dominant link layer: MAC addresses and frame format, the MAC-vs-PHY split (and how MCUs pair an on-chip MAC with an external PHY over RMII), and how switches forward by MAC.

22 min read

In this lesson:


The local-delivery layer

Ethernet is the dominant Link-layer (OSI layer 2) technology, it moves frames between devices on the same local network (LAN). Above it sits IP (which addresses across networks); Ethernet handles delivery within a link using MAC addresses.

A MAC address is a 48-bit hardware address, usually globally unique: the top 24 bits are the manufacturer (OUI), the bottom 24 identify the device. Written AA:BB:CC:DD:EE:FF. Every Ethernet interface has one, and frames carry a source and destination MAC for local delivery.


The Ethernet frame

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”
β”‚ Preamble β”‚ Dest MAC β”‚ Src MAC  β”‚ EtherType β”‚   Payload    β”‚ FCS  β”‚
β”‚  (7+1)   β”‚   (6)    β”‚   (6)    β”‚    (2)    β”‚  46 – 1500   β”‚ (4)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚              β”‚            β”‚
                          e.g. 0x0800 = IPv4   the data    CRC-32 check

MAC vs PHY: two halves of the interface

An Ethernet port is split into two blocks, a distinction that matters constantly on embedded:

They connect over a standard interface, MII or the reduced RMII (fewer pins). Beyond the PHY you also need magnetics (a transformer for isolation) and the RJ45 jack.

 MCU ─[ Ethernet MAC ]─(R)MII─[ PHY chip ]─[ magnetics ]─[ RJ45 ]─ cable
        digital: frames           analog: signaling, speed/duplex

So a typical MCU Ethernet design is: on-chip MAC + external PHY over RMII, configured via the MDIO management bus, with lwIP running the IP/TCP layers on top.


Switching: forwarding by MAC

Old hubs were dumb, every bit in one port went out all ports (one shared collision domain). A switch is smart: it learns which MAC address lives on which port (by watching source MACs), then forwards each frame only to the port where the destination lives.

flowchart LR
  A[Host A<br/>MAC AA] --- SW[Switch<br/>learns MAC↔port]
  B[Host B<br/>MAC BB] --- SW
  C[Host C<br/>MAC CC] --- SW
  SW -. "frame to BB β†’ only B's port" .-> B

This means each switch port is its own collision domain, so modern full-duplex switched Ethernet has no collisions at all. (The old half-duplex shared medium used CSMA/CD, carrier sense, collision detect, back off, which is now historical for wired Ethernet.) Broadcasts (destination FF:FF:FF:FF:FF:FF) still go to every port, the broadcast domain.


Gotchas


TL;DR

This is just the start

Sign up free to track progress on this lesson, get coding problems with the Run button, and unlock the full interview Q&A.

More in Networking & IoT

OSI vs TCP/IP ModelIP Addressing
TCP vs UDP
Sockets
MQTT
CoAP