CN116896543A - IP address allocation method and device, electronic equipment and storage medium - Google Patents

IP address allocation method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN116896543A
CN116896543A CN202311161333.8A CN202311161333A CN116896543A CN 116896543 A CN116896543 A CN 116896543A CN 202311161333 A CN202311161333 A CN 202311161333A CN 116896543 A CN116896543 A CN 116896543A
Authority
CN
China
Prior art keywords
network segment
address
target
index value
addresses
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311161333.8A
Other languages
Chinese (zh)
Inventor
石刘强
李国辉
廖光贤
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Mobile Communications Group Co Ltd
China Mobile Suzhou Software Technology Co Ltd
Original Assignee
China Mobile Communications Group Co Ltd
China Mobile Suzhou Software Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Mobile Communications Group Co Ltd, China Mobile Suzhou Software Technology Co Ltd filed Critical China Mobile Communications Group Co Ltd
Priority to CN202311161333.8A priority Critical patent/CN116896543A/en
Publication of CN116896543A publication Critical patent/CN116896543A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/50Address allocation
    • H04L61/5007Internet protocol [IP] addresses

Abstract

The invention provides an IP address allocation method, an IP address allocation device, electronic equipment and a storage medium, wherein the method comprises the following steps: receiving an IP address allocation request sent by a client; determining a target network segment from a pre-established network segment pool according to the IP address allocation request; determining a target IP address from the remaining allocable IP address range under the target network section; and returning the target IP address to the client. Therefore, the balanced distribution of the IP address resources of different network segments can be realized, and the coverage utilization rate of the IP address resources of each network segment can be improved. In addition, the network segment pool replaces the IP address pool to distribute the IP addresses, so that the data size can be greatly reduced, and the IP address distribution performance can be effectively improved. And the network segments of all IP addresses are unified by the network segment pool with lower order of magnitude, so that the problem of IP address dispersion management in the IP address pool scheme can be solved, and the stability and usability of IP address allocation are improved in terms of order magnitude and operability.

Description

IP address allocation method and device, electronic equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to an IP address allocation method, an IP address allocation device, electronic equipment and a storage medium.
Background
With the rapid development of internet technology, the network access demand of end users has increased dramatically, and the demand of IP (Internet Protocol Address internet address) addresses is increasing on the premise of network access. As a limited network resource, the problem of reasonable allocation of IP addresses is a focus of attention of various large vendors. The prior art mainly manages and distributes IP addresses by maintaining an IP address pool, and simultaneously records the use state of each IP address in the pool.
However, in the above manner, since the IP addresses of all the different network segments are indiscriminately managed in the unified IP address pool, and only the use state of the IP addresses is used as the main basis of the IP address allocation, the problem of unbalanced IP address allocation under the different network segments is easy to occur, and flexible management of the IP addresses of the network segments is not facilitated. Meanwhile, when the number of the assignable IP addresses in the IP address pool is insufficient, new network segment expansion is required, and each network segment contains a plurality of IP addresses, so that the new network segment expansion can continuously increase the total data size of the initial IP address pool, meanwhile, the use state of the IP addresses in the pool needs to be frequently updated in the IP address allocation process is considered, and as the capacity of the IP address pool is continuously increased, the frequent state update operation becomes lower and lower, so that the overall IP address allocation performance is affected.
Disclosure of Invention
The embodiment of the invention provides a method, a device, electronic equipment and a storage medium for distributing IP addresses, which are used for solving the technical problems that the scheme for managing and distributing the IP addresses by maintaining an IP address pool in the related art is not beneficial to flexible management of the IP addresses, and the distribution efficiency of the IP addresses is lower and the performance is poorer.
In a first aspect, an embodiment of the present invention provides a method for allocating an IP address, where the method includes:
receiving an IP address allocation request sent by a client;
determining a target network segment from a pre-established network segment pool according to the IP address allocation request;
determining a target IP address from the remaining allocable IP address range under the target network segment;
and returning the target IP address to the client.
Optionally, before receiving the IP address allocation request sent by the client, the method further includes:
establishing a network segment pool, wherein the network segment pool comprises a plurality of network segments, each network segment corresponds to a network segment record, and the network segment record comprises at least one of the following: the management state of the network segment, the IP address allocation range under the network segment and the number of the residual allocable IP addresses under the network segment; wherein the management state includes any one of: the network segment is available or the network segment is not available.
Optionally, determining the target network segment from the pre-established network segment pool according to the IP address allocation request includes:
inquiring a network segment record corresponding to each network segment;
determining the network segment with the management state being available for the network segment and the maximum number of the remaining allocable IP addresses as the target network segment; or alternatively, the process may be performed,
randomly selecting any network segment from network segments with the management state being that the network segments are available and the number of the remaining allocable IP addresses exceeding a preset threshold value, and determining the network segment as the target network segment; or alternatively, the process may be performed,
if the management state of each network segment is that the network segment is unavailable, and/or the number of the remaining assignable IP addresses of each network segment is lower than the preset threshold value, adding a new network segment into the network segment pool;
and determining the new network segment as the target network segment.
Optionally, determining the target network segment from the pre-established network segment pool according to the IP address allocation request includes:
locking the determined target network segment;
judging whether locking is successful;
and if not, re-executing the step of determining the target network segment from the pre-established network segment pool according to the IP address allocation request until the target network segment is successfully locked.
Optionally, the IP address allocation range under the network segment corresponds to a preset index value sequence, and each IP address in the IP address allocation range corresponds to one index value in the index value sequence in sequence; before determining the target IP address from the range of allocatable IP addresses remaining under the target network segment, the method further comprises:
determining the rest index value sequence according to the index value sequence and the allocated index value sequence corresponding to the allocated IP address under the network segment; wherein the remaining index value sequence corresponds to the remaining allocatable IP address range.
Optionally, determining the target IP address from the remaining allocatable IP address range under the target network segment includes:
randomly selecting an index value from the remaining index value sequences; or sequentially selecting a preset number of index values from the rest index value sequences from the first position, or sequentially selecting a preset number of index values from the last position in reverse order; wherein the preset number is equal to the number of the target IP addresses;
and determining the target IP address according to the selected index value and the target network segment.
Optionally, after determining the target IP address according to the selected index value and the target network segment, the method further includes:
adding an index value corresponding to the target network segment into the allocated index value sequence; and, in addition, the processing unit,
updating the number of the remaining allocable IP addresses under the network section; the updated number is the original number of the remaining allocable IP addresses in the network segment minus the preset number.
In a second aspect, an embodiment of the present invention provides an apparatus for allocating an IP address, where the apparatus includes:
the receiving module is used for receiving the IP address allocation request sent by the client;
the execution module is used for determining a target network segment from a pre-established network segment pool according to the IP address allocation request; determining a target IP address from the remaining allocable IP address range under the target network segment; and returning the target IP address to the client.
Optionally, the executing module is further configured to establish a network segment pool before receiving the IP address allocation request sent by the client, where the network segment pool includes a plurality of network segments, each network segment corresponds to a network segment record, and the network segment record includes at least one of the following: the management state of the network segment, the IP address allocation range under the network segment and the number of the residual allocable IP addresses under the network segment; wherein the management state includes any one of: the network segment is available or the network segment is not available.
Optionally, the executing module is further configured to query a network segment record corresponding to each network segment;
determining the network segment with the management state being available for the network segment and the maximum number of the remaining allocable IP addresses as the target network segment; or alternatively, the process may be performed,
randomly selecting any network segment from network segments with the management state being that the network segments are available and the number of the remaining allocable IP addresses exceeding a preset threshold value, and determining the network segment as the target network segment; or alternatively, the process may be performed,
if the management state of each network segment is that the network segment is unavailable, and/or the number of the remaining assignable IP addresses of each network segment is lower than the preset threshold value, adding a new network segment into the network segment pool;
and determining the new network segment as the target network segment.
Optionally, the execution module is further configured to lock the determined target network segment;
judging whether locking is successful;
and if not, re-executing the step of determining the target network segment from the pre-established network segment pool according to the IP address allocation request until the target network segment is successfully locked.
Optionally, the IP address allocation range under the network segment corresponds to a preset index value sequence, and each IP address in the IP address allocation range corresponds to one index value in the index value sequence in sequence; the execution module is further configured to determine, before determining a target IP address from the remaining allocatable IP address range under the target network segment, a remaining index value sequence according to the index value sequence and an allocated index value sequence corresponding to the allocated IP address under the network segment; wherein the remaining index value sequence corresponds to the remaining allocatable IP address range.
Optionally, the execution module is further configured to randomly select an index value from the remaining index value sequence; or sequentially selecting a preset number of index values from the rest index value sequences from the first position, or sequentially selecting a preset number of index values from the last position in reverse order; wherein the preset number is equal to the number of the target IP addresses;
and determining the target IP address according to the selected index value and the target network segment.
Optionally, the executing module is further configured to add an index value corresponding to the target network segment to the allocated index value sequence after determining the target IP address according to the selected index value and the target network segment; and updating the number of the remaining allocable IP addresses in the network section; the updated number is the original number of the remaining allocable IP addresses in the network segment minus the preset number.
In a third aspect, an embodiment of the present invention provides an electronic device, including: a processor, a memory and a program stored on the memory and executable on the processor, which when executed by the processor implements the steps of a method of assigning IP addresses as described in the first aspect.
In a fourth aspect, an embodiment of the present invention provides a computer readable storage medium, on which a computer program is stored, the computer program implementing the steps of a method for allocating IP addresses according to the first aspect when being executed by a processor.
According to the embodiment of the invention, the network segment pool replaces the IP address pool to distribute the IP address, the target network segment is selected and the target IP address to be distributed is determined from the rest of the distributable IP address range under the target network segment, so that the balanced distribution of IP address resources of different network segments can be realized, the problem of unbalanced distribution of IP address pool distribution scheme is solved, the coverage utilization rate of the IP address resources of each network segment can be improved, and the coverage utilization rate of the whole IP address resources is further effectively improved. In addition, the network segment pool replaces the IP address pool to distribute the IP addresses, so that the data size is greatly reduced, the problem of frequent updating of the IP address state can be avoided, and the IP address distribution performance is effectively improved. And the network segment pool with lower order of magnitude carries out unified nano tube on all network segments of IP addresses, one-key management can be realized on the IP addresses to which the network segment pool belongs through the network segment state, the problem of IP address dispersion management in the IP address pool scheme is solved, and the stability and the usability of IP address allocation are improved in terms of order of magnitude and operability.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to designate like parts throughout the figures. In the drawings:
fig. 1 is a schematic diagram of an IP address allocation system according to an embodiment of the present invention;
fig. 2 is a flowchart of a method for allocating IP addresses according to an embodiment of the present invention;
fig. 3 is a flowchart of a method for allocating IP addresses according to an embodiment of the present invention;
fig. 4 is a block diagram of a configuration of an IP address allocation apparatus according to an embodiment of the present invention;
fig. 5 is a block diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Fig. 1 shows an architecture diagram of an IP address assignment system (IP address assignment management console) according to an embodiment of the present invention, which involves the following key points.
And (3) a network segment pool: the network segment management method is used for managing the associated network segment information of all the allocatable IP addresses, sharing a network segment pool record with all the IP addresses under the network segment, wherein each record comprises the management state of the network segment, the IP address allocation range, the number of the rest allocatable IP addresses and the like.
Index value sequence: all IP addresses of a network segment are marked in turn by a set of consecutive values (e.g., consecutive positive integers 123456 … …), each of the marked values corresponding to an IP address being referred to as an index value for that IP address under the current network segment, together with a plurality of IP address index values under the network segment forming an index value sequence, whereby the index values can be used to directly proxy the IP address, and correspondingly, the corresponding IP address can be uniquely matched according to the network segment and the index value.
Cache queue: the method is used for storing index value sequences of used IP addresses of network segments, each network segment independently shares a buffer queue record, the key of the buffer queue is a unique identification of the network segment, namely the network segment ID, and the value records the index value sequences of all used IP addresses of the current network segment.
The calculation module: according to the IP address distribution range of the target network segment and the index value sequence of the used IP address of the network segment, a problem model (detailed later) for searching for missing elements in the ordered array is established, a design algorithm calculates the index value sequence of the residual allocable IP address of the network segment, and optionally, the first index value can be converted into the corresponding target IP address and returned.
Network segment pool management module: the method is used for directly managing and operating all network segment records in the network segment pool, including the initialization addition and smooth expansion of new network segments, the control console management of network segment states, the dynamic monitoring of the number of available IP addresses of the network segments and the like.
Based on the system architecture diagram shown in fig. 1, fig. 2 shows a method for allocating IP addresses according to an embodiment of the present invention, where the method includes:
step S101, receiving an IP address allocation request sent by a client;
step S102, determining a target network segment from a pre-established network segment pool according to an IP address allocation request;
step S103, determining a target IP address from the remaining allocatable IP address range under the target network segment;
step S104, the target IP address is returned to the client.
In one possible implementation manner, before receiving the IP address allocation request sent by the client in step S101, a network segment pool needs to be established, where the network segment pool includes a plurality of network segments, each network segment corresponds to a network segment record, and the network segment record includes at least one of the following: the management state of the network segment, the IP address distribution range under the network segment and the number of the residual distributable IP addresses under the network segment; wherein the management state includes any one of: the network segment is available or the network segment is not available.
It should be noted that the network segment pool may be used to nanotube the associated network segment information of all the assignable IP addresses, and share a network segment pool record with all the IP addresses under the network segment, where each record includes the management state of the network segment, the IP address assignment range, the number of remaining assignable IP addresses, and so on.
In one possible implementation manner, step S102, determining, according to the IP address allocation request, the target network segment from the pre-established network segment pool includes: inquiring a network segment record corresponding to each network segment; determining the network segment with the management state of network segment availability and the maximum number of the remaining allocable IP addresses as a target network segment; or, randomly selecting any network segment from network segments with the management state of network segments available and the number of the remaining allocable IP addresses exceeding a preset threshold value, and determining the network segment as a target network segment; or if the management state of each network segment is that the network segment is unavailable and/or the number of the remaining allocable IP addresses of each network segment is lower than a preset threshold, adding a new network segment into the network segment pool; the new network segment is determined as the target network segment.
In the above three cases, the preset threshold may be 1 or any positive integer value set by the user according to experience or actual application scenario; the range of the allocation target is locked according to the maximum residual allocable IP address quantity of the network segments, so that the balanced allocation of IP address resources of different network segments can be realized; the network segment pool is used for replacing the IP address pool with huge data scale, the available quantity of the IP addresses can be dynamically monitored according to the information of each network segment in the pool, when the quantity is insufficient, the network segment expansion is carried out, only the initial information of a new network segment is added to the network segment pool, and all IP addresses are not required to be added to the IP address pool in batches, so that the data size is greatly reduced.
In one possible implementation manner, step S102, determining, according to the IP address allocation request, the target network segment from the pre-established network segment pool includes: locking the determined target network segment; judging whether locking is successful; if not, the step of determining the target network segment from the pre-established network segment pool is re-executed according to the IP address allocation request until the target network segment is successfully locked. It should be noted that, the target network segment is locked, and the subsequent IP address allocation operations are all limited to the locked network segment, and the network segment is not secondarily scheduled. Thus, the problem of reuse of the IP address caused by concurrent allocation requests can be avoided by locking network segments.
In one possible implementation, the IP address allocation range under the network segment corresponds to a preset index value sequence, each IP address in the IP address allocation range corresponds to one index value in the index value sequence in sequence, and before determining the target IP address from the remaining allocable IP address range under the target network segment, the method further includes: determining the rest index value sequence according to the index value sequence and the allocated index value sequence corresponding to the allocated IP address under the network segment; wherein the remaining index value sequence corresponds to the remaining allocatable IP address range. It should be noted that, all the IP addresses of the network segment are marked sequentially by a set of consecutive values (for example, consecutive positive integers 123456 … …), and each marked value corresponding to each IP address is called an index value of the IP address under the current network segment, and the index values of the IP addresses under the same network segment form an index value sequence, so that the IP addresses can be directly proxied by using the index values, and correspondingly, the corresponding IP addresses can be uniquely matched according to the network segment and the index values.
In one possible implementation, determining the target IP address from the remaining allocatable IP address range under the target network segment includes: randomly selecting an index value from the rest index value sequences; or sequentially selecting a preset number of index values from the rest index value sequences from the first position, or sequentially selecting a preset number of index values from the last position in reverse order; wherein the preset number is equal to the number of target IP addresses. And determining the target IP address according to the selected index value and the target network segment.
The implementation mode shows three optional allocation modes, can flexibly select a proper allocation mode according to actual needs in specific application, and sequentially selects the allocation modes of the preset number of index values from the beginning, so that the efficiency is high and the management is convenient.
In one possible implementation, after determining the target IP address according to the selected index value and the target network segment, the method further includes: adding an index value corresponding to the target network segment into an allocated index value sequence; and updating the number of the remaining allocable IP addresses in the network section; the updated number is the original number of the remaining allocable IP addresses in the network segment minus the preset number. That is, the network segment record is adjusted and updated at any time according to the distribution result of the IP address, and the corresponding distributed index value sequence is updated, so that the status is updated in time, thereby avoiding disorder of management of the IP address and avoiding distribution errors.
In summary, the embodiment of the invention is based on the problem of IP address allocation, and provides a method for directly controlling the IP address allocation process by replacing an IP address pool with a network segment pool, wherein the IP address allocation method based on network segment control can realize the equalization of allocation results and improve the coverage utilization rate of IP addresses; the network segment pool can greatly reduce the scale of the managed target data volume, and effectively improve the distribution performance of the IP address; the network segment controls the IP address to perform unified centralized management on the IP address, and the stability and usability of the overall IP address allocation are ensured. In addition, in the process of selecting the allocatable IP address based on the network segment, the embodiment of the invention proposes to use a lighter index value to proxy the IP address, use a high-performance cache queue to store the used record, and compared with the direct operation of a large-scale IP address pool, the embodiment of the invention adopts an index value allocation mode to skillfully solve the IP address allocation problem, and has higher safety, stability and flexibility.
Fig. 3 shows a flowchart of a method for allocating IP addresses according to an embodiment of the present invention, based on the system architecture diagram shown in fig. 1. As shown in fig. 3, the method includes.
step1: in an IP address allocation management console (IP address allocation system), initial segment information available for IP address allocation is added to a segment pool by a segment pool management module, and the added segment information must contain the management state of the segment, the IP address allocation range, the number of remaining allocable IP addresses, and the like.
step2: the IP address allocation management console receives the IP address allocation request through a unified interface, initiates an IP address allocation flow through the request processing module, and feeds back an IP address allocation result to the requester.
step3: and obtaining a network segment record list meeting the condition from the network segment pool by taking the maximum number of available network segment states and the remaining allocable IP addresses of the network segments as selection conditions.
It should be noted that, since the network segment with the largest remaining amount of IP addresses is selected each time, the allocation result equalization may be implemented, but this is an alternative implementation, and embodiments of the present invention are not limited thereto.
step4: judging whether a network segment record list meeting the conditions acquired in step3 exists or not, and when the network segment is unavailable (for example, the network segment is offline) or the IP address remaining quantity of the network segment is insufficient, or the IP address remaining quantity of the network segment is lower than a preset threshold value, failing to acquire the record meeting the conditions, and entering step1 to expand the new network segment; otherwise, the distribution flow can be continued.
The preset threshold value can be preset by a user according to experience or actual application scenes.
step5: selecting one network segment from the network segment record list meeting the condition as a target network segment, locking the network segment, and limiting the subsequent IP address allocation operation to the locked network segment, wherein the network segment is not secondarily scheduled. Thus, the problem of reuse of the IP address caused by concurrent allocation requests can be avoided by locking network segments.
step6: judging whether the locking of the target network segment in step5 is successful, if the target network segment is locked by other allocation requests and is in the allocation operation, the network segment occupies the lock failure, and entering step3 to acquire other network segment records meeting the conditions again; otherwise, IP address allocation can be performed under the target network segment successfully locked.
It should be noted that steps 1 to 6 belong to the first stage of the IP address allocation method according to the embodiment of the present invention, and the main function thereof is to lock the target network segment. The subsequent IP address assignment step based on this target network segment is referred to as the second stage of the method.
step7: each network segment has a lightweight cache queue in the cache, the key of the cache queue is the network segment ID, and the value is the index value sequence of the IP address to which the network segment has been assigned. The target segment ID locked according to the first stage may obtain its value, i.e. the assigned index value sequence, from the cache queue. In addition, when a new network segment is allocated for the first time, there is no cache queue matching with the new network segment, so that a cache queue record with value being empty needs to be initialized for the new network segment.
step8: according to the IP address distribution range of the target network segment locked in step6 and the value of the cache queue in step7, calculating the index value sequence of the rest allocatable IP addresses of the network segment by an algorithm of an index value calculation module, and taking the IP address corresponding to the first index value as the allocated target IP address (which is an optional implementation mode).
step9: after the target IP address distributed by the index value calculation module is returned to the request processing module, subsequent operations such as synchronization of used data are needed. On the one hand, the index value of the allocated target IP address is added to the used index value sequence of the target network segment, and the index value is rewritten into the cache queue; on the other hand, the number of the remaining allocable IP addresses of the target network segment is updated in the network segment pool, the target network segment is unlocked at the same time, and the current allocation process is ended.
As the core of the IP address allocation method provided by the embodiment of the present invention, the algorithm processing procedure related to the index value calculation module in step8 is further described as follows: the key point is that all IP addresses of each network segment are marked by a group of continuous values to form an index value sequence, and the continuous index value sequence rather than the IP addresses are adopted as objects, so that problem modeling is facilitated, and an allocable target range is calculated rapidly. For this purpose, firstly, a conversion function of the IP address and the corresponding index value in the target network segment is introduced, and is recorded as:
wherein the method comprises the steps ofRepresenting the first of the target network segmentsThe index value corresponding to the one IP address,is an index valueIs used for the sequence number of (c),is the total number of IP addresses under the target network segment,and indicating the index value corresponding to the initial IP address in the target network segment. Secondly, the index value sequence of the allocated IP address obtained from the buffer queue of the target network segment is recorded as follows:
can be according to the above formulaTo directly calculate the sequence number list corresponding to the used index value sequence. IP address allocation range in combination with target network segmentThe problem of solving the sequence of index values for the remaining allocatable IP addresses of the target network segment can be equivalently modeled as: "find missing elements in ordered array", the specific modeling process is as follows: distribution range of IP address of target network segmentModeling as a complete ordered array; list of sequence numbers corresponding to the index value sequence allocated to the target network segmentModeling is performed as an ordered group with possible missing elements, then the sequence number list corresponding to the rest of the assignable index value sequences of the target network segment is all missing elements, and the assignment target can be satisfied only by taking the first missing element.
For the above problem model, a solution algorithm is designed as follows:
in the above algorithm, the algorithm is a combination of the algorithm,an ordered array representing the existence of missing elements, i.e., a list of sequence numbers corresponding to the assigned index value sequence,is the length of the array of the data,is the first element of the array that is missing, i.e. the first remaining allocatable target,are subscripts of the array. In addition, the algorithm relates to a method for calculating the number of missing elements of the array, which is recorded as follows:
wherein, the liquid crystal display device comprises a liquid crystal display device,the subscript value of the array is represented,indicating cut-offThe number of elements in the bit actual is,indicating the number of elements which should be present up to the position without missing the element, and obtaining the cut-offNumber of missing elements. Based on the method, the target can be found out quickly finally by traversing in combination with the dichotomy. Therefore, the sequence number corresponding to the index value of the residual allocable IP address of the target network section can be solved through the algorithm, the index value of the target network section is further solved, and the allocated target IP address can be obtained by combining the information of the target network section.
It should be noted that, in a specific application scenario, when an IP address allocation request is received, firstly, a network segment is obtained from a network segment pool according to a management state of the network segment and the number of remaining allocable IP addresses, and is locked, the network segment is in an available state, and the number of remaining allocable IP addresses is maximum, then, an index value sequence used by the network segment is obtained from a cache queue according to the locked network segment, and an equivalence problem model is established and a solution algorithm is designed, so that the remaining allocable index value sequence of the network segment is calculated, and an IP address corresponding to the first index value is taken as a final allocation target; and finally, writing the index value into a high-performance cache queue, updating the number of the residual allocable IP addresses of the network segment and unlocking the network segment. Therefore, the balanced distribution of the IP address resources of different network segments can be realized, the problem of unbalanced distribution in the IP address pool distribution scheme is solved, the coverage utilization rate of the IP address resources of each network segment can be improved, and the coverage utilization rate of the whole IP address resources is further effectively improved; in addition, the network segment pool replaces the IP address pool to distribute the IP addresses, so that the data size is greatly reduced, the problem of frequent updating of the IP address state can be avoided, and the IP address distribution performance is effectively improved; and the network segment pool with lower order of magnitude carries out unified nano tube on all network segments of IP addresses, one-key management can be realized on the IP addresses to which the network segment pool belongs through the network segment state, the problem of IP address dispersion management in the IP address pool scheme is solved, and the stability and the usability of IP address allocation are improved in terms of order of magnitude and operability.
Further, the method for allocating the IP address provided by the embodiment of the present invention is applicable to any system having an IP address allocation requirement. For example: in the current mobile cloud management platform, service products related to IP address allocation include an elastic public network IP, an in-cloud IPv4 network, an IPv6 network and the like, and as the computing network is continuously pushed and the mobile cloud is rapidly developed, the demand for IP addresses is further increased, and the allocation and management requirements for the IP addresses are correspondingly improved, for example: when a user orders an elastic public network IP product through a mobile cloud network management console, the problem of public network IP address allocation is related, and similarly, the problem of IP address allocation is also related when an IPv4 network and an IPv6 network in the cloud are created based on the virtual private cloud. Therefore, the IP address allocation method provided by the embodiment of the invention has wide application prospect.
Fig. 4 shows an apparatus for allocating IP addresses according to an embodiment of the present invention, where an apparatus 40 includes:
a receiving module 401, configured to receive an IP address allocation request sent by a client;
an execution module 402, configured to determine a target network segment from a pre-established network segment pool according to an IP address allocation request; determining a target IP address from the remaining allocable IP address range under the target network section; and returning the target IP address to the client.
In a possible implementation manner, the execution module 402 is further configured to, before receiving the IP address allocation request, establish a network segment pool, where the network segment pool includes a plurality of network segments, each network segment corresponds to a network segment record, and the network segment record includes at least one of: the management state of the network segment, the IP address distribution range under the network segment and the number of the residual distributable IP addresses under the network segment; wherein the management state includes any one of: the network segment is available or the network segment is not available.
In a possible implementation manner, the execution module 402 is further configured to query a segment record corresponding to each segment;
determining the network segment with the management state of network segment availability and the maximum number of the remaining allocable IP addresses as a target network segment; or alternatively, the process may be performed,
randomly selecting any network segment from network segments with available management states and the number of the remaining allocable IP addresses exceeding a preset threshold value, and determining the network segment as a target network segment; or alternatively, the process may be performed,
if the management state of each network segment is that the network segment is unavailable and/or the number of the remaining assignable IP addresses of each network segment is lower than a preset threshold value, adding a new network segment into the network segment pool; the new network segment is determined as the target network segment.
In one possible implementation, the execution module 402 is further configured to lock the determined target network segment;
judging whether locking is successful;
if not, the step of determining the target network segment from the pre-established network segment pool is re-executed according to the IP address allocation request until the target network segment is successfully locked.
In one possible implementation manner, the IP address allocation range under the network segment corresponds to a preset index value sequence, and each IP address in the IP address allocation range corresponds to one index value in the index value sequence in sequence; the execution module is further used for determining the remaining index value sequence according to the index value sequence and the assigned index value sequence corresponding to the assigned IP address under the network segment before determining the target IP address from the remaining assignable IP address range under the target network segment; wherein the remaining index value sequence corresponds to the remaining allocatable IP address range.
In one possible implementation, the execution module 402 is further configured to randomly select an index value from the remaining index value sequence; or sequentially selecting a preset number of index values from the rest index value sequences from the first position, or sequentially selecting a preset number of index values from the last position in reverse order; wherein the preset number is equal to the number of the target IP addresses; and determining the target IP address according to the selected index value and the target network segment.
In a possible implementation manner, the execution module 402 is further configured to, after determining the target IP address according to the selected index value and the target network segment, add the index value corresponding to the target network segment to the assigned index value sequence; and updating the number of the remaining allocable IP addresses in the network section; the updated number is the original number of the remaining allocable IP addresses in the network segment minus the preset number.
In the embodiment of the invention, the network segment pool replaces the IP address pool to distribute the IP addresses, the range of the distribution targets is locked according to the maximum residual distributable IP address quantity of the network segments, the balanced distribution of the IP address resources of different network segments can be realized, the problem of unbalanced distribution of the IP address pool distribution scheme is solved, the coverage utilization rate of the IP address resources of each network segment is improved, and the coverage utilization rate of the whole IP address resources is further effectively improved.
In the embodiment of the invention, the network segment pool is used for replacing the IP address pool with huge data scale, the available number of the IP addresses can be dynamically monitored according to the information of each network segment in the pool, when the number is insufficient, the network segment expansion is carried out, only the initial information of a new network segment is needed to be added to the network segment pool, all IP addresses of the new network segment are not needed to be added to the IP address pool in batches, the data scale is greatly reduced, and meanwhile, the technical scheme avoids the problem of frequent updating of the IP address state and effectively improves the IP address allocation performance. And the network segment pool with lower order of magnitude carries out unified nano tube on all network segments of IP addresses, the dynamic monitoring of the number of the IP addresses of each network segment and the smooth expansion of the new network segment are realized through a management console, the one-key management of the IP address to which the network segment belongs can also be realized through the network segment state, and the stability and the usability of IP address allocation are improved in terms of order of magnitude and operability.
In the embodiment of the invention, all IP addresses are managed from the network segment level, the allocation behavior of each IP address is limited in the range of the network segment, one-key management can be realized on all the associated IP addresses by operating the state of the network segment, the problem of IP address dispersion management in the IP address pool scheme is solved, and meanwhile, the IP address allocation behaviors of different network segments are mutually isolated, so that the normal allocation in other network segments is not influenced when the state of a certain network segment is updated, and the stability and the usability of the overall IP address allocation are ensured.
In the embodiment of the invention, the IP address is proxied by lighter index values, an equivalent problem model for searching the missing elements in the ordered array is established by combining the cache queue, the goal of IP address allocation is achieved by designing a solving algorithm, and the IP address allocation process is mathematically performed, thereby being beneficial to improving the safety, stability and flexibility of IP address allocation.
The embodiment of the invention also provides an electronic device 50, as shown in fig. 5, including: the processor 501, the memory 502, and a program stored in the memory 502 and executable on the processor 501, which when executed by the processor, implement the steps of an IP address allocation method as in the above-described embodiment.
The embodiment of the present invention further provides a computer readable storage medium, where a computer program is stored, where the computer program when executed by a processor implements each process of the method embodiments shown in fig. 2 and fig. 3 and achieves the same technical effects, and in order to avoid repetition, a detailed description is omitted here. Wherein the computer readable storage medium is selected from Read-Only Memory (ROM), random access Memory (Random Access Memory, RAM), magnetic disk or optical disk.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. ROM/RAM, magnetic disk, optical disk) comprising instructions for causing a terminal (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the method according to the embodiments of the present invention.
The embodiments of the present invention have been described above with reference to the accompanying drawings, but the present invention is not limited to the above-described embodiments, which are merely illustrative and not restrictive, and many forms may be made by those having ordinary skill in the art without departing from the spirit of the present invention and the scope of the claims, which are to be protected by the present invention.

Claims (10)

1. A method for assigning an IP address, the method comprising:
receiving an IP address allocation request sent by a client;
determining a target network segment from a pre-established network segment pool according to the IP address allocation request;
determining a target IP address from the remaining allocable IP address range under the target network segment;
and returning the target IP address to the client.
2. The method of claim 1, wherein prior to receiving the IP address assignment request sent by the client, the method further comprises:
establishing a network segment pool, wherein the network segment pool comprises a plurality of network segments, each network segment corresponds to a network segment record, and the network segment record comprises at least one of the following: the management state of the network segment, the IP address allocation range under the network segment and the number of the residual allocable IP addresses under the network segment; wherein the management state includes any one of: the network segment is available or the network segment is not available.
3. The method of claim 2, wherein determining a target network segment from a pre-established pool of network segments based on the IP address assignment request comprises:
inquiring a network segment record corresponding to each network segment;
determining the network segment with the management state being available for the network segment and the maximum number of the remaining allocable IP addresses as the target network segment; or alternatively, the process may be performed,
randomly selecting any network segment from network segments with the management state being that the network segments are available and the number of the remaining allocable IP addresses exceeding a preset threshold value, and determining the network segment as the target network segment; or alternatively, the process may be performed,
if the management state of each network segment is that the network segment is unavailable, and/or the number of the remaining assignable IP addresses of each network segment is lower than the preset threshold value, adding a new network segment into the network segment pool;
and determining the new network segment as the target network segment.
4. The method of claim 1, wherein determining a target network segment from a pre-established pool of network segments in accordance with the IP address assignment request comprises:
locking the determined target network segment;
judging whether locking is successful;
and if not, re-executing the step of determining the target network segment from the pre-established network segment pool according to the IP address allocation request until the target network segment is successfully locked.
5. The method of claim 2, wherein the IP address allocation range under the network segment corresponds to a preset index value sequence, and each IP address in the IP address allocation range corresponds to one index value in the index value sequence in sequence; before determining the target IP address from the range of allocatable IP addresses remaining under the target network segment, the method further comprises:
determining the rest index value sequence according to the index value sequence and the allocated index value sequence corresponding to the allocated IP address under the network segment; wherein the remaining index value sequence corresponds to the remaining allocatable IP address range.
6. The method of claim 5, wherein determining a target IP address from the range of allocatable IP addresses remaining under the target network segment comprises:
randomly selecting an index value from the remaining index value sequences; or sequentially selecting a preset number of index values from the rest index value sequences from the first position, or sequentially selecting a preset number of index values from the last position in reverse order; wherein the preset number is equal to the number of the target IP addresses;
and determining the target IP address according to the selected index value and the target network segment.
7. The method of claim 6, wherein after determining the target IP address based on the selected index value and the target network segment, the method further comprises:
adding an index value corresponding to the target network segment into the allocated index value sequence; and, in addition, the processing unit,
updating the number of the remaining allocable IP addresses under the network section; the updated number is the original number of the remaining allocable IP addresses in the network segment minus the preset number.
8. An apparatus for assigning IP addresses, the apparatus comprising:
the receiving module is used for receiving the IP address allocation request sent by the client;
the execution module is used for determining a target network segment from a pre-established network segment pool according to the IP address allocation request; determining a target IP address from the remaining allocable IP address range under the target network segment; and returning the target IP address to the client.
9. An electronic device, comprising: a processor, a memory and a program stored on the memory and executable on the processor, which when executed by the processor, implements the steps of the IP address allocation method according to any one of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored, which computer program, when being executed by a processor, implements the steps of the IP address allocation method according to any one of claims 1 to 7.
CN202311161333.8A 2023-09-11 2023-09-11 IP address allocation method and device, electronic equipment and storage medium Pending CN116896543A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311161333.8A CN116896543A (en) 2023-09-11 2023-09-11 IP address allocation method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311161333.8A CN116896543A (en) 2023-09-11 2023-09-11 IP address allocation method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116896543A true CN116896543A (en) 2023-10-17

Family

ID=88311116

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311161333.8A Pending CN116896543A (en) 2023-09-11 2023-09-11 IP address allocation method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116896543A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102281333A (en) * 2010-06-11 2011-12-14 中兴通讯股份有限公司 Method and system for avoiding IP address conflict, DHCP server and DHCP client
CN105872130A (en) * 2016-06-14 2016-08-17 浪潮电子信息产业股份有限公司 Method for distributing IP (Internet Protocol) addresses and cloud management platform
CN111629083A (en) * 2020-06-01 2020-09-04 瑞斯康达科技发展股份有限公司 Method, device, storage medium and electronic device for acquiring IP address
CN112995349A (en) * 2019-12-12 2021-06-18 中兴通讯股份有限公司 Address management method, server, and computer-readable storage medium
CN115022289A (en) * 2022-05-31 2022-09-06 苏州浪潮智能科技有限公司 Method, device, equipment and storage medium for detecting continuously available IP addresses
CN116366606A (en) * 2023-03-31 2023-06-30 北京奇艺世纪科技有限公司 IP address allocation method and device, electronic equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102281333A (en) * 2010-06-11 2011-12-14 中兴通讯股份有限公司 Method and system for avoiding IP address conflict, DHCP server and DHCP client
CN105872130A (en) * 2016-06-14 2016-08-17 浪潮电子信息产业股份有限公司 Method for distributing IP (Internet Protocol) addresses and cloud management platform
CN112995349A (en) * 2019-12-12 2021-06-18 中兴通讯股份有限公司 Address management method, server, and computer-readable storage medium
CN111629083A (en) * 2020-06-01 2020-09-04 瑞斯康达科技发展股份有限公司 Method, device, storage medium and electronic device for acquiring IP address
CN115022289A (en) * 2022-05-31 2022-09-06 苏州浪潮智能科技有限公司 Method, device, equipment and storage medium for detecting continuously available IP addresses
CN116366606A (en) * 2023-03-31 2023-06-30 北京奇艺世纪科技有限公司 IP address allocation method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
US10901796B2 (en) Hash-based partitioning system
CN109343963B (en) Application access method and device for container cluster and related equipment
CN109040212B (en) Method, system, device and storage medium for accessing device to server cluster
US9052962B2 (en) Distributed storage of data in a cloud storage system
CN103038788B (en) Providing multiple network resources
CN103518364B (en) The data-updating method of distributed memory system and server
CN109684307A (en) A kind of date storage method, device, equipment and storage medium
JP5701398B2 (en) Computer system, data management method and program
CN109379448B (en) File distributed deployment method and device, electronic equipment and storage medium
CN110474940B (en) Request scheduling method, device, electronic equipment and medium
CN103024053A (en) Cloud storage method, resource scheduling system and cloud storage node and system
JP6582445B2 (en) Thin client system, connection management device, virtual machine operating device, method, and program
JP2009295127A (en) Access method, access device and distributed data management system
EP2998862A1 (en) Method, device, and system for memory management
CN110569302A (en) method and device for physical isolation of distributed cluster based on lucene
CN111857539B (en) Method, apparatus and computer readable medium for managing a storage system
US20220318071A1 (en) Load balancing method and related device
CN113515364A (en) Data migration method and device, computer equipment and storage medium
Hsieh et al. The incremental load balance cloud algorithm by using dynamic data deployment
US9760370B2 (en) Load balancing using predictable state partitioning
CN114500462A (en) Virtual private cloud network address allocation method and device, electronic equipment and medium
WO2010079713A1 (en) Distributed file name resolution system, distributed file name resolution method, and distributed file name resolution program
CN112422611B (en) Virtual bucket storage processing method and system based on distributed object storage
CN105978744B (en) A kind of resource allocation methods, apparatus and system
CN109005071B (en) Decision deployment method and scheduling equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination