Skip to main content
networking

Checksum

A checksum is a value computed from packet data used to detect transmission errors. TCP, UDP, and IP headers include checksums. The receiver recomputes the checksum on arrival – if it does not match, the packet is silently discarded. Checksums detect accidental corruption but not malicious tampering (use HMAC for that).

Definition

Checksums provide error detection for network protocols. The sender computes a value over the packet data using a simple algorithm (IP uses one's complement sum of 16-bit words) and includes it in the header. The receiver performs the same computation – if the result differs, the packet was corrupted in transit and is dropped. TCP and UDP checksums cover the payload plus a pseudo-header (source/destination IP, protocol, length) to detect misdelivery. IP header checksum covers only the header (it changes at every hop due to TTL decrement, so routers must recompute it). Checksums catch random bit errors from electrical noise, cosmic rays, and faulty hardware. They do not prevent intentional modification – an attacker can recompute the checksum after altering data. For integrity against active attacks, use cryptographic MACs (HMAC-SHA256) or authenticated encryption (AES-GCM).

Examples

  • TCP checksum offload: ethtool -k eth0 | grep checksum
  • Wireshark: 'tcp.checksum.status == bad' filter finds corrupted packets
  • UDP checksum is optional in IPv4 (set to 0) but mandatory in IPv6

Related Protocols

Related Terms