Fundamentals 36 min read

Unlocking Ethernet: How MAC and PHY Drive Your Network Traffic

This article demystifies Ethernet by explaining the roles of MAC and PHY within the network protocol stack, covering OSI and TCP/IP models, data encapsulation, ARP address resolution, hardware interfaces like MII/MDIO, and practical troubleshooting tips for real‑world network devices.

Deepin Linux
Deepin Linux
Deepin Linux
Unlocking Ethernet: How MAC and PHY Drive Your Network Traffic

What is a network protocol stack?

A network protocol stack is a collection of layered rules that enable computers to communicate, much like traffic rules allow vehicles to move safely. Each layer—from the application down to the physical medium—has specific responsibilities and works together to encapsulate, transmit, receive, and process data.

1.1 Definition of a protocol stack

The stack defines how data is packaged, transmitted, and interpreted across the network, ensuring interoperability between devices.

1.2 Common protocol stacks

OSI model : Seven layers (Physical, Data Link, Network, Transport, Session, Presentation, Application) each providing services to the layer above while using services from the layer below.

Physical layer : Handles raw bit transmission over media such as copper cables, fiber, or wireless signals.

Data Link layer : Groups bits into frames, performs error detection/correction, and uses MAC addresses for device identification. Ethernet is a typical Data Link protocol.

Network layer : Routes packets between networks using IP addresses; includes protocols like IPv4, IPv6, ICMP, ARP.

Transport layer : Provides end‑to‑end reliability (TCP) or low‑latency best‑effort delivery (UDP).

Session layer : Manages sessions between applications.

Presentation layer : Handles data representation, encryption, compression.

Application layer : Implements protocols such as HTTP, FTP, SMTP that directly serve user applications.

TCP/IP stack : A practical four‑layer model (Network Interface, Internet, Transport, Application) that simplifies implementation and is used on the Internet.

Network Interface layer: Combines OSI’s Physical and Data Link functions; supports Ethernet, Wi‑Fi, PPP, etc.

Internet layer: Uses IP for routing and ARP for address resolution.

Transport layer: TCP/UDP provide reliable or fast delivery.

Application layer: Hosts protocols like HTTP, HTTPS, FTP, DNS.

1.3 Journey of data through the stack

Sending process : An application creates data (e.g., an HTTP request). The Transport layer adds TCP/UDP headers, the Internet layer adds an IP header, and the Network Interface layer adds an Ethernet header with source and destination MAC addresses before the bits travel over the physical medium.

Receiving process : The Physical layer receives the signal, the Network Interface layer strips the Ethernet frame and checks integrity, the Internet layer verifies the destination IP, the Transport layer reassembles the segment (handling TCP acknowledgments if needed), and finally the Application layer processes the payload.

2. MAC Controller

2.1 What is MAC?

MAC (Media Access Control) is both a hardware controller and a sub‑protocol of the Data Link layer. It acts as a traffic officer, assigning each device a unique MAC address (its “ID”) and managing access to the shared medium to avoid collisions.

2.2 Functions of MAC

Medium access control: Implements CSMA/CD (carrier‑sense multiple access with collision detection) to prevent simultaneous transmissions.

Frame handling: Encapsulates upper‑layer data into Ethernet frames, adding source/destination MAC addresses, type/length fields, and a Frame Check Sequence (FCS) for error detection.

Address management: Uses 48‑bit MAC addresses (OUI + device‑specific suffix) to uniquely identify devices on a LAN.

Error detection: Calculates CRC for each frame; receivers recompute CRC to verify integrity and discard corrupted frames.

2.3 MAC address and ARP protocol

(1) ARP principle : ARP translates an IP address into a MAC address. When a device knows the destination IP but not the MAC, it broadcasts an ARP request; the owner of the IP replies with its MAC.

(2) ARP table : Operating systems cache IP‑to‑MAC mappings. On Windows, the command arp -a displays the table.

Interface: 192.168.1.5 --- 0x3
Internet Address      Physical Address      Type
192.168.1.1           00-11-22-33-44-55    Dynamic
192.168.1.10          00-06-07-08-09-0A    Dynamic

3. PHY – The Physical‑Layer Translator

3.1 What is PHY?

PHY (Physical Layer) is the hardware that converts digital bits from the MAC into analog signals suitable for the transmission medium (and vice‑versa). It bridges the Data Link layer and the physical cable or fiber.

3.2 Functions of PHY

Signal encoding & modulation: Implements standards such as 4B/5B encoding and MLT‑3 modulation for 100Base‑TX Ethernet.

Medium control: Defines electrical/mechanical parameters for the chosen medium (e.g., voltage, impedance for RJ45) and performs amplification, noise reduction, and attenuation compensation.

Bit synchronization: Uses clock recovery (PLL) to align the receiver’s clock with the transmitter’s, ensuring correct sampling.

3.3 Internal structure of PHY

MII/GMII sub‑layer: Interface between MAC and PHY; MII supports 10/100 Mbps, GMII adds 1000 Mbps support.

PCS sub‑layer: Performs encoding/decoding (e.g., 4B/5B) and controls data flow.

PMA sub‑layer: Converts parallel data to serial for the medium and vice‑versa.

PMD sub‑layer: Directly interacts with the physical medium (copper or fiber), handling driver strength, equalization, etc.

MDI sub‑layer: Defines connector pin‑outs (e.g., RJ45) and electrical characteristics.

Ethernet PHY diagram
Ethernet PHY diagram

4. Cooperation Between MAC and PHY

4.1 MII Interface – The Bridge

Definition: MII (Media Independent Interface) standardizes the connection between MAC and PHY, allowing chips from different vendors to interoperate.

Function: Provides separate data paths for MAC‑to‑PHY transmission, PHY‑to‑MAC reception, status signaling, and a management interface (MDIO) for configuration.

Evolution: Variants such as GMII, RMII, and RGMII reduce pin count or increase speed to meet modern Ethernet requirements.

4.2 Ethernet hardware architectures

CPU‑integrated MAC & PHY: Rare, used in ultra‑low‑power IoT nodes.

CPU‑integrated MAC with external PHY: The dominant design; the CPU handles MAC functions while a separate PHY chip manages the analog front‑end.

Separate CPU, MAC, and PHY: Found in high‑performance servers and switches where each block can be optimized independently.

4.3 MDIO bus – Configuration and management

MDIO (Management Data Input/Output) is a two‑wire serial bus (MDC clock + MDIO data) used by the CPU or MAC to read/write PHY registers, set speed, duplex mode, auto‑negotiation, and monitor link status.

5. Practical Applications and Common Issues

5.1 Use in network devices

Routers : MAC handles frame forwarding and ARP lookups; PHY converts frames to electrical signals for the WAN link.

Switches : MAC learns device addresses to build a forwarding table; PHY provides the physical ports.

Computer NICs : Integrated MAC/PHY encapsulate application data into Ethernet frames and drive the RJ45 connector.

5.2 Typical problems and solutions

Unstable connection : Check cables, avoid electromagnetic interference, ensure unique MAC addresses.

Reduced speed : Use certified CAT5e/CAT6 cables, verify that both ends support the desired rate, and confirm correct duplex settings.

MAC‑PHY communication failure : Verify MDIO pull‑up resistors, keep signal traces short, ensure proper PHY power/reset sequencing, and debug register access (e.g., Linux kernel logs showing phy_id = 0xFFFF indicates no response).

hardwareTCP/IPMacNetwork ProtocolOSI ModelEthernetPHY
Deepin Linux
Written by

Deepin Linux

Research areas: Windows & Linux platforms, C/C++ backend development, embedded systems and Linux kernel, etc.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.