IP packet structure

Source: Internet
Author: User

I. IP address data packet structure:

The fields are described as follows:

1, version: version number, 4 bits, indicates the version of the IP protocol.

2, header length: header length, 4 bits, unit: 4 bytes, so the maximum length is 4*(2 ^ 4-1) = 60 bytes, the first fixed part is 20 bytes in length, and the variable part is 0 ~ 40 bytes.

3, differentiated services: service type, 8 bits, composition is as follows:

Process Field: 3 bits, set the importance of the data packet. The greater the value, the more important the data is. value range: 0 (normal )~ 7 (Network Control)

Latency field: 1 bit; Value: 0 (normal); 1 (low latency)

Traffic field: 1 bit; Value: 0 (normal); 1 (high traffic)

Reliability field: 1 bit; Value: 0 (normal); 1 (extremely high reliability)

Cost field: 1 bit; Value: 0 (normal); 1 (special minimum cost)

Reserved field: 1 bit, not used

4, total length: total length, 16 bits, header plus the total length of data, in bytes, so the maximum length of a datagram is 2 ^ 16-1 = 65525 bytes. In addition, the total length must not exceed the maximum transmission unit MTU.

5. identification: ID, 16 bits, counter, used as the datagram identifier. When a datagram needs to be sharded, This identifier is used to represent the shard of the same datagram. Use the following flags and fragment offset when you need to partition.

6, flags: Flag, 3 bits, as D0-D1-D2, their respective meanings are as follows:

D0: 1 indicates that there are subsequent shards, and 0 indicates that the datagram is the last shard.

D1: 1 indicates not sharding, and 0 indicates sharding.

D2: Reserved bits, not used.

7. fragment offset: the part offset, 13 bits, in 8 bytes. It indicates the relative position of a part in the original group.

8, time to live: survival time, 8 bits, indicates the lifetime of the datagram in the network. Unit: Hop. After a route, it indicates a hop. If this value is reduced by one, it is discarded.

9, protocal: Protocol, 8 bits, indicating the upper layer protocol using the package, such as TCP = 6, ICMP = 1, UDP = 17, etc.

10. header checksum: header (excluding the data) Check and 16 bits. Here, we do not use CRC verification codes but use a simple calculation method of "inverse code arithmetic summation.

11, source address: source address, 32 bits, that is, the source IP address.

12, destination address: destination address, 32 bits, that is, destination IP address.

13, options: optional field, variable length, 1 ~ 40 bytes. It is used to add the control function of IP datagram.

14. There is also a filling field, which is not displayed. This field is used to ensure that the header length is an integer multiple of 4 bytes.

15. Data: user Data.

2. Use the packet capture tool to capture IP datagram as follows:

The figure shows that the IP address header is only 20 bytes and the field values are:

Version (4): 4.

Header length (4): 5*4 = 20 bytes.

Differentiated services (8): ox00.

Total length (16): ox0034, 3*16 + 4 = 52 bytes. We can see that the IP packet length is 66-14 = 52, and the first 14 bytes are part of the data in the Ethernet frame, it is actually two mac (6 byte) addresses plus a 2-byte type.

Identification (16): ox4c46, 19526.

Flags (3): Binary 010. We can see that the datagram is not sharded and is the last part.

Fragment offset (13): Binary 0 0000 0000 0000.

Time to live (8): 0x40, that is, 64 hops.

Protocal (8): 0x06, that is, the upper layer protocol is TCP.

Header checksum (16): 0xd7e8.

Source address (32): 0xc0a80569, that is, 192.168.5.105.

Destination address (32): ox774bd938, that is, 119.75.217.56.

Options (1 ~ 40): None

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.