The data link layer moves frames between machines on the same network segment: it addresses each frame with 48-bit MAC addresses, protects it with a 4-byte CRC-32, and decides who may transmit. An Ethernet frame carries a 14-byte header and a payload of 46 to 1,500 bytes, so a 10-byte message is padded and still costs 64 bytes on the wire. Every machine on a segment hears every broadcast, so a router at the edge of each settlement keeps one site’s broadcast traffic off the link to the next.

Part of Networking

The layer above the cable that frames bits, addresses neighbours by hardware address, detects corruption and arbitrates access to a shared segment.

Four Jobs Happen Between Neighbours And Nowhere Else

The data link layer is local. It carries a message from one machine to another on the same wire, switch or radio cell, and no further; getting across several networks is the layer above (Routing Protocols). Within that scope it does four jobs, each already covered in its own article, so this one only joins them up:

  • Framing — marking where a message starts and ends in a stream of bits; Frame Format gives the Ethernet fields and Framing gives the start/stop and flag methods used on serial links
  • Addressing — the 48-bit hardware address in every frame, described in Network Addressing
  • Error detection — the CRC-32 frame check sequence; the principles are in Error Detection and Checksums, and a frame that fails is discarded, leaving recovery to the transport layer
  • Access control — deciding who may transmit on a shared medium; CD and Collision Handling cover the shared-wire case that hubs recreate

A Switch Learns From Source Addresses And Forwards By Destination

A switch is a data-link device. Switch Construction explains the mechanism: it records which port each source address arrived on, forwards a frame only to the port of its destination, and floods a frame to every other port when the destination is not yet known. For choosing and placing switches see Network Switches.

The link layer cannot find a hardware address by itself. A sender that knows only an IP address broadcasts an ARP request and the owner replies; Network Addressing describes the exchange and the cache that follows it. This is the point where layer 2 and layer 3 meet, and a duplicate IP address or a stale cache entry shows up here as traffic going to the wrong machine.

Broadcasts Stop At A Router, So A Router Is A Layer 2 Boundary

Hardware broadcasts (all bits set in the destination) reach every device on the segment. That is how ARP and DHCP discovery work, and it is why a single flat segment gets noisier as it grows. Routing Basics states that broadcasts reach all devices in a subnet but do not cross routers. Putting a router between settlements therefore gives each settlement its own broadcast domain.

Loops are the other layer 2 hazard. Network Topologies explains that without Spanning Tree Protocol, loops create broadcast storms in which broadcast frames circulate forever and consume all the bandwidth. A VLAN is the tool that splits one physical switch into several segments; the 802.1Q tag adds 4 bytes and a 12-bit identifier (Frame Format), and traffic between VLANs needs a router.

Worked Example: Padding, Frame Limits And The Minimum Frame

The sizes come from Frame Format: a 14-byte header (two 6-byte addresses and a 2-byte type), a 4-byte check sequence, a payload from 46 to 1,500 bytes, and 4 more bytes when a VLAN tag is present.

A small message. Payload 10 bytes. The minimum payload is 46, so padding is 46 - 10 = 36 bytes. The frame is 14 + 46 + 4 = 64 bytes. Only 10 of those 64 bytes are the message: 10 / 64 = 0.156, or 15.6%.

The largest frame. Payload 1,500 bytes: 14 + 1,500 + 4 = 1,518 bytes. With a VLAN tag: 1,518 + 4 = 1,522 bytes, which is why Frame Format says equipment on a tagged link must accept the larger size.

Why 64 bytes is the minimum. Collision Handling explains that the minimum frame must outlast the collision detection window. A 64-byte frame is 64 x 8 = 512 bits. At 10 Mbps the time to send it is 512 / 10,000,000 s = 0.0000512 s = 51.2 microseconds. The detection window the same article gives for a 185 m coaxial segment is about 1.6 microseconds, comfortably inside it. On a full-duplex switched link there are no collisions at all (Ethernet Basics), but the minimum frame size stays for compatibility.

Common Mistakes

  • Plugging two ports of the same switch together, or closing a ring of switches, with no Spanning Tree running — the result is a broadcast storm that looks like a dead network; trace the most recent cable change first
  • Mismatched speed or duplex at the two ends of a link — one end auto-negotiating against a fixed other end can drop to 10 Mbps half-duplex (Ethernet Basics); set both ends the same way
  • Trusting hardware addresses to be unique — Ethernet Basics notes uniqueness is not enforced and duplicates can exist; two machines with one address behave erratically and are hard to find, so write the address of every machine in the address plan

What’s Next

  • Learn next: Network Switches — choosing, placing and configuring the layer 2 device
  • Combine with: IP Addressing — the layer 3 addresses that ride on these frames