Device discovery method, electronic device and storage medium
By receiving and verifying the verification information in the ARP declaration packet, extracting and using the information receiving port to complete the device discovery, the problem of difficult device discovery in complex network environments is solved, and efficient and secure device discovery is achieved.
Patent Information
- Application Number
- CN202311781886.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-21
- Publication Date
- 2025-06-24
AI Technical Summary
In complex network environments, existing device discovery schemes 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 process is performed using the verification information in the fill field. After successful, the information receiving port is extracted, connected to the sender's protocol address and information receiving port, and the device information is sent to complete the device discovery.
It realizes efficient discovery of equipment in complex network environments, avoids occupation and security issues caused by fixed ports, and enhances the scalability and security of applications.
Smart Images

Figure CN120201003A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of the Internet of Things, and particularly to a device discovery method, an electronic device, and a storage medium. Background Art
[0002] With the development of the Internet of Things (IoT), in a local area network, for devices to communicate and process data with each other, they must be able to discover each other and establish a connection.
[0003] However, in a complex network environment of users, some discovery solutions may have problems such as non-forwarding or non-reception of data packets, resulting in the inability to discover devices. Summary of the Invention
[0004] This application provides at least one device discovery method, an electronic device, and a storage medium to solve the above problems.
[0005] In a first aspect of this application, a device discovery method is provided, which is applied to a security receiving device and includes: receiving an ARP declaration packet sent by a security sending device, where 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.
[0006] In some embodiments, 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 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 a preset salt value, obtaining a verification value; comparing the verification value with the target verification value to obtain the verification result, where in response to the verification value being the same as the target verification value, it indicates that the verification result is successful.
[0007] In some embodiments, using a preset algorithm, based on the sender protocol address, the random number, and a preset salt value, obtaining a verification value includes:
[0008] Verification value = CRC32(IP + Salt + Random value)
[0009] Wherein, 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: receiving the ARP declaration packet using a first preset function.
[0011] A second aspect of the present application provides a device discovery method applied to a security sending device, including: generating and sending an ARP declaration packet to a 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, extracts verification information from the padding field to perform a verification process on the ARP declaration packet, obtains a verification result, and in response to the verification result being successful, extracts the information receiving port of the security sending device from the padding field; through the information receiving port, receiving the device information sent by the security receiving device 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 in the sender protocol address field, a random number, and a preset salt value; filling the random number and the target verification value into the padding field for verification; and generating the ARP declaration packet based on the sender protocol address field and the padding field.
[0013] In some embodiments, using a preset algorithm to obtain a target verification value based on the sender protocol address in the sender protocol address field, a random number, and a preset salt value includes:
[0014] Target verification value = CRC32(IP + Salt + Random value)
[0015] Wherein, CRC32 represents the preset algorithm, IP represents the sender protocol address, Salt represents the preset salt value, and Random value represents the random number.
[0016] In some embodiments, the device discovery method further includes: sending the ARP declaration packet using a second preset function.
[0017] 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 a preset number of times at 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 an ARP declaration packet at a second preset time interval.
[0018] The third aspect of the present application provides an electronic device, including a memory and a processor coupled to each other, and 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 above.
[0019] The fourth aspect of the present application provides a non-volatile computer-readable storage medium, which 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 in the first aspect and the device discovery method in the second aspect above.
[0020] In the above solution, by receiving an ARP declaration packet sent by a security sending device, where 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 and the information receiving port in the sender protocol address field, and sending the device information of the security receiving device to the information receiving port of the security sending device to complete device discovery; in the solution of the present application, the verification information is stored in the padding field by the security sending device, which increases the extensibility of the application. The security sending device customizes the information receiving port, which can also avoid the port occupation caused by fixed ports and the security problems caused by being easily monitored.
[0021] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and do not limit the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The drawings here are incorporated into the specification and constitute a part of this specification. These drawings show embodiments consistent with the present application and are used together with the specification to explain the technical solutions of the present application.
[0023] Figure 1 is a flowchart of the device discovery method of the present application;
[0024] Figure 2 is a schematic structural diagram of an Ethernet frame of the present application;
[0025] Figure 3 is another flowchart of the device discovery method of the present application;
[0026] Figure 4 is a schematic structural diagram of an embodiment of the electronic device of the present application;
[0027] Figure 5It is a schematic structural diagram of an embodiment of a non - volatile computer - readable storage medium of the present application. Detailed implementation manners
[0028] The present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be specifically noted that the following embodiments are only used to illustrate the present application, but do not limit the scope of the present application. Similarly, the following embodiments are only partial embodiments of the present application rather than all embodiments. All other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of the present application.
[0029] The mention of "embodiment" in the present application means that the specific features, structures, or characteristics described in connection with the embodiment may be included in at least one embodiment of the present application. The phrase appears at various positions in the specification and does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.
[0030] The term "and / or" in this article is merely a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in this article generally represents an "or" relationship between the associated objects before and after. In addition, "multiple" in this article means two or more than two. In addition, the term "at least one" in this article represents any one of multiple or any combination of at least two of multiple. For example, including at least one of A, B, and C can represent including any one or more elements selected from the set composed of A, B, and C. In addition, the terms "first", "second", and "third" in the present application are only for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the quantity of the indicated technical features.
[0031] As described above, with the development of the Internet of Things (IoT), in a local area network, the premise for devices to communicate and process data with each other is to be able to discover and connect to each other. However, in a complex network environment of users, some discovery solutions may result in non - forwarding or non - reception of data packets, leading to the inability to discover devices.
[0032] The current discovery methods include broadcast protocols, multicast protocols, and Apple's MDNS protocol. Among them, broadcasting means sending broadcast messages to all possible receivers in the network. To avoid network storms, routers do not forward broadcasts to sub - routers. In a mesh network, this discovery method cannot discover devices connected to sub - routers. Multicasting is that a device joins a multicast address, and devices within the multicast group can receive device information messages. Different manufacturers' routers have different settings. Some do not forward multicast packets, and some do not forward them either after the firewall is turned on, 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 the discovery efficiency is better than that of multicasting. However, if the same IoT device supports the Homekit protocol and an additional MDNS is used to discover private devices, it will cause the Apple Homekit authentication to fail.
[0033] Therefore, this application provides a device discovery method, an electronic device, and a storage medium.
[0034] The Address Resolution Protocol (ARP) is used to map from an Internet Protocol (IP) address to a Media Access Control (MAC) address, that is, a protocol for querying the MAC address corresponding to a target IP address.
[0035] The main way for the link layer to identify an ARP frame is through the Ethernet type field of the frame. In the header of an Ethernet frame, there is a 16 - bit field called "type" or "Ethertype", which is used to indicate the protocol type of the payload (i.e., the data part of the frame).
[0036] For an ARP frame, the value of this type field is 0x0806. When the link layer receives a frame and the type field is 0x0806, it will know that this is an ARP frame. The link layer will pass the ARP frame to the ARP handler in the network layer, and this handler will further parse the content of the ARP frame, including information such as the source IP address, target IP address, and source MAC address.
[0037] 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.
[0038] Please refer to Figure 1 , Figure 1 which is a schematic flowchart of the device discovery method of this application. It should be noted that if there are substantially the same results, the method of this application does not depend on Figure 1The process sequence shown is limited. This method can be applied to electronic devices with functions such as computing. For example, the electronic device is an intelligent security device, which includes a security receiving device and a security transmitting device. The security receiving device is a camera or a doorbell, and the security transmitting device is a base station. It can be understood that in other embodiments, the security receiving device and the security transmitting device can be interchanged, that is, the security receiving device is the base station, and the security transmitting device is a camera, a doorbell, etc.
[0039] Specifically, in some possible implementation manners, the device discovery method of the embodiments of the present application can be implemented by a processor in an electronic device calling computer program instructions stored in a memory. As Figure 1 shown, the device discovery method, applied to a security receiving device, includes the following steps:
[0040] S11. Receive an ARP announcement packet sent by a security transmitting device, where the ARP announcement packet includes a sender protocol address field and a padding field for verification.
[0041] The ARP announcement in the standard ARP protocol is an ARP data packet used to announce the local IP address and Mac address to the network. Nodes in the network send ARP announcement packets to share their IP addresses and MAC addresses with other nodes, so that all hosts in the LAN (VLAN) will update their ARP caches, mapping the IP address to the MAC address of the security transmitting device.
[0042] In an application scenario, device discovery includes a security transmitting device for sending data and a security receiving device for receiving data.
[0043] The security receiving device receives the ARP announcement packet sent by the security transmitting 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 transmitting device. The security transmitting device fills the sender protocol address field and the padding field for verification into 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 transmitting device.
[0044] In an embodiment, Ethernet stipulates that the minimum length of each frame is 64 bytes. 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.
[0045] Figure 2 is a schematic diagram of the structure of the Ethernet frame of the present application. As Figure 2As shown, the main fields of the ARP announcement packet altogether occupy 42 bytes, and the FCS occupies 4 bytes. After deducting the 42 bytes of the main fields and the 4 bytes of the FCS, the length of the padding field can be set to 18 bytes. Among the 42 bytes altogether occupied by the main fields, it includes the MAC header (altogether 14 bytes, where DST occupies 6 bytes, SRC occupies 6 bytes, length / type occupies 2 bytes), fixed-size fields (altogether 8 bytes, where hardware type occupies 2 bytes, protocol type occupies 2 bytes, hardware address length occupies 1 byte, protocol address length occupies 1 byte, opcode occupies 1 byte), and variable-size fields (altogether 20 bytes, where sender hardware address occupies 6 bytes, sender protocol address occupies 4 bytes, target hardware address occupies 6 bytes, target protocol address occupies 4 bytes). That is to say, 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 occupies 2 bytes, and this field indicates the hardware type used, such as Ethernet or wireless local area network. For Ethernet, the value of this field is 1. The protocol type occupies 2 bytes, and this field indicates the protocol type used, such as IPv4 or IPv6. For IPv4, the value of this field is 0x0800. The hardware address length occupies 1 byte, and this field indicates the length of the hardware address. For the Ethernet MAC address, this value is 6. The protocol address length occupies 1 byte, and this field indicates the length of the protocol address. For the IPv4 address, the value of this field is 4. The opcode occupies 2 bytes, and this field indicates the type of the ARP announcement packet, such as request (1) or response (2). The sender hardware address occupies 6 bytes, and this field contains the hardware address of the device that sends the ARP announcement packet. The sender protocol address occupies 4 bytes, and this field contains the protocol address of the device that sends the ARP announcement packet. The target hardware address occupies 6 bytes, and this field contains the hardware address of the target device; in the ARP request, this field is usually set to 0 because the sender does not know the hardware address of the target. The target protocol address occupies 4 bytes, and this field contains the protocol address of the target device.
[0046] S12. Extract the check information from the padding field to perform check processing on the ARP announcement packet and obtain the check result.
[0047] After the security receiving device receives the ARP announcement packet, it extracts the verification information from the padding field of the ARP announcement packet, and performs verification processing on the ARP announcement packet according to the verification information to obtain a verification result.
[0048] S13. In response to the verification result being successful, extract the information receiving port of the security sending device from the padding field.
[0049] It can be understood that the verification result includes success and failure. In response to the verification result being successful, extract the information receiving port of the security sending device from the padding field. In response to the verification result being failure, discard the corresponding ARP announcement packet without processing.
[0050] 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.
[0051] The security receiving device connects to the sender protocol address and the information receiving port in the sender protocol address field. For example, use TCP to connect to the sender protocol address 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. Among them, the device information of the security receiving device may include the IP address of the security receiving device, the desensitized device binding information, the account association information, and other information that can be realized, without specific limitation.
[0052] In the above solution, by receiving the ARP announcement packet sent by the security sending device, where the ARP announcement packet includes a sender protocol address field and a padding field for verification, extract the verification information from the padding field to perform verification processing on the ARP announcement packet to obtain a verification result; in response to the verification result being successful, extract the port for receiving return information, that is, the information receiving port of the security sending device, from the padding field, 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; in the solution of the present application, the verification information is stored in the padding field by the security sending device, which increases the scalability of the application. The security sending device customizes the information receiving port, which can also avoid the port occupation caused by fixed ports and the security problems caused by being easily monitored.
[0053] In an embodiment of the present application, verification information is extracted from the padding field to perform verification processing on the ARP declaration packet, and a verification result is obtained, 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 a preset salt value, obtaining a verification value; comparing the verification value with the target verification value to obtain a 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.
[0054] The security receiving device extracts a random number and a target verification value from the padding field, and extracts the sender protocol address from the sender protocol address field. Among them, the random number is generated by the security sending device and filled in the padding field. For example, " / dev / random" in the Linux system is used as a true random number generator, and it can be used to generate an int (4-byte) random number. " / dev / random" is based on the system's entropy pool and is very suitable for applications that require high security, such as generating SSL keys, etc.
[0055] Using a preset algorithm, based on the sender protocol address, the random number, and a preset salt value, a verification value is obtained. Among them, in the encryption algorithm, the "salt value" is an additional parameter used to increase the complexity of encryption and prevent attackers from using pre-computed methods such as rainbow tables to crack passwords. Comparing the obtained verification value with the target verification value to obtain a 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; in response to the verification value being different from the target verification value, it indicates that the verification result is failed.
[0056] In an embodiment of the present application, using a preset algorithm, based on the sender protocol address, the random number, and a preset salt value, obtaining a verification value includes:
[0057] Verification value = CRC32(IP + Salt + Random value)
[0058] Wherein, 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.
[0059] It can be understood that using the CRC32 algorithm, based on the sender protocol address, the preset salt value, and the random number, the CRC32 value, that is, the verification value, is calculated. Then, the verification value is compared with the target verification value to obtain a verification result.
[0060] Among them, the random number is an unfixed value. The random number is used to increase the randomness and uniqueness of the generated verification value and can prevent replay attacks.
[0061] In an embodiment of the present application, receiving an ARP announcement packet sent by a security sending device includes: receiving the ARP announcement packet using a first preset function.
[0062] The pseudo-codes for sending data and receiving data in an embodiment of the present application are as follows:
[0063]
[0064] Among them, a raw socket is constructed. The security receiving device uses a first preset function to receive the ARP announcement packet sent by the security sending device. The first preset function can be the recvfrom function or other functions that can be implemented, without specific limitation.
[0065] Please refer to Figure 3 , Figure 3 which is another flowchart of the device discovery method of the present application. It should be noted that if there are substantially the same results, the method of the present application is not limited to the Figure 3 shown flowchart order. This method can be applied to electronic devices with functions such as computing. For example, the electronic device is a smart security device, which includes a security receiving device and a security sending device. The security receiving device is a camera or a doorbell, and the security sending device is a base station. It can be understood that in other embodiments, the security receiving device and the security sending device can be interchanged, that is, the security receiving device is the base station, and the security sending device is a camera, a doorbell, etc.
[0066] Specifically, in some possible implementation manners, 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 Figure 3 shown, the device discovery method, applied to a security sending device, includes the following steps:
[0067] S21. Generate and send 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. The security receiving device receives the ARP announcement packet, extracts verification information from the padding field to perform verification processing on the ARP announcement packet to obtain a verification result, and in response to the verification result being successful, extracts the information receiving port of the security sending device from the padding field.
[0068] In the standard ARP protocol, the ARP announcement is an ARP data packet used to announce the local IP address and MAC address to the network. Nodes in the network send ARP announcements to share their IP addresses and MAC addresses with other nodes, causing all hosts in the LAN (VLAN) to update their ARP caches, mapping the IP address to the MAC address of the sender device.
[0069] In an application scenario, device discovery includes a sender device for sending data and a receiver device for receiving data.
[0070] The sender device sends an ARP announcement to the receiver device. The ARP announcement 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 sender device. The sender device fills the sender protocol address field and the padding field for verification into the ARP announcement and sends it to the receiver device. Thus, the receiver device receives the ARP announcement sent by the sender device. After receiving the ARP announcement, the receiver device extracts the verification information from the padding field of the ARP announcement and performs a verification process on the ARP announcement based on the verification information to obtain a verification result. The verification result includes success and failure. In response to the verification result being successful, the receiver device extracts the information receiving port of the sender device from the padding field. The receiver device connects to the sender protocol address and the information receiving port in the sender protocol address field. For example, it uses TCP to connect to the sender protocol address and the information receiving port.
[0071] S22. Receive the device information sent by the receiver device through the information receiving port to achieve device discovery.
[0072] The receiver device sends the device information of the receiver device to the information receiving port of the sender device. The device information of the receiver device may include the IP address of the receiver device, the desensitized device binding information, the account association information, and other information that can be implemented, without specific limitation.
[0073] The receiver device receives the device information sent by the receiver device through the information receiving port to achieve device discovery.
[0074] In an embodiment of the present application, generating an ARP announcement includes: using a preset algorithm to obtain a target verification value based on the sender protocol address in the sender protocol address field, a random number, and a preset salt value; filling the random number and the target verification value into the padding field for verification; and generating an ARP announcement based on the sender protocol address field and the padding field.
[0075] Using a preset algorithm, based on the sender protocol address in the sender protocol address field, a random number, and a preset salt value, a target verification value is obtained. For example, " / dev / random" in the Linux system can be used as a true random number generator to generate an int (4-byte) random number. " / dev / random" is based on the system's entropy pool and is very suitable for applications that require high security, such as generating SSL keys. The GUID generation algorithm can be used to generate a 32-byte fixed salt value, or any other achievable algorithm can be used without specific limitation to obtain the preset salt value, ensuring the uniqueness, randomness, and sufficient length of the preset salt value to increase the cracking difficulty.
[0076] The security sending device fills the random number and the target verification value into the filling field for verification, and thus generates an ARP declaration packet based on the sender protocol address field and the filling field.
[0077] In one embodiment, the filling of the ARP declaration packet of the present application is as follows:
[0078]
[0079] Among them, the ARP declaration packet includes a Hardware Type, a Protocol Type, an Opcode, a Sender Hardware Address, a Sender Protocol Address, a Target Hardware Address, and a Target Protocol Address. Among them, the value of the Hardware Type is 1, indicating that the hardware type is Ethernet; the Protocol Type is 0x800, indicating that the protocol type is IPV4; the value of the Opcode is 1, indicating that the opcode is a request; the value of the 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 the 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 the Target Hardware Address is 00.00.00.00.00.00, indicating that the target hardware address is all devices within the broadcast network and there is no mac address of a specific device; the value of the Target Protocol Address is xxx.xxx.xxx.xxx, indicating that the target protocol address is for no specific device and the IP address of the security sending device is filled in, representing a broadcast ARP.
[0080] In an embodiment of the present application, using a preset algorithm, based on the sender protocol address in the sender protocol address field, a random number, and a preset salt value, a target check value is obtained, including:
[0081] Target check value = CRC32(IP + Salt + Random value)
[0082] 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.
[0083] It can be understood that using the CRC32 algorithm, based on the sender protocol address, the preset salt value, and the random number, the CRC32 value, that is, the target check value, is calculated. Furthermore, the security receiving device uses the same preset algorithm, and based on the same sender protocol address, random number, and preset salt value, the obtained check value will be the same as the target check value.
[0084] In an embodiment of the present application, the device discovery method further includes: sending an ARP announcement packet using a second preset function.
[0085] The pseudocode for sending and receiving data in another embodiment of the present application is as follows:
[0086]
[0087] 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 announcement packet. The second preset function can be the sendto function or other functions that can be implemented, without specific limitation.
[0088] In an embodiment of the present application, 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 announcement packet at a first preset time interval for a preset number of times; and / or, in response to receiving the device information sent by the security receiving device within a preset time period, sending the ARP announcement packet at a second preset time interval.
[0089] After the security sending device sends the ARP announcement packet to the security receiving device, the security receiving device will perform verification processing on the received ARP announcement packet. After successful verification, the security receiving device will send the device information of the security receiving device to the security sending device.
[0090] In response to not receiving the device information sent by the security receiving device within a preset time period, the security sending device resends the ARP announcement packet at a first preset time interval for a preset number of times. For example, the ARP announcement packet is sent once every 1 second and repeated three times to avoid the device not being discovered due to packet loss caused by network factors.
[0091] In response to receiving the device information sent by the security receiving device within a preset time period, the security sending device sends the ARP announcement packet at a second preset time interval. For example, the ARP announcement packet is sent at an interval of 10 seconds to timely discover whether a new device joins the network or an existing device goes offline.
[0092] The solution in the present application can efficiently discover relevant devices for communication, effectively reduce the number of network broadcast packets, and in the three-address and four-address configuration schemes in various complex network environments and MESH routing environments, devices can be mutually discovered to achieve device interconnection.
[0093] Those skilled in the art can understand that in the above method of the specific implementation manner, the writing order of each step does not mean a strict execution order and does not impose any limitation on the implementation process. The specific execution order of each step should be determined according to its function and possible internal logic.
[0094] Please refer to Figure 4 , Figure 4 which is a schematic structural diagram of an embodiment of an electronic device of the present application. The electronic device 400 includes a memory 401 and a processor 402 that are coupled to each other. The processor 402 is configured to execute program instructions stored in the memory 401 to implement the steps in the above embodiment of the device discovery method. In a specific implementation scenario, the electronic device 400 may include, but is not limited to, a microcomputer, a server, which is not limited herein.
[0095] Specifically, the processor 402 is configured to control itself and the memory 401 to implement the steps in the above embodiment of the device discovery method. The processor 402 may also be referred to as a CPU (Central Processing Unit), and the processor 402 may be an integrated circuit chip with signal processing capabilities. The processor 402 may 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 gate or transistor logic devices, discrete hardware components. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. Additionally, the processor 402 may be implemented jointly by integrated circuit chips.
[0096] Please refer to Figure 5 , Figure 5 which is a schematic structural diagram of an embodiment of a non-volatile computer-readable storage medium of the present application. The computer-readable storage medium 500 is used to store program instructions 501, and when the program instructions 501 are executed by the processor 402, they are used to implement the steps in the above embodiment of the device discovery method.
[0097] The descriptions of the above embodiments tend to emphasize the differences between the embodiments. Their similarities or similarities can be referred to each other. For the sake of brevity, they will not be elaborated herein.
[0098] In several embodiments provided in the present 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 embodiments 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. For example, 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 displayed or discussed coupling or direct coupling or communication disconnection between each other can be through some interfaces, and the indirect coupling or communication disconnection of devices or units can be in electrical, mechanical or other forms.
[0099] In addition, each functional unit in various embodiments of the present application can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
[0100] 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 such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods in various embodiments of the present application. The foregoing storage medium includes: USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs and other various media that can store program codes.
Claims
1. A device discovery method, applied to a security receiving device, characterized in that, including: Receiving an ARP declaration packet sent by a security sending device, where 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.
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, 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 a preset salt value, obtaining a verification value; Comparing the verification value with the target verification value to obtain the verification result, where 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, characterized in that, Using a preset algorithm, based on the sender protocol address, the random number, and a preset salt value, obtaining a verification value, including: Verification value = CRC32(IP + Salt + Random value) where 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 Receiving an ARP declaration packet sent by a security sending device, including: Receiving the ARP declaration packet using a first preset function.
5. A device discovery method, characterized in that, Applied to a security sending device, including: Generating and sending an ARP declaration packet to a 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, 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, extracts 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.
6. The method according to claim 5, wherein Generating the ARP declaration packet, including: Using a preset algorithm, based on the sender protocol address, a random number, and a preset salt value in the sender protocol address field, obtaining a target verification value; Filling the random number and the target verification value into the padding field for verification; Generating the ARP declaration packet based on the sender protocol address field and the padding field.
7. The method according to claim 6, characterized in that, Using a preset algorithm, based on the sender protocol address, a random number, and a preset salt value in the sender protocol address field, obtaining a target verification value, including: Target verification 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: Sending the ARP announcement packet using a second preset function.
9. The method according to claim 5, wherein 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 announcement packet at a first preset time interval for a preset number of times; and / or In response to receiving the device information sent by the security receiving device within a preset time period, sending the ARP announcement packet at a second preset time interval.
10. An electronic device, characterized in that, It includes a mutually coupled memory and a processor, and the processor is used to execute the program instructions stored in the memory to implement the device discovery method according to any one of claims 1-9.
11. A non-volatile computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store program instructions, and when the program instructions are executed by the processor, they are used to implement the device discovery method according to any one of claims 1-9.