WO2018130061A1 - 域名解析方法、服务器和存储介质 - Google Patents

域名解析方法、服务器和存储介质 Download PDF

Info

Publication number
WO2018130061A1
WO2018130061A1 PCT/CN2017/117904 CN2017117904W WO2018130061A1 WO 2018130061 A1 WO2018130061 A1 WO 2018130061A1 CN 2017117904 W CN2017117904 W CN 2017117904W WO 2018130061 A1 WO2018130061 A1 WO 2018130061A1
Authority
WO
WIPO (PCT)
Prior art keywords
domain name
name resolution
data
packet
request packet
Prior art date
Application number
PCT/CN2017/117904
Other languages
English (en)
French (fr)
Inventor
姜凤波
王海龙
陈方舟
Original Assignee
腾讯科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 腾讯科技(深圳)有限公司 filed Critical 腾讯科技(深圳)有限公司
Priority to KR1020197013202A priority Critical patent/KR102199403B1/ko
Priority to JP2019524972A priority patent/JP6816275B2/ja
Priority to EP17891473.5A priority patent/EP3570512B1/en
Publication of WO2018130061A1 publication Critical patent/WO2018130061A1/zh
Priority to US16/357,082 priority patent/US10826869B2/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/45Network directories; Name-to-address mapping
    • H04L61/4505Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols
    • H04L61/4511Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols using domain name system [DNS]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/25Mapping addresses of the same type
    • H04L61/2503Translation of Internet protocol [IP] addresses
    • H04L61/2546Arrangements for avoiding unnecessary translation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing
    • H04L45/745Address table lookup; Address filtering
    • H04L45/7453Address table lookup; Address filtering using hashing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/25Mapping addresses of the same type
    • H04L61/2503Translation of Internet protocol [IP] addresses
    • H04L61/2521Translation architectures other than single NAT servers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/58Caching of addresses or names
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/22Parsing or analysis of headers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L2101/00Indexing scheme associated with group H04L61/00
    • H04L2101/60Types of network addresses
    • H04L2101/618Details of network addresses
    • H04L2101/622Layer-2 addresses, e.g. medium access control [MAC] addresses
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/10Mapping addresses of different types
    • H04L61/103Mapping addresses of different types across network layers, e.g. resolution of network layer into physical layer addresses or address resolution protocol [ARP]

Definitions

  • the present application relates to the field of computer technologies, and in particular, to a domain name resolution method, a server, and a storage medium.
  • IP address Internet Protocol Address
  • the traditional domain name resolution method parses the layer data protocol of the domain name resolution request packet layer by layer until the IP address corresponding to the domain name requested to be resolved is parsed, and the entire parsing process needs to be performed. Secondary data replication, resulting in inefficient domain name resolution.
  • a domain name resolution method a server, and a storage medium are provided.
  • a method for domain name resolution comprising:
  • the server obtains a domain name resolution request packet
  • the server caches the obtained domain name resolution request packet to the first buffer area
  • the server modifies the header data included in the cached domain name resolution request packet in the first buffer area, and obtains header data of the domain name resolution response packet corresponding to the cached domain name resolution request packet;
  • the server extracts the domain name of the cached domain name resolution request packet and the requested record type
  • the server searches, in the second buffer area, the pre-cached response data corresponding to the extracted domain name and belongs to the extracted record type;
  • the server combines the found response data with the modified domain name resolution request packet to obtain a domain name resolution response packet.
  • a server comprising a memory and a processor, the memory storing computer readable instructions, the computer readable instructions being executed by the processor such that the processor performs the following steps:
  • the obtained response data is combined with the modified domain name resolution request packet to obtain a domain name resolution response packet.
  • One or more non-volatile storage media storing computer readable instructions, when executed by one or more processors, cause one or more processors to perform the following steps:
  • the obtained response data is combined with the modified domain name resolution request packet to obtain a domain name resolution response packet.
  • 1 is an application environment diagram of a domain name resolution method in an embodiment
  • FIG. 2 is a schematic diagram of an internal structure of a server for implementing a domain name resolution method in an embodiment
  • FIG. 3 is a schematic flowchart of a domain name resolution method in an embodiment
  • FIG. 4 is a schematic flowchart of a step of performing a process of acquiring a domain name resolution request packet by using a selected parsing thread in an embodiment
  • FIG. 5 is an internal architecture diagram of a domain name resolution server in an embodiment
  • FIG. 6 is a flow chart showing the steps of modifying the header data included in the cached domain name resolution request packet in the first buffer area in the first buffer area, and obtaining the header data of the domain name resolution response packet corresponding to the cached domain name resolution request packet. ;
  • FIG. 7 is a schematic flowchart of a step of searching for a pre-cached response data corresponding to an extracted domain name and belonging to an extracted record type in a second buffer area in an embodiment
  • FIG. 8 is a schematic flowchart of a step of combining a searched response data with a modified domain name resolution request packet to obtain a domain name resolution response packet in an embodiment
  • FIG. 10 is a logic diagram of a domain name resolution process in an embodiment
  • Figure 11 is a block diagram showing the structure of a server in an embodiment
  • FIG. 12 is a structural block diagram of a server in another embodiment.
  • Figure 13 is a block diagram showing the structure of a server in still another embodiment.
  • FIG. 1 is an application environment diagram of a domain name resolution method in an embodiment.
  • the domain name resolution method is applied to a domain name resolution system.
  • the domain name resolution system includes a terminal 110, a domain name resolution server 120, and an authorized domain name server 130.
  • the terminal 110 is connected to the domain name resolution server 120 through a network, and the domain name resolution server 120 is connected to the authorized domain name server 130 through a network.
  • the terminal 110 may specifically be a desktop terminal or a mobile terminal, and the mobile terminal may specifically be at least one of a mobile phone, a tablet computer, a notebook computer, a smart watch, a personal digital assistant (PDA), and a networkable electronic reader.
  • the domain name resolution server 120 and the authorized domain name server 130 may specifically be independent physical servers or physical server clusters.
  • a server that can be used as the domain name resolution server 120 of FIG. 1 to implement a domain name resolution method.
  • the server includes a processor, memory and network interface connected by a system bus.
  • the memory comprises a non-volatile storage medium and an internal memory.
  • the server's non-volatile storage medium can store operating system and computer readable instructions.
  • the computer readable instructions when executed, may cause the processor to perform a method of domain name resolution.
  • the server's processor is used to provide computing and control capabilities that support the operation of the entire server.
  • Computer readable instructions may be stored in the internal memory of the server, and when the computer readable instructions are executed by the processor, the processor may be caused to perform a domain name resolution method.
  • the network interface of the server is used to communicate with an external terminal through a network connection, such as receiving a domain name solution sent by the terminal. Parse the request packet and return a domain name resolution response packet to the terminal.
  • the server can be implemented with a stand-alone server or a server cluster consisting of multiple servers. It will be understood by those skilled in the art that the structure shown in FIG. 2 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the server to which the solution of the present application is applied.
  • the specific server may include a ratio. More or fewer components are shown in the figures, or some components are combined, or have different component arrangements.
  • a domain name resolution method is provided. This embodiment is applied to the domain name resolution server 120 in FIG. 1 to illustrate. The method specifically includes the following steps:
  • the domain name resolution request packet refers to a data packet used for requesting domain name resolution.
  • a domain name is the name of a computer or group of computers on the Internet consisting of a string of dot-separated strings that identify the electronic orientation of the computer as it is transmitted.
  • Domain name resolution refers to the process of resolving a domain name into a record type pointed to by a domain name resolution request packet. Record types such as addresses point to record type, mail exchange record type, or alias record type.
  • the terminal when the terminal obtains the domain name input by the user and obtains the request for accessing the Internet through the domain name, the terminal may first determine the record type pointed to by the request, and search for the domain name corresponding to the obtained domain name in the local database or the cache. And belongs to the record of the record type pointed to by the request. If it is found, it accesses the Internet according to the record; if not found, the domain name and the record type pointed to by the request are encapsulated according to the format of the domain name resolution request packet, a domain name resolution request packet is generated, and the domain name is parsed. The request packet is sent to the domain name resolution server.
  • the domain name resolution server receives the domain name resolution request packet sent by the terminal, and obtains the domain name resolution request packet.
  • the first buffer area is a cache area that is divided in the cache of the domain name resolution server, and is used to store the obtained domain name resolution request packet.
  • the domain name resolution server receives the data packet through the network card, and after receiving the domain name resolution request packet, the domain name resolution request packet can be cached to the first buffer area by the process.
  • the domain name resolution server can be enabled in the kernel space through the operating system kernel.
  • the NIC driver process obtains the domain name resolution request packet received by the network card, stores the obtained domain name resolution request packet in the first cache area of the kernel space, and waits for the operating system kernel to respond.
  • the domain name resolution server may pre-configure the packet interception process running in the kernel space. After the network card driver process obtains the domain name resolution request packet received by the network card, the domain name resolution process in the domain name resolution server user space may be The packet interception process is enabled, and the domain name resolution request packet obtained by the network card driver process is stored in the first buffer area of the user space, and the domain name resolution process of the user space is responded.
  • the operating system is used to manage computer hardware and software.
  • the area where the operating system kernel is located is the kernel space, and the kernel function module runs in the kernel space.
  • User space is the space that the operating system divides relative to the kernel space.
  • a network card is a network component that operates at the link layer and is used for the transmission and reception of data packets.
  • the NIC driver process is a process in which the operating system kernel calls to execute the data packet received by the network card and send the data packet to the network card.
  • the packet interception process is a pre-configured process for intercepting packets acquired by the NIC driver process into user space.
  • the domain name resolution server can use the DPDK (Data Plane Development Kit) to pre-configure the packet interception process.
  • the configured packet interception process can directly transfer the intercepted data packets to the user space without going through The transit of kernel space, the packet interception process can be enabled by the operating system kernel, or by the domain name resolution process of user space.
  • the domain name parsing data packet usually includes five parts: header data, query question, response, authorization response and additional information.
  • header data is the part that the domain name resolution data packet must include, including the domain name resolution packet identifier, the domain name resolution packet identifier, the number of request problems, the number of resource records, the number of authorized resource records, and the number of additional resource records.
  • the domain name resolution packet identifier is used to identify the domain name resolution packet, and the corresponding domain name resolution request packet and the domain name resolution response packet have the same domain name resolution packet identifier, and can be used to match the domain name resolution response packet corresponding to the domain name resolution request packet.
  • the domain name resolution packet flag defines the domain name resolution packet is please
  • the request or response packet also defines whether other parts besides the header data need to exist, and the type of the query.
  • the number of request questions, the number of resource records, the number of authorized resource records, and the number of additional resource records correspond to the number of four parts of the query question, response, authorization response, and additional information, respectively.
  • the domain name resolution server may first determine the header data of the domain name resolution response packet corresponding to the cached domain name resolution request packet, and determine the header data of the domain name resolution request packet according to the determined domain name resolution response packet header data. The difference data in the header data of the domain name resolution response packet. The domain name resolution server may locate the determined difference data in the first buffer area, and modify the located difference data according to the header data of the domain name resolution response packet.
  • the difference data includes a domain name resolution packet identifier and a resource record number.
  • the received domain name resolution request packet includes a domain name parsing packet flag indicating that the character of the request packet is “0” and should be modified to indicate “1” of the response.
  • the number of resource records is modified according to the number of request questions.
  • the domain name requested by the domain name resolution request packet and the requested record type are encapsulated in the query problem part of the domain name resolution request packet.
  • the domain name resolution server parses the domain name resolution request packet to obtain a parsing result, and extracts the domain name and the requested record type of the domain name resolution request packet request from the parsing result.
  • the requested record type such as the address points to the record type, the mail exchange record type or the alias record type.
  • the address points to the record, that is, the A (Address) record, also known as the IP (Internet Protocol) point, used to specify the record of the host name or the IP address corresponding to the domain name.
  • the mail exchange record that is, the MX (Mail Exchanger) record, is used to locate the mail server according to the address suffix of the addressee when the email system sends the mail, and points the address suffix of the new person to the record of the IP address of the mail server.
  • An alias points to a record record, that is, a CNAME record, also known as an alias record, which maps multiple names or domain names to the same computer.
  • the record includes two domain names or names, and the first domain name points to the record of the second domain name.
  • the second buffer area is a cache area divided in the cache of the domain name resolution server.
  • the pre-packaged response data is stored.
  • the second buffer area and the first buffer area are both cache areas, but are different buffer areas.
  • the domain name resolution server After the domain name resolution server performs domain name resolution, the resolution result is recorded, and the domain name resolution record is stored in the database.
  • the domain name resolution server can establish a connection with the authoritative domain name server to detect whether the domain name resolution record stored locally is consistent with the corresponding domain name resolution record stored in the authoritative domain name server. If they are inconsistent, the corresponding domain name resolution records stored in the authoritative domain name server are synchronized to the local database.
  • the time for performing the detection operation may be a preset detection period, or may be performed when the current time exceeds a buffer period included in the domain name resolution record.
  • the domain name resolution server may encapsulate the domain name resolution record stored in the database according to a preset response format to obtain response data and cache it in the second buffer area, and perform searching when needed.
  • the domain name resolution server may cache the obtained response data into the second buffer area according to the record type to which the response data belongs.
  • the response data set belonging to the extracted record type is determined according to the extracted record type, and then The pre-cached response data corresponding to the extracted domain name is filtered out in the determined response data set.
  • the domain name resolution server may also cache the obtained response data in the second buffer area according to the domain name corresponding to the response data.
  • domain name resolution is required, the response data set corresponding to the extracted domain name is determined according to the extracted domain name, and then the determination is performed.
  • the pre-cached response data belonging to the extracted record type is filtered out in the response data set.
  • the domain name resolution server may also obtain the number of historical records corresponding to the local domain name resolution record, and the obtained response data is arranged in descending order according to the number of historical records corresponding to the domain name resolution record corresponding to the response data, and is cached in the second buffer area.
  • the domain name resolution is required, the pre-cached response data corresponding to the extracted domain name and belonging to the extracted record type is searched.
  • steps S308 to S310 and step S306 can be performed asynchronously.
  • the domain name resolution server may locate the modified domain name resolution request packet cached in the first buffer area, and add the found response data to the data included in the located domain name resolution request packet. At the end, the domain name resolution response packet is obtained by combining with the cached domain name resolution request packet.
  • the domain name resolution request method stores the obtained domain name resolution request packet in the first buffer area, and completes the process of parsing the cached domain name resolution request packet in the first buffer area, and includes the header included in the domain name resolution request packet.
  • the data is modified into the header data of the corresponding domain name resolution response packet, and the found response data is combined with the modified domain name resolution request packet to obtain a domain name resolution response packet.
  • the response data of the search is pre-stored in the second buffer area, and can be directly combined with the modified domain name resolution request packet after being found, which greatly improves the domain name resolution efficiency.
  • the domain name resolution process can be completed in the first buffer area, which effectively reduces the number of data copies, and further improves the domain name resolution efficiency.
  • step S302 specifically includes: when the operating system kernel reads the data packet from the network card receiving queue and delivers the data to the user space, acquiring the data protocol identifier included in the delivered data packet; and when the data protocol identifier indicates the data transmitted
  • the package is a domain name resolution request packet
  • the domain name resolution request packet is obtained.
  • the first buffer area and the second buffer area are in user space.
  • the data protocol identifier refers to the identifier of each layer of the data protocol included in the data packet.
  • the data packet network layer data protocol identifier is TCP (Transmission Control Protocol)/UDP (User Datagram Protocol), and the data packet whose destination port is port 53 in the transport layer is a domain name parsing data packet.
  • the operating system kernel of the domain name resolution server can enable the pre-configured packet interception process, read the data packet from the network card receive queue, and read the data packet and deliver it to the user space.
  • the domain name resolution process of the user space obtains the data protocol identifier included in the delivered data packet, and detects the acquired data protocol identifier according to the identifier of each layer protocol that matches the domain name resolution request packet, and obtains the data protocol identifier and If the identifier of each layer protocol matched by the domain name resolution request packet is consistent, the data packet to be delivered is a domain name resolution request packet, and the domain name resolution process of the user space obtains the domain name resolution request packet.
  • the acquired data protocol identifier and the layer protocol matching the domain name resolution request packet are matched, If the identifiers of the packets are inconsistent, it indicates that the delivered data packet is a non-domain name resolution request packet, and the domain name resolution process of the user space feeds back the delivered data packet to the operating system kernel for response.
  • the data packet determined to be the domain name resolution request packet is directly parsed in the user space, and does not need to undergo a transition of the kernel space, thereby avoiding the problem of requiring data replication multiple times in the kernel space for parsing, and improving The efficiency of domain name resolution.
  • the data packet that is determined to be a non-domain name resolution request packet is fed back to the operating system kernel, and a processing method for the data packet that cannot be analyzed in the user space is provided, and the success rate of the packet analysis is improved.
  • the domain name resolution method further includes: selecting a parsing thread in an idle state in the parallel parsing thread; and performing step S302 to step S312 through the selected parsing thread.
  • the parsing thread refers to a thread used for domain name resolution. Being idle means that the domain name resolution is not performed at the current time. Specifically, in the domain name resolution process of the domain name resolution server, multiple parsing threads are run in parallel, and each parsing thread is independent of each other.
  • the domain name resolution process of the domain name resolution server may enable the network card driver process to obtain the domain name resolution request packet received by the network card, and then select the parsing thread in the idle state to perform the domain name resolution process of the obtained domain name resolution request packet.
  • the domain name resolution process is separately performed by the parsing thread, and does not involve data interaction processing with other threads, thereby avoiding the waiting process of thread interaction processing data, and further improving the domain name parsing efficiency.
  • the first cache area and the second cache area involved in the domain name resolution method are in user space.
  • obtaining a domain name resolution request packet by using the selected parsing thread includes:
  • the operating system kernel reads the data packet from the network card receiving queue and delivers the data to the user space
  • the data protocol identifier included in the delivered data packet is obtained by the selected parsing thread.
  • the operating system kernel of the domain name resolution server can enable the pre-configured packet interception process, read the data packet from the network card receive queue, and read the data packet and deliver it to the user space.
  • the domain name resolution server then obtains the data protocol identifier included in the delivered data packet through the parsing thread of the user space.
  • the selected parsing thread caches the passed packet to the third buffer in user space.
  • the domain name resolution server compares the acquired data protocol identifier with the identifier of each layer protocol that matches the domain name resolution request packet by using a parsing thread of the user space, and the obtained data protocol identifier and the domain name resolution request are obtained in the comparison result.
  • the identifiers of the packets matching the layers are inconsistent, it is determined that the delivered data packet is a non-domain name resolution request packet, and the domain name resolution process of the user space caches the delivered data packet to the third buffer area in the user space.
  • the third buffer area is a cache area divided in the cache of the domain name resolution server, and is used to store a non-domain name resolution request packet delivered to the user space.
  • S406 Read a data packet from the third buffer area by a kernel interaction thread independent of the parallel parsing thread, and feed the read data packet to the operating system kernel for response.
  • the kernel interaction thread is a thread that interacts with the kernel space and is opposed to the existence of the parsing thread.
  • the parsing thread in the user space cannot directly interact with the operating system kernel, so the non-domain name resolution request packet that needs to be fed back to the operating system kernel for response is cached to the third buffer area in the user space.
  • the kernel interaction thread which is independent of the parallel parsing thread that can interact with the operating system kernel, reads the packet from the third buffer and caches the read packet to the buffer area of the kernel space.
  • the kernel space parsing thread parses the data packet buffered in the kernel space buffer and obtains a response packet corresponding to the parsing packet.
  • the non-domain name resolution request packet that cannot be parsed by the domain name resolution process of the user space is fed back to the operating system kernel for response, thereby avoiding the problem that the domain name resolution process of the user space fails to resolve the non-domain name resolution request packet.
  • the domain name resolution method may further include: acquiring the data packet and buffering to the first buffer area; detecting, in the first buffer area, a data protocol identifier included in the data packet; and when the data protocol identifier indicates that the data packet is a domain name When parsing the request packet, step S306 to step S310 are continued. When the data protocol identifier indicates that the delivered data packet is a non-domain name resolution request packet, the buffered data packet is fed back to the operating system kernel for response.
  • the read data packet may be directly buffered to the first buffer area of the user space.
  • the parsing thread in the idle state is selected in the parallel parsing thread in the user space to detect whether the data packet buffered to the first buffer area is a domain name resolution request packet.
  • the step S306 to step S310 are continued by the selected parsing thread.
  • the address pointer of the non-domain name resolution request packet in the first buffer area is cached to the third buffer area by the selected parsing thread.
  • the kernel interaction thread which is independent of the parallel parsing thread, reads the non-domain name resolution request packet from the first buffer area according to the address pointer stored in the third buffer area, and stores it in the buffer area of the kernel space.
  • the operating system kernel responds to the non-domain name resolution request packet stored in the kernel space cache.
  • the pointer is a variable of the computer language used to indicate the memory address.
  • the address pointer of the non-domain name resolution request packet in the second buffer area points to the cache address of the non-domain name resolution request packet in the second buffer area.
  • the non-domain name resolution request packet is, for example, an ARP (Address Resolution Protocol) request packet or an OSPF (Open Shortest Path First) request packet.
  • the data packet is directly cached in the first buffer area, and the domain name parsing operation is directly performed when detecting the domain name resolution request packet, and after detecting the non-domain name resolution request packet, the first buffer area is The non-domain name resolution request packet is fed back to the operating system kernel for response.
  • the number of data copies is further reduced, and the processing method for the data packets that cannot be parsed in the user space is also provided, and the success rate of data packet parsing is improved.
  • FIG. 5 is an internal architecture diagram of a domain name resolution server in an embodiment.
  • the system space of the domain name resolution server is divided into kernel space and user space, and the operating system kernel can enable the packet interception process to read the data packet from the network card receiving queue and deliver it to the user space.
  • the parsing thread in the user space determines that the delivered data packet is a domain name parsing data packet
  • the passed domain name parsing data packet is buffered to the first buffer area; after the determined data packet is a non-domain name parsing data packet, the parsing thread transmits the The non-domain name resolution packet is cached to the third buffer area.
  • the kernel interaction thread in the user space independent of the parsing thread caches the non-domain name parsing data buffer cached in the third buffer area to the buffer area of the kernel space, and is responded by the operating system kernel.
  • step S306 specifically includes the following steps:
  • S602. Determine a first address pointer of the domain name resolution request packet buffered in the first buffer area.
  • the domain name resolution server may save the first address pointer of the domain name resolution request packet to a temporary cache file or a log file, and the domain name resolution request packet needs to be performed. Read again when the data is modified.
  • S604. Determine an address pointer offset of the data to be modified in the domain name resolution request packet cached in the first buffer area.
  • the data to be modified is data that is different in the header data of the domain name resolution request packet and the corresponding domain name resolution response packet.
  • the domain name resolution server may first determine the header data of the domain name resolution response packet corresponding to the cached domain name resolution request packet, and determine the header data of the domain name resolution request packet according to the determined domain name resolution response packet header data.
  • the domain name parses the difference data in the header data of the response packet, and uses the determined difference data as the data to be modified.
  • the data encapsulated in the header data of the domain name resolution packet is usually subjected to a determined byte division.
  • the first byte and the second byte of the header data of the domain name parsing data packet are the domain name parsing data packet identifier; the third byte and the fourth byte are the domain name parsing data packet identifier, and the domain name parsing data packet flag character segment
  • the first bit is a flag bit, "0" indicates a domain name resolution request packet, and "1" indicates a domain name resolution response packet.
  • the domain name resolution server may determine the address pointer offset of the data to be modified according to the byte in which the determined difference data is located.
  • the data to be modified is located in the first buffer area according to the first address pointer and the address pointer offset.
  • the address pointer offset of the data to be modified is added to the first address pointer of the domain name resolution request packet to obtain an address pointer of the data to be modified, and the domain name resolution server may determine, according to the obtained address pointer, that the first buffer area is to be modified.
  • the cache address of the data is added to the first address pointer of the domain name resolution request packet to obtain an address pointer of the data to be modified, and the domain name resolution server may determine, according to the obtained address pointer, that the first buffer area is to be modified.
  • S608 Modify the located data to be modified into data corresponding to the data to be modified in the domain name resolution response packet.
  • the domain name resolution server writes the header data of the domain name resolution response packet corresponding to the domain name resolution request packet on the cache address of the data to be modified in the determined first buffer area. For example, a flag indicating a packet type is modified from a flag indicating a request packet to a flag indicating a response packet.
  • the domain name resolution request packet header data is directly modified into the header data of the domain name resolution response packet corresponding to the domain name resolution request packet in the first buffer area of the cache domain name resolution request packet, thereby avoiding the parsing process.
  • the cumbersome steps of real-time encapsulation of the domain name resolution response packet are required, which reduces the response time and further improves the efficiency of domain name resolution.
  • step S310 specifically includes the following steps:
  • the hash value is a fixed-length smaller binary value obtained by mapping a binary value of an arbitrary length by using a hash algorithm.
  • the domain name resolution server may calculate a hash value mapped by the extracted domain name according to a preset hash algorithm.
  • the hash table is a list for storing the cache address of the response data corresponding to the domain name and the domain name according to the mapping relationship between the domain name and the hash value.
  • the hash value is the storage location in the hash table.
  • the domain name and the response data corresponding to the domain name are stored in the storage location of the hash value mapped by the domain name.
  • a linked list is a chained storage structure for storing multiple data elements. In this embodiment, the linked list refers to a sub-list pointed to by the same hash value of the domain name with the same hash value of the storage map.
  • the domain name resolution server may previously establish a plurality of hash tables according to the record type requested by the domain name resolution request packet, and each hash table correspondingly stores the cache address of the response data belonging to the same record type and the corresponding domain name.
  • a linked list pointed to by the hash value is determined in a hash table corresponding to the extracted request type.
  • the domain name resolution server may also store the cache address of the response data corresponding to the corresponding domain name and the associated record type into a hash table, and determine the linked list pointed to by the hash value in the hash table.
  • Each element stored in the linked list is called a node, and each node includes two parts: a data field in which the data element is stored and a pointer field in which the address of the next node is stored.
  • the domain name resolution server may be associated with the node in the determined linked list according to the extracted domain name.
  • the domain name stored in the data domain is compared.
  • the node is determined to be a node to be searched.
  • the linked list for searching belongs to a hash table corresponding to the extracted request type.
  • the domain name resolution server stores the cached address of the response data corresponding to the corresponding domain name and the associated record type to a hash table
  • the domain name resolution server stores the domain name in the determined linked list and the data field of the node one by one according to the extracted domain name.
  • the record type stored in the data field of the node is compared one by one in the determined linked list, and when the record type stored in the node is consistent with the extracted record type, it is determined. This node is the node that needs to be found.
  • the domain name resolution server may read the cached data from the cache address in the second buffer area, and the read cached data is pre-cached response data.
  • the cache address of the response data is searched in the hash table, and then the response data is read in the cache according to the found address, thereby avoiding the problem that it is a waste of time to directly search for the corresponding response data in the cache.
  • the earth has improved the search rate and further improved the efficiency of domain name resolution.
  • the domain name resolution server does not find the corresponding response data in the hash table
  • the primary domain name corresponding to the extracted domain name is determined, and the hash table is searched for the corresponding primary domain name, and belongs to the domain name start record.
  • Type of response data The domain name adopts a hierarchical structure, and is hierarchical according to a geographic domain or an institutional domain, and the respective levels are separated by a decimal point, and the highest domain segment and the second highest domain segment are sequentially from right to left, and the leftmost field is a primary domain name.
  • the requested domain name is www.xx.com and its primary domain name is xx.com.
  • the domain name start record indicates the authorized domain name server corresponding to the primary domain name.
  • a processing method for not obtaining the response data corresponding to the domain name and the requested record type requested by the domain name resolution request packet, and the domain name start record is fed back, so that the domain name resolution requesting party can
  • the domain name start record sends a domain name resolution request to the authorized domain name server, which improves the success rate of domain name resolution.
  • step S312 specifically includes the following steps:
  • the domain name resolution server may save the first address pointer of the domain name resolution request packet to a temporary cache file or a log file, and the domain name resolution request packet needs to be performed. Read again when the data is modified. The domain name resolution request packet does not change after the modification.
  • the domain name resolution server may detect the total amount of data of the modified domain name resolution request packet, and determine the cache address interval occupied by the modified domain name resolution request packet in the first buffer area according to the detected total quantity, and then according to the The size of the address range determines the address pointer offset.
  • the domain name resolution server may add an address pointer offset to the first address pointer of the response data on the first address pointer of the modified domain name resolution request packet.
  • S808 Cache the response data to the first buffer area according to the first address pointer of the response data, and obtain a domain name resolution response packet that is cached in the first buffer area and includes the modified domain name resolution request packet and the cached response data.
  • the first address pointer of the determined response data is the next cache address of the cache address of the last byte of the data included in the modified domain name resolution request packet. Cache the response data according to the determined address pointer to the first buffer area to obtain a domain name resolution response packet cached in the first buffer area and including the modified domain name resolution request packet and the cached response data.
  • the domain name resolution process is performed in the first buffer area from the domain name resolution request packet and the domain name resolution response packet, and only the response data found in the second buffer area is copied to the domain name in the cache area.
  • the domain name resolution response packet can be obtained by combining with the domain name resolution request packet, thereby improving the efficiency of domain name resolution.
  • a domain name resolution method is provided, and the method specifically includes the following steps:
  • S906 Determine, according to the obtained data protocol identifier, whether the delivered data packet is a domain name resolution request packet; if yes, go to step S908; if no, go to step S910.
  • the selected parsing thread caches the delivered data packet to a third buffer area in the user space, and reads the data packet from the third buffer area through a kernel interaction thread independent of the parallel parsing thread, and reads the data packet.
  • the packet is fed back to the operating system kernel for response.
  • the obtained domain name resolution request packet is cached to a first buffer area in the user space.
  • S914. Determine, by the selected parsing thread, a first address pointer of the domain name resolution request packet cached in the first buffer area. Determining an address pointer offset of the data to be modified in the domain name resolution request packet cached in the first buffer area; the data to be modified is data in the header data of the domain name resolution request packet and the corresponding domain name resolution response packet. The data to be modified is located in the first buffer area according to the first address pointer and the address pointer offset. The located data to be modified is modified into data corresponding to the data to be modified in the domain name resolution response packet.
  • S916 Extract the domain name and the requested record type of the cached domain name resolution request packet request by the selected parsing thread.
  • step S918 detecting whether the current time exceeds the buffer period included in the response data; if not, the process proceeds to step S920, and if yes, the process proceeds to step S922.
  • the cache deadline refers to the validity period of the response data.
  • the results of the domain name resolution that belong to each record type are not fixed.
  • the current time exceeds the buffer period included in the response data, it is necessary to detect whether the domain name resolution record encapsulated as the response data has changed. Resets the cache period included in the response data when the domain name resolution record has not changed.
  • the domain name resolution server may establish a connection with the authoritative domain name server to detect whether the locally stored domain name resolution record is consistent with the corresponding domain name resolution record stored in the authoritative domain name server. If the information is inconsistent, the local domain name resolution record is updated according to the corresponding domain name resolution record stored in the authoritative domain name server, and the updated domain name resolution record is encapsulated into the updated response data according to the preset response format, and the second cache area is pre-cached. The response data is replaced with the updated response data.
  • the obtained domain name resolution request packet is stored in the first buffer area in the user space, and the parsing process of the cached domain name resolution request packet is completed in the first buffer area by a separate parsing thread to avoid The thread waits for the data to process the waiting process, which improves the data processing efficiency.
  • the acknowledgment data is pre-stored in the second buffer area in the user space, and can be directly combined with the modified domain name resolution request packet after being found, which greatly improves the domain name resolution efficiency.
  • the data required in the domain name resolution process is stored in the buffer area of the user space, and does not need to be read from the disk, which greatly improves the data processing speed. After the response data is copied from the second buffer area to the first buffer area, the domain name resolution process can be completed in the first buffer area, which effectively reduces the number of data copies, and further improves the domain name resolution efficiency.
  • Figure 10 is a logic diagram of a domain name resolution process in one embodiment.
  • the system space of the domain name resolution server is divided into kernel space and user space, and the operating system kernel can enable the packet interception process to deliver the data packet read by the network card driver process to the user space.
  • Domain name resolution server Caching the domain name resolution data packet to the first buffer area in the user space, and searching for the response data corresponding to the domain name requested by the domain name resolution data packet in the second buffer area in the user space, and belonging to the requested record type, The obtained response data is stored at the end of the domain name resolution request packet in the first buffer area, and the header data of the domain name resolution request packet is modified to obtain a domain name resolution response packet.
  • the non-domain name resolution response packet is fed back to the operating system kernel response.
  • the various steps in the various embodiments of the present application are not necessarily performed in the order indicated by the steps. Except as explicitly stated herein, the execution of these steps is not strictly limited, and the steps may be performed in other orders. Moreover, at least some of the steps in the embodiments may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be executed at different times, and the execution of these sub-steps or stages The order is also not necessarily sequential, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of the other steps.
  • a server 1100 is provided.
  • the internal structure of the server 1100 can be referred to the structure shown in FIG. 2.
  • Each of the modules described below can be implemented in whole or in part by software, hardware, or a combination thereof.
  • the server 1100 includes an acquisition module 1101, a modification module 1102, an extraction module 1103, a lookup module 1104, and a combination module 1105.
  • the obtaining module 1101 is configured to obtain a domain name resolution request packet, and cache the obtained domain name resolution request packet to the first buffer area.
  • the modifying module 1102 is configured to modify the header data included in the cached domain name resolution request packet in the first buffer area, and obtain the header data of the domain name resolution response packet corresponding to the cached domain name resolution request packet.
  • the extracting module 1103 is configured to extract a domain name that is requested by the cached domain name resolution request packet and a record type of the request.
  • the searching module 1104 is configured to search, in the second buffer area, the pre-cached response data corresponding to the extracted domain name and belonging to the extracted record type.
  • the combination module 1105 is configured to combine the found response data with the modified domain name resolution request packet to obtain a domain name resolution response packet.
  • the server 1100 stores the obtained domain name resolution request packet in the first buffer area, and completes the process of parsing the cached domain name resolution request packet in the first buffer area, and the header data included in the domain name resolution request packet is Modify the header data of the corresponding domain name resolution response packet, and then combine the found response data with the modified domain name resolution request packet to obtain a domain name resolution response packet.
  • the response data of the search is pre-stored in the second buffer area, and can be directly combined with the modified domain name resolution request packet after being found, which greatly improves the domain name resolution efficiency.
  • the domain name resolution process can be completed in the first buffer area, which effectively reduces the number of data copies, and further improves the domain name resolution efficiency.
  • the obtaining apparatus 1101 is further configured to: when the operating system kernel reads the data packet from the network card receiving queue and delivers the data to the user space, acquire the data protocol identifier included in the delivered data packet; when the data protocol identifier indicates the delivery When the data packet is a domain name resolution request packet, the domain name resolution request packet is obtained.
  • the first buffer area and the second buffer area are in user space.
  • the data packet determined to be the domain name resolution request packet is directly parsed in the user space, and does not need to undergo a transition of the kernel space, thereby avoiding the problem of requiring multiple process data replication in the kernel space for parsing, and improving The efficiency of domain name resolution.
  • the packet that is determined to be a non-domain name resolution request packet is fed back to the operating system kernel, and the processing method for the data packet that cannot be parsed in the user space is provided, and the success rate of the packet parsing is improved.
  • the modifying module 1102 is further configured to determine a first address pointer of the domain name resolution request packet buffered in the first buffer area, and determine an address pointer offset of the data to be modified in the domain name resolution request packet cached in the first buffer area.
  • the data to be modified is the data of the difference between the header data of the domain name resolution request packet and the corresponding domain name resolution response packet; the data to be modified is located in the first buffer area according to the offset of the first address pointer and the address pointer;
  • the data to be modified is modified into data corresponding to the data to be modified in the domain name resolution response packet.
  • the domain name resolution request packet header data is directly modified into the header data of the domain name resolution response packet corresponding to the domain name resolution request packet in the first buffer area of the cache domain name resolution request packet, thereby avoiding the parsing process.
  • the cumbersome steps of real-time encapsulation of the domain name resolution response packet are required, which reduces the response time and further improves the efficiency of domain name resolution.
  • the searching module 1104 is further configured to obtain a hash value mapped by the extracted domain name; determine a linked list pointed to by the hash value in the hash table; and look up the extracted domain name in the linked list and the extracted record a node corresponding to the type; extracting a cache address of the response data from the found node; and reading the corresponding pre-cached response data from the second buffer area according to the cache address.
  • the cache address of the response data is searched in the hash table, and then the response data is read in the cache according to the found address, thereby avoiding the problem that it is a waste of time to directly search for the corresponding response data in the cache.
  • the earth has improved the search rate and further improved the efficiency of domain name resolution.
  • the combining module 1105 is further configured to obtain a first address pointer of the modified domain name resolution request packet in the first buffer area, and obtain an address pointer offset corresponding to the total data amount of the modified domain name resolution request packet. Determining a first address pointer of the response data according to the first address pointer and the address pointer offset of the modified domain name resolution request packet; buffering the response data to the first buffer area according to the first address pointer of the response data, and obtaining the cached first
  • the cache area includes a modified domain name resolution request packet and a cached response data domain name resolution response packet.
  • the domain name resolution process is performed in the first buffer area from the domain name resolution request packet and the domain name resolution response packet, and only the response data found in the second buffer area is copied to the domain name in the cache area.
  • the domain name resolution response packet can be obtained by combining with the domain name resolution request packet, thereby improving the efficiency of domain name resolution.
  • FIG. 12 is a structural block diagram of a server 1100 in another embodiment. Referring to FIG. 12, the server 1100 further includes a pre-caching module 1106.
  • the pre-caching module 1106 is configured to: if the current time exceeds the buffering period included in the response data, update the domain name resolution record; encapsulate the updated domain name resolution record into the updated response data according to the preset response format; The cached response data is replaced with the updated response data.
  • the response data is obtained by encapsulating the domain name resolution record according to a preset response format.
  • the obtained domain name resolution request packet is stored in the first buffer area in the user space, and the parsing process of the cached domain name resolution request packet is completed in the first buffer area by a separate parsing thread to avoid The thread waits for the data to process the waiting process, which improves the data processing efficiency.
  • the acknowledgment data of the lookup is pre-stored in the second buffer area in the user space, and can be straight after being found.
  • the combination of the modified domain name resolution request packet greatly improves the efficiency of domain name resolution.
  • the data required in the domain name resolution process is stored in the buffer area of the user space, and does not need to be read from the disk, which greatly improves the data processing speed. After the response data is copied from the second buffer area to the first buffer area, the domain name resolution process can be completed in the first buffer area, which effectively reduces the number of data copies, and further improves the domain name resolution efficiency.
  • a server 1300 is provided.
  • the internal structure of the server 1300 can be referred to the structure shown in FIG. 2.
  • Each of the modules described below can be implemented in whole or in part by software, hardware, or a combination thereof.
  • the server 1300 includes a selection module 1301, an acquisition module 1302, a modification module 1303, an extraction module 1304, a lookup module 1305, and a combination module 1306.
  • the selecting module 1301 is configured to select a parsing thread in an idle state among parallel parsing threads.
  • the obtaining module 1302 is configured to obtain a domain name resolution request packet by using the selected parsing thread, and cache the obtained domain name resolution request packet to the first buffer area.
  • the modifying module 1303 is configured to modify, by using the selected parsing thread, the header data included in the cached domain name resolution request packet in the first buffer area, to obtain the header data of the domain name resolution response packet corresponding to the cached domain name resolution request packet.
  • the extracting module 1304 is configured to extract, by the selected parsing thread, the domain name that is parsed by the cached domain name resolution request packet and the requested record type.
  • the searching module 1305 is configured to search, in the second buffer area, the pre-cached response data corresponding to the extracted domain name by the selected parsing thread and belonging to the extracted record type.
  • the combination module 1306 is configured to combine the found response data with the modified domain name resolution request packet by using the selected parsing thread to obtain a domain name resolution response packet.
  • the domain name resolution process is separately performed by the parsing thread, and does not involve data interaction processing with other threads, thereby avoiding the waiting process of thread interaction processing data, and further improving the domain name parsing efficiency.
  • the obtaining module 1302 is further configured to: when the operating system kernel reads the data packet from the network card receiving queue and delivers the data to the user space, acquires the delivered data packet by using the selected parsing thread.
  • the data protocol identifier included in the data protocol identifier when the data protocol identifier indicates that the delivered data packet is a non-domain name resolution request packet, the data packet delivered by the selected parsing thread is cached to the third buffer area in the user space;
  • the kernel interaction thread that parses the thread reads the packet from the third buffer and feeds the read packet back to the operating system kernel for response.
  • the first buffer area and the second buffer area are in user space.
  • the non-domain name resolution request packet that cannot be parsed by the domain name resolution process of the user space is fed back to the operating system kernel for response, thereby avoiding the problem that the domain name resolution process of the user space fails to resolve the non-domain name resolution request packet.
  • Non-volatile memory can include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
  • Volatile memory can include random access memory (RAM) or external cache memory.
  • RAM is available in a variety of formats, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronization chain.
  • SRAM static RAM
  • DRAM dynamic RAM
  • SDRAM synchronous DRAM
  • DDRSDRAM double data rate SDRAM
  • ESDRAM enhanced SDRAM
  • Synchlink DRAM SLDRAM
  • Memory Bus Radbus
  • RDRAM Direct RAM
  • DRAM Direct Memory Bus Dynamic RAM
  • RDRAM Memory Bus Dynamic RAM

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

一种域名解析方法,包括:获取域名解析请求包;将获取的所述域名解析请求包缓存至第一缓存区;在所述第一缓存区中修改缓存的所述域名解析请求包所包括的头部数据,得到与缓存的所述域名解析请求包相应的域名解析应答包的头部数据;提取缓存的所述域名解析请求包请求解析的域名以及请求的记录类型;在第二缓存区中查找与提取的所述域名对应,且属于提取的所述记录类型的预缓存的应答数据;将查找到的所述应答数据与修改后的所述域名解析请求包组合,得到域名解析应答包。

Description

域名解析方法、服务器和存储介质
本申请要求于2017年01月11日提交中国专利局,申请号为2017100211114,申请名称为“域名解析方法和装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机技术领域,特别是涉及一种域名解析方法、服务器和存储介质。
背景技术
随着计算机技术的发展,通过计算机使用互联网来获取信息越来越普遍。用户在使用互联网获取信息时,需要互联网协议地址(Internet Protocol Address,IP地址),而直接使用IP地址非常不便。传统技术建立了域名和IP地址的映射关系,在获取用户请求解析的域名后,根据获取的域名解析得到与该域名存在映射关系的IP地址,再根据该IP地址接入互联网。
然而,传统的域名解析方式在获取到域名解析请求包后,根据该域名解析请求包的各层数据协议逐层进行解析直至解析得到与请求解析的域名对应的IP地址,整个解析过程需要进行多次数据复制,从而导致域名解析效率低。
发明内容
根据本申请提供的各种实施例,提供一种域名解析方法、服务器和存储介质。
一种域名解析方法,包括:
服务器获取域名解析请求包;
所述服务器将获取的所述域名解析请求包缓存至第一缓存区;
所述服务器在所述第一缓存区中修改缓存的所述域名解析请求包所包括的头部数据,得到与缓存的所述域名解析请求包相应的域名解析应答包的头部数据;
所述服务器提取缓存的所述域名解析请求包请求解析的域名以及请求的记录类型;
所述服务器在第二缓存区中查找与提取的所述域名对应,且属于提取的所述记录类型的预缓存的应答数据;及
所述服务器将查找到的所述应答数据与修改后的所述域名解析请求包组合,得到域名解析应答包。
一种服务器,包括存储器和处理器,所述存储器中存储有计算机可读指令,所述计算机可读指令被所述处理器执行时,使得所述处理器执行以下步骤:
获取域名解析请求包;
将获取的所述域名解析请求包缓存至第一缓存区;
在所述第一缓存区中修改缓存的所述域名解析请求包所包括的头部数据,得到与缓存的所述域名解析请求包相应的域名解析应答包的头部数据;
提取缓存的所述域名解析请求包请求解析的域名以及请求的记录类型;
在第二缓存区中查找与提取的所述域名对应,且属于提取的所述记录类型的预缓存的应答数据;及
将查找到的所述应答数据与修改后的所述域名解析请求包组合,得到域名解析应答包。
一个或多个存储有计算机可读指令的非易失性存储介质,所述计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行以下步骤:
获取域名解析请求包;
将获取的所述域名解析请求包缓存至第一缓存区;
在所述第一缓存区中修改缓存的所述域名解析请求包所包括的头部数据,得到与缓存的所述域名解析请求包相应的域名解析应答包的头部数据;
提取缓存的所述域名解析请求包请求解析的域名以及请求的记录类型;
在第二缓存区中查找与提取的所述域名对应,且属于提取的所述记录类型的预缓存的应答数据;及
将查找到的所述应答数据与修改后的所述域名解析请求包组合,得到域名解析应答包。
本申请的一个或多个实施例的细节在下面的附图和描述中提出。本申请的其它特征、目的和优点将从说明书、附图以及权利要求书变得明显。
附图说明
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为一个实施例中域名解析方法的应用环境图;
图2为一个实施例中用于实现域名解析方法的服务器的内部结构示意图;
图3为一个实施例中域名解析方法的流程示意图;
图4为一个实施例中通过选择的解析线程执行获取域名解析请求包的步骤的流程示意图;
图5为一个实施例中域名解析服务器内部架构图;
图6为一个实施例中在第一缓存区中修改缓存的域名解析请求包所包括的头部数据,得到与缓存的域名解析请求包相应的域名解析应答包的头部数据的步骤的流程示意图;
图7为一个实施例中在第二缓存区中查找与提取的域名对应,且属于提取的记录类型的预缓存的应答数据的步骤的流程示意图;
图8为一个实施例中将查找到的应答数据与修改后的域名解析请求包组合,得到域名解析应答包的步骤的流程示意图;
图9为另一个实施例中域名解析方法的流程示意图;
图10为一个实施例中域名解析过程的逻辑图;
图11为一个实施例中服务器的结构框图;
图12为另一个实施例中服务器的结构框图;及
图13为又一个实施例中服务器的结构框图。
具体实施方式
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
图1为一个实施例中域名解析方法的应用环境图。参照图1,该域名解析方法应用于域名解析系统。域名解析系统包括终端110、域名解析服务器120和授权域名服务器130,终端110通过网络与域名解析服务器120连接,域名解析服务器120通过网络与授权域名服务器130连接。终端110具体可以是台式终端或移动终端,移动终端具体可以手机、平板电脑、笔记本电脑、智能手表、个人数字助理(PDA)和可联网电子阅读器等中的至少一种。域名解析服务器120和授权域名服务器130具体可以是独立的物理服务器,也可以是物理服务器集群。
如图2所示,在一个实施例中,提供一种服务器,该服务器可用作图1中的域名解析服务器120以实施一种域名解析方法。参考图2,该服务器包括通过系统总线连接的处理器、存储器和网络接口。其中,存储器包括非易失性存储介质和内存储器。该服务器的非易失性存储介质可存储操作系统和计算机可读指令。该计算机可读指令被执行时,可使得处理器执行一种域名解析方法。该服务器的处理器用于提供计算和控制能力,支撑整个服务器的运行。该服务器的内存储器中可储存有计算机可读指令,该计算机可读指令被所述处理器执行时,可使得所述处理器执行一种域名解析方法。该服务器的网络接口用于据以与外部的终端通过网络连接通信,比如接收终端发送的域名解 析请求包以及向终端返回域名解析应答包等。服务器可以用独立的服务器或者是多个服务器组成的服务器集群来实现。本领域技术人员可以理解,图2中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的服务器的限定,具体的服务器可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。
如图3所示,在一个实施例中,提供了一种域名解析方法,本实施例以该方法应用于上述图1中的域名解析服务器120来举例说明。该方法具体包括如下步骤:
S302,获取域名解析请求包。
其中,域名解析请求包是指用于请求进行域名解析的数据包。域名是由一串用点分隔的字符串组成的互联网上计算机或计算机组的名称,用于在数据传输时标识计算机的电子方位。域名解析是指将域名解析为域名解析请求包中指向的记录类型的过程。记录类型比如地址指向记录类型、邮件交换记录类型或别名记录类型等。
具体地,终端在获取用户输入的域名,并获取通过该域名接入互联网的请求时,可先确定该请求所指向的记录类型,并在本地的数据库或者缓存中查找与该获取的域名对应,且属于该请求所指向的记录类型的记录。若查找到,则根据该记录接入互联网;若未查找到,则按照域名解析请求包的格式将获取的域名和请求所指向的记录类型进行封装,生成域名解析请求包,并将该域名解析请求包发送至域名解析服务器。域名解析服务器接收终端发送的域名解析请求包,获取到域名解析请求包。
S304,将获取的域名解析请求包缓存至第一缓存区。
其中,第一缓存区是在域名解析服务器的缓存中划分出的缓存区域,用于存储获取到的域名解析请求包。具体地,域名解析服务器通过网卡接收数据包,在接收到域名解析请求包后,可通过进程将接收到的域名解析请求包缓存至第一缓存区。
在一个实施例中,域名解析服务器可通过操作系统内核在内核空间启用 网卡驱动进程,获取网卡接收到的域名解析请求包,将获取的域名解析请求包存储在内核空间的第一缓存区中,等待操作系统内核进行响应。
在一个实施例中,域名解析服务器也可预先配置运行在内核空间中的数据包截取进程,在网卡驱动进程获取网卡接收到的域名解析请求包后,域名解析服务器用户空间中的域名解析进程可启用该数据包截取进程,通过该数据包截取进程将网卡驱动进程获取的域名解析请求包存储至用户空间的第一缓存区中,等待用户空间的域名解析进程进行响应。
其中,操作系统用于管理计算机硬件与软件,操作系统内核所在的区域为内核空间,内核功能模块运行在内核空间。用户空间是操作系统划分的相对于内核空间的空间。网卡是工作在链路层的网络组件,用于数据包的发送和接收。网卡驱动进程是操作系统内核调用来执行获取网卡接收的数据包和发送数据包至网卡的进程。数据包截取进程是预先配置的用于将网卡驱动进程获取的数据包截取到用户空间的进程。比如,域名解析服务器可利用DPDK(Data Plane Development Kit数据平面开发工具集)预先配置数据包截取进程,配置的数据包截取进程可以实现将截取的数据包直接存储传递到用户空间,不需进过内核空间的中转,该数据包截取进程可由操作系统内核启用,也可由用户空间的域名解析进程启用。
S306,在第一缓存区中修改缓存的域名解析请求包所包括的头部数据,得到与缓存的域名解析请求包相应的域名解析应答包的头部数据。
其中,域名解析数据包通常包括头部数据、查询问题、应答、授权应答和附加信息五个部分。通常情形下,域名解析请求包和域名解析应答包都采用上述五部分的数据包格式。头部数据是域名解析数据包必须包括的部分,包括域名解析数据包标识、域名解析数据包标志、请求问题数、资源记录数、授权资源记录数和额外资源记录数。
域名解析数据包标识用来标识域名解析数据包,相应的域名解析请求包和域名解析应答包的域名解析数据包标识相同,可用来匹配与域名解析请求包相应的域名解析应答包。域名解析数据包标志定义了域名解析数据包是请 求包还是应答包,也定义了除头部数据外的其他部分是否需要存在,以及查询的类型。请求问题数、资源记录数、授权资源记录数和额外资源记录数分别对应查询问题、应答、授权应答和附加信息四个部分的数量。
具体地,域名解析服务器可先确定与缓存的域名解析请求包对应的域名解析应答包的头部数据,根据确定的域名解析应答包的头部数据,确定域名解析请求包的头部数据中与域名解析应答包的头部数据中的差异数据。域名解析服务器可在第一缓存区中定位确定的差异数据,对定位的差异数据按照域名解析应答包的头部数据进行修改。
其中,差异数据包括域名解析数据包标志和资源记录数。比如,接收到的域名解析请求包所包括的域名解析数据包标志中表示请求包的字符为“0”,应当修改为表示应答的“1”。资源记录数根据请求问题数相应修改。
S308,提取缓存的域名解析请求包请求解析的域名以及请求的记录类型。
具体地,在域名解析请求包的查询问题部分封装了域名解析请求包所请求的域名以及请求的记录类型。域名解析服务器可在获取到域名解析请求包后,对域名解析请求包进行解析得到解析结果,从解析结果提取域名解析请求包请求解析的域名以及请求的记录类型。
其中,请求的记录类型比如地址指向记录类型、邮件交换记录类型或者别名记录类型等。地址指向记录,即A(Address)记录,又称IP(Internet Protocol)指向,用来指定主机名或域名对应的IP地址的记录。邮件交换记录,即MX(Mail Exchanger)记录,用于电子邮件系统发邮件时根据收信人的地址后缀来定位邮件服务器,将收新人的地址后缀指向邮件服务器的IP地址的记录。别名指向记录记录,即CNAME记录,又称别名记录,这种记录将多个名字或域名映射到同一台计算机,记录中包括两个域名或名字,将第一域名指向第二域名的记录。
S310,在第二缓存区中查找与提取的域名对应,且属于提取的记录类型的预缓存的应答数据。
其中,第二缓存区是在域名解析服务器的缓存中划分出的缓存区域,用 于存储预先封装完成的应答数据。第二缓存区与前述第一缓存区都是缓存区,但为不同的缓存区。
域名解析服务器可每次进行域名解析后,将解析结果进行记录,并将域名解析记录存储在数据库中。域名解析服务器可与权威域名服务器建立连接,检测本地存储的域名解析记录与权威域名服务器中存储的相应的域名解析记录是否一致。若不一致,则将权威域名服务器中存储的相应的域名解析记录同步到本地的数据库中。其中,执行检测操作的时间可以是预设设置的检测周期,也可以是在当前时间超过域名解析记录中包括的缓存期限时进行。
具体地,应答数据的格式是固定的,域名解析服务器可按照预设的应答格式将存储在数据库中的域名解析记录封装得到应答数据并缓存到第二缓存区中,在需要的时候进行查找。域名解析服务器可以将得到的应答数据按照应答数据所属的记录类型分类缓存至第二缓存区中,在需要进行域名解析时,根据提取的记录类型确定属于提取的记录类型的应答数据集合,再从确定的应答数据集合中筛选出与提取的域名对应预缓存的应答数据。
域名解析服务器也可以将得到的应答数据按照应答数据对应的域名分类缓存至第二缓存区中,在需要进行域名解析时,根据提取的域名确定与提取的域名对应的应答数据集合,再从确定的应答数据集合中筛选出属于提取的记录类型的预缓存的应答数据。
域名解析服务器还可以获取与存储在本地的域名解析记录对应的历史记录次数,将得到的应答数据按照应答数据对应的域名解析记录所对应的历史记录次数降序排列,并缓存至第二缓存区中,在需要进行域名解析时,查找与提取的域名对应,且属于提取的记录类型的预缓存的应答数据。
其中,步骤S308至S310与步骤S306可异步执行。
S312,将查找到的应答数据与修改后的域名解析请求包组合,得到域名解析应答包。
具体地,域名解析服务器可定位第一缓存区中缓存的修改后的域名解析请求包,将查找到的应答数据添加到定位的域名解析请求包所包括的数据的 末尾,与已缓存的域名解析请求包组合得到域名解析应答包。
上述域名解析方法,将获取的域名解析请求包存储在第一缓存区中,并在该第一缓存区中完成对缓存的域名解析请求包的解析过程,将域名解析请求包中包括的头部数据修改为相应的域名解析应答包的头部数据,再将查找到的应答数据与修改后的域名解析请求包组合得到域名解析应答包。其中查找的应答数据是预先存储在第二缓存区中,在查找到后可直接与修改的域名解析请求包组合,极大地提高了域名解析效率。而且,在将应答数据从第二缓存区复制到第一缓存区后,可在第一缓存区中完成域名解析过程,有效减少了数据复制的次数,进一步提高了域名解析效率。
在一个实施例中,步骤S302具体包括在操作系统内核从网卡接收队列中读取数据包并传递至用户空间时,获取传递的数据包中包括的数据协议标识;当数据协议标识表示传递的数据包为域名解析请求包时,获取域名解析请求包。在本实施例中,第一缓存区和第二缓存区在用户空间中。
其中,数据协议标识是指数据包所包括的各层数据协议的标识。数据包在生成时,经过数据链路层、网络层和传输层等时,都会在数据包上添加相应数据协议层的数据协议标识。不同类型的数据包中包括的各层数据协议的标识不同。比如,数据包网络层数据协议标识为TCP(Transmission Control Protocol传输控制协议)/UDP(User Datagram Protocol用户数据报协议),传输层中目的端口为53端口的数据包为域名解析数据包。
具体地,域名解析服务器的操作系统内核可启用预先配置的数据包截取进程,从网卡接收队列中读取数据包,并将读取数据包并传递至用户空间。用户空间的域名解析进程获取传递的数据包中包括的数据协议标识,跟据与域名解析请求包匹配的各层协议的标识,对获取的数据协议标识进行检测,当获取的数据协议标识和与域名解析请求包匹配的各层协议的标识一致时,表示传递的数据包为域名解析请求包,用户空间的域名解析进程获取该域名解析请求包。
进一步地,当获取的数据协议标识和与域名解析请求包匹配的各层协议 的标识不一致时,表示传递的数据包为非域名解析请求包,用户空间的域名解析进程将传递的数据包反馈至操作系统内核进行响应。
在本实施例中,将判定为域名解析请求包的数据包直接在用户空间完成域名解析,不需要经过内核空间的过渡,避免了在内核空间进行解析时需要多次进行数据复制的问题,提高了域名解析效率。而且,对判定为非域名解析请求包的数据包反馈至操作系统内核进行响应,提供了对于用户空间无法完成解析的数据包的处理方式,提高了数据包解析的成功率。
在一个实施例中,该域名解析方法还包括在并行的解析线程中选择处于空闲状态的解析线程;再通过选择的解析线程执行步骤S302至步骤S312。
其中,解析线程是指用于进行域名解析的线程。处于空闲状态是指当前时间未进行域名解析。具体地,在域名解析服务器的域名解析进程中并行运行着多个解析线程,每个解析线程相互独立。域名解析服务器的域名解析进程可启用网卡驱动进程获取网卡接收到的域名解析请求包,再选择处于空闲状态的解析线程来执行对获取的域名解析请求包的域名解析过程。
在本实施例中,域名解析过程由解析线程单独完成,不涉及与其他线程之间进行数据交互处理,避免了线程交互处理数据的等待过程,进一步提高了域名解析效率。
如图4所示,在一个实施例中,域名解析方法涉及的第一缓存区和第二缓存区在用户空间中。域名解析方法中通过选择的解析线程执行获取域名解析请求包包括:
S402,在操作系统内核从网卡接收队列中读取数据包并传递至用户空间时,通过选择的解析线程获取传递的数据包中包括的数据协议标识。
具体地,域名解析服务器的操作系统内核可启用预先配置的数据包截取进程,从网卡接收队列中读取数据包,并将读取数据包并传递至用户空间。域名解析服务器再通过用户空间的解析线程获取传递的数据包中包括的数据协议标识。
S404,当数据协议标识表示传递的数据包为非域名解析请求包时,通过 选择的解析线程将传递的数据包缓存至用户空间中的第三缓存区。
具体地,域名解析服务器通过用户空间的解析线程将获取的数据协议标识和与域名解析请求包匹配的各层协议的标识进行比对,在比对结果表示获取的数据协议标识和与域名解析请求包匹配的各层协议的标识不一致时,判定传递的数据包为非域名解析请求包,用户空间的域名解析进程将传递的数据包缓存至用户空间中的第三缓存区。其中,第三缓存区是在域名解析服务器的缓存中划分出的缓存区域,用于存储传递至用户空间的非域名解析请求包。
S406,通过独立于并行的解析线程的内核交互线程从第三缓存区中读取数据包,并将读取的数据包反馈至操作系统内核进行响应。
其中,内核交互线程是对立于解析线程存在的,与内核空间进行交互的线程。具体地,用户空间中的解析线程不能直接与操作系统内核进行交互,因此将需要反馈至操作系统内核进行响应的非域名解析请求包缓存至用户空间中的第三缓存区。再由可以与操作系统内核进行交互的独立于并行的解析线程的内核交互线程从第三缓存区中读取数据包,并将读取的数据包缓存至内核空间的缓存区。内核空间的解析线程对缓存在内核空间的缓存区的数据包进行解析,并得到与该解析包对应的应答包。
在本实施例中,将用户空间的域名解析进程无法进行解析的非域名解析请求包反馈至操作系统内核进行响应,避免了用户空间的域名解析进程对非域名解析请求包解析出现失败的问题,提高了数据包解析的成功率。
在一个实施例中,域名解析方法还可包括获取数据包并缓存至第一缓存区;在第一缓存区中检测数据包所包括的数据协议标识;当数据协议标识表示传递的数据包为域名解析请求包时,继续执行步骤S306至步骤S310。当数据协议标识表示传递的数据包为非域名解析请求包时,将缓存的数据包反馈至操作系统内核进行响应。
具体地,域名解析方法中在操作系统内核从网卡接收队列中读取数据包并传递至用户空间后,可直接将读取的数据包缓存至用户空间的第一缓存区。 在用户空间中并行的解析线程中选择处于空闲状态的解析线程,检测缓存至第一缓存区的数据包是否为域名解析请求包。当检测判定缓存的数据包为域名解析请求包时,通过选择的解析线程继续执行步骤S306至步骤S310。当检测判定缓存的数据包为非域名解析请求包时,通过选择的解析线程将第一缓存区中的非域名解析请求包的地址指针缓存至第三缓存区。再由独立于并行的解析线程的内核交互线程根据存储在第三缓存区的地址指针从第一缓存区读取非域名解析请求包,并存储至内核空间的缓存区中。再由操作系统内核对存储在内核空间缓存区的非域名解析请求包进行响应。
其中,指针是用来指示内存地址的计算机语言的变量。第二缓存区中的非域名解析请求包的地址指针指向非域名解析请求包在第二缓存区中的缓存地址。非域名解析请求包比如ARP(Address Resolution Protocol地址解析协议)请求包或者OSPF(Open Shortest Path First开放式最短路径优先)请求包等。
在本实施例中,将数据包直接缓存至第一缓存区中,在检测判定为域名解析请求包时直接执行域名解析操作,在检测判定为非域名解析请求包之后,将第一缓存区中的非域名解析请求包反馈至操作系统内核进行响应。进一步减少了数据复制的次数,同时也提供了对于用户空间无法完成解析的数据包的处理方式,提高了数据包解析的成功率。
图5为一个实施例中域名解析服务器内部架构图。参考图5,域名解析服务器的系统空间被划分为内核空间和用户空间,操作系统内核可启用数据包截取进程从网卡接收队列中读取数据包并传递至用户空间中。用户空间中的解析线程在判定传递的数据包为域名解析数据包后,将传递的域名解析数据包缓存至第一缓存区;在判定传递的数据包为非域名解析数据包后,将传递的非域名解析数据包缓存至第三缓存区。用户空间中独立于解析线程的内核交互线程将缓存在第三缓存区的非域名解析数据包缓存至内核空间的缓存区,由操作系统内核响应。
如图6所示,在一个实施例中,步骤S306具体包括如下步骤:
S602,确定第一缓存区中缓存的域名解析请求包的首地址指针。
具体地,域名解析服务器在将获取的域名解析请求包缓存至第一缓存区后,可将域名解析请求包的首地址指针保存到临时缓存文件或者日志文件中,在需要对域名解析请求包进行数据修改时再读取。
S604,确定第一缓存区中缓存的域名解析请求包中待修改数据的地址指针偏移量;待修改数据为域名解析请求包与其相应的域名解析应答包各自的头部数据中差异的数据。
具体地,域名解析服务器可先确定与缓存的域名解析请求包对应的域名解析应答包的头部数据,根据确定的域名解析应答包的头部数据,确定域名解析请求包的头部数据中与域名解析应答包的头部数据中的差异数据,将确定的差异数据作为待修改的数据。
域名解析数据包的头部数据中封装的数据通常都进行了确定的字节划分。比如,域名解析数据包的头部数据的第一字节和第二字节为域名解析数据包标识;第三字节和第四字节为域名解析数据包标志,域名解析数据包标志字符段的第一比特为标志位,“0”表示为域名解析请求包,“1”表示为域名解析应答包等。域名解析服务器可根据确定的差异数据所在的字节确定待修改数据的地址指针偏移量。
S606,根据首地址指针与地址指针偏移量在第一缓存区中定位待修改数据。
具体地,在域名解析请求包的首地址指针上增加待修改数据的地址指针偏移量可得到待修改数据的地址指针,域名解析服务器可根据得到的该地址指针确定第一缓存区中待修改数据的缓存地址。
S608,将定位的待修改数据修改为域名解析应答包中与待修改数据相应的数据。
具体地,域名解析服务器在确定的第一缓存区中待修改数据的缓存地址上写入与域名解析请求包相应的域名解析应答包的头部数据。比如,将表示数据包类型的标志位从表示请求包的标志修改为表示应答包的标志。
在本实施例中,直接在缓存域名解析请求包的第一缓存区内将域名解析请求包头部数据修改为与域名解析请求包相应的域名解析应答包的头部数据,避免了在解析过程中需要实时封装域名解析应答包的繁琐步骤,减少了应答时间,进一步提高了域名解析效率。
如图7所示,在一个实施例中,步骤S310具体包括如下步骤:
S702,获取提取的域名所映射的哈希值。
其中,哈希值是利用哈希算法将任意长度的二进制值映射得到的固定长度的较小二进制值。比如,哈希算法是将字符串的各个字符所对应的ASCII码(American Standard Code for Information Interchange,美国信息交换标准代码)进行累加,那么字符串“ming”对应的哈希值为109+105+110+103=427。具体地,域名解析服务器可根据预设的哈希算法计算得到提取的域名所映射的哈希值。
S704,在哈希表中确定哈希值所指向的链表。
其中,哈希表是用于将域名以及域名对应的应答数据的缓存地址按照域名和哈希值的映射关系存放的列表。哈希值为哈希表中的存储位置。将域名以及域名对应的应答数据存储至域名所映射的哈希值的存储位置上。链表是一种用于存储多个数据元素的链式存储结构。本实施例中,链表是指存储映射的哈希值相同的域名,且由该相同的哈希值所指向的子列表。
具体地,域名解析服务器可事先根据域名解析请求包请求的记录类型建立多个哈希表,每个哈希表对应存储属于相同记录类型的应答数据的缓存地址与对应的域名。在对应于提取的请求类型的哈希表中确定哈希值所指向的链表。域名解析服务器也可将应答数据的缓存地址对应于对应的域名和所属的记录类型存储至一个哈希表中,在该哈希表中确定哈希值所指向的链表。
S706,在链表中查找包括提取的域名且与提取的记录类型对应的结点。
其中,链表中存储的每一个元素称为结点,每个结点包括两个部分:存储数据元素的数据域和存储下一个结点地址的指针域。
具体地,域名解析服务器可根据提取的域名在确定的链表中逐个与结点 的数据域中存储的域名比对,当结点内存储的域名与提取的域名一致时,确定该结点为需要查找的结点。其中,用于查找的链表属于对应于提取的请求类型的哈希表。
对于域名解析服务器将应答数据的缓存地址对应于对应的域名和所属的记录类型存储至一个哈希表的情形,域名解析服务器根据提取的域名在确定的链表中逐个与结点的数据域中存储的域名比对成功后,再根据提取的记录类型在确定的链表中逐个与结点的数据域中存储的记录类型比对,当结点内存储的记录类型与提取的记录类型一致时,确定该结点为需要查找的结点。
S708,从查找到的结点中提取应答数据的缓存地址。
S710,根据缓存地址从第二缓存区中读取相应的预缓存的应答数据。
具体地,域名解析服务器可从第二缓存区中的缓存地址读取缓存的数据,读取的缓存的数据为预缓存的应答数据。
在本实施例中,在哈希表中查找应答数据的缓存地址,再根据查找到的地址在缓存中读取应答数据,避免了直接在缓存中逐个查找对应的应答数据浪费时间的问题,极大地提高了查找速率,进一步提高了域名解析的效率。
进一步地,当域名解析服务器未在哈希表中查找到对应的应答数据时,确定提取的域名对应的主域名,并在哈希表中查找与确定的主域名对应,且属于域名起始记录类型的应答数据。其中,域名采用层次结构,按地理域或机构域进行分层,用小数点将各个层次隔开,从右到左依次为最高域名段、次高域名段等,最左的一个字段为主域名。比如请求的域名为www.xx.com,其主域名为xx.com。域名起始记录表示该主域名所对应的授权域名服务器。
在本实施例中,提供了对于未查找到与域名解析请求包所请求解析的域名和请求的记录类型对应的应答数据时的处理方法,反馈域名起始记录,使得域名解析请求方可以根据该域名起始记录向授权域名服务器发送域名解析请求,提高了域名解析的成功率。
如图8所示,在一个实施例中,步骤S312具体包括如下步骤:
S802,获取第一缓存区中修改后的域名解析请求包的首地址指针。
具体地,域名解析服务器在将获取的域名解析请求包缓存至第一缓存区后,可将域名解析请求包的首地址指针保存到临时缓存文件或者日志文件中,在需要对域名解析请求包进行数据修改时再读取。域名解析请求包在修改后首地址指针不发生改变。
S804,获取与修改后的域名解析请求包的数据总量对应的地址指针偏移量。
具体地,域名解析服务器可检测修改后的域名解析请求包的数据总量,根据检测的数量总量确定修改后的域名解析请求包在第一缓存区中所占的缓存地址区间,再根据该地址区间的大小确定地址指针偏移量。
S806,根据修改后的域名解析请求包的首地址指针和地址指针偏移量,确定应答数据的首地址指针。
具体地,域名解析服务器可在修改后的域名解析请求包的首地址指针上增加地址指针偏移量得到应答数据的首地址指针。
S808,根据应答数据的首地址指针将应答数据缓存至第一缓存区,得到缓存于第一缓存区且包括修改后的域名解析请求包以及缓存的应答数据的域名解析应答包。
具体地,确定的应答数据的首地址指针为修改后的域名解析请求包所包括的数据的最后一个字节的缓存地址的下一个缓存地址。将应答数据按照确定的该地址指针缓存至第一缓存区得到缓存于第一缓存区且包括修改后的域名解析请求包以及缓存的应答数据的域名解析应答包
在本实施例中,域名解析过程从获取域名解析请求包和得到域名解析应答包都在第一缓存区进行,只需将在第二缓存区中查找到的应答数据复制到第缓存区中域名解析请求包所包括的数据的末尾,即可与域名解析请求包组合得到域名解析应答包,提高了域名解析效率。
如图9所示,在一个实施例中,提供了一种域名解析方法,该方法具体包括如下步骤:
S902,在用户空间中并行的解析线程中选择处于空闲状态的解析线程。
S904,在操作系统内核从网卡接收队列中读取数据包并传递至用户空间时,通过选择的解析线程获取传递的数据包中包括的数据协议标识。
S906,根据获取的数据协议标识判断传递的数据包是否为域名解析请求包;若是,则跳转至步骤S908;若否,则跳转至步骤S910。
S908,通过选择的解析线程获取域名解析请求包,并跳转至步骤S912。
S910,通过选择的解析线程将传递的数据包缓存至用户空间中的第三缓存区,通过独立于并行的解析线程的内核交互线程从第三缓存区中读取数据包,并将读取的数据包反馈至操作系统内核进行响应。
S912,将获取的域名解析请求包缓存至用户空间中的第一缓存区。
S914,通过选择的解析线程确定第一缓存区中缓存的域名解析请求包的首地址指针。确定第一缓存区中缓存的域名解析请求包中待修改数据的地址指针偏移量;待修改数据为域名解析请求包与其相应的域名解析应答包各自的头部数据中差异的数据。根据首地址指针与地址指针偏移量在第一缓存区中定位待修改数据。将定位的待修改数据修改为域名解析应答包中与待修改数据相应的数据。
S916,通过选择的解析线程提取缓存的域名解析请求包请求解析的域名以及请求的记录类型。
S918,检测当前时间是否超出应答数据所包括的缓存期限;若否,则跳转到步骤S920,若是,则跳转到步骤S922。
其中,缓存期限是指应答数据的有效期。对域名解析得到的属于各个记录类型的结果不是固定不变的。在当前时间超出应答数据所包括的缓存期限时,需要检测封装为应答数据的域名解析记录是否发生改变。在域名解析记录未发生改变时,重置应答数据所包括的缓存期限。
S920,通过选择的解析线程获取提取的域名所映射的哈希值。在哈希表中确定哈希值所指向的链表。在链表中查找包括提取的域名且与提取的记录类型对应的结点。从查找到的结点中提取应答数据的缓存地址。根据缓存地址从第二缓存区中读取相应的预缓存的应答数据。
S922,更新域名解析记录,按照预设应答格式将更新的域名解析记录封装为更新的应答数据,将第二缓存区中预缓存的应答数据替换为更新的应答数据,跳转到步骤S920。
具体地,在当前时间超出应答数据所包括的缓存期限时,域名解析服务器可与权威域名服务器建立连接,检测本地存储的域名解析记录与权威域名服务器中存储的相应的域名解析记录是否一致。若不一致,则根据权威域名服务器中存储的相应的域名解析记录更新本地的域名解析记录,按照预设应答格式将更新的域名解析记录封装为更新的应答数据,将第二缓存区中预缓存的应答数据替换为更新的应答数据。
S924,通过选择的解析线程获取第一缓存区中修改后的域名解析请求包的首地址指针。获取与修改后的域名解析请求包的数据总量对应的地址指针偏移量。根据修改后的域名解析请求包的首地址指针和地址指针偏移量,确定应答数据的首地址指针。根据应答数据的首地址指针将应答数据缓存至第一缓存区,得到缓存于第一缓存区且包括修改后的域名解析请求包以及缓存的应答数据的域名解析应答包。
在本实施例中,将获取的域名解析请求包存储在用户空间中的第一缓存区中,通过单独的解析线程在该第一缓存区中完成对缓存的域名解析请求包的解析过程,避免了线程交互处理数据的等待过程,提高了数据处理效率。查找的应答数据是预先存储在用户空间中的第二缓存区中,在查找到后可直接与修改的域名解析请求包组合,极大地提高了域名解析效率。而且,域名解析过程中需要的数据均存储在用户空间的缓存区中,无需从磁盘中读取,极大地提高了数据处理速度。并且在将应答数据从第二缓存区复制到第一缓存区后,可在第一缓存区中完成域名解析过程,有效减少了数据复制的次数,进一步提高了域名解析效率。
图10为一个实施例中域名解析过程的逻辑图。参考图10,域名解析服务器的系统空间被划分为内核空间和用户空间,操作系统内核可启用数据包截取进程将网卡驱动进程读取的数据包传递至用户空间中。域名解析服务器 将域名解析数据包缓存至用户空间中的第一缓存区,并在用户空间中的第二缓存区中查找与域名解析数据包所请求解析的域名对应,且属于请求的记录类型的应答数据,将查找到的应答数据存储至第一缓存区中域名解析请求包的末尾,并对域名解析请求包的包头数据进行修改,得到域名解析应答包。对于非域名解析应答包则反馈至操作系统内核响应。
应该理解的是,虽然本申请各实施例中的各个步骤并不是必然按照步骤标号指示的顺序依次执行。除非本文中有明确的说明,这些步骤的执行并没有严格的顺序限制,这些步骤可以以其它的顺序执行。而且,各实施例中至少一部分步骤可以包括多个子步骤或者多个阶段,这些子步骤或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些子步骤或者阶段的执行顺序也不必然是依次进行,而是可以与其它步骤或者其它步骤的子步骤或者阶段的至少一部分轮流或者交替地执行。
如图11所示,在一个实施例中,提供了一种服务器1100。该服务器1100的内部结构可参照如图2所示的结构。下述的每个模块可全部或部分通过软件、硬件或其组合来实现。参照图11,该服务器1100包括:获取模块1101、修改模块1102、提取模块1103、查找模块1104和组合模块1105。
获取模块1101,用于获取域名解析请求包;将获取的域名解析请求包缓存至第一缓存区。
修改模块1102,用于在第一缓存区中修改缓存的域名解析请求包所包括的头部数据,得到与缓存的域名解析请求包相应的域名解析应答包的头部数据。
提取模块1103,用于提取缓存的域名解析请求包请求解析的域名以及请求的记录类型。
查找模块1104,用于在第二缓存区中查找与提取的域名对应,且属于提取的记录类型的预缓存的应答数据。
组合模块1105,用于将查找到的应答数据与修改后的域名解析请求包组合,得到域名解析应答包。
上述服务器1100,将获取的域名解析请求包存储在第一缓存区中,并在该第一缓存区中完成对缓存的域名解析请求包的解析过程,将域名解析请求包中包括的头部数据修改为相应的域名解析应答包的头部数据,再将查找到的应答数据与修改后的域名解析请求包组合得到域名解析应答包。其中查找的应答数据是预先存储在第二缓存区中,在查找到后可直接与修改的域名解析请求包组合,极大地提高了域名解析效率。而且,在将应答数据从第二缓存区复制到第一缓存区后,可在第一缓存区中完成域名解析过程,有效减少了数据复制的次数,进一步提高了域名解析效率。
在一个实施例中,获取装置1101还用于在操作系统内核从网卡接收队列中读取数据包并传递至用户空间时,获取传递的数据包中包括的数据协议标识;当数据协议标识表示传递的数据包为域名解析请求包时,获取域名解析请求包。在本实施例中,第一缓存区和第二缓存区在用户空间中。
在本实施例中,将判定为域名解析请求包的数据包直接在用户空间完成域名解析,不需要经过内核空间的过渡,避免了在内核空间进行解析时需要多次进程数据复制的问题,提高了域名解析效率。对判定为非域名解析请求包的数据包反馈至操作系统内核进行响应,提供了对于用户空间无法完成解析的数据包的处理方式,提高了数据包解析的成功率。
在一个实施例中,修改模块1102还用于确定第一缓存区中缓存的域名解析请求包的首地址指针;确定第一缓存区中缓存的域名解析请求包中待修改数据的地址指针偏移量;待修改数据为域名解析请求包与其相应的域名解析应答包各自的头部数据中差异的数据;根据首地址指针与地址指针偏移量在第一缓存区中定位待修改数据;将定位的待修改数据修改为域名解析应答包中与待修改数据相应的数据。
在本实施例中,直接在缓存域名解析请求包的第一缓存区内将域名解析请求包头部数据修改为与域名解析请求包相应的域名解析应答包的头部数据,避免了在解析过程中需要实时封装域名解析应答包的繁琐步骤,减少了应答时间,进一步提高了域名解析效率。
在一个实施例中,查找模块1104还用于获取提取的域名所映射的哈希值;在哈希表中确定哈希值所指向的链表;在链表中查找包括提取的域名且与提取的记录类型对应的结点;从查找到的结点中提取应答数据的缓存地址;根据缓存地址从第二缓存区中读取相应的预缓存的应答数据。
在本实施例中,在哈希表中查找应答数据的缓存地址,再根据查找到的地址在缓存中读取应答数据,避免了直接在缓存中逐个查找对应的应答数据浪费时间的问题,极大地提高了查找速率,进一步提高了域名解析的效率。
在一个实施例中,组合模块1105还用于获取第一缓存区中修改后的域名解析请求包的首地址指针;获取与修改后的域名解析请求包的数据总量对应的地址指针偏移量;根据修改后的域名解析请求包的首地址指针和地址指针偏移量,确定应答数据的首地址指针;根据应答数据的首地址指针将应答数据缓存至第一缓存区,得到缓存于第一缓存区且包括修改后的域名解析请求包以及缓存的应答数据的域名解析应答包。
在本实施例中,域名解析过程从获取域名解析请求包和得到域名解析应答包都在第一缓存区进行,只需将在第二缓存区中查找到的应答数据复制到第缓存区中域名解析请求包的所包括数据的末尾,即可与域名解析请求包组合得到域名解析应答包,提高了域名解析效率。
图12为另一个实施例中服务器1100的结构框图,参照图12,该服务器1100还包括预缓存模块1106。
预缓存模块1106,用于若当前时间超出应答数据所包括的缓存期限,则更新域名解析记录;按照预设应答格式将更新的域名解析记录封装为更新的应答数据;将第二缓存区中预缓存的应答数据替换为更新的应答数据。其中应答数据通过将域名解析记录按照预设应答格式进行封装得到。
在本实施例中,将获取的域名解析请求包存储在用户空间中的第一缓存区中,通过单独的解析线程在该第一缓存区中完成对缓存的域名解析请求包的解析过程,避免了线程交互处理数据的等待过程,提高了数据处理效率。查找的应答数据是预先存储在用户空间中的第二缓存区中,在查找到后可直 接与修改的域名解析请求包组合,极大地提高了域名解析效率。而且,域名解析过程中需要的数据均存储在用户空间的缓存区中,无需从磁盘中读取,极大地提高了数据处理速度。并且在将应答数据从第二缓存区复制到第一缓存区后,可在第一缓存区中完成域名解析过程,有效减少了数据复制的次数,进一步提高了域名解析效率。
如图13所示,在一个实施例中,提供了一种服务器1300。该服务器1300的内部结构可参照如图2所示的结构。下述的每个模块可全部或部分通过软件、硬件或其组合来实现。参照图13,该服务器1300包括:选择模块1301、获取模块1302、修改模块1303、提取模块1304、查找模块1305和组合模块1306。
选择模块1301,用于在并行的解析线程中选择处于空闲状态的解析线程。
获取模块1302,用于通过选择的解析线程获取域名解析请求包,将获取的域名解析请求包缓存至第一缓存区。
修改模块1303,用于通过选择的解析线程在第一缓存区中修改缓存的域名解析请求包所包括的头部数据,得到与缓存的域名解析请求包相应的域名解析应答包的头部数据。
提取模块1304,用于通过选择的解析线程提取缓存的域名解析请求包请求解析的域名以及请求的记录类型。
查找模块1305,用于通过选择的解析线程在第二缓存区中查找与提取的域名对应,且属于提取的记录类型的预缓存的应答数据。
组合模块1306,用于通过选择的解析线程将查找到的应答数据与修改后的域名解析请求包组合,得到域名解析应答包。
在本实施例中,域名解析过程由解析线程单独完成,不涉及与其他线程之间进行数据交互处理,避免了线程交互处理数据的等待过程,进一步提高了域名解析效率。
在一个实施例中,获取模块1302还用于在操作系统内核从网卡接收队列中读取数据包并传递至用户空间时,通过选择的解析线程获取传递的数据包 中包括的数据协议标识;当数据协议标识表示传递的数据包为非域名解析请求包时,通过选择的解析线程将传递的数据包缓存至用户空间中的第三缓存区;通过独立于并行的解析线程的内核交互线程从第三缓存区中读取数据包,并将读取的数据包反馈至操作系统内核进行响应。在本实施例中,第一缓存区和第二缓存区在用户空间中。
在本实施例中,将用户空间的域名解析进程无法进行解析的非域名解析请求包反馈至操作系统内核进行响应,避免了用户空间的域名解析进程对非域名解析请求包解析出现失败的问题,提高了数据包解析的成功率。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一非易失性计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。
以上实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。
以上实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形 和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。

Claims (24)

  1. 一种域名解析方法,包括:
    服务器获取域名解析请求包;
    所述服务器将获取的所述域名解析请求包缓存至第一缓存区;
    所述服务器在所述第一缓存区中修改缓存的所述域名解析请求包所包括的头部数据,得到与缓存的所述域名解析请求包相应的域名解析应答包的头部数据;
    所述服务器提取缓存的所述域名解析请求包请求解析的域名以及请求的记录类型;
    所述服务器在第二缓存区中查找与提取的所述域名对应,且属于提取的所述记录类型的预缓存的应答数据;及
    所述服务器将查找到的所述应答数据与修改后的所述域名解析请求包组合,得到域名解析应答包。
  2. 根据权利要求1所述的方法,其特征在于,所述第一缓存区和所述第二缓存区在用户空间中;所述服务器获取域名解析请求包包括:
    所述服务器在操作系统内核从网卡接收队列中读取数据包并传递至用户空间时,获取传递的所述数据包中包括的数据协议标识;及
    当所述数据协议标识表示传递的所述数据包为域名解析请求包时,所述服务器获取所述域名解析请求包。
  3. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    所述服务器在并行的解析线程中选择处于空闲状态的解析线程;及
    所述服务器通过选择的所述解析线程执行所述获取域名解析请求包的步骤,所述将获取的所述域名解析请求包缓存至第一缓存区,所述在所述第一缓存区中修改缓存的所述域名解析请求包所包括的头部数据,得到与缓存的所述域名解析请求包相应的域名解析应答包的头部数据,所述提取缓存的所述域名解析请求包请求解析的域名以及请求的记录类型,所述在第二缓存区中查找与提取的所述域名对应,且属于提取的所述记录类型的预缓存的应答 数据,以及所述将查找到的所述应答数据与修改后的所述域名解析请求包组合,得到域名解析应答包。
  4. 根据权利要求3所述的方法,其特征在于,所述服务器第一缓存区和所述第二缓存区在用户空间中;所述通过选择的所述解析线程执行所述获取域名解析请求包包括:
    所述服务器在操作系统内核从网卡接收队列中读取数据包并传递至用户空间时,通过选择的所述解析线程获取传递的所述数据包中包括的数据协议标识;
    当所述数据协议标识表示传递的所述数据包为非域名解析请求包时,所述服务器通过选择的所述解析线程将传递的所述数据包缓存至所述用户空间中的第三缓存区;及
    所述服务器通过独立于并行的解析线程的内核交互线程从所述第三缓存区中读取数据包,并将读取的数据包反馈至所述操作系统内核进行响应。
  5. 根据权利要求1所述的方法,其特征在于,所述服务器在所述第一缓存区中修改缓存的所述域名解析请求包所包括的头部数据,得到与缓存的所述域名解析请求包相应的域名解析应答包的头部数据包括:
    所述服务器确定所述第一缓存区中缓存的所述域名解析请求包的首地址指针;
    所述服务器确定所述第一缓存区中缓存的所述域名解析请求包中待修改数据的地址指针偏移量;所述待修改数据为所述域名解析请求包与其相应的域名解析应答包各自的头部数据中差异的数据;
    所述服务器根据所述首地址指针与所述地址指针偏移量在所述第一缓存区中定位所述待修改数据;及
    所述服务器将定位的所述待修改数据修改为所述域名解析应答包中与所述待修改数据相应的数据。
  6. 根据权利要求1所述的方法,其特征在于,所述应答数据通过将域名解析记录按照预设应答格式进行封装得到;
    所述方法还包括:
    若当前时间超出所述应答数据所包括的缓存期限,所述服务器则更新所述域名解析记录;
    所述服务器按照预设应答格式将更新的所述域名解析记录封装为更新的应答数据;及
    所述服务器将所述第二缓存区中预缓存的所述应答数据替换为所述更新的应答数据。
  7. 根据权利要求1所述的方法,其特征在于,所述服务器在第二缓存区中查找与提取的所述域名对应,且属于提取的所述记录类型的预缓存的应答数据包括:
    所述服务器获取提取的所述域名所映射的哈希值;
    所述服务器在哈希表中确定所述哈希值所指向的链表;
    所述服务器在所述链表中查找包括提取的所述域名且与提取的所述记录类型对应的结点;
    所述服务器从查找到的所述结点中提取应答数据的缓存地址;及
    所述服务器根据所述缓存地址从所述第二缓存区中读取相应的预缓存的应答数据。
  8. 根据权利要求1所述的方法,其特征在于,所述服务器将查找到的所述应答数据与修改后的所述域名解析请求包组合,得到域名解析应答包包括:
    所述服务器获取所述第一缓存区中修改后的所述域名解析请求包的首地址指针;
    所述服务器获取与修改后的所述域名解析请求包的数据总量对应的地址指针偏移量;
    所述服务器根据修改后的所述域名解析请求包的首地址指针和所述地址指针偏移量,确定所述应答数据的首地址指针;及
    所述服务器根据所述应答数据的首地址指针将所述应答数据缓存至所述第一缓存区,得到缓存于所述第一缓存区且包括修改后的所述域名解析请求 包以及缓存的所述应答数据的域名解析应答包。
  9. 一种服务器,包括存储器和处理器,所述存储器中存储有计算机可读指令,所述计算机可读指令被所述处理器执行时,使得所述处理器执行以下步骤:
    获取域名解析请求包;
    将获取的所述域名解析请求包缓存至第一缓存区;
    在所述第一缓存区中修改缓存的所述域名解析请求包所包括的头部数据,得到与缓存的所述域名解析请求包相应的域名解析应答包的头部数据;
    提取缓存的所述域名解析请求包请求解析的域名以及请求的记录类型;
    在第二缓存区中查找与提取的所述域名对应,且属于提取的所述记录类型的预缓存的应答数据;及
    将查找到的所述应答数据与修改后的所述域名解析请求包组合,得到域名解析应答包。
  10. 根据权利要求9所述的服务器,其特征在于,所述第一缓存区和所述第二缓存区在用户空间中;所述获取域名解析请求包包括:
    在操作系统内核从网卡接收队列中读取数据包并传递至用户空间时,获取传递的所述数据包中包括的数据协议标识;及
    当所述数据协议标识表示传递的所述数据包为域名解析请求包时,获取所述域名解析请求包。
  11. 根据权利要求9所述的服务器,其特征在于,所述计算机可读指令被所述处理器执行时,还使得所述处理器执行以下步骤:
    在并行的解析线程中选择处于空闲状态的解析线程;及
    通过选择的所述解析线程执行所述获取域名解析请求包,所述将获取的所述域名解析请求包缓存至第一缓存区,所述在所述第一缓存区中修改缓存的所述域名解析请求包所包括的头部数据,得到与缓存的所述域名解析请求包相应的域名解析应答包的头部数据,所述提取缓存的所述域名解析请求包请求解析的域名以及请求的记录类型,所述在第二缓存区中查找与提取的所 述域名对应,且属于提取的所述记录类型的预缓存的应答数据,以及所述将查找到的所述应答数据与修改后的所述域名解析请求包组合,得到域名解析应答包。
  12. 根据权利要求11所述的服务器,其特征在于,所述第一缓存区和所述第二缓存区在用户空间中;所述通过选择的所述解析线程执行所述获取域名解析请求包包括:
    在操作系统内核从网卡接收队列中读取数据包并传递至用户空间时,通过选择的所述解析线程获取传递的所述数据包中包括的数据协议标识;
    当所述数据协议标识表示传递的所述数据包为非域名解析请求包时,通过选择的所述解析线程将传递的所述数据包缓存至所述用户空间中的第三缓存区;及
    通过独立于并行的解析线程的内核交互线程从所述第三缓存区中读取数据包,并将读取的数据包反馈至所述操作系统内核进行响应。
  13. 根据权利要求9所述的服务器,其特征在于,所述在所述第一缓存区中修改缓存的所述域名解析请求包所包括的头部数据,得到与缓存的所述域名解析请求包相应的域名解析应答包的头部数据包括:
    确定所述第一缓存区中缓存的所述域名解析请求包的首地址指针;
    确定所述第一缓存区中缓存的所述域名解析请求包中待修改数据的地址指针偏移量;所述待修改数据为所述域名解析请求包与其相应的域名解析应答包各自的头部数据中差异的数据;
    根据所述首地址指针与所述地址指针偏移量在所述第一缓存区中定位所述待修改数据;及
    将定位的所述待修改数据修改为所述域名解析应答包中与所述待修改数据相应的数据。
  14. 根据权利要求9所述的服务器,其特征在于,所述应答数据通过将域名解析记录按照预设应答格式进行封装得到;
    所述计算机可读指令被所述处理器执行时,还使得所述处理器执行以下 步骤:
    若当前时间超出所述应答数据所包括的缓存期限,则
    更新所述域名解析记录;
    按照预设应答格式将更新的所述域名解析记录封装为更新的应答数据;及
    将所述第二缓存区中预缓存的所述应答数据替换为所述更新的应答数据。
  15. 根据权利要求9所述的服务器,其特征在于,所述在第二缓存区中查找与提取的所述域名对应,且属于提取的所述记录类型的预缓存的应答数据包括:
    获取提取的所述域名所映射的哈希值;
    在哈希表中确定所述哈希值所指向的链表;
    在所述链表中查找包括提取的所述域名且与提取的所述记录类型对应的结点;
    从查找到的所述结点中提取应答数据的缓存地址;及
    根据所述缓存地址从所述第二缓存区中读取相应的预缓存的应答数据。
  16. 根据权利要求9所述的服务器,其特征在于,所述将查找到的所述应答数据与修改后的所述域名解析请求包组合,得到域名解析应答包包括:
    获取所述第一缓存区中修改后的所述域名解析请求包的首地址指针;
    获取与修改后的所述域名解析请求包的数据总量对应的地址指针偏移量;
    根据修改后的所述域名解析请求包的首地址指针和所述地址指针偏移量,确定所述应答数据的首地址指针;及
    根据所述应答数据的首地址指针将所述应答数据缓存至所述第一缓存区,得到缓存于所述第一缓存区且包括修改后的所述域名解析请求包以及缓存的所述应答数据的域名解析应答包。
  17. 一个或多个存储有计算机可读指令的非易失性存储介质,所述计算 机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行以下步骤:
    获取域名解析请求包;
    将获取的所述域名解析请求包缓存至第一缓存区;
    在所述第一缓存区中修改缓存的所述域名解析请求包所包括的头部数据,得到与缓存的所述域名解析请求包相应的域名解析应答包的头部数据;
    提取缓存的所述域名解析请求包请求解析的域名以及请求的记录类型;
    在第二缓存区中查找与提取的所述域名对应,且属于提取的所述记录类型的预缓存的应答数据;及
    将查找到的所述应答数据与修改后的所述域名解析请求包组合,得到域名解析应答包。
  18. 根据权利要求17所述的存储介质,其特征在于,所述第一缓存区和所述第二缓存区在用户空间中;所述获取域名解析请求包包括:
    在操作系统内核从网卡接收队列中读取数据包并传递至用户空间时,获取传递的所述数据包中包括的数据协议标识;及
    当所述数据协议标识表示传递的所述数据包为域名解析请求包时,获取所述域名解析请求包。
  19. 根据权利要求17所述的存储介质,其特征在于,所述计算机可读指令被一个或多个处理器执行时,还使得一个或多个处理器执行以下步骤:
    在并行的解析线程中选择处于空闲状态的解析线程;及
    通过选择的所述解析线程执行所述获取域名解析请求包,所述将获取的所述域名解析请求包缓存至第一缓存区,所述在所述第一缓存区中修改缓存的所述域名解析请求包所包括的头部数据,得到与缓存的所述域名解析请求包相应的域名解析应答包的头部数据,所述提取缓存的所述域名解析请求包请求解析的域名以及请求的记录类型,所述在第二缓存区中查找与提取的所述域名对应,且属于提取的所述记录类型的预缓存的应答数据,以及所述将查找到的所述应答数据与修改后的所述域名解析请求包组合,得到域名解析 应答包。
  20. 根据权利要求19所述的存储介质,其特征在于,所述第一缓存区和所述第二缓存区在用户空间中;所述通过选择的所述解析线程执行所述获取域名解析请求包包括:
    在操作系统内核从网卡接收队列中读取数据包并传递至用户空间时,通过选择的所述解析线程获取传递的所述数据包中包括的数据协议标识;
    当所述数据协议标识表示传递的所述数据包为非域名解析请求包时,通过选择的所述解析线程将传递的所述数据包缓存至所述用户空间中的第三缓存区;及
    通过独立于并行的解析线程的内核交互线程从所述第三缓存区中读取数据包,并将读取的数据包反馈至所述操作系统内核进行响应。
  21. 根据权利要求17所述的存储介质,其特征在于,所述在所述第一缓存区中修改缓存的所述域名解析请求包所包括的头部数据,得到与缓存的所述域名解析请求包相应的域名解析应答包的头部数据包括:
    确定所述第一缓存区中缓存的所述域名解析请求包的首地址指针;
    确定所述第一缓存区中缓存的所述域名解析请求包中待修改数据的地址指针偏移量;所述待修改数据为所述域名解析请求包与其相应的域名解析应答包各自的头部数据中差异的数据;
    根据所述首地址指针与所述地址指针偏移量在所述第一缓存区中定位所述待修改数据;及
    将定位的所述待修改数据修改为所述域名解析应答包中与所述待修改数据相应的数据。
  22. 根据权利要求17所述的存储介质,其特征在于,所述应答数据通过将域名解析记录按照预设应答格式进行封装得到;
    所述计算机可读指令被一个或多个处理器执行时,还使得一个或多个处理器执行以下步骤:
    若当前时间超出所述应答数据所包括的缓存期限,则
    更新所述域名解析记录;
    按照预设应答格式将更新的所述域名解析记录封装为更新的应答数据;及
    将所述第二缓存区中预缓存的所述应答数据替换为所述更新的应答数据。
  23. 根据权利要求17所述的存储介质,其特征在于,所述在第二缓存区中查找与提取的所述域名对应,且属于提取的所述记录类型的预缓存的应答数据包括:
    获取提取的所述域名所映射的哈希值;
    在哈希表中确定所述哈希值所指向的链表;
    在所述链表中查找包括提取的所述域名且与提取的所述记录类型对应的结点;
    从查找到的所述结点中提取应答数据的缓存地址;及
    根据所述缓存地址从所述第二缓存区中读取相应的预缓存的应答数据。
  24. 根据权利要求17所述的存储介质,其特征在于,所述将查找到的所述应答数据与修改后的所述域名解析请求包组合,得到域名解析应答包包括:
    获取所述第一缓存区中修改后的所述域名解析请求包的首地址指针;
    获取与修改后的所述域名解析请求包的数据总量对应的地址指针偏移量;
    根据修改后的所述域名解析请求包的首地址指针和所述地址指针偏移量,确定所述应答数据的首地址指针;及
    根据所述应答数据的首地址指针将所述应答数据缓存至所述第一缓存区,得到缓存于所述第一缓存区且包括修改后的所述域名解析请求包以及缓存的所述应答数据的域名解析应答包。
PCT/CN2017/117904 2017-01-11 2017-12-22 域名解析方法、服务器和存储介质 WO2018130061A1 (zh)

Priority Applications (4)

Application Number Priority Date Filing Date Title
KR1020197013202A KR102199403B1 (ko) 2017-01-11 2017-12-22 도메인 네임 분석 방법, 서버 및 저장 매체
JP2019524972A JP6816275B2 (ja) 2017-01-11 2017-12-22 ドメイン名解析方法、サーバー及び記憶媒体
EP17891473.5A EP3570512B1 (en) 2017-01-11 2017-12-22 Domain name resolution method, server and storage medium
US16/357,082 US10826869B2 (en) 2017-01-11 2019-03-18 Domain name resolution method, server and storage medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710021111.4A CN106790762B (zh) 2017-01-11 2017-01-11 域名解析方法和装置
CN201710021111.4 2017-01-11

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US16/357,082 Continuation US10826869B2 (en) 2017-01-11 2019-03-18 Domain name resolution method, server and storage medium

Publications (1)

Publication Number Publication Date
WO2018130061A1 true WO2018130061A1 (zh) 2018-07-19

Family

ID=58947925

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/117904 WO2018130061A1 (zh) 2017-01-11 2017-12-22 域名解析方法、服务器和存储介质

Country Status (7)

Country Link
US (1) US10826869B2 (zh)
EP (1) EP3570512B1 (zh)
JP (1) JP6816275B2 (zh)
KR (1) KR102199403B1 (zh)
CN (1) CN106790762B (zh)
MA (1) MA47252A (zh)
WO (1) WO2018130061A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11374874B2 (en) * 2018-11-06 2022-06-28 Nippon Telegraph And Telephone Corporation Access control method, access control device, and data processing device

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106790762B (zh) 2017-01-11 2022-05-24 腾讯科技(深圳)有限公司 域名解析方法和装置
CN107483604B (zh) * 2017-08-29 2020-12-15 武汉斗鱼网络科技有限公司 Nginx-RTMP动态更新DNS缓存的方法和装置
CN108600406B (zh) * 2018-03-27 2021-06-01 上海兆芯集成电路有限公司 处理不同类型请求的网络装置
CN110147864B (zh) 2018-11-14 2022-02-22 腾讯科技(深圳)有限公司 编码图案的处理方法和装置、存储介质、电子装置
CN111030988B (zh) * 2019-11-01 2022-01-04 烽火通信科技股份有限公司 一种自反馈调度导流方法及系统
CN111711706B (zh) * 2020-04-30 2023-04-07 广州根链国际网络研究院有限公司 Dns递归请求方法及系统
CN111770049B (zh) * 2020-05-09 2022-06-03 优刻得科技股份有限公司 全局缓存变量及报文信息存储方法及装置
KR102537370B1 (ko) * 2020-05-29 2023-05-30 주식회사 맥데이타 대용량 네트워크 모니터링을 위한 실시간 패킷 분석 방법 및 장치
KR102423039B1 (ko) * 2020-06-30 2022-07-21 주식회사 맥데이타 대용량 네트워크 모니터링을 위한 실시간 패킷 데이터 저장 방법 및 장치
CN112040027B (zh) * 2020-09-14 2023-06-16 网易(杭州)网络有限公司 一种数据处理的方法及装置、电子设备、存储介质
CN112887442B (zh) * 2021-01-11 2023-02-07 杭州迪普科技股份有限公司 域名解析查询请求的处理方法及装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101102336A (zh) * 2007-06-14 2008-01-09 中兴通讯股份有限公司 一种电话号码映射域名服务器的内存处理方法及装置
US20090300191A1 (en) * 2008-05-27 2009-12-03 Silver Spring Networks, Inc. Multi-Protocol Network Registration and Address Resolution
CN102075432A (zh) * 2011-01-25 2011-05-25 上海聚欣网络科技有限公司 一种用于发送及接收报文的方法、装置、设备及系统
CN104917851A (zh) * 2015-05-08 2015-09-16 亚信科技(南京)有限公司 信息处理方法及dns缓存服务器
CN106790762A (zh) * 2017-01-11 2017-05-31 腾讯科技(深圳)有限公司 域名解析方法和装置

Family Cites Families (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040073707A1 (en) * 2001-05-23 2004-04-15 Hughes Electronics Corporation Generating a list of network addresses for pre-loading a network address cache via multicast
US7769826B2 (en) * 2003-06-26 2010-08-03 Nominum, Inc. Systems and methods of providing DNS services using separate answer and referral caches
US7440453B2 (en) * 2004-11-12 2008-10-21 International Business Machines Corporation Determining availability of a destination for computer network communications
US7467230B2 (en) * 2006-02-28 2008-12-16 Microsoft Corporation Global names zone
US8677018B2 (en) * 2008-08-25 2014-03-18 Google Inc. Parallel, side-effect based DNS pre-caching
US9197486B2 (en) * 2008-08-29 2015-11-24 Google Inc. Adaptive accelerated application startup
US9083644B2 (en) * 2012-02-14 2015-07-14 International Business Machines Corporation Packet routing for embedded applications sharing a single network interface over multiple virtual networks
US9215205B1 (en) * 2012-04-20 2015-12-15 Infoblox Inc. Hardware accelerator for a domain name server cache
CN102882991B (zh) * 2012-09-29 2016-03-30 北京奇虎科技有限公司 一种浏览器及其进行域名解析的方法
CN103634315B (zh) * 2013-11-29 2017-11-10 哈尔滨工业大学(威海) 域名服务器的前端控制方法及系统
US9531849B2 (en) * 2014-06-19 2016-12-27 Cavium, Inc. Method of splitting a packet into individual layers for modification and intelligently stitching layers back together after modification and an apparatus thereof
US10061619B2 (en) * 2015-05-29 2018-08-28 Red Hat, Inc. Thread pool management
CN105162900B (zh) * 2015-09-25 2019-02-15 中国互联网络信息中心 一种多节点协作的域名解析和缓存方法及系统
CN105681483B (zh) * 2015-12-29 2019-06-11 赛尔网络有限公司 基于dns服务器测量特定ip范围解析占比的方法及系统
CN106096023B (zh) * 2016-06-24 2019-03-08 腾讯科技(深圳)有限公司 数据读取方法、数据写入方法及数据服务器
CN108206814B (zh) * 2016-12-20 2021-03-16 腾讯科技(深圳)有限公司 一种防御dns攻击的方法、装置及系统
US10375016B1 (en) * 2018-04-02 2019-08-06 Cloudflare, Inc. Managing domain name system (DNS) record cache across multiple DNS servers using multicast communication

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101102336A (zh) * 2007-06-14 2008-01-09 中兴通讯股份有限公司 一种电话号码映射域名服务器的内存处理方法及装置
US20090300191A1 (en) * 2008-05-27 2009-12-03 Silver Spring Networks, Inc. Multi-Protocol Network Registration and Address Resolution
CN102075432A (zh) * 2011-01-25 2011-05-25 上海聚欣网络科技有限公司 一种用于发送及接收报文的方法、装置、设备及系统
CN104917851A (zh) * 2015-05-08 2015-09-16 亚信科技(南京)有限公司 信息处理方法及dns缓存服务器
CN106790762A (zh) * 2017-01-11 2017-05-31 腾讯科技(深圳)有限公司 域名解析方法和装置

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3570512A4 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11374874B2 (en) * 2018-11-06 2022-06-28 Nippon Telegraph And Telephone Corporation Access control method, access control device, and data processing device

Also Published As

Publication number Publication date
US20190215299A1 (en) 2019-07-11
JP2019537372A (ja) 2019-12-19
US10826869B2 (en) 2020-11-03
CN106790762A (zh) 2017-05-31
CN106790762B (zh) 2022-05-24
EP3570512A1 (en) 2019-11-20
MA47252A (fr) 2019-11-20
EP3570512A4 (en) 2020-11-18
EP3570512B1 (en) 2023-05-24
JP6816275B2 (ja) 2021-01-20
KR20190062530A (ko) 2019-06-05
KR102199403B1 (ko) 2021-01-06

Similar Documents

Publication Publication Date Title
WO2018130061A1 (zh) 域名解析方法、服务器和存储介质
US11388251B2 (en) Providing access to managed content
US8463850B1 (en) System and method of algorithmically generating a server side transaction identifier
US7953077B2 (en) Network processor with single interface supporting tree search engine and CAM
US11102118B2 (en) System and method for supporting ICN-within-IP networking
WO2019165665A1 (zh) 一种域名解析方法、服务器及系统
WO2017114205A1 (zh) 短链接处理方法、装置及服务器
US8321503B2 (en) Context-specific network resource addressing model for distributed services
WO2014206118A1 (zh) 基于tcp协议的移动互联网域名解析方法及dns服务器
US20210377211A1 (en) Cross protocol association for internet addresses for metadata association systems and methods
WO2020119310A1 (zh) 查找表存储方法、装置及计算机可读存储介质
US20160275199A1 (en) Data processing device, data processing method, and non-transitory computer readable medium
US11843650B2 (en) Two-level cache architecture for live video streaming through hybrid ICN
EP3107010B1 (en) Data integration pipeline
CN111352938B (zh) 数据处理方法、计算机设备及存储介质
CN106959975B (zh) 一种转码资源缓存处理方法、装置及设备
US10185783B2 (en) Data processing device, data processing method, and non-transitory computer readable medium
CN115004665A (zh) 文件分享方法、装置及系统
CN109495525B (zh) 网络组件、解析内容标识的方法和计算机可读存储介质
US20180367452A1 (en) Information centric networking over multi-access network interfaces
CN116866429A (zh) 一种数据访问方法及相关装置
WO2021087865A1 (zh) 寻址方法、寻址系统以及寻址装置
CN115129779A (zh) 数据库的同步方法、装置及可读介质
Alhisnawi Forwarding information base design techniques in content-centric networking: a survey
WO2023143061A1 (zh) 一种数据访问方法及其数据访问系统

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17891473

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 20197013202

Country of ref document: KR

Kind code of ref document: A

ENP Entry into the national phase

Ref document number: 2019524972

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE

ENP Entry into the national phase

Ref document number: 2017891473

Country of ref document: EP

Effective date: 20190812