Device discovery method, electronic device, and storage medium
By receiving and verifying the ARP declaration packet, extracting the information receiving port and sending device information, the problems discovered by equipment in complex network environments are solved, efficient discovery and connection of equipment are achieved, and port occupation and security problems are avoided.
Patent Information
- Application Number
- PCT/CN2024/126158
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-12-21
- Filing Date
- 2024-10-21
- Publication Date
- 2025-06-26
AI Technical Summary
In complex network environments, existing device discovery methods may cause data packets to not be forwarded or received, resulting in devices being unable to discover each other.
By receiving the ARP declaration packet sent by the security sending device, the verification information is extracted for verification processing. After successful, the information receiving port is extracted from the fill field, connected to the sender's protocol address and information receiving port, and the device information of the security receiving device is sent to the information receiving port of the security sending device to the information receiving port of the security sending device to the device discovery.
This method effectively solves the problem of device discovery, especially in complex network environments and MESH routing environments, which can efficiently discover related devices for communications, reduce the number of network broadcast packets, and avoid port occupation and security issues.
Smart Images

Figure CN2024126158_26062025_PF_FP_ABST
Abstract
Description
Device discovery method, electronic device, and storage medium Technical Field
[0001] The present application relates to the technical field of Internet of Things, and in particular to a device discovery method, electronic device, and storage medium. Background Art
[0002] With the development of the Internet of Things (IoT), the premise for devices to communicate and process data in a local area network is to be able to discover each other and achieve connection.
[0003] However, in a complex network environment, some discovery solutions may fail to forward or receive data packets, resulting in the inability to discover devices.
[0004] Summary of the Invention
[0005] This application at least provides a device discovery method, electronic device and storage medium to solve the above problems.
[0006] In a first aspect, the present application provides a device discovery method, which is applied to a security receiving device, comprising: receiving an ARP declaration packet sent by a security sending device, wherein the ARP declaration packet includes a sender protocol address field and a padding field for verification; extracting verification information from the padding field to perform verification processing on the ARP declaration packet to obtain a verification result; in response to the verification result being successful, extracting the information receiving port of the security sending device from the padding field; connecting to the sender protocol address in the sender protocol address field and the information receiving port, and sending the device information of the security receiving device to the information receiving port of the security sending device to complete device discovery.
[0007] In some embodiments, verification information is extracted from the padding field to perform verification processing on the ARP declaration packet to obtain a verification result, including: extracting a random number and a target verification value from the padding field, and extracting the sender protocol address from the sender protocol address field; using a preset algorithm to obtain a verification value based on the sender protocol address, the random number and a preset salt value; comparing the verification value with the target verification value to obtain the verification result, wherein in response to the verification value being the same as the target verification value, it indicates that the verification result is successful.
[0008] In some embodiments, a check value is obtained based on the sender protocol address, the random number, and a preset salt value using a preset algorithm, including: Check value = CRC32 (IP + Salt + Random value)
[0009] Among them, CRC32 represents the preset algorithm, IP represents the sender protocol address, Salt represents the preset salt value, and Random value represents the random number.
[0010] In some embodiments, receiving an ARP declaration packet sent by a security sending device includes: using a first preset function to receive the ARP declaration packet.
[0011] A second aspect of the present application provides a device discovery method, which is applied to a security sending device, including: generating and sending an ARP declaration packet to a security receiving device, wherein the ARP declaration packet includes a sender protocol address field and a padding field for verification, the security receiving device receives the ARP declaration packet and extracts verification information from the padding field to perform verification processing on the ARP declaration packet to obtain a verification result, and in response to the verification result being successful, extracting the information receiving port of the security sending device from the padding field; receiving the device information sent by the security receiving device through the information receiving port to achieve device discovery.
[0012] In some embodiments, generating the ARP declaration packet includes: using a preset algorithm to obtain a target verification value based on the sender protocol address, a random number, and a preset salt value in the sender protocol address field; filling the random number and the target verification value into a filling field for verification; and generating the ARP declaration packet based on the sender protocol address field and the filling field.
[0013] In some embodiments, a target check value is obtained based on the sender protocol address in the sender protocol address field, a random number, and a preset salt value using a preset algorithm, including: Target check value = CRC32 (IP + Salt + Random value)
[0014] Among them, CRC32 represents the preset algorithm, IP represents the sender protocol address, Salt represents the preset salt value, and Random value represents the random number.
[0015] In some embodiments, the device discovery method further includes: sending the ARP declaration packet using a second preset function.
[0016] In some embodiments, the device discovery method further includes: in response to not receiving the device information sent by the security receiving device within a preset time period, resending the ARP declaration packet repeatedly for a preset number of times according to a first preset time interval; and / or, in response to receiving the device information sent by the security receiving device within a preset time period, sending the ARP declaration packet according to a second preset time interval.
[0017] A third aspect of the present application provides an electronic device, comprising a memory and a processor coupled to each other, wherein the processor is configured to execute program instructions stored in the memory to implement the device discovery method in the first aspect and the device discovery method in the second aspect.
[0018] A fourth aspect of the present application provides a non-volatile computer-readable storage medium, which is used to store program instructions. When the program instructions are executed by a processor, they are used to implement the device discovery method in the first aspect and the device discovery method in the second aspect.
[0019] The above scheme receives the ARP declaration packet sent by the security sending device, where the ARP declaration packet includes a sender protocol address field and a padding field for verification, extracts the verification information from the padding field to verify the ARP declaration packet and obtain a verification result; in response to the verification result being successful, extracts the port for receiving the return information of the information receiving port of the security sending device from the padding field, connects to the sender protocol address and information receiving port in the sender protocol address field, and sends the device information of the security receiving device to the information receiving port of the security sending device to complete device discovery; in the scheme of this application, the verification information is stored in the padding field by the security sending device, which increases the scalability of the application, and the security sending device customizes the information receiving port, which can also avoid the port occupation and easy monitoring caused by fixed ports. Security issues.
[0020] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The drawings herein are incorporated into and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and, together with the specification, are used to illustrate the technical solutions of the present application.
[0022] FIG1 is a flow chart of a device discovery method of the present application;
[0023] FIG2 is a schematic diagram of the structure of an Ethernet frame of the present application;
[0024] FIG3 is another flow chart of the device discovery method of the present application;
[0025] FIG4 is a schematic structural diagram of an electronic device according to an embodiment of the present application;
[0026] FIG5 is a schematic structural diagram of an embodiment of a non-volatile computer-readable storage medium of the present application. DETAILED DESCRIPTION
[0027] The present application will be further described in detail below in conjunction with the accompanying drawings and examples. It is particularly noted that the following examples are only intended to illustrate the present application and are not intended to limit the scope of the present application. Similarly, the following examples are only some examples of the present application and not all examples. All other examples obtained by those of ordinary skill in the art without creative work are intended to fall within the scope of protection of this application.
[0028] References to "embodiments" in this application mean that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0029] The term "and / or" herein is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may indicate three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " herein generally indicates that the objects associated with each other are in an "or" relationship. In addition, "many" herein means two or more than two. In addition, the term "at least one" herein means any combination of at least two of any one or more of a plurality of, for example, including at least one of A, B, and C, and may indicate any one or more elements selected from the set consisting of A, B, and C. In addition, the terms "first", "second", and "third" in this application are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated.
[0030] As mentioned above, with the development of the Internet of Things (IoT), communication and data processing between devices on a local area network (LAN) require mutual discovery and connectivity. However, in complex network environments, some discovery solutions may fail to forward or receive data packets, resulting in device discovery failure.
[0031] The current discovery methods include broadcast protocol, multicast protocol, and Apple's MDNS protocol. Among them, broadcast refers to sending broadcast messages to all possible receivers in the network. In order to avoid network storms, the router will not forward the broadcast to the sub-router. This discovery method cannot discover devices connected to the sub-router in a mesh network. Multicast is when a device joins a multicast address, and all devices in the multicast group can receive device information messages. Routers from different manufacturers have different settings. Some do not forward multicast packets, and some routers do not forward them after opening the firewall, resulting in devices being unable to discover each other. Apple's MDNS discovery protocol uses DNS+multicast technology. Most routers support the MDNS protocol, and its discovery efficiency is better than multicast. However, if the same IOT device supports the Homekit protocol, and an additional set of MDNS is used to discover private devices, Apple Homekit authentication will fail.
[0032] To this end, the present application provides a device discovery method, an electronic device, and a storage medium.
[0033] The Address Resolution Protocol (ARP) is a protocol used to implement the mapping from Internet Protocol (IP) addresses to Media Access Control (MAC) addresses, that is, to query the MAC address corresponding to the target IP address.
[0034] The main way the link layer identifies ARP frames is through the Ethernet type field of the frame. In the header of the Ethernet frame, there is a 16-bit field called "Type" or "Ethertype", which is used to indicate the protocol type of the payload (that is, the data part of the frame).
[0035] For ARP frames, the type field has a value of 0x0806. When the link layer receives a frame with the type field set to 0x0806, it identifies it as an ARP frame. The link layer passes the frame to the network layer's ARP handler, which further parses the frame's contents, including the source IP address, destination IP address, and source MAC address.
[0036] In the header of an Ethernet frame, the value of the type field for an IP datagram is 0x0800. Therefore, the link layer identifies an IP datagram by checking this type field.
[0037] Please refer to Figure 1, which is a flowchart of the device discovery method of the present application. It should be noted that the method of the present application is not limited to the flowchart sequence shown in Figure 1 if substantially the same results are achieved. The present method can be applied to electronic devices with computing and other functions, such as smart security devices, which include security receiving devices and security sending devices, wherein the security receiving devices are cameras or doorbells, and the security sending devices are base stations. It is understandable that in other embodiments, the security receiving devices and security sending devices can be interchangeable, that is, the security receiving devices are base stations, and the security sending devices are cameras or doorbells, etc.
[0038] Specifically, in some possible implementations, the device discovery method of the embodiment of the present application can be implemented by a processor in an electronic device calling computer program instructions stored in a memory. As shown in Figure 1, the device discovery method, applied to a security receiving device, includes the following steps:
[0039] S11. Receive an ARP declaration packet sent by a security sending device, wherein the ARP declaration packet includes a sender protocol address field and a padding field for verification.
[0040] An ARP announcement packet in the standard ARP protocol is an ARP packet used to announce the local IP address and MAC address to the network. A node on the network sends an ARP announcement packet to share its IP address and MAC address with other nodes, causing all hosts on the LAN (VLAN) to update their ARP cache and map the IP address to the MAC address of the security device.
[0041] In one application scenario, device discovery includes a secure sending device for sending data and a secure receiving device for receiving data.
[0042] The security receiving device receives the ARP announcement packet sent by the security sending device. The ARP announcement packet includes a sender protocol address field and a padding field for verification. It can be understood that the sender protocol address field is the protocol address field of the security sending device. The security sending device adds the sender protocol address field and the padding field for verification to the ARP announcement packet and sends it to the security receiving device. Thus, the security receiving device receives the ARP announcement packet sent by the security sending device.
[0043] In one embodiment, Ethernet specifies that the minimum length of each frame is 64 bytes, and the total length of the ARP announcement packet is usually 46-60 bytes to ensure that the minimum length of the entire Ethernet frame (including the Ethernet header and the frame check sequence (FCS) checksum) is 64 bytes.
[0044] Figure 2 is a schematic diagram of the structure of the Ethernet frame of the present application. As shown in Figure 2, the main fields of the ARP declaration packet occupy a total of 42 bytes, and the FCS occupies 4 bytes. After deducting the 42 bytes of the main fields and the 4 bytes of FCS, the length of the padding field can be set to 18 bytes. The 42 bytes occupied by the main fields include the MAC header (a total of 14 bytes, of which DST occupies 6 bytes, SRC occupies 6 bytes, and length / type occupies 2 bytes), a fixed-size field (a total of 8 bytes, of which the hardware type occupies 2 bytes, the protocol type occupies 2 bytes, the hardware address length occupies 1 byte, the protocol address length occupies 1 byte, and the operation code occupies 1 byte), and a variable-size field (a total of 20 bytes, of which the sender hardware address occupies 6 bytes, the sender protocol address occupies 4 bytes, the target hardware address occupies 6 bytes, and the target protocol address occupies 4 bytes). That is, the main fields include Hardware Type, Protocol Type, Hardware Address Length, Protocol Address Length, Opcode, Sender Hardware Address, Sender Protocol Address, Target Hardware Address, and Target Protocol Address. Specifically, the Hardware Type field occupies 2 bytes and indicates the type of hardware used, such as Ethernet or Wireless LAN. For Ethernet, the value of this field is 1. The Protocol Type field occupies 2 bytes and indicates the type of protocol used, such as IPv4 or IPv6. For IPv4, the value of this field is 0x0800. The Hardware Address Length field occupies 1 byte and indicates the length of the hardware address. For Ethernet MAC addresses, the value is 6. The Protocol Address Length field occupies 1 byte and indicates the length of the protocol address. For IPv4 addresses, the value is 4. The Opcode field occupies 2 bytes and indicates the type of ARP announcement packet, such as request (1) or response (2). The sender hardware address is 6 bytes long and contains the hardware address of the device sending the ARP announcement packet. The sender protocol address is 4 bytes long and contains the protocol address of the device sending the ARP announcement packet. The target hardware address is 6 bytes long and contains the hardware address of the target device. In an ARP request, this field is usually set to 0 because the sender does not know the target's hardware address. The target protocol address is 4 bytes long and contains the protocol address of the target device.
[0045] S12. Extract verification information from the padding field to perform verification processing on the ARP announcement packet to obtain a verification result.
[0046] After receiving the ARP declaration packet, the security receiving device extracts the verification information from the padding field of the ARP declaration packet, verifies the ARP declaration packet according to the verification information, and obtains the verification result.
[0047] S13. In response to a successful verification result, extract the information receiving port of the security sending device from the filled field.
[0048] It is understood that the verification results include success and failure. In response to a successful verification result, the information receiving port of the security sending device is extracted from the filled field. In response to a failed verification result, the corresponding ARP announcement packet is discarded and not processed.
[0049] S14. Connect to the sender protocol address and the information receiving port in the sender protocol address field, and send the device information of the security receiving device to the information receiving port of the security sending device to complete device discovery.
[0050] The security receiving device connects to the sender protocol address and information receiving port in the sender protocol address field, for example, using TCP to connect to the sender protocol address and information receiving port, and sends the device information of the security receiving device to the information receiving port of the security sending device to complete device discovery. The device information of the security receiving device may include the IP address of the security receiving device, desensitized device binding information, account association information, and other achievable information, without specific limitation.
[0051] The above scheme receives the ARP declaration packet sent by the security sending device, where the ARP declaration packet includes a sender protocol address field and a padding field for verification, extracts the verification information from the padding field to verify the ARP declaration packet and obtain a verification result; in response to the verification result being successful, extracts the port for receiving the return information of the information receiving port of the security sending device from the padding field, connects to the sender protocol address and information receiving port in the sender protocol address field, and sends the device information of the security receiving device to the information receiving port of the security sending device to complete device discovery; in the scheme of this application, the verification information is stored in the padding field by the security sending device, which increases the scalability of the application, and the security sending device customizes the information receiving port, which can also avoid the port occupation and easy monitoring caused by fixed ports. Security issues.
[0052] In one embodiment of the present application, verification information is extracted from the padding field to perform verification processing on the ARP declaration packet to obtain a verification result, including: extracting a random number and a target verification value from the padding field, and extracting the sender protocol address from the sender protocol address field; using a preset algorithm, based on the sender protocol address, the random number and the preset salt value, to obtain a verification value; comparing the verification value with the target verification value to obtain a verification result, wherein a response that the verification value is the same as the target verification value indicates that the verification result is successful.
[0053] The security receiving device extracts the random number and target checksum from the padding field and the sender's protocol address from the sender's protocol address field. The random number is generated by the security sending device and filled into the padding field. For example, the Linux system's " / dev / random" is a true random number generator that can be used to generate int (4-byte) random numbers. " / dev / random" is based on the system's entropy pool and is well-suited for applications requiring high security, such as generating SSL keys.
[0054] A checksum is generated using a preset algorithm based on the sender's protocol address, a random number, and a preset salt value. In encryption algorithms, the salt value is an additional parameter used to increase encryption complexity and prevent attackers from using pre-calculated methods such as rainbow tables to crack the password. The resulting checksum is compared with the target checksum to obtain a verification result. If the checksum is the same as the target checksum, the verification result is successful; if the checksum is different from the target checksum, the verification result is failed.
[0055] In one embodiment of the present application, a check value is obtained using a preset algorithm based on the sender's protocol address, a random number, and a preset salt value, including: Check value = CRC32 (IP + Salt + Random value)
[0056] Among them, CRC32 (Cyclic Redundancy Check) represents the preset algorithm, IP represents the sender protocol address, Salt represents the preset salt value, and Random value represents the random number.
[0057] As can be understood, the CRC32 algorithm is used to calculate the CRC32 value, i.e., the check value, based on the sender's protocol address, the preset salt value, and the random number. The check value is then compared with the target check value to obtain a verification result.
[0058] The random number is a non-fixed value, which is used to increase the randomness and uniqueness of the generated checksum and prevent replay attacks.
[0059] In an embodiment of the present application, receiving an ARP declaration packet sent by a security sending device includes: receiving the ARP declaration packet using a first preset function.
[0060] The pseudo code for sending and receiving data in an embodiment of the present application is as follows:
[0061] Among them, a raw socket (RAW Socket) is constructed, and the security receiving device uses a first preset function to receive the ARP declaration packet sent by the security sending device. Among them, the first preset function can be a recvfrom function, or other achievable functions, without specific limitation.
[0062] Please refer to Figure 3, which is another flowchart of the device discovery method of the present application. It should be noted that the method of the present application is not limited to the flowchart sequence shown in Figure 3 if substantially the same results are achieved. The present method can be applied to electronic devices with computing and other functions, for example, the electronic device is an intelligent security device, and the intelligent security device includes a security receiving device and a security sending device, wherein the security receiving device is a camera or a doorbell, and the security sending device is a base station. It is understandable that in other embodiments, the security receiving device and the security sending device can be interchangeable, that is, the security receiving device is a base station, and the security sending device is a camera or a doorbell, etc.
[0063] Specifically, in some possible implementations, the device discovery method of the embodiment of the present application can be implemented by a processor in an electronic device calling computer program instructions stored in a memory. As shown in Figure 3, the device discovery method, applied to a security sending device, includes the following steps:
[0064] S21. Generate and send an ARP declaration packet to the security receiving device, where the ARP declaration packet includes a sender protocol address field and a padding field for verification. The security receiving device receives the ARP declaration packet and extracts verification information from the padding field to verify the ARP declaration packet and obtain a verification result. In response to a successful verification result, the security receiving device extracts the information receiving port of the security sending device from the padding field.
[0065] An ARP announcement packet in the standard ARP protocol is an ARP packet used to announce the local IP address and MAC address to the network. A node on the network sends an ARP announcement packet to share its IP address and MAC address with other nodes, causing all hosts on the LAN (VLAN) to update their ARP cache and map the IP address to the MAC address of the security device.
[0066] In one application scenario, device discovery includes a secure sending device for sending data and a secure receiving device for receiving data.
[0067] The security sending device sends an ARP announcement packet to the security receiving device. The ARP announcement packet includes a sender protocol address field and a padding field for verification. It should be understood that the sender protocol address field is the protocol address field of the security sending device. The security sending device fills the sender protocol address field and the padding field into the ARP announcement packet and sends it to the security receiving device. The security receiving device then receives the ARP announcement packet from the security sending device. After receiving the ARP announcement packet, the security receiving device extracts verification information from the padding field of the ARP announcement packet and verifies the ARP announcement packet based on the verification information to obtain a verification result. The verification result can be either success or failure. In response to a success verification result, the security receiving device extracts the information receiving port of the security sending device from the padding field. The security receiving device connects to the sender protocol address and information receiving port in the sender protocol address field, for example, using TCP to connect to the sender protocol address and information receiving port.
[0068] S22. Receive device information sent by the security receiving device through the information receiving port to achieve device discovery.
[0069] The security receiving device sends the device information of the security receiving device to the information receiving port of the security sending device, where the device information of the security receiving device may include the IP address of the security receiving device, desensitized device binding information, account association information, and other achievable information without specific limitation.
[0070] The security receiving device receives the device information sent by the security receiving device through the information receiving port to realize device discovery.
[0071] In one embodiment of the present application, an ARP declaration packet is generated, including: using a preset algorithm to obtain a target verification value based on the sender protocol address, a random number, and a preset salt value in the sender protocol address field; filling the random number and the target verification value into a padding field for verification; and generating an ARP declaration packet based on the sender protocol address field and the padding field.
[0072] A target checksum is obtained using a preset algorithm based on the sender protocol address in the sender protocol address field, a random number, and a preset salt value. For example, the Linux system's " / dev / random" is used as a true random number generator to generate int (4-byte) random numbers. " / dev / random" is based on the system's entropy pool and is well suited for applications requiring high security, such as generating SSL keys. A GUID generation algorithm can be used to generate a 32-byte fixed salt value, or any other feasible algorithm, without specific limitation, to obtain the preset salt value, ensuring its uniqueness, randomness, and sufficient length to increase the difficulty of cracking.
[0073] The security sending device fills the random number and the target check value into the padding field for verification, thereby generating an ARP announcement packet based on the sender protocol address field and the padding field.
[0074] In one embodiment, the filling of the ARP announcement packet of the present application is as follows:
[0075] The ARP declaration packet includes the hardware type (Hardware Type), protocol type (Protocol Type), operation code (Opcode), sender hardware address (Sender Hardware Address), sender protocol address (Sender Protocol Address), target hardware address (Target Hardware Address), and target protocol address (Target Protocol Address). Among them, the value of Hardware Type is 1, indicating that the hardware type is Ethernet; the value of Protocol Type is 0x800, indicating that the protocol type is IPV4; the value of Opcode is 1, indicating that the opcode is request; the value of Sender Hardware Address is xx.xx.xx.xx.xx.xx, indicating that the sender hardware address is the MAC address of the security sending device; the value of Sender Protocol Address is xxx.xxx.xxx.xxx, indicating that the sender protocol address is the IP address of the security sending device; the value of Target Hardware Address is 00.00.00.00.00.00, indicating that the target hardware address is the MAC address of all devices in the broadcast network, without a specific device; the value of Target Protocol Address is xxx.xxx.xxx.xxx, indicating that the target protocol address is no specific device, enter the IP address of the security sending device, representing broadcast ARP.
[0076] In one embodiment of the present application, a target check value is obtained based on the sender protocol address, random number, and preset salt value in the sender protocol address field using a preset algorithm, including: Target check value = CRC32 (IP + Salt + Random value)
[0077] Among them, CRC32 represents the preset algorithm, IP represents the sender protocol address, Salt represents the preset salt value, and Random value represents the random number.
[0078] As can be understood, the CRC32 algorithm is used to calculate the target checksum based on the sender's protocol address, the preset salt value, and the random number. Furthermore, the security receiving device, using the same preset algorithm, based on the same sender's protocol address, the random number, and the preset salt value, will obtain a checksum that is the same as the target checksum.
[0079] In an embodiment of the present application, the device discovery method further includes: sending an ARP declaration packet using a second preset function.
[0080] The pseudo code for sending data and receiving data in another embodiment of the present application is as follows:
[0081] Among them, a raw socket is constructed, and then an Ethernet header is constructed. The security sending device uses a second preset function to send the filled ARP declaration packet, wherein the second preset function can be a sendto function, or other achievable functions, without specific limitation.
[0082] In one embodiment of the present application, the device discovery method further includes: in response to not receiving device information sent by the security receiving device within a preset time period, resending the ARP declaration packet repeatedly a preset number of times according to a first preset time interval; and / or, in response to receiving device information sent by the security receiving device within a preset time period, sending the ARP declaration packet according to a second preset time interval.
[0083] After the security sending device sends the ARP declaration packet to the security receiving device, the security receiving device will verify the received ARP declaration packet. After the verification is successful, the security receiving device will send the device information of the security receiving device to the security sending device.
[0084] In response to not receiving the device information sent by the security receiving device within the preset time period, the security sending device resends the ARP declaration packet a preset number of times at a first preset time interval, for example, sending an ARP declaration packet once every 1 second, and repeating it three times, to avoid device failure due to packet loss due to network factors.
[0085] In response to receiving device information sent by the security receiving device within a preset time period, the security sending device sends an ARP declaration packet at a second preset time interval, such as sending an ARP declaration packet at a 10-second interval, to promptly detect whether a new device has joined the network or an existing device is offline.
[0086] The solution in this application can efficiently discover the relevant devices that need to communicate, effectively reduce the number of network broadcast packets, and can discover devices from each other and realize device interconnection in three-address and four-address configuration schemes in various complex network environments and MESH routing environments.
[0087] Those skilled in the art will understand that in the above-mentioned method of the specific implementation method, the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.
[0088] Please refer to Figure 4, which is a schematic diagram of the structure of an embodiment of an electronic device of the present application. Electronic device 400 includes a memory 401 and a processor 402 coupled to each other. Processor 402 is configured to execute program instructions stored in memory 401 to implement the steps of the device discovery method embodiment described above. In a specific implementation scenario, electronic device 400 may include, but is not limited to, a microcomputer and a server, which are not limited herein.
[0089] Specifically, the processor 402 is used to control itself and the memory 401 to implement the steps in the above-mentioned device discovery method embodiment. The processor 402 can also be called a CPU (Central Processing Unit), and the processor 402 may be an integrated circuit chip with signal processing capabilities. The processor 402 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 402 can be implemented by an integrated circuit chip.
[0090] 5 is a schematic diagram of a non-volatile computer-readable storage medium according to an embodiment of the present invention. The computer-readable storage medium 500 is used to store program instructions 501. When executed by the processor 402, the program instructions 501 are used to implement the steps of the device discovery method embodiment described above.
[0091] The above description of the various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced with each other and will not be repeated herein for the sake of brevity.
[0092] In the several embodiments provided in this application, it should be understood that the disclosed methods and related devices can be implemented in other ways. For example, the above-described related device implementation methods are merely illustrative. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division methods, such as units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication disconnection shown or discussed can be through some interfaces, indirect coupling or communication disconnection of devices or units, which can be electrical, mechanical or other forms.
[0093] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0094] If the integrated unit 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 technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of each embodiment method of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
Claims
1. A device discovery method, applied to a security receiving device, wherein: include: Receive an ARP declaration packet sent by a security sending device, wherein the ARP declaration packet includes a sender protocol address field and a padding field for verification; Extracting verification information from the padding field to perform verification processing on the ARP declaration packet to obtain a verification result; In response to the verification result being successful, extracting the information receiving port of the security sending device from the fill field; Connect to the sender protocol address in the sender protocol address field and the information receiving port, and send the device information of the security receiving device to the information receiving port of the security sending device to complete device discovery.
2. The method according to claim 1, wherein: Extracting verification information from the padding field to perform verification processing on the ARP declaration packet to obtain a verification result includes: Extracting a random number and a target check value from the padding field, and extracting the sender protocol address from the sender protocol address field; Using a preset algorithm, a check value is obtained based on the sender protocol address, the random number and a preset salt value; The verification value is compared with the target verification value to obtain the verification result, wherein in response to the verification value being the same as the target verification value, it indicates that the verification result is successful.
3. The method according to claim 2, wherein: Using a preset algorithm, based on the sender protocol address, the random number and the preset salt value, a check value is obtained, including: Check value = CRC32 (IP + Salt + Random value) Among them, CRC32 represents the preset algorithm, IP represents the sender protocol address, Salt represents the preset salt value, and Random value represents the random number.
4. The method according to claim 1, wherein: Receive the ARP declaration packet sent by the security sending device, including: The ARP announcement packet is received using a first preset function.
5. A device discovery method, wherein: Applied to security transmission equipment, including: Generate and send an ARP declaration packet to a security receiving device, wherein the ARP declaration packet includes a sender protocol address field and a padding field for verification, the security receiving device receives the ARP declaration packet and extracts verification information from the padding field to perform verification processing on the ARP declaration packet to obtain a verification result, and in response to the verification result being successful, extract the information receiving port of the security sending device from the padding field; The device information sent by the security receiving device is received through the information receiving port to realize device discovery.
6. The method according to claim 5, wherein: Generate the ARP declaration packet, including: Using a preset algorithm, based on the sender protocol address in the sender protocol address field, the random number, and the preset salt value, a target checksum is obtained; Fill the random number and the target check value into a fill field for verification; The ARP announcement packet is generated based on the sender protocol address field and the padding field.
7. The method according to claim 6, wherein: Using the preset algorithm, based on the sender protocol address, random number and preset salt value in the sender protocol address field, the target check value is obtained, including: Target check value = CRC32 (IP + Salt + Random value) Among them, CRC32 represents the preset algorithm, IP represents the sender protocol address, Salt represents the preset salt value, and Random value represents the random number.
8. The method according to claim 5, wherein: The device discovery method further includes: The ARP declaration packet is sent using a second preset function.
9. The method according to claim 5, wherein: The device discovery method further comprises: In response to not receiving the device information sent by the security receiving device within a preset time period, resending the ARP declaration packet repeatedly for a preset number of times at a first preset time interval.
10. The method according to claim 5, wherein: The device discovery method further comprises: In response to receiving the device information sent by the security receiving device within a preset time period, sending an ARP declaration packet at a second preset time interval.
11. The method according to claim 5, wherein: The device discovery method further comprises: In response to not receiving the device information sent by the security receiving device within a preset time period, resending the ARP declaration packet repeatedly for a preset number of times at a first preset time interval; and In response to receiving the device information sent by the security receiving device within a preset time period, sending an ARP declaration packet at a second preset time interval.
12. A security receiving device, wherein: The invention comprises a memory and a processor coupled to each other, wherein the processor is used to execute program instructions stored in the memory to implement: Receive an ARP declaration packet sent by a security sending device, wherein the ARP declaration packet includes a sender protocol address field and a padding field for verification; Extract verification information from the padding field to verify the ARP declaration packet. Verification processing to obtain verification results; In response to the verification result being successful, extracting the information receiving port of the security sending device from the fill field; Connect to the sender protocol address in the sender protocol address field and the information receiving port, and send the device information of the security receiving device to the information receiving port of the security sending device to complete device discovery.
13. The device according to claim 12, wherein: Extracting verification information from the padding field to perform verification processing on the ARP declaration packet to obtain a verification result includes: Extracting a random number and a target check value from the padding field, and extracting the sender protocol address from the sender protocol address field; Using a preset algorithm, a check value is obtained based on the sender protocol address, the random number and a preset salt value; The verification value is compared with the target verification value to obtain the verification result, wherein in response to the verification value being the same as the target verification value, it indicates that the verification result is successful.
14. The device according to claim 13, wherein: Using a preset algorithm, based on the sender protocol address, the random number and the preset salt value, a check value is obtained, including: Check value = CRC32 (IP + Salt + Random value) Among them, CRC32 represents the preset algorithm, IP represents the sender protocol address, Salt represents the preset salt value, and Random value represents the random number.
15. The apparatus according to claim 12, wherein: Receive the ARP declaration packet sent by the security sending device, including: The ARP announcement packet is received using a first preset function.
16. A security transmission device, wherein: The invention comprises a memory and a processor coupled to each other, wherein the processor is used to execute program instructions stored in the memory to implement: Generate and send an ARP declaration packet to a security receiving device, wherein the ARP declaration packet includes a sender protocol address field and a padding field for verification, the security receiving device receives the ARP declaration packet and extracts verification information from the padding field to perform verification processing on the ARP declaration packet to obtain a verification result, and in response to the verification result being successful, extract the information receiving port of the security sending device from the padding field; The device information sent by the security receiving device is received through the information receiving port to realize device discovery.
17. The device according to claim 16, wherein: Generate the ARP declaration packet, including: Using a preset algorithm, based on the sender protocol address in the sender protocol address field, the random number, and the preset salt value, a target checksum is obtained; Fill the random number and the target check value into a fill field for verification; The ARP announcement packet is generated based on the sender protocol address field and the padding field.
18. The apparatus according to claim 17, wherein: Using the preset algorithm, based on the sender protocol address, random number and preset salt value in the sender protocol address field, the target check value is obtained, including: Target check value = CRC32 (IP + Salt + Random value) Among them, CRC32 represents the preset algorithm, IP represents the sender protocol address, Salt represents the preset salt value, and Random value represents the random number.
19. The apparatus according to claim 16, wherein: The device discovery method further includes: The ARP declaration packet is sent using a second preset function.
20. A non-volatile computer-readable storage medium, wherein: The computer-readable storage medium is used to store program instructions, and when the program instructions are executed by a processor, they are used to implement the device discovery method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Method for quickly searching equipment information within local area network
CN103297559A
System and method for automatically finding and adding devices
CN103873301A
Method for safely finding intelligent device in local area network
CN106102051A
Method and system for using SIM card as TCP client to communicate with terminal application
CN117041918A
System and method to discover and configure remotely located network devices
US20040095897A1