Knowledge (XXG)

Internet checksum

Source 📝

104:
If there is no corruption, the result of summing the entire IP header, including checksum, and then taking its one's complement should be zero. At each hop, the checksum is verified. Packets with checksum mismatch are discarded. The router must adjust the checksum if it changes the IP header (such as
108:
The procedure is explained in detail in RFC 1071 "Computing the Internet Checksum". Optimisations are presented in RFC 1624 "Computation of the Internet Checksum via Incremental Update", to cover the case in routers which need to recompute the header checksum during packet forwarding when only a
143:
For ones' complement addition, each time a carry occurs, we must add a 1 to the sum. A carry check and correction can be performed with each addition or as a post-process after all additions. If another carry is generated by the correction, another 1 is added to the sum.
203:
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.
147:
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 these values are in
66:, are sufficient. Thus, IPv6 routers are relieved of the task of recomputing the checksum whenever the packet changes, for instance by the lowering of the 81: 166:
Only a single carry addition is ever necessary even for maximum length IPv4 header, since the carry addition will never itself generate another carry.
510: 100:
of the one's complement sum of all 16 bit words in the header. For purposes of computing the checksum, the value of the checksum field is zero.
50:
protocol does not use header checksums. Its designers considered that the whole-packet link layer checksumming provided in protocols, such as
474: 59: 342: 191:
When verifying a checksum, the same procedure is used as above, except that the original header checksum is not omitted.
122:
Take the following truncated excerpt of an IPv4 packet. The header is shown in bold and the checksum is underlined.
417: 51: 74: 63: 217: 437: 380: 305: 260: 212: 170: 97: 329: 36: 427: 370: 295: 250: 160:
Carry addition is then made by adding the fifth hexadecimal digit to the first 4 digits:
478: 515: 504: 183:
This checksum value is shown as underlined in the original IP packet header above.
495: 461: 457: 453: 449: 440: 421: 404: 400: 396: 317: 308: 289: 272: 263: 244: 174: 148: 39:(IPv4) to detect corruption in the header of IPv4 packets. It is carried in the 392: 383: 360: 356: 240: 67: 194:
4500 + 0073 + 0000 + 4000 + 4011 + b861 + c0a8 + 0001 + c0a8 + 00c7 = 2fffd
55: 28: 58:, combined with the use of checksums in upper layer protocols such as 432: 375: 300: 255: 43:, and represents the 16-bit result of summation of the header words. 156:
4500 + 0073 + 0000 + 4000 + 4011 + c0a8 + 0001 + c0a8 + 00c7 = 2479c
362:
INTERNET PROTOCOL - DARPA INTERNET PROGRAM PROTOCOL SPECIFICATION
366: 47: 40: 32: 16:
Mechanism to detect corruption in the header of an IPv4 packet
291:
Computation of the Internet Checksum via Incremental Update
386:. IEN 128, 123, 111, 80, 54, 44, 41, 28, 26. 92:The checksum calculation is defined as follows: 73:The Internet checksum is mandatory to detect 8: 243:; D. Borman; C. Partridge (September 1988). 431: 374: 299: 283: 281: 254: 235: 233: 80:The Internet checksum is used to detect 341:Iljitsch van Beijnum (September 2006). 229: 475:"Compute 16-bit One's Complement Sum" 423:Requirements for IP Version 4 Routers 7: 118:Calculating the IPv4 header checksum 187:Verifying the IPv4 header checksum 14: 96:The checksum field is the 16 bit 288:A. Rijsinghani, ed. (May 1994). 246:Computing the Internet Checksum 511:Error detection and correction 1: 139:0035 e97c 005f 279f 1e4b 8180 105:when decrementing the TTL). 532: 464:. 407:. 330:IP Datagram General Format 320:. 275:. 109:single field has changed. 84:(including data payload). 77:(including data payload). 75:errors in IPv6 UDP packets 426:. Network Working Group. 294:. Network Working Group. 249:. Network Working Group. 169:The checksum is then the 127:4500 0073 0000 4000 4011 359:, ed. (September 1981). 456:. Updated by RFC  395:. Updated by RFC  102: 82:errors in ICMP packets 70:counter on every hop. 218:Header check sequence 94: 389:Internet Standard 5. 271:Updated by RFC  213:Frame check sequence 25:IPv4 header checksum 448:Obsoletes RFC  420:, ed. (June 1995). 391:Obsoletes RFC  197:Add the carry bits: 446:Proposed Standard. 177:) of this result: 154:Initial addition: 23:, also called the 316:Updates RFC  37:Internet Protocol 21:Internet checksum 523: 483: 482: 477:. Archived from 471: 465: 444: 435: 433:10.17487/RFC1812 414: 408: 387: 378: 376:10.17487/RFC0791 353: 347: 346: 343:"IPv6 Internals" 338: 332: 327: 321: 312: 303: 301:10.17487/RFC1624 285: 276: 267: 258: 256:10.17487/RFC1071 237: 201: 195: 180: 171:ones' complement 163: 157: 140: 134: 98:one's complement 41:IP packet header 531: 530: 526: 525: 524: 522: 521: 520: 501: 500: 496:Header Checksum 492: 487: 486: 473: 472: 468: 416: 415: 411: 355: 354: 350: 340: 339: 335: 328: 324: 287: 286: 279: 239: 238: 231: 226: 209: 202: 200:fffd + 2 = ffff 199: 198: 196: 193: 192: 189: 179:NOT 479e = b861 178: 162:2 + 479c = 479e 161: 155: 135: 133: 125: 120: 115: 90: 17: 12: 11: 5: 529: 527: 519: 518: 513: 503: 502: 499: 498: 491: 490:External links 488: 485: 484: 481:on 2020-11-17. 466: 409: 348: 333: 322: 314:Informational. 277: 269:Informational. 228: 227: 225: 222: 221: 220: 215: 208: 205: 188: 185: 119: 116: 114: 111: 89: 86: 15: 13: 10: 9: 6: 4: 3: 2: 528: 517: 514: 512: 509: 508: 506: 497: 494: 493: 489: 480: 476: 470: 467: 463: 459: 455: 451: 447: 442: 439: 434: 429: 425: 424: 419: 413: 410: 406: 402: 398: 394: 390: 385: 382: 379:. STD 5. 377: 372: 368: 364: 363: 358: 352: 349: 344: 337: 334: 331: 326: 323: 319: 315: 310: 307: 302: 297: 293: 292: 284: 282: 278: 274: 270: 265: 262: 257: 252: 248: 247: 242: 236: 234: 230: 223: 219: 216: 214: 211: 210: 206: 204: 186: 184: 181: 176: 172: 167: 164: 158: 152: 150: 145: 141: 138: 132: 130: 123: 117: 112: 110: 106: 101: 99: 93: 87: 85: 83: 78: 76: 71: 69: 65: 61: 57: 53: 49: 44: 42: 38: 34: 30: 26: 22: 479:the original 469: 445: 422: 412: 388: 361: 351: 336: 325: 313: 290: 268: 245: 190: 182: 168: 165: 159: 153: 146: 142: 136: 128: 126: 124: 121: 107: 103: 95: 91: 79: 72: 45: 24: 20: 18: 175:bitwise NOT 149:hexadecimal 88:Computation 505:Categories 224:References 151:notation. 357:J. Postel 241:R. Braden 137:c0a8 00c7 131:c0a8 0001 68:hop limit 33:version 4 418:F. Baker 345:. Cisco. 207:See also 113:Examples 56:Ethernet 31:used in 29:checksum 35:of the 27:is a 516:IPv4 462:6633 460:and 458:2644 454:1009 452:and 450:1716 441:1812 405:6864 403:and 401:2474 397:1349 367:IETF 318:1141 309:1624 273:1141 264:1071 129:b861 62:and 54:and 48:IPv6 46:The 19:The 438:RFC 428:doi 393:760 384:791 381:RFC 371:doi 306:RFC 296:doi 261:RFC 251:doi 64:UDP 60:TCP 52:PPP 507:: 436:. 399:, 369:. 365:. 304:. 280:^ 259:. 232:^ 443:. 430:: 373:: 311:. 298:: 266:. 253:: 173:(

Index

checksum
version 4
Internet Protocol
IP packet header
IPv6
PPP
Ethernet
TCP
UDP
hop limit
errors in IPv6 UDP packets
errors in ICMP packets
one's complement
hexadecimal
ones' complement
bitwise NOT
Frame check sequence
Header check sequence


R. Braden
Computing the Internet Checksum
doi
10.17487/RFC1071
RFC
1071
1141


Computation of the Internet Checksum via Incremental Update

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.