Internet checksum)

Source: Internet
Author: User
Internet checksum Algorithm

Fortune 10.20

Anticode arithmetic operation: It is easy to calculate the sum of two numbers for Binary anticode. Its rule is to perform column-by-column calculation from low to high. The sum of 0 and 0 is 0, 0 and 1. The sum of 1 and 1 is 0, but a carry 1 is generated and added to the next column.If the highest bit is added to generate carry, the final result will be incremented by 1..

Internet checksum Algorithm:

The sender divides the verified data into 16-bit sequences. If the length of the data is an odd number of bytes, add a byte 0 at the end of the data to make it an even number. After all the 16-bit characters are added by the anticode calculation, the checksum is obtained by pairing and obtaining the anticode.

On the receiver side, add all 16 characters in the received datagram (including the checksum field) and use the inverse code calculation to calculate the sum of the obtained sum. If the data packet does not change during transmission, the result is 0, so the data packet is retained. Otherwise, the system considers that the business trip is incorrect and discards the datagram.

"A, B, C ,..., "Y, Z" represents a series of eight-bit groups respectively. byte groups in the form of [a, B] are used to represent the Integers of A * 256 + B, then, you can use one of the following two expressions to decode the byte sequence:

[A, B] + '[c, d] +'... + '[y, z]

[A, B] + '[c, d] +'... + '[Z, 0]

+ 'Indicates the sum of the anticode arithmetic operations. The first formula applies to the checksum of even bytes, and the second formula applies to the checksum of odd bytes.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.