Application scenarios of TCP and UDP

TCP and UDP

Both are communication protocols, TCP and UDP are both transport layer protocols, but their communication mechanisms and application scenarios are different.

TCP

TCP (Transmission Control Protocol) is also called Transmission Control Protocol. TCP is connection-oriented and a reliable protocol. When communicating based on TCP, both parties need to establish a TCP connection. The establishment of a connection requires a three-way handshake. The handshake is successful. Can communicate.

UDP

UDP is a connectionless, unreliable protocol. In the communication process, it does not need to establish a connection first like TCP. As long as the destination address, port number, source address, and port number are determined, it can be sent directly. Information messages, and do not necessarily receive or complete data. It only provides a checksum mechanism to ensure the integrity of the message. If the check fails, the message is directly discarded without any processing.

Advantages and disadvantages of TCP and UDP

TCP advantages

Reliable and stable
TCP's reliability is reflected in the three-way handshake to establish a connection (four waved to disconnect) before data transmission, and during data transmission, there are confirmation, window, retransmission, congestion control mechanisms, and disconnection after data transmission. Connect to save system resources.

TCP disadvantages

Slow, low efficiency, occupies system resources, and is easy to be attacked
to establish a connection before transmitting data. This will consume time. Moreover, the confirmation mechanism, retransmission mechanism and congestion mechanism will consume a lot of time during message transmission, and it must be done on each device. Maintain all transmission connections on the device. And each connection will occupy the system's CPU, memory and other hardware and software resources. In addition, TCP's takeover mechanism and the three-way handshake mechanism make TCP easy to be used by people to achieve DOS and DDOS attacks.

UDP advantages

Faster, safer than TCP,
UDP has no TCP handshake, confirmation window, retransmission, and congestion mechanism. UDP is a stateless transmission mechanism, so it is very fast when transmitting data. UDP does not have the mechanisms of TCP, and accordingly there are fewer vulnerabilities to be exploited. But UDP attacks also exist, such as: UDP flood attacks.

UDP disadvantages

Unreliable and unstable
Because UDP does not have the reliable mechanisms of TCP, packet loss is prone to occur when the network quality is poor.

Application scenarios

TCP application scenarios

When there is a requirement for the quality of network communication, such as: the entire data must be accurately and accurately transmitted to the other party. This is often for some applications that require reliability, such as HTTP, HTTPS, FTP and other file transfer protocols, POP, SMTP and other mail transfer protocols . Common applications that use the TCP protocol:
1. The browser uses: HTTP
2. FlashFXP: FTP
3. Outlook: POP, SMTP
4. QQ file transfer

UDP file transfer protocol

When the current network communication quality is not high, the network communication speed is required to be as fast as possible. At this time, UDP
is commonly used in daily life:
1.QQ voice 2.QQ
video
3.TFTP

Guess you like

Origin blog.csdn.net/qq_43518425/article/details/115315753