TCP
TCP is connection-oriented and reliable flow protocol. TCP provides reliable transmission, implements sequence control or retransmission control, and provides flow control (flow control), congestion control, and network utilization.
TCP three-way handshake
Why three handshakes? To prevent an error caused by an invalid request packet being sent to the server, if no ACK packet is sent by the client for the third time, the server considers that a new connection is established. However, the client does not know the existence of this connection, causing status inconsistency. Therefore, the connection can be established only after the server receives an ACK packet. So the three-way handshake is to solve the problem of unreliable network channels. To establish a reliable connection over an unreliable channel
Four times to wave
UDP
UDP is a unreliable datagram protocol. Subtle processing is left to the upper level applications. UDP can determine the size of the sent message, but it cannot guarantee that the message will arrive. Therefore, applications sometimes resend the message according to their own needs.
Comparison between TCP and UDP
One might think that since TCP is a reliable transport protocol, it must be superior to UDP. In fact, the advantages and disadvantages of TCP and UDP cannot be simply and absolutely compared. So, how to distinguish the two protocols? Let me make a brief explanation of this problem.
TCP is used when reliable transport is necessary at the transport layer. Because it is connection-oriented and has sequence control, retransmission control and other mechanisms, it can provide reliable transmission for applications. On the one hand,UDP is mainly used for communications or broadcast communications that require high speed transmission and real-time performance. Let’s take an example of talking over an IP phone. If TCP is used, the data is retransmitted if lost during transmission, but the voice of the caller cannot be smoothly transmitted and communication cannot be normal. With UDP, it does not retransmit. Thus, there is no problem with the arrival of sound with a large delay. Even if some data is lost, only a small number of calls will be affected. In addition, UDP is used in multicast and broadcast communication instead of TCP. Broadcast protocols such as RIP and DHCP also rely on UDP. Therefore,TCP and UDP should be used on demand according to the purpose of the application.
Resources: 【 1 】 the computer network, Andrew S.T anenBaum David j. WetheraH [2] www.bilibili.com/video/BV1kV…
This article has participated in the activity of “New person creation Ceremony”, and started the road of digging gold creation together.