1. UDP Header
2. UDP sharding
In the second chapter, the link layer is mentioned. Ethernet is used to split the data frame header. The maximum transmission length is 1500. That is to say, if an IP datagram has a length greater than 1500, it needs to be split.
- In the IP header, the three-digit flag and the 13-digit offset are used for partitioning.
- Among the three-digit mark: a more part ID, except for the last part, must be included in other parts, and a non-part ID. If it is set to a higher part, the IP datagram is discarded and an ICMP error message is sent to the sender even if the IP datagram is longer.
- 13-bit offset: used to indicate the offset relative to the start offset.
- Each Shard has an independent IP header, 20 bytes.
- IP fragmentation and assembly are completed at the IP layer, which is transparent to the UDP/TCP network layer.
- If a part is lost during transmission, you need to re-transmit the entire IP datagram and cannot transmit a part separately. This is mainly because, if a part is made by a middle router, the start end does not know how to Shard, so it can only re-transmit the entire IP datagram.
- As for re-transmission. It can only be determined by the network layer. TCP will re-transmit packet loss, but UDP will not. The IP layer does not have the re-transmission mechanism of packet loss.
- Transmission unit. The IP layer is called an IP datagram, And the link layer is called a group.
As shown in, only the first part has a UDP header, but each part has an IP header.
3. ICMP inaccessibility error (sharding required)
If the unsharding flag is set in the IP header but the MTU limit is reached, the IP address is discarded and an ICMP inaccessibility error is returned.
The u d p length field refers to the bytes length of the u d p header and u d p data. The minimum value of this field is 8 bytes (send
0-byte u d p datagram is o k ). The u d p length is redundant. The length of an I p datagram refers to the total length of the datagram.
(Figure 3-1). Therefore, the length of the u d p datagram is the length of the total length minus the length of the I p header.
The Host Requirements RFC declares that the u d p check and option are enabled by default. It also states that,
If the sender has calculated the test, the receiver must check the received test (for example, the received test ).
And not 0 ). However, many systems do not comply with this, but are verified only when exit inspection and option is turned on
The physical network layer generally limits the maximum length of data frames sent each time. At any time, when the I p layer receives an I p data report to be sent, it must determine which local interface to send data (optional) and query the interface to obtain its m T U. I p compares M t u with the datagram length, and fragment if necessary. Fragments can occur on the original sending host or intermediate router. After an I p data packet is split, it is re-assembled only when it reaches the destination (here the re-assembled with other networks
Different network protocols require re-assembly at the next stop, rather than at the final destination ). Re-assemble
The purpose of the Objective I p layer is to make the multipart and re-assembly process transparent to the transport layer (t C P and U D p,
Except for some possible excessive operations. Data packets that have already been sharded may be sharded again (more than once ).
The data contained in the I p header provides sufficient information for sharding and reassembly.
For each I p datagram sent by the sender,
Each field contains a unique value. This value is copied to each piece when the data packet is sharded (we can see that
The purpose of this field ). The flag field uses a bit to represent "more slices ". Except the last one
The bit must be set to 1 for all the parts that constitute the datagram. The offset field refers to the position at the beginning of the offset of the original datagram.
In addition, after the data packet is split, the total length value of each piece should be changed to the length value of the piece.
Finally, a bit in the flag field is called the "not sharding" bit. If this bit is set to 1, I p will not use the datagram
. Instead, the datagram is discarded and an I c m p error message is sent.
(See Figure 6-3. In the next section, we will see an example of this error.
When an I p datagram is split, each piece becomes a group and has its own I p header.
Other groups are independent. In this way, the fragments of the datagram may be out of order when they arrive at the target end, but there are enough
Sufficient information allows the receiver to correctly assemble these datagram fragments.
Although the I p sharding process Looks transparent, one thing that makes people don't want to use it: even if only one piece of data is lost
Upload the entire datagram. Why is this happening? Because the I p layer itself does not have a mechanism for timeout retransmission-from a higher level
Responsible for timeout and retransmission (t c p has a timeout and retransmission mechanism, but u D p does not. Some u d p applications also execute timeout and
Re-transmission ). When a piece of data from the t c p packet segment is lost, t c p resends the entire t c p packet segment after the timeout.
It should be an I p datagram. There is no way to re-transmit only one piece of data. In fact, if
If it is an intermediate router, rather than a start-end system, the start-end system cannot know how the datagram is split. This
The reason is that you often need to avoid sharding.
The first two u d p data packets (1st and 2nd rows) can be loaded into Ethernet data frames without being split. But it corresponds to the write
1 4 7 3 byte I p datagram length is 1 5 0 1, you must partition (3rd rows and 4th rows ). Similarly, write 1 4 7 4 bytes to generate
The datagram length of is 1 5 0 2, it also needs to be split (5th rows and 6th rows ).
After I p datagram is split, t C P d u m p prints other information. First, frag 26304 (3rd rows and 4th
Rows) and frag 26313 (5th rows and 6th rows) indicate the value of the field identified in the header of I p.
The next number in the part information, that is, the 1 4 8 0 between the colon and the @ number in row 3rd, is the length of the segment except the I p header.
The first piece of two datagram data is 1 4 8 0: u d p header occupies 8 bytes, user data occupies 1 4 7 2 bytes (plus I p Header
The length of the 2 0 byte group is exactly 1 5 0 byte ). 1st pieces (2nd rows) of 4th data packets only contain 1 byte of data-the rest
User data. The first 2nd pieces (2nd rows) of 6th data packets contain the remaining 2 bytes of user data.
During the sharding process, except for the last one, the data in each other (except for the I p header) must be 8
An integer multiple of bytes. In this example, 1 4 8 0 is an integer multiple of 8.
The number after the @ symbol is the offset value calculated from the beginning of the datagram. The offset value of 1st pieces of two datagram data packets is 0 (3rd rows
And 5th rows), the offset value of 2nd slices is 1 4 8 0 (4th rows and 6th rows ). The plus sign following the offset value corresponds to the 3-bit sign in the I p header.
"More" bits in the field. The purpose of setting this bit is to let the receiver know when to complete all multipart assembly.
At last, note that the protocol name (u d p), source port number, and destination port number are omitted in lines 4th and 6th (not 1st.
The protocol name can be printed, because it is in the I p header and copied to each film. However, the port number is in the u d p header,
Only 1st clips can be found.
3rd pieces of data sent (the user data is 1 4 7 3 bytes) are split, as shown in 11-8. What needs to be reiterated is: Ren
The first part of the transport layer only appears in 1st pieces of data.
Also, several terms need to be explained: I p datagram refers to the end-to-end transmission unit of the I p layer (Before and After partitioning
Group refers to the Data Unit transmitted between the I p layer and the link layer. A group can be a complete I p datagram,
It can also be a part of an I p datagram.
Theoretically, the maximum length of an I p datagram is 6 5 5 3 5 bytes, which is determined by the I p header (Figure 3-1) 1 6-bit total length field.
Restricted. Remove the I p header of 2 0 bytes and the U D p header of 8 bytes. The maximum length of user data in the U D p datagram is
6 5 5 0 7 bytes. However, the length provided by most implementations is smaller than the maximum value.
UDP User Datagram Protocol-IP sharding