A dynamic address recycling method, device and computer readable storage medium
By querying the list of offline devices in the gateway device and reclaiming eligible IPv4 addresses, the problem of insufficient address pool resources in the gateway device is solved, enabling normal access for new devices and high availability of network devices.
Patent Information
- Application Number
- CN202410888437.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-03
- Publication Date
- 2026-01-27
- Estimated Expiration
- 2044-07-03
AI Technical Summary
In environments with a large number of mobile terminal devices accessing the network and frequent connection/disconnection, the DHCP address pool of the gateway device has limited IPv4 address resources, which prevents new devices from obtaining IPv4 addresses in a timely manner, affecting the availability of network devices.
By querying a pre-defined list of offline devices, selecting devices that meet the offline time criteria for recycling, sending probe messages, and recycling available IPv4 addresses, dynamic address recycling is achieved.
It effectively solves the problem of normal access for new devices when there are no addresses available in the address pool, greatly improves the availability of network devices, and reduces network overhead.
Smart Images

Figure CN118660035B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of network communication technology, and in particular to a dynamic address reclamation method, device, and computer-readable storage medium. Background Technology
[0002] In existing technologies, when a mobile terminal device connects to a gateway device, its DHCP Server (Dynamic Host Configuration Protocol) assigns an IPv4 address for communication. However, when gateway devices are deployed in locations with a large number of mobile terminal connections and frequent connection / disconnection (e.g., public places like cafeterias and shopping malls), the limited IPv4 address resources in the DHCP address pool mean that the IPv4 address leases allocated to most mobile terminals after they go offline cannot be released in a timely manner. That is, when the address pool is exhausted and the IPv4 address leases of offline devices have not expired, newly connected mobile terminals cannot be properly assigned an IPv4 address when connecting to the gateway device.
[0003] Therefore, how to enable mobile devices to efficiently access gateway devices and be properly assigned IPv4 addresses for communication, thereby improving the availability of network devices, has become an urgent technical problem to be solved. Summary of the Invention
[0004] To address the aforementioned technical deficiencies in the prior art, this invention proposes a dynamic address reclamation method applied to gateway devices, the method comprising:
[0005] When a new device is connected and no address can be assigned, query the preset list of offline devices;
[0006] Select the address of the device to be recycled from the list of offline devices whose offline time meets the preset time condition, and send a probe message containing the address to be recycled;
[0007] If a response message corresponding to the probe message is received, the entry corresponding to the device to be recycled is deleted from the offline device list; if no response message is received, the address to be recycled is determined to be a recyclable address.
[0008] Delete the entry corresponding to the reclaimable address from the current lease table and send an address allocation message containing the reclaimable address to the new device.
[0009] Optionally, before querying the preset list of offline devices, the following steps are included:
[0010] The offline device list is created through the management module of the network device;
[0011] When a device is offline, the management module is notified through the driver module of the gateway device, so that the management module adds an entry corresponding to the offline device to the offline device list. When the offline device comes online, the management module is notified through the driver module, so that the management module deletes the entry corresponding to the offline device from the offline device list.
[0012] Optionally, selecting devices from the offline device list whose offline time meets a preset time condition for recycling specifically includes:
[0013] In the list of offline devices, calculate the first difference between the offline time and the access time of each offline device, and calculate the second difference between the lease time of each offline device and the first difference.
[0014] The calculated second difference is taken as the offline time of the offline device, and the offline device with the longest offline time is taken as the device to be recycled.
[0015] Optionally, sending a probe message containing the address of the device to be recycled specifically includes:
[0016] The address to be reclaimed and the preset physical address are encapsulated into the probe message;
[0017] The detection message is broadcast within a preset detection time.
[0018] Optionally, the method further includes:
[0019] Monitor whether there are aging entries in the current address resolution table;
[0020] If the aging entry exists, the management module adds the address and corresponding device in the aging entry to the offline device list.
[0021] Optionally, selecting devices from the offline device list whose offline time meets a preset time condition for recycling specifically includes:
[0022] When multiple addresses need to be reclaimed simultaneously, the offline times of the multiple offline devices in the offline device list are sorted from longest to shortest, and the multiple offline devices at the top of the sort are designated as devices to be reclaimed.
[0023] Optionally, selecting devices from the offline device list whose offline time meets a preset time condition for recycling specifically includes:
[0024] When multiple addresses need to be reclaimed simultaneously, the offline times in the offline device list are sorted from longest to shortest. The offline devices at the top of the list are then filtered by their offline frequency, and several devices with low offline frequency are selected as the devices to be reclaimed.
[0025] Optionally, selecting devices from the offline device list whose offline time meets a preset time condition for recycling specifically includes:
[0026] When multiple addresses need to be reclaimed simultaneously, the offline times in the offline device list are sorted from longest to shortest. The offline devices at the top of the list are then filtered by lease duration, and the devices with the longest lease durations are selected as the devices to be reclaimed.
[0027] The present invention also proposes a dynamic address reclamation device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the dynamic address reclamation method as described in any of the preceding claims.
[0028] The present invention also proposes a computer-readable storage medium storing a dynamic address reclamation program, which, when executed by a processor, implements the steps of the dynamic address reclamation method as described in any of the preceding claims.
[0029] The present invention provides a dynamic address reclamation method, apparatus, and computer-readable storage medium. When a new device connects and there are no addresses available for allocation, a preset list of offline devices is queried. Addresses of devices whose offline time meets a preset time condition are selected from the offline device list, and a probe message containing the address to be reclaimed is sent. If a response message corresponding to the probe message is received, the entry corresponding to the device to be reclaimed is deleted from the offline device list. If no response message is received, the address to be reclaimed is determined to be a reclaimable address. The entry corresponding to the reclaimable address is deleted from the current lease table, and an address allocation message containing the reclaimable address is sent to the new device. This invention provides an efficient dynamic address reclamation scheme, effectively solving the problem of normal access for new devices when there are no addresses available in the address pool, and greatly improving the availability of network devices. Attached Figure Description
[0030] The present invention will be further described below with reference to the accompanying drawings and embodiments. In the accompanying drawings:
[0031] Figure 1 This is the first flowchart of the dynamic address reclamation method of the present invention;
[0032] Figure 2This is the second flowchart of the dynamic address reclamation method of the present invention;
[0033] Figure 3 This is the third flowchart of the dynamic address reclamation method of the present invention;
[0034] Figure 4 This is the fourth flowchart of the dynamic address reclamation method of the present invention;
[0035] Figure 5 This is the fifth flowchart of the dynamic address reclamation method of the present invention;
[0036] Figure 6 This is a timing diagram of the dynamic address reclamation method of the present invention. Detailed Implementation
[0037] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.
[0038] In the following description, the use of suffixes such as "module," "part," or "unit" to denote elements is solely for the purpose of illustrative purposes and has no specific meaning in itself. Therefore, "module," "part," or "unit" may be used interchangeably.
[0039] Figure 1 This is the first flowchart of the dynamic address reclamation method of the present invention. This embodiment proposes a dynamic address reclamation method applied to a gateway device, the method comprising:
[0040] S1. When a new device is connected and no address can be assigned, query the preset list of offline devices;
[0041] S2. Select the address of the device to be recycled from the list of offline devices whose offline time meets the preset time condition, and send a probe message containing the address to be recycled;
[0042] S3. If a reply message corresponding to the probe message is received, the entry corresponding to the device to be recycled is deleted from the offline device list; if no reply message is received, the address to be recycled is determined to be a recyclable address.
[0043] S4. Delete the entry corresponding to the recyclable address in the current lease table, and send an address allocation message containing the recyclable address to the new device.
[0044] Optionally, in this embodiment, the address to be reclaimed is an IPv4 address. Specifically, addressing the problem that when a new mobile terminal device cannot obtain an IPv4 address when it accesses the gateway device because the address pool of the gateway device is exhausted and the offline device lease has not expired, this embodiment proposes a method for reclaiming offline addresses when the gateway device has no addresses to allocate. This allows mobile devices to be allocated a usable network IPv4 address when they access the gateway device, thus improving the availability of network devices.
[0045] For details, please refer to Figure 6 The gateway device in this embodiment includes a driver module and a management module. When a mobile device connects / disconnects, the driver module (based on drivers for network devices such as USB / WLAN / ETH Ethernet) notifies the management module of the gateway device. Furthermore, in this embodiment, to prevent the driver from sometimes failing to receive device connection / disconnection messages, a safeguard is added: when an entry in the ARP (Address Resolution Protocol) table becomes old, the management module is notified that the device corresponding to the IP network address / MAC physical address in that entry is offline, and the corresponding relationship is added to the offline device list. It can be seen that the management module in this embodiment is responsible for maintaining the access / offline device access information, specifically in the following ways: First, during module initialization, an offline device list is created; second, when a device goes offline, the driver module notifies the management module, and the management module adds offline device information to the offline device list, including IP address, MAC address, access time, offline time, and lease time; third, when a device comes online, the driver module notifies the management module, and the management module deletes records with the same IP / MAC address from the offline device list.
[0046] Furthermore, in this embodiment, when a new device connects, the gateway device determines whether to initiate offline address reclamation upon receiving a DHCP discover message. Specifically: on the one hand, if there are available IPs in the address pool for allocation, an available IP is selected from the address pool, and an offer allocation message is sent to the connected device; on the other hand, if there are no available IP addresses in the address pool for allocation, the offline address reclamation process is initiated.
[0047] Furthermore, in the offline address reclamation process of this embodiment, the management module queries the list of offline devices, selects the device with the longest offline time for reclamation, and obtains the IP address of the device as the reclamation address; optionally, the offline time calculation scheme of this embodiment is: offline time = lease time - (offline time - access time).
[0048] In this embodiment, before reclaiming the address, the gateway device module encapsulates an ARP probe packet with a destination MAC address of FF:FF:FF:FF:FF:FF and an IP address that is the IP address to be reclaimed determined in the above steps.
[0049] In this embodiment, if an ARP reply message is received, the record corresponding to the IP / MAC address is deleted from the offline list; if no ARP reply message is received, it proves that the IP address can be reclaimed.
[0050] In this embodiment, for IP addresses that are determined to be reclaimed, the driver module (i.e., the DHCP Server) deletes the lease table record corresponding to that IP address and simultaneously deletes the corresponding ARP table entry. Specifically, the DHCP lease table in this embodiment is a table dynamically managed by the DHCP server. It is a list of IP address leases allocated to clients recorded on the DHCP server. Whenever the DHCP server allocates an IP address to a client, it records information such as the allocated IP address, the client's MAC address, the allocation time, and the lease period. Furthermore, the above information in this embodiment is used to manage the allocation and reclamation of IP addresses during the operation of the DHCP server.
[0051] In this embodiment, the aforementioned IP address is encapsulated into a DHCP offer address allocation message and allocated to the access device for use.
[0052] The beneficial effect of this embodiment is that, when a new device connects and there are no addresses to allocate, a preset offline device list is queried; the address of the device to be reclaimed that meets the preset time condition for offline time is selected from the offline device list, and a probe message containing the address to be reclaimed is sent; if a reply message corresponding to the probe message is received, the entry corresponding to the device to be reclaimed is deleted from the offline device list; if no reply message is received, the address to be reclaimed is determined to be a reclaimable address; the entry corresponding to the reclaimable address is deleted from the current lease table, and an address allocation message containing the reclaimable address is sent to the new device. This implements an efficient dynamic address reclamation scheme, effectively solving the problem of normal access for new devices when there are no addresses to allocate in the address pool, and greatly improving the availability of network devices.
[0053] Figure 2 This is a second flowchart of the dynamic address reclamation method of the present invention. Based on the above embodiment, before querying the preset offline device list, the following steps are included:
[0054] S01. Create the offline device list through the management module of the network device;
[0055] S02. When the device is offline, the management module is notified through the driver module of the gateway device so that the management module adds an entry corresponding to the offline device to the offline device list. When the offline device comes online, the management module is notified through the driver module so that the management module deletes the entry corresponding to the offline device from the offline device list.
[0056] Optionally, in this embodiment, considering that the current solution is based on the IP address reclamation method of RFC2131, which specifically reclaims and reuses IP addresses only after the lease of the allocated IP addresses expires, thus preventing useful addresses from being released and used in a timely manner; while this application, through the dynamic management of the offline device list, allows new devices to access normally even when there are no available addresses in the address pool, without modifying the RFC (Request For Comments, a series of drafts released by the Internet Engineering Task Force) protocol specifications.
[0057] Optionally, in this embodiment, since the address pool is reclaimed when there are no valid addresses in use, periodic probing is not required, which can effectively reduce the network overhead of the gateway device. In contrast, existing offline address reclamation methods reclaim addresses after the device goes offline, which can significantly increase the load on the gateway device if deployed in public places.
[0058] Figure 3 This is the third flowchart of the dynamic address reclamation method of the present invention. Based on the above embodiments, the step of selecting devices to be reclaimed from the offline device list whose offline time meets the preset time condition specifically includes:
[0059] S21. Calculate the first difference between the offline time and the access time of each offline device in the offline device list, and calculate the second difference between the lease time of each offline device and the first difference.
[0060] S22. The calculated second difference is taken as the offline time of the offline device, and the offline device with the longest offline time is taken as the device to be recycled.
[0061] Optionally, in this embodiment, when multiple addresses need to be reclaimed simultaneously, the offline times are sorted from longest to shortest, and the offline devices at the top of the sort are designated as devices to be reclaimed.
[0062] Optionally, in this embodiment, when multiple addresses need to be reclaimed simultaneously, the offline time is sorted from longest to shortest, and the offline devices at the top of the sort are filtered by offline frequency, and several devices with low offline frequency are selected as devices to be reclaimed.
[0063] Optionally, in this embodiment, when multiple addresses need to be reclaimed simultaneously, the offline time is sorted from longest to shortest, and the offline devices at the top of the sort are filtered according to their lease duration, selecting several devices with longer lease durations as the devices to be reclaimed.
[0064] Figure 4 This is the fourth flowchart of the dynamic address reclamation method of the present invention. Based on the above embodiments, the step of sending a probe message containing the address to be reclaimed of the device to be reclaimed specifically includes:
[0065] S23. Encapsulate the address to be reclaimed and the preset physical address into the probe message;
[0066] S24. Broadcast the detection message within the preset detection time.
[0067] Optionally, in this embodiment, considering existing offline address reclamation methods, the use of ICMP (Internet Control Message Protocol) for probing offline addresses is not applicable to mobile terminals that are banned from pinging or those with high latency that cannot respond. Furthermore, existing offline address reclamation methods periodically probe offline devices or send probe packets to all IPs within the network segment during reclamation probes, increasing the load on the network and DHCP server. Therefore, this embodiment only probes the reclaimed addresses, reducing the overhead of invalid data packets and invalid probe packets in the network. Additionally, this embodiment uses the ARP protocol to prevent inaccurate probing by some mobile terminals when ICMP is banned, improving the availability of reclaimed addresses.
[0068] Figure 5 This is the fifth flowchart of the dynamic address reclamation method of the present invention. Based on the above embodiments, the method further includes:
[0069] S03. Monitor whether there are aging entries in the current address resolution table;
[0070] S04. If the aging entry exists, the management module adds the address and corresponding device in the aging entry to the offline device list.
[0071] In this embodiment, the address resolution table entry refers to the ARP table, which is automatically generated by the operating system. Specifically, the ARP table in this embodiment is dynamically generated, recording the mapping relationship between the IP addresses and MAC addresses of local network devices. Specifically, the ARP table in this embodiment is used to process ARP requests and provide a response mechanism, storing the mapping relationship of responding devices in its own ARP cache, updating the ARP cache based on ARP requests and responses, and managing the entries in the ARP table. Optionally, in this embodiment, the aging time is dynamically adjusted according to the frequency of address reclamation. For example, when an increase in the address reclamation frequency is detected, the aging time is reduced, thereby improving address reclamation efficiency.
[0072] Based on the above embodiments, the present invention also proposes a dynamic address reclamation device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, it implements the following:
[0073] When a new device is detected to be connected through the gateway device and there is no address to assign, the preset list of offline devices is queried.
[0074] Select the address of the device to be recycled from the list of offline devices whose offline time meets the preset time condition, and send a probe message containing the address to be recycled;
[0075] If a response message corresponding to the probe message is received, the entry corresponding to the device to be recycled is deleted from the offline device list; if no response message is received, the address to be recycled is determined to be a recyclable address.
[0076] Delete the entry corresponding to the reclaimable address from the current lease table and send an address allocation message containing the reclaimable address to the new device.
[0077] Optionally, the computer program is implemented when executed by the processor as follows:
[0078] The offline device list is created through the management module of the network device;
[0079] When a device is offline, the management module is notified through the driver module of the gateway device so that the management module adds an entry corresponding to the offline device to the offline device list. When the offline device comes online, the management module is notified through the driver module so that the management module deletes the entry corresponding to the offline device from the offline device list.
[0080] Monitor whether there are aging entries in the current address resolution table;
[0081] If the aging entry exists, the management module adds the address and corresponding device in the aging entry to the offline device list.
[0082] Optionally, the computer program is implemented when executed by the processor as follows:
[0083] In the list of offline devices, calculate the first difference between the offline time and the access time of each offline device, and calculate the second difference between the lease time of each offline device and the first difference.
[0084] The calculated second difference is taken as the offline time of the offline device, and the offline device with the longest offline time is taken as the device to be recycled.
[0085] Optionally, the computer program is implemented when executed by the processor as follows:
[0086] The address to be reclaimed and the preset physical address are encapsulated into the probe message;
[0087] The detection message is broadcast within a preset detection time.
[0088] It should be noted that the above-described device embodiments and method embodiments belong to the same concept. The specific implementation process can be found in the method embodiments, and the technical features in the method embodiments are also applicable to the device embodiments, which will not be repeated here.
[0089] Based on the above embodiments, the present invention also proposes a computer-readable storage medium storing a dynamic address reclamation program, which, when executed by a processor, implements the steps of the dynamic address reclamation method as described in any of the above embodiments.
[0090] It should be noted that the above-described medium embodiments and method embodiments belong to the same concept. The specific implementation process can be found in the method embodiments, and the technical features in the method embodiments are also applicable to the medium embodiments, which will not be repeated here.
[0091] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0092] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0093] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0094] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims. All of these forms are within the protection scope of the present invention.
Claims
1. A dynamic address reclamation method, applied to a gateway device, characterized in that, The method includes: When a new device is connected and no address can be assigned, query the preset list of offline devices; Select the address of the device to be recycled from the list of offline devices whose offline time meets the preset time condition, and send a probe message containing the address to be recycled; wherein, calculate the first difference between the offline time and the access time of each offline device in the list of offline devices, and calculate the second difference between the lease time of each offline device and the first difference, take the calculated second difference as the offline time of the offline device, and take the offline device with the longest offline time as the device to be recycled; If a response message corresponding to the probe message is received, the entry corresponding to the device to be recycled is deleted from the offline device list; if no response message is received, the address to be recycled is determined to be a recyclable address. Delete the entry corresponding to the reclaimable address from the current lease table and send an address allocation message containing the reclaimable address to the new device.
2. The dynamic address reclamation method according to claim 1, characterized in that, Before querying the preset list of offline devices, the following steps are included: The offline device list is created through the management module of the gateway device; When a device is offline, the management module is notified through the driver module of the gateway device, so that the management module adds an entry corresponding to the offline device to the offline device list. When the offline device comes online, the management module is notified through the driver module, so that the management module deletes the entry corresponding to the offline device from the offline device list.
3. The dynamic address reclamation method according to claim 1, characterized in that, Sending a probe message containing the address of the device to be recycled specifically includes: The address to be reclaimed and the preset physical address are encapsulated into the probe message; The detection message is broadcast within a preset detection time.
4. The dynamic address reclamation method according to claim 2, characterized in that, The method further includes: Monitor whether there are aging entries in the current address resolution table; If the aging entry exists, the management module adds the address and corresponding device in the aging entry to the offline device list.
5. The dynamic address reclamation method according to claim 1, characterized in that, The step of selecting devices from the list of offline devices that meet preset time conditions for offline time specifically includes: When multiple addresses need to be reclaimed simultaneously, the offline times of the multiple offline devices in the offline device list are sorted from longest to shortest, and the multiple offline devices at the top of the sort are designated as devices to be reclaimed.
6. The dynamic address reclamation method according to claim 1, characterized in that, The step of selecting devices from the list of offline devices that meet preset time conditions for offline time specifically includes: When multiple addresses need to be reclaimed simultaneously, the offline times in the offline device list are sorted from longest to shortest. The offline devices at the top of the list are then filtered by their offline frequency, and several devices with low offline frequency are selected as the devices to be reclaimed.
7. The dynamic address reclamation method according to claim 1, characterized in that, The step of selecting devices from the list of offline devices that meet preset time conditions for offline time specifically includes: When multiple addresses need to be reclaimed simultaneously, the offline times in the offline device list are sorted from longest to shortest. The offline devices at the top of the list are then filtered by lease duration, and the devices with the longest lease durations are selected as the devices to be reclaimed.
8. A dynamic address reclamation device, characterized in that, The device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the dynamic address reclamation method as described in any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a dynamic address reclamation program, which, when executed by a processor, implements the steps of the dynamic address reclamation method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Method for quickly recovering DHCP leases
CN103763405A
Method and device for recovering IP (Internet protocol) address of DHCP (dynamic host configuration protocol) client
CN104158917A