TCP (transmission Control Protocol, transmission Protocol) is a connection-based protocol, which means that a reliable connection must be established with each other before the data is formally sent and received.
A TCP connection must go through three "dialogues" to build up, the process is very complex, we only do a simple, image of the introduction, you just 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, OK?" "This is the first dialogue;
Host B sends a consent connection to host A and requires synchronization (synchronization is the two host one in the send, one in the receiving, coordinated work) packet: "Can, when do you send?" "This is the second dialogue;
Host A then sends a packet to confirm that Host B's requirements are synchronized: "I'll send it now, you go on!" ", this is the third dialogue. Three times the purpose of the "conversation" is to synchronize the sending and receiving of packets, and after three "conversations", host a formally sends the data to Host B.
UDP (User data Protocol, Subscriber Datagram Protocol) is the protocol that corresponds to TCP. It is a non-connected protocol that does not establish a connection with the other, but sends the packet over directly!
UDP is suitable for applications where only a small amount of data is transmitted at a time, and the reliability requirements are low. For example, we often use the "ping" command to test the TCP/IP communication between the two hosts is normal, in fact, the principle of "ping" command is to send UDP packets to the other host,
Then the other host confirms the receipt of the packet, if the packet arrives in time to return the message, then the network is a pass. For example, in the default state, a "ping" operation sends 4 packets (as shown in 2).
As you can see, the number of packets sent is 4 packets, and the received is also 4 packets (because the other host receives a confirmation of the received packet back). This fully illustrates that the UDP protocol is for a non-connected protocol, and there is no process for establishing a connection.
Because the UDP protocol does not have a connection process, it has high communication performance, but because of this, its reliability is not as high as the TCP protocol. QQ uses UDP to send messages, so there are times when messages are not received.
Differences between the TCP protocol and the UDP protocol:
TCP UDP
Whether connection-oriented connection oriented non-connected
Reliable unreliable transmission reliability
Applications that transmit large amounts of data, small amounts of data
Slow speed
The difference between TCP and UDP