Analysis on whether DNS uses the TCP or UDP protocol

Source: Internet
Author: User
Tags domain name server

DNS uses the TCP protocol or UDP protocol. It is recognized that DNS uses both UDP and TCP port 53, this single application protocol uses two transmission protocols at the same time in the TCP/IP stack is also an alternative. However, few people know under what circumstances DNS uses the two Protocols. First, we will briefly introduce TCP and UDP. TCP is a connection-oriented protocol that provides reliable data transmission. This protocol is used when the service quality requirements are high. UDP-User Datagram Protocol (UDP) is a connectionless transport layer protocol that provides a simple and unreliable information transmission service for transactions. The difference between www.2cto.com TCP and UDP:
The main difference between UDP and TCP is that they differ in how to implement reliable information transmission. The TCP protocol includes a special transmission guarantee mechanism. When the data receiver receives the message from the sender, it will automatically send a confirmation message to the sender; the sender continues to transmit other information only after receiving the confirmation message. Otherwise, the sender waits until the confirmation message is received. Unlike TCP, UDP does not provide a data transmission guarantee mechanism. If a data packet is lost during transmission from the sender to the receiver, the Protocol itself cannot detect or prompt. Therefore, UDP is often called an unreliable transmission protocol. Compared with the TCP protocol, another difference between the UDP protocol is how to receive burst data packets. Unlike TCP, UDP does not guarantee the order in which data is sent and received. In fact, this out-of-order nature of UDP is rarely seen. Generally, it can only happen when the network is very crowded.
Since UDP is an unreliable network protocol, what is its value or necessity? In fact, in some cases, UDP may become very useful. Because UDP has a speed advantage beyond the reach of TCP. Although various security protection functions are embedded in the TCP protocol, a large amount of system overhead will be occupied during actual execution, and the speed will undoubtedly be seriously affected. In contrast, UDP eliminates the information reliable transfer mechanism and transfers security and sorting functions to upper-layer applications, greatly reducing the execution time and ensuring the speed. DNS uses the TCP protocol for regional transmission, and UDP protocol for other purposes;
The DNS specification specifies two types of DNS servers, one is the primary DNS server and the other is the secondary DNS server. In a zone, the primary DNS server reads the DNS data from the local data file, while the secondary DNS server reads the DNS data from the primary DNS server. When a secondary DNS server is started, it needs to communicate with the primary DNS server and load data information, which is called zone transfer ). Why both TCP and UDP are used? First, let's take a look at the length limit of TCP and UDP transmission Bytes: the maximum length of UDP packets is 512 bytes, while TCP allows the length of packets to exceed 512 bytes. When the DNS query exceeds 512 bytes, the TC mark of the Protocol is deleted, and then sent over TCP. Generally, traditional UDP packets do not contain more than 512 bytes. TCP is used for transmission in the www.2cto.com region. There are two main considerations: 1. The secondary Domain Name Server regularly queries the Primary Domain Name Server (generally three hours) to check whether the data has changed. If there is any change, a regional transfer will be executed for data synchronization. Area transfer uses TCP instead of UDP, because the amount of data synchronously transmitted is much larger than the amount of data in a request and response. 2. TCP is a reliable connection that ensures data accuracy. Use UDP protocol for domain name resolution:
The client queries the domain name from the DNS server. Generally, the returned content is no more than 512 bytes. Use UDP for transmission. The DNS server has lower load and faster response because it does not have to undergo TCP three-way handshake. Although theoretically, the client can also specify to use TCP when querying the DNS server, in fact, many DNS servers only support UDP Query Packets When configuring.
By benbenxiongyuan

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.