TCP segment and IP segment

Source: Internet
Author: User

Preface:

Groups can occur at the transport layer and network layer. TCP segments in the transport layer and IP segments in the network layer. The IP layer fragment is mostly for UDP Service at the transport layer. Because TCP itself avoids IP fragment, the use of TCP transmission at the IP layer will not cause fragment.

When learning the TCP/IP protocol, we know that if the TCP packet segment is long, the segment will occur during sending and the segment will be reorganized during receiving, similarly, when the IP datagram length exceeds a certain value, it will also be split, and then be reorganized at the receiving end.

Let's take a look at two concepts that are closely related to TCP packet segment segmentation and IP datagram fragmentation.

Myu (maximum transmission unit)

As MTU has mentioned earlier, it is a limitation of the network on the data frame in the link layer. The MTU is 1500 bytes in the case of Ethernet. An IP datagram is transmitted over Ethernet. If its length is greater than the MTU value, it must be transmitted through multipart transmission so that the length of each datagram is smaller than MTU. IP datagram for multipart transmission does not necessarily arrive in order, but the information in the IP header allows these datagram slices to be assembled in order. The fragmentation and reorganization of IP datagram are completed at the network layer.

MSS (maximum segment size)

MSS is a concept in TCP (in the first option field ). MSS is the maximum data segment that TCP data packets can transmit each time. When the length of a TCP packet segment is greater than that of MSs, it must be transmitted in segments. When establishing a connection, the TCP protocol usually negotiates the MSS value of both parties. Each party has the MSS option used to advertise the desired receipt (the MSS option only appears in the SYN packet segment, that is, the first two TCP three-way handshake ). The MSS value is generally the MTU value minus the size of two headers (the size of the IP packet header must be reduced to 20 bytes and the size of the TCP Data Segment to 20 bytes). Therefore, if you use link layer Ethernet, the MSS value is usually 1460. The standard MTU (minimum MTU, when the link layer network is x2.5) on the Internet is 576. If this parameter is not set, the default value of MSS is 536 bytes. In many cases, the MSS value should be a multiple of 512. The segmentation and reorganization of TCP packets are completed at the transport layer.

At this point, there is a problem, and it is clear that the reason for TCP segmentation is MSS, and the reason for IP fragmentation is MTU, because MSS has always been <= MTU, it is obvious that, the length of each segment of TCP packet after segmentation plus the IP header cannot exceed MTU, so you do not need to perform IP sharding at the network layer. Therefore, IP segments are rarely split.

Let's look at the UDP datagram. Because UDP datagram does not segment itself, when the length exceeds MTU, IP segments will be performed at the network layer. Similarly, ICMP (at the network layer) may also experience IP sharding.

Conclusion: if UDP is not segmented, IP addresses are used for segmentation. TCP will be segmented. Of course, IP address is not used for splitting!

In addition, only the first part of the IP datagram with the UDP header or ICMP header, and the rest of the parts only have the IP header. After arriving at the endpoint, the parts are reorganized at the network layer based on the information in the IP header. Each segment of the TCP packet segment contains a TCP header, which is then reorganized at the transport layer based on the TCP header information. After the IP datagram is sharded, it is only reorganized after it reaches the destination, rather than to other network protocols. It will be reorganized at the next stop.

Finally, even if only one piece of data is lost, the whole datagram should be re-transmitted for the IP part datagram (since there is re-transmission, it indicates that the transport layer uses a protocol with the re-transmission function, such as TCP ). This is because the IP layer itself does not have a timeout retransmission mechanism ------ a higher level (such as TCP) is responsible for timeout and retransmission. When a segment from a TCP packet segment (in a portion of an IP datagram) is lost, TCP resends the entire TCP packet segment after the timeout, the CIDR Block corresponds to an IP datagram (multiple IP segments may exist). There is no way to re-transmit only one data segment in the datagram.


When the IP layer is sliced, only the first slice has the transport layer protocol header, and the rest of the slice does not contain the transport layer protocol header, which is very important. Then the TCP segment, each segment contains the TCP header information ,. In addition, the IP layer is reorganized after it reaches the destination when it is sliced. The IP layer is reorganized at the destination IP layer, and the TCP layer is reorganized at the destination transport layer.

TCP segment and IP segment

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.