TCP and UDP protocols

Source: Internet
Author: User

Http://net.zdnet.com.cn/network_security_zone/2009/0107/1305139.shtml

Before learning about TCP and UDP, we need to understand two concepts: connection-oriented Service When connecting to a connectionless service or application, the customer and the server send control groups to each other before sending data. This is called a handshake process, this allows both the customer and the server to prepare for group exchange. This preparation is loose. connection-oriented services are bundled with many other services, including reliable data transmission, traffic control, and congestion control, the dependency connection transmits all data in the correct order without errors. The validation and retransmission mechanisms are also used for reliability. The unconnected Service side does not have a handshake process. When one party wants to send data, it directly sends the data, because there is no traffic control or congestion control without the handshake process, in this way, the data may be transmitted faster, but the source end does not know that those groups have reached the target end because there is no validation process. Therefore, data may be lost during transmission, which is not suitable for file transmission, but can be used for Internet calls or video conferences.


TCP (Transmission Control Protocol) and UDP (supporting Datagram Protocol) are two transmission protocols at the transport layer. The biggest difference between them is whether they are connection-oriented.


TCP includes connection-oriented and reliable data transmission services. Before communication between the client and the server, you must first exchange control information on the transport layer to prepare for communication between the two parties. In this handshake phase, we can assume that there is a TCP connection between the two processes and it is a full-duplex connection. After the message is sent, the application will tell TCP to remove the connection. Reliable transmission services ensure that all data can be transmitted in an error-free sequence during communication.

When any application transmits a byte such as a socket, it can expect TCP to send the same byte to the socket of the other party without any loss or retransmission. TCP is a public service of the Internet. Its purpose is to regulate some problems in the data transmission process, so it also includes a congestion mechanism. TCP congestion prevents sending processes when the network becomes congested. Specifically, TCP congestion control attempts to limit each TCP connection to the network bandwidth it shares fairly. For real-time audio or video applications with minimum bandwidth requirements, blocking their bandwidth will make them unable to work normally. In addition, we can imagine that during network calls, occasional disconnections are tolerable. It can be seen that real-time applications can tolerate the loss of a small amount of data without completely reliable services.

After talking about so many good services that TCP can provide, let's look at its shortcomings. First, TCP does not guarantee the minimum transmission rate, TCP does not allow the sending process to send data at the desired rate. Due to TCP congestion control, the sending process may be forced to send data at a low average rate. Second, TCP does not provide any latency protection. Specifically, after the sending process passes data into its own TCP socket, the data will eventually reach its accept socket, however, the time passed in the middle cannot be guaranteed.
, Takes a few seconds or several minutes.


UDP is a lightweight connection-oriented transmission protocol with the simplest service model. UDP is not connected, so there is no handshake before two processes communicate with each other. UDP provides unreliable data transmission services. That is to say, when a process sends a message to its own socket, UDP cannot guarantee that the message will eventually arrive at the receiving socket. In addition, the order of arrival of messages that actually receive a set of characters may not be sequential.

UDP does not include the congestion control mechanism, so the sending process can send data to the UDP socket at any rate. Although it cannot ensure that all data reaches the receiving socket, there will be a considerable proportion of data in the column. Developers of real-time applications often choose to run their applications on UDP. Like TCP, UDP does not provide any latency guarantee.

After talking about this, we can use the following table to understand the true meaning of the above.

Application

Application Layer Protocol

Supported transmission protocols

Email

SMTP (rfc82)

TCP

Remote Terminal Access

Telenet

TCP

Web

HTTP

TCP

File Transfer

FTP

TCP

Remote File Server

NFS

TCP or UDP

Stream multimedia

Exclusive

UDP or TCP

Internet phone number

Exclusive

Generally UDP

In the table, we can see that email, remote terminal access, web and file transfer all use the TCP protocol. The main reason for choosing TCP for these applications is that TCP provides reliable data transmission services, this ensures that all data will eventually reach its destination. We also see that internet phones generally run on UDP protocol, and both ends of an Internet phone application can send data at a certain minimum rate across the network. In addition, internet phones can tolerate data loss, both of these conditions are applicable to UDP and do not require reliable TCP transmission services.

In general, TCP can ensure that all data is transmitted, but UDP cannot, and they do not provide latency assurance. They do not provide latency assurance, which does not mean that time-sensitive applications cannot run on the current Internet, but applications use other methods to ensure these needs.

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.