Comparison of UDP and TCP

Source: Internet
Author: User
Tags snmp file transfer protocol

When the client needs to request some data on the database server, it needs at least three datagram to establish a TCP connection, three datagram to send and confirm a small amount of data, and three to close the connection. However, if you use UDP, you only need to issue two data packets to achieve the same effect. UDP does not require the client to establish or disable connections to the server. The client only places the data in the datagram and sends it to the server. The server constructs a response, places the response data in the datagram to the client, and then sends it to the client. Although this data transmission method is fast and effective compared with TCP for simple real transactions, UDP cannot process the loss of data packets. UDP allows service contacts on specific ports of the remote computer, but it does not establish a connection with the remote computer.

UDP is a substitute for TCP. Sometimes it is called UDP/IP together with IP. Like TCP, UDP also uses IP addresses for real datagram transmission between computers. However, UDP does not provide the function of dividing information into groups and reorganizing it on the receiving terminal.

The most fundamental difference between UDP and TCP is that they implement different data transmission methods. TCP supports guaranteed transmission because the receiving end automatically confirms a message after receiving it. In addition, if the receiving end does not respond within the specified time, the sending end will wait and re-transmit the data. The reliability of TCP may overhead the execution process. However, UDP does not implement guaranteed message transmission. During transmission, UDP datagram may be lost and the Protocol cannot detect or report this error. However, UDP does not impede reliable message transmission, but it is only necessary to hand over this task to a higher level in the TCP/IP Reference Model.

UDP is more advantageous than TCP in terms of packet overhead. Since TCP is a reliable protocol, it must ensure that the data arrives at the destination intact, so that a relatively large number of groups are exchanged on the network. UDP does not have this overhead, so the speed is much faster than TCP. UDP does not need to establish a connection before transmission, further reducing the overhead related to message transmission.

TCP needs to complete the three-way handshake process before starting data transmission. UDP does not need any formal preparation before transmitting data. TCP keeps connected computers in the connection state. The connection status includes the buffer size, congestion control parameters, serial numbers, and validation numbers of the sliding window and the acceptor computer. However, UDP does not need to maintain such a connection status or trace any parameters. Many clients supported by a server dedicated to a specific application are much more active when using UDP than when using TCP. For example, the UDP-Based SNMP management system supports multiple SNMP proxies.

The size of the header in the TCP segment is 20 bytes, while that in UDP is only 8 bytes. TCP has a congestion control mechanism to reduce the amount of data transmitted from the sending end when one or more links between the sending end and the receiving end experience excessive congestion. This process may have a negative impact on real-time applications because they can tolerate packet loss, but require a lower transmission rate. On the other hand, the speed of UDP data transmission is limited by factors such as the data rate, processing capability, clock rate of the source computer, and connection bandwidth generated by the application. In addition, the receiving host may not necessarily receive all the data. When the network is congested, data transmitted over UDP may be partially lost because the buffer zone of the router is full of a large number of data packets. For UDP, even if the sending rate is not limited, the receiving rate is also limited by network congestion.

TCP supports the following application protocols: HTTP (Hypertext Transfer Protocol), telnet (Remote logon), FTP (file transfer protocol), and SMTP (Simple Mail Transfer Protocol; UDP supports the following application-layer protocols: NFS (Network File System), SNMP (Simple Network Management Protocol), DNS (Primary Domain Name System), and TFTP (Common File Transfer Protocol) and NTP (Network Time Protocol.

Zookeeper

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.