Hawkynt

Ones-Complement

Internet protocol checksum using one’s complement arithmetic. Sums 16-bit words with end-around carry, then inverts all bits. Used in IP, TCP, UDP, and ICMP headers for packet integrity verification.

Properties

Property Value
Category Checksums
Sub-category Internet Protocol
Security status πŸŽ“ Educational Only
Complexity Beginner
Inventor Internet Protocol designers
Year 1974
Origin πŸ‡ΊπŸ‡Έ United States
Source algorithms/checksum/complement.js

Security

Status: πŸŽ“ Educational Only

No vulnerabilities are recorded for this implementation.

Notes

Documentation

References

Test vectors

3 vectors ship with this algorithm and run in the test suite. Byte values are hexadecimal.

Vector 1 β€” Two 16-bit words 0x0001 + 0x0002, complement 0xFFFC (RFC 1071 section 1 definition)

Field Value
input 00010002
expected fffc

Vector 2 β€” IP header fragment

Field Value
input 0001f203f4f5f6f7
expected 220d

Vector 3 β€” Single word 0xFFFF, complement 0x0000 (RFC 1071 section 1 definition)

Field Value
input ffff
expected 0000

← All algorithms