Device access control method and device

By using the server in the Internet of Things system to determine the random value range based on the load and the number of requests, the device selects a random number to determine access, and uses the composite properties of prime numbers to control the access probability, which solves the problem of low accuracy of device access control in the existing technology. problem, achieving precise control of device access and smooth management of server load.

CN116132210BActive Publication Date: 2024-10-11FIBERHOME TELECOMMUNICATION TECHNOLOGIES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310131773.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-17
Publication Date
2024-10-11
Estimated Expiration
2043-02-17

AI Technical Summary

Technical Problem

Existing IoT device access control methods have low control accuracy and cannot dynamically adjust the device access rate, causing the server load to exceed limits and affecting server stability.

Method used

The server determines the random value range based on the current load and the number of device requests. The device selects a random number within this range. The server determines whether to allow access based on the type of random number and load status, and uses the properties of prime numbers to achieve device access probability. smooth transition.

Benefits of technology

It achieves precise control of device access, ensures the normal operation of servers and devices, reduces server load impact, and ensures the stability of device access and the continued stable operation of servers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116132210B_ABST
    Figure CN116132210B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of Internet of Things device access technology, and provides a device access control method and apparatus. The method includes: when a server receives an access request from a device, it determines a corresponding random value range according to the current load of the server and / or the number of times the device requests access; sends the random value range to the device so that the device selects a corresponding random number within the random value range; receives the random number sent by the device, and determines whether to allow the device to access according to the type of the random number and the current load. The present invention controls the random value range by using the current load of the server and the number of times the device requests access, and selects a random number within the random value range to control the probability of device access, thereby achieving precise control of device access according to the server load or the number of device requests, and ensuring the normal operation of the server and the device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of Internet of Things device access, and in particular to a device access control method and device. Background Art

[0002] The current Internet of Things system requires access to a massive number of devices. The access of a large number of devices has a great impact on server performance and will directly affect the server load. If the access of devices is not controlled, it may even cause the server load to exceed the limit, affecting the normal operation of the server and even causing the server to crash. In order to reduce the impact on the server, the server usually controls the access of devices to maintain the stability of the service.

[0003] There are many existing control methods, such as method 1: setting rules through the server to simply determine whether the device is connected. This method cannot dynamically adjust the device access and access rate, resulting in low control accuracy; method 2: restricting according to the policy, such as prohibiting access or queuing for a long time if the number of access devices exceeds a certain threshold, which is not conducive to smooth access control of the device.

[0004] In view of this, overcoming the defects of the prior art is an urgent problem to be solved in the field of this technology. Summary of the invention

[0005] The technical problem to be solved by the present invention is that the control accuracy of the device access control method in the prior art is low.

[0006] The present invention adopts the following technical solution:

[0007] In a first aspect, the present invention provides a device access control method, comprising:

[0008] When receiving an access request from a device, the server determines a corresponding random value range according to the current load of the server and / or the number of access requests from the device;

[0009] Sending the random value range to the device so that the device can select a corresponding random number within the random value range;

[0010] A random number sent by the device is received, and according to the type of the random number and the current load, whether to allow the device to access is determined.

[0011] Preferably, determining whether to allow the device to access according to the type of the random number and the current load specifically includes:

[0012] The server determines whether the random number is a prime number, and determines whether the current load exceeds a preset load;

[0013] If the current load does not exceed the preset load and the random number is a composite number, or if the current load exceeds the preset load and the random number is a prime number, allowing the device to access;

[0014] Otherwise, the device is denied access.

[0015] Preferably, determining the corresponding random value range according to the current load of the server and / or the number of times the device requests access includes:

[0016] Determine an upper boundary value of a random value range, wherein the random value range is determined by a preset lower boundary value and the upper boundary value;

[0017] When the number of times the device requests access is not greater than a preset number, determining the upper boundary value of the random value range specifically includes:

[0018] The absolute value of the difference between the current load and the preset load plus the preset increment is used as the first base value;

[0019] The upper boundary value is obtained by multiplying the first base value by a first preset coefficient.

[0020] Preferably, when the number of times the device requests access is greater than a preset number and the current load exceeds a preset load, determining the upper boundary value of the random value range specifically includes:

[0021] Subtracting the preset number of times from the number of times the device requests access to obtain an excess access number, and multiplying the excess access number by a second preset coefficient as a second base value;

[0022] The upper boundary value is obtained by multiplying the first base value by the first preset coefficient and then dividing the result by the second base value.

[0023] Preferably, when the number of times the device requests access is greater than a preset number and the current load does not exceed a preset load, determining the upper boundary value of the random value range specifically includes:

[0024] Subtracting the preset number of times from the number of times the device requests access to obtain an excess access number, and multiplying the excess access number by a second preset coefficient as a second base value;

[0025] The upper boundary value is obtained by multiplying the first base value by the first preset coefficient and then by the second base value.

[0026] Preferably, the current load of the server is calculated based on at least one of the CPU occupancy rate, memory occupancy rate, disk occupancy rate and device access rate of the server, and specifically includes:

[0027] The maximum value among the CPU occupancy rate, memory occupancy rate, disk occupancy rate and device access rate is taken as the current load, or,

[0028] The average value of the CPU occupancy rate, memory occupancy rate, disk occupancy rate and device access rate is taken as the current load.

[0029] Preferably, after denying access to the device, the method further comprises:

[0030] The server sends the current load to the device, so that the device uses the current load multiplied by a preset waiting coefficient as a waiting time, and requests access again after the waiting time.

[0031] In a second aspect, the present invention further provides a device access control method, comprising:

[0032] The device sends an access request to the server;

[0033] The device receives a random value range determined by the server according to a current load and / or a number of device access requests;

[0034] The device selects a corresponding random number within the random value range, and forwards the random number to the server, so that the server determines whether to allow the device to access according to the type of the random number and the current load status;

[0035] The device receives response information from the server and selectively accesses the server according to the response information.

[0036] Preferably, the device selects a corresponding random number within the random value range, specifically including:

[0037] Add the device's decimal MAC address to the request time to get the seed number;

[0038] Calculate the hash value of the seed number using a HASH algorithm, use the hash value as the dividend, use the value obtained by subtracting 1 from the upper boundary value of the random value range as the divisor, and perform a remainder operation to obtain an intermediate number;

[0039] If the value of the middle number is 0, the random number selected is the value obtained by subtracting 1 from the upper boundary value;

[0040] If the value of the middle number is 1, the random number is selected as the upper boundary value;

[0041] Otherwise, a random number is selected as the intermediate number.

[0042] In a third aspect, the present invention further provides a device access control apparatus, used to implement the device access control method according to the first aspect, the apparatus comprising:

[0043] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the processor to execute the device access control method described in the first aspect or the second aspect.

[0044] In a fourth aspect, the present invention further provides a non-volatile computer storage medium, wherein the computer storage medium stores computer executable instructions, which are executed by one or more processors to complete the device access control method described in the first aspect or the second aspect.

[0045] The present invention controls the random value range by using the current load of the server and the number of times the device requests access, and selects a random number within the random value range to control the device access probability, thereby achieving precise control of device access according to the server load or the number of device requests, ensuring the normal operation of the server and the device; and in a preferred embodiment of the present invention, the properties of prime numbers and composite numbers are also used to control the access of the device, achieving a smooth transition of the device access probability with the random value range, thereby ensuring the continuous and stable operation of the server and the device. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0047] Figure 1 It is a flow chart of a device access control method provided by an embodiment of the present invention;

[0048] Figure 2 It is a flowchart of another device access control method provided by an embodiment of the present invention;

[0049] Figure 3 1 is a schematic diagram of a relationship curve between the probability and range of a number randomly selected within a certain range being a prime number provided by an embodiment of the present invention;

[0050] Figure 4 It is a schematic diagram of a process of determining an upper boundary value of a random value range in a device access control method provided by an embodiment of the present invention;

[0051] Figure 5It is a schematic diagram of a process of determining an upper boundary value of a random value range in another device access control method provided by an embodiment of the present invention;

[0052] Figure 6 It is a schematic diagram of a process of determining an upper boundary value of a random value range in another device access control method provided by an embodiment of the present invention;

[0053] Figure 7 is a schematic diagram of a device access control method provided by an embodiment of the present invention;

[0054] Figure 8 It is a flowchart of another device access control method provided by an embodiment of the present invention;

[0055] Fig. 9 is a schematic diagram of a device access control method in a specific scenario provided by an embodiment of the present invention;

[0056] Fig.10 It is a flowchart of a device access control method in a specific scenario provided by an embodiment of the present invention;

[0057] Fig.11 is a schematic diagram of a device access control method in a specific scenario provided by an embodiment of the present invention;

[0058] Fig.12 is a schematic diagram of a device access control method in another specific scenario provided by an embodiment of the present invention;

[0059] Fig.13 is a flow chart of a device access control method in another specific scenario provided by an embodiment of the present invention;

[0060] Fig.14 It is a schematic diagram of the architecture of a device access control apparatus provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0061] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0062] In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.

[0063] Embodiment 1:

[0064] Embodiment 1 of the present invention provides a device access control method, such as Figure 1 As shown, including:

[0065] In step 201, when receiving an access request from a device, the server determines a corresponding random value range according to the current load of the server and / or the number of access requests from the device.

[0066] The access request of the device carries a device ID. When the corresponding random value range needs to be determined by the number of times the device requests access, the access request of the device also carries the number of times the device requests access.

[0067] The number of times the device requests access can also be understood as the number of times the device is denied access by the server.

[0068] In step 202, the random value range is sent to the device so that the device can select a corresponding random number within the random value range.

[0069] In step 203, a random number sent by the device is received, and it is determined whether to allow the device to access according to the type of the random number and the current load.

[0070] The type of the random number may be the parity of the random number, whether it is a prime number or a composite number, etc. When the type of the random number is a prime number or a composite number, the determination of whether to allow the device to access is based on the type of the random number and the current load, such as Figure 2 As shown, specifically including:

[0071] In step 301, the server determines whether the random number is a prime number and whether the current load exceeds a preset load. The preset load is obtained by those skilled in the art based on analysis of the device access control requirements of the server.

[0072] In step 302, if the current load does not exceed the preset load and the random number is a composite number, or if the current load exceeds the preset load and the random number is a prime number, the device is allowed to access.

[0073] Among them, the random number is divided by each natural number that is less than or equal to the random number to check the number of natural numbers that can be divided. If the number of natural numbers that can be divided is 2, the random number is a prime number; if the number of natural numbers that can be divided is 0 or 1, the random number is neither a prime number nor a composite number (that is, the random number is 0 or 1); in other cases, the random number is a composite number. A person skilled in the art can select an appropriate random number selection method to ensure that the random number is greater than 1, and avoid the situation where the random number is neither a prime number nor a composite number; when the random number is neither a prime number nor a composite number, a person skilled in the art can also perform corresponding processing for this special situation to determine whether to allow the device to access. This processing method will be described in detail in the subsequent embodiments in combination with specific application scenarios, and will not be repeated here.

[0074] In step 303, otherwise, the device access is denied.

[0075] This embodiment utilizes the properties of prime numbers and composite numbers. In the digital arrangement, prime numbers are relatively sparse, while composite numbers are relatively dense. Therefore, when the load is low, the device whose random number is a composite number is selected for access, so that the probability of device access becomes larger, and when the load is high, the device whose random number is a prime number is selected for access, so that the probability of device access becomes smaller, thereby realizing the control of device access probability. At the same time, the larger the value range of the random number is, the sparser the prime numbers are, and the denser the composite numbers are, that is, the probability of device access is affected by the random value range. The probability that a number randomly selected from a certain range is a prime number can be mathematically derived from the prime number theorem, that is, the probability of a number randomly selected from natural numbers not greater than n being a prime number is approximately When n is greater than 1, the probability is expressed as Figure 3 The curve shown in Figure 3 In the figure, the horizontal axis is n and the vertical axis is From the obtained values, it can be seen that the probability presents a nonlinear smooth change trend. Therefore, this embodiment also determines the corresponding random value range according to the current load of the server and / or the number of device access requests, so that the server load or the number of device requests directly affects the value range of the random number, thereby affecting the probability that the random number is a prime number or a composite number, that is, affecting the device access probability, and then achieving smooth control of the device access probability by controlling the random value range.

[0076] This embodiment also provides a preferred implementation method for the above-mentioned step 201, namely, determining the corresponding random value range according to the current load of the server and / or the number of times the device requests access, specifically including: determining the upper boundary value of the random value range, and determining the random value range by a preset lower boundary value and the upper boundary value; as an optional implementation method, the preset lower boundary value can be 0, and the random value range can be greater than 0 and less than the upper boundary value.

[0077] When the number of times the device requests access is not greater than the preset number, the upper boundary value of the random value range is determined, such as Figure 4 As shown, specifically including:

[0078] In step 401, the absolute value of the difference between the current load and the preset load plus the preset increment is used as the first base value.

[0079] In step 402, the upper boundary value is obtained by multiplying the first base value by a first preset coefficient.

[0080] The preset increment is obtained by those skilled in the art based on empirical analysis, and its purpose is to ensure the minimum value of the upper boundary value, that is, when the current load is infinitely close to or even equal to the preset load, a reasonable random value range can still be ensured. The preset number of times and the first preset coefficient are obtained by those skilled in the art based on the analysis of the device access control requirements of the server.

[0081] When the number of times the device requests access is greater than the preset number and the current load exceeds the preset load, the upper boundary value of the random value range is determined, such as Figure 5 As shown, specifically including:

[0082] In step 501, the number of excess access times is obtained by subtracting the preset number of times from the number of times the device requests access, and the second base value is obtained by multiplying the excess access number by a second preset coefficient.

[0083] In step 502, the first base value is multiplied by the first preset coefficient and then divided by the second base value to obtain the upper boundary value.

[0084] The second preset coefficient is obtained by those skilled in the art based on analysis of device access control requirements of the server.

[0085] When the number of times the device requests access is greater than the preset number and the current load does not exceed the preset load, the upper boundary value of the random value range is determined, such as Figure 6 As shown, specifically including:

[0086] In step 601, the number of excess access times is obtained by subtracting the preset number of times from the number of times the device requests access, and the second base value is obtained by multiplying the excess access number by a second preset coefficient.

[0087] In step 602, the first base value is multiplied by the first preset coefficient and then multiplied by the second base value to obtain the upper boundary value.

[0088] The above preferred implementation is expressed in the form of a mathematical formula:

[0089]

[0090] Among them, Y represents the upper boundary value of the random value range, A represents the first preset coefficient, B represents the second preset coefficient, B is greater than or equal to 1, and B is much smaller than A, such as A is greater than or equal to 100 times B, K represents the preset value-added, X is the current load, X' is the preset load, P is the number of times the device requests access, Q is the preset number, and Q is a positive integer. When the calculated Y is a decimal, Y can be rounded to facilitate the subsequent selection of random numbers through the remainder operation. As an optional implementation method in a specific scenario, the preset load X' can be set to 50%, and B can be set to 1.

[0091] Among them, since the number of times the device requests access must be a positive integer, B is greater than or equal to 1, then when P, (PQ)×B must be greater than 1, that is, the second base value must be greater than 1, so that when the current load is greater than the preset load, the first base value is divided by a value greater than 1 to make the obtained upper boundary value smaller, thereby increasing the probability that the random number is a prime number; and when the current load is less than or equal to the preset load, the first base value is multiplied by a value greater than 1 to make the obtained upper boundary value larger, thereby increasing the probability that the random number is a composite number, thereby using the server load to control the probability of device access, while also increasing the probability of device access with a large number of requests. Furthermore, B is also made much smaller than A, thereby ensuring that the server load has a relatively large impact on the device access probability, and the number of device requests has a relatively small impact on the device access probability.

[0092] In the above preferred implementation, when the number of device access requests is not greater than the preset number, only the server load is used to control device access, so that the farther the current load is from the preset load, the larger the upper boundary value, the larger the random value range, the smaller the possibility that the random number is a prime number, and the greater the possibility that it is a composite number. Among them, when the current load does not exceed the preset load, the smaller the current load, the larger the upper boundary value, the larger the random value range, and the greater the possibility that the random number is a composite number. Since the device with a composite random number is selected for access at this time, the greater the probability of device access. When the current load exceeds the preset load, the larger the current load, the larger the upper boundary value, the larger the random value range, and the smaller the possibility that the random number is a prime number. Since the device with a prime random number is selected for access at this time, the smaller the probability of device access. When the current load is close to the preset load, the preset value is increased to ensure the minimum upper boundary value, thereby controlling the probability of device access.

[0093] When the number of device requests exceeds the preset number, the number of device requests is also included in the access control of the device. When the current load exceeds the preset load, the upper boundary value is reduced by dividing by the second base value, and the random value range is also reduced accordingly, thereby increasing the probability that the random number is a prime number; when the current load does not exceed the preset load, the upper boundary value is increased by multiplying by the second base value, and the random value range is also increased accordingly, thereby further increasing the probability that the random number is a composite number, so that as the number of device requests increases, the probability of device access increases.

[0094] In the above preferred embodiment, Figure 7 As shown in FIG. 1 , taking the access control of device 1 as an example, the access control of device 1 is determined by the current load of the server and the number of device accesses. If device 1 is allowed to access, after access, device 1 affects the current load of the server, thereby affecting subsequent devices (i.e. Figure 7 Access control of device 2, ..., device n) in the middle forms a feedback loop of multi-device access control to achieve precise control of device access. If device 1 is not allowed to access, the number of accesses of device 1 is affected, which is fed back to the access control of device 1, thereby forming a feedback loop of access control of device 1 itself. Through the feedback loop of multi-device access control and the feedback loop of device access control itself, a balance is maintained between the load demand of the server and the access demand of the device.

[0095] This embodiment includes the number of times a device requests access and the current load of the server in the calculation of the random value range, so that the access of multiple devices is feedback-regulated and controlled by the server load, and the device access is feedback-regulated and controlled by the number of times the device requests access. This allows the device access to be accurately controlled through double-layer feedback regulation while achieving a two-way balance between the server load demand and the device access demand.

[0096] It should be noted that the above is only an optional implementation. In actual use, there are also the following two implementations:

[0097] Method 1: Determine the corresponding random value range only based on the current load of the server. Specifically: take the absolute value of the difference between the current load and the preset load, plus the preset increment, as the first base value; multiply the first base value by the first preset coefficient to obtain the upper boundary value, thereby obtaining the random value range.

[0098] Method 2: Determine the corresponding random value range only based on the number of device accesses, specifically: when the number of device accesses does not exceed the preset number, use the first preset value as the upper boundary value to determine the random value range; when the number of device accesses exceeds the preset number, subtract the preset number from the number of times the device requests access to obtain the excess access number, and multiply the excess access number by the second preset coefficient as the second base value; when the current load exceeds the preset load, divide the first value by the second base value to obtain the upper boundary value, thereby determining the random value range; when the current load does not exceed the preset load, multiply the first preset value by the second base value to obtain the upper boundary value, thereby determining the random value range. The first preset value is obtained by a technician in this field based on the analysis of the device access control requirements of the server.

[0099] The current load of the server is calculated based on at least one of the CPU occupancy rate, memory occupancy rate, disk occupancy rate and device access rate of the server. This embodiment provides an optional implementation method, which specifically includes:

[0100] The maximum value among the CPU occupancy rate, memory occupancy rate, disk occupancy rate and device access rate is taken as the current load, or the average value of the CPU occupancy rate, memory occupancy rate, disk occupancy rate and device access rate is taken as the current load.

[0101] The device access rate is the number of devices currently accessing the server divided by the maximum number of devices allowed to access the server. The maximum number of devices allowed to access the server is obtained by technicians in this field based on the performance analysis of the server.

[0102] As an optional implementation manner, the allowing the device to access specifically includes:

[0103] The server sends the address of the corresponding access module to the device, so that the device can establish a TCP connection with the access module.

[0104] After denying access to the device, the method further includes:

[0105] The server sends the current load to the device, so that the device uses the current load multiplied by the preset waiting coefficient as the waiting time, and requests access again after the waiting time. That is, the waiting time E = D × X, D is the preset waiting coefficient. The preset waiting coefficient is obtained by a technician in this field according to the device access control requirements of the server.

[0106] The device also records the number of access requests, which is used to determine the corresponding random value range when the device requests access again later.

[0107] This implementation method determines the waiting time according to the server load, thereby controlling the access speed of the device. The greater the server load, the slower the device access speed, thereby reducing the burden on the server to ensure its normal operation.

[0108] In order to further control the current load of the server, this embodiment also provides an optional implementation mode, that is, the method further includes:

[0109] The server also monitors the data communication between each connected device, and disconnects the device from the corresponding access module if it detects that there is no data communication between the server and the corresponding device for a period exceeding a preset time. The preset time is obtained by a person skilled in the art based on the performance analysis of the server.

[0110] Embodiment 2:

[0111] Based on the device access control method described in Example 1, this embodiment further provides a device access control method, in order to explain the device side of the corresponding method in Example 1 and further analyze its design principle. It should be noted that the device access control method in Example 1 is applicable to this embodiment 2, and will not be described in detail in this embodiment.

[0112] The device access control method provided in this embodiment is as follows: Figure 8 As shown, including:

[0113] In step 701, the device sends an access request to the server.

[0114] In step 702, the device receives a random value range determined by the server according to the current load and / or the number of times the device requests access.

[0115] In step 703, the device selects a corresponding random number within the random value range, and forwards the random number to the server, so that the server determines whether to allow the device to access according to the type of the random number and the current load status.

[0116] In step 704, the device receives response information from the server and selectively accesses the server according to the response information.

[0117] If the server determines to allow the device to access, the response information carries the address information required for the device to access, and the device accesses the server based on the address information; if the server determines to deny the device access, the response information carries the current load, and the device determines the waiting time based on the current load.

[0118] The device access control method on the server side has been described in Example 1 and will not be further elaborated in this embodiment.

[0119] In actual usage scenarios, the random number is usually calculated by a corresponding random number algorithm, so there are the following optional implementations, that is, the device selects a corresponding random number within the random value range, specifically including:

[0120] Add the device's decimal MAC address to the request time to get the seed number.

[0121] A HASH algorithm is used to calculate the hash value of the seed number, with the hash value as the dividend and the value obtained by subtracting 1 from the upper boundary value of the random value range as the divisor, and a remainder operation is performed to obtain the intermediate number.

[0122] If the value of the middle number is 0, the random number selected is the value obtained by subtracting 1 from the upper boundary value.

[0123] If the value of the middle number is 1, the random number is selected as the upper boundary value.

[0124] Otherwise, a random number is selected as the intermediate number.

[0125] The above implementation method is expressed in the form of a formula:

[0126] Z0=hash(B+C)%(Y-1)

[0127]

[0128] Among them, Y represents the upper boundary value of the random value range, B is the decimal value of the device's mac address, C is the request time of the device. As an optional implementation method, the number of seconds since 1970 of the current timestamp when the device requests can be selected as C to participate in the calculation, hash() represents using the content in the brackets as the seed number, and using the HASH algorithm to calculate the hash value of the seed number, % is the remainder operation, that is, the remainder left after the hash value is divided by Y-1 is the intermediate number Z0, Z is a random number, when Z0 is 0, Z is Y-1, when Z0 is 1, Z is Y, so that 0 and 1 that are neither composite numbers nor prime numbers are specially processed, so that the range of the finally selected random number Z is [2, Y].

[0129] Embodiment 3:

[0130] On the basis of the methods described in Example 1 and Example 2, the present invention also combines specific application scenarios and uses technical descriptions in related scenarios to illustrate the implementation process of the present invention in characteristic scenarios.

[0131] like Fig. 9 As shown, the server includes a control module and a device access module. The control module is used to control device access and, when allowing device access, sends the address of the device access module to the device so that the device can establish a TCP connection with the device access module.

[0132] The interaction process between the server and the device is as follows Fig.10 and Fig.11 As shown, specifically including:

[0133] In step 801, the device sends a device access request to the control module of the server, and the device access request carries the device ID and the number of times the device requests access P; wherein the number of times the device requests access is obtained by the device record, and the recording starts when the device initiates the first access request, and the number of times the device requests access is cleared when the device successfully accesses the server.

[0134] In step 802, the control module determines the size of P and Q according to the connection number threshold Q. If P>Q, let S=B×(PQ); if P<=Q, let S=1.

[0135] In step 803, the control module calculates the current load X of the server. When X is greater than 50% (50% can be understood as the preset load in Example 1), the upper boundary value of the random value range is calculated as Y=A'×((|X-50%|+K)×100÷S). When X is less than or equal to 50%, the upper boundary value Y=A'×((|X-50%|+K)×100×S); wherein A'×100 can be understood as the first preset coefficient A in Example 1, and S can be understood as the second base number in Example 1. The upper boundary value is sent to the device.

[0136] In step 804, the device calculates the intermediate number Z0=hash(B+C)%(Y-1) according to the upper boundary value. When Z0 is 0, the random number Z is Y-1. When Z0 is 1, the random number Z is Y. Otherwise, the random number Z is Z0 and the random number Z is sent to the control module.

[0137] In step 805 , the control module determines whether the current load X is greater than 50%. If so, the control module proceeds to step 807 , otherwise, the control module proceeds to step 806 .

[0138] In step 806, the control module detects whether the value of the random number Z is a prime number or a composite number. When the random number Z is detected to be a composite number, the control module sends a request result (which can be understood as the response information in Example 2) to the device to allow the device access, and carries the address of the device access module in the request result, and the device establishes a TCP connection with the device access module based on the address; otherwise, the control module sends a request result to the device to deny the device access, and carries the current load X in the request result, and the device calculates the waiting time E=D×X based on the current load X, and the device sends a device access request to the control module again after the waiting time.

[0139] In step 807, the control module detects whether the value of the random number Z is a prime number or a composite number. When the random number Z is detected to be a prime number, the control module sends a request result to the device to allow the device access, and carries the address of the device access module in the request result, and the device establishes a TCP connection with the device access module based on the address; otherwise, the control module sends a request result to the device to deny the device access, and carries the current load X in the request result, and the device calculates the waiting time E=D×X based on the current load X, and the device sends a device access request to the control module again after the waiting time.

[0140] Embodiment 4:

[0141] On the basis of the methods described in Example 1 and Example 2, the present invention also combines a distributed server scenario and uses the technical description in this scenario to illustrate the implementation process in the characteristic scenario of the present invention.

[0142] like Fig.12 As shown, the distributed server scenario includes multiple servers, and one of the servers controls the access of the device, such as server 1 controls the access of the device. Based on the above embodiment, this embodiment also provides a preferred implementation method for the specific scenario of the distributed server, such as Fig.13 As shown, specifically including:

[0143] In step 901, the control server monitors the current load of each server. When receiving an access request from a device, the control server uses the current load of each server and / or the number of times the device requests access to determine the random value range corresponding to each server, and sends the random value range of each server to the device, so that the device can select a corresponding random number from the corresponding random value range for each server and forward each random number to the control server.

[0144] In step 902, the control server determines whether each server allows the device to access based on the current load of each server and the corresponding random numbers.

[0145] In step 903, if there is a server that the device is allowed to access, then among the servers that the device is allowed to access, the server with the smallest current load is selected as the target server, and the control server sends the address of the target server to the device so that the device can access the target server according to the address.

[0146] The control server determines whether each server allows the device to access based on the current load of each server and the corresponding random numbers. This is based on the same concept as in Example 1 and specifically includes:

[0147] If the current load of the corresponding server does not exceed the preset load and the corresponding random number is a composite number, or if the current load of the corresponding server exceeds the preset load and the corresponding random number is a prime number, the server allows the device to access.

[0148] Otherwise, the server denies access to the device.

[0149] In step 904, if there is no server that allows the device to access, the current load of each server with the largest current load X is max Sent to the device, the device according to X max Calculate the waiting time E = D × X max , and then send an access request to the control server after the waiting time.

[0150] Embodiment 5:

[0151] like Fig.14 , which is a schematic diagram of the architecture of a device access control apparatus according to an embodiment of the present invention. The device access control apparatus according to this embodiment includes one or more processors 21 and a memory 22. Fig.14 A processor 21 is taken as an example.

[0152] The processor 21 and the memory 22 may be connected via a bus or other means. Fig.14 The example of connecting through bus is taken in the following.

[0153] The memory 22 is a non-volatile computer-readable storage medium, which can be used to store non-volatile software programs and non-volatile computer executable programs, such as the device access control method in Embodiment 1, Embodiment 2, Embodiment 3, or Embodiment 4. The processor 21 executes the device access control method by running the non-volatile software programs and instructions stored in the memory 22.

[0154] The memory 22 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices. In some embodiments, the memory 22 may optionally include a memory remotely arranged relative to the processor 21, and these remote memories may be connected to the processor 21 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0155] The program instructions / modules are stored in the memory 22, and when executed by the one or more processors 21, the device access control method in the above-mentioned embodiment 1 is executed.

[0156] It is worth noting that the information interaction, execution process, etc. between the modules and units within the above-mentioned devices and systems are based on the same concept as the processing method embodiment of the present invention. The specific contents can be found in the description of the method embodiment of the present invention and will not be repeated here.

[0157] A person skilled in the art may understand that all or part of the steps in the various methods of the embodiments may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the storage medium may include: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.

[0158] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A device access control method, characterized in that: include: When receiving an access request from a device, the server determines a corresponding random value range according to the current load of the server and / or the number of access requests from the device; Sending the random value range to the device so that the device can select a corresponding random number within the random value range; Receiving a random number sent by the device, the server determines whether the random number is a prime number, and determines whether the current load exceeds a preset load; If the current load does not exceed the preset load and the random number is a composite number, or if the current load exceeds the preset load and the random number is a prime number, allowing the device to access; Otherwise, the device is denied access.

2. The device access control method according to claim 1, characterized in that: The determining of the corresponding random value range according to the current load of the server and / or the number of times the device requests access includes: Determine an upper boundary value of a random value range, wherein the random value range is determined by a preset lower boundary value and the upper boundary value; When the number of times the device requests access is not greater than a preset number, determining the upper boundary value of the random value range specifically includes: The absolute value of the difference between the current load and the preset load plus the preset increment is used as the first base value; The upper boundary value is obtained by multiplying the first base value by a first preset coefficient.

3. The device access control method according to claim 2, characterized in that: When the number of times the device requests access is greater than a preset number and the current load exceeds a preset load, determining the upper boundary value of the random value range specifically includes: Subtracting the preset number of times from the number of times the device requests access to obtain an excess access number, and multiplying the excess access number by a second preset coefficient as a second base value; The upper boundary value is obtained by multiplying the first base value by the first preset coefficient and then dividing the result by the second base value.

4. The device access control method according to claim 2, characterized in that: When the number of times the device requests access is greater than a preset number and the current load does not exceed a preset load, determining the upper boundary value of the random value range specifically includes: Subtracting the preset number of times from the number of times the device requests access to obtain an excess access number, and multiplying the excess access number by a second preset coefficient as a second base value; The upper boundary value is obtained by multiplying the first base value by the first preset coefficient and then by the second base value.

5. The device access control method according to claim 1, characterized in that: The current load of the server is calculated based on at least one of the CPU occupancy rate, memory occupancy rate, disk occupancy rate and device access rate of the server, and specifically includes: The maximum value among the CPU occupancy rate, memory occupancy rate, disk occupancy rate and device access rate is taken as the current load, or, The average value of the CPU occupancy rate, memory occupancy rate, disk occupancy rate and device access rate is taken as the current load.

6. The device access control method according to claim 1, characterized in that: After denying access to the device, the method further includes: The server sends the current load to the device, so that the device uses the current load multiplied by a preset waiting coefficient as a waiting time, and requests access again after the waiting time.

7. A device access control method, characterized in that: include: The device sends an access request to the server; The device receives a random value range determined by the server according to a current load and / or a number of device access requests; The device selects a corresponding random number within the random value range, and forwards the random number to the server, so that the server determines whether to allow the device to access according to the type of the random number and the current load state; wherein, if the current load does not exceed the preset load and the random number is a composite number, or the current load exceeds the preset load and the random number is a prime number, the server allows the device to access; otherwise, the server refuses the device to access; The device receives response information from the server and selectively accesses the server according to the response information.

8. The device access control method according to claim 7, characterized in that: The device selects a corresponding random number within the random value range, specifically including: Add the device's decimal MAC address to the request time to get the seed number; Calculate the hash value of the seed number using a HASH algorithm, use the hash value as the dividend, use the value obtained by subtracting 1 from the upper boundary value of the random value range as the divisor, and perform a remainder operation to obtain an intermediate number; If the value of the middle number is 0, the random number selected is the value obtained by subtracting 1 from the upper boundary value; If the value of the middle number is 1, the random number is selected as the upper boundary value; Otherwise, a random number is selected as the intermediate number.

9. A device access control device, characterized in that: The device comprises: At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the processor to execute the device access control method described in any one of claims 1-6 or the device access control method described in any one of claims 7-8.