"Go" http Learning---The difference and application of TCP and UDP protocols

Source: Internet
Author: User

"Original" https://www.toutiao.com/i6592813624689951239/

Overview

⊙TCP/IP is a protocol group that can be divided into three levels: Network layer, Transport layer and application layer.

At the network layer are IP protocols, ICMP protocols, ARP protocols, RARP protocols, and BOOTP protocols.

There are TCP protocols and UDP protocols in the transport layer.

In the application layer, there are FTP, HTTP, TELNET, SMTP, DNS and other protocols.

⊙TCP (transmission Control Protocol), also known as Transmission Protocol, TCP is connection-oriented, and is a reliable protocol, in the TCP-based communication, the two sides need to establish a TCP connection, the establishment of a connection requires three handshake, The handshake succeeds to communicate, and the disconnection is made 4 times.

⊙UDP (user Datagram Protocol), also known as Subscriber Datagram Protocol, UDP is a non-connected, and unreliable protocol, in the communication process, it does not need to establish a connection as TCP, as long as (destination address, port number, source address, port number) determined, You can send the message directly, and you do not need to ensure that the server will receive or receive complete data. It only provides a checksum mechanism to ensure the integrity of a message, if the verification fails, then directly discard the message, do not do any processing.

the difference between TCP and UDP

Connection-based and no-connection: TCP is based on connection-oriented, UDP is oriented to no connection;

System Resource requirements: TCP consumes more system resources, less UDP;

The program structure is simple: TCP program structure is complex, UDP program structure is simple;

Flow mode and Datagram mode: TCP is the streaming mode, UDP is the datagram mode;

Reliability: TCP guarantees data correctness, UDP may drop packets, TCP guarantees data order, UDP is not guaranteed.

Scenarios for TCP and UDP

From the features we already know, TCP is reliable but the transmission speed is slow, UDP is unreliable but the transmission speed is fast. Therefore, in the selection of specific protocol communication, should be based on the requirements of the communication data to decide.

If the communication data integrity needs to give way and the communication real-time, then the TCP protocol should be used (such as file transfer, update of important state, etc.), instead, use UDP protocol (such as video transmission, real-time communication, etc.)

"Go" http Learning---The difference and application of TCP and UDP protocols

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.