What is the IP protocol function from the format of the datagram can be known that an IP datagram is divided into the first and the data two parts, in the header 20 bytes are fixed, and some optional field length is variable, the following is the specific format of the IP datagram:
The meaning of each field in the IP datagram
1. Version number
Version number 4 bits, refers to the version of the IP protocol used, communication between the two sides to use the same version to communicate, the current version has IPV4 and IPV6,
2. First ministerial degree
The index is reported by the length of the first, accounting for 4 bits, note that the initial ministerial unit is 4 bytes, so the maximum header length can reach 15 * 4 = 60 bytes, when the header length is not 4 integer times, you need to fill with the Fill field.
3. Differentiated Services
8-bit for better service, this field is only useful when using differentiated services, and in general, this field is not used
4. Total length
The sum of the length of the header and data portion, which accounts for 16 bits, so the maximum length of the IP datagram is 2 of 16 square-1, or 65,535 bytes, however, so the length of the datagram is rarely encountered, we know that at the data link layer Specifies the size of the MTU (the common Ethernet MTU is 1500 bytes), When the datagram size exceeds the MTU, it is necessary to fragment processing.
The IP protocol specifies that all hosts and routers must be able to accept datagrams of not more than 576 bytes in length, and that when the packet to be sent exceeds 576 bytes, it should be understood whether the destination host is capable of accepting the length of the datagram being sent, otherwise it will be shard-processed.
5. Identification
Occupies 16 bits, the IP software maintains a counter in memory, each generates a datagram, adds a counter and assigns this value to the Identity field, and when the datagram is longer than the MTU of the network, the Shard must be processed, and the identity will be assigned to all shards. This means that the identity of multiple datagrams formed by a datagram after fragmentation is the same, so that they are made into a complete datagram.
6. Logo
Accounted for 3 bits, but at present only two bits are meaningful,
? The lowest bit of the flag field is MF, when MF = 1 o'clock, indicating that there is also a shard behind, MF = 0 indicates that this is the last Shard
The intermediate bit df,df means that shards cannot be partitioned, and when Df=0 is allowed
7. Sheet Displacement
Occupies 13 bits, each slice after the Shard in the original datagram position, that is, relative to the beginning of the datagram position, the piece from where to start, the slice displacement in 8 byte units,
8. Time to Live
8-bit, abbreviated as TTL (time to Live), this field indicates the lifetime of the datagram in the network, each time the datagram passes through a router, the TTL is reduced by 1, and when the TTL is 0 o'clock, the router discards the datagram without forwarding it, to prevent the datagram from being in the network " In circles "and in vain to consume network resources, the general operating system has a default TTL:
? Linux 64
? Windows 128
? Unix 256
9. Agreement
Accounted for 8 bits, the Protocol field indicates what protocol the data portion of the packet uses, so that the destination host's IP layer knows which part of the datagram is to be processed, and the common protocol and corresponding field values are as follows:
? ICMP 1
? IGMP 2
? IP 4, IP datagrams are then encapsulated in IP datagrams
? TCP 6
? IGP 9
? UDP 17
? IPV6 41
? ESP 50
? OSPF 89
10. First Inspection and
Accounted for 16, only the first Test after the inspection and fill in this field, do not test the data portion of the datagram, the datagram every router must recalculate the inspection and, the test and the calculation process is as follows:
? Set the test and field to full 0 first,
? The header of the IP datagram is then divided into a sequence of 16 bits in one unit, and these fields are summed in the inverse code arithmetic operation,
The resulting results are reversed and written to the test and field, noting that the inverse result and the original result are added to the total of 1
After receiving the datagram, the receiver also divides the header of the IP datagram into a sequence of 16 bits in one unit, and sums the fields in inverse code arithmetic operations.
If the resulting result is not 0, then it proves to be wrong, then discard the datagram, if the counter result is 0, the data will be submitted.
11. Source Address and Destination address
32-bit per cent
12. Variable part
The variable part of the IP header is an option field that can be used to support troubleshooting, measurement, and security measures such as rich content, a maximum of 40 bytes for the option field, and a minimum of 0 bytes, in fact these fields are rarely used, as this reduces overhead. The header of the IPV6 version of the IP datagram is fixed-length,
Format of IP datagrams