Detailed Explanation of TCP/UDP Differences and Advantages and Disadvantages

insert image description here

  1. The specific meaning of the TCP/IP protocol
    The TCP protocol is located at the transport layer, and the IP protocol is located at the network layer.
    In many cases, the TCP/IP protocol is just a general term for the protocol group that must be used when using IP for communication. Specifically, IP or ICMP, TCP and UDP, TELNET or FTP, and FTTP all belong to the TCP/IP protocol, and TCP/IP is sometimes called a network protocol group.
    insert image description here
    The difference between TCP and UDP protocols:
    Note: You can answer systematically from the following aspects
    1. Connection-based or connectionless
    2. Requirements for system resources (more TCP, less UDP)
    3. UDP program structure is simple
    4. Stream Media and datagram mode
    5. TCP guarantees data correctness, UDP may lose packets, TCP guarantees data order, UDP does not
TCP UDP
Is it connected connection-oriented connectionless
transmission reliability reliable Unreliable
Applications small amount of data transfer large amounts of data
speed slow quick

①Advantages of the TCP protocol: Reliable and stable. The reliability of TCP is reflected in the fact that TCP will have three handshakes to establish a connection before transmitting data, and before data transmission, there will be three handshakes to establish a connection, and there will be confirmation during data transmission. , window, retransmission, and congestion control mechanisms. After the data is transmitted, the connection will be disconnected to save system resources.

Disadvantages of TCP: slow, low efficiency, high system resource occupation, easy to be attacked, TCP needs to establish a connection before transmitting data, which will consume time, and when data is transmitted, confirmation mechanism, retransmission mechanism, congestion mechanism, etc. It consumes a lot of time and maintains all transmission connections on each device. In fact, each connection will occupy hardware resources such as CPU and memory of the system. Moreover, because TCP has a confirmation mechanism and a three-way handshake mechanism, these also make TCP easy to be exploited to achieve DOS, DDOS, CC and other attacks.

② Advantages of UDP: fast, slightly safer than TCP, UDP does not have TCP 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. However, UDP cannot avoid attacks; it is unreliable and unstable because UDP does not have the reliable mechanism of TCP. During data transmission, if the network quality is not good, it is easy to lose packets.

When should TCP be used:
When there are requirements for the quality of network communication, for example: the entire data must be transmitted to the other party accurately, which is often used in some applications that require reliability, such as QQ, browsers, HTTP, HTTPS, FTP, etc. Protocols for transferring files, protocols for mail transfers such as POP and SITP.

When should UDP be used:
When the communication quality requirements are not high, and the network communication is required to be as fast as possible, then UDP can be used, such as qq voice, qq video FTFP

Guess you like

Origin blog.csdn.net/qq_44333320/article/details/125986399
Recommended