The Advantages, Disadvantages and Differences of TCP and UDP

Source: Internet
Author: User
Keywords what is the difference between tcp and udp what is the purpose of tcp and udp difference between tcp and udp
Advantages of TCP: Reliable and stable. The reliability of TCP is reflected in the three-way handshake to establish a connection before TCP transmits data, and during data transmission, there are confirmation, window, retransmission, and congestion control mechanisms. After the data is transmitted, Also disconnected to save system resources. Disadvantages of TCP: slow, low efficiency, high system resources, easy to be attacked. TCP must establish a connection before transmitting data, which will consume time, and during data transmission, confirmation mechanism, retransmission mechanism, congestion control mechanism, etc. It will consume a lot of time and maintain all transmission connections on each device. In fact, each connection will take up the system's CPU, memory and other hardware resources. Moreover, because TCP has an acknowledgment mechanism and a three-way handshake mechanism, these also make it easy for people to use TCP to achieve DOS, DDOS, and CC attacks.
Simple Application Server
USD1.00 New User Coupon
* Only 3,000 coupons available.
* Each new user can only get one coupon(except users from distributors).
* The coupon is valid for 30 days from the date of receipt.

Advantages of UDP: Faster and slightly safer than TCP. UDP does not have TCP's handshake, confirmation, window, retransmission, congestion control and other mechanisms. UDP is a stateless transmission protocol, so it is very fast when transferring data. Without these mechanisms of TCP, UDP has fewer vulnerabilities exploited by attackers than TCP. But UDP also cannot avoid attacks, such as: UDP Flood attack... The disadvantages of UDP: unreliable and unstable because UDP does not have the reliable mechanisms of TCP. During data transmission, if the network quality is not good, it will be easy to lose packets. . Based on the above advantages and disadvantages, then: When should you use TCP: When there is a requirement for network communication quality, such as: the entire data must be accurately transmitted to the other party, which is often used for some applications that require reliability, such as HTTP, HTTPS , FTP and other file transfer protocols, POP, SMTP and other mail transfer protocols. In daily life, the common applications that use the TCP protocol are as follows: Browser, HTTP FlashFXP, FTP Outlook, POP, SMTP Putty, Telnet, SSH, QQ file transfer...... When should you use UDP : When the network communication quality is not high, the network communication speed is required to be as fast as possible, then UDP can be used. For example, in daily life, the common applications that use UDP protocol are as follows: QQ voice QQ video TFTP ……

Some application scenarios do not require high reliability and will use UPD, such as long video, which requires speed

The difference between TCP and UDP:

1. Based on connection and no connection;
2. Requirements for system resources (more TCP, less UDP);
3. UDP program structure is relatively simple;
4. Stream mode and datagram mode;

5. TCP guarantees the correctness of the data, UDP may lose packets, TCP guarantees the data sequence, UDP does not guarantee.

The difference between tcp protocol and udp protocol
TCP UDP
Whether to connect connection-oriented connection-oriented non-connection
Transmission reliability reliable unreliable
Application occasions Transfer large amounts of data, small amounts of data
Speed slow fast

Summary of the difference between TCP and UDP:

1. TCP connection-oriented (such as dialing to establish a connection before making a call); UDP is connectionless, that is, there is no need to establish a connection before sending data

2. TCP provides reliable services. That is to say, the data transmitted through the TCP connection has no errors, no loss, no duplication, and arrives in order; UDP does its best to deliver, that is, reliable delivery is not guaranteed

3. TCP is byte-oriented, in fact TCP treats data as a series of unstructured byte streams; UDP is message-oriented

UDP has no congestion control, so network congestion will not reduce the sending rate of the source host (useful for real-time applications, such as IP telephony, real-time video conferencing, etc.)

4. Each TCP connection can only be point-to-point; UDP supports one-to-one, one-to-many, many-to-one and many-to-many interactive communications

5. TCP header overhead is 20 bytes; UDP header overhead is small, only 8 bytes
6. The logical communication channel of TCP is a full-duplex reliable channel, while UDP is an unreliable channel

Related Article

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.