![]() ![]() Note that the UDP length appears twice.IpSendDatagram ( NetInterface *interface, IpPseudoHeader *pseudoHeader, NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary) The calculation result is the same as that at 0x0028. (No data here: the UDP data length is actually 0 bytes) = 0x28038 First, set the two bytes at the checksum and 0x002a to 0, calculate the UDP packet checksum as follows:Ġxc0a8 + 0圆401 (source IP address before) + 0xab46 + 0x9ce9 (destination IP address before) + 0x0011 (zero and Protocol) +Ġx0008 (UDP length) + 0x0f3a (source port) + 0x0405 (destination port) + 0x0008 (UDP length) + 0x0000 (checksum preset is 0) +. The IP Source Address is stored in eight bytes from 0x0x1a to 0x0x21. The protocol type of the preceding packet at 0x0018 = hexadecimal 11, that is, the packet is a UDP packet, the length of the two bytes is stored at the beginning of 0x0027 (including the source port address 4 bytes + UDP length 2 bytes + checksum 2 bytes = 8 bytes, and the length of UDP data: therefore, the UDP data length of this packet is actually 0 bytes. The purpose of adding a virtual header to the verification is to verify whether the datagram reaches the correct destination and prevent spoofing attacks ). There are IP source addresses, IP destination addresses, protocol numbers (TCP: 6/UDP: 17), and the total length of TCP or UDP datagram (header + data ). The virtual header is defined as follows: In this case, the checksum not only contains the entire TCP/UDP datagram, but also overwrites a virtual header. The verification algorithm is exactly the same as that of the IPv4 packet header, but the data involved in the verification is different. In practice, for the intermediate forwarding router and the final receiver, you can directly add the received IPv4 packet header checksum part according to the same algorithm, if the result is 0 xFFFF, the verification is correct.įor TCP and UDP datagram, the header also contains a 16-bit checksum. The preceding process is only used by the sender to calculate the initial checksum. We can see that the checksum of this grouping header is exactly the same as the received value. ![]() Note that in the first step, we use 0x0000 to set the header checksum. Based on the above algorithm description, we can perform the following calculations: The first byte is 0x45, and the last byte is 0xe9, that is, the IPv4 group header ends with the target IP address. The IPv4 group header starts from the address offset 0x000e. In the preceding hexadecimal sampling, the start point is the beginning of the Ethernet frame (DLC package. repeat this process until the high 16 bits are all 0. ![]() After the accumulation is complete, add the high 16 bits in the result to the low 16 bits. If the total number of bytes is odd, the last byte is added separately. When an IPv4 packet header verification is to be calculated, the sender first sets it to 0, and then accumulates it to the IPv4 packet header one by one based on 16 bits, accumulating and saving it in a 32-bit value. The "header checksum" field is the header checksum part. | Time to live | Protocol | headerchecksum | | Identification | flags | Fragment Offset | | Version | IHL | type ofservice | totallength | The structure of the IPv4 group header is as follows:Ġ 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 4 5 6 7 8 9 01 The Checksum algorithm of the grouping header is the inverse code after 16-bit accumulation and UDP data headers also use the same validation algorithm, but the data involved in the calculation is different from the IP grouping header. ![]()
0 Comments
Leave a Reply. |