View TCP and UDP protocol applications/parameters

Source: Internet
Author: User

The packet sent by TCP has a serial number. After receiving the packet, the other party needs to send a feedback. If the packet has not received the feedback for a certain period of time, it will automatically execute timeout and resend the packet. Therefore, the biggest advantage of TCP is reliability. Generally, TCP is used for webpage (HTTP), email (SMTP), remote connection (Telnet), and file (FTP) transmission.
UDP is a message-oriented protocol that does not need to be connected during communication. data transmission is naturally unreliable and is generally used for multi-point communication and real-time data services, such as voice broadcast, video, QQ, TFTP (simple file transfer), SNMP (Simple Network Management Protocol), RTP (Real-Time Transfer Protocol) Rip (routing information protocol, such as report to the stock market, aviation information), DNS (Domain Name explanation ). Focus on speed and smoothness.

 

 

/*************************************** *

First, we will explain that the segmentation and fragment of the datagram do occur at the transmission layer, and the segmentation occurs at the network layer. However, for segments, this often happens on the UDP Transport Layer Protocol, which rarely happens on the transport layer using TCP channels.

1, MTU (maximum transmission unit, MTU), maximum transmission unit

(1) Ethernet and 802.3 have a limit on the length of data frames. The maximum values are 1500 and 1492 bytes, respectively. This feature of the link layer is called MTU. Most networks of different types have an upper limit. If there is data to be transmitted on the IP layer and the data length is greater than the MTU on the link layer, fragmentation is required on the IP layer to split the data into several parts, in this way, each part is smaller than MTU.

 

(2) After sharding an IP datagramIP layerThe purpose of re-assembly is to make the partition and re-assembly process transparent to the transport layer (TCP/UDP. Since each part is an independent package, when the piece of the datagram arrives at the destination end, it may be out of order, but there is enough information in the IP header to allow the receiving end to correctly assemble the piece of the datagram.

 

(3)Although the IP sharding process Looks transparent, one thing that people don't want to use is to re-transmit the entire datagram even if only one piece of data is lost.Why? 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 piece of data from a TCP packet segment is lost, TCP resends the entire TCP packet segment after the timeout. The packet segment corresponds to an IP datagram (instead of a shard ), there is no way to re-transmit only one data shard in the datagram.

 

(4)Using UDP can easily cause IP sharding. TCP tries to avoid IP sharding.. So how does TCP try to avoid IP sharding? To put it bluntly, using the TCP protocol for data transmission will not cause IP fragmentation, because once the TCP data is too large, it exceeds the MSS, TCP packets are segmented at the transport layer (see the following section for details about how to split them !), The data packets at the IP layer will certainly not exceed the MTU, and the parts are not required. For UDP datagram, if the length of an IP datagram consisting of UDP exceeds 1500, the IP datagram must be split, because UDP cannot segment itself like TCP.Conclusion: UDP will not be segmented, so it will be divided by my IP address. TCP will be segmented. Of course, I don't need to split the IP address!

 

2. the abbreviation of the Maximum Segment Size of MSs (maxitum segment size) is a concept in TCP.

(1) MSS is the maximum data segment that TCP data packets can transmit each time. To achieve optimal transmission performanceWhen establishing a connection, we usually need to negotiate the mss of both parties.Value. This value is often replaced by the MTU value when the TCP protocol is implemented (the packet header size of the IP packet must be reduced to 20 bytes and the packet header of the TCP data segment is 20 bytes ).MSS is 1460. Both parties will determine the maximum MSS value for this connection based on the MSS value provided by both parties.

(2) I believe there areLast question: How does TCP implement segmentation?? In fact, TCP does not matter in segments, because the size of each TCP datagram is limited by MSS before it is made up, so the length of the TCP datagram cannot be greater than that of MSs, of course, the length of the IP package Formed by it will not be greater than that of MTU, So you naturally do not need to partition the IP.

In short:

1. The cause of IP fragmentation is the MTU at the network layer. The cause of TCP segmentation is MSS.

2. IP segments are completed at the network layer and reorganized at the network layer. TCP segments are completed at the transport layer and reorganized at the transport layer. // transparency

3. For Ethernet, MSS is 1460 bytes, while mut is usually larger than MSS.

Therefore, using the TCP protocol for data transmission will not cause IP fragmentation. If the data size is too large, data is segmented only at the transport layer, so that data is not sliced at the IP layer.

This can be seen as the case: when the transport layer protocol wants to send a datagram that exceeds MTI, the network layer needs to partition it. Generally, UDP and ICMP will have a sharding problem, but TCP does not! Because TCP uses MSS to avoid sharding!

Only the first IP segment with the transport layer or ICMP header, and the rest of the parts only have the IP header. As for how to restructure the IP address layer after the peer end.

If the TCP packet is very long, it may be divided into multiple short datagram Slices During transmission at the IP layer. (Computer network Xie xiiren)

Each TCP segment has a complete header.

PS: So I think this is the case. TCP segments are for data at the application layer. For example, if we use TCP to send 70 KB of data, we need to divide 70 KB into several MSS, you do not need to partition at the network layer. The existence of MSs avoids the occurrence of network layer fragments,

The IP layer fragment is based on UDP protocol in the transport layer. If UDP is used to send data and UDP does not know how to segment the data, it is necessary to perform the fragment at the IP layer, based on MTU, the maximum data load for UDP is 1500-8 = 1492.

* **************************** Tcp udp segmentation ******* **************************************** ****************************/

View TCP and UDP protocol applications/parameters

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.