Current location - Loan Platform Complete Network - Big data management - 2-ipv6 basics-data packets
2-ipv6 basics-data packets
The IPv4 header consists of a fixed 20-byte header and a variable-length option:

Version field, 4 digits long. Identifies the version number of the currently adopted IP protocol. The general values are 0 100(IPv4) and 0 1 10(IPv6).

IHL is represented by 4 bits.

Since the length of the header is not fixed, the IHL field of the header indicates how long the header is (in units of the length of 32-bit words).

The minimum length of IHL is 5, indicating that there is no option. The maximum value of this 4-bit field is 15, which means that the maximum length of the header is 15*(32/8) = 60 bytes, so the option) = 60-20 = 40 bytes, and the maximum content of the option is 40 bytes. For some options, such as the path to record packets, 40 bytes is usually too small, which makes these options useless.

Service type field, 8 bits long.

8-bit bit-by-bit PPP DTRC0 is defined as follows.

PPP: Defines the priority of the package. The higher the value, the more important the data is.

DTRCO

Total length field, the length of IP packet (including header and data) is calculated in bytes, so the maximum length of IP packet is 65535 bytes.

The identification field, used in combination with the Flags and fragmentoffer fields, segments a larger upper-layer packet. After the router splits the packets, all the split packets are marked with the same value, and the destination device can distinguish which packet belongs to the split packet. Let the target host determine which datagram the newly arrived segment belongs to. All segments of the same datagram have the same identification value.

Next are the unused bits. There are two 1 bit fields.

DF stands for Don't Fragment and is a command to the router. It tells the router not to fragment the datagram because the target host may not be able to reassemble the fragment into the original datagram. For example, when a computer starts, its ROM may request a datagram containing a memory image from the network. After marking the DF bit in the datagram, it knows that the datagram will reach the receiver as a whole, but this means that the datagram must avoid the small packet network with the optimal path and have to take the suboptimal path. All machines need to accept data segments of 576 bytes or less (4.5k).

MF stands for more subdivision. This bit must be set to 1 for all segments except the last segment. Its purpose is to let the receiver know when all the data segments of the datagram arrive.

The fragment offset (13 bit field) field indicates the position of the fragment in the current datagram. Except the last segment of the datagram, all other segments must be multiples of 8 bytes, where 8 bytes are the basic segment unit (64-bit size). Because this field has 13 bits, each datagram can have at most two 13 = 8 192 segments, so the maximum datagram length is 8 192*8 = 65536 bytes, which is larger than the Taotal length field 1.

TTL (Time to Live) field (8-bit field), when an IP packet passes through every router along the way, every router along the way will reduce the TTL value of the IP packet by 1. If TTL is reduced to 0, IP packets will be discarded. This field can prevent IP packets from being continuously forwarded in the network due to routing loops.

When the network layer assembles a complete datagram, it needs to know how to deal with it. The protocol field indicates to which transmission process it should be switched. TCP is a possibility, so is UDP or other protocols. The serial number of the agreement is integrated with the Internet and unified globally.

The header checksum field only checks the header. Such a checksum is very useful for detecting "errors caused by poor router memory". Because every router changes the value of TTL, the router recalculates the value for each packet that passes. The algorithm is as follows: when the data arrives, all 16 bits (half words) are added, and then the complement of the result is taken. The intention of this algorithm is that when the data arrives, the calculation result of the header checksum should be 0. This algorithm is more stable than the conventional algorithm. Note that the header checksum field must be recalculated at each hop, because at least one field is always changing (i.e. time to live), but some techniques can be used to speed up the calculation.

Indicated by 32. Note that these two addresses will not change during the whole transmission unless NAT is used.

The design intention of the Option field is: it is mainly used for testing; Allow subsequent versions of the agreement to contain some information that was not in the original design; Allow experimenters to try new ideas; Avoid assigning header fields to information that is not commonly used. The length of the options is variable, and the first byte of each option is an identification code to indicate the options. Some options are followed by an option length field of 1 byte, followed by one or more data bytes. The option fields are filled in multiples of 4 bytes.

IPv6 datagrams include a main header and zero or more extended headers. The IPv6 header structure is shown in the following figure.

The length of IPv6 header is fixed at 40 bytes, which removes all optional items in IPv4 and only contains 8 required fields. Therefore, although the length of IPv6 address is 4 times that of IPv4, the length of IPv6 header is only 2 times that of IPv4.

4 digits, IP protocol version number, value = 6.

8 bits, indicating the communication category or priority of IPv6 data flow. This function is similar to the service type (TOS/QOS) field of IPv4. (You can modify the value of this field during the visit to the target node. )

20 bits, a new field is added in IPv6 to mark the data flow that needs special handling by IPv6 router. This field will provide more support for real-time datagram delivery and QoS. This field is used for some communications that have special requirements on the quality of service of the connection, such as real-time data transmission such as audio or video. In IPv6, there can be many different data streams between the same source and receiver, which are distinguished by non-"0" stream markers. If the router does not need to do special treatment, the value of this field is set to "0". The stream label was originally 28 bits, which was gradually modified to 20 bits in rfc2460. The stream label is generated by a pseudo-random algorithm, ranging from 1 to fffff. If a group of data streams have the same source address, destination address, hop-by-hop and route, then this group of data streams may * * * enjoy the flow label. It can be seen that IPv6 nodes can know how to process and forward this set of data streams only through the flow label, without checking other attribute values.

16 bit load length. The payload length includes the extension header and the upper layer PDU, and 16 bits can represent the payload length of 65535 bytes at most. For loads exceeding this number of bytes, the value of this field is set to "0" and the Jumbo Payload option in the hop-by-hop option of the extension header is used. In short, the value of this field = total message length -40.

8 bits, indicating the type of packet header that identifies the IPv6 header, such as extension header (if any) or transport layer protocol header (such as TCP, UDP or ICMPv6).

As can be seen from the following figure, because there can be multiple extension headers, there is a Next header field in one extension header to indicate the type of the next extension header or transport layer. (There can be multiple extensions, but only one upper layer data)

Common next header value:

8 bits, similar to the TTL (lifetime) field of IPv4. Unlike IPv4, which uses time to define the life cycle of packets, IPv6 uses the number of times packets are forwarded between routers to define the life cycle of packets. Every time a packet is forwarded, this field is reduced by 1, and when it is reduced to 0, the packet is discarded.

S

128 bits (16 bytes), the host address of the sender.

128 bits, in most cases, the destination address is the destination address. However, if there is a routing extension header, the destination address may be the next router interface in the sender's routing table.

Please refer to the document "Deep Analysis of IPv6".