A network address dynamic configuration method, device and computer readable storage medium
By calculating the integer range of unmanned aircraft network addresses and dynamically configuring the address list, the problems of low efficiency and poor flexibility of unmanned aircraft network address configuration in the prior art are solved, and efficient and accurate network address management is achieved.
Patent Information
- Application Number
- CN202310249095.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-14
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2043-03-14
AI Technical Summary
In the prior art, the dynamic configuration of unmanned aircraft network addresses has problems such as low efficiency, high maintenance costs and poor flexibility, especially when the number of aircraft is large or frequent changes.
By calculating the minimum and maximum values of the integer range of valid addresses in the current network, converting them into valid addresses and adding them to the address list, excluding connected addresses by preset periods and assigning addresses to the aircraft to be connected.
It realizes convenient, efficient and accurate dynamic configuration and access of unmanned aircraft, reduces the manpower and material costs in the configuration link, and enhances the flexibility of the access link.
Smart Images

Figure CN116233069B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of unmanned aerial vehicles, and in particular to a method and device for dynamically configuring a network address, and a computer-readable storage medium. Background Art
[0002] In the prior art, there are two ways to discover unmanned aerial vehicles and establish communication in a local area network: one is to directly input the IP address of each unmanned aerial vehicle manually, manually click to connect and execute; the other is to configure a fixed ground control station IP address for each unmanned aerial vehicle, so that each unmanned aerial vehicle automatically sends data to this IP address.
[0003] However, the above two methods have obvious defects: when the number of unmanned aerial vehicles is large, or the increase and decrease are frequent, the former will bring a greater workload to the staff, with a higher probability of error, lower execution efficiency and higher maintenance costs; and when the computer where the ground control station is located fails, the latter is not convenient for immediately switching to another computer for access, and has low redundancy and poor flexibility.
[0004] Therefore, how to realize the dynamic configuration and access of network addresses of unmanned aerial vehicles more conveniently, efficiently and accurately has become a technical problem that needs to be solved urgently. Summary of the invention
[0005] In order to solve the above technical defects in the prior art, the present invention proposes a method for dynamic configuration of a network address, the method comprising:
[0006] Calculate the minimum and maximum values of the integers corresponding to all valid addresses in the current network according to the address input to the current network and the number of bits of the subnet mask;
[0007] Convert each integer in the integer range formed by the minimum value and the maximum value into the corresponding effective address, and add all the effective addresses to a preset address list;
[0008] The connected addresses of the first aircraft in the connected state are excluded from the address list according to a preset configuration period, and the connection operation of the second aircraft in the non-connected state is performed according to the remaining addresses.
[0009] Optionally, the step of calculating the minimum and maximum values of integers corresponding to all valid addresses in the current network according to the addresses input to the current network and the number of bits of the subnet mask comprises:
[0010] Receive the address and the number of bits of the subnet mask input by the user to the current network;
[0011] The bytes and the number of bits corresponding to the address and the number of bits of the subnet mask are obtained by parsing.
[0012] Optionally, the step of calculating the minimum and maximum values of integers corresponding to all valid addresses in the current network according to the address input to the current network and the number of bits of the subnet mask, further comprises:
[0013] Calculate a mask according to the byte and the number of bits;
[0014] The minimum value and the maximum value are calculated based on the integer composed of the bytes and the mask.
[0015] Optionally, converting each integer in the integer range formed by the minimum value and the maximum value into the corresponding effective address, and adding all the effective addresses to a preset address list includes:
[0016] Get all integers in the integer range formed by the minimum value and the maximum value;
[0017] Convert all the integers into the corresponding effective addresses according to the bytes.
[0018] Optionally, excluding the connected addresses of the first aircraft in the connected state in the address list according to a preset configuration period, and performing a connection operation of the second aircraft in the unconnected state according to the remaining addresses, includes:
[0019] Excluding the connected addresses from the address list according to the configuration period to obtain the remaining addresses;
[0020] Sending preset detection data packets to the remaining addresses according to a preset detection period.
[0021] Optionally, the step of excluding the connected addresses of the first aircraft in the connected state from the address list according to a preset configuration period, and performing the connection operation of the second aircraft in the non-connected state according to the remaining addresses, further includes:
[0022] When first reply data corresponding to the detection data packet is received, a heartbeat data packet of a preset communication protocol is sent to a source address of the first reply data via a user datagram protocol;
[0023] When second reply data corresponding to the communication protocol is received, the source address is determined to be the second aircraft to be connected, and a communication link with the second aircraft is established according to the communication protocol.
[0024] Optionally, the method further comprises:
[0025] When the connection operation with the second aircraft is successfully completed, using the address of the second aircraft as the connected address;
[0026] When the next configuration cycle is reached, the address of the second aircraft is excluded from the remaining addresses.
[0027] Optionally, the method further comprises:
[0028] When the first aircraft switches from a connected state to a non-connected state, sending a heartbeat packet to the connected address corresponding to the first aircraft according to a preset monitoring period;
[0029] When the third reply data corresponding to the heartbeat packet is received within the preset monitoring period, the connection status with the first aircraft is restored; when the third reply data is not received within the monitoring period, the connected address corresponding to the first aircraft is used as the remaining address in the next configuration cycle.
[0030] The present invention also proposes a network address dynamic configuration 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, the steps of the network address dynamic configuration method as described in any one of the above items are implemented.
[0031] The present invention also proposes a computer-readable storage medium on which a network address dynamic configuration program is stored. When the network address dynamic configuration program is executed by a processor, the steps of the network address dynamic configuration method as described in any one of the above items are implemented.
[0032] The network address dynamic configuration method, device and computer-readable storage medium of the present invention are implemented by calculating the minimum and maximum values of the integers corresponding to all valid addresses in the current network by inputting the address and subnet mask bit number of the current network; converting each integer in the integer range formed by the minimum value and the maximum value into the corresponding valid address, and adding all the valid addresses to the preset address list; excluding the connected address of the first aircraft in the connected state from the address list according to the preset configuration cycle, and performing the connection operation of the second aircraft in the non-connected state according to the remaining address. A convenient, efficient and accurate network address dynamic configuration and access solution for unmanned aerial vehicles is realized, which reduces the manpower and material costs of the configuration link and enhances the flexibility of the access link. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The present invention will be further described below with reference to the accompanying drawings and embodiments, in which:
[0034] Figure 1is a first flow chart of the network address dynamic configuration method of the present invention;
[0035] Figure 2 is a second flow chart of the network address dynamic configuration method of the present invention;
[0036] Figure 3 is a third flow chart of the network address dynamic configuration method of the present invention;
[0037] Figure 4 is a fourth flow chart of the network address dynamic configuration method of the present invention;
[0038] Figure 5 is a fifth flow chart of the network address dynamic configuration method of the present invention;
[0039] Figure 6 is a sixth flow chart of the network address dynamic configuration method of the present invention;
[0040] Figure 7 is the seventh flow chart of the network address dynamic configuration method of the present invention;
[0041] Figure 8 This is the eighth flow chart of the network address dynamic configuration method of the present invention. DETAILED DESCRIPTION
[0042] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0043] In the subsequent description, the suffixes such as "module", "component" or "unit" used to represent elements are only used to facilitate the description of the present invention, and have no specific meanings. Therefore, "module", "component" or "unit" can be used in a mixed manner.
[0044] Figure 1 This is the first flow chart of the network address dynamic configuration method of the present invention. This embodiment proposes a network address dynamic configuration method, the method comprising:
[0045] S1. Calculate the minimum and maximum values of the integers corresponding to all valid addresses in the current network according to the address input to the current network and the number of bits of the subnet mask;
[0046] S2, converting each integer in the integer range formed by the minimum value and the maximum value into the corresponding effective address, and adding all the effective addresses to a preset address list;
[0047] S3. Excluding the connected addresses of the first aircraft in the connected state from the address list according to a preset configuration period, and performing a connection operation of the second aircraft in the unconnected state according to the remaining addresses.
[0048] In this embodiment, the current network is a local area network supporting IPv4 as an example for explanation. First, the 4 bytes of the address input to the current network are parsed and recorded as a, b, c, d, and the number of subnet mask bits corresponding to the above address input to the current network is parsed and recorded as maskBits; then, the integer composed of the 4 bytes of the address input to the current network is calculated, recorded as address, where the calculation formula of address is address = (a<<24)+(b<<16)+(c<<8)+d; finally, the minimum and maximum values of the integers corresponding to all valid addresses in the current network are calculated according to the above integers, where the minimum value is recorded as min and the maximum value is recorded as max.
[0049] In this embodiment, after the minimum value min and the maximum value max are calculated, for all integers i in the integer range [min, max], its 4 bytes are obtained and converted into corresponding IP addresses, and these IP addresses are added to the address list list as valid addresses.
[0050] In this embodiment, after obtaining the address list list, the connected addresses of the aircraft in the connected state are excluded from the address list according to the preset configuration cycle, and the connection operation of the aircraft in the non-connected state is performed according to the remaining addresses, wherein the aircraft in the connected state is recorded as the first aircraft, and the aircraft in the non-connected state is recorded as the second aircraft; further, the aircraft that was once in the connected state and is now in the non-connected state is still regarded as the first aircraft, so that when the aircraft resumes communication with the ground station, it can re-establish the connection.
[0051] The beneficial effects of this embodiment are that the minimum and maximum values of the integers corresponding to all valid addresses in the current network are calculated by inputting the address and subnet mask bits of the current network; each integer in the integer range formed by the minimum value and the maximum value is converted into the corresponding valid address, and all the valid addresses are added to the preset address list; the connected address of the first aircraft in the connected state is excluded from the address list according to the preset configuration cycle, and the connection operation of the second aircraft in the non-connected state is performed according to the remaining address. A convenient, efficient and accurate network address dynamic configuration and access solution for unmanned aerial vehicles is realized, which reduces the manpower and material costs of the configuration link and enhances the flexibility of the access link.
[0052] Figure 2 is a second flow chart of the network address dynamic configuration method of the present invention, based on the above embodiment, the minimum and maximum values of the integers corresponding to all valid addresses in the current network are calculated according to the address input to the current network and the number of bits of the subnet mask, including:
[0053] S11, receiving the address of the current network and the number of bits of the subnet mask input by the user;
[0054] S12. Analyze and obtain the bytes and bits corresponding to the address and the subnet mask bits respectively.
[0055] Optionally, in this embodiment, the parameter "192.168.2.0 / 23" input to the current network is taken as an example for description, wherein the address of the parameter is "192.168.2.0" and the number of subnet mask bits of the parameter is "23".
[0056] Optionally, in this embodiment, the address of the above parameter "192.168.2.0 / 23" is 4 bytes, that is, 32 bits.
[0057] Figure 3 The third flow chart of the network address dynamic configuration method of the present invention is based on the above embodiment, and the minimum and maximum values of the integers corresponding to all valid addresses in the current network are calculated according to the address input to the current network and the number of bits of the subnet mask, and also includes:
[0058] S13, calculating a mask according to the byte and the number of bits;
[0059] S14. Calculate the minimum value and the maximum value according to the integer composed of the bytes and the mask.
[0060] Optionally, in this embodiment, according to the calculation formula address = (a<<24) + (b<<16) + (c<<8) + d, the integer form of the current address is calculated, wherein the symbol "<<" represents a binary left shift, and a left shift of 8 bits is equivalent to multiplying by 2 to the 8th power. At the same time, the above 24, 16, and 8 are the number of bits of 3 bytes, 2 bytes, and 1 byte, respectively. Based on this, the result of the above entire formula is the integer form of this address. Specifically, for example, (192<<24)+(168<<16)+(2<<8)+0=192*224+168*216+2*28+0=3232236032.
[0061] Optionally, in this embodiment, according to the calculation formula mask=0xFFFFFFFFu<<(32-maskBits), a mask is calculated and recorded as mask.
[0062] Optionally, in this embodiment, the minimum value and the maximum value are calculated according to the calculation formulas min=(address&mask)+1, max=(address|~mask)−1 respectively.
[0063] Figure 4 is a fourth flow chart of the network address dynamic configuration method of the present invention, based on the above embodiment, converting each integer in the integer range consisting of the minimum value and the maximum value into the corresponding valid address, and adding all the valid addresses to the preset address list, including:
[0064] S21, obtaining all integers in the integer range formed by the minimum value and the maximum value;
[0065] S22. Convert all the integers into their corresponding effective addresses according to the bytes.
[0066] Optionally, in this embodiment, first, since the address of the IPv4 network has 4 bytes, that is, 32 bits, based on this, the number of host number bits can be obtained by subtracting the number of network number bits (that is, the number of subnet mask bits) maskBits from 32; then, the number of host number bits is left-shifted from 0xFFFFFFFFu (32 bits all 1) to obtain a mask mask with all binary 1s for the network number and all binary 0s for the host number.
[0067] Optionally, in this embodiment, when maskBits=23, mask=111111111111111111111110 000000000 (binary) can be calculated.
[0068] Optionally, in this embodiment, the calculation result of min is that the network number is consistent with the given address, and the host number is binary all 0 plus 1; at the same time, the calculation result of max is that the network number is consistent with the given address, and the host number is binary all 0 minus 1. Based on the above embodiment, if address = 3232236032, which is 11000000 10101000 00000010 00000000, then min = 11000000 101010000000010 00000001 (binary), and max = 1100000010101000 00000011 11111110 (binary).
[0069] Similarly, as described in the above example, min = 11000000 10101000 00000010 00000001 (binary), max = 11000000 10101000 00000011 11111110 (binary), a number in the range 1100000010101000 00000010 00000011 (binary), its 4 bytes converted to decimal are 192, 168, 2, 3, and the corresponding IP address is 192.168.2.3.
[0070] Figure 5 The fifth flow chart of the network address dynamic configuration method of the present invention is based on the above embodiment, wherein the step of excluding the connected address of the first aircraft in the connected state from the address list according to the preset configuration period, and performing the connection operation of the second aircraft in the non-connected state according to the remaining address, comprises:
[0071] S31, excluding the connected addresses in the address list according to the configuration period to obtain the remaining addresses;
[0072] S32. Sending preset detection data packets to the remaining addresses according to a preset detection period.
[0073] Optionally, in this embodiment, at configurable intervals, the addresses in the address list list are continuously pinged, excluding connected addresses, so as to send ping packets with very low resource consumption to the remaining addresses as the detection packets of this embodiment.
[0074] Figure 6 is a sixth flow chart of the network address dynamic configuration method of the present invention, based on the above embodiment, the configuration cycle according to the preset configuration period excludes the connected address of the first aircraft in the connected state in the address list, and performs the connection operation of the second aircraft in the non-connected state according to the remaining address, and also includes:
[0075] S33, when receiving the first reply data corresponding to the detection data packet, sending a heartbeat data packet of a preset communication protocol to the source address of the first reply data through the user datagram protocol;
[0076] S34. When receiving the second reply data corresponding to the communication protocol, determine that the source address is the second aircraft to be connected, and establish a communication link with the second aircraft according to the communication protocol.
[0077] Optionally, in this embodiment, after the aircraft in the local area network receives the ping data packet, it will send a reply as the first reply data of this embodiment.
[0078] Optionally, in this embodiment, after receiving the first reply data, the ground control station sends a heartbeat data packet of the communication protocol set by the ground control station to the source address through UDP (User Datagram Protocol); if the second reply data corresponding to the communication protocol is received, the second aircraft at the source address is determined to be the object to be connected of the ground control station.
[0079] Figure 7 is a seventh flow chart of the method for dynamic configuration of a network address of the present invention. Based on the above embodiment, the method further includes:
[0080] S41. When the connection operation with the second aircraft is successfully completed, use the address of the second aircraft as the connected address;
[0081] S42: When the next configuration cycle is reached, exclude the address of the second aircraft from the remaining addresses.
[0082] Optionally, in this embodiment, the configuration cycle of this embodiment is set according to the current ratio of the number of the first aircraft to the number of the second aircraft and the current processing resource state of the ground control station, for example, to quickly discover newly powered-on aircraft and / or to occupy less computer processing resources.
[0083] Optionally, in this embodiment, when each detection data packet or heartbeat data packet is sent in each configuration cycle, it is checked whether each address is included in the preset connection pool, wherein the connection pool of this embodiment adopts a hash set data structure to improve the checking speed.
[0084] Figure 8 FIG. 8 is an eighth flow chart of the method for dynamic configuration of a network address of the present invention. Based on the above embodiment, the method further includes:
[0085] S51, when the first aircraft switches from a connected state to a non-connected state, sending a heartbeat packet to the connected address corresponding to the first aircraft according to a preset monitoring period;
[0086] S52. When the third reply data corresponding to the heartbeat packet is received within the preset monitoring period, the connection status with the first aircraft is restored; when the third reply data is not received within the monitoring period, the connected address corresponding to the first aircraft is used as the remaining address in the next configuration cycle.
[0087] Optionally, in this embodiment, the time period between when the user turns on the search and when the user turns off the search is used as the monitoring period of this embodiment, and the above-mentioned exclusion, sending and connection operations are continuously and cyclically performed during this period, so as to discover newly started aircraft earlier.
[0088] Optionally, in this embodiment, the connected aircraft object is still maintained in the above address list, based on which, even if the aircraft is disconnected for a short time, the ground control station will continue to try to send a heartbeat data packet to its corresponding aircraft. Therefore, when the aircraft's communication is restored, the aircraft can receive the above data packet and make the above reply in a targeted manner, so that the link can be reestablished.
[0089] Based on the above embodiments, the present invention also proposes a network address dynamic configuration device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the network address dynamic configuration method as described in any one of the above items when executed by the processor.
[0090] It should be noted that the above-mentioned device embodiment and method embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, and the technical features in the method embodiment are correspondingly applicable in the device embodiment, which will not be repeated here.
[0091] Based on the above embodiments, the present invention further proposes a computer-readable storage medium, which stores a network address dynamic configuration program. When the network address dynamic configuration program is executed by a processor, the steps of the network address dynamic configuration method as described in any of the above items are implemented.
[0092] It should be noted that the above-mentioned medium embodiment and method embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, and the technical features in the method embodiment are correspondingly applicable in the medium embodiment, which will not be repeated here.
[0093] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0094] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0095] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0096] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.
Claims
1. A method for dynamic configuration of a network address, characterized in that: The method comprises: Calculate the minimum and maximum values of the integers corresponding to all valid addresses in the current network according to the address input to the current network and the number of bits of the subnet mask; Convert each integer in the integer range formed by the minimum value and the maximum value into the corresponding effective address, and add all the effective addresses to a preset address list; Excluding the connected addresses of the first aircraft in the connected state from the address list according to a preset configuration period, and performing a connection operation of the second aircraft in the non-connected state according to the remaining addresses; The step of excluding the connected address of the first aircraft in the connected state from the address list according to the preset configuration period, and performing the connection operation of the second aircraft in the non-connected state according to the remaining addresses, comprises: Excluding the connected addresses from the address list according to the configuration period to obtain the remaining addresses; Sending a preset detection data packet to the remaining addresses according to a preset detection period; When first reply data corresponding to the detection data packet is received, a heartbeat data packet of a preset communication protocol is sent to a source address of the first reply data via a user datagram protocol; Upon receiving second reply data corresponding to the communication protocol, determining that the source address is the second aircraft to be connected, and establishing a communication link with the second aircraft according to the communication protocol; When the connection operation with the second aircraft is successfully completed, using the address of the second aircraft as the connected address; When the next configuration cycle is reached, excluding the address of the second aircraft from the remaining addresses; When the first aircraft switches from a connected state to a non-connected state, sending a heartbeat packet to the connected address corresponding to the first aircraft according to a preset monitoring period; When the third reply data corresponding to the heartbeat packet is received within a preset monitoring period, the connection state with the first aircraft is restored; when the third reply data is not received within the monitoring period, the connected address corresponding to the first aircraft is used as the remaining address in the next configuration cycle; in, Setting the configuration period according to the current ratio of the number of the first aircraft to the number of the second aircraft and the current processing resource status of the ground control station; The time period between when the user starts searching and when the user closes searching is used as the monitoring period; The connected aircraft object remains in the address list.
2. The method for dynamic configuration of network address according to claim 1, characterized in that: The step of calculating the minimum and maximum values of integers corresponding to all valid addresses in the current network according to the address input to the current network and the number of bits of the subnet mask comprises: Receive the address and the number of bits of the subnet mask input by the user to the current network; The bytes and the number of bits corresponding to the address and the number of bits of the subnet mask are obtained by parsing.
3. The method for dynamic configuration of network address according to claim 2, characterized in that: The method of calculating the minimum and maximum values of integers corresponding to all valid addresses in the current network according to the address input to the current network and the number of bits of the subnet mask, further includes: Calculate a mask according to the byte and the number of bits; The minimum value and the maximum value are calculated based on the integer composed of the bytes and the mask.
4. The method for dynamic configuration of network address according to claim 3, characterized in that: The converting each integer in the integer range formed by the minimum value and the maximum value into the corresponding effective address, and adding all the effective addresses to a preset address list, comprises: Get all integers in the integer range formed by the minimum value and the maximum value; Convert all the integers into the corresponding effective addresses according to the bytes.
5. A network address dynamic configuration device, characterized in that: The device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the method for dynamic configuration of network addresses as claimed in any one of claims 1 to 4 when executed by the processor.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a network address dynamic configuration program, and when the network address dynamic configuration program is executed by a processor, the steps of the network address dynamic configuration method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Equipment adding method, device, equipment and medium in local area network
CN108848200A