Detailed analysis of IP protocol header format (1)

Source: Internet
Author: User

IP protocol is the first and most basic protocol for us to learn about network protocols. Today we will introduce the basic status of the IP protocol header format. Let's take a look at the following content about the IP protocol header format and the Sniiffer Portable IP header. The IP (Internet Protocol) is the layer-3 network layer Protocol of OSI. This section only describes the IPv4 version as an example. The IP Protocol is also a connectionless Protocol, it is mainly responsible for addressing between hosts and setting routes for data packets. It does not establish a session before data is exchanged because it does not guarantee correct transmission. On the other hand, when data is received, the IP address does not need to be confirmed, so it is unreliable 。

IP protocol Header Format

When the data passes through the IP network layer, it will also encapsulate the data, and there will be a corresponding IP header. In an Ethernet frame, the IPv4 header is followed by the Ethernet frame header, at the same time, the protocol type value in the Ethernet frame header is set to 0800 Of The hexadecimal format 。

◆ Version)

The version number of the specified IP protocol. Because the IPv4 version is still used, the value here is usually 0x4 (Note that the number used by the packet is usually hexadecimal 。

◆ Header Length (Internet Header Length, IHL)

Indicates the number of 32-bit characters in the length of the IPv4 header. Because the IPv4 header may contain a variable number of optional values, therefore, this field can be used to determine the offset position of the Data part in an IPv4 datagram. The minimum length of an IPv4 packet header is 20 bytes, therefore, the minimum value of the IHL field is 5 in decimal format. It occupies 4 bits. Because it is a 4-bit field, the header is up to 60 bytes, however, it can still be up to 24 bytes at present 。

◆ Type of Service (TOS)

Defines the service types required by IP packets during transmission, each of the eight bits represents a different meaning. Only 1bit can be set in 4 bits. If all 4bit values are 0, it means a General Service:

◆ 000... (Routine): Process field, which occupies three places. It sets the importance of data packets. The greater the value, the more important the data is. The value range is 0 (normal )~ 7 (Network Control)

◆... 0... (Delay): latency field, which occupies 1 digit; Value: 0 (normal), 1 (low latency)

◆... 0... (Throughput): traffic field, which occupies 1 place. Value: 0 (normal), 1 (extremely high traffic)

◆... 0 .. (Reliability): Reliability field, which occupies 1 digit. Value: 0 (normal), 1 (special high Reliability)

◆ ..... 0. (ECN-Capable Transport): indicates the Transport field, which occupies 1 position. It is set by the source to show that the Transport protocol for the source node is ECN (Explicit Cogestion Transport ica tion, value: 0 (ECN not supported), 1 (ECN supported)

◆... 0 (Congestion Experienced): indicates the Congestion warning field, which occupies 1 place. Values: 0 (normal, no Congestion), 1 (Congestion)

◆ Package Length (Total Length, TL)

Specify the total length of the IP packet in the IP protocol header format. The total length of the packet is usually measured in bytes. This value includes the total length of the header and data. It is measured in bytes, the header length field and the total length field can be used to know the start position and length of the data content in the IP datagram 。

Because this field is 16 bits long, the IP datagram can be up to 65535 bytes. Although a 65535-byte IP datagram can be transmitted, most link layers segment it, the host also requires that data packets of more than 576 bytes cannot be received. Because TCP divides user data into several segments, therefore, this restriction does not affect TCP. UDP applications (such as RIP, TFTP, BOOTP, DNS, and SNMP) all limit the User Datagram length to 512 bytes, less than 576 bytes. However, in fact, most of the current implementations allow more than 8192 bytes of IP datagram 。

The total length field is necessary in the IP header, because some data links (such as Ethernet) some data needs to be filled to the minimum length. Although the minimum frame length of Ethernet is 46 bytes (which will be described later in this chapter), the IP data may be shorter. If there is no total length field, the IP layer does not know how many of the 46 bytes are IP datagram content 。

◆ Identification)

Each IP packet has a unique 16-bit identifier. When the data generated by the program is transmitted over the network, it is split into packets for transmission, this ID is the basis for packet restructuring 。

The ID field uniquely identifies each datagram sent by the host. Generally, the value of each sent message is increased by 1. RFC791 considers that the ID field should be sent by the upper layer of the datagram sent by the IP address. select. Suppose there are two consecutive IP datagram, one of them is generated by TCP, and the other is generated by UDP, so they may have the same identification field. Although this can also work as usual (processed by the reorganization algorithm ), however, in most systems derived from Berkeley, each time an IP datagram is sent, the IP layer must add the value of a kernel variable to 1, no matter which layer of data is sent to the IP address. The initial value of the kernel variable is set based on the time during system boot 。

◆ Flag (Flags)

This is the three-bit recognition mark used when the packet is best combined during transmission 。

◆ 000 (Reserved Fragment): Reserved segments. When this value is 0, it indicates that it is not used currently 。

◆. 0. (Don't Fragment): Do not segment. When this value is 0, it indicates that the packet can be segmented. If it is 1, it cannot be split 。

◆ .. 0 (More Fragment): More segments. When a value of 0 indicates that the package is the last package, if the value is 1, there are still split packets 。

◆ Fragment Offset (FO)

The IP protocol Header Format specifies that after a packet is segmented, the arrival sequence of the packet will not be the same as the original cut sequence due to network conditions or other factors, therefore, when the packets are segmented, the positioning records are prepared for each segment so that the segments can be seated during the reorganization. The value is the number of bytes. If the packets are not segmented, the FO value is "0". It occupies 13 places 。


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.