IPv6 priority optimization method, device and equipment

By managing the domain name cache table and the abnormal cache table under the IPv6 priority strategy, and sorting and returning IP addresses according to the preset priority principle, the problem of low business response efficiency caused by abnormal response of DNS cache server is solved, and efficient network connection with IPv6 priority is achieved.

CN121664773APending Publication Date: 2026-03-13FIBERHOME TELECOMMUNICATION TECHNOLOGIES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-22
Publication Date
2026-03-13

AI Technical Summary

Technical Problem

Under the IPv6 priority policy, abnormal responses from DNS caching servers or proxy gateways result in low real-time business responses and low overall business interaction response efficiency.

Method used

When the target IP address does not exist in the domain name cache data table, it is determined whether the abnormal cache data table has an IP address type, and an IP address resolution request is sent to the domain name server. The IP addresses are returned in order of preset priority principles to perform active positive caching and negative caching management.

Benefits of technology

Under the IPv6 priority policy, ensure timely asynchronous return of available addresses, guarantee network connectivity, improve business response efficiency, and avoid network resource waste and long application waiting times caused by repeated DNS resolution request anomalies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121664773A_ABST
    Figure CN121664773A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of intelligent terminal equipment, and discloses an IPv6 priority optimization method, device and equipment. The method comprises the following steps: when a domain name corresponding to a domain name address resolution instruction meets a condition, sending a domain name IP address resolution request corresponding to an IP address type to a domain name server; after a request response of the domain name server is received within a first preset duration, adding an IP address corresponding to the IP address resolution request into an effective domain name cache data table; and sorting the IP addresses in the effective domain name cache data table according to a preset priority principle, and returning the sorted IP addresses to the application. Through the IPv6 address resolution method and device, the technical problems that in the prior art, when a DNS carries out IPv6 address resolution, a DNS cache server or a proxy gateway will respond abnormally, and the real-time performance and efficiency of service response are low are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of smart terminal equipment technology, and in particular to an optimization method, apparatus and device for prioritizing IPv6. Background Technology

[0002] Currently, the core strategy for internet upgrades is IPv6 priority. Its significance lies in completely resolving the IPv4 address exhaustion problem, providing near-infinite address space to support the access needs of billions of devices using emerging technologies such as 5G and the Internet of Things. In the long-term transition from IPv4 to IPv6, home entertainment terminals like set-top boxes and televisions need to utilize both IPv4 and IPv6 dual-stack protocols to ensure network compatibility during the smooth transition, support service continuity across all business scenarios, and provide future-oriented technological expansion capabilities. Therefore, achieving a dual-stack coexistence mode that prioritizes IPv6 while providing IPv4 as a fallback, along with the rapid service response capabilities under this mode, is a crucial network infrastructure capability.

[0003] DNS (Domain Name System) is the core coordination mechanism for domain name address resolution in dual-stack protocols. In related technologies, DNS simultaneously supports A records (IPv4) and AAAA records (IPv6) to achieve address lookup and protocol selection in a dual-stack environment.

[0004] However, under the IPv6 priority strategy, when DNS performs IPv6 address resolution, due to IPv6 network path issues, DNS server configuration and performance problems, abnormal behavior of intermediate devices (proxy / gateway), and protocol stack and application behavior, the DNS caching server or proxy gateway may respond abnormally. This affects the real-time performance of service responses and the overall efficiency of service interaction. For example, it may manifest as very slow video playback on set-top boxes, slow user interaction response, or timeout errors. This is a technical problem that urgently needs optimization. Summary of the Invention

[0005] The purpose of this invention is to provide an IPv6-preferred optimization method, apparatus, and device, which can solve the technical problems existing in the prior art where DNS caching servers or proxy gateways respond abnormally when performing IPv6 address resolution, resulting in low real-time service response and overall low efficiency of service interaction.

[0006] To achieve the above objectives, the present invention provides the following technical solution: An IPv6-preferred optimization method, the method comprising: When a domain name address resolution instruction is received, if the IP address corresponding to the target domain name does not exist in the valid domain name cache data table, and the type corresponding to the target domain name is an unspecified protocol family, then it is determined whether the IP address type corresponding to the target domain name exists in the abnormal domain name cache data table, wherein the target domain name is the domain name corresponding to the domain name address resolution instruction; If no IP address type exists, a domain name IP address resolution request corresponding to the IP address type is sent to the domain name server; Upon receiving a request response from the domain name server within a first preset time period, the IP address corresponding to the IP address resolution request is added to the valid domain name cache data table. The IP addresses in the valid domain name cache data table are sorted according to the preset priority principle, and the sorted IP addresses are returned to the application.

[0007] Optionally, in one embodiment, the IP address type includes a first IP address type and a second IP address type; The IP address resolution requests corresponding to the IP address types include the first IP address resolution request corresponding to the first IP address type and the second IP address resolution request corresponding to the second IP address type.

[0008] Optionally, in one embodiment, after determining whether the IP address type corresponding to the target domain name exists in the abnormal domain name cache data table, the following steps are included: If the abnormal domain name cache data table only contains the first IP address type corresponding to the target domain name, then determine whether the valid domain name cache data table contains the second IP address type. If a second IP address type exists in the valid domain name cache data table, the IP addresses in the valid domain name cache data table are sorted according to the preset priority principle, and the sorted IP addresses are returned to the application.

[0009] Optionally, in one embodiment, after determining whether the IP address type corresponding to the target domain name exists in the abnormal domain name cache data table, the method further includes: If the abnormal domain name cache data table only contains the second IP address type corresponding to the target domain name, then determine whether the valid domain name cache data table contains the first IP address type. If the first IP address type exists in the valid domain name cache data table, the IP addresses in the valid domain name cache data table are sorted according to the preset priority principle, and the sorted IP addresses are returned to the application.

[0010] Optionally, in one embodiment, the step of adding the IP address corresponding to the IP address resolution request to the valid domain name cache data table after receiving the request response from the domain name server within a first preset time period includes: When the first IP address corresponding to the first IP address resolution request and the second IP address corresponding to the second IP address resolution request are received from the domain name server within a first preset time period, the first IP address and the second IP address are added to the valid domain name cache data table, wherein the start time of the first preset time period is the time when the IP address resolution request is sent.

[0011] Optionally, in one embodiment, after sending the domain name IP address resolution request corresponding to the IP address type to the domain name server, the process includes: If the first IP address corresponding to the first IP address resolution request is not received from the domain name server within the first preset time period, the IP addresses in the valid domain name cache data table are sorted according to the preset priority principle, the sorted IP addresses are returned to the application, and the application continues to wait for the second preset time period. If the first IP address is not received from the domain name server within the second preset time period, or if the content of the domain name server's reply is abnormal, the first IP address that failed to resolve will be added to the abnormal domain name cache data table, and the retry count corresponding to the first IP address that failed to resolve will be incremented by one.

[0012] Optionally, in one embodiment, after sending the domain name IP address resolution request corresponding to the IP address type to the domain name server, the process includes: If the second IP address corresponding to the second IP address resolution request is not received from the domain name server within the first preset time period, the IP addresses in the valid domain name cache data table are sorted according to the preset priority principle, the sorted IP addresses are returned to the application, and the application continues to wait for the second preset time period. If the second IP address is not received from the domain name server within the second preset time period, or if the content of the domain name server's reply is abnormal, the second IP address that failed to resolve will be added to the abnormal domain name cache data table, and the retry count corresponding to the second IP address that failed to resolve will be incremented by one.

[0013] Optionally, in one embodiment, the method further includes: Active positive caching is performed on cache records in the valid domain name cache data table that have a control cache validity period less than the third preset duration and a usage frequency greater than the preset frequency, returned by the DNS server. For abnormal domain name cache data tables, if the validity period of the cache is less than the third preset duration and the usage frequency is greater than the preset frequency, active negative caching is performed.

[0014] Based on the same inventive concept, embodiments of the present invention also provide an IPv6-preferred optimization device, the device comprising: The judgment module is configured to, when receiving a domain name address resolution instruction, if the IP address corresponding to the target domain name does not exist in the valid domain name cache data table and the type corresponding to the target domain name is unspecified protocol family, then determine whether the IP address type corresponding to the target domain name exists in the abnormal domain name cache data table, wherein the target domain name is the domain name corresponding to the domain name address resolution instruction; The request sending module is configured to send a domain name IP address resolution request corresponding to the IP address type to the domain name server if the IP address type does not exist. The cache update module is configured to add the IP address corresponding to the IP address resolution request to the valid domain name cache data table after receiving a request response from the domain name server within a first preset time period. The priority sorting module is configured to sort the IP addresses in the valid domain name cache data table according to a preset priority principle and return the sorted IP addresses to the application.

[0015] Based on the same inventive concept, embodiments of the present invention also provide an electronic device, including: a memory and a processor; the processor is configured to read and execute a computer program stored in the memory to implement the steps of the aforementioned IPv6-preferred optimization method.

[0016] The technical effects and advantages of this invention are as follows: When the IP address corresponding to the target domain name does not exist in the effective domain name cache data table, an IP address resolution request is sent to the domain name server. The successfully resolved IP addresses returned by the domain name server are sorted according to a preset priority principle and returned to the application. This ensures that in the event of abnormal domain name address resolution, an available address can be returned to the application in a timely and asynchronous manner. It also maintains a balance between ensuring the priority use of IPv6 and ensuring the timeliness of network connection. This solves the technical problem in the existing technology that, under the IPv6 priority strategy, the DNS cache server or proxy gateway may respond abnormally when the DNS is performing IPv6 address resolution, resulting in low real-time business response and low overall business interaction response efficiency. The domain caching module performs proactive positive caching of data in the valid domain caching data table based on usage frequency, enabling zero-time DNS resolution for high-frequency domain addresses; The DNS protocol stack actively performs negative caching based on the frequency of use for data in the cache table for abnormal domain names. This can avoid situations where repeated DNS resolution requests for domain names are abnormal, which wastes network resources and causes long application waiting times, affecting business response.

[0017] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures pointed out in the description, claims and drawings. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This is a flowchart of the first embodiment of the IPv6-preferred optimization method of the present invention; Figure 2 This is a block diagram of a terminal device's network communication based on a domain name, according to an embodiment of the present invention. Figure 3 This is a schematic diagram of the internal structure of the DNS protocol stack of a terminal device according to an embodiment of the present invention; Figure 4 This is a flowchart of a second embodiment of the IPv6-preferred optimization method of the present invention; Figure 5 This is a flowchart of a third embodiment of the IPv6-preferred optimization method of the present invention; Figure 6 This is a flowchart of the fourth embodiment of the IPv6-preferred optimization method of the present invention; Figure 7 This is a flowchart of the fifth embodiment of the IPv6-preferred optimization method of the present invention; Figure 8 This is a functional module diagram of an embodiment of the IPv6 priority optimization device of the present invention. Figure 9 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention. Detailed Implementation

[0020] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0021] To address the shortcomings of existing technologies, this invention discloses an IPv6-preferred optimization method, referring to... Figure 1 The method includes: Step S10: When a domain name address resolution instruction is received, if the IP address corresponding to the target domain name does not exist in the valid domain name cache data table, and the type corresponding to the target domain name is an unspecified protocol family, then it is determined whether the IP address type corresponding to the target domain name exists in the abnormal domain name cache data table, wherein the target domain name is the domain name corresponding to the domain name address resolution instruction. The IP address corresponding to the target domain name does not exist in the effective domain name cache data table. Specifically, when a domain name address resolution instruction is received, the domain name corresponding to the domain name address resolution instruction is taken as the target domain name. The domain name address resolution instruction includes requesting IPv4 address resolution, requesting IPv6 address resolution, or requesting address resolution without specifying a protocol family.

[0022] If the domain name address resolution instruction is to request IPv4 address resolution, then check whether there is an IPv4 address cache in the valid domain name cache data table. If there is an IPv4 address cache in the valid domain name cache data table, then there is an IP address corresponding to the target domain name in the valid domain name cache data table. If the domain name address resolution instruction is to request IPv6 address resolution, then check whether there is an IPv6 address cache in the valid domain name cache data table. If there is an IPv6 address cache in the valid domain name cache data table, then there is an IP address corresponding to the target domain name in the valid domain name cache data table. If the domain name address resolution instruction is a request for unspecified protocol family address resolution, then check whether both IPv4 and IPv6 addresses are cached in the valid domain name cache data table. If both IPv4 and IPv6 addresses are cached in the valid domain name cache data table, then the IP address corresponding to the target domain name exists in the valid domain name cache data table.

[0023] In this embodiment, refer to Figure 2 , Figure 2 This is a block diagram illustrating the network communication operation of a terminal device based on a domain name, according to an embodiment of the present invention. Figure 2 As shown, this invention relates to terminal devices (such as set-top boxes), service platforms (such as IPTV service platforms and device management platforms), and domain name servers (DNS servers). The terminal device includes an application process group and a DNS protocol stack for network processes; the application process group contains N upper-layer applications, and the DNS protocol stack includes a domain name caching module and a domain name resolution module.

[0024] Terminal devices, business platforms, and domain name servers are all connected via a network. The terminal device's application interacts with the domain name server through its internal DNS protocol stack client to obtain the IP address corresponding to the domain name. Then, it requests business data from the business platform via the network, ultimately presenting a smooth and complete service to the customer. Within the terminal device, the DNS protocol stack runs in an independent process, and the application process communicates with the DNS protocol stack through inter-process communication mechanisms.

[0025] Reference Figure 3 , Figure 3 This is a schematic diagram of the internal structure of the DNS protocol stack of a terminal device according to an embodiment of the present invention. Figure 3 As shown, the domain name resolution module is mainly responsible for sending domain name address resolution requests to the DNS server and resolving the domain name addresses returned by the DNS server; The domain caching system consists of two tables: a valid domain caching table and an abnormal domain caching table. The valid domain caching table stores valid domain name resolution results obtained by the domain name resolution module from the domain name server; the abnormal domain caching table stores abnormal domain name resolution results obtained by the domain name resolution module from the domain name server.

[0026] For cache records whose TTL is about to expire (the control cache validity period returned by the DNS server in the valid domain name cache data table is less than the third preset time, and the control abnormal cache validity period in the abnormal domain name cache data table is less than the third preset time), if they are determined to be frequently used cache records, they are sent to the domain name resolution module for resolution. The domain name resolution module writes the resolution result back to the valid domain name cache data table and the abnormal domain name cache data table, so that frequently resolved domain names can continue to have cache records and will not be deleted due to the cache time exceeding the TTL validity period, thus making the cache unavailable for the next application request.

[0027] For cached records whose TTL is about to expire and are frequently used, specifically, in one embodiment, the IPv6-preferred optimization method further includes: Active positive caching is performed on cache records in the valid domain name cache data table that have a control cache validity period less than the third preset duration and a usage frequency greater than the preset frequency, returned by the DNS server. For abnormal domain name cache data tables, if the validity period of the cache is less than the third preset duration and the usage frequency is greater than the preset frequency, active negative caching is performed.

[0028] In this embodiment, the domain name caching module is mainly responsible for performing strategic active positive caching and active negative caching on the data in the valid domain name caching data table and the abnormal domain name caching data table.

[0029] Specifically, the system reads cache records from the valid domain name cache data table where the control cache expiration time (TTL) returned by the DNS server is less than a third preset time (e.g., 5 seconds). For cache records in the valid domain name cache data table where the control cache expiration time returned by the DNS server is less than the third preset time and the usage frequency is greater than a preset frequency (e.g., the usage frequency field in Table 1 or Table 2 is greater than the preset frequency), a strategic proactive positive caching is performed. This means proactively initiating a domain name address resolution request to the platform. After successful resolution, the system refreshes all fields of this cached record in the valid domain name cache data table, resets the frequency count to zero, re-accumulates the usage frequency for the new cycle, and clears the abnormal cached record in the abnormal domain name cache data table. The domain name caching module performs proactive positive caching based on the usage frequency of the data in the valid domain name cache data table, enabling zero-time DNS resolution for high-frequency domain name addresses. It should be noted that the control cache expiration time returned by the DNS server is used as the TTL time. This time counts down from the moment it is received until the countdown time is less than the third preset time, at which point the corresponding cached record is read.

[0030] The system reads cache records from the abnormal domain cache data table whose control exception cache validity period is less than the third preset time (e.g., TTL time less than 5 seconds). For these abnormal domain cache records whose control exception cache validity period is less than the third preset time (TTL time is about to expire) and whose usage frequency is greater than the preset frequency (e.g., the usage frequency field in Table 1 or Table 2 is greater than the preset frequency), a strategic proactive negative caching is performed. This involves proactively initiating a domain name address resolution request to the platform. If the resolution is successful, the resolution result is written to the valid domain cache data table, and the corresponding abnormal cache record in the abnormal domain cache data table is cleared. If the resolution fails, the retry count for this cache record in the abnormal domain cache data table is incremented by one. It should be noted that if the cache is used infrequently, even if it is an abnormal cache, it does not need to be proactively cached.

[0031] For abnormal cache records with fewer than the corresponding threshold retries, the DNS protocol stack will not take effect and will make a real request to the platform. When the number of retries is greater than or equal to the corresponding threshold, the DNS protocol stack will consider the resolution request for this domain name to be abnormal and will directly return the valid cache corresponding to this domain name to the application without making repeated invalid attempts.

[0032] The DNS protocol stack actively performs negative caching on data in the cache table for abnormal domain names. This can avoid situations where repeated DNS resolution requests for domain names are abnormal, which wastes network resources and causes long application waiting times, affecting business response.

[0033] The DNS protocol stack of the terminal device system runs in a resident process and has the capabilities for DNS protocol request interaction, DNS positive cache management, DNS negative cache management, and active DNS caching. When a terminal device application initiates a domain name-based network interaction, it first calls the system's DNS resolution interface to initiate a DNS domain name address resolution process. When the DNS protocol stack receives a domain name address resolution instruction from an upper-layer application, it uses the domain name corresponding to the instruction as the target domain name, resolves the target domain name through the domain name resolution module based on the instruction, and determines the validity of the target domain name based on the resolution result.

[0034] If the target domain name is invalid, an error is returned to the upper-layer application. If the target domain name is valid, the system checks if an IP address corresponding to the target domain name exists in the valid domain name cache table. If an IP address corresponding to the target domain name exists, the usage frequency of the target domain name in the valid domain name cache table is incremented by one.

[0035] The effective domain name cache data table is shown in Table 1.

[0036] Table 1

[0037] The main fields involved in the effective domain name cache data table (Table 1) include: domain name, record type, TTL time, timestamp, IP address, and usage frequency.

[0038] a. Domain name: The character identifier requested for resolution, such as www.example.com; b. Record type: A type represents IPv4 address resolution, and AAAA type represents IPv6 address resolution; c. TTL time: The validity period of the control cache returned by the DNS server (unit: seconds), balancing load and real-time performance; d. Timestamp: Records the time this cached entry was written; e. IP address: Write the resolved IP address. A record stores a 32-bit IPv4 address (e.g., 203.0.113.5), and AAAA record stores a 128-bit IPv6 address (e.g., 2001:db8::8a2e:370:7334). f. Frequency of use: The number of times the upper-layer application resolves this domain name and triggers the caching of this domain name within the validity period of this round of TTL. The frequency of use increases by 1 for each time it is used.

[0039] It should be noted that the key fields related to the effective cache data table of this invention are shown in Table 1, but this does not mean that the effective cache data only contains these fields.

[0040] If it is determined that the IP address corresponding to the target domain does not exist in the valid domain name cache data table, then it is determined whether the type corresponding to the target domain is an unspecified protocol cluster. If the type corresponding to the target domain is not an unspecified protocol cluster, it means that the IPv4 protocol cluster or IPv6 protocol cluster is specified, and then the default DNS protocol stack resolution process is followed, including DNS protocol interaction requests and resolution for the specified protocol cluster.

[0041] If the target domain name corresponds to an unspecified protocol family, it indicates a dual-stack optimization process prioritizing IPv6. Therefore, it checks if the abnormal domain name cache table contains an IP address type corresponding to the target domain name. IP address types include a first IP address type and a second IP address type. Taking an IPv4 address as the first IP address type and an IPv6 address as the second IP address type as an example (the same applies below), it checks if the abnormal domain name cache table contains both an IPv4 address and an IPv6 address corresponding to the target domain name.

[0042] The cached data table for abnormal domains is shown in Table 2.

[0043] Table 2

[0044] The main fields involved in the abnormal domain name cache data table (Table 2) include: domain name, record type, error type, TTL time, timestamp, IP address, usage frequency, and number of retries.

[0045] a. Domain name: The character identifier requested for resolution, such as www.example.com; b. Record type: A type represents IPv4 address resolution, and AAAA type represents IPv6 address resolution; c. Error types: DNS resolution error types, in addition to explicit errors returned by the DNS server (such as SERVFAIL, NXDOMAIN), also include various exceptions such as returning null and returning timeout; d. TTL time: A custom time used to control the validity period of the exception cache (unit: seconds); e.Timestamp: Records the time this cached entry was written; f. Frequency of use: The number of times the upper-layer application resolves this domain name and triggers the caching of this domain name within the validity period of this round of TTL. The frequency of use increases by 1 for each time it is used. g. Number of retries: The cumulative number of times this domain name requests an exception to the DNS server. If multiple exceptions are of the same type, this exception cache record is a valid exception cache record, which can avoid requesting the domain name address that cannot be responded to normally from the DNS server each time, as well as the resulting network resource overhead and time overhead.

[0046] Step S20: If no IP address type exists, send a domain name IP address resolution request corresponding to the IP address type to the domain name server; In this embodiment, if the IPv4 address and IPv6 address corresponding to the target domain name do not exist in the abnormal domain name cache data table, a domain name IP address resolution request corresponding to the IP address type is sent to the domain name server. That is, an IPv4 address resolution request corresponding to the IP address type is sent to the domain name server, and an IPv6 address resolution request corresponding to the IP address type is sent to the domain name server. It should be noted that when the number of retries corresponding to the target domain name in the abnormal domain name is greater than or equal to the corresponding threshold, the IP address corresponding to the target domain name is considered to exist; when the number of retries corresponding to the target domain name is less than the corresponding threshold, the IP address corresponding to the target domain name is considered not to exist.

[0047] Furthermore, in one embodiment, reference is made to Figure 4 After step S10, the method further includes: Step S50: If the abnormal domain name cache data table only contains the first IP address type corresponding to the target domain name, then determine whether the valid domain name cache data table contains the second IP address type. Step S60: If a second IP address type exists in the valid domain name cache data table, the IP addresses in the valid domain name cache data table are sorted according to a preset priority principle, and the sorted IP addresses are returned to the application.

[0048] This invention takes IPv4 as the first IP address type and IPv6 as the second IP address type as an example. In this embodiment, when a domain name address resolution instruction is received, if the IP address corresponding to the target domain name does not exist in the valid domain name cache data table, and the type corresponding to the target domain name is unspecified protocol family, then it is determined whether the IP address type corresponding to the target domain name exists in the abnormal domain name cache data table (i.e., whether the IPv4 address and IPv6 address corresponding to the target domain name exist in the abnormal domain name cache data table). If the abnormal domain name cache data table only contains the IPv4 address corresponding to the target domain name, then it is further determined whether the IPv6 address corresponding to the target domain name exists in the valid domain name cache data table. If the IPv6 address corresponding to the target domain exists in the valid domain cache data table, meaning the IPv6 address is valid (indicating that the abnormal domain cache data table has implemented a strategic proactive negative cache for this cache record (the record type corresponding to the target domain is AAAA (IPv6 address resolution)), i.e., it has proactively initiated a domain address resolution request to the platform and the resolution was successful), then the IP addresses in the valid domain cache data table are sorted according to the IPv6 address priority principle, and the sorted IP addresses are returned to the application, thereby achieving the goal of ensuring IPv6 priority. At the same time, the usage frequency corresponding to both the valid domain cache data table and the abnormal domain cache data table is incremented by one.

[0049] If the abnormal domain name cache data table only contains the IPv4 corresponding to the target domain name, but the valid domain name cache data table does not contain the IPv6 corresponding to the target domain name, then no valid address is available, and an IPv4 address resolution request is sent to the domain name server.

[0050] Furthermore, in one embodiment, reference is made to Figure 5 After step S10, the method further includes: Step S70: If the abnormal domain name cache data table only contains the second IP address type corresponding to the target domain name, then determine whether the valid domain name cache data table contains the first IP address type. Step S80: If the first IP address type exists in the valid domain name cache data table, sort the IP addresses in the valid domain name cache data table according to the preset priority principle, and return the sorted IP addresses to the application.

[0051] In this embodiment, when a domain name address resolution instruction is received, if the IP address corresponding to the target domain name does not exist in the valid domain name cache data table, and the type corresponding to the target domain name is an unspecified protocol family, then it is determined whether the IP address type corresponding to the target domain name exists in the abnormal domain name cache data table (i.e., whether the IPv4 address and IPv6 address corresponding to the target domain name exist in the abnormal domain name cache data table). If the abnormal domain name cache data table only contains the IPv6 address corresponding to the target domain name, then it is further determined whether the IPv4 address corresponding to the target domain name exists in the valid domain name cache data table. If the valid domain name cache data table contains an IPv4 address corresponding to the target domain name, meaning the IPv4 address is valid (indicating that the abnormal domain name cache data table performs a strategic proactive negative cache for this cache record (the record type corresponding to the target domain name is type A (IPv4 address resolution)), i.e., it actively initiates a domain name address resolution request to the platform and the resolution is successful), then the IP addresses in the valid domain name cache data table are sorted according to the IPv6 address priority principle, and the sorted IP addresses are returned to the application. At this time, since only IPv4 addresses are valid, only IPv4 addresses can be returned to the application. At the same time, the usage frequency corresponding to the valid domain name cache data table and the abnormal domain name cache data table is incremented by one.

[0052] If the abnormal domain name cache data table only contains the IPv6 corresponding to the target domain name, but the valid domain name cache data table does not contain the IPv4 corresponding to the target domain name, then no valid address is available, and an IPv6 address resolution request is sent to the domain name server.

[0053] Step S30: After receiving the request response from the domain name server within the first preset time period, add the IP address corresponding to the IP address resolution request to the valid domain name cache data table. In some specific embodiments, step S30 includes: When the first IP address corresponding to the first IP address resolution request and the second IP address corresponding to the second IP address resolution request are received from the domain name server within a first preset time period, the first IP address and the second IP address are added to the valid domain name cache data table, wherein the start time of the first preset time period is the time when the IP address resolution request is sent.

[0054] In this embodiment, after initiating a domain name IP address resolution request to the domain name server, a timer is started. The timer is used to return a valid address to the application ahead of time when DNS resolution takes a long time. The duration is set to ensure the effective acquisition of the IPv6 address as much as possible, while preventing the upper-layer application from waiting for too long. It should be noted that this timer is unique within this solution process and will be executed at most once; it will not be created multiple times due to the execution of different processes.

[0055] If the DNS server successfully resolves both IPv4 and IPv6 address resolution requests, and if the DNS protocol stack receives a response from the DNS server within a first preset time period (containing the IPv4 address for the IPv4 resolution request and the IPv6 address for the IPv6 resolution request), then the IPv4 and IPv6 addresses are added to the valid domain name cache table. Furthermore, the records corresponding to the IPv4 and IPv6 addresses in the abnormal domain name cache table are cleared. At this point, the interaction process with the DNS server is complete, and the timer is canceled. The first preset time period is the duration of the timer.

[0056] Furthermore, in one embodiment, reference is made to Figure 6 After step S20, the method further includes: Step S110: If the first IP address corresponding to the first IP address resolution request is not received from the domain name server within the first preset time period, the IP addresses in the valid domain name cache data table are sorted according to the preset priority principle, the sorted IP addresses are returned to the application, and the application continues to wait for the second preset time period. Step S111: If the first IP address is not received from the domain name server within the second preset time period, or if the content of the domain name server's reply is abnormal, the first IP address that failed to resolve is added to the abnormal domain name cache data table, and the retry count corresponding to the first IP address that failed to resolve is incremented by one.

[0057] In this embodiment, if no IPv4 address corresponding to the IPv4 address resolution request is received from the domain name server within the first preset time period, the IP addresses in the valid domain name cache data table are sorted according to a preset priority principle, the sorted IP addresses are returned to the application, and the application continues to wait for the second preset time period. It should be noted that the sum of the first preset time period and the second preset time period is the timeout duration for the IP address resolution request.

[0058] If no IPv4 address is received from the DNS server within the second preset time period, or if the DNS server's response is abnormal, it is determined that the IPv4 address resolution has failed. The failed IPv4 address is then added to the abnormal domain name cache data table, and the retrieval count for the failed IPv4 address is incremented. It should be noted that abnormal DNS server responses include: the DNS server responding with an empty response, or the DNS server responding with an incorrect IP address (e.g., SERVFAIL (a problem occurred during the query process), NXDOMAIN (the domain name does not exist)). In other words, when querying based on the IP address responded by the DNS server, errors occur or the domain name cannot be found.

[0059] Furthermore, if an IPv4 address is received from the domain name server within the second preset time period, the IPv4 address is added to the valid domain name cache data table.

[0060] In this embodiment, the strategic asynchronous return mechanism of the DNS protocol stack does not interrupt the complete DNS polling process, which ensures both the timeliness of the current response application and the integrity of DNS resolution, so as to enable a fast response to the next resolution request.

[0061] Furthermore, in one embodiment, reference is made to Figure 7 After step S20, the method further includes: Step S120: If the second IP address corresponding to the second IP address resolution request is not received from the domain name server within the first preset time period, the IP addresses in the valid domain name cache data table are sorted according to the preset priority principle, the sorted IP addresses are returned to the application, and the application continues to wait for the second preset time period. Step S121: If the second IP address is not received from the domain name server within the second preset time period, or if the content of the domain name server's reply is abnormal, the second IP address that failed to resolve is added to the abnormal domain name cache data table, and the retry count corresponding to the second IP address that failed to resolve is incremented by one.

[0062] In this embodiment, if no IPv6 address corresponding to the IPv6 address resolution request is received from the domain name server within the first preset time period, the IP addresses in the valid domain name cache data table are sorted according to the preset priority principle, the sorted IP addresses are returned to the application, and the application continues to wait for the second preset time period.

[0063] If no IPv6 address is received from the domain name server within the second preset time period, it is determined that the IPv6 address resolution has failed, or the content of the domain name server's reply is abnormal. The IPv6 address that failed to resolve is added to the abnormal domain name cache data table, and the retry count corresponding to the IPv6 address that failed to resolve is incremented by one.

[0064] Furthermore, if an IPv6 address is received from the domain name server within the second preset time period, the IPv6 address is added to the valid domain name cache data table.

[0065] Step S40: Sort the IP addresses in the valid domain name cache data table according to the preset priority principle, and return the sorted IP addresses to the application.

[0066] In this embodiment, the preset priority principle is the IPv6 priority principle. When the target domain name is of type with no specified protocol family, the domain name server resolves the IP address successfully based on both IPv4 and IPv6 address resolution requests. The IP address corresponding to the target domain name in the valid domain name cache data table is the IPv4 address and the IPv6 address. At this time, the IP addresses in the valid domain name cache data table are sorted according to the IPv6 priority principle, and the IP addresses are returned to the application asynchronously in sequence. This achieves a dual-stack coexistence mode with IPv6 priority and IPv4 as a fallback.

[0067] Furthermore, in one embodiment, the IPv6-preferred optimization method further includes: When a domain name address resolution instruction is received, if the IP address corresponding to the target domain name exists in the valid domain name cache data table, the IP addresses in the valid domain name cache data table are sorted according to a preset priority principle, and the sorted IP addresses are returned to the application.

[0068] In this embodiment, there are three cases for the address resolution instruction: Case 1: IPv4 address resolution instruction; Case 2: IPv6 address resolution instruction; Case 3: No protocol address resolution specified.

[0069] For scenario one, since the received domain name resolution instruction is an IPv4 address resolution instruction, if the IPv4 address corresponding to the target domain name exists in the valid domain name cache data table, then the IPv4 address corresponding to the target domain name in the valid domain name cache data table can be returned to the application.

[0070] For scenario two, since the received domain name resolution instruction is an IPv6 address resolution instruction, if the IPv6 address corresponding to the target domain name exists in the valid domain name cache data table, then the IPv6 address corresponding to the target domain name in the valid domain name cache data table can be returned to the application.

[0071] For scenario three, since the received domain name address resolution instruction does not specify the protocol address resolution, it is necessary to send IPv4 and IPv6 address resolution requests to the domain name server. After the domain name server resolves the IPv4 and IPv6 addresses successfully and asynchronously returns the resolved IPv4 and IPv6 addresses, the resolved IPv4 and IPv6 addresses are added to the valid domain name cache data table. Then, the IP addresses in the valid domain name cache data table are sorted according to the IPv6 address priority principle, and the IP addresses are asynchronously returned to the application in sequence. In this way, a dual-stack coexistence mode with IPv6 priority and IPv4 as a fallback can be achieved.

[0072] In this embodiment, when a domain name address resolution instruction is received, if the IP address corresponding to the target domain name does not exist in the valid domain name cache data table, and the type corresponding to the target domain name is an unspecified protocol family, then it is determined whether the IP address type corresponding to the target domain name exists in the abnormal domain name cache data table, wherein the target domain name is the domain name corresponding to the domain name address resolution instruction; if the IP address type does not exist, a domain name IP address resolution request corresponding to the IP address type is sent to the domain name server; when the domain name server resolves the IP address successfully, the IP address corresponding to the IP address resolution request is added to the valid domain name cache data table; the IP addresses in the valid domain name cache data table are sorted according to a preset priority principle, and the IP addresses are returned to the application. In this embodiment, when the IP address corresponding to the target domain name does not exist in the effective domain name cache data table, an IP address resolution request is sent to the domain name server. The successfully resolved IP addresses returned by the domain name server are sorted according to a preset priority principle and returned to the application. This ensures that in the event of abnormal domain name address resolution, an available address can be returned to the application asynchronously in a timely manner. It also maintains a balance between ensuring the priority use of IPv6 and ensuring the timeliness of network connection. This solves the technical problem in the prior art where, under the IPv6 priority strategy, the DNS cache server or proxy gateway may respond abnormally when the DNS is performing IPv6 address resolution, resulting in low real-time business response and low overall business interaction response efficiency.

[0073] Based on the same inventive concept, embodiments of the present invention also provide an IPv6 priority optimization device.

[0074] In one embodiment, reference is made to Figure 8 , Figure 8 This is a functional module diagram of an embodiment of the IPv6 priority optimization device of the present invention. Figure 8 As shown, the IPv6-preferred optimization device includes: The judgment module 10 is configured to, when receiving a domain name address resolution instruction, if the IP address corresponding to the target domain name does not exist in the valid domain name cache data table and the type corresponding to the target domain name is an unspecified protocol family, then determine whether the IP address type corresponding to the target domain name exists in the abnormal domain name cache data table, wherein the target domain name is the domain name corresponding to the domain name address resolution instruction; The request sending module 20 is configured to send a domain name IP address resolution request corresponding to the IP address type to the domain name server if the IP address type does not exist. The cache update module 30 is configured to add the IP address corresponding to the IP address resolution request to the valid domain name cache data table after receiving a request response from the domain name server within a first preset time period. The priority sorting module 40 is configured to sort the IP addresses in the valid domain name cache data table according to a preset priority principle and return the sorted IP addresses to the application.

[0075] Optionally, in one embodiment, the IP address type includes a first IP address type and a second IP address type; The IP address resolution requests corresponding to the IP address types include the first IP address resolution request corresponding to the first IP address type and the second IP address resolution request corresponding to the second IP address type.

[0076] Optionally, in one embodiment, the determination module 10 is further configured to: If the abnormal domain name cache data table only contains the first IP address type corresponding to the target domain name, then determine whether the valid domain name cache data table contains the second IP address type. If a second IP address type exists in the valid domain name cache data table, the IP addresses in the valid domain name cache data table are sorted according to the preset priority principle, and the sorted IP addresses are returned to the application.

[0077] Optionally, in one embodiment, the determination module 10 is further configured to: If the abnormal domain name cache data table only contains the second IP address type corresponding to the target domain name, then determine whether the valid domain name cache data table contains the first IP address type. If the first IP address type exists in the valid domain name cache data table, the IP addresses in the valid domain name cache data table are sorted according to the preset priority principle, and the sorted IP addresses are returned to the application.

[0078] Optionally, in one embodiment, the cache update module 30 is configured to: When the first IP address corresponding to the first IP address resolution request and the second IP address corresponding to the second IP address resolution request are received from the domain name server within a first preset time period, the first IP address and the second IP address are added to the valid domain name cache data table, wherein the start time of the first preset time period is the time when the IP address resolution request is sent.

[0079] Optionally, in one embodiment, the cache update module 30 is further configured to: If the first IP address corresponding to the first IP address resolution request is not received from the domain name server within the first preset time period, the IP addresses in the valid domain name cache data table are sorted according to the preset priority principle, the sorted IP addresses are returned to the application, and the application continues to wait for the second preset time period. If the first IP address is not received from the domain name server within the second preset time period, or if the content of the domain name server's reply is abnormal, the first IP address that failed to resolve will be added to the abnormal domain name cache data table, and the retry count corresponding to the first IP address that failed to resolve will be incremented by one.

[0080] Optionally, in one embodiment, the cache update module 30 is further configured to: If the second IP address corresponding to the second IP address resolution request is not received from the domain name server within the first preset time period, the IP addresses in the valid domain name cache data table are sorted according to the preset priority principle, the sorted IP addresses are returned to the application, and the application continues to wait for the second preset time period. If the second IP address is not received from the domain name server within the second preset time period, or if the content of the domain name server's reply is abnormal, the second IP address that failed to resolve will be added to the abnormal domain name cache data table, and the retry count corresponding to the second IP address that failed to resolve will be incremented by one.

[0081] Optionally, in one embodiment, the cache update module 30 is further configured to: Active positive caching is performed on cache records in the valid domain name cache data table that have a control cache validity period less than the third preset duration and a usage frequency greater than the preset frequency, returned by the DNS server. For abnormal domain name cache data tables, if the validity period of the cache is less than the third preset duration and the usage frequency is greater than the preset frequency, active negative caching is performed.

[0082] The functions of each module in the above-mentioned IPv6 priority optimization device correspond to the steps in the above-mentioned IPv6 priority optimization method embodiment, and their functions and implementation processes will not be described in detail here.

[0083] Based on the same inventive concept, embodiments of the present invention also provide an electronic device, the structure of which is as follows: Figure 9 As shown, it includes: a memory and a processor, the processor being used to read and execute a computer program stored in the memory to implement the aforementioned IPv6-preferred optimization method.

[0084] Finally, it should be noted that while some processes described in the embodiments of the present invention include multiple operations or steps that appear in a specific order, it should be understood that these operations or steps may not be executed in the order they appear in the embodiments of the present invention, or may be executed in parallel. The sequence number of the operation is only used to distinguish different operations, and the sequence number itself does not represent any execution order. In addition, these processes may include more or fewer operations, and these operations or steps may be executed sequentially or in parallel, and these operations or steps may be combined.

[0085] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. An IPv6-preferred optimization method, characterized in that, The method includes: When a domain name address resolution instruction is received, if the IP address corresponding to the target domain name does not exist in the valid domain name cache data table, and the type corresponding to the target domain name is an unspecified protocol family, then it is determined whether the IP address type corresponding to the target domain name exists in the abnormal domain name cache data table, wherein the target domain name is the domain name corresponding to the domain name address resolution instruction; If no IP address type exists, a domain name IP address resolution request corresponding to the IP address type is sent to the domain name server; Upon receiving a request response from the domain name server within a first preset time period, the IP address corresponding to the IP address resolution request is added to the valid domain name cache data table. The IP addresses in the valid domain name cache data table are sorted according to the preset priority principle, and the sorted IP addresses are returned to the application.

2. The IPv6-preferred optimization method according to claim 1, characterized in that, The IP address type includes a first IP address type and a second IP address type; The IP address resolution requests corresponding to the IP address types include the first IP address resolution request corresponding to the first IP address type and the second IP address resolution request corresponding to the second IP address type.

3. The IPv6-preferred optimization method according to claim 2, characterized in that, After determining whether the IP address type corresponding to the target domain exists in the abnormal domain cache data table, the following steps are included: If the abnormal domain name cache data table only contains the first IP address type corresponding to the target domain name, then determine whether the valid domain name cache data table contains the second IP address type. If a second IP address type exists in the valid domain name cache data table, the IP addresses in the valid domain name cache data table are sorted according to the preset priority principle, and the sorted IP addresses are returned to the application.

4. The IPv6-preferred optimization method according to claim 2, characterized in that, After determining whether the IP address type corresponding to the target domain exists in the abnormal domain cache data table, the process also includes: If the abnormal domain name cache data table only contains the second IP address type corresponding to the target domain name, then determine whether the valid domain name cache data table contains the first IP address type. If the first IP address type exists in the valid domain name cache data table, the IP addresses in the valid domain name cache data table are sorted according to the preset priority principle, and the sorted IP addresses are returned to the application.

5. The IPv6-preferred optimization method according to claim 2, characterized in that, Upon receiving a request response from the domain name server within a first preset time period, the step of adding the IP address corresponding to the IP address resolution request to the valid domain name cache data table includes: When the first IP address corresponding to the first IP address resolution request and the second IP address corresponding to the second IP address resolution request are received from the domain name server within a first preset time period, the first IP address and the second IP address are added to the valid domain name cache data table, wherein the start time of the first preset time period is the time when the IP address resolution request is sent.

6. The IPv6-preferred optimization method according to claim 2, characterized in that, After sending the domain name IP address resolution request corresponding to the IP address type to the domain name server, the process includes: If the first IP address corresponding to the first IP address resolution request is not received from the domain name server within the first preset time period, the IP addresses in the valid domain name cache data table are sorted according to the preset priority principle, the sorted IP addresses are returned to the application, and the application continues to wait for the second preset time period. If the first IP address is not received from the domain name server within the second preset time period, or if the content of the domain name server's reply is abnormal, the first IP address that failed to resolve will be added to the abnormal domain name cache data table, and the retry count corresponding to the first IP address that failed to resolve will be incremented by one.

7. The IPv6-preferred optimization method according to claim 2, characterized in that, After sending the domain name IP address resolution request corresponding to the IP address type to the domain name server, the process includes: If the second IP address corresponding to the second IP address resolution request is not received from the domain name server within the first preset time period, the IP addresses in the valid domain name cache data table are sorted according to the preset priority principle, the sorted IP addresses are returned to the application, and the application continues to wait for the second preset time period. If the second IP address is not received from the domain name server within the second preset time period, or if the content of the domain name server's reply is abnormal, the second IP address that failed to resolve will be added to the abnormal domain name cache data table, and the retry count corresponding to the second IP address that failed to resolve will be incremented by one.

8. The IPv6-preferred optimization method according to any one of claims 1 to 7, characterized in that, The method further includes: Active positive caching is performed on cache records in the valid domain name cache data table that have a control cache validity period less than the third preset duration and a usage frequency greater than the preset frequency, returned by the DNS server. For abnormal domain name cache data tables, if the validity period of the cache is less than the third preset duration and the usage frequency is greater than the preset frequency, active negative caching is performed.

9. An IPv6-preferred optimization device, characterized in that, The device includes: The judgment module is configured to, when receiving a domain name address resolution instruction, if the IP address corresponding to the target domain name does not exist in the valid domain name cache data table and the type corresponding to the target domain name is unspecified protocol family, then determine whether the IP address type corresponding to the target domain name exists in the abnormal domain name cache data table, wherein the target domain name is the domain name corresponding to the domain name address resolution instruction; The request sending module is configured to send a domain name IP address resolution request corresponding to the IP address type to the domain name server if the IP address type does not exist. The cache update module is configured to add the IP address corresponding to the IP address resolution request to the valid domain name cache data table after receiving a request response from the domain name server within a first preset time period. The priority sorting module is configured to sort the IP addresses in the valid domain name cache data table according to a preset priority principle and return the sorted IP addresses to the application.

10. An electronic device, characterized in that, include: Memory and processor; The processor is configured to read and execute the computer program stored in the memory to implement the IPv6-preferred optimization method according to any one of claims 1-8.