In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
3. The checksum field is filled with zeros when the checksum field is initially calculated
This is how the checksum is calculated for the sender, and for the receiver, the verification is simple:
1. The received IP header is summed up one by one in 16 bits.
two。 If the result is 1, the check is correct, otherwise the error is discarded.
The principle is very simple, the receiver's calculation object is the inverse XOR of An and A, and the result is, of course, 1!
Specific examples of program implementation are as follows:
SHORT checksum (USHORT* buffer, int size)
{
Unsigned long cksum = 0
While (size > 1)
{
Cksum + = * buffer++
Size-= sizeof (USHORT)
}
If (size)
{
Cksum + = * (UCHAR*) buffer
}
Cksum = (cksum > > 16) + (cksum&0xffff)
Cksum + = (cksum > > 16)
Return (USHORT) (~ cksum)
}
IP header:
4500 0046
17d9 0000
4011 ec1d (check field)
Ac1c 0f3b
Ac1c 0f3d
Calculate:
4500 + 0046 + 17d9 + 0000 + 4011 + ec1d + ac1c + 0f3b + ac1c + 0f3d
The sum taken out is the checksum that should be filled.
When receiving an IP packet, to check whether the IP header is correct, check the IP header, using the same method as above:
Calculate:
44500 + 0046 + 17d9 + 0000 + 4011 + ec1d + ac1c + 0f3b + ac1c + 0f3d is added to FFFF again, and the result is all-in-one and correct.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.