Method and apparatus for managing IP addresses

By combining the target array and the doubly linked list structure, the IP address allocation and recycling process is optimized, solving the problems of increased response time and excessive resource consumption of DHCP servers in large LAN environments, and improving system efficiency.

CN117155899BActive Publication Date: 2026-05-29CHINA TELECOM INTELLIGENT NETWORK TECHNOLOGY CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA TELECOM INTELLIGENT NETWORK TECHNOLOGY CO LTD
Filing Date
2023-08-07
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

In large local area network environments, the response time of DHCP servers increases when managing and allocating IP addresses, leading to a decrease in system operating efficiency. Furthermore, large-scale IP address management consumes excessive amounts of server memory and processor resources.

Method used

It adopts a combined structure of target array and target doubly linked list, quickly finds allocable IP addresses through array index, and optimizes the IP address allocation and recycling process by taking advantage of the high efficiency of linked list insertion and deletion.

Benefits of technology

This reduces the time complexity of the IP address allocation and recycling process, decreases system overhead, and improves server performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117155899B_ABST
    Figure CN117155899B_ABST
Patent Text Reader

Abstract

The application discloses an IP address management method and device. The method comprises the following steps: in response to a request of a client for applying for an IP address, determining an allocable IP address through a target bidirectional linked list corresponding to a target array, wherein the target array stores data objects of each IP address in an IP address pool, the target bidirectional linked list stores data objects of unallocated IP addresses, and the data objects comprise a host number of the IP address, an allocation state and linked list pointer information; allocating the IP address to the client, adjusting the allocation state in the corresponding data object, and unbinding the data object from the target bidirectional linked list; in response to a request of the client for returning the IP address, determining the data object of the IP address in the target array by taking the host number of the IP address as an array index; adjusting the allocation state in the data object, and adding the data object to the target bidirectional linked list. The application solves the technical problem that the allocation and recovery management of IP addresses in the related art cause large performance overhead.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of network communication technology, and more specifically, to an IP address management method and apparatus. Background Technology

[0002] DHCP (Dynamic Host Configuration Protocol) is typically used in large local area network (LAN) environments for centralized management and allocation of IP addresses. The DHCP protocol employs a client / server model; the dynamic allocation of IP addresses is driven by the client. The DHCP server only sends the relevant IP address configuration information to the client when it receives a request for an IP address from the client.

[0003] In related technologies, when a server receives an IP address request from a client, it searches for a valid IP address from the IP address pool and provides it to the client. However, due to the increase in IP address ranges and IP addresses in the IP address pool, the response time for the client to obtain an IP address will inevitably increase when the server searches for a valid IP address. At the same time, when using DHCP to dynamically allocate IP addresses on a large scale, the management of adding, deleting, allocating, and reclaiming a large number of IP address ranges will inevitably increase the server's memory and processor consumption, seriously affecting system operating efficiency.

[0004] There is currently no effective solution to the above problems. Summary of the Invention

[0005] This application provides an IP address management method and apparatus to at least solve the technical problem in the related art that the allocation and reclamation management of IP addresses causes significant performance overhead.

[0006] According to one aspect of the embodiments of this application, an IP address management method is provided, comprising: responding to a first request from a first client to apply for an IP address, determining a first IP address to be allocated through a target doubly linked list corresponding to a target array, wherein the target array stores data objects of each IP address in an IP address pool, and the target doubly linked list stores data objects of each unallocated IP address, the data objects including at least: the host number of the IP address, the allocation status, and linked list pointer information; allocating the first IP address to the first client, adjusting the allocation status in the first data object of the first IP address, and unbinding the first data object from the target doubly linked list; responding to a second request from a second client to return a second IP address, determining a second data object of the second IP address in the target array based on the second host number of the second IP address as an array index; adjusting the allocation status in the second data object, and adding the second data object to the target doubly linked list.

[0007] Optionally, before responding to the first request from the first client to request an IP address, a memory region of the target size is allocated; the data objects of each IP address in the IP address pool are stored in the memory region, wherein the allocation status of each IP address is unallocated and the linked list pointer information is empty; the host number in each data object is used as the array index to obtain the target array; the linked list pointer information of each data object is assigned according to the size order of the host number in each data object, and the data object with the smallest host number is determined as the head element to obtain the target doubly linked list, wherein the linked list pointer information includes: the previous element pointer and the next element pointer of the current element.

[0008] Optionally, requesting a memory region of the target size includes: determining the target size based on the number of IP addresses in the IP address pool and the size of the data object for each IP address; and requesting a memory region of the target size from the server.

[0009] Optionally, determining the first IP address to be assigned through the target doubly linked list corresponding to the target array includes: determining the first host number in the first data object corresponding to the current head element when the current head element of the target doubly linked list is not empty; obtaining the configuration information of the IP address pool, wherein the configuration information includes at least network segment and subnet mask information; and determining the first IP address based on the first host number and the configuration information.

[0010] Optionally, adjusting the allocation status of the first data object of the first IP address and unbinding the first data object from the target doubly linked list includes: changing the allocation status of the first data object from unallocated to allocated; adjusting the pointer of the next element in the first data object in the target doubly linked list to null; adjusting the pointer of the previous element of the next element corresponding to the first data object to null; and setting the next element corresponding to the first data object as the new head element.

[0011] Optionally, determining the second data object of the second IP address in the target array based on the second host number of the second IP address as the array index includes: obtaining the configuration information of the IP address pool, wherein the configuration information includes at least network segment and subnet mask information; determining the second host number based on the second IP address and the configuration information, and using the second host number as the array index; determining the target memory address based on the array pointer and array index of the target array, and determining the element at the target memory address as the second data object.

[0012] Optionally, adjusting the allocation state of the second data object and adding the second data object to the target doubly linked list includes: changing the allocation state of the second data object from allocated to unallocated; adjusting the pointer of the previous element of the current head element to point to the second data object; adjusting the pointer of the next element of the second data object to point to the current head element; and setting the second data object as the new head element.

[0013] According to another aspect of the embodiments of this application, an IP address management device is also provided, comprising: a first response module, configured to respond to a first request from a first client to apply for an IP address, and determine a first IP address to be allocated by means of a target doubly linked list corresponding to a target array, wherein the target array stores data objects of each IP address in an IP address pool, and the target doubly linked list stores data objects of each unallocated IP address, the data objects including at least: the host number of the IP address, the allocation status, and the linked list pointer information; an allocation module, configured to allocate the first IP address to the first client, adjust the allocation status of the first data object of the first IP address, and unbind the first data object from the target doubly linked list; a second response module, configured to respond to a second request from a second client to return a second IP address, and determine a second data object of the second IP address in the target array based on the second host number of the second IP address as an array index; and a recycling module, configured to adjust the allocation status of the second data object and add the second data object to the target doubly linked list.

[0014] According to another aspect of the embodiments of this application, a non-volatile storage medium is also provided, the non-volatile storage medium including a stored computer program, wherein the device where the non-volatile storage medium is located executes the above-described IP address management method by running the computer program.

[0015] According to another aspect of the embodiments of this application, an electronic device is also provided, the electronic device including: a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the above-described IP address management method through the computer program.

[0016] In this embodiment, after allocating a memory region, the data objects of each IP address in the IP address pool can be stored in the memory region. Each data object includes at least the host number of the IP address, its allocation status, and linked list pointer information. Initially, the allocation status of each IP address is unallocated, and the linked list pointer information is empty. Then, using the host number in each data object as an array index, a target array can be obtained. The linked list pointer information of each data object is assigned values ​​according to the order of the host numbers, and the data object with the smallest host number is determined as the head element, resulting in a target doubly linked list. Subsequently, when responding to a client's request to apply for an IP address, an allocable IP address can be quickly determined and allocated using the target doubly linked list. When responding to a client's request to return an IP address, the memory address of that IP address can be quickly found using the host number as an index through the target array, and then reclaimed. This scheme fully utilizes the high efficiency of linked list insertion and deletion and the high efficiency of array access and query, reducing the time complexity of IP address allocation and reclamation processes, reducing system overhead, and effectively solving the technical problem of significant performance overhead caused by IP address allocation and reclamation management in related technologies. Attached Figure Description

[0017] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0018] Figure 1 This is a schematic diagram of the structure of an optional computer terminal according to an embodiment of this application;

[0019] Figure 2 This is a flowchart illustrating an optional IP address management method according to an embodiment of this application;

[0020] Figure 3 This is a schematic diagram of an optional target array according to an embodiment of this application;

[0021] Figure 4 This is a schematic diagram of an optional target doubly linked list according to an embodiment of this application;

[0022] Figure 5 This is a schematic diagram of an optional target array after IP address allocation according to an embodiment of this application;

[0023] Figure 6 This is a schematic diagram of an optional target doubly linked list after IP address allocation according to an embodiment of this application;

[0024] Figure 7 This is a schematic diagram of an optional IP address management device according to an embodiment of this application. Detailed Implementation

[0025] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0026] It should be noted that the terms "first," "second," etc., used in the specification, claims, and drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0027] Example 1

[0028] According to an embodiment of this application, an IP address management method is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0029] The method embodiments provided in this application can be executed on a mobile terminal, computer terminal, or similar computing device. Figure 1 A hardware block diagram of a computer terminal (or mobile device) for implementing an IP address management method is shown. Figure 1As shown, the computer terminal 10 (or mobile device 10) may include one or more processors 102 (shown as 102a, 102b, ..., 102n in the figure) 102 (processor 102 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of a BUS bus), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 10 may also include... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.

[0030] It should be noted that the aforementioned one or more processors 102 and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the computer terminal 10 (or mobile device). As involved in the embodiments of this application, the data processing circuits serve as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).

[0031] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the IP address management method in this embodiment. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby implementing the above-mentioned application vulnerability detection method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0032] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 10. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.

[0033] The display can be, for example, a touchscreen liquid crystal display (LCD) that allows the user to interact with the user interface of the computer terminal 10 (or mobile device).

[0034] Under the above operating environment, embodiments of this application provide an IP address management method, such as... Figure 2 As shown, the method includes the following steps:

[0035] Step S202: In response to the first request from the first client to apply for an IP address, the first IP address to be allocated is determined by the target doubly linked list corresponding to the target array. The target array stores the data objects of each IP address in the IP address pool, and the target doubly linked list stores the data objects of each unallocated IP address. The data objects include at least: the host number of the IP address, the allocation status, and the linked list pointer information.

[0036] Step S204: Assign the first IP address to the first client, adjust the allocation status in the first data object of the first IP address, and unbind the first data object from the target doubly linked list;

[0037] Step S206: In response to the second request from the second client to return the second IP address, determine the second data object of the second IP address in the target array based on the second host number of the second IP address as the array index;

[0038] Step S208: Adjust the allocation state in the second data object and add the second data object to the target doubly linked list.

[0039] The following section explains each step of the IP address management method in conjunction with the specific implementation process.

[0040] As an optional implementation, before allocating or reclaiming IP addresses in the IP address pool, a target array and a target doubly linked list corresponding to the IP address pool can be established in the following way:

[0041] To request a memory region of the target size, specifically, the target size can be determined first based on the number of IP addresses in the IP address pool and the size of the data object for each IP address, and then a memory region of that target size can be requested from the server. Assume the IP address pool is 192.168.10.0 / 24.

[0042] Store the data objects of each IP address in the IP address pool into the memory area. The data objects include at least the following information: the host number of the IP address (data), the allocation status (status), and the linked list pointer information. The linked list pointer information includes: the pointer to the previous element (prev) and the pointer to the next element (next). In the initial state, the allocation status (status) of each IP address is unallocated, and the linked list pointer information is null.

[0043] Optionally, the host number (data) in each data object is used as the array index (index), usually in the form of a subscript, to establish a mapping relationship between IP addresses and memory addresses, thus obtaining the target array, whose array pointer is denoted as ip_block. Figure 3 A schematic diagram of the structure of an optional target array is shown.

[0044] Optionally, the linked list pointer information of each data object is assigned according to the size order of the host number in each data object, that is, the previous element pointer prev and the next element pointer next of each element are determined. Among them, the data object with the smallest host number is the head element, and its previous element pointer prev is null. The data object with the largest host number is the tail element, and its next element pointer next is null. The target doubly linked list is obtained, and its head pointer is denoted as ip_nonallocator. Figure 4 A schematic diagram of an optional target doubly linked list is shown.

[0045] As an optional implementation, in the IP address allocation scenario, in response to the first request from the first client to apply for an IP address, the first IP address to be allocated can be determined in the following way: when the current head element of the target doubly linked list is not empty, it indicates that there are still unallocated IP addresses in the IP address pool, and the first host number in the first data object corresponding to the current head element can be determined; since a complete IP address consists of a network number and a host number, in order to determine the complete first IP address, it is also necessary to obtain the configuration information of the IP address pool, which includes at least the network segment and subnet mask information, and then determine the first IP address based on the first host number and the configuration information.

[0046] Afterwards, the first IP address can be assigned to the first client, the allocation status in the first data object can be changed from unallocated to allocated, and the first data object can be unbound from the target doubly linked list in the following way: the next element pointer in the first data object is adjusted to null, the previous element pointer prev of the next element corresponding to the first data object is adjusted to null, and the next element corresponding to the first data object is set as the head element, that is, the head pointer ip_nonallocator is adjusted to point to the next element corresponding to the first data object.

[0047] Figure 5 This diagram illustrates the structure of a target array after the first IP address with host number 0 has been assigned. Figure 6 This shows a schematic diagram of the target doubly linked list after the first IP address with host number 0 is assigned.

[0048] Based on the method of inserting and deleting elements in a linked list, the time complexity of the entire IP address allocation process is O(1).

[0049] It should be noted that when the current head element of the target doubly linked list is null, it indicates that all IP addresses in the IP address pool have been allocated, and a message indicating that no available IP address is currently available can be sent to the first client.

[0050] As an optional implementation, in an IP address reclamation scenario, in response to a second request from a second client to return a second IP address, the second data object of the second IP address in the target array can be determined as follows: obtain the configuration information of the IP address pool, which includes at least network segment and subnet mask information; determine the second host number based on the second IP address and the configuration information, and use the second host number as the array index; determine the target memory address based on the array pointer ip_block and the array index of the target array, and determine the element at the target memory address as the second data object.

[0051] Based on array lookup to access elements, the time complexity of accessing the second data object is O(1). Compared with the time complexity of O(n) of querying the memory address of the IP address to be reclaimed through linked list in related technologies, the scheme of this application to access the memory address of the IP address to be reclaimed is more efficient and can reduce server performance overhead.

[0052] After finding the second data object in the memory region, the allocation status of the second data object can be changed from allocated to unallocated, and the second data object can be added to the target doubly linked list in the following way: adjust the previous element pointer prev of the current head element to point to the second data object, adjust the next element pointer next of the second data object to point to the current head element, and then set the second data object as the new head element, that is, adjust the head pointer ip_nonallocator to point to the second data object.

[0053] by Figure 6 Taking the target doubly linked list as an example, after reclaiming the first IP address with host number 0, the result is as shown in the figure. Figure 4 The target doubly linked list is shown.

[0054] In this embodiment, after allocating a memory region, the data objects of each IP address in the IP address pool can be stored in the memory region. Each data object includes at least the host number of the IP address, its allocation status, and linked list pointer information. Initially, the allocation status of each IP address is unallocated, and the linked list pointer information is empty. Then, using the host number in each data object as an array index, a target array can be obtained. The linked list pointer information of each data object is assigned values ​​according to the order of the host numbers, and the data object with the smallest host number is determined as the head element, resulting in a target doubly linked list. Subsequently, when responding to a client's request to apply for an IP address, an allocable IP address can be quickly determined and allocated using the target doubly linked list. When responding to a client's request to return an IP address, the memory address of that IP address can be quickly found using the host number as an index through the target array, and then reclaimed. This scheme fully utilizes the high efficiency of linked list insertion and deletion and the high efficiency of array access and query, reducing the time complexity of IP address allocation and reclamation processes, reducing system overhead, and effectively solving the technical problem of significant performance overhead caused by IP address allocation and reclamation management in related technologies.

[0055] Example 2

[0056] According to an embodiment of this application, an IP address management device for implementing the IP address management method in Embodiment 1 is also provided, such as... Figure 7 As shown, the IP address management device includes at least a first response module 71, an allocation module 72, a second response module 73, and a recycling module 74, wherein:

[0057] The first response module 71 is used to respond to the first request from the first client to apply for an IP address. It determines the first IP address to be allocated by using the target doubly linked list corresponding to the target array. The target array stores the data objects of each IP address in the IP address pool, and the target doubly linked list stores the data objects of each unallocated IP address. The data objects include at least the host number of the IP address, the allocation status, and the linked list pointer information.

[0058] The allocation module 72 is used to allocate the first IP address to the first client, adjust the allocation status in the first data object of the first IP address, and unbind the first data object from the target doubly linked list.

[0059] The second response module 73 is used to respond to the second request from the second client to return the second IP address, and to determine the second data object of the second IP address in the target array based on the second host number of the second IP address as the array index.

[0060] The recycling module 74 is used to adjust the allocation status of the second data object and add the second data object to the target doubly linked list.

[0061] Optionally, the IP address management device in this application embodiment further includes a creation module, used to create a target array and a target doubly linked list corresponding to the IP address pool before allocating or reclaiming IP addresses in the IP address pool, in the following manner:

[0062] To request a memory region of the target size, specifically, the target size can be determined first based on the number of IP addresses in the IP address pool and the size of the data object for each IP address. Then, a memory region of the target size is requested from the server. The data objects of each IP address in the IP address pool are stored in the memory region. The data object includes at least the following information: the host number of the IP address, the allocation status, and the linked list pointer information. The linked list pointer information includes: the pointer to the previous element and the pointer to the next element of the current element. In the initial state, the allocation status of each IP address is unallocated, and the linked list pointer information is empty.

[0063] Next, the host number in each data object is used as an array index, usually in the form of an index, to establish a mapping relationship between IP addresses and memory addresses, thus obtaining the target array. The linked list pointer information of each data object is assigned according to the size order of the host number in each data object, that is, the previous element pointer and the next element pointer of each element are determined. Among them, the data object with the smallest host number is the head element of the list, and its previous element pointer is null. The data object with the largest host number is the tail element of the list, and its next element pointer is null, thus obtaining the target doubly linked list.

[0064] As an optional implementation, in the IP address allocation scenario, the first response module responds to the first client's first request for an IP address and determines the first IP address to be allocated in the following way: when the current head element of the target doubly linked list is not empty, it indicates that there are still unallocated IP addresses in the IP address pool, and the first host number in the first data object corresponding to the current head element can be determined; since a complete IP address consists of a network number and a host number, in order to determine the complete first IP address, it is also necessary to obtain the configuration information of the IP address pool, which includes at least the network segment and subnet mask information, and then determine the first IP address based on the first host number and the configuration information.

[0065] Afterwards, the allocation module can allocate the first IP address to the first client, change the allocation status of the first data object from unallocated to allocated, and unbind the first data object from the target doubly linked list in the following way: adjust the next element pointer in the first data object to null, adjust the previous element pointer of the next element corresponding to the first data object to null, and set the next element corresponding to the first data object as the head element, that is, adjust the head pointer to point to the next element corresponding to the first data object.

[0066] Based on the method of inserting and deleting elements in a linked list, the time complexity of the entire IP address allocation process is O(1).

[0067] It should be noted that when the current head element of the target doubly linked list is empty, it indicates that all IP addresses in the IP address pool have been allocated, and the first response module can send a message to the first client indicating that there are currently no available IP addresses.

[0068] As an optional implementation, in an IP address reclamation scenario, the second response module, in response to a second request from a second client to return a second IP address, can determine the second data object of the second IP address in the target array in the following way: obtain the configuration information of the IP address pool, which includes at least network segment and subnet mask information; determine the second host number based on the second IP address and the configuration information, and use the second host number as the array index; determine the target memory address based on the array pointer and array index of the target array, and determine the element at the target memory address as the second data object.

[0069] Based on array lookup to access elements, the time complexity of accessing the second data object is O(1). Compared with the time complexity of O(n) of querying the memory address of the IP address to be reclaimed through linked list in related technologies, the scheme of this application to access the memory address of the IP address to be reclaimed is more efficient and can reduce server performance overhead.

[0070] After the second response module finds the second data object in the memory area, the recycling module can change the allocation status of the second data object from allocated to unallocated, and add the second data object to the target doubly linked list in the following way: adjust the pointer of the previous element of the current head element to point to the second data object, adjust the pointer of the next element of the second data object to point to the current head element, and then set the second data object as the new head element, that is, adjust the head pointer to point to the second data object.

[0071] It should be noted that each module in the IP address management device in this embodiment corresponds one-to-one with each implementation step of the IP address management method in Embodiment 1. Since Embodiment 1 has been described in detail, some details not shown in this embodiment can be referred to Embodiment 1, and will not be elaborated further here.

[0072] Example 3

[0073] According to an embodiment of this application, a non-volatile storage medium is also provided, which includes a stored computer program, wherein the device where the non-volatile storage medium is located executes the IP address management method in Embodiment 1 by running the computer program.

[0074] Specifically, the device containing the non-volatile storage medium executes the following steps by running the computer program: In response to a first request from a first client to apply for an IP address, a first IP address to be allocated is determined through a target doubly linked list corresponding to a target array, wherein the target array stores data objects of each IP address in the IP address pool, and the target doubly linked list stores data objects of each unallocated IP address, and the data objects include at least: the host number of the IP address, the allocation status, and the linked list pointer information; the first IP address is allocated to the first client, the allocation status in the first data object of the first IP address is adjusted, and the first data object is unbound from the target doubly linked list; In response to a second request from a second client to return a second IP address, a second data object of the second IP address is determined in the target array based on the second host number of the second IP address as an array index; the allocation status in the second data object is adjusted, and the second data object is added to the target doubly linked list.

[0075] According to an embodiment of this application, a processor is also provided for running a computer program, wherein the computer program executes the IP address management method in embodiment 1 during runtime.

[0076] Specifically, the computer program executes the following steps during runtime: In response to a first request from a first client to apply for an IP address, a first IP address to be allocated is determined using a target doubly linked list corresponding to a target array. The target array stores data objects of each IP address in the IP address pool, and the target doubly linked list stores data objects of each unallocated IP address. Each data object includes at least: the host number of the IP address, its allocation status, and a linked list pointer. The first IP address is allocated to the first client, the allocation status of the first data object of the first IP address is adjusted, and the first data object is unbound from the target doubly linked list. In response to a second request from a second client to return a second IP address, a second data object of the second IP address is determined in the target array based on the second host number of the second IP address as an array index. The allocation status of the second data object is adjusted, and the second data object is added to the target doubly linked list.

[0077] According to an embodiment of this application, an electronic device is also provided, comprising: a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the IP address management method of Embodiment 1 through the computer program.

[0078] Specifically, the processor is configured to execute the following steps via a computer program: In response to a first request from a first client to apply for an IP address, determine a first IP address to be allocated using a target doubly linked list corresponding to a target array, wherein the target array stores data objects of each IP address in the IP address pool, and the target doubly linked list stores data objects of each unallocated IP address, the data objects including at least: the host number of the IP address, the allocation status, and the linked list pointer information; allocate the first IP address to the first client, adjust the allocation status in the first data object of the first IP address, and unbind the first data object from the target doubly linked list; In response to a second request from a second client to return a second IP address, determine a second data object of the second IP address in the target array based on the second host number of the second IP address as an array index; adjust the allocation status in the second data object, and add the second data object to the target doubly linked list.

[0079] The sequence numbers of the above embodiments are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0080] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0081] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some interfaces; indirect couplings or communication connections between units or modules may be electrical or other forms.

[0082] The units described as separate components may or may not be physically separate. Similarly, the components shown as units may or may not be physical units; they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.

[0083] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0084] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0085] The above are merely preferred embodiments of this application. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. An IP address management method, characterized in that, include: In response to the first request from the first client to apply for an IP address, the first IP address to be allocated is determined by the target doubly linked list corresponding to the target array. The target array stores data objects of each IP address in the IP address pool, and the target doubly linked list stores data objects of each unallocated IP address. The data objects include at least: the host number of the IP address, the allocation status, and the linked list pointer information. Assign the first IP address to the first client, adjust the allocation status in the first data object of the first IP address, and unbind the first data object from the target doubly linked list; In response to a second request from a second client to return a second IP address, the second data object of the second IP address in the target array is determined based on the second host number of the second IP address as an array index; Adjust the allocation state in the second data object and add the second data object to the target doubly linked list.

2. The method according to claim 1, characterized in that, Prior to responding to the first request from the first client to request an IP address, the method further includes: Allocate a memory region of the target size; The data objects of each IP address in the IP address pool are stored in the memory area, wherein the allocation status of each IP address is unallocated and the linked list pointer information is empty; The target array is obtained by using the host number in each data object as the array index; The linked list pointer information of each data object is assigned values ​​according to the size order of the host number in each data object, and the data object with the smallest host number is determined as the head element, thus obtaining the target doubly linked list. The linked list pointer information includes: the previous element pointer and the next element pointer of the current element.

3. The method according to claim 2, characterized in that, Allocate a memory region of the target size, including: The target size is determined based on the number of IP addresses in the IP address pool and the size of the data object for each IP address; Request a memory region of the target size from the server.

4. The method according to claim 2, characterized in that, The first IP address to be assigned is determined by the doubly linked list corresponding to the target array, including: When the current head element of the target doubly linked list is not empty, determine the first host number in the first data object corresponding to the current head element; Obtain the configuration information of the IP address pool, wherein the configuration information includes at least network segment and subnet mask information; The first IP address is determined based on the first host number and the configuration information.

5. The method according to claim 4, characterized in that, Adjusting the allocation status of the first data object of the first IP address and unbinding the first data object from the target doubly linked list includes: Change the allocation status of the first data object from unallocated to allocated; The pointer to the next element in the first data object of the target doubly linked list is set to null, the pointer to the previous element of the next element corresponding to the first data object is set to null, and the next element corresponding to the first data object is set as the new head element.

6. The method according to claim 2, characterized in that, Using the second host number of the second IP address as an array index, determine the second data object of the second IP address in the target array, including: Obtain the configuration information of the IP address pool, wherein the configuration information includes at least network segment and subnet mask information; The second host number is determined based on the second IP address and the configuration information, and the second host number is used as an array index; The target memory address is determined based on the array pointer and the array index of the target array, and the element at the target memory address is determined to be the second data object.

7. The method according to claim 6, characterized in that, Adjusting the allocation state of the second data object and adding the second data object to the target doubly linked list includes: Change the allocation status of the second data object from allocated to unallocated; Adjust the pointer of the previous element of the current header element to point to the second data object, adjust the pointer of the next element of the second data object to point to the current header element, and set the second data object as the new header element.

8. An IP address management device, characterized in that, include: The first response module is used to respond to the first request from the first client to apply for an IP address. It determines the first IP address to be allocated by using a target doubly linked list corresponding to the target array. The target array stores data objects of each IP address in the IP address pool, and the target doubly linked list stores data objects of each unallocated IP address. The data objects include at least: the host number of the IP address, the allocation status, and the linked list pointer information. The allocation module is used to allocate the first IP address to the first client, adjust the allocation status in the first data object of the first IP address, and unbind the first data object from the target doubly linked list; The second response module is used to respond to the second request from the second client to return the second IP address, and to determine the second data object of the second IP address in the target array based on the second host number of the second IP address as an array index; The recycling module is used to adjust the allocation status of the second data object and add the second data object to the target doubly linked list.

9. A non-volatile storage medium, characterized in that, The non-volatile storage medium includes a stored computer program, wherein the device containing the non-volatile storage medium executes the IP address management method according to any one of claims 1 to 7 by running the computer program.

10. An electronic device, characterized in that, include: A memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the IP address management method according to any one of claims 1 to 7 through the computer program.