The difference between TCP protocol and UDP protocol

Source: Internet
Author: User
Tags ack file transfer protocol

TCP     the difference between protocol and UDP protocol first, let's get this straight. TCP agreements and UCP Agreement and TCP/IP agreement, a lot of people are confused, has always been said TCP/IP Agreement and UDP the difference between the protocols, I think it is not clear from the nature of network communication! the TCP/IP Protocol is a protocol cluster. It includes a lot of protocols. UDP is just one of them. The TCP/IP protocol is named because the TCP,IP protocol is two very important protocols, named after him.

tcp/ip , network layer , network access layer < Span style= "color: #ff0000;" >

< Span style= "color:black;" > The application layer includes: Hypertext Transfer Protocol (http ): Basic protocols for the World Wide Web .    Span style= "color:black;" > file transfer (tftp Simple File Transfer Protocol ):    Telnet (telnet ), providing remote access to other host features, which allows users to log in       host and execute commands on this host .     network management (SNMP Simple Network Management Protocol), which provides methods for monitoring network devices, as well as configuration management, statistical information collection , performance management and security management, etc. .   

< Span style= "color:black;" > < Span style= "color:black;" > second Network layer including internet protocol (IP)       internet Address Resolution Protocol (ARP)      Reverse Address Resolution Protocol (RARP)   

< Span style= "color:black;" > < Span style= "color:black;" > Finally said network access layer: The network access layer is also known as the host-to-network layer (host-to-network). The network access layer's capabilities include the mapping of IP addresses to physical address hardware, and encapsulating the IP into frames. Based on the network interface of different hardware types, the network access layer defines the connection to the physical media. tcp/ip protocol

< Span style= "color:black;" > < Span style= "color:black;" > < Span style= "color:black;" > The following is an emphasis on TCP The difference between the protocol and the UDP protocol.

< Span style= "color:black;" > < Span style= "color:black;" > Span style= "color:black;" >tcp Span style= "color:black;" > is a connection-oriented protocol, which means that a reliable connection must be established with each other before sending or receiving data.

A TCP connection has to go through three times.“Dialogue”In order to build up, the process is very complex, and simply describes the simple process of the three conversations: Host A sends a connection request packet to Host B:“I want to send you the data, OK?”, this is the first conversation; Host B sends a consent connection to host A and requires synchronization (synchronization is the two host one in the sending, one in the receiving, coordinating work) packet:“Yes, when are you going to send it?”, this is the second conversation; Host a then sends a packet to confirm that Host B requires synchronization:“I'll send it now, and you go ahead!”, this is the third dialogue. three times“Dialogue”The purpose is to synchronize the sending and receiving of packets, after three times“Dialogue”After that, host a formally sends data to Host B.In detail, it is:(Part of the article reprinted http://zhangjiangxing-gmail-com.iteye.com, mainly this person explained very in place, indeed very easy to make people understand! )TCPthree-time handshake process1Host A by sending to host B a data segment containing the flag bits of the synchronization sequence number to Host B, to host B to request a connection, through this data segment, host a tells Host B two things: I want to communicate with you, you can use which serial number as the starting data segment to respond to me. 2 when Host B receives a request from host A, it responds to host A with a data segment with an acknowledgment answer (ACK) and a synchronous sequence number (SYN) flag bit, and also tells host a two things: I have received your request, you can transfer the data; which pins XLR serial number you want to use as the starting data segment to respond to my 3 When host a receives this data segment, it sends a confirmation reply confirming that the data segment of Host B has been received: "I have received a reply and I am now going to start transmitting the actual data.So 3 times the handshake is complete, and host A and Host B can transfer the data. 3-time handshake features no application layer of Data SYN This flag bit will only be set when the TCP build connection is set 1 The SYN flag bit is set 0 after the handshake is completed TCP3 handshake to make connection, 4 times for disconnection
1When host a completes the data transfer, the control bit fin 1, the request to stop the TCP connection 2 Host B receives fin response to it, confirm that the side of the TCP connection will be closed, the ACK 1 3 by the B end of the reverse direction of the shutdown request, the fin 1 4 Host a confirms the request to host B, placing the ACK at 1 and closing the two-direction closure. It can be seen from the three handshake and four disconnects of TCP that TCP uses the connection-oriented communication method, which greatly improves the reliability of data communication, so that the transmitting data end and the receiving end have interaction before the formal transmission of the date, which lays a reliable foundation for the formal transmission of data.noun explanationAckTcpOne of the control bits of the header to confirm the data. Confirmation is issued by the destination, using it to tell the sender that the serial number before the data section received. For example, the confirmation number is X, the first X-1 data segment received, only when ack=1, the confirmation number is valid, when ack=0, the confirmation number is invalid, This will require data to be re-transmitted to ensure the integrity of the data.SynSynchronize serial number, TCP establishes this position 1 when connection is establishedFINThe sender completes the send task bit, and when TCP completes the data transfer needs to disconnect, the side that proposes the disconnection will have this position 1TCPthe Baotou structure: Source Port 16-bit destination port 16-bit serial number 32-bit response ordinal 32-bit TCP header length 4-bit reserved 6-bit control Code 6-bit window size 16-bit offset 16-bit check and 16-bit option 32-bit (optional) so we have reached the minimum length of the TCP header, 20 Bytes.
UDP(User data Protocol, Subscriber Datagram Protocol) (1) UDP is a non-connected protocol that transmits data before the source and terminal do not establish a connection, when it wants to transfer the simple to crawl data from the application, and throw it to the network as soon as possible. On the sending side, UDP transmits data at a speed that is limited by the speed of the application-generated data, the ability of the computer, and the transmission bandwidth; At the receiving end, UDP places each message segment in the queue and the application reads a message segment from the queue each time.(2) Because the transfer data does not establish a connection, so there is no need to maintain the connection state, including the sending and receiving status, so a server can simultaneously transmit the same message to multiple clients.(3) The header of the UDP packet is very short, with only 8 bytes, and the extra overhead of 20 byte packets relative to TCP is small.(4) Throughput is not regulated by congestion control algorithms, only the rate of data generated by the application software, the transmission bandwidth, the source side and the performance limit of the terminal host.(5) UDP usagedo your best to deliver,That is, there is no guarantee of reliable delivery, so the host does not need to maintain a complex link state table (which has many parameters).(6) UDP isMessage OrientedOf The sender's UDP message to the application is delivered down to the IP layer after the header is added. Instead of splitting and merging, the boundaries of these messages are preserved, so the application needs to select the appropriate message size.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, and then the other host to confirm the receipt of the packet , if the packet arrives in time for feedback, then the network is a pass. UDP the Baotou structure: Source Port 16-bit destination port 16-bit length 16-bit checksum 16-bit
Summary of the differences between TCP and UDP: 1. based on connection and no connection; 2. Requirements for system resources (TCP more, less UDP), 3.UDP program structure is simple, 4. Flow mode and datagram mode, 5.TCP guarantees data correctness, UDP may drop packets, TCP guarantees data order, UDP is not guaranteed.

The difference between TCP protocol and UDP protocol

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.