This paper is participating in theNetwork protocols must be known and must be known”Essay campaign
TCP and UDP
Today, we will talk about one of the most common problems: the basic knowledge of TCP and UDP
This problem has a lot of explanations on the Internet, today to talk about their own understanding and some knowledge summary
Both TCP and UDP are transport layer protocols. Their basic function is to extend the host-host transfer service provided by IP to the end-to-end process level. In layman’s terms, data segments are transferred from one application on one computer to another application on another computer.
Take a look at the OSI seven-tier model, which is most commonly used
- Link layer: encapsulates and unencapsulates IP packets and sends and receives ARP/RARP packets.
- The network layer is responsible for routing and sending packet packets to the target network or host.
- Transport layer: groups and reorganizes packets and encapsulates them in TCP or UDP format.
- Application layer: responsible for providing applications to users, such as HTTP, FTP, Telnet, DNS, SMTP, and so on.
TCP
TCP is used for communication between applications.
TCP (Transmission Control Protocol) is a connection-oriented, reliable, byte stream based transport layer communication protocol. Three handshakes, four waves
When an application wants to communicate with another application over TCP, it sends a communication request. The request must be sent to an exact address. After a “handshake”, TCP establishes a full-duplex communication between the two applications.
This full-duplex communication will occupy the communication line between the two computers until it is shut down by one or both.
UDP is similar to TCP, but simpler and less reliable than TCP.
UDP
UDP is the user Datagram protocol. In the network, it is a connectionless protocol like TCP for processing data packets.
In the OSI model, layer 4, the transport layer, is one layer above the IP protocol. UDP does not provide packet grouping, assembly, and sorting. That is, after a packet is sent, it is impossible to know whether the packet arrived safely and intact.
The difference between TCP and UDP is resolved
A brief introduction to the characteristics of TCP and UDP can better compare their differences!
UDP features:
- Connectionless oriented
- Message-oriented,
- Unreliability,
- Unicast, multicast, broadcast functions
- The header cost is low and it is very efficient in transmitting data packets.
TCP features:
- connection-oriented
- Only unicast transmission is supported
- Word oriented stream
- Reliable transport
- Provide congestion control
- TCP provides full duplex communication
Let’s take a look at the comparison table to see the difference more clearly
The characteristics of | UDP | TCP |
---|---|---|
Whether connection | There is no connection | connection-oriented |
reliable | Unreliable transmission, not using flow control and congestion control | Reliable transmission, using flow control and congestion control |
Number of connected objects | Supports one-to-one, one-to-many, many-to-one and many-to-many interactive communication | It can only be one-to-one communication |
transport | For a message | Word oriented stream |
The first overhead | The header overhead is small, only 8 bytes | Minimum 20 bytes, maximum 60 bytes |
Applicable scenario | For real-time applications (IP phone calls, video conferencing, live streaming, etc.) | Suitable for applications that require reliable transmission, such as file transfer |
conclusion
These are the differences between TCP and UDP
Generally in the interview, just ask about their characteristics and differences
We want to grasp the key to learn, want to understand a deeper layer need to work hard to network protocol research ~