Server switching method and device and electronic equipment
By dynamically adjusting the switching parameters of the DHCP server, the problem of the inability to adapt to the dynamic changes of the DHCP server and network environment in the prior art is solved, and the reliability of the switching of the DHCP server and the stability of the network environment are improved.
Patent Information
- Application Number
- CN202510115143.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-23
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2045-01-23
AI Technical Summary
In the prior art, the switching parameters of the DHCP server (such as selecting priority and switching wait time) are fixed parameters pre-configured manually, and cannot adapt to the dynamic changes of the DHCP server and networking environment, resulting in the possible switching to the DHCP server with poor stability, affecting the reliability of the switching.
By obtaining the number of switched times, packet return speed information and network stability parameters of each DHCP server in a specified historical time period, dynamically adjusting its switching parameters to adapt to the dynamic stability of the DHCP server and networking environment.
It effectively avoids switching to a DHCP server with poor stability, improves the reliability of the DHCP server switching, and thus improves the reliability of the networking environment.
Smart Images

Figure CN119892795A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a server switching method, device and electronic device. Background Art
[0002] The DHCP protocol is usually used in a local area network environment. Its main function is to centrally manage and allocate address information such as IP addresses, so that hosts in the network environment can dynamically obtain address information such as IP addresses. DHCP is the abbreviation of Dynamic Host Configuration Protocol; IP is the abbreviation of Internet Protocol.
[0003] In a Client-Relay-Server (CRS) networking environment, when a DHCP relay server (also known as Relay) receives an address request message sent by a client (such as the above-mentioned host), it selects the DHCP server (also known as server) with the highest ranking from each DHCP server as the current DHCP server according to the pre-configured order of each DHCP server, and sends the message to the current DHCP server, so that the current DHCP server returns the corresponding address information to the client based on the message; based on this, if no response result returned by the current DHCP server is received after a set switching waiting time (such as 10 seconds, etc.), then according to the above-mentioned order, it switches from the current DHCP server to the next DHCP server of the current DHCP server, that is, the next DHCP server is used as the current DHCP server, and sends the message to the current DHCP server; and so on, until the address information returned by the current DHCP server based on the message is received.
[0004] However, in the above application process, the order of each DHCP server and the set switching waiting time are fixed parameters pre-configured manually, while the stability of each DHCP server and the stability of the networking environment in which it is located are dynamically changing. The manually pre-configured order of priority and the set switching waiting time cannot be applied to the DHCP servers and networking environments with dynamically changing stability. In this way, when switching DHCP servers, it may be possible to switch to a DHCP server with poor stability, affecting the reliability of DHCP server switching, thereby affecting the reliability of the networking environment in which it is located. Summary of the invention
[0005] In view of this, the present application provides a server switching method, device and electronic device to improve the reliability of DHCP server switching.
[0006] The embodiment of the present application provides a server switching method, which is applied to an electronic device, wherein the electronic device establishes connections with N Dynamic Host Configuration Protocol DHCP servers respectively, where N is greater than 1; the method includes:
[0007] Obtain the number of times each DHCP server has been switched within a specified historical time period, the latest recorded packet return speed information of each DHCP server, and the latest recorded historical network stability parameters;
[0008] According to the information of the number of times each DHCP server is switched within the specified historical time period and the latest recorded packet return speed information of each DHCP server, a first adjustment coefficient for adjusting the switching parameters of each DHCP server is correspondingly determined, where the switching parameters include a selection priority and a switching waiting time;
[0009] According to the first adjustment coefficient of each DHCP server and the latest recorded historical network stability parameter, the selection priority of each DHCP server is correspondingly adjusted;
[0010] The switching waiting time of each DHCP server is adjusted accordingly according to the latest recorded historical network stability parameter and the current network stability parameter, and the current network stability parameter is determined depending on the first adjustment coefficient of each DHCP server.
[0011] The embodiment of the present application also provides a server switching device, which is applied to an electronic device, and the electronic device establishes connections with N dynamic host configuration protocol DHCP servers respectively, where N is greater than 1; the device includes:
[0012] An acquisition module is used to acquire the number of times each DHCP server is switched within a specified historical time period, the latest recorded packet return speed information of each DHCP server, and the latest recorded historical network stability parameters;
[0013] A determination module, configured to determine a first adjustment coefficient for adjusting a switching parameter of each DHCP server according to information on the number of times each DHCP server is switched within a specified historical time period and the latest recorded packet return speed information of each DHCP server, wherein the switching parameter includes a selection priority and a switching waiting time;
[0014] A first adjustment module, configured to adjust the selection priority of each DHCP server according to the first adjustment coefficient of each DHCP server and the latest recorded historical network stability parameter;
[0015] The second adjustment module is used to adjust the switching waiting time of each DHCP server according to the latest recorded historical network stability parameter and the current network stability parameter, and the current network stability parameter is determined by the first adjustment coefficient of each DHCP server.
[0016] The present application also provides an electronic device, the electronic device comprising:
[0017] Processor; and
[0018] A computer-readable storage medium stores computer program instructions, which, when executed by a processor, cause the processor to execute the steps of the above method.
[0019] An embodiment of the present application further provides a computer-readable storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the processor executes the steps in the above method.
[0020] It can be seen from the above technical solution that in the embodiment of the present application, by utilizing the number of times each DHCP server has been switched within a specified historical time period, the latest recorded packet reply speed information of each DHCP server, the latest recorded historical network stability parameters, and the current network stability parameters, the switching parameters of each DHCP server are dynamically adjusted, that is, the priority and switching waiting time are selected so that the adjusted switching parameters of each DHCP server are as suitable as possible for each DHCP server and networking environment with dynamically changing stability. This can effectively avoid the situation where switching to a DHCP server with poor stability may occur when switching DHCP servers, thereby improving the reliability of DHCP server switching, and then improving the reliability of the networking environment in which each DHCP server is located. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The accompanying drawings, which are incorporated in the specification and constitute a part of this application, illustrate embodiments consistent with the application and, together with the description, serve to explain the principles of the application.
[0022] Figure 1 A schematic diagram of the method flow provided in an embodiment of the present application.
[0023] Figure 2 Another method flow chart provided in the embodiment of the present application.
[0024] Figure 3 A flowchart of another method provided in an embodiment of the present application.
[0025] Figure 4 A schematic diagram of the device structure provided in an embodiment of the present application.
[0026] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0027] As described above, in the related art, in a CRS networking environment, when a DHCP relay server receives an address request message sent by a client, it will select a DHCP server for processing the address request message according to the pre-configured sequence of DHCP servers and the set waiting time. However, this will lead to the following problems:
[0028] (1) In actual applications, the stability of the network link between the DHCP relay server and each DHCP server (referred to as server) is inconsistent. For example, assume that the DHCP relay server is connected to three DHCP servers (referred to as server 1, server 2, and server 3), where the pre-configured order of the servers is server 1, server 2, and server 3; and the current order of the servers according to the stability of the network link with the DHCP relay server is server 3, server 1, and server 2. If the server is switched every time according to the pre-configured order, it may be switched to a server with a worse network link stability, thereby reducing the reliability of server switching.
[0029] (2) The stability of the same server at different times (i.e., the stability of the device itself) is also changing dynamically. If the server is switched according to the pre-configured order, it may be switched to a server with worse stability, thus reducing the reliability of server switching;
[0030] (3) Different servers have different network links with DHCP relay servers and different stability. Servers with higher stability do not need too long a switching waiting time, while servers with lower stability need to be given enough message processing time, that is, a relatively longer switching waiting time. The use of pre-configured fixed switching waiting time is not applicable to servers and networking environments with dynamically changing stability, and will reduce the reliability of server switching.
[0031] To solve the above problems, an embodiment of the present application provides a server switching method, which dynamically adjusts the switching parameters of each DHCP server, that is, the selection priority and the switching waiting time, so that the adjusted switching parameters of each DHCP server are as suitable as possible for each DHCP server and the networking environment with dynamically changing stability. This can effectively avoid the situation where a DHCP server with poor stability may be switched when switching the DHCP server, thereby improving the reliability of DHCP server switching, and further improving the reliability of the networking environment in which each DHCP server is located.
[0032] In order to enable those skilled in the art to better understand the technical solutions provided by the embodiments of the present application and to make the above-mentioned purposes, features and advantages of the embodiments of the present application more obvious and understandable, the technical solutions in the embodiments of the present application are further described in detail below in conjunction with the accompanying drawings.
[0033] See also Figure 1 , Figure 1 A flowchart of a method provided in an embodiment of the present application. The method is applied to an electronic device. As an embodiment, the electronic device establishes connections with N DHCP servers respectively, where N is greater than 1; the electronic device may be, for example, a DHCP relay server, etc., which is not specifically limited in this embodiment.
[0034] like Figure 1 As shown, the process may include the following steps:
[0035] Step 101, obtaining information on the number of times each DHCP server is switched within a specified historical time period, the latest recorded packet return speed information of each DHCP server, and the latest recorded historical network stability parameters.
[0036] In this embodiment, as an embodiment, in order to make the switching parameters of each DHCP server suitable for DHCP servers with dynamically changing stability and the networking environment in which each DHCP server is located, the switching parameters of N DHCP servers can be adjusted at set adjustment times. Here, the setting adjustment time can be flexibly set based on actual application requirements, such as 10 minutes, 1 hour or 2 hours, etc., which is not specifically limited in this embodiment. Based on this, when it is determined that the switching parameters of N DHCP servers need to be adjusted, the number of times each DHCP server is switched within a specified historical time period, the latest recorded packet return speed information of each DHCP server, and the latest recorded historical network stability parameters are first obtained for subsequent adjustment of the switching parameters of each DHCP server. As for the specific content of the switching parameters, an example will be described below, which will not be repeated here.
[0037] In this embodiment, as an embodiment, the above-mentioned specified historical time period can be, for example: a time period with the moment when the switching parameters of N DHCP servers need to be adjusted as the end moment and the duration being the same as the above-mentioned set adjustment time; this embodiment does not specifically limit this and can be flexibly set based on actual application requirements.
[0038] In this embodiment, the switching times information of any DHCP server indicates the number of times the DHCP server has been switched. Based on this, as an embodiment, for any DHCP server, within a specified historical time period, if it is found that a DHCP server other than the DHCP server has switched to the DHCP server, the sum of the latest recorded number of times the DHCP server has been switched and the set value is used as the number of times the DHCP server has been switched; the set value here can be, for example, 1. It should be noted that at the start time of the above-mentioned specified historical time period, the number of times the DHCP server has been switched is the initial value, and the initial value here can be, for example, 0.
[0039] In this embodiment, the packet return speed information of any DHCP server indicates the packet return speed of the DHCP. The packet return speed of any DHCP server is determined according to the packet return time of the DHCP server. For example, the packet return speed of any DHCP server may be a ratio of 1 to the packet return time of the DHCP server, which is not specifically limited here. The packet return time of the DHCP server may refer to the time period between the time when the address request message is sent from the sender and the time when the DHCP server returns a response result based on the address request message.
[0040] Step 102, according to the information of the number of times each DHCP server is switched in a specified historical time period and the latest recorded packet return speed information of each DHCP server, a first adjustment coefficient for adjusting the switching parameters of each DHCP server is correspondingly determined, and the switching parameters include a selection priority and a switching waiting time.
[0041] In this embodiment, the first adjustment coefficient for adjusting the switching parameters of the DHCP server can be understood as a parameter associated with the device stability of the DHCP server. The higher the device stability of the DHCP server, the higher the first adjustment coefficient of the DHCP server, and the lower the device stability of the DHCP server, the lower the first adjustment coefficient of the DHCP server.
[0042] For any DHCP server, if the DHCP server is switched a large number of times and the packet reply speed is slow (that is, the smaller the packet reply speed value is), it means that the device stability of the DHCP server is low, and the first adjustment coefficient of the DHCP server will be low in this case; and if the DHCP server is switched a small number of times and the packet reply speed is fast (that is, the larger the packet reply speed value is), it means that the device stability of the DHCP server is high, and the first adjustment coefficient of the DHCP server will be high in this case. Based on this, as an embodiment, the first adjustment coefficient of any DHCP server in this embodiment is negatively correlated with the number of times the DHCP server is switched in the specified historical time period, and is positively correlated with the latest recorded packet reply speed information of the DHCP server.
[0043] In this embodiment, in this step, the first adjustment coefficient for adjusting the switching parameters of each DHCP server is determined according to the number of times each DHCP server is switched within a specified historical time period and the latest recorded packet return speed information of each DHCP server. There are many ways to implement it. For example, as an embodiment, for each DHCP server, the number of times the DHCP server is switched within a specified historical time period and the latest recorded packet return speed information of each DHCP server can be input into a preset function for calculating the first adjustment coefficient to obtain the first adjustment coefficient for adjusting the switching parameters of the DHCP server.
[0044] Based on the above description, the function for calculating the first adjustment coefficient preset in this embodiment can be flexibly set according to the first adjustment coefficient of any of the above-mentioned DHCP servers, the negative correlation between the information of the number of times the DHCP server is switched in a specified historical time period, and the positive correlation between the information of the latest recorded packet return speed of the DHCP server. For example, as an embodiment, the above-mentioned preset function for calculating the first adjustment coefficient can be: Rs=Vs / (Ns+1), where Rs represents the first adjustment coefficient of the DHCP server, Vs represents the packet return speed of the DHCP server, and Ns represents the number of times the DHCP server is switched.
[0045] Step 103: According to the first adjustment coefficient of each DHCP server and the latest recorded historical network stability parameter, the selection priority of each DHCP server is correspondingly adjusted.
[0046] In this embodiment, in order to effectively ensure that each DHCP server after adjusting the switching parameters is more suitable for DHCP servers with dynamically changing stability and the network environment in which each DHCP server is located, when updating the selection priority of each DHCP server, at least the device stability of each DHCP server and the stability of the network environment in which each DHCP server is located need to be considered. The above network stability parameter is used to indicate the stability of the network in which the N DHCP servers are located.
[0047] Based on this, for any DHCP server, this embodiment can adjust the selection priority of the DHCP server according to the parameter associated with the device stability of the DHCP server, that is, the first adjustment coefficient of the DHCP server, and the latest recorded historical network stability parameter, so that the adjusted selection priority of the DHCP server is more suitable for DHCP servers with dynamically changing stability and the network environment in which each DHCP server is located. This can effectively avoid the situation where a DHCP server with poor stability may be switched when switching the DHCP server, thereby improving the reliability of DHCP server switching, and then improving the reliability of the networking environment in which each DHCP server is located.
[0048] As for how to adjust the selection priority of each DHCP server according to the first adjustment coefficient of each DHCP server and the latest recorded historical network stability parameter in step 103, the following will give an example and will not be described here.
[0049] Step 104: According to the latest recorded historical network stability parameters and the current network stability parameters, the switching waiting time of each DHCP server is correspondingly adjusted.
[0050] Based on the above description, in this embodiment, in order to effectively ensure that each DHCP server after adjusting the switching parameters is more suitable for DHCP servers with dynamically changing stability and the network environment in which each DHCP server is located, when adjusting the switching waiting time of each DHCP server, it is also necessary to at least consider the device stability of each DHCP server and the stability of the network environment in which each DHCP server is located.
[0051] Based on this, for any DHCP server, this embodiment can adjust the switching waiting time of the DHCP server according to parameters associated with the device stability of the DHCP server and the stability of the network environment in which each DHCP server is located, that is, the latest recorded historical network stability parameters and the current network stability parameters, so that the adjusted switching waiting time of the DHCP server is more suitable for DHCP servers with dynamically changing stability and the network environment in which each DHCP server is located. This can effectively avoid the situation where switching to a DHCP server with poor stability may occur when switching DHCP servers, thereby improving the reliability of DHCP server switching, and then improving the reliability of the networking environment in which each DHCP server is located.
[0052] In this embodiment, as an embodiment, the current network stability parameter may be determined in the following manner: an average value of the first adjustment coefficients of each DHCP server is used as the current network stability parameter.
[0053] In this embodiment, as an embodiment, the above-adjusted switching parameters of the N DHCP servers can be used as the basis for each DHCP server to be selected for address request message processing. Specifically, when the DHCP relay server receives the address request message sent by the client, it first selects the DHCP server with the highest selection priority from each DHCP server as the current DHCP server based on the selection priority of each DHCP server, and sends the address request message to the current DHCP server; if it is found that the response result of the address request message (that is, the address information in response to the address request message, such as the IP address, etc.) has not been received after the switching waiting time of the current DHCP server, then based on the selection priority of each DHCP server, select the DHCP server with the highest selection priority from the current remaining unselected DHCP servers as the DHCP server to be switched to, use the selected DHCP server to be switched to as the current DHCP server, and return to the step of sending the address request message to the current DHCP server until the response result of the address request message returned by the current DHCP server is received.
[0054] As for how to adjust the switching waiting time of each DHCP server according to the latest recorded historical network stability parameters and the current network stability parameters in step 104, the following will give an example and will not be described here.
[0055] So far, completed Figure 1 The process shown.
[0056] pass Figure 1As can be seen from the illustrated process, in the embodiment of the present application, by utilizing the information on the number of times each DHCP server has been switched within a specified historical time period, the latest recorded packet reply speed information of each DHCP server, the latest recorded historical network stability parameters, and the current network stability parameters, the switching parameters of each DHCP server, that is, the selected priority and the switching waiting time, are dynamically adjusted, so that the adjusted switching parameters of each DHCP server are as suitable as possible for each DHCP server and the networking environment with dynamically changing stability. This can effectively avoid the situation where switching to a DHCP server with poor stability may occur when switching DHCP servers, thereby improving the reliability of DHCP server switching, and further improving the reliability of the networking environment in which each DHCP server is located.
[0057] The following describes how to adjust the selection priority of each DHCP server in step 103 according to the first adjustment coefficient of each DHCP server and the latest recorded historical network stability parameter:
[0058] In this embodiment, the selection priority of each DHCP server is adjusted accordingly according to the first adjustment coefficient of each DHCP server and the latest recorded historical network stability parameter. There are many ways to implement it in specific implementation; for example, as an embodiment, for each DHCP server, first, a first difference between the first adjustment coefficient of the DHCP server and the latest recorded historical network stability parameter is calculated; then, the first difference is input into a first specified function to obtain a second adjustment coefficient for adjusting the switching parameter of the DHCP server; finally, the second adjustment coefficient of the DHCP server is input into a second specified function to obtain a calculation result, and the calculation result is used as the selection priority of the DHCP server.
[0059] In this embodiment, the second adjustment coefficient for adjusting the switching parameters of the DHCP server can be understood as a parameter associated with the device stability of the DHCP server and / or the overall stability of the network environment in which the DHCP server is located. The higher the device stability of the DHCP server and / or the higher the overall stability of the network environment in which the DHCP server is located, the higher the second adjustment coefficient of the DHCP server. The lower the device stability of the DHCP server and / or the lower the overall stability of the network environment in which the DHCP server is located, the lower the second adjustment coefficient of the DHCP server.
[0060] For any DHCP server, the larger the first difference between the first adjustment coefficient of the DHCP server and the latest recorded historical network stability parameter, the higher the device stability of the DHCP server and / or the higher the overall stability of the network environment in which the DHCP server is located, and in this case the larger the second adjustment coefficient of the DHCP server; correspondingly, the smaller the first difference between the first adjustment coefficient of the DHCP server and the latest recorded historical network stability parameter, the lower the device stability of the DHCP server and / or the lower the overall stability of the network environment in which the DHCP server is located, and in this case the smaller the second adjustment coefficient of the DHCP server. Based on this, as an embodiment, for any DHCP server, the second adjustment coefficient of the DHCP server is positively correlated with the first difference between the first adjustment coefficient of the DHCP server and the latest recorded historical network stability parameter.
[0061] Based on the above description, the first specified function used to calculate the second adjustment coefficient in this embodiment can be flexibly set according to the positive correlation between the second adjustment coefficient of the DHCP server and the first difference between the first adjustment coefficient of the DHCP server and the latest recorded historical network stability parameter. For example, as an embodiment, the above-mentioned first specified function can be: Hs'=Hs+α(Rs-Ra), wherein Hs' represents the second adjustment coefficient currently calculated, Hs represents the latest recorded second adjustment coefficient, α represents a preset adjustment factor for indicating the adjustment range, α is greater than 0, and Ra represents the latest recorded historical network stability parameter.
[0062] In this embodiment, the selection priority of any DHCP server is associated with the device stability of the DHCP server and / or the overall stability of the network environment in which the DHCP server is located; specifically, the higher the device stability of the DHCP server and / or the higher the overall stability of the network environment in which the DHCP server is located, the higher the selection priority of the DHCP server, and the lower the device stability of the DHCP server and / or the lower the overall stability of the network environment in which the DHCP server is located, the lower the selection priority of the DHCP server. Based on this, the selection priority of any DHCP server in this embodiment is positively correlated with the second adjustment coefficient of the DHCP server; that is, the larger the second adjustment coefficient of the DHCP server, the higher the selection priority of the DHCP server, and the smaller the second adjustment coefficient of the DHCP server, the lower the selection priority of the DHCP server.
[0063] Based on the above description, the second specified function for determining the selection priority of the DHCP server in this embodiment can be flexibly set according to the positive correlation between the selection priority of the DHCP server and the second adjustment coefficient of the DHCP server. For example, as an embodiment, the second specified function can be: Ps'=Ps+β*Hs, where Ps' represents the currently determined selection priority of the DHCP server, Ps represents the most recently recorded selection priority of the DHCP server, β represents a preset priority adjustment factor, and β is greater than 0.
[0064] The following describes how to adjust the switching waiting time of each DHCP server according to the latest recorded historical network stability parameters and the current network stability parameters in the above step 103;
[0065] In this embodiment, there are many specific implementations for adjusting the switching waiting time of each DHCP server according to the latest recorded historical network stability parameters and the current network stability parameters; for example, as an embodiment, see Figure 2 The method flow chart shown in FIG. 1 may include the following steps:
[0066] Step 201: for each DHCP server, input the second adjustment coefficient of the DHCP server into a third specified function to obtain a first reference time for adjusting the switching waiting time of the DHCP server.
[0067] In this embodiment, as described above, the larger the second adjustment coefficient of the DHCP server is, the higher the equipment stability of the DHCP server is. At this time, if the DHCP server switches, it may be unrelated to the equipment stability of the DHCP server, but may be due to an equipment failure of the DHCP server. Therefore, there is no need to extend the switching waiting time due to the equipment stability of the DHCP server, that is, the switching waiting time of the DHCP server can be reduced; based on this, the larger the second adjustment coefficient of the DHCP server is, the smaller the first reference time used to adjust the switching waiting time of the DHCP server is.
[0068] Correspondingly, the smaller the second adjustment coefficient of the DHCP server is, the lower the equipment stability of the DHCP server is. At this time, if the DHCP server switches, it may be related to the equipment stability of the DHCP server. In this case, it is necessary to extend the switching waiting time due to the equipment stability of the DHCP server, that is, the switching waiting time of the DHCP server can be increased to reserve sufficient message processing time for the DHCP server as much as possible; based on this, the smaller the second adjustment coefficient of the DHCP server is, the larger the first reference time used to adjust the switching waiting time of the DHCP server is.
[0069] Based on the above description, in this embodiment, the first reference time used to adjust the switching waiting time of any DHCP server is negatively correlated with the second adjustment coefficient of the DHCP server.
[0070] In this embodiment, the third specified function for calculating the first reference time can be flexibly set according to the negative correlation between the first reference time for adjusting the switching waiting time of any DHCP server and the second adjustment coefficient of the DHCP server. For example, as an embodiment, the third specified function can be: Ts'=Ts-γ*Hs, where Ts' represents the first reference time of the currently calculated DHCP server, Ts represents the first reference time of the most recently recorded DHCP server, γ represents the preset first time adjustment factor, and γ is greater than 0.
[0071] Step 202: Calculate a second difference between the current network stability parameter and the latest recorded historical network stability parameter.
[0072] Step 203: Input the second difference into a fourth specified function to obtain a second reference time for adjusting the switching waiting time of the DHCP server.
[0073] In this embodiment, the larger the second difference is, the better the overall stability of the network environment in which the DHCP server is currently located. If the DHCP server switches at this time, it may be unrelated to the overall stability of the network environment in which the DHCP server is located, but may be due to a device failure in the DHCP server. In this case, there is no need to extend the switching waiting time due to the overall stability of the network environment in which the DHCP server is located, that is, the switching waiting time of the DHCP server can be reduced. Based on this, the larger the second difference is, the smaller the second reference time for adjusting the switching waiting time of the DHCP server is.
[0074] Correspondingly, the smaller the second difference is, the lower the overall stability of the network environment in which the DHCP server is currently located. Compared with the overall stability of the network environment in which the DHCP server was previously located, if the DHCP server switches at this time, it may be related to the overall stability of the network environment in which the DHCP server is located. In this case, it is necessary to extend the switching waiting time due to the overall stability of the network environment in which the DHCP server is located, that is, the switching waiting time of the DHCP server can be increased to reserve sufficient message processing time for the DHCP server as much as possible; based on this, the smaller the second difference is, the larger the second reference time used to adjust the switching waiting time of the DHCP server.
[0075] Based on the above description, in this embodiment, the second reference time used to adjust the switching waiting time of any DHCP server is negatively correlated with the second difference.
[0076] In this embodiment, the fourth designated function for calculating the second reference time can be flexibly set according to the negative correlation between the second reference time for adjusting the switching waiting time of any DHCP server and the second difference. For example, as an embodiment, the fourth designated function can be: Ta'=Ta-δ*(Ra'-Ra), wherein Ta' represents the second reference time of the currently calculated DHCP server, Ta represents the second reference time of the most recently recorded DHCP server, δ represents the preset second time adjustment factor, δ is greater than 0, Ra' represents the current network stability parameter, and Ra represents the most recently recorded historical network stability parameter.
[0077] Step 204: The sum of the first reference time and the second reference time is used as the switching waiting time of the DHCP server.
[0078] This completes the description of how to adjust the switching waiting time of each DHCP server according to the latest recorded historical network stability parameters and the current network stability parameters.
[0079] In order to facilitate understanding of the specific implementation process of the above server switching method, a specific embodiment is described below by way of example.
[0080] In this embodiment, the updating of the switching parameters of the server based on the Gradient Bandits algorithm is taken as an example for explanation. Among them, the Gradient Bandits algorithm can be understood as a policy optimization method based on reinforcement learning, which can be used to learn how to choose the most appropriate behavior (or action). It should be noted that this is only an exemplary description, and this embodiment does not specifically limit the algorithm used, and can be flexibly set based on actual application requirements.
[0081] For ease of understanding, here is an explanation of the relevant terms in the Gradient Bandits algorithm:
[0082] Reward: It can refer to a feedback signal used to evaluate the quality of a behavior (or action); the larger the reward value, the better the behavior.
[0083] Preference function: It is interrelated with the reward and has a positive correlation with the reward. Based on this, the preference function can refer to a function used to measure the quality of each action, which represents the expected reward when selecting a certain action (in the scenario of this embodiment, it can refer to selecting a certain server) in the current state.
[0084] In this embodiment, initially, based on the above-mentioned Gradient Bandits algorithm, the following initial parameters are pre-configured for each server connected to the DHCP relay server based on actual application requirements: initial switching waiting time T0, initial selection priority P0, initial overall switching time Ta0, initial overall average reward Ra0. Among them, T0 of each server is the same, and Ta0 of each server is the same. Among them, the initial overall switching time Ta0 is set based on the stability of the network environment in which each server is located, that is, the initial overall switching time Ta0 is used to indicate the stability of the network environment in which each server is located at the beginning.
[0085] It should be noted that the initial switching waiting time T0, the initial overall switching time Ta0 and the initial selection priority P0 of each server are used as the basis for each DHCP server to be selected for address request message processing at the beginning. As for how to use the initial switching waiting time T0, the initial overall switching time Ta0 and the initial selection priority P0 of each server to process the address request message, please refer to the above related description, which will not be repeated here.
[0086] Based on the above description, as an example, see Figure 3 The server switching method shown is applied to a DHCP relay server, where the DHCP relay server is connected to N DHCP servers, namely, servers, respectively, where N is greater than 1. The method may include the following steps:
[0087] Step 301: When it is determined that the switching parameters of N servers need to be updated, for each server, the real-time reward Rsx corresponding to the server is calculated based on the number of times the server has been switched in the specified historical time period and the latest recorded packet return speed information of the server. t .
[0088] Here, the switching parameters include at least the switching waiting time and the selected priority. t (corresponding to the first adjustment coefficient) can be understood as a feedback signal used to evaluate the quality of the action of "selecting this server". As for how to calculate the real-time reward Rsx corresponding to this server t , please refer to the calculation method of the first adjustment coefficient mentioned above, which will not be repeated here.
[0089] Step 302: The real-time reward Rsx corresponding to the server t The difference between the overall average reward of the latest record is input into the configured preference function to calculate the preference value Ht(s) corresponding to the server; wherein the difference is positively correlated with the preference value Ht(s) corresponding to the server.
[0090] It is understandable that if the switching parameters of N servers are adjusted for the first time, the latest recorded overall average reward is the initial overall average reward Ra0. The preference value corresponding to any server can be understood as a value used to measure the quality of the action of "selecting this server".
[0091] In this embodiment, the overall average reward of the latest record corresponds to the historical network stability parameter of the latest record; the configured preference function corresponds to the first specified function; and the preference value Ht(s) corresponds to the second adjustment coefficient.
[0092] Step 303: adjusting the selection priority of the server according to the preference value Ht(s) corresponding to the server; wherein the preference value Ht(s) corresponding to the server and the selection priority of the server are positively correlated.
[0093] The specific implementation of this step can refer to the above-mentioned specific implementation of inputting the second adjustment coefficient of the DHCP server into the second specified function to obtain a calculation result, and using the calculation result as the selection priority of the DHCP server, which will not be repeated here.
[0094] Step 304: Calculate the server's own switching waiting time Tsx according to the preference value Ht(s) corresponding to the server. t ; Among them, the preference value Ht(s) corresponding to the server and the server's own switching waiting time Tsx t There is a positive correlation between them.
[0095] In this embodiment, the server's own switching waiting time Tsx tBased on this, the specific implementation of this step can refer to the specific implementation of inputting the second adjustment coefficient of the DHCP server into the third specified function to obtain the first reference time for adjusting the switching waiting time of the DHCP server, which will not be repeated here.
[0096] Step 305: Real-time reward Rsx corresponding to each server t The difference between the average of the last recorded overall reward and the current overall switching waiting time Ta is determined t ; Among them, the difference and the current overall switching waiting time Ta t There is a negative correlation between them.
[0097] In this embodiment, the real-time reward Rsx corresponding to each server t The mean value of corresponds to the current network stability parameter mentioned above. The real-time reward Rsx corresponding to each server t The difference between the average of the last recorded overall average reward and the last recorded overall average reward corresponds to the second difference mentioned above. The current overall switching waiting time Ta t Based on this, the specific implementation of this step can refer to the specific implementation of inputting the second difference into the fourth specified function to obtain the second reference time for adjusting the switching waiting time of the DHCP server, which will not be repeated here.
[0098] Step 306: Set the server's own switching waiting time Tsx t The current overall switching waiting time Ta t The sum of the values is used as the switching waiting time for the server.
[0099] Completed Figure 3 This embodiment periodically and dynamically adjusts the switching parameters of each server, that is, the selection priority and the switching waiting time, so that the adjusted switching parameters of each server are as suitable as possible for each server with dynamically changing stability and the network environment in which each server is located. This can effectively avoid the situation where switching to a server with poor stability may occur when switching servers, thereby improving the reliability of server switching and further improving the reliability of the network environment in which each server is located.
[0100] At this point, the description of the method provided in the embodiment of the present application is completed. The following is a description of the device provided in the embodiment of the present application:
[0101] See also Figure 4 , Figure 4A schematic diagram of the structure of a server switching device provided in an embodiment of the present application. The device is applied to an electronic device, and the electronic device establishes connections with N DHCP servers respectively, where N is greater than 1; Figure 4 As shown, the device 400 includes an acquisition module 401, a determination module 402, a first adjustment module 403 and a second adjustment module 404;
[0102] The acquisition module 401 is used to acquire the number of times each DHCP server is switched within a specified historical time period, the latest recorded packet return speed information of each DHCP server, and the latest recorded historical network stability parameters;
[0103] The determination module 402 is used to determine a first adjustment coefficient for adjusting a switching parameter of each DHCP server according to the information of the number of times each DHCP server is switched within a specified historical time period and the latest recorded packet return speed information of each DHCP server, wherein the switching parameter includes a selection priority and a switching waiting time;
[0104] A first adjustment module 403, configured to adjust the selection priority of each DHCP server according to the first adjustment coefficient of each DHCP server and the latest recorded historical network stability parameter;
[0105] The second adjustment module 404 is used to adjust the switching waiting time of each DHCP server according to the latest recorded historical network stability parameter and the current network stability parameter, and the current network stability parameter is determined by the first adjustment coefficient of each DHCP server.
[0106] As an embodiment, the first adjustment module 403 is specifically configured to:
[0107] For each DHCP server, calculating a first difference between a first adjustment coefficient of the DHCP server and a latest recorded historical network stability parameter;
[0108] Inputting the first difference into a first specified function to obtain a second adjustment coefficient for adjusting a switching parameter of the DHCP server;
[0109] The second adjustment coefficient of the DHCP server is input into the second specified function to obtain a calculation result, and the calculation result is used as the selection priority of the DHCP server.
[0110] As an embodiment, there is a positive correlation between the second adjustment coefficient of the DHCP server and the first difference;
[0111] There is a positive correlation between the selection priority of the DHCP server and the second adjustment coefficient of the DHCP server.
[0112] As an embodiment, the second adjustment module 404 is specifically configured to:
[0113] For each DHCP server, inputting the second adjustment coefficient of the DHCP server into a third specified function to obtain a first reference time for adjusting the switching waiting time of the DHCP server;
[0114] Calculating a second difference between the current network stability parameter and the most recently recorded historical network stability parameter;
[0115] inputting the second difference into a fourth specified function to obtain a second reference time for adjusting a switching waiting time of the DHCP server;
[0116] The sum of the first reference time and the second reference time is used as the switching waiting time of the DHCP server.
[0117] As an embodiment, there is a negative correlation between the first reference time and the second adjustment coefficient of the DHCP server;
[0118] The second reference time is negatively correlated with the second difference.
[0119] As an embodiment, the first adjustment coefficient of any DHCP server is negatively correlated with the number of times the DHCP server is switched within a specified historical time period, and is positively correlated with the latest recorded packet return speed information of the DHCP server.
[0120] As an embodiment, the current network stability parameter is determined in the following manner:
[0121] The average value of the first adjustment coefficients of the DHCP servers is used as the current network stability parameter.
[0122] So far, completed Figure 4 Structural description of the device shown.
[0123] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.
[0124] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present application scheme. A person of ordinary skill in the art can understand and implement it without paying creative labor.
[0125] See also Figure 5 , is a schematic diagram of the hardware structure of an electronic device provided by an exemplary embodiment of the present application. The electronic device may include a processor 501, a communication interface 502, a computer-readable storage medium 503 and a communication bus 504. The processor 501, the communication interface 502 and the computer-readable storage medium 503 communicate with each other through the communication bus 504. Among them, computer program instructions are stored on the computer-readable storage medium 503; the processor 501 can execute the steps of the method described in the above embodiment by executing the computer program instructions stored on the computer-readable storage medium 503. The electronic device may also include other hardware according to the actual function of the electronic device, which will not be described in detail.
[0126] Correspondingly, an embodiment of the present application further provides a computer-readable storage medium, on which a number of computer program instructions are stored. When the computer program instructions are executed by a processor, the method disclosed in the above example of the present application can be implemented.
[0127] Exemplarily, the computer-readable storage medium may be any electronic, magnetic, optical or other physical storage device that may contain or store information, such as executable instructions, data, etc. For example, the computer-readable storage medium may be: RAM (Radom Access Memory), volatile memory, non-volatile memory, flash memory, storage drive (such as hard disk drive), solid state drive, any type of storage disk (such as optical disk, DVD, etc.), or similar storage medium, or a combination thereof. The processor and memory may be supplemented by or incorporated into a dedicated logic circuit.
[0128] The above are only preferred embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application.
Claims
1. A server switching method, characterized in that: The method is applied to an electronic device, wherein the electronic device respectively establishes connections with N Dynamic Host Configuration Protocol DHCP servers, where N is greater than 1; the method comprises: Obtain the number of times each DHCP server has been switched within a specified historical time period, the latest recorded packet return speed information of each DHCP server, and the latest recorded historical network stability parameters; According to the information of the number of times each DHCP server is switched within the specified historical time period and the latest recorded packet return speed information of each DHCP server, a first adjustment coefficient for adjusting the switching parameters of each DHCP server is correspondingly determined, wherein the switching parameters include a selection priority and a switching waiting time; According to the first adjustment coefficient of each DHCP server and the latest recorded historical network stability parameter, correspondingly adjusting the selection priority of each DHCP server; The switching waiting time of each DHCP server is adjusted accordingly according to the latest recorded historical network stability parameter and the current network stability parameter, wherein the current network stability parameter is determined depending on the first adjustment coefficient of each DHCP server.
2. The method according to claim 1, characterized in that The step of adjusting the selection priority of each DHCP server according to the first adjustment coefficient of each DHCP server and the latest recorded historical network stability parameter includes: For each DHCP server, calculating a first difference between a first adjustment coefficient of the DHCP server and the latest recorded historical network stability parameter; Inputting the first difference into a first specified function to obtain a second adjustment coefficient for adjusting a switching parameter of the DHCP server; The second adjustment coefficient of the DHCP server is input into the second specified function to obtain a calculation result, and the calculation result is used as the selection priority of the DHCP server.
3. The method according to claim 2, characterized in that There is a positive correlation between the second adjustment coefficient of the DHCP server and the first difference; There is a positive correlation between the selection priority of the DHCP server and the second adjustment coefficient of the DHCP server.
4. The method according to claim 2, characterized in that: The step of adjusting the switching waiting time of each DHCP server according to the latest recorded historical network stability parameter and the current network stability parameter includes: For each DHCP server, inputting the second adjustment coefficient of the DHCP server into a third specified function to obtain a first reference time for adjusting the switching waiting time of the DHCP server; Calculating a second difference between the current network stability parameter and the latest recorded historical network stability parameter; inputting the second difference into a fourth specified function to obtain a second reference time for adjusting a switching waiting time of the DHCP server; The sum of the first reference time and the second reference time is used as the switching waiting time of the DHCP server.
5. The method according to claim 4, characterized in that There is a negative correlation between the first reference time and the second adjustment coefficient of the DHCP server; The second reference time is negatively correlated with the second difference.
6. The method according to claim 1, characterized in that The first adjustment coefficient of any DHCP server is negatively correlated with the number of times the DHCP server is switched within a specified historical time period, and is positively correlated with the latest recorded packet return speed information of the DHCP server.
7. The method according to claim 1, characterized in that The current network stability parameter is determined by: An average value of the first adjustment coefficients of each DHCP server is used as the current network stability parameter.
8. A server switching device, characterized in that: The device is applied to an electronic device, and the electronic device establishes connections with N dynamic host configuration protocol DHCP servers respectively, where N is greater than 1; the device comprises: An acquisition module is used to acquire the number of times each DHCP server is switched within a specified historical time period, the latest recorded packet return speed information of each DHCP server, and the latest recorded historical network stability parameters; A determination module, configured to determine a first adjustment coefficient for adjusting a switching parameter of each DHCP server according to information on the number of times each DHCP server is switched within a specified historical time period and the latest recorded packet return speed information of each DHCP server, wherein the switching parameter includes a selection priority and a switching waiting time; A first adjustment module, configured to adjust the selection priority of each DHCP server according to the first adjustment coefficient of each DHCP server and the latest recorded historical network stability parameter; The second adjustment module is used to adjust the switching waiting time of each DHCP server according to the latest recorded historical network stability parameter and the current network stability parameter, wherein the current network stability parameter is determined based on the first adjustment coefficient of each DHCP server.
9. An electronic device, characterized in that: The electronic device includes: Processor; and A computer-readable storage medium, wherein computer program instructions are stored in the computer-readable storage medium, and when the computer program instructions are executed by the processor, the processor executes the steps in any one of the methods of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, which, when executed by a processor, enable the processor to perform the steps of any one of the methods of claims 1 to 7.
Citation Information
Patent Citations
Method for improving reliability of 6RD (IPv6 rapid deployment) network, home gateway and DHCP (dynamic host configuration protocol) server
CN102710804A
Method of acquiring IP address, terminal device and storage medium
CN107968848A
Multimedia data processing method and equipment
CN112000454A
Method and device for realizing DHCP (Dynamic Host Configuration Protocol) relay function, program product and medium
CN118337688A
System and method for assigning a service flow classifier to a device
US20120254346A1