A method and system for dynamically allocating communication protocol addresses based on priority
The communication protocol address allocation method based on dynamic hash table and priority management solves the problems of address resource waste and system performance bottleneck in traditional methods, realizes efficient address allocation and recovery, and improves the adaptability and stability of the system.
Patent Information
- Application Number
- CN202411025683.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2044-07-30
AI Technical Summary
Traditional communication protocol address allocation methods are unable to meet the complex and changing communication environment and growing business needs, resulting in waste of address resources, system performance bottlenecks and inability to adapt to load changes in real time.
A priority-based communication protocol address dynamic allocation method is adopted. The address and its status are stored in a dynamic hash table. The address allocation is adjusted in real time according to the priority weight of the functional module and the system load. It includes address management, priority management, sorting, address allocation and recycling modules.
It improves the efficiency of address allocation and recovery, optimizes system performance, reduces resource waste, improves hardware resource utilization and system stability, and reduces maintenance costs.
Smart Images

Figure CN118784617B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network communications, and in particular to a method and system for dynamically allocating communication protocol addresses based on priority. Background Art
[0002] With the increasing digitization of today's internet systems, the complexity and scale of communication systems are rapidly increasing. As key identifiers in communication networks, the effective allocation of communication protocol addresses is crucial for ensuring accurate data transmission, efficient system operation, and rational resource utilization. The continuous emergence of various emerging application scenarios, such as large-scale device connectivity in the Internet of Things and dynamic resource allocation in cloud computing environments, has placed higher demands on the flexibility, adaptability, and efficiency of communication protocol address allocation.
[0003] Traditional address allocation methods are no longer able to meet the ever-changing demands of today's communication systems, leading to wasted address resources, system performance bottlenecks, and difficulty coping with sudden business growth and load changes. For example, static address allocation lacks flexibility and cannot adapt to the addition and removal of devices or dynamic changes in system load. Range-based address allocation suffers from the drawback of being unable to precisely adjust to real-time demand and load. Simple priority-based address allocation prioritizes different functions or users, but such priorities are often pre-set and fixed, and cannot be dynamically adjusted in real time based on the actual operating status of the system. Summary of the Invention
[0004] In order to overcome the problems of existing communication address allocation schemes such as insufficient flexibility, low resource utilization efficiency and inability to adapt to load changes in real time when facing complex and changing communication environments and growing business needs, the present invention provides a priority-based communication protocol address dynamic allocation method and system.
[0005] The present invention provides a method for dynamically allocating communication protocol addresses based on priority, which is applied to an entity having a communication protocol, and includes the following steps:
[0006] A dynamic hash table is created for storing a plurality of communication protocol addresses and their corresponding address states; wherein the address states include allocated and unallocated;
[0007] Presetting priority weights for different functional modules; wherein the functional modules are program functional modules within the entity that have communication protocol call capabilities;
[0008] When a functional module in the entity initiates an allocation request, the existing allocation requests are sorted according to the priority weight of each functional module. When the priority weights are the same, the allocation requests are sorted according to the time when the allocation requests were initiated; wherein the allocation request is used to request allocation of a communication protocol address for the functional module;
[0009] Searching for unassigned communication protocol addresses in a dynamic hash table, assigning the unassigned communication protocol addresses to the functional modules that initiated the current allocation request in order of sorting, changing the address status of the communication protocol addresses to allocated, and terminating the allocation request;
[0010] When the communication protocol address allocated by the functional module is used up, the address status of the communication protocol address is changed to unallocated;
[0011] Continuously monitor the system resource usage and communication traffic of each functional module, and modify the priority weight of each functional module based on the current ranking of the system resource usage and communication traffic of each functional module.
[0012] Preferably, the step of presetting priority weights for different functional modules further includes the following steps:
[0013] Preset several application scenarios for the entity;
[0014] For each application scenario, a priority weight for each functional module of the entity is preset for the application scenario;
[0015] Based on the application scenario of the current entity, call each functional module according to the priority weight of the application scenario.
[0016] Preferably, the priority weight of each functional module is modified according to the current ranking of the system resource usage and communication traffic of each functional module, and the steps for its implementation are as follows:
[0017] Ranking by the current system resource usage and communication traffic size of each functional module;
[0018] Every first time, the priority weight of the first-ranked functional module is increased by a, and the priority weights of the remaining functional modules are decreased by a, wherein a is the minimum value allowed for increase or decrease of the priority weight, and the first time is a preset time value.
[0019] Preferably, the dynamic hash table includes several keys, each of which includes a hexadecimal communication protocol address, an address status, a corresponding module, and an address allocation time.
[0020] Preferably, the address status includes allocated, unallocated and reclaimable;
[0021] When the communication protocol address allocated by the functional module is used up, the address status of the communication protocol address is changed to unallocated. The specific implementation steps are as follows:
[0022] When the communication protocol address allocated by the functional module is used up, the address state of the key corresponding to the communication protocol address is changed to be recyclable;
[0023] Every second time, the dynamic hash table is traversed, the address status of all keys with recyclable address status is modified to unallocated, and the corresponding module and address allocation time of the key are cleared; wherein the second time is a preset time value.
[0024] The present invention also provides a priority-based communication protocol address dynamic allocation system, comprising: an address management module, a priority management module, a sorting module, an address allocation module, an address recovery module and a dynamic priority module;
[0025] The address management module is provided with a dynamic hash table for storing a number of communication protocol addresses and their corresponding address states; wherein the address states include allocated and unallocated;
[0026] The priority management module is used to preset priority weights for different functional modules; wherein the functional modules are program functional modules within the entity that have the ability to call communication protocols;
[0027] The sorting module is used to sort the existing allocation requests according to the priority weight of each functional module when a functional module in the entity initiates an allocation request. When the priority weights are the same, the allocation requests are sorted according to the time when the allocation requests were initiated; wherein the allocation request is used to request allocation of a communication protocol address to the functional module;
[0028] The address allocation module is used to search for unallocated communication protocol addresses in a dynamic hash table, allocate the unallocated communication protocol addresses to the functional modules that initiate the current allocation request in order of order, change the address status of the communication protocol addresses to allocated, and terminate the allocation request;
[0029] The address recovery module is used to change the address status of the communication protocol address allocated by the functional module to unallocated when the communication protocol address allocated by the functional module is used up;
[0030] The dynamic priority module is used to continuously monitor the system resource usage and communication traffic of each functional module, and modify the priority weight of each functional module according to the current ranking of the system resource usage and communication traffic of each functional module.
[0031] The beneficial effects of the present invention are:
[0032] (1) The communication protocol address and its related information are stored in a dynamic hash table, which reduces the average time required for communication address retrieval, greatly improves the efficiency of address allocation and recovery, and can more effectively utilize storage space and facilitate the modification of stored content. It is suitable for existing network equipment hardware architecture and has strong adaptability.
[0033] (2) By assigning a priority weight to each functional module and dynamically adjusting the priority weight according to the real-time load of the system, the system can better adapt to the dynamically changing load conditions, more accurately allocate addresses to the functional modules that are most needed at the moment, improve the utilization of hardware resources, and reduce the workload and cost of subsequent manual maintenance of the entity.
[0034] (3) Communication protocol addresses are allocated based on the priority weights of functional modules to ensure the normal operation of key functions and prevent low-priority functional modules from occupying too many system resources.
[0035] (4) By changing the status of the communication protocol address that has been used to unallocated, an effective address recycling mechanism is formed, which optimizes the performance of the system, reduces the waste of computing and addressing resources caused by redundant addresses and data, and improves the stability of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The present invention will be further described below with reference to the accompanying drawings, in which:
[0037] Figure 1 This is a flow chart of the method according to the first embodiment of the present invention. DETAILED DESCRIPTION
[0038] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0039] See also Figure 1 As a first embodiment of the present invention, a method for dynamically allocating communication protocol addresses based on priority is disclosed, which is applied to an entity having a communication protocol, and includes the following steps:
[0040] S1. Address management: creating a dynamic hash table for storing a number of communication protocol addresses and their corresponding address states; wherein the address states include allocated and unallocated;
[0041] S2. Priority management: presetting priority weights for different functional modules; wherein the functional modules are program functional modules within the entity that have the ability to call communication protocols;
[0042] S3. Sorting: When a functional module in the entity initiates an allocation request, the existing allocation requests are sorted according to the priority weight of each functional module. If the priority weights are the same, the allocation requests are sorted according to the time when the allocation requests were initiated. The allocation request is used to request allocation of a communication protocol address to the functional module.
[0043] S4. Address allocation: Searching for unallocated communication protocol addresses in the dynamic hash table, assigning the unallocated communication protocol addresses to the functional modules that initiated the current allocation request in order of sorting, changing the address status of the communication protocol addresses to allocated, and terminating the allocation request.
[0044] S5. Address recovery: When the communication protocol address allocated by the functional module is used up, the address status of the communication protocol address is changed to unallocated;
[0045] S6. Dynamic priority adjustment: Continuously monitor the system resource usage and communication traffic of each functional module, and automatically modify the priority weight of each functional module based on the current ranking of the system resource usage and communication traffic of each functional module.
[0046] This embodiment also discloses a priority-based communication protocol address dynamic allocation system, comprising: an address management module, a priority management module, a sorting module, an address allocation module, an address recovery module, and a dynamic priority module;
[0047] The address management module is provided with a dynamic hash table for storing a number of communication protocol addresses and their corresponding address states; wherein the address states include allocated and unallocated;
[0048] The priority management module is used to preset priority weights for different functional modules; wherein the functional modules are program functional modules within the entity that have the ability to call communication protocols;
[0049] The sorting module is used to sort the existing allocation requests according to the priority weight of each functional module when a functional module in the entity initiates an allocation request. When the priority weights are the same, the allocation requests are sorted according to the time when the allocation requests were initiated; wherein the allocation request is used to request allocation of a communication protocol address to the functional module;
[0050] The address allocation module is used to search for unallocated communication protocol addresses in a dynamic hash table, allocate the unallocated communication protocol addresses to the functional modules that initiate the current allocation request in order of order, change the address status of the communication protocol addresses to allocated, and terminate the allocation request;
[0051] The address recovery module is used to change the address status of the communication protocol address allocated by the functional module to unallocated when the communication protocol address allocated by the functional module is used up;
[0052] The dynamic priority module is used to continuously monitor the system resource usage and communication traffic of each functional module, and automatically modify the priority weight of each functional module according to the current ranking of the system resource usage and communication traffic of each functional module.
[0053] This embodiment stores communication protocol addresses and related information through a dynamic hash table, reducing the average time required for communication address retrieval, greatly improving the efficiency of address allocation and recovery, making more effective use of storage space, facilitating modification of stored content, and being applicable to existing network device hardware architectures with strong adaptability.
[0054] This embodiment assigns a priority weight to each functional module and dynamically adjusts the priority weight according to the real-time load of the system, so that the system can better adapt to dynamically changing load conditions, more accurately allocate addresses to the functional modules that are most needed at the moment, improve the utilization rate of hardware resources, and reduce the workload and cost of subsequent manual maintenance of the entity.
[0055] This embodiment allocates communication protocol addresses according to the priority weights of functional modules, thereby ensuring the normal operation of key functions and preventing low-priority functional modules from occupying excessive system resources.
[0056] This embodiment forms an effective address recycling mechanism by changing the status of communication protocol addresses that have been used to unallocated, optimizes system performance, reduces the waste of computing and addressing resources caused by redundant addresses and data, and improves system stability.
[0057] In actual practice, a new dynamic hash table needs to use different hash functions depending on different situations. Factors usually considered include: the time required to calculate the hash function, the length of the keyword, the size of the dynamic hash table, the distribution of the keyword, and the search frequency of the record. Since the specific selection of the hash function belongs to the existing technology, this solution will not be repeated.
[0058] The following is Example 2 of the present invention. The difference between this embodiment and Example 1 is that the dynamic hash table of this embodiment includes several keys, each key includes a hexadecimal communication protocol address, address status, corresponding module and address allocation time, and the address status includes allocated, unallocated and recyclable.
[0059] Specifically, the new dynamic hash table AddressHashTable created in this embodiment is used to efficiently manage and store communication protocol addresses and related information. The value corresponding to the key of the dynamic hash table is a structure AddressInfo, which contains the following members:
[0060] Communication protocol address in hexadecimal format, such as 0x1000, 0x2000, etc.
[0061] boolIsAllocated (address status): indicates whether the address has been allocated, true means it has been allocated, false means it has not been allocated;
[0062] stringFunctionModule (corresponding module): records the function module to which the address belongs, such as "user management" and "device control";
[0063] DateTime_AllocationTime (address allocation time): records the allocation time of the address, accurate to milliseconds, so as to track and manage the usage time of the address.
[0064] For example, when the system needs to allocate an address for the "User Management" function module, it quickly locates the possible storage location through hash calculation and then traverses to find the first unallocated address, such as 0x1500. The corresponding IsAllocated value is marked as true, the FunctionModule is recorded as "User Management," and the AllocationTime is recorded as the current time. When the address is reclaimed, the corresponding address is found through hash calculation, the IsAllocated value is marked as false, the FunctionModule is cleared, and the AllocationTime is reset.
[0065] In step S2 of this embodiment, the following sub-steps are also included:
[0066] S21. Preset several application scenarios for the entity;
[0067] S22. For each application scenario, preset a priority weight for each functional module of the entity;
[0068] S23. Based on the application scenario of the current entity, call the priority weight of each functional module corresponding to the application scenario.
[0069] This embodiment presets different application scenarios, so that when it detects that the application scenario of the entity switches or changes, it automatically switches to different preset priority schemes, so as to better adapt to the changing usage scenarios, better fit the working environment of the entity, and more accurately allocate addresses to the functional modules that are most needed at the moment.
[0070] In this embodiment, in step S6, the priority weight of each functional module is modified according to the current ranking of the system resource usage and communication traffic of each functional module. The steps for implementing this are as follows:
[0071] S61, ranking the functional modules based on their current system resource usage and communication traffic;
[0072] S62. Every 2 seconds, increase the priority weight of the top-ranked functional module by a, and decrease the priority weights of the remaining functional modules by a, where a is the minimum value allowed for increase or decrease in priority weight.
[0073] Taking a time clock entity as a specific example, we set priority weights for different functional modules of the entity to reflect their importance and urgency in the system. The entity has the following functional modules:
[0074] User Management: Priority weight is 3;
[0075] Device Control: Priority weight is 5;
[0076] Data Collection: The priority weight is 2.
[0077] The priority weights here are not fixed but can be adjusted dynamically based on actual conditions. The device control module always carries critical tasks, so its initial priority is higher. However, in certain scenarios, such as large-scale data collection and analysis, the data acquisition module consumes significantly more system resources and communication bandwidth. In this case, its priority weight can be adjusted to 3, while the device control module's priority weight can be correspondingly reduced to 4. In this case, a is 1.
[0078] Preferably, the monitoring program in the entity monitors the load and communication traffic in real time; by embedding monitoring codes in each functional module, information such as data transmission volume, number and frequency of processing tasks, etc. is collected.
[0079] Assume that during a certain period of time, it is found that the communication traffic of the data acquisition module increases significantly, from an average of 100MB per second to 500MB per second, while the communication traffic of the device control module remains relatively stable at around 50MB per second.
[0080] Based on this load change, the priority weights are dynamically adjusted, increasing the priority weight of the data acquisition module from 2 to 3 or 4, and reducing the priority weight of the device control module from 5 to 4.
[0081] In subsequent address allocation, the system will be more inclined to allocate more address resources to the data acquisition module. For example, when there are address allocation requests from both the data acquisition module and the device control module, the data acquisition module will be given priority to allocate unused addresses.
[0082] In step S5 of this embodiment, when the communication protocol address allocated by the functional module is used up, the address status of the communication protocol address is changed to unallocated. The specific implementation steps are as follows:
[0083] S51, when the communication protocol address allocated by the functional module is used up, the address state of the key corresponding to the communication protocol address is changed to recyclable;
[0084] S52. Every 24 hours, traverse the dynamic hash table, change the address status of all keys with recyclable address status to unallocated, and clear the corresponding module and address allocation time of the key.
[0085] Specifically, the entity runs a cleanup program at regular intervals (for example, at 2:00 AM every day). The cleanup program iterates over all addresses in the AddressHashTable. For addresses marked as reclaimable, such as 0x2500, its IsAllocated flag is reset to false, its FunctionModule is cleared, and its AllocationTime is reset, making it available for re-allocation.
[0086] In step S3, whenever a new address allocation request is generated, for example, a request is sent by a device control module, the system first determines the allocation order according to the priority weights of each functional module.
[0087] Assume that the available unallocated addresses in the current system are 0x2500, 0x3000, and 0x3500. The system searches for the unallocated addresses in the AddressHashTable.
[0088] Because the device control module has the highest priority, the system assigns it address 0x2500 and updates the relevant information of this address in the hash table: IsAllocated is marked as true, FunctionModule is recorded as "Device Control", and AllocationTime is recorded as the current time.
[0089] If multiple functional modules have the same highest priority, they will be allocated based on first-come, first-served or other preset rules.
[0090] The present invention also discloses a terminal device, including a processor and a storage device, wherein the storage device is used to store one or more programs; when the one or more programs are executed by the processor, the processor implements the above-mentioned priority-based communication protocol address dynamic allocation method. The processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc. The processor is the control center of the test equipment, and uses various interfaces and lines to connect the various parts of the entire test equipment.
[0091] The storage device can be used to store computer programs and / or functional modules. The processor implements various functions of the terminal device by running or executing the computer programs and / or functional modules stored in the storage device, and calling data stored in the storage device. The storage device may mainly include a program storage area and a data storage area. The program storage area may store an operating system, at least one application required for a function, etc.; the data storage area may store data created based on the use of the terminal device, etc. In addition, the storage device may include high-speed random access memory and non-volatile memory, such as a hard disk, internal memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, at least one disk storage device, a flash memory device, or other volatile solid-state storage device.
[0092] Among them, if the functional module / unit integrated in the priority-based communication protocol address dynamic allocation system is implemented in the form of 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 present invention implements all or part of the process in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in at least one computer-readable storage medium, and when the computer program is executed by the processor, it can implement the steps of the above-mentioned various method embodiments. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. Computer-readable media may include: any entity or device that can carry computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc.
[0093] It should be noted that the embodiments of the devices and apparatuses described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units. That is, they may be located in one place or distributed across multiple network units. Some or all of the functional modules may be selected based on actual needs to achieve the objectives of the present embodiment.
Claims
1. A method for dynamically allocating communication protocol addresses based on priority, applied to an entity having a communication protocol, characterized in that: The steps are as follows: A dynamic hash table is created for storing a plurality of communication protocol addresses and their corresponding address states; wherein the address states include allocated and unallocated; Presetting priority weights for different functional modules; wherein the functional modules are program functional modules within the entity that have communication protocol call capabilities; When a functional module in the entity initiates an allocation request, the existing allocation requests are sorted according to the priority weight of each functional module. When the priority weights are the same, the allocation requests are sorted according to the time when the allocation requests were initiated; wherein the allocation request is used to request allocation of a communication protocol address for the functional module; Searching for unassigned communication protocol addresses in a dynamic hash table, assigning the unassigned communication protocol addresses to the functional modules that initiated the current allocation request in order of sorting, changing the address status of the communication protocol addresses to allocated, and terminating the allocation request; When the communication protocol address allocated by the functional module is used up, the address status of the communication protocol address is changed to unallocated; Continuously monitor the system resource usage and communication traffic of each functional module, and modify the priority weight of each functional module based on the current ranking of the system resource usage and communication traffic of each functional module.
2. A method for dynamically allocating communication protocol addresses based on priority according to claim 1, characterized in that: The step of presetting priority weights for different functional modules also includes the following steps: Preset several application scenarios for the entity; For each application scenario, a priority weight for each functional module of the entity is preset for the application scenario; Based on the application scenario of the current entity, call each functional module according to the priority weight of the application scenario.
3. The method for dynamically allocating communication protocol addresses based on priority according to claim 1, wherein: The steps for modifying the priority weight of each functional module according to the current system resource usage and communication traffic ranking of each functional module are as follows: Ranking by the current system resource usage and communication traffic size of each functional module; Every first time, the priority weight of the first-ranked functional module is increased by a, and the priority weights of the remaining functional modules are decreased by a, wherein a is the minimum value allowed for increase or decrease of the priority weight, and the first time is a preset time value.
4. The method for dynamically allocating communication protocol addresses based on priority according to claim 1, wherein: The dynamic hash table includes several keys, each of which includes a hexadecimal communication protocol address, an address state, a corresponding module, and an address allocation time.
5. The method for dynamically allocating communication protocol addresses based on priority according to claim 4, characterized in that: The address status includes allocated, unallocated and reclaimable; When the communication protocol address allocated by the functional module is used up, the address status of the communication protocol address is changed to unallocated. The specific implementation steps are as follows: When the communication protocol address allocated by the functional module is used up, the address state of the key corresponding to the communication protocol address is changed to be recyclable; Every second time, the dynamic hash table is traversed, the address status of all keys with recyclable address status is modified to unallocated, and the corresponding module and address allocation time of the key are cleared; wherein the second time is a preset time value.
6. A priority-based communication protocol address dynamic allocation system, characterized in that: include: Address management module, priority management module, sorting module, address allocation module, address recovery module and dynamic priority module; The address management module is provided with a dynamic hash table for storing a number of communication protocol addresses and their corresponding address states; wherein the address states include allocated and unallocated; The priority management module is used to preset priority weights for different functional modules; wherein the functional modules are program functional modules within the entity that have the ability to call communication protocols; The sorting module is used to sort the existing allocation requests according to the priority weight of each functional module when a functional module in the entity initiates an allocation request. When the priority weights are the same, the allocation requests are sorted according to the time when the allocation requests were initiated; wherein the allocation request is used to request allocation of a communication protocol address to the functional module; The address allocation module is used to search for unallocated communication protocol addresses in a dynamic hash table, allocate the unallocated communication protocol addresses to the functional modules that initiate the current allocation request in order of order, change the address status of the communication protocol addresses to allocated, and terminate the allocation request; The address recovery module is used to change the address status of the communication protocol address allocated by the functional module to unallocated when the communication protocol address allocated by the functional module is used up; The dynamic priority module is used to continuously monitor the system resource usage and communication traffic of each functional module, and modify the priority weight of each functional module according to the current ranking of the system resource usage and communication traffic of each functional module.
Citation Information
Patent Citations
Hierarchical registration method and device based on micro-service architecture, storage medium and equipment
CN111490890A
Plant station electric energy acquisition terminal and system based on intelligent detection technology, and meter searching method
CN116528077A