Current location - Quotes Website - Team slogan - What are TCP ports and UDP ports? Which expert explains it clearly? Thank you.
What are TCP ports and UDP ports? Which expert explains it clearly? Thank you.
TCP (Transmission Control Protocol) is a connection-based protocol, that is, a reliable connection must be established with the other party before sending and receiving data formally. A TCP connection can only be established after three sessions, and the process is very complicated. We only make a simple and vivid introduction here, as long as you can understand the process. Let's take a look at the simple process of these three conversations: Host A sends a connection request packet to Host B: "I want to send you data, can I?" This is the first conversation; Host B sends a data packet to host A, and host A agrees to connect and asks for synchronization (synchronization means that the two hosts are sending and receiving and coordinating their work): "OK, when will you send it?" This is the second conversation; Host A sends another data packet to confirm the request of synchronizing host B: "I'll send it now, you can continue!" " "This is the third conversation. The purpose of the three sessions is to synchronize the sending and receiving of data packets. After three conversations, Host A will formally send data to Host B. ..

Udp (User Datagram Protocol) is a protocol corresponding to TCP. It is a non-connection-oriented protocol, it does not establish a connection with the other party, but sends data packets directly!

UDP is suitable for the application environment where only a small amount of data is transmitted at a time and the reliability requirement is not high. For example, we often use the "ping" command to test whether the TCP/IP communication between two hosts is normal. In fact, the principle of the "ping" command is to send a UDP packet to the other host, and then the other host confirms the receipt of the packet. If the message of whether the packet arrives is fed back in time, then the network is connected. For example, by default, the ping operation sends four packets (as shown in Figure 2). As you can see, the number of packets sent is 4, and the number of packets received is also 4 (because the other host will send back a packet to confirm receipt). This fully shows that UDP protocol is a connectionless protocol, and there is no process of establishing a connection. Because UDP protocol has no connection process, the communication effect is high; But because of this, its reliability is not as high as TCP protocol. QQ uses UDP to send messages, so sometimes you can't receive messages.

The difference between tcp protocol and udp protocol

TCP UDP

Whether the connection is connection-oriented, connection-oriented or non-connection-oriented.

Transmission reliability is reliable and unreliable.

Applications transmit large amounts of data and small amounts of data.

Slow and fast