Difference between TCP/IP and UDP, tcpudp

Source: Internet
Author: User
Tags file transfer protocol

Difference between TCP/IP and UDP (reprinted), tcpudp

Before analyzing the differences between the two, we should first understand the relationship between the two,

The TCP/IP protocol cluster is a network control protocol. Simply put, it is a network protocol. Computers in our network use this protocol cluster for data communication.
This protocol cluster contains many protocols, such as DNS, HTTP, ARP, ICMP, and UDP.

For details about TCP/IP protocol cluster can refer to: http://blog.chinaunix.net/uid-30077524-id-5074334.html

1. TCP/IP protocol details

TCP/IP protocol sets include the application layer, transport layer, network layer, and network access layer.
The application layer includes:
Hypertext Transfer Protocol (HTTP): the basic protocol for the World Wide Web.
File Transfer (TFTP simple File Transfer Protocol ):
Remote Logon (Telnet) provides the function of Remotely accessing other hosts, which allows users to log on
Internet host, and execute commands on this host.
Network Management (SNMP Simple Network Management Protocol), which provides methods for monitoring network devices, configuration management, statistics collection, performance management, and security management.
Domain Name System (DNS), which is used to convert the domain name and its public network nodes into IP addresses on the internet.
Second, the network layer includes:
Internet Protocol (IP)
Internet Control Information Protocol (ICMP)
Address Resolution Protocol (ARP)
Reverse Address Resolution Protocol (RARP)
Network access layer: the network access layer is also called host-to-network ). the functions of the network access layer include the ing between IP addresses and physical address hardware, and encapsulation of IP addresses into frames. based on Network Interfaces of different hardware types, the network access layer defines the connection to the physical media.

 

2. UDP protocol explanation

 

UDP (User Data Protocol)
(1) UDP is a non-connection protocol. The source end of data transmission does not establish a connection with the terminal. when it wants to transmit data, it simply crawls data from the application, and throw it to the network as quickly as possible. At the sending end, the speed of UDP data transmission is limited only by the speed at which the application generates data, the ability of the computer, and the transmission bandwidth. at the receiving end, UDP puts each message segment in the queue, the application reads a message segment from the queue each time.
(2) Since no connection is established for data transmission, you do not need to maintain the connection status, including the sending and receiving status. Therefore, a server can transmit the same message to multiple clients at the same time.
(3) The title of the UDP information package is very short, with only 8 bytes. The additional overhead of the 20 bytes information package of TCP is very small.
(4) throughput is not adjusted by the congestion control algorithm, but is limited by the data generation rate, transmission bandwidth, source end and terminal host performance of the application software.
(5) UDP uses the best effort to deliver, that is, it does not guarantee reliable delivery, so the host does not need to maintain a complex link status table (there are many parameters ).
(6) UDP is packet oriented. The packet sent by the sender's UDP to the application is delivered to the IP layer after the header is added. Without splitting or merging, the boundary of these packets is retained. Therefore, the application needs to select the appropriate packet size.
We often use the "ping" command to test whether the TCP/IP communication between the two hosts is normal. In fact, the "ping" command is used to send UDP packets to the other host, then, the host of the other party confirms that the packet is received. If the message indicating whether the packet arrives is returned in time, the network is connected.
UDP header structure:
Source Port 16-bit
16-bit destination port
16 characters in length
16-bit checksum


3. Differences Between TCP and UDP


TCP (Transport Control Protocol) is a connection-oriented Protocol, that is, a reliable connection must be established with the other party before sending and receiving data. A TCP connection can be established only after three "conversations". The process is very complex. Only a simple process of the three conversations is described: host A sends A connection request packet to host B: "Can I send you data? ", This is the first conversation; host B sends A packet to host A that agrees to the connection and requires synchronization (synchronization means that two hosts are sending, receiving, and coordinating): "Yes, when will you send it? ", This is the second conversation. host a sends another packet to confirm that host B's request is synchronized: "I will send it now, let's proceed !", This is the third dialogue. The purpose of the three "dialogs" is to synchronize the transmission and receipt of data packets. After the three "dialogs", host A formally sends data to host B.
The details are as follows: (most of the articles are reproduced in the Forum)
TCP three-way handshake process
1. host a sends A data segment containing the flag of the synchronous serial number to host B and requests A connection from host B,
Host A tells host B two things: I want to communicate with you; which serial number can you use as the starting data segment to respond to me.
2. After receiving the request from host A, host B responds to host A with A data segment with the acknowledgment response (ACK) and synchronous serial number (SYN) flag. It also tells host A two things:
I have received your request. You can transmit data. Which region serial number do you want to use as the initial data segment to respond to me?
3. When host A receives the data segment, it sends A confirmation response to confirm that it has received the data segment of host B: "I have received A reply. Now I want to transmit the actual data.
In this way, three handshakes are completed, and data can be transmitted between host A and host B.
Features of three handshakes
No data at the application layer
The SYN flag is set to 1 only when a TCP production connection is established.
The SYN flag is set to 0 after the handshake is complete.

Three handshakes are required for TCP connection establishment and four for TCP disconnection.

1 When host A completes data transmission, set the control bit FIN to 1 and request to stop the TCP Connection
2. Host B responds to FIN after receiving it, confirming that the TCP connection to this party will be closed, and the ACK will be set to 1.
3. the B end then requests a reverse shutdown request to set FIN to 1.
4. host a confirms the request of host B, sets ACK to 1, and closes the request in both directions.
It can be seen from the three-way handshake and four-way disconnection of TCP that TCP uses connection-oriented communication mode, which greatly improves the reliability of data communication and enables the sending data end
It interacts with the acceptor before the formal data transmission, laying a reliable foundation for the formal data transmission.
Glossary
One of the control bits of the ack tcp Header, which confirms that the data is sent by the target end and uses it to tell the Data Segment Before the serial number of the sending end.
All received. for example, if the validation number is X, it indicates that the previous data segment of the X-1 has been received, only when ACK = 1, the validation number is valid, when ACK = 0, the validation number is invalid, in this case, re-transmission of data is required to ensure data integrity.
SYN synchronization serial number. When TCP establishes a connection, set this position to 1.
The FIN sending end completes the sending task bit. When the TCP completes the data transmission, it is proposed that the disconnected party will

TCP Header structure:
Source Port 16-bit
16-bit Target Port
32-bit serial number
Response No. 32-bit
4-digit TCP Header Length
Reserved 6-bit
6-digit control code
Window Size 16 bits
16-bit offset
16-bit checksum
Option 32-bit (optional)
The minimum length of the TCP header is 20 bytes.

4. Differences Between TCP and UDP:

1. TCP connection-oriented (for example, a call requires a dial-up to establish a connection); UDP is connectionless, that is, no connection is required before sending data.

2. TCP provides reliable services. That is to say, the data transmitted through the TCP connection has no errors, no loss, no duplicates, and is delivered in order. UDP tries its best to deliver, that is, reliable delivery is not guaranteed.

3. TCP is oriented to byte streams. In fact, TCP regards data as a series of unstructured byte streams. UDP is oriented to packets.
UDP has no congestion control, so network congestion does not reduce the transmission rate of the source host (useful for real-time applications, such as IP phones and real-time video conferences)
4. Each TCP connection can only be point-to-point. UDP supports one-to-one, one-to-many, multiple-to-one, and many-to-many interactive communication.
5. TCP Header overhead 20 bytes; UDP header overhead is small, only 8 bytes

6. TCP's logical communication channel is a full-duplex reliable channel, while UDP is an unreliable channel.

5. application fields:

1. TCP has a strong vitality in network communication. For example, remote connection (Telnet) and file transmission (FTP) require data of an indefinite length to be reliably transmitted. However, reliable transmission requires a price. The test of the correctness of the data content will inevitably take up the processing time of the computer and the bandwidth of the network. Therefore, the efficiency of TCP transmission is not as high as that of UDP.

2. UDP is easy to operate and requires less monitoring. Therefore, it is usually used for client/server applications in distributed systems with high LAN reliability. For example, a video conferencing system does not require that the audio and video data be absolutely correct. You only need to ensure consistency. In this case, UDP is obviously more reasonable.

Note: This article is from reposted and sorted by yourself. If you have any questions or questions, please join us for discussion and study.

 

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.