World Library  
Flag as Inappropriate
Email this Article

IPv4 header checksum

Article Id: WHEBN0014745373
Reproduction Date:

Title: IPv4 header checksum  
Author: World Heritage Encyclopedia
Language: English
Subject: IPv4, Checksum, IPsec
Publisher: World Heritage Encyclopedia

IPv4 header checksum

The IPv4 header checksum is a simple checksum used in version 4 of the Internet Protocol (IPv4) to protect the header of IPv4 data packets against data corruption. This checksum is calculated only for the header bytes (with the checksum bytes set to 0), is 16 bits long and is a part of the IP packet header.

The checksum is calculated by forming the ones' complement of the ones' complement sum of the header's 16-bit words.[1] The result of summing the entire IP header, including checksum, should be zero if there is no corruption. At each hop, the checksum is recalculated and the packet will be discarded upon checksum mismatch. The router must adjust the checksum if it changes part of the IP header (such as when decrementing the TTL.)[2]

The IPv6 protocol lacks a header checksum: its designers considered that the whole-packet link-layer checksumming provided in layer 2 transports such as PPP and Ethernet, combined with the use of checksums in upper-layer protocols such as TCP and UDP, were sufficient to make a separate header checksum unnecessary.[3]

Example: calculating an IPv4 header checksum

Take the following truncated excerpt of an IPv4 packet. The header is shown in bold and the checksum is underlined.
4500 0073 0000 4000 4011 b861 c0a8 0001
c0a8 00c7 0035 e97c 005f 279f 1e4b 8180

To calculate the checksum, we can first calculate the sum of each 16 bit value within the header, skipping only the checksum field itself. Note that the values are in hexadecimal notation.
4500 + 0073 + 0000 + 4000 + 4011 + c0a8 + 0001 + c0a8 + 00c7 = 2479C (equivalent to 149,404 in decimal)
Next, we convert the value 2479C to binary:
0010 0100 0111 1001 1100
The first 4 bits are the carry and will be added to the rest of the value:
0010 + 0100 0111 1001 1100 = 0100 0111 1001 1110
Next, we flip every bit in that value, to obtain the checksum:
0100 0111 1001 1110 becomes:
1011 1000 0110 0001
This is equal to B861 in hexadecimal, as shown underlined in the original IP packet header.

Example: verifying an IPv4 header checksum

When verifying a checksum, the same procedure is used as above, except that the original header checksum is not omitted.
4500 + 0073 + 0000 + 4000 + 4011 + b861 + c0a8 + 0001 + c0a8 + 00c7 = 2fffd
Add the carry bits:
fffd + 2 = ffff
Taking the ones' complement (flipping every bit) yields 0000, which indicates that no error is detected. IP header checksum does not check for the correct order of 16 bit values within the header.

See also

External links

  • IP Datagram General Format
  • Header Checksum


  1. ^ "Internet Header Format". Internet Protocol DARPA Internet program protocol specification. . Retrieved 2009-10-27.
  2. ^ . Retrieved 2009-10-27.
  3. ^ Iljitsch van Beijnum (September 2006). "IPv6 Internals". Cisco. 
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.

Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.