Reproduced TCP vs. UDP

Source: Internet
Author: User
Tags ack

TCP and UDP differences
Tcp Udp
Whether to connect Connection oriented For non-connected
Transmission Reliability Reliable, Not reliable.
Application situations Transfer large amounts of data Small amount of data
Speed Slow Fast
The OSI and TCP/IP models define two transport protocols in the Transport layer: TCP (or Transmission Control Protocol) and UDP (or User Datagram Protocol). UDP
The main difference between UDP and TCP is that UDP does not necessarily provide reliable data transfer. In fact, the agreement does not guarantee that the data will arrive at the destination accurately. UDP is very effective in many ways. UDP can be used when the goal of a program is to transfer as much information as possible, where any given data is of relatively low importance. ICQ Short message sends a message using the UDP protocol.
Many programs will use a separate TCP connection and a separate UDP connection. Important state information is sent with a reliable TCP connection, while the primary traffic is sent over UDP. TCP
The purpose of TCP is to provide reliable data transfer and to maintain a virtual connection between the devices or services that communicate with each other. TCP is responsible for data recovery when packets are received unordered, lost, or destroyed during delivery. It accomplishes this by providing a sequence number for each packet it sends. Remember that the lower network layer treats each packet as a separate unit, so the packets can be sent along a completely different path, even if they are part of the same message. This kind of routing is very similar to the way the network layer handles fragmentation and reassembly of packets, just a higher level.
To ensure that data is received correctly, TCP requires an acknowledgment (that is, an ACK) to be sent back when the destination computer successfully receives the data. If the corresponding ACK is not received within a certain time limit, the packet is re-routed. If the network is congested, this re-transfer will result in duplicate packets being sent. However, the receiving computer can use the sequence number of the packet to determine whether it is a duplicate packet and discard it if necessary. selection of TCP and UDPIf you compare the structure of UDP packets and TCP packets, it is obvious that UDP packets do not have a complex TCP packet reliability and control mechanism。 As with the TCP protocol, the number of source ports and destination ports for UDP also supports multiple applications on a single host. A 16-bit UDP packet contains a byte-long header and the length of the data, and the checksum field makes it possible to verify the whole. (Many applications only support UDP, such as multimedia data streams, without generating any additional data, even if they know that a damaged package is not re-sent.) )
It is clear that the performance of the data transfer must be made in the integrity, control, and reliability, the TCP protocol is of course a choice. When emphasizing transmission performance, not the integrity of the transmission, such as: Audio and multimedia applications, UDP is the best choice. UDP is also a good choice in cases where the data transfer time is so short that the previous connection process becomes the entire flow body, such as: DNS Exchange. Part of the reason that SNMP is built on UDP is that the designer thinks that when network congestion occurs, the lower cost of UDP gives it a better chance to transfer management data. TCP-rich functionality can sometimes lead to unpredictable performance, but we believe that TCP's reliable point-to-point connections will be used for the vast majority of network applications in the near future.the difference between TCP protocol and UDP protocol features is summarized:1. The TCP protocol will give the segment designator when transmitting the data segment; The UDP protocol does not2. TCP protocol is reliable; UDP protocol is unreliable3. The TCP protocol is connection-oriented, and the UDP protocol uses no connection4. TCP protocol with high load, virtual circuit; UDP with no connection5. The sender of the TCP protocol is to confirm that the receiver has received the data segment (3-Time Handshake Protocol)6. TCP Protocol using window technology and flow control

Reproduced TCP vs. UDP

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.