Skip to content
Documentation Background

Link layer services and error detection

The link layer moves a datagram across one link: from a host to a switch, between two routers, or from a laptop to an access point. Everything above it thinks about end-to-end paths. This layer only cares about the next neighbor, and it fails in its own ways: bad cables, mismatched settings, noisy radio, overflowing queues.

This page covers the services every link-layer protocol offers and how corrupted frames are detected. Multiple access protocols covers how nodes share a medium. ARP and switching covers addressing and forwarding inside a LAN.


ServiceWhat it doesWhere you see it
FramingWraps the network-layer datagram in a frame with a header (addresses, type) and usually a trailer (error check)Ethernet frame, Wi-Fi frame
Link accessRules for when a node may transmit. Trivial on a point-to-point link, a real protocol on a shared oneEthernet switch port vs Wi-Fi channel
Reliable deliveryAcknowledgments and retransmissions on the link itselfWi-Fi and cellular. Not Ethernet
Error detectionExtra bits let the receiver notice flipped bits and drop the frameThe Ethernet FCS, the Wi-Fi FCS
Error correctionEnough redundancy to repair some errors without a resendRadio and fiber links, storage media

Reliable delivery at the link layer looks redundant, since TCP already retransmits. It pays off when the link itself is lossy. A Wi-Fi frame lost to interference is cheaper to resend over the one hop than to detect through a TCP timeout across the whole path. On Ethernet, bit errors are rare, so the extra machinery is skipped and a damaged frame is silently dropped.

The services vary by protocol. Ethernet is connectionless and unreliable. Wi-Fi acknowledges every unicast frame. Choose your expectations from the protocol, not from the layer.


Most of the link layer runs in the network adapter (NIC), and the rest runs in the operating system’s driver.

Done in NIC hardwareDone in the driver and kernel
Building the frame, adding preamble and trailerChoosing the next hop and the destination MAC (see ARP)
Computing and checking the CRCConfiguring the adapter, bringing the link up
Dropping frames not addressed to this adapterHandling interrupts when a frame arrives
Carrier sense, backoff, and acknowledgments, depending on the mediumPassing the extracted datagram up to the IP layer

Hardware address filtering has a practical effect. A NIC discards frames for other stations before they reach the CPU, which is why a busy shared segment does not slow every host. Putting an interface in promiscuous mode turns the filter off, which is what tcpdump does.

Modern NICs also take over more of the work. These are offloads:

Terminal window
# Which offloads are active on this interface
ethtool -k eth0 | grep -E 'checksum|segmentation|receive-offload'
# rx-checksumming: on
# tx-checksumming: on
# tcp-segmentation-offload: on
# generic-receive-offload: on

Offloads matter when you read captures. A capture taken on the sending host can show a TCP checksum as bad or incorrect on outgoing packets, because the NIC fills it in after the capture point. That is normal. A capture on the receiving side of the wire shows the real value.


Electrical noise and signal loss can flip bits in transit. The sender adds redundant bits, and the receiver recomputes them. A mismatch means the frame is dropped. More redundancy buys better detection.

Single-bit parity adds one bit so that the count of 1s is even (or odd). It detects any odd number of flipped bits and misses every even number. On real links errors arrive in bursts, so a single parity bit misses roughly half of them.

Two-dimensional parity arranges the bits in a grid and adds a parity bit for each row and column. One flipped bit shows up in exactly one row and one column, which locates it and lets the receiver correct it. Any two flipped bits are detected, though not corrected.

Correcting errors without a resend is forward error correction (FEC). It matters where a resend is expensive: real-time audio and video, and links with long propagation delay such as deep-space and satellite paths. Wireless standards and optical transceivers use much stronger codes than parity, but the idea is the same.

The checksum used by IP, TCP, and UDP treats the data as 16-bit integers, adds them, and stores the one’s complement of the sum. The receiver adds everything including the checksum field and expects all 1 bits. It is cheap to compute in software and weak against some error patterns, which is acceptable because the link layer has already applied a stronger check below it.

A CRC treats the frame as a long binary number and divides it by an agreed generator value, using arithmetic without carries (which makes the division an XOR operation). The remainder is appended as the check value. The receiver divides the whole frame and expects a remainder of zero.

Ethernet and Wi-Fi use a 32-bit CRC. Its guarantees are strong:

  • Every burst of up to 32 bad bits in a row is detected.
  • Every error of 1, 2, or 3 flipped bits is detected in frames of Ethernet size.
  • Longer bursts are missed with a probability of about 1 in 4 billion.

The division is awkward in software and trivial in hardware, which is why the link layer does it in the NIC and the upper layers use the cheaper checksum. A step-by-step division with a small generator is in the CRC and multiple access math deep dive.

MethodOverheadDetectsWhere used
Single parity1 bitOdd numbers of errorsSerial links, memory
Two-dimensional parityRow and column bitsCorrects 1 bit, detects 2Teaching, simple codes
Internet checksum16 bitsMost random errorsIP header, TCP, UDP
CRC-3232 bitsAll bursts up to 32 bits, all 1 to 3 bit errorsEthernet, Wi-Fi

The transport layer also has its own check (UDP header and checksum), so a corrupted payload can be caught at several levels. End-to-end checks remain necessary because a switch or router can corrupt a frame inside its own memory after the link-layer check has passed.


A frame that fails the CRC is dropped without a message. The only trace is a counter.

Terminal window
# Per-interface totals
ip -s link show eth0
# RX: bytes packets errors dropped missed mcast
# TX: bytes packets errors dropped carrier collsns
# Detail breakdown (names vary by driver)
ethtool -S eth0 | grep -iE 'crc|frame|align|len|drop|miss|collision'
# rx_crc_errors: 0
# rx_length_errors: 0
Counter that risesUsual meaning
CRC or FCS errorsCorrupted bits on the wire. Bad cable, dirty or failing optic, an unsupported cable length, electrical interference, or a duplex mismatch
Frame or alignment errorsOften a duplex mismatch or a faulty NIC
Length errors or giant framesA neighbor sending frames larger than the receiver’s MTU
Missed or dropped (not errors)The NIC or the kernel ran out of buffer, which is a capacity problem rather than a cable problem
Collisions, late collisionsHalf-duplex operation, or a duplex mismatch. Should be zero on switched full-duplex links

Corruption on a healthy wire is rare, so any steady count of CRC errors is worth chasing. Wireless links are the opposite. Loss is routine there, and the link layer hides it with acknowledgments, retransmissions, and lower data rates.