Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Network protocol IP

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

The IP protocol is used to connect multiple packet-switched networks. It transmits something called a packet between the source address and the destination address. It also provides the function of reassembling the data size to meet the packet size requirements of different networks. The responsibility of IP is to transfer data from source to destination. It is not responsible for ensuring transmission reliability, flow control, packet ordering and other services that are common to host-to-host protocols.

Format of ip packet:

The IP protocol is one of the two main protocols in the TCP/IP system, and the IP address is located in the head of the IP Datagram, and the IP address is used at and above the network layer, so the IP address of the invisible Datagram is not visible in the data link layer, and the first part of the header is a fixed length, with a total of 20 bytes. In the TCP/IP standard, various data formats are often described in 32-bit units. By analyzing the format of IP datagrams, we can know what functions IP protocols have.

Analyze the captured packets:

From the captured packets, we can see that it is the version of ipv4, with a header length of 20 bytes and a secondary length of fixed length. The full length of total length: 60 is bytes Differentiated services Field: 0xoo indicates the service type; the flags flag Fragment offset: 0 chip offset is zero. Time to live: 64 lifetime, also known as hop count. Header checksum: oxee19 checksum to verify whether there is an error in the packet. The ip Destination:172.28.15.55 of the original address of the source:172.28.15.1 is the destination address ip.

IP uses four key technologies to provide services: service type, time to live, options, and header parity codes. The type of service refers to the desired quality of service. A service type is a set of parameters that represent the services that Internet can provide. This service type is used by gateways to select the actual transport parameters on a specific network, or on the next network to pass through, or on the next gateway to route this Datagram. Survival time is the upper limit of how long a Datagram can survive. It is set by the sender and handled by the routed place. If the time to live before arrival is zero, discard this Datagram. Options are important for control functions, but they are not necessary for normal communication. Options include timestamp, security, and special routing. The header check code ensures the correct transmission of data. If there is a verification error, discard the entire Datagram.

IP does not provide reliable transmission services, it does not provide end-to-end or node-to-node confirmation, there is no error control for data, it only uses the header check code, it does not provide retransmission and flow control. If an error occurs, it can be reported by ICMP, and ICMP is implemented in the IP module.

Then there is the calculation of the checksum:

The calculation method of IP header checksum

1. Zero the checksum field.

two。 Then the binary inverse code is summed for every 16 bits (2 bytes). The inverse code summation means that the sum of every 16 bits is summed first, and then the resulting sum is converted into the inverse code.

Here is an example on the Internet:

When the receiver carries on the check, it also carries on the binary inverse code summation for every 16 bits. Compared with the header when the sender calculates the checksum, there is one more checksum calculated by the sender. Therefore, if there is no error in the first part during transmission, then the result of the receiver's calculation should be all-in-one, because the receiver calculates that the value other than the checksum is the inverse code of the checksum, and the extra checksum is of course all-in-one.

Finally, give an example of the above process: first set the checksum field to zero.

IP header:

45 00 00 31

89 F5 00 00

6e 06 00 00 (check field)

DE B7 45 5D-> 222.183.69.93

C0 A8 00 DC-> 192.168.0.220

Calculate:

4500 + 0031 + 89F5 + 0000 + 6e06 + 0000 + DEB7 + 455D + C0A8 + 00DC = 3 22C4

0003 + 22C4 = 22C7

~ 22C7 = DD38-> 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:

4500 + 0031 + 89F5 + 0000 + 6E06 + DD38 + DEB7 + 455D + C0A8 + 00DC = 3 FFFC

0003 + FFFC = FFFF

The result is all in one, correct.

(operation)

Algorithms and procedures for finding checksums:

Algorithm:

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)

}

Program:

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.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report