Difference Between TCP and UDP, difference between TCPUDP

Source: Internet
Author: User

Difference Between TCP and UDP, difference between TCPUDP
Difference Between TCP and UDP

Difference Between TCP and UDP

TCP-the transmission control protocol provides connection-oriented and reliable byte stream services. Before the customer and the server exchange data with each other, a TCP connection must be established between the two parties before data can be transmitted. TCP provides timeout resend, discard duplicate data, test data, traffic control, and other functions to ensure data can be transferred from one end to the other.
UDP-the User Datagram Protocol is a simple datagram-oriented transport layer protocol. UDP does not provide reliability. It only sends the data from the application to the IP layer, but it cannot guarantee that the data can reach the destination. Because UDP does not need to establish a connection between the client and the server before transmitting the datagram, and there is no timeout and re-transmission mechanism, the transmission speed is very fast.

Overview

TCP (Transmission Control Protocol) is the most commonly used protocol on the Internet. the reason for this is because TCP offers error correction. when the TCP protocol is used there is a "guaranteed delivery. "This is due largely in part to a method called" flow control. "Flow control determines when data needs to be re-sent, and stops the flow of data until previous packets are successfully transferred. this works because if a packet of data is sent, a collision may occur. when this happens, the client re-requests the packet from the server until the whole packet is complete and is identical to its original.

UDP (User datateprotocol) is anther commonly used Protocol on the Internet. however, UDP is never used to send important data such as webpages, database information, etc; UDP is commonly used for streaming audio and video. streaming media such as Windows Media audio files (. WMA), Real Player (. RM), and others use UDP because it offers speed! The reason UDP is faster than TCP is because there is no form of flow control or error correction. the data sent over the Internet is affected by collisions, and errors will be present. remember that UDP isOnlyConcerned with speed. This is the main reason why streaming media is not high quality.





On the contrary, UDP has been implemented among some trojan horse viruses. hackers develop scripts and trojans to run over UDP in order to mask their activities. UDP packets are also used in DoS (Denial of Service) attacks. it is important to know the difference between TCP port 80 and UDP port 80. if you don't know what ports are go here.

Frame Structure

As data moves along a network, varous attributes are added to the file to createFrame. This process is calledEncapsulation. There are different methods of encapsulation depending on which protocol and topology are being used. as a result, the frame structure of these packets differ as well. the images below show both the TCP and UDP frame structures.

TCP FRAME STRUCTUREUDP FRAME STRUCTURE



ThePayloadField contains the actually data. notice that TCP has a more complex frame structure. this is largely due to the fact the TCP is a connection-oriented protocol. the extra fields are need to ensure the "guaranteed delivery" offered by TCP.

 

UDP 
The main difference between UDP and TCP is that UDP does not necessarily provide reliable data transmission. In fact, this Protocol cannot ensure that the data is accurate to the destination. UDP is very effective in many ways. When a program aims to transmit as much information as possible as soon as possible (where any given data is of relatively low importance), UDP can be used. ICQ short messages use UDP to send messages.
Many programs will use separate TCP connections and separate UDP connections. Important Status information is sent along with reliable TCP connections, while the main data stream is sent over UDP.

TCP

TCP aims to provide reliable data transmission and maintain a virtual connection between devices or services that communicate with each other. TCP is responsible for data recovery when data packets are unordered, lost, or damaged during delivery. It completes the recovery by providing a sequence number for each packet it sends. Remember, each packet is considered as an independent unit at the lower network layer. Therefore, data packets can be sent along completely different paths, even if they are components of the same message. This route is similar to the way the network layer processes segments and reassembles data packets. It is only at a higher level.
To ensure that data is correctly received, TCP requires a confirmation (ACK) when the target computer successfully receives the data ). If the corresponding ACK is not received within a certain time limit, the data packet will be re-transmitted. If the network is congested, this re-transmission will lead to repeated data packets. However, the receiving computer can use the serial number of the data packet to determine whether it is a duplicate data packet and discard it if necessary.

TCP and UDP Selection

If we compare the structure of UDP packets and TCP packets, it is obvious that UDP packets do not have the complex reliability and Control Mechanism of TCP packets. Similar to TCP, UDP supports multiple applications on one host as well as the number of source ports and destination ports. A 16-bit UDP packet contains a Byte Length header and Data Length. The verification code field enables it to perform overall verification. (Many applications only support UDP, such as multimedia data streams, and do not generate any additional data. Even if you know the damaged packets, do not resend them .)
Obviously, when the performance of data transmission must be in the integrity, controllability, and reliability of data transmission, TCP is certainly the choice. UDP is the best choice for audio and multimedia applications that emphasize transmission performance rather than transmission integrity. When the data transmission time is so short that the previous connection process becomes the whole traffic subject, UDP is also a good choice, such as DNS switching. The reason for establishing SNMP on UDP is that the designer believes that when the network is blocked, the low overhead of UDP gives it a better chance to transmit and manage data. The rich functions of TCP sometimes lead to unpredictable low performance, but we believe that in the near future, reliable point-to-point connections of TCP will be used in most network applications.

Related Article

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.