Network address allocation method and device, electronic equipment, chip and storage medium
Through the combination of bitmap storage and ETCD path, the uniqueness and efficiency problems of IP address allocation in VPC scenarios are solved, efficient allocation and release of IP addresses is achieved, and the problems of waste of storage resources and high complexity in the existing technology are solved. .
Patent Information
- Application Number
- CN202410972750.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-19
- Publication Date
- 2024-09-27
AI Technical Summary
In cloud computing networks, there is the possibility of massive storage of IP addresses in VPC scenarios. How to quickly search and allocate IP addresses and ensure the uniqueness of IP address allocation? Existing solutions have problems such as waste of storage resources and high system complexity. .
Bitmaps are used to store IP resources, and subnet segmentation and ETCD storage data paths are used to achieve efficient allocation and release of IP addresses, ensure uniqueness, and reduce system complexity.
Effectively save storage space, improve the efficiency of IP address allocation, ensure uniqueness, and reduce system implementation complexity.
Smart Images

Figure CN118714115A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of IT support, and in particular to a network address allocation method, device, electronic device, chip and storage medium. Background Art
[0002] In the field of cloud computing network products, if virtual machines in a virtual private cloud (VPC) want to communicate with each other, they need to apply for a unique Internet Protocol (IP) address in their network. However, there is the possibility of massive storage of IP addresses in the VPC scenario. Therefore, how to achieve massive storage in the VPC scenario and ensure the uniqueness of IP address allocation is the main problem to be solved by this solution. Summary of the invention
[0003] The present disclosure provides a network address allocation method, device, electronic device, chip and storage medium, which can realize mass storage in a VPC scenario and ensure the uniqueness of IP address allocation.
[0004] The first aspect of the present disclosure proposes a network address allocation method, which includes, in response to an IP address allocation request of a target device, determining a starting IP and an ending IP corresponding to a subnet to determine a target subdivided network segment, wherein the target subdivided network segment is one of a plurality of subdivided network segments included in a subnet segment of the subnet; determining a target IP address from a first storage space based on the target subdivided network segment, wherein the first storage space stores the IP address corresponding to each subdivided network segment via a bitmap; and allocating the target IP address to a target device.
[0005] In some embodiments of the present disclosure, in response to an IP address allocation request of a target device, determining the starting IP and ending IP corresponding to the subnet to determine the target subdivided network segment includes: determining the subnet segment based on the starting IP and the ending IP; determining multiple subdivided network segments based on the subnet segment and the bitmap storage structure; if the IP address allocation request includes a specified IP, determining whether the specified IP falls into the subnet segment, and determining whether the specified IP is occupied, if the specified IP falls into the subnet segment and the specified IP is not occupied, determining the target subdivided network segment for the specified IP; if the IP address allocation request does not include the specified IP, determining whether there is an available IP in the subnet segment, and if so, determining the target subdivided network segment that includes the available IP in the subnet segment.
[0006] In some embodiments of the present disclosure, determining the target IP address from the first storage space according to the target network segment includes: if the IP address allocation request includes a specified IP, determining the target storage position of the specified IP in the target network segment according to the initial IP of the target network segment and the storage position of the initial IP in the target network segment; determining whether the bitmap value of the target storage position is a first preset value, and if so, determining that the specified IP has not yet been allocated; and determining that the specified IP is the target IP address.
[0007] In some embodiments of the present disclosure, determining the target IP address from the first storage space according to the target network segment includes: if the IP address allocation request does not include a specified IP, searching the target storage location whose bitmap value is a first preset value in the target network segment; determining the target IP address according to the initial IP of the target network segment and the target storage location.
[0008] In some embodiments of the present disclosure, assigning a target IP address to a target device includes: setting the bitmap value of the target storage location to a second preset value; reducing the number of available IP addresses in the target segment by one; feeding back the target IP address to the target device, and storing the target IP address in an allocated service table.
[0009] In some embodiments of the present disclosure, the method also includes: when the target device releases the target IP address, setting the bitmap value of the target storage location to a first preset value; increasing the number of available IPs in the target segment by one; and deleting the target IP address from the allocated service table.
[0010] In some embodiments of the present disclosure, the first storage space includes: a first structure, the first structure is used to maintain subnet business information; a second structure, the second structure is used to maintain subnet resources and the IP range owned by the subnet; a third structure, the third structure includes multiple subdivided network segments, each subdivided network segment stores the IP resources owned by the subnet in a bitmap structure, the IP resources include allocation attributes, IP positioning attributes, and IP calculation attributes, the allocation attributes are used to identify whether the IP resources have been allocated, the IP positioning attributes are used to identify the range of IP resources and the number of IPs to be allocated, and the IP calculation attributes are used to identify the initial IP of each subdivided network segment.
[0011] In some embodiments of the present disclosure, determining the target IP address from the first storage space according to the target subdivided network segment includes: determining the target IP address from the first storage space according to the ETCD storage data path; wherein the ETCD storage data path includes: a subdivided network segment path, through which all IP resources stored in the subdivided network segment can be obtained; a subdivided network segment resource path, through which the subdivided network segment resource can be used to obtain a subdivided network segment containing a specified IP or a subdivided network segment containing at least one available IP; an allocated IP path, through which it can be obtained whether the specified IP has been allocated.
[0012] The second aspect embodiment of the present disclosure proposes an electronic device, comprising: 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 at least one processor so that the at least one processor can execute the method described in the first aspect embodiment of the present disclosure.
[0013] The third aspect embodiment of the present disclosure proposes a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the method described in the first aspect embodiment of the present disclosure.
[0014] A fourth aspect embodiment of the present disclosure provides a computer program product, including a computer program, which executes the method described in the first aspect embodiment of the present disclosure when a processor is used to execute the computer program.
[0015] The fifth aspect embodiment of the present disclosure proposes a chip, which includes one or more interfaces and one or more processors; the interface is used to receive signals from a memory of an electronic device and send signals to the processor, the signals include computer instructions stored in the memory, and when the processor executes the computer instructions, the electronic device executes the method described in the first aspect embodiment of the present disclosure.
[0016] In summary, the network address allocation method, device, electronic device, chip and storage medium proposed in the present invention can achieve the uniqueness of IP address allocation by responding to the IP address allocation request of the target device, determining the target subdivided network segment, and obtaining the IP address allocated to the target device from the first storage space according to the subdivided network segment; the first storage space stores IP addresses through a bitmap, which can save storage space.
[0017] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0019] Figure 1 A flowchart of a network address allocation method provided in an embodiment of the present disclosure;
[0020] Figure 2 A flowchart of a network address allocation method provided by an embodiment of the present disclosure;
[0021] Figure 3 A flowchart of a network address allocation method provided by an embodiment of the present disclosure;
[0022] Figure 4 A flowchart of a network address allocation method provided by an embodiment of the present disclosure;
[0023] Figure 5 A flowchart of a network address allocation method provided by an embodiment of the present disclosure;
[0024] Figure 6 An ER diagram of an IP storage method provided in an embodiment of the present disclosure;
[0025] Figure 7 A schematic diagram of an IP allocation method provided in an embodiment of the present disclosure;
[0026] Figure 8 A schematic diagram of an IP allocation method based on ETCD transactions provided in an embodiment of the present disclosure;
[0027] Fig. 9 A schematic diagram of the structure of a network address allocation device provided in an embodiment of the present disclosure;
[0028] Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure;
[0029] Fig.11 A schematic diagram of the chip structure provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0030] Embodiments of the present disclosure are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present disclosure, and should not be construed as limiting the present disclosure.
[0031] In the field of cloud computing network products, IP address allocation is an indispensable and important function. If virtual machines within a VPC want to communicate with each other, they need to apply for a unique IP (such as a Fixed IP or a floating IP, etc.) in the network to which they belong, and IP addresses within the same VPC cannot be allocated repeatedly. However, there is the possibility of massive storage of IP addresses in the VPC scenario. For example, each VPC may have a unique set of IP address systems. As far as IPv4 addresses are concerned, each IP address system has a maximum of more than 4 billion IPv4 addresses, and each IPv4 address requires 4 bytes for storage. Therefore, how to achieve massive IP address storage in the VPC scenario, how to achieve rapid search and allocation of IP addresses, and how to ensure the uniqueness of IP address allocation are all topics worth studying.
[0032] When allocating IP addresses using existing solutions, two aspects usually need to be considered:
[0033] 1. Storage methods of IP resources. Different storage methods determine different IP allocation methods.
[0034] 2. A method to ensure the uniqueness of IP when allocating IP. Because IP address is a shared resource, when applying for IP address resources concurrently, it is necessary to ensure the uniqueness and efficiency of IP address.
[0035] In terms of the storage method of IP resources, existing solutions usually adopt an explicit storage method without encoding IP addresses. For example, the IP address is used as a table record in a relational database, and a status bit is used to indicate whether it is available. In this way, when an IP is allocated, an IP record will be explicitly added to the library table, and those recycled IPs will continue to remain in the library table; or the entire set of unallocated IP addresses in a certain IP segment is stored in Redis, and when the IP is allocated or recycled, the IP address set is dynamically updated.
[0036] In terms of methods for ensuring IP uniqueness when allocating IPs, existing solutions usually use database optimistic locking and unique indexing, or use Redis collections to ensure that only one request can be assigned to a certain IP.
[0037] The following are the specific contents of two related technical solutions.
[0038]
[0039]
[0040] The above solutions still have shortcomings in terms of "storage method of IP resources" and "method of ensuring IP uniqueness when allocating IPs".
[0041] First, the existing solution explicitly stores IP addresses, which consumes a lot of storage resources: for the above-mentioned relational database method of storing all assigned IPs in the library table, when more and more IP address resources are required, it will cause storage waste and reduce query efficiency; for the above-mentioned Redis database method, it is necessary to explicitly store all unassigned IPs under the network segment in the IP set in advance, which consumes memory resources.
[0042] Second, the existing solution uses database optimistic locking and unique indexing to ensure the uniqueness of IP allocation, and the system implementation is relatively complex.
[0043] Therefore, in order to solve the above technical problems, the present invention proposes a network address allocation method, which forms a bitmap-based IP resource allocation method, compresses storage resources, and improves query efficiency. The specific contents of the method are as follows.
[0044] Figure 1 A flowchart of a network address allocation method provided by an embodiment of the present disclosure is shown in FIG. Figure 1 As shown, the method may include the following steps.
[0045] Step 101, in response to an IP address allocation request of a target device, determine a start IP and an end IP corresponding to a subnet to determine a target subdivided network segment.
[0046] In some embodiments, for example, the target device may be a virtual network card bound to a virtual machine, and one target device may have one IP.
[0047] In some embodiments, the target subdivided network segment is one of multiple subdivided network segments included in the subnet network segment of the subnet, that is, the subnet network segment can be split to obtain multiple subdivided network segments.
[0048] In some embodiments, the subnet segment can be determined based on the starting IP and the ending IP. The subnet segment can be a Classless Inter Domain Routing (CIDR) resource. The CIDR resource can be the IP range owned by the subnet. For example, the CIDR segment corresponding to a subnet is 168.0.0.0 / 24, then the subnet contains 254 allocatable valid IP addresses from 168.0.0.1 (CIDR's starting IP) to 168.0.0.254 (CIDR's ending IP).
[0049] In some embodiments, multiple subdivided network segments can be determined based on the subnet segment and the bitmap storage structure. Since a subdivided network segment can use a bitmap structure to store a portion of IP resources, the storage capacity of a bitmap structure is limited and can only store a certain number of IP resources. Therefore, a subnet segment can be split into multiple subdivided network segments. The multiple subdivided network segments obtained can be called buckets. Each subdivided network segment can accommodate up to 64 IP addresses. In the above example, the subnet segment has 254 IP addresses, so the subnet segment can be split into 4 subdivided network segments.
[0050] For example, for the CIDR network segment 168.0.0.0 / 24, it is subdivided into 4 bucket network segments, and the corresponding valid IP ranges are: [{168.0.0.1 (bucket start IP), 168.0.0.63 (bucket end IP)}, {168.0.0.64 (bucket start IP), 168.0.0.127 (bucket end IP)}, {168.0.0.128 (bucket start IP), 168.0.0.191 (bucket end IP)}, {168.0.0.192 (bucket start IP), 168.0.0.255 (bucket end IP)}].
[0051] In some embodiments, if the IP address allocation request includes a specified IP, it is determined whether the specified IP falls into the subnet segment, and it is determined whether the specified IP is occupied. For example, it can be determined whether the specified IP is occupied by the allocated IP address and business information. If the specified IP falls into the subnet segment and the specified IP is not occupied, the target subdivided segment of the specified IP is determined.
[0052] In some embodiments, if the IP address allocation request does not include a specified IP, determine whether there is an available IP in the subnet segment. If so, determine the target subdivided segment in the subnet segment that includes the available IP. For example, the number of available IPs in each subdivided segment can be used to determine whether there is an available IP in the subnet segment.
[0053] Step 102: determine a target IP address from a first storage space according to the target network segment, wherein the first storage space stores an IP address corresponding to each network segment via a bitmap.
[0054] In some embodiments, the first storage space includes:
[0055] A first structure, the first structure is used to maintain subnet service information. For example, the first structure may be subnets;
[0056] The second structure is used to maintain subnet resources and the IP range owned by the subnet. For example, the second structure may be ip_allocation_pools;
[0057] The third structure includes multiple subdivided network segments, each subdivided network segment stores the IP resources owned by the subnet in a bitmap structure, and the IP resources include allocation attributes, IP positioning attributes, and IP calculation attributes. The allocation attributes are used to identify whether the IP resources have been allocated, the IP positioning attributes are used to identify the scope of the IP resources and the number of IPs to be allocated, and the IP calculation attributes are used to identify the initial IP of each subdivided network segment.
[0058] In the above embodiment, for example, the third structure may be ip_allocation_buckets, and the third structure stores the IP resources owned by the subnet in a bitmap structure. When the bitmap stores data based on the long data structure (8Byte, 64bit), a bitmap has only 64bits, and therefore only supports the storage of 64 IP addresses.
[0059] In the above embodiment, the allocation attribute can be, for example, when the bitmap_data has 64 bits, each bit can represent an IP address, and it can be set that when the bit value is 0, it indicates that the IP resource corresponding to the bit has been allocated, and when the bit value is 1, it indicates that the IP resource corresponding to the bit has not been allocated; or it can be set that when the bit value is 1, it indicates that the IP resource corresponding to the bit has been allocated, and when the bit value is 0, it indicates that the IP resource corresponding to the bit has not been allocated, and the present disclosure does not limit this.
[0060] In the above embodiment, the IP location attributes may include the starting IP (start_ip), the ending IP (end_ip) and the number of available IPs (available_ip_count). Since the third structure stores the IP address in a bitmap structure, it is inconvenient to explicitly view the IP address and perform IP location. Therefore, the IP address is located through the above three location attributes, among which available_ip_count specifies the number of remaining IPs to be allocated by the subdivided network segment, and start_ip and end_ip specify the IP range of the subdivided network segment.
[0061] In the above embodiment, the IP calculation attribute can be the initial IP (prefix), where prefix is the IP starting reference value of each subdivided network segment. Since each IP address is stored in a bitmap as a bit value, if you want to interpret the IP address as a readable integer IP address, you need to calculate it by adding the IP starting reference value to the displacement. For example, first use a search algorithm (such as binary search) to find a position with a bit value of 1 (that is, an IP that has not been assigned) from the 64-bit bit of bitmap_data, and then record the IP position with a bit value of 1 as the target storage position (offset). Finally, the assigned IP address interpreted from the bitmap_data is calculated to be prefix+offset-1.
[0062] In some embodiments, the target IP address can be determined from the first storage space according to the ETCD storage data path. The ETCD storage data path includes: a segmented network path, through which all IP resources stored in the segmented network can be obtained; a segmented network resource path, through which a segmented network resource path can be used to obtain a segmented network containing a specified IP or a segmented network containing at least one available IP; and an allocated IP path, through which whether the specified IP has been allocated can be obtained.
[0063] In the above embodiment, if the IP address allocation request includes a specified IP, the value corresponding to the specified IP can be found through the allocated IP path (i.e., usedIpsPath). For example, the allocated IP path can be / subnets / {subnetId} / {ip}. If the value corresponding to the IP is not empty, it means that the IP has been allocated. If the value corresponding to the IP is empty, it means that the IP has not been allocated. If the specified IP is not found under the allocated path, the subnet segment corresponding to the subdivided network segment to which the allocated IP path belongs can be obtained, and all subdivided network segments under the subnet segment can be obtained. The subdivided network segment containing the specified IP can be found from all subdivided network segments of the subnet. The path can be / subnets / {subnetId} / buckets.
[0064] In the above embodiment, if the IP address allocation request does not include a designated IP, a segment with an available IP can be randomly selected from all segments of the subnet, and the IP address allocated to the target device is selected from the segment.
[0065] In the above embodiment, the network segment resource path may be bucketsPath, and a specified IP address or an available IP address may be read from the network segment resource path. For example, the network segment resource path may be / subnets / {subnetId} / buckets. When the IP allocation request does not specify an IP, all network segment resource path nodes under the subnet may be obtained. A network segment with an available IP may be randomly selected from the network segment resource path, and the target IP address may be determined in the network segment.
[0066] In the above embodiment, the segmented network path may be bucketPath, and the target IP may be determined based on the segmented network path. For example, the target IP may be determined by reading the data stored in the bitmap and calculating the path value based on the segmented network path node / subnets / {subnetId} / buckets / {bucketId}.
[0067] Step 103: assign the target IP address to the target device.
[0068] In some embodiments, the target IP address may be assigned to the target device, and the bit value corresponding to the target IP address may be updated, for example, the bit value corresponding to the IP address may be updated from 0 to 1, or from 1 to 0, and so on.
[0069] In summary, the above embodiments of the present application can ensure the uniqueness of IP address allocation by determining the target segment according to the IP address allocation request, determining the target IP address from the target segment, and allocating the target IP address to the target device, and can quickly find the target IP address through ETCD to improve efficiency. The first storage space can save storage space by using a bitmap to store IP addresses.
[0070] Figure 2 A flowchart of a network address allocation method provided by an embodiment of the present disclosure is shown in FIG. Figure 2 As shown, based on Figure 1 In the embodiment shown, this embodiment specifically describes the above step 102. The method may include the following steps.
[0071] Step 201: If the IP address allocation request includes a designated IP, determine a target storage location of the designated IP in the target network segment according to the initial IP of the target network segment and the storage location of the initial IP in the target network segment.
[0072] In some embodiments, if the IP address allocation request includes a designated IP, the target network segment to which the designated IP belongs can be determined according to the IP range of the network segment, and the initial IP of the target network segment can be determined.
[0073] In some embodiments, the specified IP may be converted into data in a bitmap format. For example, the target storage location offset of the specified IP in the target segmented network may be determined based on the storage location of the initial IP in the target segmented network. The specific calculation formula is as follows:
[0074] offset = specified IP-prefix + 1
[0075] Among them, prefix is the initial IP, and prefix is stored as the first bit in the bitmap. Therefore, the difference between the specified IP and prefix plus 1 is the bit position where the specified IP is stored in the bitmap.
[0076] Step 202, determining whether the bitmap value of the target storage location is a first preset value, and if so, determining that the designated IP has not been allocated.
[0077] In some embodiments, whether the specified IP is allocable can be determined by verifying the legitimacy of the target storage location offset. For example, when the bitmap value of the target storage location is a first preset value, it can indicate that the specified IP has not been allocated. For example, the first preset value can be 0, and the second preset value can be 1. Then, when the bitmap value of the target storage location is 0, it indicates that the specified IP has not been allocated.
[0078] Step 203: determine that the designated IP is the target IP address.
[0079] In some embodiments, when the designated IP has not been allocated, the designated IP can be determined as the target IP address, and the designated IP address can be allocated to the target device.
[0080] In summary, in the above embodiments of the present application, when the IP address allocation request includes a designated IP, the target storage location of the designated IP can be determined, and when the bitmap value of the target storage location is the first preset value, the designated IP is determined to be the target IP address, so as to ensure the uniqueness of the IP address allocation. Storing IP addresses by bitmap can save storage space.
[0081] Figure 3 A flowchart of a network address allocation method provided by an embodiment of the present disclosure is shown in FIG. Figure 3 As shown, based on Figure 1 In the embodiment shown, this embodiment specifically describes the above step 102. The method may include the following steps.
[0082] Step 301: If the IP address allocation request does not include a designated IP, a target storage location whose bitmap value is a first preset value is searched from a target subdivided network segment.
[0083] In some embodiments, if the IP address allocation request does not include a designated IP, an unoccupied location can be randomly searched from the target network segment as the target storage location, and a location in the target network segment whose bitmap value is a first preset value can be searched as the target storage location. For example, the search algorithm can be a binary search algorithm, etc.
[0084] Step 302, determining a target IP address according to the initial IP address of the target network segment and the target storage location.
[0085] In some embodiments, based on the target storage location offset obtained in step 301 and the initial IP (prefix), the target IP address can be obtained, and the calculation formula is as follows:
[0086] IP address = prefix + offset - 1
[0087] In summary, the above embodiments of the present application can ensure the uniqueness of IP address allocation by searching for an available IP address in the target network segment and allocating it to the target device when the specified IP address allocation request does not include the specified IP address. Storing IP addresses in a bitmap can save storage space.
[0088] Figure 4 A flowchart of a network address allocation method provided by an embodiment of the present disclosure is shown in FIG. Figure 4 As shown, based on Figure 1 This embodiment specifically describes the above step 103. The method may include the following steps.
[0089] Step 401: Set the bitmap value of the target storage location to a second preset value.
[0090] In some embodiments, by Figure 2 or Figure 3 In the illustrated embodiment, after the target IP address is determined, the target IP address can be assigned to the target device.
[0091] In some embodiments, the first preset value may indicate that the current IP address has not been assigned, and the second preset value may indicate that the current IP address has been assigned, so when the target IP address is assigned to the target device, the bitmap value of the target storage location may be set to the second preset value, indicating that the IP address has been assigned. For example, the second preset value may be 0, that is, when the bitmap value of the target storage location is set to 0, it may indicate that the target IP address has been assigned, or the second preset value may be 1, which is not limited by the present disclosure.
[0092] Step 402, reduce the number of available IP addresses of the target network segment by one.
[0093] In some embodiments, when allocating a target IP address to a target device, the number of available IP addresses in the target network segment may be reduced by one, and the number of available IP addresses in the target network segment may be updated.
[0094] Step 403: Feedback the target IP address to the target device, and store the target IP address in the allocated service table.
[0095] In some embodiments, based on the formula IP address=prefix+offset-1 in step 302, an explicitly readable target IP address can be obtained.
[0096] In some embodiments, the target IP address may be fed back to the target device and the address may be stored in the allocated service table, indicating that the IP address has been allocated to the target device.
[0097] In summary, the above-mentioned embodiments of the present application can realize the allocation of IP addresses and ensure the uniqueness of IP address allocation by setting the bitmap value of the target storage location to the second preset value, reducing the number of available IPs by one, and storing the target IP address in the allocated service table.
[0098] Figure 5 A flowchart of a network address allocation method provided by an embodiment of the present disclosure is shown in FIG. Figure 5 As shown, the method may include the following steps.
[0099] Step 501: When the target device releases the target IP address, the bitmap value of the target storage location is set to a first preset value.
[0100] In some embodiments, the target device may release the IP address, which may be reused by another device.
[0101] In some embodiments, when the target IP address is released, the bitmap value of the target storage location may be reset to a first preset value, indicating that the IP address has not been allocated.
[0102] Step 502, increase the number of available IP addresses of the target network segment by one.
[0103] In some embodiments, when the target device releases the target IP address, the number of available IP addresses of the target network segment can be increased by one to update the number of available IP addresses of the target network segment.
[0104] Step 503: Delete the target IP address from the allocated service table.
[0105] In some embodiments, when the target device releases the target IP address, the target IP address may be deleted from the allocated service table and the allocated task table may be updated.
[0106] In summary, the bitmap value of the target storage location can be reset, the number of available IP addresses of the target segment can be increased by one, and the target IP address can be deleted from the allocated service table to release the target IP address and facilitate the next allocation of the IP address.
[0107] For the aforementioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should know that the present disclosure is not limited by the described order of actions, because according to the present disclosure, certain steps can be performed in other orders or simultaneously.
[0108] Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present disclosure.
[0109] The technical solution of the present disclosure is further described in detail below in conjunction with specific application examples.
[0110] The present disclosure provides an IP allocation method, which is designed and implemented mainly from the following two aspects:
[0111] First, a bitmap-based IP resource storage and IP allocation method is proposed. This method no longer explicitly presents each IP address as a library table record or a set record, but uses a bitmap to store IP resources, effectively compressing IP storage resources and improving query efficiency.
[0112] Second, an IP allocation scheme based on ETCD transactions is proposed. ETCD transactions detect conflicts and retry based on optimistic locking and ModRevision. This scheme uses the STM transaction mechanism of ETCD to enable implementers to focus on business logic, further reducing the system implementation complexity of IP allocation while ensuring uniqueness.
[0113] The specific contents of the bitmap-based IP resource storage method are as follows.
[0114] The entity relationship (ER) diagram of the IP storage method in this example is as follows Figure 6As shown in the figure, four structures are designed, among which subnets and ip_allocations focus more on the storage of business data. subnets can determine the subnet range of IP application, and ip_allocations explicitly stores the allocated IP address; IP allocation pools (ip_allocation_pools) and IP allocation buckets (ip_allocation_buckets) are really used for the storage of IP resources. ip_allocation_pools is used for resource delimitation, and ip_allocation_buckets is used to subdivide IP resource delimitation and store all IP resources. The design idea of this structure can be applied to relational databases such as Mysql, and can also be applied to distributed coordination systems such as ETCD.
[0115] The detailed description of each structure is as follows:
[0116] 1. The structure subnets maintains the business information of all subnets. Applying for an IP address is essentially applying for an IP address from a subnet in this table.
[0117] 2. The structure ip_allocation_pools separately maintains the CIDR resources owned by the subnet and clarifies the IP range owned by the subnet (first_ip and last_ip, both stored as integer types).
[0118] 3. The structure ip_allocation_buckets actually stores the IP resources owned by the subnet. This structure uses bitmap to store IP resources, as follows:
[0119] First, the Classless Inter Domain Routing (CIDR) needs to be split into smaller storage segments (called buckets). Each bucket uses a bitmap structure to store a portion of IP resources. The reason for splitting CIDR is that a bitmap structure has an upper limit on storage capacity and can only store a certain number of IP addresses, so a CIDR segment may need to be split into multiple bitmaps for separate storage. For example, a subnet has a CIDR of 168.0.0.0 / 24, and each bucket can accommodate up to 64 IP addresses, then it will be divided into 4 bucket records. The split example is:
[0120] (1) When a bitmap stores data based on a long data structure (8 bytes, 64 bits), a bitmap has only 64 bits and therefore only supports the storage of 64 IP addresses.
[0121] (2) At this time, for the subnet with CIDR 168.0.0.0 / 24 (a total of 255 IPs), all 255 IP resources need to be split into 4 bitmaps for storage. The IP addresses stored in each bitmap are [{168.0.0.0, 168.0.0.63}, {168.0.0.64, 168.0.0.127}, {168.0.0.128, 168.0.0.191}, {168.0.0.192, 168.0.0.255}].
[0122] Second, the bucket structure is designed with bitmap as the core as shown in Table 1, which includes IP resource storage attributes, IP positioning attributes, IP calculation attributes, etc.
[0123] (3) The IP resource storage attribute is bitmap_data. This field actually stores the IP address resource. For example, each bitmap_data has 64 bits, so each bit represents an IP. A bit value of 0 indicates that the IP has been allocated, and a bit value of 1 indicates that the IP has not been allocated.
[0124] (4) IP location attributes include start_ip, end_ip, and available_ip_count. Because IP resources are stored as bitmap structures, it is not convenient to explicitly view and locate IPs, so the design stores these three location attributes. Among them, available_ip_count specifies the number of remaining IPs to be allocated in the bucket, and start_ip and end_ip specify the IP range owned by the bucket.
[0125] (5) The attribute that assists in IP calculation is prefix, which is the IP starting reference value of each bucket. Because each IP address is stored as a bit in the bitmap, if you want to interpret the IP address as a readable integer IP address, you need to calculate it by adding the IP starting reference value to the displacement. Calculation example: First, use a search algorithm (such as binary search) to find a position with a bit value of 1 (that is, an IP that has not been assigned) from the 64-bit bit of bitmap_data, and then record the IP position with this bit value of 1 as offset. Finally, calculate the assigned IP address interpreted from bitmap_data as prefix+offset-1.
[0126] Table 1 Bucket structure
[0127]
[0128]
[0129] The specific contents of the bitmap-based IP resource allocation method are as follows.
[0130] This example is based on the IP allocation method designed based on the above IP storage method. Figure 7 As shown in the figure, the two scenarios of allocating designated IP and allocating non-designated IP and the structures involved in each specific process are explained. The core content includes the conversion from IP to bitmap, the conversion from bitmap to IP, and the lock update bucket record.
[0131] The detailed steps are described as follows:
[0132] Step 1, in response to a request from a target device for IP allocation, locate the target segmented network range, i.e., bucket, from multiple IP segments based on information such as the subnet to which the IP is allocated and whether the IP is specified in the request.
[0133] The requested subnet determines the network segment range where the assigned IP is located. A subnet uniquely corresponds to a CIDR network segment. For example, if the CIDR network segment corresponding to a subnet is 168.0.0.0 / 24, then the subnet contains 254 valid assignable IP addresses from 168.0.0.1 (CIDR start IP) to 168.0.0.254 (CIDR end IP), and the target IP will be assigned from this range; 168.0.0.0 is the network number and will not be assigned, and 168.0.0.255 is the broadcast address and will not be assigned either.
[0134] Furthermore, the target network segment bucket is a subdivision of the CIDR network segment. For example, for the CIDR network segment 168.0.0.0 / 24, it is subdivided into 4 bucket network segments, and the corresponding valid IP ranges are: [{168.0.0.1 (bucket start IP), 168.0.0.63 (bucket end IP)}, {168.0.0.64 (bucket start IP), 168.0.0.127 (bucket end IP)}, {168.0.0.128 (bucket start IP), 168.0.0.191 (bucket end IP)}, {168.0.0.192 (bucket start IP), 168.0.0.255 (bucket end IP)}], and the target IP will eventually be taken out and allocated from these bucket ranges.
[0135] If the request specifies an IP, you first need to determine whether the specified IP falls within the subnet CIDR segment range, which can be determined based on the "IP start and end address range of the subnet corresponding to the CIDR segment"; then determine whether the specified IP has been allocated and occupied, which can be determined based on the "allocated IP address and business information"; finally, find out which bucket segment the IP falls into, which can be determined based on the start and end ranges of each bucket.
[0136] If the request does not specify an IP, find the CIDR network segment range corresponding to the subnet and randomly select a bucket with an available IP from the multiple bucket subdivisions corresponding to the CIDR. Whether there is an available IP can be determined based on the number of available IPs in each bucket.
[0137] Step 2: Determine the target IP address to be allocated based on the target network segment bucket.
[0138] If the request specifies an IP and the bucket where the IP is located is known, the specified IP needs to be converted into bitmap format data. The conversion process mainly involves offset calculation and verification, as follows:
[0139] (1) Calculate the offset of the specified IP in the bucket using the following formula: prefix is the starting IP of the bucket. The prefix is stored as the first bit in the bitmap. Therefore, the difference between the specified IP and prefix plus 1 is the bit position where the specified IP is stored in the bitmap.
[0140] offset = specified IP-prefix + 1
[0141] (2) Check the validity of the offset to determine whether the specified IP is assignable. Specifically, obtain the value of the offset bit from the bitmap value of the bucket. If the value of the bit is 1, it means that the IP has not been assigned yet and is available. If the value of the bit is 0, it means that the IP has been assigned and is unavailable.
[0142] (3) At this point, it has been determined whether the specified IP is assignable.
[0143] If the request does not specify an IP and the bucket where the IP is located is known, a bit with a bit value of 1 is searched from the bitmap value of the bucket (the search algorithm can be binary search, etc.), and the position is recorded as the offset. The offset is the offset of the target IP. Based on this, the target IP to be allocated is obtained. The corresponding target IP calculation formula is:
[0144] IP address = prefix + offset - 1
[0145] Step 3: According to the determined target IP to be allocated, the IP is actually allocated to the target device. The allocation process specifically includes the following three aspects:
[0146] 1. Set the value of the offset bit of the bucket bitmap value (where the target IP is located) to 0, indicating that the IP is already occupied.
[0147] 2. Reduce the number of available IP addresses in the bucket by 1, indicating that one available IP address is reduced in the bucket network segment.
[0148] 3. Feedback the explicitly readable target IP to the target device and store it in the service table where the IP has been assigned.
[0149] The above allocation process needs to be completed under lock. Only when the changed bitmap value and the number of available IP addresses are successfully updated to the bucket can the target IP be preempted. Therefore, when allocating IP addresses concurrently, locks are required to ensure the uniqueness of the allocated IP addresses.
[0150] The bitmap-based IP resource allocation method also includes the IP recovery and release process. When the target device releases the target IP, the core includes the following three aspects of the reverse operation of IP allocation, which also needs to be locked:
[0151] 1. Set the value of the offset bit of the bucket bitmap value (where the target IP is located) to 1, indicating that the IP has been released.
[0152] 2. Increase the number of available IP addresses in the bucket by 1, indicating that one more available IP address is added to the bucket network segment.
[0153] 3. Delete the explicitly readable target IP from the service table to which the IP has been assigned.
[0154] This solution uses the STM transaction mechanism of ETCD to reduce the system implementation complexity of IP allocation.
[0155] The ETCD storage data path is as follows:
[0156] 1. bucketPath: all IP resources of a bucket
[0157] / subnets / {subnetId} / buckets / {bucketId}
[0158] 2.bucketsPath: all bucket resource path nodes
[0159] / subnets / {subnetId} / buckets
[0160] 3.usedIpsPath: Allocated IP resource path node
[0161] / subnets / {subnetId} / {ip}
[0162] Because ETCD's STM has built-in optimistic locking and encapsulates the conflict resolution logic based on the ModRevision version number, combined with the fact that ETCD nodes can directly obtain path parameters, system implementers can focus on the business logic itself, reducing the complexity of implementation.
[0163] A design of IP allocation method based on etcd transaction is as follows Figure 8 The detailed steps are described as follows:
[0164] Step 1, in response to a request from a target device for IP allocation, locate the target segmented network range, i.e., bucket, from multiple IP segments based on information such as the subnet to which the IP is allocated and whether the IP is specified in the request.
[0165] If the request specifies an IP, use the subnet and the specified IP to obtain the allocated IP resource path node / subnets / {subnetId} / {ip}; if the node is not found, obtain all bucket resource path nodes / subnets / {subnetId} / buckets under the subnet and find the bucket containing the target IP.
[0166] If the request does not specify an IP, get all bucket resource path nodes / subnets / {subnetId} / buckets under the subnet and randomly select a bucket with an available IP.
[0167] Step 2: Determine the target IP to be allocated based on the target segment bucket. Read the bucket data based on the bucket path node / subnets / {subnetId} / buckets / {bucketId}, and update the data to calculate the new value (see step 2 of the above "IP resource allocation method based on bitmap").
[0168] Step 3: According to the determined target IP to be allocated, the IP is actually allocated to the target device, that is, the allocated data is written to the bucket path node / subnets / {subnetId} / buckets / {bucketId} and the allocated IP resource path node / subnets / {subnetId} / {ip}.
[0169] The above allocation process utilizes the fast positioning feature of ETCD and completes the optimistic locking and conflict resolution logic based on the STM transaction mechanism of ETCD.
[0170] In summary, the above examples disclosed herein effectively compress IP storage resources and improve query efficiency through a bitmap-based IP resource storage method and allocation method. In addition, based on the theoretical basis of the bitmap-based IP resource storage method and allocation method, this proposal further proposes an IP allocation scheme based on ETCD transactions, so that implementers can focus on the business logic of IP allocation and reduce the complexity of system implementation.
[0171] Fig. 9 FIG. 9 is a block diagram of a network address allocation device 900 provided in an embodiment of the present disclosure. Fig. 9 As shown, the device 900 includes: a first processing unit 910, used to respond to an IP address allocation request of a target device, determine the starting IP and ending IP corresponding to the subnet, so as to determine a target subdivided network segment, wherein the target subdivided network segment is one of a plurality of subdivided network segments included in the subnet network segment of the subnet; a second processing unit 920, used to determine a target IP address from a first storage space according to the target subdivided network segment, wherein the first storage space stores the IP address corresponding to each subdivided network segment through a bitmap; and a third processing unit 930, used to allocate the target IP address to the target device.
[0172] In some embodiments, the first processing unit 910 can also be used to: determine the subnet segment based on the starting IP and the ending IP; determine multiple subdivided segments based on the subnet segment and the bitmap storage structure; if the IP address allocation request includes a specified IP, determine whether the specified IP falls into the subnet segment, and determine whether the specified IP is occupied. If the specified IP falls into the subnet segment and the specified IP is not occupied, determine the target subdivided segment of the specified IP; if the IP address allocation request does not include the specified IP, determine whether there is an available IP in the subnet segment, and if so, determine the target subdivided segment that includes the available IP in the subnet segment.
[0173] In some embodiments, the second processing unit 920 can also be used for: if the IP address allocation request includes a specified IP, determining the target storage location of the specified IP in the target subdivided network segment based on the initial IP of the target subdivided network segment and the storage location of the initial IP in the target subdivided network segment; determining whether the bitmap value of the target storage location is a first preset value, and if so, determining that the specified IP has not yet been allocated; and determining that the specified IP is the target IP address.
[0174] In some embodiments, the second processing unit 920 can also be used to: if the IP address allocation request does not include a specified IP, search for a target storage location with a bitmap value of a first preset value from the target network segment; determine the target IP address based on the initial IP of the target network segment and the target storage location.
[0175] In some embodiments, the third processing unit 930 can also be used to: set the bitmap value of the target storage location to a second preset value; reduce the number of available IPs in the target segment by one; feed back the target IP address to the target device, and store the target IP address in the allocated service table.
[0176] In some embodiments, the network address allocation device 900 also includes a fourth processing unit, which is used to set the bitmap value of the target storage location to a first preset value when the target device releases the target IP address; increase the number of available IPs in the target subdivided network segment by one; and delete the target IP address from the allocated service table.
[0177] In some embodiments, the first storage space includes: a first structure, the first structure is used to maintain subnet business information; a second structure, the second structure is used to maintain subnet resources and the IP range owned by the subnet; a third structure, the third structure includes multiple subdivided network segments, each subdivided network segment stores the IP resources owned by the subnet in a bitmap structure, the IP resources include allocation attributes, IP positioning attributes, and IP calculation attributes, the allocation attributes are used to identify whether the IP resources have been allocated, the IP positioning attributes are used to identify the range of IP resources and the number of IPs to be allocated, and the IP calculation attributes are used to identify the initial IP of each subdivided network segment.
[0178] In some embodiments, the second processing unit 920 can also be used to: determine the target IP address from the first storage space according to the ETCD storage data path; wherein the ETCD storage data path includes: a subdivided network segment path, through which all IP resources stored in the subdivided network segment can be obtained; a subdivided network segment resource path, through which a subdivided network segment containing a specified IP or a subdivided network segment containing at least one available IP can be obtained; an allocated IP path, through which it can be obtained whether the specified IP has been allocated.
[0179] In summary, the network address allocation device can achieve network address allocation, improve the efficiency of network address allocation, and determine the uniqueness of network address allocation by determining the target subdivided network segment according to the IP address allocation request of the target device, determining the target IP address from the first storage space, and allocating the target IP address to the target device. The first storage space can save storage space by storing the IP address corresponding to each subdivided network segment through a bitmap.
[0180] Fig.10A block diagram of an electronic device 1000 for implementing the above method is provided in an embodiment of the present disclosure.
[0181] Based on the hardware implementation of the above program modules, and in order to implement the method of the embodiment of the present disclosure, the embodiment of the present disclosure also provides an electronic device, such as Fig.10 As shown, the electronic device 1000 includes:
[0182] Communication interface 1001, capable of exchanging information with other devices;
[0183] The processor 1002 is connected to the communication interface 1001 to implement information interaction with other devices, and is used to execute the method provided by one or more of the above technical solutions when running the computer program;
[0184] The computer program is stored in the memory 1003 .
[0185] Specifically, the processor 1002 may be configured to determine a first family to which the first object belongs based on the communication data of the first object; determine the first family as a target family when the first family satisfies a first preset condition; and push target information to the target family.
[0186] It should be noted that the specific processing process of the processor 1002 can be understood by referring to the above method.
[0187] Of course, in actual application, the various components in the electronic device 1000 are coupled together through the bus system 1004. It can be understood that the bus system 1004 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 1004 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Fig.10 Various buses are labeled as bus system 1004 .
[0188] The memory 1003 in the embodiment of the present application is used to store various types of data to support the operation of the electronic device 1000. Examples of such data include: any computer program used to operate on the electronic device 1000.
[0189] The method disclosed in the above embodiment of the present application can be applied to the processor 1002, or implemented by the processor 1002. The processor 1002 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 1002. The above-mentioned first processor 1002 can be a general-purpose processor, a digital signal processor (DSP, Digital Signal Processor), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 1002 can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present application, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in the memory 1003, and the processor 1002 reads the information in the memory 1003 and completes the steps of the above method in combination with its hardware.
[0190] In an exemplary embodiment, the electronic device 1000 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0191] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 1004 including instructions, and the instructions can be executed by the processor 1020 of the electronic device 1000 to complete the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0192] The embodiments of the present disclosure further provide a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the method described in the above embodiments of the present disclosure.
[0193] The embodiment of the present disclosure also provides a chip, such as Fig.11As shown, the chip includes a processor 1110 and an interface 1120. The number of processors 1110 may be one or more, the number of interfaces 1120 may be multiple, and the interface circuit is used to receive signals from the memory of the electronic device and send signals to the processor, the signals include computer instructions stored in the memory, and when the processor executes the computer instructions, the electronic device executes the method described in the above embodiments of the present disclosure.
[0194] It should be noted that, for the convenience of description, only the parts related to the relevant invention are shown in the drawings. In the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other.
[0195] It should be understood that the "system", "device", "unit" and / or "module" used in this application is a method for distinguishing different components, elements, parts, portions or assemblies at different levels. However, if other words can achieve the same purpose, the word can be replaced by other expressions.
[0196] As shown in this application and claims, unless the context clearly indicates an exception, the words "a", "an", "a kind" and / or "the" do not refer to the singular, but also include the plural. Generally speaking, the terms "include" and "comprise" only indicate the inclusion of clearly identified steps and elements, and these steps and elements do not constitute an exclusive list. The method or device may also include other steps or elements. The elements defined by the sentence "includes a..." do not exclude the existence of other identical elements in the process, method, commodity or device that includes the elements.
[0197] In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0198] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features.
[0199] Flowcharts are used in the present application to illustrate the operations performed by the system according to the embodiments of the present application. It should be understood that the preceding or following operations are not necessarily performed accurately in order. On the contrary, the various steps may be processed in reverse order or simultaneously. At the same time, other operations may also be added to these processes, or one or more operations may be removed from these processes.
[0200] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples" or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiments or examples are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0201] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present invention includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present invention belong.
[0202] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processing module, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (control method), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or otherwise processing in a suitable manner if necessary, and then stored in a computer memory.
[0203] It should be understood that the various parts of the embodiments of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0204] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0205] In addition, each functional unit in each embodiment of the present invention may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent commodity, it may also be stored in a computer-readable storage medium. The above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0206] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. A network address allocation method, It is characterized in that The method comprises: In response to an IP address allocation request of a target device, determining a start IP and an end IP corresponding to a subnet to determine a target subdivided network segment, wherein the target subdivided network segment is one of a plurality of subdivided network segments included in a subnet network segment of the subnet; Determine a target IP address from a first storage space according to the target network segment, wherein the first storage space stores the IP address corresponding to each network segment via a bitmap; The target IP address is assigned to the target device.
2. The method according to claim 1, It is characterized in that The step of responding to the IP address allocation request of the target device and determining the start IP and the end IP corresponding to the subnet to determine the target subdivided network segment includes: Determine the subnet segment according to the starting IP and the ending IP; Determine the multiple subdivided network segments according to the subnet network segment and the bitmap storage structure; If the IP address allocation request includes a designated IP, determine whether the designated IP falls into the subnet segment, and determine whether the designated IP is occupied; if the designated IP falls into the subnet segment and the designated IP is not occupied, determine the target subdivided segment of the designated IP; If the IP address allocation request does not include a designated IP, determine whether there is an available IP in the subnet segment, and if so, determine a target subdivided segment that includes the available IP in the subnet segment.
3. The method according to claim 2, It is characterized in that Determining the target IP address from the first storage space according to the target segmented network segment includes: If the IP address allocation request includes a designated IP, determining a target storage location of the designated IP in the target network segment according to the initial IP of the target network segment and the storage location of the initial IP in the target network segment; Determine whether the bitmap value of the target storage location is a first preset value, and if so, determine that the designated IP has not been allocated; Determine the designated IP as the target IP address.
4. The method according to claim 2, It is characterized in that Determining the target IP address from the first storage space according to the target segmented network segment includes: If the IP address allocation request does not include a designated IP, searching the target storage location where the bitmap value is a first preset value from the target subdivided network segment; The target IP address is determined according to the initial IP address of the target segment and the target storage location.
5. The method according to claim 3 or 4, It is characterized in that The allocating the target IP address to the target device comprises: Setting the bitmap value of the target storage location to a second preset value; Reduce the number of available IP addresses in the target network segment by one; The target IP address is fed back to the target device, and the target IP address is stored in the allocated service table.
6. The method according to claim 5, It is characterized in that The method further comprises: When the target device releases the target IP address, setting the bitmap value of the target storage location to the first preset value; Increase the number of available IP addresses in the target network segment by one; The target IP address is deleted from the allocated service table.
7. The method according to claim 1, It is characterized in that The first storage space includes: A first structure, wherein the first structure is used to maintain subnet service information; A second structure, wherein the second structure is used to maintain subnet resources and IP ranges owned by the subnet; The third structure includes multiple subdivided network segments, each subdivided network segment stores the IP resources owned by the subnet in a bitmap structure, the IP resources include allocation attributes, IP positioning attributes, and IP calculation attributes, the allocation attributes are used to identify whether the IP resources have been allocated, the IP positioning attributes are used to identify the scope of the IP resources and the number of IPs to be allocated, and the IP calculation attributes are used to identify the initial IP of each subdivided network segment.
8. The method according to claim 1, It is characterized in that Determining the target IP address from the first storage space according to the target segmented network segment includes: According to the ETCD storage data path, determine the target IP address from the first storage space; Wherein, the ETCD storage data path includes: A segmented network path, through which all IP resources stored in the segmented network can be obtained; A network segment resource path, through which a network segment containing a specified IP or a network segment containing at least one available IP can be obtained; The allocated IP path is used to determine whether the specified IP has been allocated.
9. A network address allocation device, comprising: A first processing unit is used to determine the start IP and the end IP corresponding to the subnet in response to the IP address allocation request of the target device, so as to determine the target subdivided network segment, wherein the target subdivided network segment is one of the multiple subdivided network segments included in the subnet network segment of the subnet; A second processing unit, configured to determine a target IP address from a first storage space according to the target subdivided network segment, wherein the first storage space stores an IP address corresponding to each subdivided network segment via a bitmap; The third processing unit is configured to allocate the target IP address to the target device.
10. An electronic device, It is characterized in that include: one or more processors; A storage device communicatively connected to the one or more processors, on which one or more programs are stored; When the one or more programs are executed by the one or more processors, the one or more processors are enabled to implement the method according to any one of claims 1 to 8.
11. A non-transitory computer-readable storage medium storing computer instructions, It is characterized in that The computer instructions are used to cause the computer to execute the method according to any one of claims 1-8.
12. A computer program product, It is characterized in that The invention comprises a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 8.
13. A chip, It is characterized in that It comprises one or more interface circuits and one or more processors; the interface circuit is used to receive a signal from a memory of an electronic device and send the signal to the processor, the signal includes a computer instruction stored in the memory, and when the processor executes the computer instruction, the electronic device executes the method described in any one of claims 1 to 8.
