IPv4 datagram: parsing working principle and meaning of each field

IPv4 datagram is a kind of network protocol, it is a member of the Internet protocol family, responsible for the transmission of data packets from the source address to the destination address. IPv4 datagram is a connectionless protocol, which means that each datagram is processed independently, without the need to establish a connection like the TCP protocol. The advantages of IPv4 datagrams are fast transmission speed and high transmission efficiency, but the disadvantages are high unreliability, and problems such as packet loss and repeated transmission may occur.

Each field of the IPv4 datagram and its meaning will be introduced below.

eed4bdb0ff9d0dac14976ced11dbf8da.jpeg

version number

The version number of the IPv4 datagram occupies four digits, and its value is 4, representing the IPv4 protocol.

header length

The header length of an IPv4 datagram occupies four bits. Since a unit length is 32 bytes, the minimum value of the header length is 0101, which is 20 bytes, and the maximum value is 1111, which is 60 bytes. If the length of the header is not an integer multiple of 4 bytes, the following padding fields will be automatically filled to an integer multiple of 4 bytes. The differentiated service of the IPv4 datagram occupies eight bits, which is generally of no practical use.

total length

The total length of the IPv4 datagram occupies 16 bits, indicating the total length of the header and data, and the maximum value is 65535 bytes. Fragmentation is required if the length of the transfer exceeds this value.

The identifier of the IPv4 datagram occupies 16 bits, and represents the value of a counter of a datagram. When a datagram must be fragmented because its length exceeds the MTU of the network, this value will be copied to the identification field of all datagram fragments, and when reassembly occurs, datagrams with the same identifier value will be reassembled into A datagram.

82b128e7e403f11e6e736b5e9c0a59c2.jpeg

the sign

The flag of the IPv4 datagram occupies three bits, and the lowest bit is called MF. MF=1 means that there are several datagrams behind, and MF=0 means that this is the last datagram. The middle bit is called DF, and DF means that fragmentation cannot be performed, and only when DF=0 can fragmentation be performed.

slice offset

The fragment offset of an IPv4 datagram occupies 13 bits, indicating the relative position of a fragment in the original datagram, and the basic unit is 8 bytes. The length of each fragment is an integer multiple of 8 bytes, and the last fragment is filled if it is less than 8 bytes.

survival time

The lifetime of an IPv4 datagram occupies 8 bits, that is, TTL (time to live), which indicates the lifetime of the datagram in the network. This value is set as the number of hops, that is, the number of routers that the datagram can pass through. For routers, the value is decremented by one, and discarded when it reaches zero.

protocol

The protocol of the IPv4 datagram occupies 8 bits, which is used to indicate which protocol the datagram carries. The checksum of the header of the IPv4 datagram occupies 16 bits, and is used to check the correctness of the header of the datagram. The IP source address of the IPv4 datagram occupies 32 bits, indicating the source address of the datagram.

Destination address

The destination address of the IPv4 datagram occupies 32 bits, indicating the destination address of the datagram.

options

Options in an IPv4 datagram can be of variable length and contain up to 40 bytes. Available IP options are Record Routing, Timestamp, Loose Routing, Strict Routing, etc.

20aa552ab2d9a9625cdd4366481e032d.jpeg

The above are the various fields of the IPv4 datagram and their meanings. Understanding these contents can better understand the working principle of the IPv4 datagram. The format and field information of IPv4 datagrams is a must-knowledge, especially for those engaged in network or computer-related work.

Guess you like

Origin blog.csdn.net/qq_40427481/article/details/132712834