WO2019165775A1 - Local area network equipment searching method and searching system - Google Patents
Local area network equipment searching method and searching system Download PDFInfo
- Publication number
- WO2019165775A1 WO2019165775A1 PCT/CN2018/104615 CN2018104615W WO2019165775A1 WO 2019165775 A1 WO2019165775 A1 WO 2019165775A1 CN 2018104615 W CN2018104615 W CN 2018104615W WO 2019165775 A1 WO2019165775 A1 WO 2019165775A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- slave device
- local area
- area network
- slave
- connection state
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 29
- 238000012360 testing method Methods 0.000 claims description 58
- 230000006854 communication Effects 0.000 claims description 32
- 238000004891 communication Methods 0.000 claims description 31
- 230000002159 abnormal effect Effects 0.000 claims description 7
- 230000001960 triggered effect Effects 0.000 description 5
- 230000005540 biological transmission Effects 0.000 description 3
- 238000010586 diagram Methods 0.000 description 2
- 230000003993 interaction Effects 0.000 description 2
- 238000001514 detection method Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/104—Peer-to-peer [P2P] networks
- H04L67/1061—Peer-to-peer [P2P] networks using node-based peer discovery mechanisms
Definitions
- the invention belongs to the technical field of networks, and in particular relates to a search method and a search system for a local area network device.
- the existing IoT network is based on the Transmission Control Protocol (TCP) or the Internet Protocol (IP).
- TCP Transmission Control Protocol
- IP Internet Protocol
- the existing local area network device discovery protocol can be implemented, for example, a multicast domain name system (mDNS) protocol and universal plug and play (Universal). Plug and Play, UPnP) protocol, however, the existing LAN device discovery protocol has a complicated implementation process and cannot be compatible with many devices on the market, and has a problem of a small application range.
- mDNS multicast domain name system
- Universal plug and Play, UPnP universal plug and play
- the embodiment of the present invention provides a search method and system for a local area network device, so as to solve the problem that the implementation process of the local area network device discovery protocol is complicated and has a small application scope.
- a first aspect of the embodiments of the present invention provides a method for searching a local area network device, including:
- the master device detects the first preset instruction for searching for the slave device, acquiring the broadcast address of the local area network
- the slave device returns slave device information to the master device according to the device search request.
- a second aspect of the embodiments of the present invention provides a search system for a local area network device, including:
- a master device configured to acquire a broadcast address of a local area network if the first preset instruction for searching for the slave device is detected
- the master device is further configured to: send a device search request to a broadcast address of the local area network, so that the device search request is broadcasted in the local area network;
- the slave device is configured to return slave device information to the master device according to the device search request.
- the method for searching for a local area network device is provided by the embodiment of the present invention.
- the master device obtains the broadcast address of the local area network, and the master device sends the device search to the broadcast address of the local area network.
- the request is such that the device search request is broadcast in the local area network, and the slave device returns the slave device information according to the device search request to the master device, simplifying the search step of the local area network device.
- FIG. 1 is a schematic flowchart of implementing a search method of a local area network device according to an embodiment of the present invention
- FIG. 2 is a schematic flowchart of implementing a search method of a local area network device according to another embodiment of the present invention
- FIG. 3 is a schematic structural diagram of a search system of a local area network device according to an embodiment of the present invention.
- FIG. 1 it is a flow chart of implementing a search method of a local area network device according to an embodiment of the present invention.
- the search method of the local area network device is applicable to data interaction between multiple devices, wherein at least one of the plurality of devices includes at least one master device.
- the search method of the local area network device shown in FIG. 1 may include:
- the master device and the slave device are in the same local area network, and the local area network is a pre-created local area network, and the master device and the slave device respectively access the local area network through wired or wireless manner, and respectively serve as nodes in the local area network.
- the broadcast address is the address used to broadcast the information to be broadcast to each node in the local area network in the local area network where the broadcast device is located.
- the broadcast address is a reserved address for sending information to each node in the local area network.
- the content of the target address in the information header of the to-be-broadcast information is a broadcast address, the information may be Received by all nodes in the LAN.
- the master device performs a search operation on the slave device in the local area network, that is, realizes discovery between the devices in the local area network, and triggers the master device to search for the slave devices in the same local area network through the first preset instruction, thereby implementing the device.
- the master device detects the first preset instruction for searching for the slave device, it may include, but is not limited to, the following scenario.
- the device is configured to perform the device discovery period. If the current time is the cycle time point for device discovery, the first preset instruction for searching the slave device is triggered, so that the master device configuration detects the first preset command. .
- the master device After the current master device is connected to the local area network, the master device starts to work and acquires the current time. If the current time is the preset cycle time point, the first preset instruction for searching the slave device is triggered, and the first command is detected. When the preset command is received, the broadcast address of the local area network is obtained.
- the master device sends a device search request to a broadcast address of the local area network, so that the device search request is broadcasted in the local area network.
- the device search request is a User Datagram Protocol (UDP) broadcast packet
- the header content of the UDP broadcast packet includes: a device discovery command, a serial number, a device type, and an error code in a communication process.
- UDP User Datagram Protocol
- the UDP broadcast packet may adopt a JavaScript Object Notation (JSON) format, for example:
- JSON JavaScript Object Notation
- the device search request is used to discover a slave device in the local area network, which carries the information receiving port of the master device, and broadcasts the device search request to the local area network, so that the slave device in the local area network receives the device search request after receiving the device search request.
- the slave device information is returned to the information receiving port of the master device.
- S13 The slave device returns the slave device information to the master device according to the device search request.
- the slave device information is used to describe the slave device attributes, including information such as the IP address of the slave device, the communication port, and the device identifier.
- the slave information is the response information of the device search request, and the response information may be in a JSON format, for example:
- the slave device information describes the slave device attribute and is the response information of the device search request
- the master device when the master device receives the slave device information sent by the slave device, the master device can perform the search operation on the slave device in the local area network. .
- the communication port of the slave device may include multiple, and when data transmission or communication is performed with different master devices, communication ports with the same or different communication port numbers may be selected.
- the host device obtains the broadcast address of the local area network when the master device detects the first preset instruction for searching the slave device, and the master device sends the local area network to the local area network.
- the broadcast address transmitting device searches for a request to cause the device search request to be broadcast in the local area network, and the slave device returns the slave device information to the master device according to the device search request, simplifying the search step of the local area network device.
- the slave device information includes an internet protocol IP address, a communication port, and a connection state identifier of the slave device.
- the search method of the local area network device includes:
- the master device and the slave device are in the same local area network, and the local area network is a pre-created local area network, and the master device and the slave device respectively access the local area network through wired or wireless manner, and respectively serve as nodes in the local area network.
- the broadcast address is the address used to broadcast the information to be broadcast to each node in the local area network in the local area network where the broadcast device is located.
- the master device sends a device search request to a broadcast address of the local area network, so that the device search request is broadcasted in the local area network.
- step S22 specifically includes: the primary device creates a first user datagram protocol UDP socket based on the broadcast address, and describes the first UDP socket by using the first UDP socket.
- a port sends a connection status test request to the broadcast address.
- a socket is a handle of a communication chain used to implement communication between different virtual machines or different computers.
- the master device creates a first UDP socket based on the broadcast address, the first UDP socket is a UDP broadcast socket, used to describe a broadcast address (IP address), and the master device performs data interaction with the broadcast address.
- IP address broadcast address
- the master device sends a device search request to the broadcast address through the first port described by the first UDP socket.
- the existing SELECT character set needs to be cleared first, and the created UDP socket is added to the SELECT character set for information reception.
- S23 The slave device returns the slave device information to the master device according to the device search request.
- the master device generates a slave device list according to the slave device information, where data in the slave device list is used to describe the slave device, an IP address of the slave device, the communication port, and the connection state. The correspondence between the identifiers.
- the slave device list is used to reflect all the slave devices searched by the master device, wherein the slave device is in the same local area network as the master device.
- the IP address of the slave device is used to describe the node address of the slave device in the local area network
- the communication port is a communication port for the slave device to exchange information with the master device
- the connection forwarding identifier is used to describe the connection state between the slave device and the master device. , that is, the state of connection from the LAN.
- the master device sends a connection state test request to the IP addresses of all the slave devices in the slave device list in sequence if detecting a second preset instruction for testing the slave device connection state.
- connection status test request may be in a JSON format, for example:
- the master device After the slave device returns the slave device information to the master device according to the device search request, in order to be able to timely learn the connection state of the slave device and the local area network, the master device generates a slave device list according to the slave device information, and detects that the slave device is used for When the second preset instruction of the slave device connection state is tested, a connection state test request is sent to all the slave devices that are searched, and since the slave device lists the IP addresses of all the slave devices, the master device sequentially goes to the slave device. By sending a connection status test request to all the slave devices' IP addresses in the list, the connection status detection can be performed on all the slave devices that are searched.
- the second preset instruction for testing the connection state of the slave device is triggered by the master device.
- the test period of the device connection state is configured for the master device, and if the current time is the test cycle time point for performing the device connection state, the second preset instruction for testing the slave device connection state is triggered, so that the master The device configuration detects the second preset instruction.
- the second preset instruction may also be triggered by the tester when the tester performs debugging on the master device and the slave device in the local area network.
- step S25 specifically includes: the master device creates a second UDP socket based on an IP address of the slave device, and describes the second UDP socket by using the second UDP socket.
- the two ports send a connection status test request to the slave device.
- connection status test request carries the address information of the second port.
- each second UDP socket corresponds to an IP address of the slave device, and multiple seconds.
- the UDP sockets are unicast sockets.
- the master device sends the second port described by each second UDP socket to each slave device in the slave device list.
- the IP address sends a connection status test request.
- the slave device receives the connection state test request, and returns the target information to the master device through the communication port according to the connection state test request.
- step S26 the target information is used to describe that the connection state between the slave device and the local area is normal.
- the target information may be in a JSON format, for example:
- cmd describes the device discovery command
- seq is The serial number
- the content described by type is the device type
- the content described by error is the error code.
- the slave device When the slave device and the master device are in the same local area network, and the master device can exchange information based on the IP address in the local area network, the slave device can receive the connection state test request, and generate a target according to the connection state test request. The information is returned to the master device through the communication port; when the slave device is not in the same local area network as the master device, and the master device cannot exchange information based on the IP address in the local area network, the slave device cannot receive the connection state. Test request.
- the slave device By sequentially transmitting a connection status test request to the IP addresses of all the slave devices in the slave device list, if the slave device receives the connection state test request, the slave device returns the target information to the master device through the communication port according to the connection state test request.
- the master device After the master device is searched for the slave device in the local area network, it can update the online condition of the slave device in the local area network in time, that is, update the information of the searched local area network device in time.
- connection state test request carries the address information of the second port
- step S26 specifically includes: the slave device according to the address information, to the second through the communication port.
- the port returns the target information.
- connection status identifier is used to characterize the connection status between the slave device and the local area network.
- connection status identifier may be a specific value, where the value is used to describe the number of times the master device sends a connection status test request to the slave device.
- each slave device corresponds to one.
- a connection status identifier which is used to describe the number of times the master device sends a connection status test request to the slave device.
- the connection state test request is sequentially sent to the IP addresses of all the slave devices in the slave device list.
- the master device modifies the connection state identifier in the slave device list, that is, performs a subtraction operation on the value corresponding to the connection state identifier.
- the master device receives the target information, and the value represented by the connection status identifier is not 0, it determines that the connection status of the slave device is normal; when the master device does not receive the target information, and the value represented by the connection status identifier is 0, then It is determined that the connection status of the slave device is abnormal.
- the method may further include: when the master device does not receive the target information, listening to the second Whether the second port described by the UDP socket is enabled, if the second port is disabled, the second port is enabled to receive the target information; when the primary device does not receive the target information, and the second port is enabled, the connection status identifier is characterized When the value is 0, it is determined that the connection status of the slave device is abnormal.
- the host device obtains the broadcast address of the local area network when the master device detects the first preset instruction for searching the slave device, and the master device sends the local area network to the local area network.
- the broadcast address transmitting device searches for a request to cause the device search request to be broadcast in the local area network, and the slave device returns the slave device information to the master device according to the device search request, simplifying the search step of the local area network device.
- the slave device By sequentially transmitting a connection status test request to the IP addresses of all the slave devices in the slave device list, if the slave device receives the connection state test request, the slave device returns the target information to the master device through the communication port according to the connection state test request. After searching for the slave devices in the local area network, the master device can update the online status of the slave devices in the local area network in time, that is, timely update the information of the searched local area network devices.
- FIG. 3 is a schematic structural diagram of a search system of a local area network device according to an embodiment of the present invention.
- the search system 2 of the local area network device of the present embodiment includes: a master device 21 and a slave device cluster 22, wherein the slave device cluster 22 includes a plurality of slave devices 221.
- the master device 21 is configured to acquire a broadcast address of a local area network if the first preset instruction for searching for the slave device is detected.
- the master device 21 is further configured to send a device search request to a broadcast address of the local area network to cause the device search request to be broadcasted in the local area network.
- the slave device 221 is configured to return the slave device information to the master device according to the device search request.
- the slave device information includes an internet protocol IP address, a communication port, and a connection state identifier of the slave device.
- the master device 21 is further configured to generate, according to the slave device information, a slave device list, where the data in the slave device list is used to describe the slave device, the slave device Correspondence between the IP address of the device, the communication port, and the connection status identifier.
- the master device 21 is further configured to: if the second preset instruction for testing the connection state of the slave device is detected, send a connection state test request to the IP addresses of all the slave devices in the slave device list in sequence .
- the slave device 221 is further configured to: if the connection state test request is received, return the target information to the master device through the communication port according to the connection state test request.
- the master device 21 Upon receiving the target information, the master device 21 determines that the connection state of the slave device is normal.
- the master device 21 determines that the connection state of the slave device is abnormal.
- the master device 21 is specifically configured to: create a first user datagram protocol UDP socket based on the broadcast address, and describe the first UDP socket by using the first UDP socket A port sends a connection status test request to the broadcast address.
- the master device 21 is specifically configured to create a second UDP socket based on the IP address of the slave device, and describe the second UDP socket by using the second UDP socket.
- the two ports send a connection status test request to the slave device, where the connection status test request carries address information of the second port.
- the slave device 221 is specifically configured to return target information to the second port through the communication port according to the address information.
- the host device obtains the broadcast address of the local area network when the master device detects the first preset instruction for searching the slave device, and the master device sends the local area network to the local area network.
- the broadcast address transmitting device searches for a request to cause the device search request to be broadcast in the local area network, and the slave device returns the slave device information to the master device according to the device search request, simplifying the search step of the local area network device.
- the slave device By sequentially transmitting a connection status test request to the IP addresses of all the slave devices in the slave device list, if the slave device receives the connection state test request, the slave device returns the target information to the master device through the communication port according to the connection state test request.
- the master device After the master device is searched for the slave device in the local area network, it can update the online condition of the slave device in the local area network in time, that is, update the information of the searched local area network device in time.
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Small-Scale Networks (AREA)
Abstract
The invention is applied for the technical field of the network, and provides a searching method and searching system of local area network (LAN) equipment. The searching method of the local area network equipment comprises the following steps: primary equipment acquires a broadcast address of the located LAN when detecting a first preset instruction for searching slave equipment; the primary equipment sends an equipment searching request to a broadcast address of the LAN, thereby enabling the equipment searching request to be broadcasted in the local area network; and the slave equipment returns slave equipment information to the primary equipment according to the equipment searching request, so that the searching step of the LAN equipment is simplified.
Description
本发明属于网络技术领域,尤其涉及一种局域网设备的搜索方法及搜索系统。The invention belongs to the technical field of networks, and in particular relates to a search method and a search system for a local area network device.
现有的物联网络是基于传输控制协议(Transmission Control Protocol,TCP)或者网际协议(Internet Protocol,IP),要实现智能设备之间的数据传输,必须先获取目的设备的IP地址,也即对同一个局域网中的设备进行搜索。The existing IoT network is based on the Transmission Control Protocol (TCP) or the Internet Protocol (IP). To implement data transmission between smart devices, the IP address of the destination device must be obtained first, that is, Search for devices on the same LAN.
现有技术中在对同一个局域网中的设备进行搜索时,可以通过现有的局域网设备发现协议实现,例如,组播域名系统(multicast Domain Name System,mDNS)协议和通用即插即用(Universal Plug and Play,UPnP)协议,然而,现有的局域网设备发现协议,实现流程较为复杂,无法兼容市场上的许多设备,存在适用范围较小的问题。In the prior art, when searching for devices in the same local area network, the existing local area network device discovery protocol can be implemented, for example, a multicast domain name system (mDNS) protocol and universal plug and play (Universal). Plug and Play, UPnP) protocol, however, the existing LAN device discovery protocol has a complicated implementation process and cannot be compatible with many devices on the market, and has a problem of a small application range.
【发明内容】[Summary of the Invention]
有鉴于此,本发明实施例提供了一种局域网设备的搜索方法及系统,以解决现有技术中局域网设备发现协议实现流程较为复杂,存在适用范围较小的问题。In view of this, the embodiment of the present invention provides a search method and system for a local area network device, so as to solve the problem that the implementation process of the local area network device discovery protocol is complicated and has a small application scope.
本发明实施例的第一方面提供了一种局域网设备的搜索方法,包括:A first aspect of the embodiments of the present invention provides a method for searching a local area network device, including:
主设备若检测到用于搜索从设备的第一预设指令,则获取所在局域网的广播地址;If the master device detects the first preset instruction for searching for the slave device, acquiring the broadcast address of the local area network;
所述主设备向所述局域网的广播地址发送设备搜索请求,以使所述设备搜索请求在所述局域网中被广播;Sending, by the master device, a device search request to a broadcast address of the local area network, so that the device search request is broadcasted in the local area network;
所述从设备根据所述设备搜索请求向所述主设备返回从设备信息。The slave device returns slave device information to the master device according to the device search request.
本发明实施例的第二方面提供了一种局域网设备的搜索系统,包括:A second aspect of the embodiments of the present invention provides a search system for a local area network device, including:
主设备,用于若检测到用于搜索从设备的第一预设指令,则获取所在局域网的广播地址;a master device, configured to acquire a broadcast address of a local area network if the first preset instruction for searching for the slave device is detected;
所述主设备还用于,向所述局域网的广播地址发送设备搜索请求,以使所述设备搜索请求在所述局域网中被广播;The master device is further configured to: send a device search request to a broadcast address of the local area network, so that the device search request is broadcasted in the local area network;
所述从设备,用于根据所述设备搜索请求向所述主设备返回从设备信息。The slave device is configured to return slave device information to the master device according to the device search request.
本发明实施例提供的一种局域网设备的搜索方法,通过主设备在检测到用于搜索从设备的第一预设指令时,获取所在局域网的广播地址,主设备向局域网的广播地址发送设备搜索请求,以使设备搜索请求在局域网中被广播,由从设备根据设备搜索请求向主设备返回从设备信息,简化了局域网设备的搜索步骤。The method for searching for a local area network device is provided by the embodiment of the present invention. When the primary device detects the first preset instruction for searching for the slave device, the master device obtains the broadcast address of the local area network, and the master device sends the device search to the broadcast address of the local area network. The request is such that the device search request is broadcast in the local area network, and the slave device returns the slave device information according to the device search request to the master device, simplifying the search step of the local area network device.
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the embodiments or the description of the prior art will be briefly described below. It is obvious that the drawings in the following description are only the present invention. For some embodiments, other drawings may be obtained from those of ordinary skill in the art in light of the inventive workability.
图1是本发明实施例提供的一种局域网设备的搜索方法的实现流程示意图;1 is a schematic flowchart of implementing a search method of a local area network device according to an embodiment of the present invention;
图2是本发明另一实施例提供的一种局域网设备的搜索方法的实现流程示意图;2 is a schematic flowchart of implementing a search method of a local area network device according to another embodiment of the present invention;
图3是本发明实施例提供的一种局域网设备的搜索系统的结构示意图。FIG. 3 is a schematic structural diagram of a search system of a local area network device according to an embodiment of the present invention.
以下描述中,为了说明而不是为了限定,提出了诸如特定系统结构、技术之类的具体细节,以便透彻理解本发明实施例。然而,本领域的技术人员应当清楚,在没有这些具体细节的其它实施例中也可以实现本发明。在其它情况中,省略对众所周知的系统、装置、电路以及方法的详细说明,以免不必要的细节妨碍本发明的描述。In the following description, for purposes of illustration and description However, it will be apparent to those skilled in the art that the present invention may be practiced in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the invention.
为了说明本发明所述的技术方案,下面通过具体实施例来进行说明。In order to explain the technical solution described in the present invention, the following description will be made by way of specific embodiments.
参见图1,是本发明实施例提供一种局域网设备的搜索方法的实现流程图。在本实施例中,局域网设备的搜索方法适用于多个设备之间进行数据交互,其中,多个设备中至少包括一个主设备。如图1所示局域网设备的搜索方法可包括:Referring to FIG. 1 , it is a flow chart of implementing a search method of a local area network device according to an embodiment of the present invention. In this embodiment, the search method of the local area network device is applicable to data interaction between multiple devices, wherein at least one of the plurality of devices includes at least one master device. The search method of the local area network device shown in FIG. 1 may include:
S11:主设备若检测到用于搜索从设备的第一预设指令,则获取所在局域网的广播地址。S11: If the master device detects the first preset instruction for searching for the slave device, acquire the broadcast address of the local area network.
在步骤S11中,主设备与从设备处于同一局域网中,该局域网为预先创建 好的局域网,主设备与从设备分别通过有线或者无线的方式接入该局域网中,并分别作为该局域网中的节点。广播地址为主设备所在的局域网中,用于将待广播信息向局域网中的各个节点进行广播的地址。In step S11, the master device and the slave device are in the same local area network, and the local area network is a pre-created local area network, and the master device and the slave device respectively access the local area network through wired or wireless manner, and respectively serve as nodes in the local area network. . The broadcast address is the address used to broadcast the information to be broadcast to each node in the local area network in the local area network where the broadcast device is located.
需要说明的是,在创建局域网时,广播地址为预留的用于向局域网中各节点发送信息的地址,当待广播信息的信息头中描述目标地址的内容为广播地址时,该信息则可被局域网中的所有节点接收。It should be noted that, when the local area network is created, the broadcast address is a reserved address for sending information to each node in the local area network. When the content of the target address in the information header of the to-be-broadcast information is a broadcast address, the information may be Received by all nodes in the LAN.
在本实施例中,在局域网中主设备对从设备进行搜索操作,也即在局域网中实现设备之间的发现,通过第一预设指令触发主设备搜索同一局域网内的从设备,进而实现设备之间的发现。In this embodiment, the master device performs a search operation on the slave device in the local area network, that is, realizes discovery between the devices in the local area network, and triggers the master device to search for the slave devices in the same local area network through the first preset instruction, thereby implementing the device. The discovery between.
至于主设备何时检测到用于搜索从设备的第一预设指令,可以包括但不仅限于以下场景。As for when the master device detects the first preset instruction for searching for the slave device, it may include, but is not limited to, the following scenario.
为主设备配置进行设备发现的周期,如果检测到当前时间为进行设备发现的周期时间点,则触发用于搜索从设备的第一预设指令,使得主设备配置检测到该第一预设指令。The device is configured to perform the device discovery period. If the current time is the cycle time point for device discovery, the first preset instruction for searching the slave device is triggered, so that the master device configuration detects the first preset command. .
例如,当前主设备被接入局域网之后,主设备开始工作并获取当前时间,若当前时间为预设周期时间点,则触发用于搜索从设备的第一预设指令,并在检测到第一预设指令时,获取所在局域网的广播地址。For example, after the current master device is connected to the local area network, the master device starts to work and acquires the current time. If the current time is the preset cycle time point, the first preset instruction for searching the slave device is triggered, and the first command is detected. When the preset command is received, the broadcast address of the local area network is obtained.
S12:所述主设备向所述局域网的广播地址发送设备搜索请求,以使所述设备搜索请求在所述局域网中被广播。S12: The master device sends a device search request to a broadcast address of the local area network, so that the device search request is broadcasted in the local area network.
在步骤S12中,设备搜索请求为用户数据报协议(User Datagram Protocol,UDP)广播包,该UDP广播包的报头内容包括:设备发现命令、序列号、设备类型以及通讯过程中的错误码。In step S12, the device search request is a User Datagram Protocol (UDP) broadcast packet, and the header content of the UDP broadcast packet includes: a device discovery command, a serial number, a device type, and an error code in a communication process.
在本实施例中,UDP广播包可以采用JavaScript对象标记格式(JavaScript Object Notation,JSON),例如:In this embodiment, the UDP broadcast packet may adopt a JavaScript Object Notation (JSON) format, for example:
{"header":{"cmd":1024,"seq":2,"type":1,"error":0}},其中,cmd所描述的内容为设备发现命令,seq所描述的内容为序列号,type所描述的内容为设备类型,error所描述的内容为错误码。{"header":{"cmd":1024,"seq":2,"type":1,"error":0}}, where the content described by cmd is the device discovery command, and the content described by seq is The serial number, the content described by type is the device type, and the content described by error is the error code.
需要说明的是,设备搜索请求用于发现局域网中的从设备,其携带有主设备的信息接收端口,通过向局域网广播该设备搜索请求,使得局域网中的从设备在接收到该设备搜索请求后,向主设备的信息接收端口返回从设备信息。It should be noted that the device search request is used to discover a slave device in the local area network, which carries the information receiving port of the master device, and broadcasts the device search request to the local area network, so that the slave device in the local area network receives the device search request after receiving the device search request. The slave device information is returned to the information receiving port of the master device.
S13:所述从设备根据所述设备搜索请求向所述主设备返回从设备信息。S13: The slave device returns the slave device information to the master device according to the device search request.
在步骤S13中,从设备信息用于描述从设备属性,包括:从设备的IP地址、通信端口以及设备标识等信息。In step S13, the slave device information is used to describe the slave device attributes, including information such as the IP address of the slave device, the communication port, and the device identifier.
在本实施例中,从设备信息为设备搜索请求的响应信息,该响应信息可以为JSON格式,例如:In this embodiment, the slave information is the response information of the device search request, and the response information may be in a JSON format, for example:
{"header":{"cmd":1024,"seq":4,"type":1,"error":0},"data":{"ip":"192.168.1.1","port":"27213"}},其中,ip所描述的内容为从设备的IP地址,port所描述的内容为从设备的通信端口编号。{"header":{"cmd":1024,"seq":4,"type":1,"error":0},"data":{"ip":"192.168.1.1","port": "27213"}}, where ip describes the IP address of the slave device, and the content described by the port is the communication port number of the slave device.
需要说明的是,由于从设备信息描述从设备属性,且作为设备搜索请求的响应信息,当主设备接收到从设备发送的从设备信息,即可实现主设备在局域网中对从设备进行搜索的操作。It should be noted that, since the slave device information describes the slave device attribute and is the response information of the device search request, when the master device receives the slave device information sent by the slave device, the master device can perform the search operation on the slave device in the local area network. .
可以理解的是,从设备的通信端口可以包括多个,在与不同的主设备之间进行数据传输或者通信时,可以选用通信端口编号相同或者不同的通信端口。It can be understood that the communication port of the slave device may include multiple, and when data transmission or communication is performed with different master devices, communication ports with the same or different communication port numbers may be selected.
以上可以看出,本发明实施例提供的一种局域网设备的搜索方法,通过主设备在检测到用于搜索从设备的第一预设指令时,获取所在局域网的广播地址,主设备向局域网的广播地址发送设备搜索请求,以使设备搜索请求在局域网中被广播,由从设备根据设备搜索请求向主设备返回从设备信息,简化了局域网设备的搜索步骤。It can be seen that, in the search method of the local area network device, the host device obtains the broadcast address of the local area network when the master device detects the first preset instruction for searching the slave device, and the master device sends the local area network to the local area network. The broadcast address transmitting device searches for a request to cause the device search request to be broadcast in the local area network, and the slave device returns the slave device information to the master device according to the device search request, simplifying the search step of the local area network device.
参见图2,是本发明另一实施例提供一种局域网设备的搜索方法的实现流程图。在本实施例中,从设备信息包括所述从设备的网际协议IP地址、通信端口以及连接状态标识。如图2所示,局域网设备的搜索方法包括:2 is a flowchart of implementing a search method of a local area network device according to another embodiment of the present invention. In this embodiment, the slave device information includes an internet protocol IP address, a communication port, and a connection state identifier of the slave device. As shown in FIG. 2, the search method of the local area network device includes:
S21:主设备若检测到用于搜索从设备的第一预设指令,则获取所在局域网的广播地址。S21: If the master device detects the first preset instruction for searching for the slave device, acquire the broadcast address of the local area network.
在步骤S21中,主设备与从设备处于同一局域网中,该局域网为预先创建好的局域网,主设备与从设备分别通过有线或者无线的方式接入该局域网中,并分别作为该局域网中的节点。广播地址为主设备所在的局域网中,用于将待广播信息向局域网中的各个节点进行广播的地址。In step S21, the master device and the slave device are in the same local area network, and the local area network is a pre-created local area network, and the master device and the slave device respectively access the local area network through wired or wireless manner, and respectively serve as nodes in the local area network. . The broadcast address is the address used to broadcast the information to be broadcast to each node in the local area network in the local area network where the broadcast device is located.
S22:所述主设备向所述局域网的广播地址发送设备搜索请求,以使所述设备搜索请求在所述局域网中被广播。S22: The master device sends a device search request to a broadcast address of the local area network, so that the device search request is broadcasted in the local area network.
作为本实施例一种可能实现的方式,步骤S22具体包括:所述主设备基于所述广播地址创建第一用户数据报协议UDP套接字,并通过所述第一UDP套接字描述的第一端口,向所述广播地址发送连接状态测试请求。As a possible implementation manner of this embodiment, step S22 specifically includes: the primary device creates a first user datagram protocol UDP socket based on the broadcast address, and describes the first UDP socket by using the first UDP socket. A port sends a connection status test request to the broadcast address.
需要说明的是,套接字是一个通信链的句柄,用来实现不同虚拟机或不同计算机之间的通信。主设备基于所述广播地址创建第一UDP套接字,该第一UDP套接字为UDP广播套接字,用于描述广播地址(IP地址),以及主设备与该广播地址进行数据交互的第一端口。It should be noted that a socket is a handle of a communication chain used to implement communication between different virtual machines or different computers. The master device creates a first UDP socket based on the broadcast address, the first UDP socket is a UDP broadcast socket, used to describe a broadcast address (IP address), and the master device performs data interaction with the broadcast address. First port.
在本实施例中,主设备在创建第一UDP套接字后,通过该第一UDP套接字所描述的第一端口向广播地址发送设备搜索请求。In this embodiment, after the first UDP socket is created, the master device sends a device search request to the broadcast address through the first port described by the first UDP socket.
在本申请的所有实施例中,在使用套接字之前,均需要先将已有的SELECT字符集进行清零操作,再将创建好的UDP套接字添加到该SELECT字符集中进行信息接收。In all embodiments of the present application, before the socket is used, the existing SELECT character set needs to be cleared first, and the created UDP socket is added to the SELECT character set for information reception.
S23:所述从设备根据所述设备搜索请求向所述主设备返回从设备信息。S23: The slave device returns the slave device information to the master device according to the device search request.
S24:所述主设备根据所述从设备信息生成从设备列表,所述从设备列表中的数据用于描述所述从设备、所述从设备的IP地址、所述通信端口以及所述连接状态标识之间的对应关系。S24: The master device generates a slave device list according to the slave device information, where data in the slave device list is used to describe the slave device, an IP address of the slave device, the communication port, and the connection state. The correspondence between the identifiers.
在步骤S24中,从设备列表用于反映主设备搜索到的所有从设备,其中,从设备与主设备处于同一局域网内。从设备的IP地址用于描述从设备在该局域网中的节点地址,通信端口为该从设备与主设备进行信息交互的通信端口,连接转标识用于描述从设备与主设备之间的连接状态,也即从与局域网之间的连接状态。In step S24, the slave device list is used to reflect all the slave devices searched by the master device, wherein the slave device is in the same local area network as the master device. The IP address of the slave device is used to describe the node address of the slave device in the local area network, and the communication port is a communication port for the slave device to exchange information with the master device, and the connection forwarding identifier is used to describe the connection state between the slave device and the master device. , that is, the state of connection from the LAN.
S25:所述主设备若检测到用于测试所述从设备连接状态的第二预设指令,则依次向所述从设备列表中的所有所述从设备的IP地址,发送连接状态测试请求。S25: The master device sends a connection state test request to the IP addresses of all the slave devices in the slave device list in sequence if detecting a second preset instruction for testing the slave device connection state.
在步骤S25中,连接状态测试请求可以为JSON格式,例如:In step S25, the connection status test request may be in a JSON format, for example:
{"header":{"cmd":1027,"seq":3,"type":1,"error":0}};其中,cmd所描述的内容为设备发现命令,seq所描述的内容为序列号,type所描述的内容为设备类型,error所描述的内容为错误码。{"header":{"cmd":1027,"seq":3,"type":1,"error":0}}; where cmd describes the device discovery command, and seq describes The serial number, the content described by type is the device type, and the content described by error is the error code.
在本实施例中,从设备根据设备搜索请求向主设备返回从设备信息后,为了能够及时获悉从设备与局域网的连接状态,主设备根据从设备信息生成从设备列表,并在检测到用于测试所述从设备连接状态的第二预设指令时,向搜索到的所有从设备发送连接状态测试请求,由于从设备列表中记载了所有从设备的IP地址,因此,主设备依次向从设备列表中所有从设备的IP地址发送连接状态测试请求,即可实现对搜索到的所有从设备进行连接状态检测。In this embodiment, after the slave device returns the slave device information to the master device according to the device search request, in order to be able to timely learn the connection state of the slave device and the local area network, the master device generates a slave device list according to the slave device information, and detects that the slave device is used for When the second preset instruction of the slave device connection state is tested, a connection state test request is sent to all the slave devices that are searched, and since the slave device lists the IP addresses of all the slave devices, the master device sequentially goes to the slave device. By sending a connection status test request to all the slave devices' IP addresses in the list, the connection status detection can be performed on all the slave devices that are searched.
需要说明的是,用于测试从设备连接状态的第二预设指令,由主设备自行触发。It should be noted that the second preset instruction for testing the connection state of the slave device is triggered by the master device.
例如,为主设备配置进行设备连接状态的测试周期,如果检测到当前时间为进行设备连接状态的测试周期时间点,则触发用于测试所述从设备连接状态的第二预设指令,使得主设备配置检测到该第二预设指令。For example, the test period of the device connection state is configured for the master device, and if the current time is the test cycle time point for performing the device connection state, the second preset instruction for testing the slave device connection state is triggered, so that the master The device configuration detects the second preset instruction.
可以理解的是,在实际中,第二预设指令也可以是由测试方在对局域网中的主设备和从设备进行调试时,由测试方触发。It can be understood that, in practice, the second preset instruction may also be triggered by the tester when the tester performs debugging on the master device and the slave device in the local area network.
作为本实施例一种可能实现的方式,步骤S25具体包括:所述主设备基于所述从设备的IP地址,创建第二UDP套接字,并通过所述第二UDP套接字描述的第二端口向所述从设备发送连接状态测试请求。As a possible implementation manner of this embodiment, step S25 specifically includes: the master device creates a second UDP socket based on an IP address of the slave device, and describes the second UDP socket by using the second UDP socket. The two ports send a connection status test request to the slave device.
需要说明的是,连接状态测试请求中携带有第二端口的地址信息。It should be noted that the connection status test request carries the address information of the second port.
在本实施例中,针对从设备列表中多个从设备,可以创建内容不同的多个第二UDP套接字,每个第二UDP套接字对应一个从设备的IP地址,多个第二UDP套接字均为单播套接字,主设备在创建第二UDP套接字后,通过各个第二UDP套接字所描述的第二端口,分别向从设备列表中的各个从设备的IP地址发送连接状态测试请求。In this embodiment, for a plurality of slave devices in the slave device list, multiple second UDP sockets with different contents may be created, and each second UDP socket corresponds to an IP address of the slave device, and multiple seconds. The UDP sockets are unicast sockets. After the second UDP socket is created, the master device sends the second port described by each second UDP socket to each slave device in the slave device list. The IP address sends a connection status test request.
S26:所述从设备若接收到所述连接状态测试请求,则根据所述连接状态测试请求,通过所述通信端口,向所述主设备返回目标信息。S26: The slave device receives the connection state test request, and returns the target information to the master device through the communication port according to the connection state test request.
在步骤S26中,目标信息用于描述从设备与局域之间的连接状态为正常。In step S26, the target information is used to describe that the connection state between the slave device and the local area is normal.
在本实施例中,目标信息可以为JSON格式,例如:In this embodiment, the target information may be in a JSON format, for example:
{"header":{"cmd":1027,"seq":5,"type":1,"error":0}};其中,cmd所描述的内容为设备发现命令,seq所描述的内容为序列号,type所描述的内容为设备类型,error所描述的内容为错误码。{"header":{"cmd":1027,"seq":5,"type":1,"error":0}}; where cmd describes the device discovery command, and the content described by seq is The serial number, the content described by type is the device type, and the content described by error is the error code.
当从设备与主设备处于同一局域网内,且与主设备之间能够基于各自在局域网中的IP地址进行信息交互时,从设备能够接收到连接状态测试请求,并根据该连接状态测试请求生成目标信息,通过通信端口返回给主设备;当从设备与主设备不处于同一局域网内,且与主设备之间无法基于各自在局域网中的IP地址进行信息交互时,从设备则无法接收到连接状态测试请求。When the slave device and the master device are in the same local area network, and the master device can exchange information based on the IP address in the local area network, the slave device can receive the connection state test request, and generate a target according to the connection state test request. The information is returned to the master device through the communication port; when the slave device is not in the same local area network as the master device, and the master device cannot exchange information based on the IP address in the local area network, the slave device cannot receive the connection state. Test request.
通过依次向从设备列表中的所有从设备的IP地址,发送连接状态测试请求,从设备若接收到连接状态测试请求,则根据连接状态测试请求,通过通信端口,向主设备返回目标信息,使得主设备被在搜索到局域网内的从设备后,能够及 时更新局域网内从设备的在线情况,也即及时更新搜索到的局域网设备的信息。By sequentially transmitting a connection status test request to the IP addresses of all the slave devices in the slave device list, if the slave device receives the connection state test request, the slave device returns the target information to the master device through the communication port according to the connection state test request. After the master device is searched for the slave device in the local area network, it can update the online condition of the slave device in the local area network in time, that is, update the information of the searched local area network device in time.
作为本实施例一种可能实现的方式,连接状态测试请求中携带有第二端口的地址信息,步骤S26具体包括:所述从设备根据所述地址信息,通过所述通信端口向所述第二端口返回目标信息。As a possible implementation manner of the embodiment, the connection state test request carries the address information of the second port, and the step S26 specifically includes: the slave device according to the address information, to the second through the communication port. The port returns the target information.
S27:所述主设备若接收到所述目标信息,则确定所述从设备的连接状态为正常。S27: If the master device receives the target information, determine that the connection status of the slave device is normal.
S28:所述主设备若未接收到所述目标信息,则确定所述从设备的连接状态为异常。S28: If the master device does not receive the target information, determine that the connection status of the slave device is abnormal.
在本实施例中,连接状态标识用于表征从设备与局域网之间的连接状态。In this embodiment, the connection status identifier is used to characterize the connection status between the slave device and the local area network.
作为本实施例一种可能实现的方式,连接状态标识可以为具体的数值,该数值用于描述主设备向从设备发送连接状态测试请求的次数,在设备列表中,每个从设备都对应一个连接状态标识,该连接状态标识用于描述主设备向该从设备发送连接状态测试请求的次数。As a possible implementation manner of the embodiment, the connection status identifier may be a specific value, where the value is used to describe the number of times the master device sends a connection status test request to the slave device. In the device list, each slave device corresponds to one. A connection status identifier, which is used to describe the number of times the master device sends a connection status test request to the slave device.
当主设备检测到用于测试从设备连接状态的第二预设指令,则依次向从设备列表中的所有从设备的IP地址,发送连接状态测试请求。针对每个从设备,主设备在向从设备的IP地址发送连接状态测试请求后,修改该从设备在从设备列表中的连接状态标识,即对连接状态标识对应的数值进行减一操作。当主设备接收到目标信息,且连接状态标识所表征的数值不为0时,则确定从设备的连接状态为正常;当主设备未接收目标信息,且连接状态标识所表征的数值为0时,则确定所述从设备的连接状态为异常。When the master device detects the second preset instruction for testing the slave device connection state, the connection state test request is sequentially sent to the IP addresses of all the slave devices in the slave device list. For each slave device, after the master device sends a connection state test request to the IP address of the slave device, the master device modifies the connection state identifier in the slave device list, that is, performs a subtraction operation on the value corresponding to the connection state identifier. When the master device receives the target information, and the value represented by the connection status identifier is not 0, it determines that the connection status of the slave device is normal; when the master device does not receive the target information, and the value represented by the connection status identifier is 0, then It is determined that the connection status of the slave device is abnormal.
进一步地,当主设备未接收目标信息,且连接状态标识所表征的数值为0时,则确定所述从设备的连接状态为异常,具体还可以包括:当主设备未接收目标信息时,监听第二UDP套接字所描述的第二端口是否被启用,若第二端口被禁止,则启用第二端口接收目标信息;当主设备未接收目标信息,且第二端口处于启用状态,连接状态标识所表征的数值为0时,则确定所述从设备的连接状态为异常。Further, when the master device does not receive the target information, and the value represented by the connection state identifier is 0, determining that the connection state of the slave device is abnormal, the method may further include: when the master device does not receive the target information, listening to the second Whether the second port described by the UDP socket is enabled, if the second port is disabled, the second port is enabled to receive the target information; when the primary device does not receive the target information, and the second port is enabled, the connection status identifier is characterized When the value is 0, it is determined that the connection status of the slave device is abnormal.
以上可以看出,本发明实施例提供的一种局域网设备的搜索方法,通过主设备在检测到用于搜索从设备的第一预设指令时,获取所在局域网的广播地址,主设备向局域网的广播地址发送设备搜索请求,以使设备搜索请求在局域网中被广播,由从设备根据设备搜索请求向主设备返回从设备信息,简化了局域网设备的搜索步骤。It can be seen that, in the search method of the local area network device, the host device obtains the broadcast address of the local area network when the master device detects the first preset instruction for searching the slave device, and the master device sends the local area network to the local area network. The broadcast address transmitting device searches for a request to cause the device search request to be broadcast in the local area network, and the slave device returns the slave device information to the master device according to the device search request, simplifying the search step of the local area network device.
通过依次向从设备列表中的所有从设备的IP地址,发送连接状态测试请求,从设备若接收到连接状态测试请求,则根据连接状态测试请求,通过通信端口,向主设备返回目标信息,使得主设备在搜索到局域网内的从设备后,能够及时更新局域网内从设备的在线情况,也即及时更新搜索到的局域网设备的信息。By sequentially transmitting a connection status test request to the IP addresses of all the slave devices in the slave device list, if the slave device receives the connection state test request, the slave device returns the target information to the master device through the communication port according to the connection state test request. After searching for the slave devices in the local area network, the master device can update the online status of the slave devices in the local area network in time, that is, timely update the information of the searched local area network devices.
参见图3,图3是本发明实施例提供的一种局域网设备的搜索系统的结构示意图。本实施例的一种局域网设备的搜索系统2包括:主设备21和从设备集群22,其中,从设备集群22中包括多个从设备221。Referring to FIG. 3, FIG. 3 is a schematic structural diagram of a search system of a local area network device according to an embodiment of the present invention. The search system 2 of the local area network device of the present embodiment includes: a master device 21 and a slave device cluster 22, wherein the slave device cluster 22 includes a plurality of slave devices 221.
主设备21,用于若检测到用于搜索从设备的第一预设指令,则获取所在局域网的广播地址。The master device 21 is configured to acquire a broadcast address of a local area network if the first preset instruction for searching for the slave device is detected.
主设备21还用于,向所述局域网的广播地址发送设备搜索请求,以使所述设备搜索请求在所述局域网中被广播。The master device 21 is further configured to send a device search request to a broadcast address of the local area network to cause the device search request to be broadcasted in the local area network.
从设备221,用于根据所述设备搜索请求向所述主设备返回从设备信息。The slave device 221 is configured to return the slave device information to the master device according to the device search request.
进一步,从设备信息包括所述从设备的网际协议IP地址、通信端口以及连接状态标识。Further, the slave device information includes an internet protocol IP address, a communication port, and a connection state identifier of the slave device.
进一步,作为本实施例一种可能的实现方式,主设备21还用于,根据所述从设备信息生成从设备列表,所述从设备列表中的数据用于描述所述从设备、所述从设备的IP地址、所述通信端口以及所述连接状态标识之间的对应关系。Further, as a possible implementation manner of the embodiment, the master device 21 is further configured to generate, according to the slave device information, a slave device list, where the data in the slave device list is used to describe the slave device, the slave device Correspondence between the IP address of the device, the communication port, and the connection status identifier.
主设备21还用于,若检测到用于测试所述从设备连接状态的第二预设指令,则依次向所述从设备列表中的所有所述从设备的IP地址,发送连接状态测试请求。The master device 21 is further configured to: if the second preset instruction for testing the connection state of the slave device is detected, send a connection state test request to the IP addresses of all the slave devices in the slave device list in sequence .
从设备221还用于,若接收到所述连接状态测试请求,则根据所述连接状态测试请求,通过所述通信端口,向所述主设备返回目标信息。The slave device 221 is further configured to: if the connection state test request is received, return the target information to the master device through the communication port according to the connection state test request.
主设备21若接收到所述目标信息,则确定所述从设备的连接状态为正常。Upon receiving the target information, the master device 21 determines that the connection state of the slave device is normal.
主设备21若未接收到所述目标信息,则确定所述从设备的连接状态为异常。If the master device 21 does not receive the target information, it determines that the connection state of the slave device is abnormal.
进一步,作为本实施例一种可能的实现方式,主设备21具体用于,基于所述广播地址创建第一用户数据报协议UDP套接字,并通过所述第一UDP套接字描述的第一端口,向所述广播地址发送连接状态测试请求。Further, as a possible implementation manner of the embodiment, the master device 21 is specifically configured to: create a first user datagram protocol UDP socket based on the broadcast address, and describe the first UDP socket by using the first UDP socket A port sends a connection status test request to the broadcast address.
进一步,作为本实施例一种可能的实现方式,主设备21具体用于,基于所述从设备的IP地址,创建第二UDP套接字,并通过所述第二UDP套接字描述的第二端口向所述从设备发送连接状态测试请求,所述连接状态测试请求携带有所述第二端口的地址信息。Further, as a possible implementation manner of the embodiment, the master device 21 is specifically configured to create a second UDP socket based on the IP address of the slave device, and describe the second UDP socket by using the second UDP socket. The two ports send a connection status test request to the slave device, where the connection status test request carries address information of the second port.
从设备221具体用于,根据所述地址信息,通过所述通信端口向所述第二端口返回目标信息。The slave device 221 is specifically configured to return target information to the second port through the communication port according to the address information.
以上可以看出,本发明实施例提供的一种局域网设备的搜索方法,通过主设备在检测到用于搜索从设备的第一预设指令时,获取所在局域网的广播地址,主设备向局域网的广播地址发送设备搜索请求,以使设备搜索请求在局域网中被广播,由从设备根据设备搜索请求向主设备返回从设备信息,简化了局域网设备的搜索步骤。It can be seen that, in the search method of the local area network device, the host device obtains the broadcast address of the local area network when the master device detects the first preset instruction for searching the slave device, and the master device sends the local area network to the local area network. The broadcast address transmitting device searches for a request to cause the device search request to be broadcast in the local area network, and the slave device returns the slave device information to the master device according to the device search request, simplifying the search step of the local area network device.
通过依次向从设备列表中的所有从设备的IP地址,发送连接状态测试请求,从设备若接收到连接状态测试请求,则根据连接状态测试请求,通过通信端口,向主设备返回目标信息,使得主设备被在搜索到局域网内的从设备后,能够及时更新局域网内从设备的在线情况,也即及时更新搜索到的局域网设备的信息。By sequentially transmitting a connection status test request to the IP addresses of all the slave devices in the slave device list, if the slave device receives the connection state test request, the slave device returns the target information to the master device through the communication port according to the connection state test request. After the master device is searched for the slave device in the local area network, it can update the online condition of the slave device in the local area network in time, that is, update the information of the searched local area network device in time.
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应以权利要求的保护范围为准。The above is only the specific embodiment of the present invention, but the scope of the present invention is not limited thereto, and any equivalent person can be easily conceived within the technical scope of the present invention by any person skilled in the art. Modifications or substitutions are intended to be included within the scope of the invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims (10)
- 一种局域网设备的搜索方法,其特征在于,所述搜索方法包括:A search method for a local area network device, characterized in that the search method comprises:主设备若检测到用于搜索从设备的第一预设指令,则获取所在局域网的广播地址;If the master device detects the first preset instruction for searching for the slave device, acquiring the broadcast address of the local area network;所述主设备向所述局域网的广播地址发送设备搜索请求,以使所述设备搜索请求在所述局域网中被广播;Sending, by the master device, a device search request to a broadcast address of the local area network, so that the device search request is broadcasted in the local area network;所述从设备根据所述设备搜索请求向所述主设备返回从设备信息。The slave device returns slave device information to the master device according to the device search request.
- 如权利要求1所述的搜索方法,其特征在于,所述从设备信息包括所述从设备的网际协议IP地址、通信端口以及连接状态标识。The search method according to claim 1, wherein said slave device information comprises an internet protocol IP address, a communication port, and a connection state identifier of said slave device.
- 如权利要求2所述的搜索方法,其特征在于,所述搜索方法还包括:The search method of claim 2, wherein the searching method further comprises:所述主设备根据所述从设备信息生成从设备列表,所述从设备列表中的数据用于描述所述从设备、所述从设备的IP地址、所述通信端口以及所述连接状态标识之间的对应关系;The master device generates a slave device list according to the slave device information, where the data in the slave device list is used to describe the slave device, an IP address of the slave device, the communication port, and the connection state identifier. Correspondence between所述主设备若检测到用于测试所述从设备连接状态的第二预设指令,则依次向所述从设备列表中的所有所述从设备的IP地址,发送连接状态测试请求;If the master device detects a second preset instruction for testing the connection state of the slave device, sending a connection state test request to the IP addresses of all the slave devices in the slave device list in sequence;所述从设备若接收到所述连接状态测试请求,则根据所述连接状态测试请求,通过所述通信端口,向所述主设备返回目标信息;Receiving, by the slave device, the connection state test request, returning target information to the master device through the communication port according to the connection state test request;所述主设备若接收到所述目标信息,则确定所述从设备的连接状态为正常;If the master device receives the target information, determining that the connection status of the slave device is normal;所述主设备若未接收到所述目标信息,则确定所述从设备的连接状态为异常。If the master device does not receive the target information, it determines that the connection state of the slave device is abnormal.
- 如权利要求1所述的搜索方法,其特征在于,所述所述主设备向所述局域网的广播地址发送设备搜索请求,以使所述设备搜索请求在所述局域网中被广播,包括:The search method according to claim 1, wherein the master device sends a device search request to the broadcast address of the local area network, so that the device search request is broadcasted in the local area network, including:所述主设备基于所述广播地址创建第一用户数据报协议UDP套接字,并通过所述第一UDP套接字描述的第一端口,向所述广播地址发送连接状态测试请求。The master device creates a first user datagram protocol UDP socket based on the broadcast address, and sends a connection state test request to the broadcast address through the first port described by the first UDP socket.
- 如权利要求3所述的搜索方法,其特征在于,所述主设备若检测到用于测试所述从设备连接状态的第二预设指令,则依次向所述从设备列表中的所有所述从设备的IP地址,发送连接状态测试请求,包括:The search method according to claim 3, wherein if the master device detects a second preset instruction for testing the connection state of the slave device, it sequentially goes to all of the slave device lists. Send a connection status test request from the IP address of the device, including:所述主设备基于所述从设备的IP地址,创建第二UDP套接字,并通过所述第二UDP套接字描述的第二端口向所述从设备发送连接状态测试请求,所述连接状态测试请求携带有所述第二端口的地址信息;The master device creates a second UDP socket based on the IP address of the slave device, and sends a connection state test request to the slave device through the second port described by the second UDP socket, the connection The status test request carries the address information of the second port;所述从设备若接收到所述连接状态测试请求,则根据所述连接状态测试请求,通过所述通信端口,向所述主设备返回目标信息,包括:And if the slave device receives the connection state test request, returning target information to the master device by using the communication port according to the connection state test request, including:所述从设备根据所述地址信息,通过所述通信端口向所述第二端口返回目标信息。The slave device returns target information to the second port through the communication port according to the address information.
- 一种局域网设备的搜索系统,其特征在于,所述搜索系统包括:A search system for a local area network device, characterized in that the search system comprises:主设备,用于若检测到用于搜索从设备的第一预设指令,则获取所在局域网的广播地址;a master device, configured to acquire a broadcast address of a local area network if the first preset instruction for searching for the slave device is detected;所述主设备还用于,向所述局域网的广播地址发送设备搜索请求,以使所述设备搜索请求在所述局域网中被广播;The master device is further configured to: send a device search request to a broadcast address of the local area network, so that the device search request is broadcasted in the local area network;所述从设备,用于根据所述设备搜索请求向所述主设备返回从设备信息。The slave device is configured to return slave device information to the master device according to the device search request.
- 如权利要求6所述的搜索系统,其特征在于,所述从设备信息包括所述从设备的网际协议IP地址、通信端口以及连接状态标识。The search system according to claim 6, wherein said slave device information comprises an internet protocol IP address, a communication port, and a connection state identifier of said slave device.
- 如权利要求7所述的搜索系统,其特征在于,The search system of claim 7 wherein:所述主设备还用于,根据所述从设备信息生成从设备列表,所述从设备列表中的数据用于描述所述从设备、所述从设备的IP地址、所述通信端口以及所述连接状态标识之间的对应关系;The master device is further configured to generate, according to the slave device information, a slave device list, where data in the slave device list is used to describe the slave device, an IP address of the slave device, the communication port, and the Correspondence between connection status identifiers;所述主设备还用于,若检测到用于测试所述从设备连接状态的第二预设指令,则依次向所述从设备列表中的所有所述从设备的IP地址,发送连接状态测试请求;The master device is further configured to: if the second preset instruction for testing the connection state of the slave device is detected, send a connection state test to the IP addresses of all the slave devices in the slave device list in sequence request;所述从设备还用于,若接收到所述连接状态测试请求,则根据所述连接状态测试请求,通过所述通信端口,向所述主设备返回目标信息;The slave device is further configured to: if the connection state test request is received, return the target information to the master device by using the communication port according to the connection state test request;所述主设备若接收到所述目标信息,则确定所述从设备的连接状态为正常;If the master device receives the target information, determining that the connection status of the slave device is normal;所述主设备若未接收到所述目标信息,则确定所述从设备的连接状态为异常。If the master device does not receive the target information, it determines that the connection state of the slave device is abnormal.
- 如权利要求6所述的搜索系统,其特征在于,所述主设备具体用于,基于所述广播地址创建第一用户数据报协议UDP套接字,并通过所述第一UDP套接字描述的第一端口,向所述广播地址发送连接状态测试请求。The search system according to claim 6, wherein the master device is specifically configured to: create a first user datagram protocol UDP socket based on the broadcast address, and describe by using the first UDP socket The first port sends a connection status test request to the broadcast address.
- 如权利要求8所述的搜索系统,其特征在于,所述主设备具体用于,基 于所述从设备的IP地址,创建第二UDP套接字,并通过所述第二UDP套接字描述的第二端口向所述从设备发送连接状态测试请求,所述连接状态测试请求携带有所述第二端口的地址信息;The search system according to claim 8, wherein the master device is specifically configured to: create a second UDP socket based on an IP address of the slave device, and describe the second UDP socket by using the second UDP socket The second port sends a connection status test request to the slave device, where the connection status test request carries address information of the second port;所述从设备具体用于,根据所述地址信息,通过所述通信端口向所述第二端口返回目标信息。The slave device is specifically configured to return target information to the second port by using the communication port according to the address information.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810167835.4A CN108521437A (en) | 2018-02-28 | 2018-02-28 | A kind of searching method and search system of lan device |
CN201810167835.4 | 2018-02-28 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2019165775A1 true WO2019165775A1 (en) | 2019-09-06 |
Family
ID=63433320
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2018/104615 WO2019165775A1 (en) | 2018-02-28 | 2018-09-07 | Local area network equipment searching method and searching system |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN108521437A (en) |
WO (1) | WO2019165775A1 (en) |
Families Citing this family (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111294375B (en) * | 2018-12-07 | 2022-11-25 | 浙江宇视科技有限公司 | Monitoring equipment connection method and device |
CN110351300A (en) * | 2019-07-25 | 2019-10-18 | 深圳康佳电子科技有限公司 | SAMBA equipment access processing method, main equipment, system and storage medium |
CN111654394B (en) * | 2020-05-26 | 2022-11-22 | 浙江大华技术股份有限公司 | Method and device for searching equipment, computing equipment and storage medium |
CN111835882B (en) * | 2020-07-01 | 2023-03-03 | 上海橙群微电子有限公司 | Device address list acquisition method, network device and readable storage medium |
CN111917902B (en) * | 2020-08-10 | 2023-05-09 | 卡车司机(北京)科技有限公司 | Method, apparatus and computer readable storage medium for detecting failure of pound room equipment |
CN112261345A (en) * | 2020-09-23 | 2021-01-22 | 厦门亿联网络技术股份有限公司 | Automatic factory pairing and online method for video conference system equipment |
CN112311790A (en) * | 2020-10-28 | 2021-02-02 | 深圳前海茂佳软件科技有限公司 | Multimedia terminal determining method, connecting method, test terminal and storage medium |
WO2022246803A1 (en) * | 2021-05-28 | 2022-12-01 | 华为技术有限公司 | Access method and communication apparatus |
CN113794994B (en) * | 2021-08-26 | 2023-02-24 | 珠海格力电器股份有限公司 | Information gathering method and device based on multicast domain name system and application thereof |
CN117354161A (en) * | 2023-09-25 | 2024-01-05 | 北京津发科技股份有限公司 | Multi-terminal communication method and collaboration system based on virtual reality model |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1547366A (en) * | 2003-12-03 | 2004-11-17 | 何世刚 | Automatic addressing method for electronic instruments and application |
CN1805395A (en) * | 2005-01-11 | 2006-07-19 | 精工爱普生株式会社 | System, method and program for searching connectable terminals in a radio lan system |
CN102413567A (en) * | 2010-09-22 | 2012-04-11 | 株式会社山武 | Radio communication system |
US20140128122A1 (en) * | 2012-11-08 | 2014-05-08 | Samsung Electronics Co., Ltd. | Assistant method and system for retrieving wireless signals for mobile devices |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080232370A1 (en) * | 2007-03-20 | 2008-09-25 | Ching Hsiang Lee | Method of communication in LAN without setting IP |
CN101478775B (en) * | 2009-01-20 | 2011-02-23 | 中兴通讯股份有限公司 | Detection method, system and equipment for multi-neighbor connection state |
CN106559288B (en) * | 2016-11-23 | 2019-11-12 | 北京航天自动控制研究所 | A Fast Fault Detection Method Based on ICMP Message |
-
2018
- 2018-02-28 CN CN201810167835.4A patent/CN108521437A/en active Pending
- 2018-09-07 WO PCT/CN2018/104615 patent/WO2019165775A1/en active Application Filing
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1547366A (en) * | 2003-12-03 | 2004-11-17 | 何世刚 | Automatic addressing method for electronic instruments and application |
CN1805395A (en) * | 2005-01-11 | 2006-07-19 | 精工爱普生株式会社 | System, method and program for searching connectable terminals in a radio lan system |
CN102413567A (en) * | 2010-09-22 | 2012-04-11 | 株式会社山武 | Radio communication system |
US20140128122A1 (en) * | 2012-11-08 | 2014-05-08 | Samsung Electronics Co., Ltd. | Assistant method and system for retrieving wireless signals for mobile devices |
Also Published As
Publication number | Publication date |
---|---|
CN108521437A (en) | 2018-09-11 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2019165775A1 (en) | Local area network equipment searching method and searching system | |
CN113630312B (en) | Path detection method, path detection device, network equipment and computer readable storage medium | |
US9042272B2 (en) | Distributed proxy addressing operations | |
CA3010741A1 (en) | Method and system for automatically bypassing network proxies in the presence of interdependent traffic flows | |
JP5612468B2 (en) | Method and apparatus for communication of diagnostic data in a real-time communication network | |
US20180205644A1 (en) | Communication processing method and apparatus | |
CN104852840A (en) | Method and device for controlling mutual access between virtual machines | |
CN107113892A (en) | A kind of method and device of gateway device automatic network-building | |
JP2010531602A5 (en) | ||
CN105917617A (en) | Single hop overlay architecture for line rate performance in campus networks | |
JP5018969B2 (en) | COMMUNICATION CONTROL PROGRAM, COMMUNICATION CONTROL DEVICE, COMMUNICATION CONTROL SYSTEM, AND COMMUNICATION CONTROL METHOD | |
CN107888711B (en) | Cross-network-segment equipment searching and communication method | |
CN106230667B (en) | VTEP keep-alive detection method and device | |
US9893979B2 (en) | Network topology discovery by resolving loops | |
JP2008148243A (en) | Communication apparatus, communication system, communication method and communication program | |
US10148515B2 (en) | Determining connections of non-external network facing ports | |
CN109842692B (en) | VxLAN switch, system and method for obtaining host information in physical network | |
JP5333793B2 (en) | Topology specifying method and topology specifying device | |
US20160344571A1 (en) | Determining Connections Between Disconnected Partial Trees | |
JP5190717B2 (en) | Topology specifying method and topology specifying device | |
JP5673133B2 (en) | MAC search system and MAC search method for MPLS-TP device | |
US11283755B2 (en) | Method for identifying a communication node | |
JP2010098429A (en) | Network switching device, network switching device network switching apparatus, method and program for controlling the same | |
WO2015184979A1 (en) | Methods and devices for processing packet, sending information, and receiving information | |
WO2015188706A1 (en) | Data frame processing method, device and system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 18908214 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 20/01/2021) |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 18908214 Country of ref document: EP Kind code of ref document: A1 |