The most complete difference between TCP and UDP

Transfer: https: //www.cnblogs.com/williamjie/p/9390164.html

TCP (Transmission Control Protocol, Transmission Control Protocol)

DUP (User Data Protocol, User Datagram Protocol)

TCP advantages and disadvantages: reliable and stable. TCP Reliable reflected in the TCP before passing the data, there will be three-way handshake to establish a connection, but at the time of data transfer, confirmation, windows, retransmission, congestion control mechanism, after the completion of the data transfer, but also to disconnect conserve system resources. TCP's shortcomings: slow, low efficiency, high system resources, vulnerable to attack TCP before passing the data, must first establish a connection, which consumes time and data transfer, the acknowledgment mechanism, retransmission mechanism, and congestion control mechanisms will time-consuming, but also to maintain all transport connections on each device, in fact, connected to each CPU takes up system memory and other hardware resources. Moreover, because TCPyou confirmation mechanism, three-way handshake, which also led to TCP vulnerable to exploitation, to achieve DOS, DDOS, CC attacks.

UDP advantages and disadvantages: fast, safe slightly than TCP UDP TCP handshake is not confirmed, window, retransmission, congestion control mechanisms, stateless UDP is a transport protocol, so it is very fast data transmission. These mechanisms are not TCP, UDP than TCP vulnerability will be exploited by attackers less. UDP attacks but also can not be avoided, such as: UDP Flood attack ..... UDP Disadvantages: unreliable, unstable because TCP UDP no reliable mechanism that, when the data transfer, if the network is not good, it will easily loss .

Based on the above advantages and disadvantages, then: when to use TCP?

When there are requirements for network communication quality, such as: the accuracy of the entire data to be passed to the other side, which is often some of the requirements for reliable applications, such as file transfer protocol HTTP, HTTPS, FTP, etc., POP, SMTP and other mail transfer agreement. In daily life, common applications use the TCP protocol are as follows: browser, use HTTP FlashFXP, use UDP can be used for example, in daily life, common application using UDP protocol are as follows:. QQ QQ voice video TFTP .... .

TCP can only point to point full duplex communication; UDP support one to one, one to many, and many-to-many interactive communication.

TCP and UDP use cases

In order to achieve reliable TCP network communication, and increase the complexity of checksum mechanism, identification number, sliding window, acknowledgment, congestion control, the establishment of a handshaking procedure cumbersome, the TCP increases the consumption of system resources; TCP retransmission mechanism, have a sequence control mechanism is a delay effect on data transmission, reducing the transmission efficiency. TCP for low transmission efficiency requirements, but requires a high accuracy of the application scenario, such as the World Wide Web (HTTP), W

After the application layer message as a string of unstructured byte stream, TCP packet into multiple segments transmitted reassembled destination; for the UDP protocol packets, application layer packets are not split, leaving only packet Wen border, once a message is sent, the recipient after removing the message header, intact packets to the upper layer application.

Guess you like

Origin www.cnblogs.com/littleswan/p/12509653.html