Network request processing method, device, computer equipment and storage medium
By detecting the application startup on the terminal device and obtaining the target domain name, determining whether to use HTTPDNS, and filtering out the target IP address from multiple IP addresses based on the performance filtering strategy, the problems of slow network connection speed and poor user experience in the existing technology are solved, and fast and stable network connection is achieved.
Patent Information
- Application Number
- CN202411869016.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-17
- Publication Date
- 2025-04-01
AI Technical Summary
In the prior art, the terminal device performs network connection processing method according to the IP set returned by the HTTPDNS server, and there are problems such as slow network connection speed and poor user experience.
When the application is detected to start, obtain the target domain name corresponding to the application and determine whether it is configured to use HTTPDNS. If configured to use HTTPDNS, obtain the first IP address corresponding to the supported network protocol stack and the target domain name, filter the target IP address from multiple IP addresses based on the performance filtering strategy, and establish a network connection.
By directly accessing the memory cache, filtering out the target IP address, avoiding sending a resolution request to the HTTPDNS server every time, achieving quick acquisition of the target IP address. The target IP address filtered based on the performance filtering strategy can improve the speed and success rate of network connections, thereby improving the user experience.
Smart Images

Figure CN119743462A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a method, device, computer equipment and storage medium for processing a network request. Background Art
[0002] In Internet communications, the Domain Name System (DNS) plays an important role in resolving domain names entered by users into corresponding IP addresses, which is the basis for achieving network access. With the development of technology, traditional DNS resolution methods have gradually exposed shortcomings such as slow resolution speed and vulnerability to attacks. Therefore, HTTPDNS has emerged as a new type of DNS resolution technology. HTTPDNS technology uses the HTTP protocol to perform DNS queries, which has higher resolution speed and stronger security than traditional UDP DNS queries. In the HTTPDNS workflow, when a user's terminal device needs to access a domain name, it needs to send a domain name resolution request to the HTTPDNS server each time to request the resolution of the IP address corresponding to the domain name. After receiving the request, the HTTPDNS server will use its own resolution capabilities and strategies to quickly return one or more IP addresses to the terminal device.
[0003] In order to improve the availability and stability of the resolution results, HTTPDNS servers usually return a set of IP addresses to the terminal device instead of a single IP address. The advantage of this is that even if a certain IP address is inaccessible for various reasons (such as server failure, network congestion, etc.), the terminal device can still try to connect to other IP addresses, thereby improving the success rate of network access.
[0004] However, in the prior art, there are deficiencies in the processing method of the terminal device for network connection based on the IP set returned by the HTTPDNS server. A common practice is that the terminal device randomly selects an IP address from the IP set for connection. Although this method improves the randomness and dispersion of the connection to a certain extent, it may also result in the selection of an IP address with poor quality or a long distance, thereby affecting the network connection speed. Another approach is that the terminal device selects the first IP address in the IP set for connection. Although this method is simple and direct, it also has risks, because if the first IP address is unavailable or has poor performance, the terminal device will directly face the problem of network access failure or slow speed. Therefore, the prior art adopts a processing method for network connection based on the IP set returned by the HTTPDNS server, which has the problems of slow network connection speed and poor user experience. Summary of the invention
[0005] The main purpose of the present invention is to provide a method, device, computer equipment and storage medium for processing network requests, aiming to solve the technical problems of slow network connection speed and poor user experience in the prior art of using a network connection processing method based on an IP set returned by an HTTPDNS server.
[0006] To achieve the above object, the present invention provides a method for processing a network request, the method comprising:
[0007] When detecting that an application is started, obtaining a target domain name corresponding to the application;
[0008] Determine whether the target domain name is configured to use HTTPDNS;
[0009] If so, obtaining a network protocol stack supported by the device and network corresponding to the application, and determining whether the network protocol stack includes a target network protocol stack;
[0010] If so, obtaining a first IP address corresponding to the network protocol stack and the target domain name from a preset memory cache;
[0011] Determine whether the first IP address contains multiple addresses;
[0012] If so, filtering out the target IP address from all the first IP addresses based on a preset performance screening strategy;
[0013] A network connection is established with a preset server based on the target IP address, and a corresponding network request is sent to the server.
[0014] Optionally, the filtering out a target IP address from all the first IP addresses based on a preset performance filtering strategy includes:
[0015] Get the preset test data package;
[0016] Performing test processing on each of the first IP addresses based on the test data packets to obtain delay data, jitter data, and packet loss rate of each of the first IP addresses;
[0017] Obtaining distance information of each of the first IP addresses corresponding to the device;
[0018] Generate a priority score value for each of the first IP addresses based on the delay data, jitter data, packet loss rate, and distance information of each of the first IP addresses;
[0019] Filter out the second IP address with the smallest priority score value from all the first IP addresses;
[0020] The second IP address is used as the target IP address.
[0021] Optionally, generating a priority score value of each first IP address based on delay data, jitter data, packet loss rate, and distance information of each first IP address includes:
[0022] Obtaining specified delay data, specified jitter data, specified packet loss rate, and specified distance information corresponding to a specified IP address; wherein the specified IP address is any one of all the first IP addresses;
[0023] Obtaining a first weight, a second weight, a third weight, and a fourth weight corresponding to the delay index, the jitter index, the packet loss rate index, and the distance index, respectively;
[0024] Call the preset priority score calculation formula;
[0025] Based on the priority score calculation formula, the specified delay data, the specified jitter data, the specified packet loss rate, the specified distance information, the first weight, the second weight, the third weight and the fourth weight are calculated and processed to obtain a corresponding calculation result;
[0026] The calculation result is used as the designated priority score value of the designated IP address.
[0027] Optionally, before acquiring the first IP address corresponding to the network protocol stack and the target domain name from the preset memory cache, the method further includes:
[0028] Call the preset timer polling strategy;
[0029] Based on the timer polling strategy, requesting the IP address corresponding to the target domain name from a preset HTTPDNS server;
[0030] Receive the IP address returned by the HTTPDNS server, and perform validity verification on the IP address to obtain a corresponding verification result;
[0031] Filtering out a third IP address that passes the validity check from all the IP addresses based on the check result;
[0032] The third IP address is stored in the memory cache.
[0033] Optionally, after establishing a network connection with a preset server based on the target IP address and sending a corresponding network request to the server, the method further includes:
[0034] When receiving a network response corresponding to the network request returned by the server, determining whether the network request is successful based on the network response;
[0035] If the network request is successful, the trustworthiness of the target IP address is enhanced based on a preset enhancement strategy;
[0036] If the network request fails, determine whether the time between the current error corresponding to the target IP address and the last error is greater than a preset time threshold;
[0037] If so, the trustworthiness of the target IP address is reduced based on a preset reduction strategy.
[0038] Optionally, after reducing the trustworthiness of the target IP address based on a preset reduction strategy, the method further includes:
[0039] Obtaining the current trustworthiness of the target IP address;
[0040] Determining whether the current trust level is less than a preset trust level threshold;
[0041] If yes, release the network connection between the target IP address and the server;
[0042] Filtering out a fourth IP address whose trustworthiness meets a preset selection condition from the memory cache;
[0043] A network connection is established with the server based on the fourth IP address, and a corresponding network request is sent to the server.
[0044] Optionally, after determining whether the target domain name is configured to use HTTPDNS, the method further includes:
[0045] If the target domain name is not configured to use HTTPDNS, the preset original network link is called;
[0046] The network request is sent to the server based on the original network link.
[0047] In addition, to achieve the above-mentioned purpose, the present invention further provides a network request processing device, the network request processing device comprising:
[0048] A first acquisition module, configured to acquire a target domain name corresponding to the application when detecting that the application is started;
[0049] A first determination module is used to determine whether the target domain name is configured to use HTTPDNS;
[0050] A second determination module is used to, if yes, obtain a network protocol stack supported by the device and network corresponding to the application, and determine whether the network protocol stack includes a target network protocol stack;
[0051] A second acquisition module, configured to, if yes, acquire a first IP address corresponding to the network protocol stack and the target domain name from a preset memory cache;
[0052] A third judgment module is used to judge whether the first IP address contains multiple addresses;
[0053] A first screening module, configured to, if yes, screen out a target IP address from all the first IP addresses based on a preset performance screening strategy;
[0054] The first processing module is used to establish a network connection with a preset server based on the target IP address and send a corresponding network request to the server.
[0055] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:
[0056] The computer device includes a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the steps of the method for processing a network request proposed in any one of the embodiments of the present application are implemented.
[0057] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:
[0058] The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the steps of the method for processing a network request proposed in any one of the embodiments of the present application are implemented.
[0059] Compared with the prior art, the embodiments of the present application have the following beneficial effects:
[0060] The present invention provides a method, apparatus, computer equipment and storage medium for processing network requests, the method comprising: when detecting that an application is started, first obtaining a target domain name corresponding to the application; then determining whether the target domain name is configured to use HTTPDNS; if so, obtaining a network protocol stack supported by a device and network corresponding to the application, and determining whether the network protocol stack contains a target network protocol stack; if so, obtaining a first IP address corresponding to the network protocol stack and the target domain name from a preset memory cache; subsequently determining whether the first IP address contains multiple addresses; if so, filtering out a target IP address from all the first IP addresses based on a preset performance screening strategy; finally establishing a network connection with a preset server based on the target IP address, and sending a corresponding network request to the server. When the application is detected to be started, the application automatically obtains the first IP address corresponding to the network protocol stack and the target domain name from the preset memory cache by acquiring the target domain name corresponding to the application, and when it is detected that the target domain name is configured to use HTTPDNS, and when it is detected that the network protocol stack supported by the device and network corresponding to the application includes the target network protocol stack, and when it is detected that the first IP address contains multiple addresses, the target IP address is intelligently filtered out from all the first IP addresses based on the use of the performance screening strategy, and then a network connection with a preset server is established based on the target IP address, and a corresponding network request is sent to the server. By directly accessing the memory cache to filter out the target IP address, there is no need to send a domain name resolution request to the HTTPDNS server each time, and the target IP address is quickly obtained. The network connection with the server is established by filtering out the target IP address with the best performance based on the use of the performance screening strategy, which effectively improves the success rate and speed of network requests, thereby helping to improve the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0062] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;
[0063] Figure 2 is a flow chart of a method for processing a network request provided by an embodiment of the present invention;
[0064] Figure 3 is a structural diagram of an embodiment of a network request processing device according to the present application;
[0065] Figure 4 This is a basic structural block diagram of the computer device in this embodiment. DETAILED DESCRIPTION
[0066] The method for processing a network request provided by an embodiment of the present invention is applied to a processing device for a network request. Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those generally understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" in the specification and claims of the present application and the above-mentioned drawings and any variations thereof are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0067] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0068] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0069] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0070] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social online platform software, etc.
[0071] Terminal devices 101, 102, 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group Audio Layer IV) players, laptop computers, desktop computers, etc.
[0072] The server 105 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal devices 101 , 102 , and 103 .
[0073] It should be noted that the network request processing method provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the network request processing device is generally set in the server / terminal device.
[0074] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0075] In Internet communications, the Domain Name System (DNS) plays an important role in resolving domain names entered by users into corresponding IP addresses, which is the basis for achieving network access. With the development of technology, traditional DNS resolution methods have gradually exposed shortcomings such as slow resolution speed and vulnerability to attacks. Therefore, HTTPDNS has emerged as a new type of DNS resolution technology. HTTPDNS technology performs DNS queries through the HTTP protocol, which has higher resolution speed and stronger security than traditional UDP DNS queries. In the HTTPDNS workflow, when a user device needs to access a domain name, it needs to send a domain name resolution request to the HTTPDNS server each time to request the resolution of the IP address corresponding to the domain name. After receiving the request, the HTTPDNS server will use its own resolution capabilities and strategies to quickly return one or more IP addresses to the terminal device.
[0076] In order to improve the availability and stability of the resolution results, HTTPDNS servers usually return a set of IP addresses to the terminal device instead of a single IP address. The advantage of this is that even if a certain IP address is inaccessible for various reasons (such as server failure, network congestion, etc.), the terminal device can still try to connect to other IP addresses, thereby improving the success rate of network access.
[0077] However, in the prior art, there are deficiencies in the processing method of the terminal device for network connection based on the IP set returned by the HTTPDNS server. A common practice is that the terminal device randomly selects an IP address from the IP set for connection. Although this method improves the randomness and dispersion of the connection to a certain extent, it may also result in the selection of an IP address with poor quality or a long distance, thereby affecting the network connection speed. Another approach is that the terminal device selects the first IP address in the IP set for connection. Although this method is simple and direct, it also has risks, because if the first IP address is unavailable or has poor performance, the terminal device will directly face the problem of network access failure or slow speed. Therefore, the prior art adopts a processing method for network connection based on the IP set returned by the HTTPDNS server, which has the problems of slow network connection speed and poor user experience.
[0078] Continue to refer Figure 2 , shows a flow chart of an embodiment of a method for processing a network request proposed in the present application. The embodiment of the present application can acquire and process relevant data based on artificial intelligence technology.
[0079] The method for processing a network request provided by an embodiment of the present invention comprises the following steps:
[0080] S210, when it is detected that the application is started, obtaining a target domain name corresponding to the application.
[0081] In this step, the execution subject of the present invention may be a terminal device installed with the application, or simply referred to as a device. When the application is started, the target domain name is usually obtained from the configuration file or code of the application. These domain names are the server addresses that the APP needs to communicate with, which may be API interfaces, content servers, advertising servers, etc. Alternatively, the target domain name may also be the domain name of the website entered by the user.
[0082] S220, determining whether the target domain name is configured to use HTTPDNS.
[0083] In this step, before initiating a network request, it is checked whether the current target domain name has been configured to use HTTPDNS. This can be achieved by reading a configuration file, checking a global variable, or calling a specific method.
[0084] S230: If yes, obtain the network protocol stack supported by the device and network corresponding to the application, and determine whether the network protocol stack includes the target network protocol stack.
[0085] In this step, the network protocol stack supported by the current device and network can be checked by using a network API (such as Android's ConnectivityManager). The network protocol stack may include IPv4 and / or IPv6. The target network protocol stack is IPv6.
[0086] S240: If yes, obtain a first IP address corresponding to the network protocol stack and the target domain name from a preset memory cache.
[0087] In this step, the corresponding IP address can be found from the memory cache according to the target domain name and the above-mentioned network protocol stack. If there is a matching IP address in the memory cache, the IP address is directly obtained. If there is no matching IP address in the memory cache, an alternative solution (such as using LocalDNS resolution) is executed. Among them, the construction process of the above-mentioned memory cache will be further described in detail in the subsequent specific embodiments of this application, and will not be elaborated on here. By using the memory cache, the application sub-application can also quickly use the IP address of HTTPDNS when it is started. In addition, by selecting the corresponding IP according to the target network protocol stack, the utilization rate of the target network protocol stack can be improved. The target network protocol stack can specifically use IPv6. IPv6 is the successor version of IPv4. It is developed to improve various aspects of the IPv4 protocol. Therefore, according to the network protocol stack where the device corresponding to the current application is located and supported, select a suitable IP address to use. Naturally, network requests can use IPv6 as much as possible, enjoy the faster and safer network transmission experience brought by IPv6, and thus shorten network time.
[0088] S250, determining whether the first IP address contains multiple IP addresses.
[0089] In this step, the number of the first IP addresses may include one or more. If the number of the first IP addresses includes only one, the first IP address is directly used as the target IP address.
[0090] S260: If yes, filter out the target IP address from all the first IP addresses based on a preset performance screening strategy.
[0091] In this step, the specific implementation process of selecting the target IP address from all the first IP addresses based on the preset performance screening strategy will be further described in detail in the subsequent specific embodiments of the present application, and will not be elaborated on in detail here. In addition, the IP address with the highest trustworthiness can also be selected from all the first IP addresses as the above target IP address.
[0092] S270: Establish a network connection with a preset server based on the target IP address, and send a corresponding network request to the server.
[0093] In this step, a network connection (such as a TCP connection) can be established with the corresponding server according to the obtained target IP address and the corresponding port number. A network request, such as an HTTP request, is sent, and a server response is waited for. The established network connection will be used to send and receive data. The establishment of the network connection will trigger the subsequent network response processing flow.
[0094] In an embodiment of the present invention, when it is detected that an application is started, a target domain name corresponding to the application is first obtained; then it is determined whether the target domain name is configured to use HTTPDNS; if so, a network protocol stack supported by a device and network corresponding to the application is obtained, and it is determined whether the network protocol stack contains a target network protocol stack; if so, a first IP address corresponding to the network protocol stack and the target domain name is obtained from a preset memory cache; subsequently, it is determined whether the first IP address contains multiple addresses; if so, the target IP address is filtered out from all the first IP addresses based on a preset performance filtering strategy; finally, a network connection with a preset server is established based on the target IP address, and a corresponding network request is sent to the server. When the application is detected to be started, the application automatically obtains the first IP address corresponding to the network protocol stack and the target domain name from the preset memory cache by acquiring the target domain name corresponding to the application, and when it is detected that the target domain name is configured to use HTTPDNS, and when it is detected that the network protocol stack supported by the device and network corresponding to the application includes the target network protocol stack, and when it is detected that the first IP address contains multiple addresses, the target IP address is intelligently filtered out from all the first IP addresses based on the use of the performance screening strategy, and then a network connection with a preset server is established based on the target IP address, and a corresponding network request is sent to the server. By directly accessing the memory cache to filter out the target IP address, there is no need to send a domain name resolution request to the HTTPDNS server each time, and the target IP address is quickly obtained. The network connection with the server is established by filtering out the target IP address with the best performance based on the use of the performance screening strategy, which effectively improves the success rate and speed of network requests, thereby helping to improve the user experience.
[0095] Optionally, the filtering out a target IP address from all the first IP addresses based on a preset performance filtering strategy includes:
[0096] Get the preset test data package.
[0097] In this step, the test data packet is a pre-built data packet for testing the IP address. By writing a script or program, the test data packet is sent to each candidate IP (i.e., the first IP address) address regularly (such as every second, every minute, etc.). The test data packet may contain a specific tag or sequence number so that it can be identified and the delay can be calculated when it is received.
[0098] Based on the test data packet, each of the first IP addresses is tested and processed respectively to obtain delay data, jitter data and packet loss rate of each of the first IP addresses.
[0099] In this step, latency refers to the time it takes for a data packet to travel from the sender to the receiver and back to the sender. Jitter refers to the degree of variation in latency, i.e., the difference between the arrival times of consecutive data packets. Packet loss rate refers to the proportion of data packets lost during transmission to the total number of data packets. Specifically, the sending time is recorded while sending the data packet. When the data packet returns, the receiving time is recorded and the latency is calculated. The packet loss rate is calculated by checking whether the content of the data packet is complete. Jitter can be calculated by sending the data packet multiple times and measuring the latency.
[0100] Obtain distance information of each of the first IP addresses corresponding to the device.
[0101] In this step, an IP address geographic location database (such as MaxMind GeoIP) can be used to convert the application's IP address into a geographic location (such as country, city, etc.). Alternatively, geographic location information (such as GPS data) can be directly obtained from the device. Then, a geographic distance calculation algorithm (such as the Haversine formula) is used to calculate the distance between the terminal's geographic location and the geographic location of each candidate IP address (i.e., the first IP address) to obtain the above distance information.
[0102] Based on the delay data, jitter data, packet loss rate and distance information of each of the first IP addresses, a priority score value of each of the first IP addresses is generated.
[0103] In this step, the specific implementation process of generating the priority score value of each first IP address based on the delay data, jitter data, packet loss rate and distance information of each first IP address will be further described in detail in subsequent specific embodiments of the present application and will not be elaborated here.
[0104] A second IP address with the smallest priority score value is selected from all the first IP addresses.
[0105] In this step, the priority score values of all the first IP addresses can be numerically compared to select the second IP address with the smallest priority score value from all the first IP addresses.
[0106] The second IP address is used as the target IP address.
[0107] In this embodiment, a preset test data packet is obtained; then each first IP address is tested and processed based on the test data packet to obtain the delay data, jitter data and packet loss rate of each first IP address; then the distance information of each first IP address corresponding to the device is obtained; subsequently, based on the delay data, jitter data, packet loss rate and distance information of each first IP address, a priority score value of each first IP address is generated; further, the second IP address with the smallest priority score value is filtered out from all the first IP addresses; finally, the second IP address is used as the target IP address. The present application tests and processes each first IP address based on the use of a test data packet, obtains the delay data, jitter data and packet loss rate of each first IP address, and obtains the distance information of each first IP address corresponding to the device, and then generates a priority score value for each first IP address based on the delay data, jitter data, packet loss rate and distance information of each first IP address, and subsequently selects the second IP address with the smallest priority score value from all the first IP addresses as the final target IP address, thereby selecting the target IP address with the best combination of network quality indicators and distance performance from multiple first IP addresses, effectively ensuring the accuracy and intelligence of the obtained target IP address, which is beneficial to the subsequent network connection based on the target IP address, and can effectively improve the speed of the network connection.
[0108] Optionally, generating a priority score value of each first IP address based on delay data, jitter data, packet loss rate, and distance information of each first IP address includes:
[0109] Get the specified delay data, specified jitter data, specified packet loss rate, and specified distance information corresponding to the specified IP address.
[0110] In this step, the above-mentioned designated IP address is any one of all the first IP addresses.
[0111] Obtain a first weight, a second weight, a third weight, and a fourth weight corresponding to the delay index, the jitter index, the packet loss rate index, and the distance index, respectively.
[0112] In this step, weight calculation processing can be performed on all indicator factors (delay indicator, jitter indicator, packet loss rate indicator and distance indicator) corresponding to the generated priority score value based on the corresponding weight calculation processing steps in the preset weight setting algorithm, thereby obtaining the first weight, second weight, third weight and fourth weight corresponding to the delay indicator, jitter indicator, packet loss rate indicator and distance indicator respectively.
[0113] Call the preset priority score calculation formula.
[0114] In this step, the priority score calculation formula may specifically include: S=a*X+b*Y+c*Z+d*W, wherein S is the priority score value, X is the delay data, a is the first weight, Y is the jitter data, b is the second weight, Z is the packet loss rate, c is the third weight, W is the distance information, and d is the fourth weight.
[0115] Based on the priority score calculation formula, the specified delay data, the specified jitter data, the specified packet loss rate, the specified distance information, the first weight, the second weight, the third weight and the fourth weight are calculated and processed to obtain a corresponding calculation result.
[0116] In this step, the specified delay data, the specified jitter data, the specified packet loss rate, the first weight, the second weight, the third weight and the fourth weight can be substituted into the corresponding positions in the priority score calculation formula to perform calculation processing, thereby obtaining the corresponding calculation result.
[0117] The calculation result is used as the designated priority score value of the designated IP address.
[0118] In this embodiment, the specified delay data, specified jitter data, specified packet loss rate and specified distance information corresponding to the specified IP address are obtained; then the first weight, second weight, third weight and fourth weight corresponding to the delay index, jitter index, packet loss rate index and distance index are obtained respectively; then the preset priority score calculation formula is called; subsequently, the specified delay data, the specified jitter data, the specified packet loss rate, the specified distance information, the first weight, the second weight, the third weight and the above-mentioned fourth weight are calculated and processed based on the priority score calculation formula to obtain the corresponding calculation result; and the calculation result is used as the specified priority score value of the specified IP address. The present application obtains the specified delay data, specified jitter data, specified packet loss rate and specified distance information corresponding to the specified IP address, that is, based on the first weight, second weight, third weight and fourth weight corresponding to the delay index, jitter index, packet loss rate index and distance index respectively, the priority score calculation formula is called to calculate and process the specified delay data, specified jitter data, specified packet loss rate and specified distance information, so as to realize the rapid and accurate generation of the specified priority score value of the specified IP address, and effectively ensure the data accuracy of the generated specified priority score value. It is beneficial to subsequently screen all first IP addresses according to the obtained priority score value, thereby improving the accuracy and intelligence of the screened target IP address.
[0119] Optionally, before acquiring the first IP address corresponding to the network protocol stack and the target domain name from the preset memory cache, the method further includes:
[0120] Invoke the preset timer polling strategy.
[0121] In this step, the timer polling strategy includes: Use HTTP client libraries (such as OkHttp, Retrofit, etc.) to send requests to the HTTPDNS server to obtain the IP address of the corresponding domain name. Receive the response returned by the HTTPDNS server and parse the IP address in it. Perform validity checks on the returned IP address (such as checking the format, trying ping, etc.). Based on the test results, write the valid IP address to the disk cache and memory cache. Based on the TTL ( T i me toLive) value to set the polling interval of the timer.
[0122] Based on the timer polling strategy, an IP address corresponding to the target domain name is requested from a preset HTTPDNS server.
[0123] In this step, the timer polling strategy is started to request the IP address corresponding to the target domain name through the HTTPDNS server.
[0124] Receive the IP address returned by the HTTPDNS server, and perform validity verification on the IP address to obtain a corresponding verification result.
[0125] In this step, the validity check includes checking the format, trying ping, etc. The above verification result includes passing the validity check or failing the validity check.
[0126] Based on the verification result, a third IP address that passes the validity verification is screened out from all the IP addresses.
[0127] In this step, the third IP address refers to a valid IP address that has passed the validity check among all the IP addresses. In addition, the result is discarded for the IP address that has not passed the validity check, and the next polling is waited.
[0128] The third IP address is stored in the memory cache.
[0129] In this step, the third IP address that passes the validity check can be written into the memory cache, and the polling interval of the timer can be set according to TTL (Time to Live) to ensure that the IP address in the memory cache is always the latest.
[0130] In this embodiment, by calling a preset timer polling strategy; then based on the timer polling strategy, requesting the IP address corresponding to the target domain name from the preset HTTPDNS server; then receiving the IP address returned by the HTTPDNS server, and performing a validity check on the IP address to obtain a corresponding check result; subsequently, based on the check result, filtering out a third IP address that passes the validity check from all the IP addresses; finally, storing the third IP address in the memory cache. This application, based on the use of a timer polling strategy, requests the IP address corresponding to the target domain name from the preset HTTPDNS server, and performs a validity check on the IP address returned by the HTTPDNS server to obtain a corresponding check result, and then based on the check result, filters out the third IP address that passes the validity check from all IP addresses and stores it in the memory cache, so that the subsequent use based on the memory cache enables the application to directly use the IP requested by the HTTPDNS server when it starts, which is beneficial to improve the success rate and speed of network requests and enhance user experience.
[0131] Optionally, after establishing a network connection with a preset server based on the target IP address and sending a corresponding network request to the server, the method further includes:
[0132] When a network response corresponding to the network request returned by the server is received, whether the network request is successful is determined based on the network response.
[0133] In this step, it is possible to determine whether the network request is successful based on the status code of the network response or the content of the response body. If the status code is 4xx or 5xx, the network request is determined to have failed, otherwise the network request is determined to have succeeded. For example, an HTTP GET request is sent to 192.168.1.1 / api / data. If the returned status code is 200, it indicates that the request is successful. If the returned status code is 500, it indicates that the server has an internal error and the request has failed.
[0134] If the network request is successful, the trustworthiness of the target IP address is enhanced based on a preset enhancement strategy.
[0135] In this step, the above-mentioned promotion strategy includes counter increment processing. For example, a simple counter is used to record the number of successful requests. Each time a request is successful, the value of the counter is increased by 1. Alternatively, the trust level can be the ratio of the counter value divided by the total number of requests.
[0136] If the network request fails, it is determined whether the time between the current error corresponding to the target IP address and the last error is greater than a preset time threshold.
[0137] In this step, if the network request fails, the current time is obtained and the time difference between the current error and the last error is calculated. If the time difference is greater than the set time threshold (for example, 5 minutes), the trust of the IP address is reduced. If the time difference is less than or equal to the set time threshold, the error is ignored and no trust adjustment is made.
[0138] If so, the trustworthiness of the target IP address is reduced based on a preset reduction strategy.
[0139] In this step, the policy content of the above reduction policy includes: each time a request fails, and if the time between the current error of the IP address and the last error is greater than a preset time threshold, the value of the IP address is reduced by 5%.
[0140] In this embodiment, when receiving the network response corresponding to the network request returned by the server, it is judged whether the network request is successful based on the network response; if the network request is successful, the trust of the target IP address is improved based on the preset improvement strategy; if the network request fails, it is judged whether the time from the current error corresponding to the target IP address to the last error is greater than the preset time threshold; if so, the trust of the target IP address is reduced based on the preset reduction strategy. When the application receives the network response corresponding to the network request returned by the server, it will intelligently judge whether the network request is successful based on the network response; if the network request is detected to be successful, the trust of the target IP address will be improved based on the use of the improvement strategy; and if the network request is detected to be failed, it will further judge whether the time from the current error corresponding to the target IP address to the last error is greater than the preset time threshold; if it is greater than the preset time threshold, the trust of the target IP address will be reduced based on the preset reduction strategy, thereby automatically and intelligently realizing the evaluation and management of the trust of the target IP address, which is conducive to optimizing the performance and reliability of network communication.
[0141] Optionally, after reducing the trustworthiness of the target IP address based on a preset reduction strategy, the method further includes:
[0142] Obtain the current trustworthiness of the target IP address.
[0143] In this step, the current trustworthiness of the target IP address can be obtained by querying the trustworthiness of the target IP address.
[0144] Determine whether the current trust level is less than a preset trust level threshold.
[0145] In this step, there is no specific limitation on the value of the above trust threshold, which can be set according to actual business needs, for example, it can be set to 60%.
[0146] If so, release the network connection between the target IP address and the server.
[0147] In this step, if it is detected that the current trust of the target IP address is less than a preset trust threshold, the process of replacing the IP address to re-establish the network connection will be intelligently executed.
[0148] A fourth IP address whose trustworthiness meets a preset selection condition is selected from the memory cache.
[0149] In this step, the above-mentioned preset selection condition may specifically be a condition for screening the highest trustworthiness.
[0150] A network connection is established with the server based on the fourth IP address, and a corresponding network request is sent to the server.
[0151] In this step, the above-mentioned processing process of establishing a network connection with the server based on the fourth IP address and sending a corresponding network request to the server can refer to the above-mentioned processing process of establishing a network connection with the preset server based on the target IP address and sending a corresponding network request to the server, and no further details will be given here.
[0152] In this embodiment, the current trust of the target IP address is obtained; then it is determined whether the current trust is less than a preset trust threshold; if so, the network connection between the target IP address and the server is released; then a fourth IP address whose trust meets the preset selection conditions is screened out from the memory cache; subsequently a network connection with the server is established based on the fourth IP address, and a corresponding network request is sent to the server. This application obtains the current trust of the target IP address. If it is detected that the current trust of the target IP address is less than the preset trust threshold, the network connection between the target IP address and the server is automatically and intelligently released, and a fourth IP address whose trust meets the preset selection conditions is screened out from the memory cache, and then a network connection with the server is established based on the fourth IP address, and a corresponding network request is sent to the server, effectively managing network requests dynamically based on the use of trust, thereby improving the stability and reliability of the network connection.
[0153] Optionally, after determining whether the target domain name is configured to use HTTPDNS, the method further includes:
[0154] If the target domain name is not configured to use HTTPDNS, the preset original network link is called.
[0155] In this step, the above-mentioned original network link refers to LocalDNS.
[0156] The network request is sent to the server based on the original network link.
[0157] In this step, the domain name is resolved by using LocalDNS. Then the network connection is established using the resolved IP address (or domain name). A network request is sent to the server and the server responds. The established network connection will be used to send and receive data.
[0158] In this embodiment, if it is detected that the target domain name is not configured to use HTTPDNS, the preset original network link is called; and the network request is subsequently sent to the server based on the original network link. When the present application detects that the target domain name is not configured to use HTTPDNS, the preset original network link is automatically and intelligently called to send the network request to the server, thereby effectively ensuring the normal progress of the network request when HTTPDNS cannot be used.
[0159] Further references Figure 3 , as a response to the above Figure 2 In order to realize the method shown in the figure, the present application provides an embodiment of a network request processing device 300, which is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0160] An embodiment of the present invention provides a network request processing device 300, and the network request processing device 300 includes:
[0161] A first acquisition module 310 is used to acquire a target domain name corresponding to the application when detecting that the application is started;
[0162] A first determination module 320 is used to determine whether the target domain name is configured to use HTTPDNS;
[0163] The second determination module 330 is used to obtain the network protocol stack supported by the device and network corresponding to the application, and determine whether the network protocol stack includes the target network protocol stack;
[0164] A second acquisition module 340 is used to acquire, if yes, a first IP address corresponding to the network protocol stack and the target domain name from a preset memory cache;
[0165] A third determination module 350 is used to determine whether the first IP address contains multiple addresses;
[0166] A screening module 360, configured to, if yes, screen out the target IP address from all the first IP addresses based on a preset performance screening strategy;
[0167] The first processing module 370 is used to establish a network connection with a preset server based on the target IP address and send a corresponding network request to the server.
[0168] Optionally, the screening module 360 includes:
[0169] A first acquisition submodule is used to acquire a preset test data packet;
[0170] A test submodule, used to perform test processing on each of the first IP addresses based on the test data packet to obtain delay data, jitter data and packet loss rate of each of the first IP addresses;
[0171] A second acquisition submodule is used to obtain distance information of each of the first IP addresses corresponding to the device;
[0172] A generating submodule, configured to generate a priority score value for each of the first IP addresses based on the delay data, jitter data, packet loss rate, and distance information of each of the first IP addresses;
[0173] A screening submodule, used for screening out the second IP address with the smallest priority score value from all the first IP addresses;
[0174] A determination submodule is used to use the second IP address as the target IP address.
[0175] Optionally, the generating submodule includes:
[0176] A first acquisition subunit, configured to acquire specified delay data, specified jitter data, specified packet loss rate, and specified distance information corresponding to a specified IP address; wherein the specified IP address is any one of all the first IP addresses;
[0177] A second acquisition subunit is used to acquire a first weight, a second weight, a third weight and a fourth weight corresponding to the delay index, the jitter index, the packet loss rate index and the distance index respectively;
[0178] A calling subunit, used to call a preset priority score calculation formula;
[0179] a calculation subunit, configured to calculate and process the specified delay data, the specified jitter data, the specified packet loss rate, the specified distance information, the first weight, the second weight, the third weight, and the fourth weight based on the priority score calculation formula to obtain a corresponding calculation result;
[0180] A determination subunit is used to use the calculation result as a designated priority score value of the designated IP address.
[0181] Optionally, the network request processing device 300 further includes:
[0182] A first calling module, used for calling a preset timer polling strategy;
[0183] A request module, used for requesting an IP address corresponding to the target domain name from a preset HTTPDNS server based on the timer polling strategy;
[0184] A verification module, used for receiving the IP address returned by the HTTPDNS server, and performing validity verification on the IP address to obtain a corresponding verification result;
[0185] A second screening module, used for screening out a third IP address that passes the validity check from all the IP addresses based on the check result;
[0186] A storage module is used to store the third IP address in the memory cache.
[0187] Optionally, the network request processing device 300 further includes:
[0188] a fourth determination module, configured to, upon receiving a network response corresponding to the network request returned by the server, determine whether the network request is successful based on the network response;
[0189] An enhancement module, configured to enhance the trustworthiness of the target IP address based on a preset enhancement strategy if the network request is successful;
[0190] A fifth judgment module, for judging, if the network request fails, whether the time between the current error corresponding to the target IP address and the last error is greater than a preset time threshold;
[0191] A reduction module is used to reduce the trustworthiness of the target IP address based on a preset reduction strategy.
[0192] Optionally, the network request processing device 300 further includes:
[0193] A third acquisition module is used to obtain the current trust of the target IP address;
[0194] A sixth judgment module, used to judge whether the current trust level is less than a preset trust level threshold;
[0195] A release module, used for releasing the network connection between the target IP address and the server if yes;
[0196] A third screening module, used to screen out a fourth IP address whose trustworthiness meets a preset selection condition from the memory cache;
[0197] The second processing module is used to establish a network connection with the server based on the fourth IP address and send a corresponding network request to the server.
[0198] Optionally, the network request processing device 300 further includes:
[0199] A second calling module is used to call a preset original network link if the target domain name is not configured to use HTTPDNS;
[0200] The third processing module is used to send the network request to the server based on the original network link.
[0201] To solve the above technical problems, the present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.
[0202] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 4 with components 41-43, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.
[0203] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.
[0204] The memory 41 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 41 can be an internal storage unit of the computer device 4, such as a hard disk or memory of the computer device 4. In other embodiments, the memory 41 can also be an external storage device of the computer device 4, such as a plug-in hard disk equipped on the computer device 4, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. Of course, the memory 41 can also include both the internal storage unit of the computer device 4 and its external storage device. In this embodiment, the memory 41 is generally used to store the operating system and various application software installed on the computer device 4, such as the program code of the method for processing network requests, etc. In addition, the memory 41 can also be used to temporarily store various types of data that have been output or are to be output.
[0205] The processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 42 is generally used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is used to run the program code stored in the memory 41 or process data, such as running the program code of the method for processing the network request.
[0206] The network interface 43 may include a wireless network interface or a wired network interface. The network interface 43 is generally used to establish a communication connection between the computer device 4 and other electronic devices.
[0207] The present application also provides another implementation, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores the application crash processing program, and the application crash processing program can be executed by at least one processor to enable the at least one processor to perform the steps of the network request processing method as described above.
[0208] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware online platform, and of course, by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0209] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0210] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.
Claims
1. A method for processing a network request, characterized in that: include: When detecting that an application is started, obtaining a target domain name corresponding to the application; Determine whether the target domain name is configured to use HTTPDNS; If so, obtaining a network protocol stack supported by the device and network corresponding to the application, and determining whether the network protocol stack includes a target network protocol stack; If so, obtaining a first IP address corresponding to the network protocol stack and the target domain name from a preset memory cache; Determine whether the first IP address contains multiple addresses; If so, filter out the target IP address from all the first IP addresses based on a preset performance screening strategy; A network connection is established with a preset server based on the target IP address, and a corresponding network request is sent to the server.
2. The method according to claim 1, characterized in that The step of filtering out a target IP address from all the first IP addresses based on a preset performance screening strategy includes: Get the preset test data package; Performing test processing on each of the first IP addresses based on the test data packets to obtain delay data, jitter data, and packet loss rate of each of the first IP addresses; Obtaining distance information of each of the first IP addresses corresponding to the device; Generate a priority score value for each of the first IP addresses based on the delay data, jitter data, packet loss rate, and distance information of each of the first IP addresses; Filter out the second IP address with the smallest priority score value from all the first IP addresses; The second IP address is used as the target IP address.
3. The method according to claim 2, characterized in that The generating a priority score value of each first IP address based on the delay data, jitter data, packet loss rate and distance information of each first IP address includes: Obtaining specified delay data, specified jitter data, specified packet loss rate, and specified distance information corresponding to a specified IP address; wherein the specified IP address is any one of all the first IP addresses; Obtaining a first weight, a second weight, a third weight, and a fourth weight corresponding to the delay index, the jitter index, the packet loss rate index, and the distance index, respectively; Call the preset priority score calculation formula; Based on the priority score calculation formula, the specified delay data, the specified jitter data, the specified packet loss rate, the specified distance information, the first weight, the second weight, the third weight and the fourth weight are calculated and processed to obtain a corresponding calculation result; The calculation result is used as the designated priority score value of the designated IP address.
4. The method according to claim 1, characterized in that: Before acquiring the first IP address corresponding to the network protocol stack and the target domain name from the preset memory cache, the method further includes: Call the preset timer polling strategy; Based on the timer polling strategy, requesting the IP address corresponding to the target domain name from a preset HTTPDNS server; Receive the IP address returned by the HTTPDNS server, and perform validity verification on the IP address to obtain a corresponding verification result; Filtering out a third IP address that passes the validity check from all the IP addresses based on the check result; The third IP address is stored in the memory cache.
5. The method according to claim 1, characterized in that: After establishing a network connection with a preset server based on the target IP address and sending a corresponding network request to the server, the method further includes: When receiving a network response corresponding to the network request returned by the server, determining whether the network request is successful based on the network response; If the network request is successful, the trustworthiness of the target IP address is enhanced based on a preset enhancement strategy; If the network request fails, determine whether the time between the current error corresponding to the target IP address and the last error is greater than a preset time threshold; If so, the trustworthiness of the target IP address is reduced based on a preset reduction strategy.
6. The method according to claim 5, characterized in that After reducing the trustworthiness of the target IP address based on the preset reduction strategy, the method further includes: Obtaining the current trustworthiness of the target IP address; Determining whether the current trust level is less than a preset trust level threshold; If yes, release the network connection between the target IP address and the server; Filtering out a fourth IP address whose trustworthiness meets a preset selection condition from the memory cache; A network connection is established with the server based on the fourth IP address, and a corresponding network request is sent to the server.
7. The method according to claim 1, characterized in that After determining whether the target domain name is configured to use HTTPDNS, the method further includes: If the target domain name is not configured to use HTTPDNS, then the preset original network link is called; The network request is sent to the server based on the original network link.
8. A network request processing device, characterized in that: include: A first acquisition module, configured to acquire a target domain name corresponding to the application when detecting that the application is started; A first determination module is used to determine whether the target domain name is configured to use HTTPDNS; A second determination module is used to, if yes, obtain a network protocol stack supported by the device and network corresponding to the application, and determine whether the network protocol stack includes a target network protocol stack; A second acquisition module, configured to, if yes, acquire a first IP address corresponding to the network protocol stack and the target domain name from a preset memory cache; A third judgment module is used to judge whether the first IP address contains multiple addresses; A first screening module, configured to, if yes, screen out a target IP address from all the first IP addresses based on a preset performance screening strategy; The first processing module is used to establish a network connection with a preset server based on the target IP address and send a corresponding network request to the server.
9. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method for processing a network request as claimed in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for processing a network request according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Dual-stack network adaptive scheduling method and system based on DNS analysis strategy
CN120017715A
Dual-stack network adaptive scheduling method and system based on DNS resolution strategy
CN120017715B