Protocol forest 05 I do my best (IP protocol details)

Source: Internet
Author: User

Author: vamei Source: http://www.cnblogs.com/vamei welcome reprint, please also keep this statement. Thank you!

 

After a rough understanding of IP address relays and IP addresses, let's look at the specific details and design philosophy of the IP protocol.

 

Comparison between IPv4 and IPv6 Headers

We have already introduced in IP address relay that an IP packet is dividedHeader(Header) andData(Payload/data. The header is the additional information required for IP communication, and the data is the information to be transmitted by IP communication.

 

Yellow area (same name Area)

We can see that the three yellow regions span IPv4 and IPv6.Version(4-bit) indicates the IP protocol version, whether it is IPv4 or IPv6 (IPv4, version = 0100; IPv6, version = 0110 ).Source adrresssAndDestination AddressThe IP addresses of the sender and destination respectively.

  Blue region (the region where the name is changed)

Time to live survival time(Hop limitIn IPv6 ). Time to live originally represents the maximum lifetime of an IP packet: If the IP packet exceeded time to live during transmission, the IP packet will be voided. Later, an integer (such as 30) is recorded in the region of IPv4, indicating that a maximum of 30 routes can be retransmitted during the IP packet transmission process. If more than 30 routes are retransmitted, the IP packet will be voided. Each time an IP packet passes through a vro, The vro reduces time to live by one. When a vro finds that time to live is 0, the IP packet is no longer sent. The hop limit region in IPv6 records the maximum number of Route relays, which is the same as that in IPv4. Time to live/hop limit does not enable unlimited IP packets over the Internet.

type of service type ( traffic class in IPv6 ). Type of service was initially used to assign priority to IP packets. For example, voice calls require real-time performance. Therefore, its IP packet should have a higher priority than the Web Service's IP packet. However, this initial good idea was not adopted by Microsoft. The IP packages generated in windows are of the same highest priority. Therefore, during the hybrid network between Linux and Windows, IP Address Transmission in Linux is slower than that in Windows (just because Linux is more disciplined !). Later, the type of service was divided into two parts: Differentiated Service field (DS, first 6 digits) and Explicit Congestion noication (ECN, the last two digits). The former is still used to differentiate service types, the latter is used to indicate the traffic condition of the IP route. The traffic class of IPv6 is also divided into two parts. The idea of providing different services through IP packages and optimizing services has been produced for a long time, but the specific practice has not yet formed a recognized agreement. For example, the ECN area is used to indicate the traffic condition of the IP packet passing through the route. If the ECN area received by the receiver is very crowded, the receiver should make adjustments. However, in fact, many receivers ignore the information contained in ECN. Traffic control is often implemented by a higher level such as TCP.

Protocol(Next HeaderIn IPv6 ). Protocol is used to describe the Protocol followed by the payload part of the IP package, that is, the Protocol above the IP package. It illustrates what kind of high-level protocol package the IP package encapsulates (TCP? UDP ?).

Total length,And IPv6Payload lengthThe discussion will be put together with the IHL area, which we will discuss soon.

 

Red Area (Deleted area in IPv6)

Let's take a look at the IPv4 and IPv6 length information. The length of the IPv4 header. At the end of the header, yesOptions. Each options has 32 bits and is an optional region. An IPv4 header can have no options region at all. If you do not consider options, the entire IPv4 header has 20 bytes (each of the above 4 bytes ). However, because of the existence of options, the total length of the entire header changes. We useIHL(Internet header length) to record the total length of the headerTotal LengthRecord the length of the entire IP package. IPv6 does not have options, and its header is a fixed length of 40 bytes. Therefore, the IHL region is not required in IPv6.Payload lengthIt indicates the length of the IPv6 data part. The entire IP package is 40 bytes + payload length.

There is also an IPv4Header checksumRegion. This checksum is used to verify the header information of the IP package. Checksum and the CRC mentioned in the small speakerAlgorithmNot the same.IPv6 does notThe Checksum area. The IPv6 package validation relies on high-level protocols. This saves the time required for performing the checksum verification and reduces the network latency (latency ).

Identification,FlagsAndFragment OffsetAll three packages are for the fragmentation service. Fragmentation means that a router splits the received IP packets into multiple IP packets for transmission, and the routers or hosts receiving the "fragments" need to reassemble the "fragments) into an IP package. The maximum transmission units (MTU and maximum transportation units) supported by different local networks are different. If the size of an IP package exceeds the MTU supported by the local area network, fragmented transmission is required when you enter the Local Area Network (as if the surface is too large, you must break it into a bowl ). Fragmentation brings a great burden to routers and networks. It is best to detect the minimum MTU of the entire path before the IP package is sent. The size of the IP package does not exceed the minimum MTU to avoid fragmentation. IPv6 is designed to avoid fragmentation. The MTU of each IPv6 LAN must be greater than or equal to 1280 bytes. The default size of the IP packet sent by IPv6 is 1280 bytes.

 

Painful fragmentation

Green area (new area of IPv6)

Flow LabelIs a new region in IPv6. It is used to remind the router to reuse the previous relay path. In this way, the IP packet can automatically keep the sequence of departure time. This is helpful for applications such as streaming media. Further use of Flow Label is still under development.

 

"I try my best"

The IP protocol is a loose network when it is generated. The network is formed by the LAN of each university and maintained by a group of geek. Therefore, the IP Protocol considers its environment to beUnreliable(Unreliable): such as a router failure, a laboratory fire, or a PHD to kill the cable.

Unreliable Network

In such a dangerous environment, the IP protocol can only provideBest Effort). In the so-called "I try my best", its subline is: do not blame me if something goes wrong,I just promised to do my best, but I have no guarantee.. Therefore, if an error occurs during the transmission of an IP packet (for example, the checksum is not correct, for example, the traffic is too busy, for example, the time to live is exceeded), your IP packet will be directly lost according to the IP protocol. Game over, no further efforts will be made to correct errors. Best Effort keeps the IP protocol simple. More quality control is handed over to the high-level protocol for processing. IP protocol is only responsible for efficient transmission.

(What an irresponsible postal system)

"Efficiency first" is also reflected in the order of IP packets. Even if the origin and destination are unchanged, the IP protocol does not guarantee the arrival of the IP packet.Order. We already know that IP address relay decides the route based on the routing table. If the routing table is updated during the continuous IP packet sending process (for example, a new shortcut appears), then the sent IP packet uses a different routes. If the new path transmission speed is faster, the outgoing IP packet may arrive first. It is like on a multi-lane road, every car is constantly changing lanes, and eventually all lanes are full of cars. This allowsHighway Utilization RateMaximum.

"Jump"

 

We recommend that the router maintain the same path for some IP packets as the flow label in IPv6. However, this is only a "suggestion", and the router may ignore this suggestion.

 

Header checksum Algorithm

The header checksum area has 16 bits. It obtains the 0/1 sequence except checksum from the header, for example:

9194 8073 0000 4000 4011 c0a8 0001 c0a8 00c7 (hex in hexadecimal format, this is a header designed to demonstrate the operation process)

Divide the entire sequence by sixteen bits (that is, four bits HEX. Accumulate and add the four hex segments. If there is a carry value greater than 16 bits, add the first bits to the last bits of the last 16 bits:

Binary hex

1001000110010100 9194

+ 1000000001110011 8073

----------------

1 0001001000000111 11207

+ 1

----------------

0001001000001000 1208
The above calculation is calledOne's complement sum. Obtain the sum of all 16 digits,

One's complement sum (4500,007 3, 0000,400 0, 4011, c0a8, 0001, c0a8, 00c7) = 1433

Then, the checksum: ebcc is obtained after each bitwise of 1433 is reversed (0-> 1, 1-> 0 ).

In this way, our header is:

9194 8073 0000 4000 4011EbccC0a8 0001 c0a8 00c7

After receiving the IP packet, the receiver of the IP packet can calculate the one's complement sum of each 16-digit number.FFFF. If it is not FFFF, the header is incorrect and the entire IP packet is discarded.

(Remind me again that the IP header used in the example is not a real header. It only serves to demonstrate the algorithm)

 

Summary

Each network protocol has its ownHistorical Reasons. For example, the IP protocol is used to connect scattered lab networks. Because the network was small at that time, the total number of IPv4 addresses (generated in IPv4 and 1970s) was 4 billion. Although it was regarded as a big number at the time, the digital wave quickly brought about the address depletion crisis. The main purpose of IPv6 is to increase IPv4 address capacity, but it also makes improvements based on IPv4 experience and technological advances in the new era, such as avoiding fragmentation, for example, to cancel checksum (due to the widespread use of high-level TCP protocol ). Network protocols are not technically complex. More considerations are:Policy.

The IP protocol is "Best Effort", and IP transmission is unreliable. However, such a design achieves the efficiency of the IP protocol.

 

Welcome to the "protocol Forest" Series

 

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.