CN106470234B - Equipment discovery method and device - Google Patents

Equipment discovery method and device Download PDF

Info

Publication number
CN106470234B
CN106470234B CN201510514960.4A CN201510514960A CN106470234B CN 106470234 B CN106470234 B CN 106470234B CN 201510514960 A CN201510514960 A CN 201510514960A CN 106470234 B CN106470234 B CN 106470234B
Authority
CN
China
Prior art keywords
network
network address
packet
equipment
port number
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201510514960.4A
Other languages
Chinese (zh)
Other versions
CN106470234A (en
Inventor
左洪涛
王志华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Beijing Co Ltd
Original Assignee
Tencent Technology Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Beijing Co Ltd filed Critical Tencent Technology Beijing Co Ltd
Priority to CN201510514960.4A priority Critical patent/CN106470234B/en
Publication of CN106470234A publication Critical patent/CN106470234A/en
Application granted granted Critical
Publication of CN106470234B publication Critical patent/CN106470234B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/51Discovery or management thereof, e.g. service location protocol [SLP] or web services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/2803Home automation networks
    • H04L12/2807Exchanging configuration information on appliance services in a home automation network
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/12Discovery or management of network topologies
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/16Multipoint routing

Abstract

The invention discloses a device discovery method and device, and belongs to the field of communication. The method comprises the following steps: acquiring a network address of first equipment; acquiring a network address included in a network segment where the first equipment is located according to the network address of the first equipment; sending a network packet according to a first network address, wherein the first network address is any network address included in the network segment, and the network packet at least comprises discovery identification information, a network address and a port number of the first device; receiving a response packet sent by a second device, where the second device is a device corresponding to the first network address, the response packet is sent by the second device according to the discovery identification information, the network address of the first device, and the port number included in the network packet after the second device receives the network packet, and the response packet includes the network address and the port number of the second device. The invention can still discover the equipment under the condition that the router does not support multicast.

Description

Equipment discovery method and device
Technical Field
The present invention relates to the field of communications, and in particular, to a method and an apparatus for device discovery.
Background
With the popularization of smart phones and smart televisions, multi-screen interaction is widely applied to our lives. The multi-screen interaction is often applicable to a local area network, and the device needs to have a capability of device discovery, that is, the device needs to discover other devices in the local area network and then perform multi-screen interaction with the other devices.
The existing device discovery technology is based on multicast technology to discover devices, and the specific discovery process is as follows: when a device starts a device discovery function, the device sends a multicast command to a router of a local area network where the device is located, wherein the multicast command carries an IP (Internet Protocol, Protocol for interconnection between networks) address and a port number of the device; the router receives the multicast command and multicasts a multicast message to other equipment in the local area network, wherein the multicast message carries the IP address and the port number of the equipment; each other device receives the multicast message, and sends a network packet to the device according to the IP address and the port number of the device included in the multicast message, wherein the network packet carries the IP address and the port number of the other device; the device receives the network packet to discover the other device.
In the process of implementing the invention, the inventor finds that the prior art has at least the following problems:
at present, not all routers support the multicast technology, and when a router corresponding to a local area network where a device is located does not support the multicast technology, the device cannot discover the device by using the above scheme.
Disclosure of Invention
In order to solve the problems in the prior art, the invention provides a device discovery method and a device discovery device. The technical scheme is as follows:
a method of device discovery, the method comprising:
acquiring a network address of first equipment;
acquiring a network address included in a network segment where the first equipment is located according to the network address of the first equipment;
sending a network packet according to a first network address, wherein the first network address is any network address included in the network segment, and the network packet at least comprises discovery identification information, a network address and a port number of the first device;
receiving a response packet sent by a second device, where the second device is a device corresponding to the first network address, the response packet is sent by the second device according to the discovery identification information, the network address of the first device, and the port number included in the network packet after the second device receives the network packet, and the response packet includes the network address and the port number of the second device.
An apparatus of device discovery, the apparatus comprising:
the acquisition module is used for acquiring the network address of the first equipment; acquiring a network address included in a network segment where the first equipment is located according to the network address of the first equipment;
a sending module, configured to send a network packet according to a first network address, where the first network address is any network address included in the network segment, and the network packet at least includes discovery identification information, a network address and a port number of the first device;
a receiving module, configured to receive a response packet sent by a second device, where the second device is a device corresponding to the first network address, the response packet is sent by the second device according to the discovery identification information, the network address of the first device, and the port number included in the network packet after the second device receives the network packet, and the response packet includes the network address and the port number of the second device.
In the embodiment of the invention, the network address included in the network segment where the first device is located is obtained according to the network address of the first device. And sending a network packet according to the first network address, wherein the first network address is any network address included in the network segment, and after receiving the network packet, receiving a response packet sent by the second device, wherein the response packet includes the network address and the port number of the second device, so that the second device is discovered. Because the first device respectively unicasts network packets to each network address included in the network segment, if the network address corresponds to a device, the first device receives a response packet sent by the device to discover the device, so that the device in the local area network can be discovered even if the router of the local area network where the first device is located does not support the multicast technology.
Drawings
Fig. 1 is a flowchart of a method for device discovery according to embodiment 1 of the present invention;
fig. 2 is a flowchart of a method for device discovery according to embodiment 2 of the present invention;
fig. 3 is a device discovery networking diagram provided in embodiment 2 of the present invention;
fig. 4 is a schematic structural diagram of an apparatus for device discovery according to embodiment 3 of the present invention;
fig. 5 is a schematic structural diagram of an apparatus provided in embodiment 4 of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail with reference to the accompanying drawings.
Example 1
Referring to fig. 1, an embodiment of the present invention provides a device discovery method, including:
step 101: a network address of a first device is obtained.
Step 102: and acquiring the network address included in the network segment where the first equipment is located according to the network address of the first equipment.
Step 103: and sending a network packet according to the first network address, wherein the first network address is any network address included in the network segment, and the network packet at least comprises discovery identification information, the network address and the port number of the first device.
Step 104: and receiving a response packet sent by the second device, wherein the second device is a device corresponding to the first network address, the response packet is sent by the second device according to the discovery identification information, the network address and the port number of the first device, which are included in the network packet, after the second device receives the network packet, and the response packet includes the network address and the port number of the second device.
In the embodiment of the invention, the network address included in the network segment where the first device is located is obtained according to the network address of the first device. And sending a network packet according to the first network address, wherein the first network address is any network address included in the network segment, and after receiving the network packet, receiving a response packet sent by the second device, wherein the response packet includes the network address and the port number of the second device, so that the second device is discovered. Because the first device respectively unicasts network packets to each network address included in the network segment, if the network address corresponds to a device, the first device receives a response packet sent by the device to discover the device, so that the device in the local area network can be discovered even if the router of the local area network where the first device is located does not support the multicast technology.
Example 2
Referring to fig. 2, an embodiment of the present invention provides a device discovery method, including:
step 201: the first device acquires its own network address.
The network address of the first device may be an IP address of the first device, and in the embodiment of the present invention, the network address of the first device is taken as an example of the IP address of the first device, which is not intended to limit the scope of the present invention. Currently, an IP address is a 32-bit binary number, which is typically divided into 4 8-bit binary numbers. IP addresses are typically represented in dot decimal form as a.b.c.d, where a, b, c, d are decimal integers between 0 and 255. For example, the dotted decimal IP address 100.4.5.6 is actually a 32-bit binary number 01100100.00000100.00000101.00000110.
Step 202: the first device obtains the network address included in the network segment where the first device is located according to the network address of the first device.
The step has the following two realization modes, including:
the first device extracts the binary number of the preset numerical digits from the network address of the first device to obtain the network segment where the first device is located, and acquires each network address included in the network segment.
For example, assuming that the network address of the first device is 100.4.5.6, the corresponding binary form is 01100100.00000100.00000101.00000110, and the preset value is 24, the first device extracts the first 24-bit binary number from its network address 01100100.00000100.00000101.00000110, the extracted binary number is 01100100.00000100.00000101, the corresponding decimal form is 100.4.5, and the decimal number 100.4.5 is the network segment where the first device is located, which includes 256 network addresses, 100.4.5.0 to 100.4.5.255 respectively.
And the second equipment acquires the subnet mask of the first equipment, determines the network segment where the first equipment is located according to the network address of the first equipment and the subnet mask, and acquires each network address included by the network segment.
The subnet mask of the first device is a type of subnet mask that is used to indicate which bits of the network address of the first device identify the network segment on which the first device is located and which bits identify the first device. The subnet mask of the first device is used for dividing the network address of the first device into two parts, namely the address of the network segment where the first device is located and the host address of the first device.
The first device multiplies the subnet mask of the first device by the network address to obtain the network segment where the first device is located. For example, assume that the subnet mask of the first device is 255.255.255.0 and the network address of the first device is 100.4.5.6; multiplying the subnet mask 255.255.255.0 by the network address 100.4.5.6 to obtain a network segment 100.4.5 where the first device is located, where the network segment 100.4.5 includes 256 network addresses 100.4.5.0 to 100.4.5.255.
Step 203: the first device sends a network packet according to a first network address, wherein the first network address is any network address included in a network segment where the first device is located, and the network packet includes discovery indication information, a network address and a port number of the first device.
The network segment where the first device is located has devices corresponding to part of the network address, and also has devices not corresponding to part of the network address, that is, the first network address may have corresponding devices, or may not have corresponding devices.
The source address and the source port number of the network packet are respectively a network address and a port number of the first device, and the destination address is a first network address. If the first network address has the corresponding network device, the network packet is routed to the device corresponding to the first network address by the network after the first device sends the network packet.
Further, the network packet may further include capability information of the first device, where the capability information of the first device is used to indicate that the first device has device capabilities. For example, the device capabilities of the first device may be a function to play audio, a function to play video, and so on.
For example, the network segment where the first device is located includes 256 network addresses, which are 100.4.5.0 to 100.4.5.255, respectively, and it is assumed that the first network address is 100.4.5.0, the network address of the first device is 100.4.5.6, and the port number is 3; the first network device sends a network packet according to the first network address 100.4.5.0, the network packet includes the discovery indication information, and the source address and the source port number of the network packet are the network address 100.4.5.6 and the port number 3 of the first device, respectively, and the destination address is the first network address 100.4.5.0.
In this embodiment, it is assumed that the first network address corresponds to a device, and for convenience of description, the device corresponding to the first network address is referred to as a second device, and the second device performs the following steps.
Step 204: the second device receives the network packet sent by the first device, determines that the network packet is used for discovering the device according to the discovery indication information included in the network packet, and then performs step 205.
For example, assume that the first network address 100.4.5.0 has a corresponding second device, the second device receives the network packet, extracts the discovery indication information from the network packet, and determines that the network packet is for discovering the device based on the discovery indication information.
Step 205: and the second equipment sends a response packet to the first equipment according to the network address of the first equipment, wherein the response packet comprises the network address and the port number of the second equipment.
The second device extracts the network address and the port number of the first device from the network packet, acquires the network address of the second device and selects a port from the ports included in the second device, and then sends a response packet according to the network address of the first device, wherein the source address and the source port number of the response packet are respectively the network address of the second device and the port number selected by the second device, and the destination address and the destination port number are respectively the network address and the port number of the first network device.
For example, the second device extracts the network address 100.4.5.6 and the port number 3 of the first device from the network packet, acquires its own network address 100.4.5.0 and selects a port with the port number 2 from its own ports, and then sends a response packet to the first device according to the address 100.4.5.0 of the first device, where the source address and the source port number of the response packet are the network address 100.4.5.0 and the selected port number 2 of the second device, respectively, and the destination address and the destination port number are the network address 100.4.5.6 and the port number 3 of the first device, respectively.
Further, when the network packet further includes the capability information of the first device, the second device determines the device capability of the first device according to the capability information of the first device, determines whether the device capability included in the second device includes the device capability of the first device, and if so, sends a response packet to the first device.
Step 206: and the first device receives the response packet sent by the second device to realize the discovery of the second device.
And the first device extracts the network address and the port number of the second device from the received response packet, so as to realize the discovery of the second device.
Wherein, for each other network address included in the network segment, the steps 203 to 206 are respectively executed as the first network address. For example, referring to fig. 3, the first device also sends network packets to network addresses 100.4.5.1, 100.4.5.2 … … 100.4.5.255, respectively.
In the embodiment of the invention, the network address included in the network segment where the first device is located is obtained according to the network address of the first device. And sending a network packet according to the first network address, wherein the first network address is any network address included in the network segment, and after receiving the network packet, receiving a response packet sent by the second device, wherein the response packet includes the network address and the port number of the second device, so that the second device is discovered. Because the first device respectively unicasts network packets to each network address included in the network segment, if the network address corresponds to a device, the first device receives a response packet sent by the device to discover the device, so that the device in the local area network can be discovered even if the router of the local area network where the first device is located does not support the multicast technology.
Example 3
Referring to fig. 4, an apparatus for device discovery according to an embodiment of the present invention includes:
an obtaining module 301, configured to obtain a network address of a first device; acquiring a network address included in a network segment where the first equipment is located according to the network address of the first equipment;
a sending module 302, configured to send a network packet according to a first network address, where the first network address is any network address included in the network segment, and the network packet at least includes discovery identification information, a network address and a port number of the first device;
a receiving module 303, configured to receive a response packet sent by a second device, where the second device is a device corresponding to the first network address, the response packet is sent by the second device according to the discovery identification information, the network address of the first device, and the port number included in the network packet after the second device receives the network packet, and the response packet includes the network address and the port number of the second device.
Optionally, the obtaining module 301 includes:
a first obtaining unit, configured to obtain a subnet mask of the first device;
a determining unit, configured to determine, according to the subnet mask and the network address of the first device, a network segment where the first device is located;
and the second obtaining unit is used for obtaining the network address included in the network segment where the first equipment is located.
Optionally, the network packet further includes capability information of the first device, where the capability information is used to discover a device including device capabilities of the first network device.
Further, the apparatus further comprises a determination module;
the receiving module is further configured to receive a network packet sent by a third device, where the network packet includes discovery indication information, a network address and a port number of the third device;
the determining module is configured to determine that the network packet is used for discovering a device according to the discovery indication information;
the sending module is further configured to send a response packet to a third device according to a network address of the third device, where the response packet includes the network address and the port number of the first device.
Optionally, the network packet further includes capability information of the third device;
the determining module is further configured to determine whether the first device includes the device capability corresponding to the capability information of the third device, and if so, execute the operation of sending a response packet to the third device according to the network address of the third device.
In the embodiment of the invention, the network address included in the network segment where the first device is located is obtained according to the network address of the first device. And sending a network packet according to the first network address, wherein the first network address is any network address included in the network segment, and after receiving the network packet, receiving a response packet sent by the second device, wherein the response packet includes the network address and the port number of the second device, so that the second device is discovered. Because the first device respectively unicasts network packets to each network address included in the network segment, if the network address corresponds to a device, the first device receives a response packet sent by the device to discover the device, so that the device in the local area network can be discovered even if the router of the local area network where the first device is located does not support the multicast technology.
Example 4
Referring to fig. 5, fig. 5 is a schematic diagram illustrating a device structure according to an embodiment of the present invention, for implementing the device discovery method provided in the foregoing embodiment. Specifically, the method comprises the following steps:
device 900 may include RF (Radio Frequency) circuitry 110, memory 120 including one or more computer-readable storage media, input unit 130, display unit 140, sensor 150, audio circuitry 160, WiFi (wireless fidelity) module 170, processor 180 including one or more processing cores, and power supply 190. Those skilled in the art will appreciate that the configuration of the apparatus shown in fig. 5 is not intended to be limiting of the apparatus and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components. Wherein:
the RF circuit 110 may be used for receiving and transmitting signals during information transmission and reception or during a call, and in particular, receives downlink information from a base station and then sends the received downlink information to the one or more processors 180 for processing; in addition, data relating to uplink is transmitted to the base station. In general, the RF circuitry 110 includes, but is not limited to, an antenna, at least one Amplifier, a tuner, one or more oscillators, a Subscriber Identity Module (SIM) card, a transceiver, a coupler, an LNA (Low Noise Amplifier), a duplexer, and the like. In addition, the RF circuitry 110 may also communicate with networks and other devices via wireless communications. The wireless communication may use any communication standard or protocol, including but not limited to GSM (Global System for Mobile communications), GPRS (General Packet Radio Service), CDMA (Code Division Multiple Access), WCDMA (Wideband Code Division Multiple Access), LTE (Long Term Evolution), email, SMS (Short Messaging Service), and the like.
The memory 120 may be used to store software programs and modules, and the processor 180 executes various functional applications and data processing by operating the software programs and modules stored in the memory 120. The memory 120 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the stored data area may store data created from use of the device 900 (e.g., audio data, a phonebook, etc.), and the like. Further, the memory 120 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory 120 may further include a memory controller to provide the processor 180 and the input unit 130 with access to the memory 120.
The input unit 130 may be used to receive input numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control. In particular, the input unit 130 may include a touch-sensitive surface 131 as well as other input devices 132. The touch-sensitive surface 131, also referred to as a touch display screen or a touch pad, may collect touch operations by a user on or near the touch-sensitive surface 131 (e.g., operations by a user on or near the touch-sensitive surface 131 using a finger, a stylus, or any other suitable object or attachment), and drive the corresponding connection device according to a predetermined program. Alternatively, the touch sensitive surface 131 may comprise two parts, a touch detection means and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 180, and can receive and execute commands sent by the processor 180. Additionally, the touch-sensitive surface 131 may be implemented using various types of resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch-sensitive surface 131, the input unit 130 may also include other input devices 132. In particular, other input devices 132 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.
The display unit 140 may be used to display information input by or provided to a user and various graphical user interfaces of the device 900, which may be made up of graphics, text, icons, video, and any combination thereof. The Display unit 140 may include a Display panel 141, and optionally, the Display panel 141 may be configured in the form of an LCD (Liquid Crystal Display), an OLED (Organic Light-Emitting Diode), or the like. Further, the touch-sensitive surface 131 may cover the display panel 141, and when a touch operation is detected on or near the touch-sensitive surface 131, the touch operation is transmitted to the processor 180 to determine the type of the touch event, and then the processor 180 provides a corresponding visual output on the display panel 141 according to the type of the touch event. Although in FIG. 5, touch-sensitive surface 131 and display panel 141 are shown as two separate components to implement input and output functions, in some embodiments, touch-sensitive surface 131 may be integrated with display panel 141 to implement input and output functions.
The device 900 may also include at least one sensor 150, such as light sensors, motion sensors, and other sensors. Specifically, the light sensor may include an ambient light sensor that may adjust the brightness of the display panel 141 according to the brightness of ambient light, and a proximity sensor that may turn off the display panel 141 and/or the backlight when the device 900 is moved to the ear. As one of the motion sensors, the gravity acceleration sensor can detect the magnitude of acceleration in each direction (generally, three axes), can detect the magnitude and direction of gravity when the mobile phone is stationary, and can be used for applications of recognizing the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer and tapping), and the like; as for other sensors such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., that may also be configured with the device 900, further description is omitted here.
Audio circuitry 160, speaker 161, and microphone 162 may provide an audio interface between a user and device 900. The audio circuit 160 may transmit the electrical signal converted from the received audio data to the speaker 161, and convert the electrical signal into a sound signal for output by the speaker 161; on the other hand, the microphone 162 converts the collected sound signal into an electric signal, converts the electric signal into audio data after being received by the audio circuit 160, and then outputs the audio data to the processor 180 for processing, and then to the RF circuit 110 to be transmitted to, for example, another device, or outputs the audio data to the memory 120 for further processing. The audio circuitry 160 may also include an earbud jack to provide communication of peripheral headphones with the device 900.
WiFi is a short-range wireless transmission technology, and the device 900 can help the user send and receive e-mails, browse web pages, access streaming media, etc. through the WiFi module 170, which provides the user with wireless broadband internet access. Although fig. 5 shows the WiFi module 170, it is understood that it does not belong to the essential constitution of the device 900 and can be omitted entirely as needed within the scope not changing the essence of the invention.
The processor 180 is the control center of the device 900, connects various parts of the entire handset using various interfaces and lines, and performs various functions of the device 900 and processes data by running or executing software programs and/or modules stored in the memory 120 and calling data stored in the memory 120, thereby performing overall monitoring of the handset. Optionally, processor 180 may include one or more processing cores; preferably, the processor 180 may integrate an application processor, which mainly handles operating systems, user interfaces, application programs, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 180.
The device 900 also includes a power supply 190 (e.g., a battery) for powering the various components, which may preferably be logically coupled to the processor 180 via a power management system to manage charging, discharging, and power consumption management functions via the power management system. The power supply 190 may also include any component including one or more of a dc or ac power source, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and the like.
Although not shown, device 900 may also include a camera, a bluetooth module, etc., which are not described in detail herein. Specifically, in this embodiment, the display unit of the device 900 is a touch screen display, the device 900 further includes a memory, and one or more programs, where the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs include instructions for:
acquiring a network address of first equipment;
acquiring a network address included in a network segment where the first equipment is located according to the network address of the first equipment;
sending a network packet according to a first network address, wherein the first network address is any network address included in the network segment, and the network packet at least comprises discovery identification information, a network address and a port number of the first device;
receiving a response packet sent by a second device, where the second device is a device corresponding to the first network address, the response packet is sent by the second device according to the discovery identification information, the network address of the first device, and the port number included in the network packet after the second device receives the network packet, and the response packet includes the network address and the port number of the second device.
Optionally, the obtaining, according to the network address of the first device, the network address included in the network segment where the first device is located includes:
acquiring a subnet mask of the first device;
determining a network segment where the first equipment is located according to the subnet mask and the network address of the first equipment;
and acquiring the network address included in the network segment where the first equipment is located.
Optionally, the network packet further includes capability information of the first device, where the capability information is used to discover a device including device capabilities of the first network device.
Optionally, the method further includes:
receiving a network packet sent by a third device, wherein the network packet comprises discovery indication information, a network address and a port number of the third device;
determining that the network packet is used for discovering the device according to the discovery indication information;
and sending a response packet to the third equipment according to the network address of the third equipment, wherein the response packet comprises the network address and the port number of the first equipment.
Optionally, the network packet further includes capability information of the third device;
before sending a response packet to the third device according to the network address of the third device, the method further includes:
and determining whether the first device comprises the device capability corresponding to the capability information of the third device, and if so, executing the operation of sending a response packet to the third device according to the network address of the third device.
In the embodiment of the invention, the network address included in the network segment where the first device is located is obtained according to the network address of the first device. And sending a network packet according to the first network address, wherein the first network address is any network address included in the network segment, and after receiving the network packet, receiving a response packet sent by the second device, wherein the response packet includes the network address and the port number of the second device, so that the second device is discovered. Because the first device respectively unicasts network packets to each network address included in the network segment, if the network address corresponds to a device, the first device receives a response packet sent by the device to discover the device, so that the device in the local area network can be discovered even if the router of the local area network where the first device is located does not support the multicast technology.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.

Claims (10)

1. A method of device discovery, the method comprising:
acquiring a network address of first equipment;
acquiring a network address included in a network segment where the first equipment is located according to the network address of the first equipment;
sending a network packet according to a first network address, where the first network address is any network address included in the network segment, the network packet at least includes discovery identification information, a network address and a port number of the first device, and the network packet further includes capability information of the first device, where the capability information is used to indicate device capability of the first device;
receiving a response packet sent by a second device under the condition that the device capability of the second device includes the device capability corresponding to the capability information of the first device, where the second device is a device corresponding to the first network address, the second device is configured to receive the network packet, and sending the response packet to the first device according to the network address and the port number of the first device under the condition that it is determined that the device capability of the second device includes the device capability corresponding to the capability information of the first device according to the discovery identification information and the capability information of the first device included in the network packet, where the response packet includes the network address and the port number of the second device.
2. The method of claim 1, wherein the obtaining, according to the network address of the first device, the network address included in the network segment where the first device is located comprises:
acquiring a subnet mask of the first device;
determining a network segment where the first equipment is located according to the subnet mask and the network address of the first equipment;
and acquiring the network address included in the network segment where the first equipment is located.
3. The method of any one of claims 1 to 2, further comprising:
receiving a network packet sent by a third device, wherein the network packet comprises discovery indication information, a network address and a port number of the third device;
determining that the network packet is used for discovering the device according to the discovery indication information;
and sending a response packet to the third equipment according to the network address of the third equipment, wherein the response packet comprises the network address and the port number of the first equipment.
4. The method of claim 3, wherein the network packet further comprises capability information of the third device;
before sending a response packet to the third device according to the network address of the third device, the method further includes:
and determining whether the first device comprises the device capability corresponding to the capability information of the third device, and if so, executing the operation of sending a response packet to the third device according to the network address of the third device.
5. An apparatus of device discovery, the apparatus comprising:
the acquisition module is used for acquiring the network address of the first equipment; acquiring a network address included in a network segment where the first equipment is located according to the network address of the first equipment;
a sending module, configured to send a network packet according to a first network address, where the first network address is any network address included in the network segment, and the network packet at least includes discovery identification information, a network address and a port number of the first device, and the network packet further includes capability information of the first device, where the capability information is used to indicate device capability of the first device;
a receiving module, configured to receive a response packet sent by a second device under a condition that a device capability of the second device includes a device capability corresponding to the capability information of the first device, where the second device is a device corresponding to the first network address, the second device is configured to receive the network packet, and send the response packet to the first device according to the network address and the port number of the first device under a condition that it is determined that the device capability of the second device includes the device capability corresponding to the capability information of the first device according to the discovery identification information and the capability information of the first device included in the network packet, where the response packet includes the network address and the port number of the second device.
6. The apparatus of claim 5, wherein the acquisition module comprises:
a first obtaining unit, configured to obtain a subnet mask of the first device;
a determining unit, configured to determine, according to the subnet mask and the network address of the first device, a network segment where the first device is located;
and the second obtaining unit is used for obtaining the network address included in the network segment where the first equipment is located.
7. The apparatus of any one of claims 5 to 6, further comprising a determination module;
the receiving module is further configured to receive a network packet sent by a third device, where the network packet includes discovery indication information, a network address and a port number of the third device;
the determining module is configured to determine that the network packet is used for discovering a device according to the discovery indication information;
the sending module is further configured to send a response packet to a third device according to a network address of the third device, where the response packet includes the network address and the port number of the first device.
8. The apparatus of claim 7, wherein the network packet further comprises capability information of the third device;
the determining module is further configured to determine whether the first device includes the device capability corresponding to the capability information of the third device, and if so, execute the operation of sending a response packet to the third device according to the network address of the third device.
9. An apparatus comprising a processor and a memory, the memory having stored therein at least one instruction that is loaded and executed by the processor to implement the method of device discovery according to any one of claims 1-4.
10. A computer-readable storage medium having stored therein at least one instruction, which is loaded and executed by a processor, to implement the method of device discovery according to any one of claims 1-4.
CN201510514960.4A 2015-08-20 2015-08-20 Equipment discovery method and device Active CN106470234B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510514960.4A CN106470234B (en) 2015-08-20 2015-08-20 Equipment discovery method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510514960.4A CN106470234B (en) 2015-08-20 2015-08-20 Equipment discovery method and device

Publications (2)

Publication Number Publication Date
CN106470234A CN106470234A (en) 2017-03-01
CN106470234B true CN106470234B (en) 2021-03-26

Family

ID=58229014

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510514960.4A Active CN106470234B (en) 2015-08-20 2015-08-20 Equipment discovery method and device

Country Status (1)

Country Link
CN (1) CN106470234B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109963203B (en) * 2017-12-25 2021-12-07 中国移动通信集团福建有限公司 Video stream conversion and adaptive switching method and device, equipment and medium
CN109167730B (en) * 2018-08-02 2021-09-07 深圳市共进电子股份有限公司 User equipment detection method, device, equipment and storage medium based on multicast
CN112134893A (en) * 2020-09-25 2020-12-25 杭州迪普科技股份有限公司 Internet of things safety protection method and device, electronic equipment and storage medium

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1929418A (en) * 2006-09-15 2007-03-14 四川长虹电器股份有限公司 LAN communication method
CN101330405A (en) * 2008-07-02 2008-12-24 北京亿阳信通软件研究院有限公司 Method for discovering network topology and related equipment
CN101534216A (en) * 2009-04-24 2009-09-16 北京东土科技股份有限公司 Automatic topology realisation method based on topological bucket algorithm
CN102195857A (en) * 2010-03-18 2011-09-21 武汉迈威光电技术有限公司 Network topology structure and node information gathering method
CN103516599A (en) * 2012-06-15 2014-01-15 华为技术有限公司 Host finding method, network device, and host
CN103873301A (en) * 2014-03-20 2014-06-18 浙江宇视科技有限公司 System and method for automatically finding and adding devices
CN103888522A (en) * 2014-03-11 2014-06-25 青岛海信电器股份有限公司 Application recommending method and electronic equipment
CN104619039A (en) * 2014-12-30 2015-05-13 北京奇虎科技有限公司 Terminal equipment interconnection method and system in wireless local area network (WLAN) and terminal equipment
CN104639913A (en) * 2015-02-12 2015-05-20 浙江宇视科技有限公司 Network video recorder (NVR) and automatic IPC (Internet Protocol Camera) access method thereof

Family Cites Families (2)

* Cited by examiner, † Cited by third party
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
US9203704B2 (en) * 2011-08-22 2015-12-01 Verizon Patent And Licensing Inc. Discovering a server device, by a non-DLNA device, within a home network

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1929418A (en) * 2006-09-15 2007-03-14 四川长虹电器股份有限公司 LAN communication method
CN101330405A (en) * 2008-07-02 2008-12-24 北京亿阳信通软件研究院有限公司 Method for discovering network topology and related equipment
CN101534216A (en) * 2009-04-24 2009-09-16 北京东土科技股份有限公司 Automatic topology realisation method based on topological bucket algorithm
CN102195857A (en) * 2010-03-18 2011-09-21 武汉迈威光电技术有限公司 Network topology structure and node information gathering method
CN103516599A (en) * 2012-06-15 2014-01-15 华为技术有限公司 Host finding method, network device, and host
CN103888522A (en) * 2014-03-11 2014-06-25 青岛海信电器股份有限公司 Application recommending method and electronic equipment
CN103873301A (en) * 2014-03-20 2014-06-18 浙江宇视科技有限公司 System and method for automatically finding and adding devices
CN104619039A (en) * 2014-12-30 2015-05-13 北京奇虎科技有限公司 Terminal equipment interconnection method and system in wireless local area network (WLAN) and terminal equipment
CN104639913A (en) * 2015-02-12 2015-05-20 浙江宇视科技有限公司 Network video recorder (NVR) and automatic IPC (Internet Protocol Camera) access method thereof

Also Published As

Publication number Publication date
CN106470234A (en) 2017-03-01

Similar Documents

Publication Publication Date Title
CN106851654B (en) Pseudo base station identification method, pseudo base station identification device and terminal
US10069818B2 (en) Method, system, device, and terminal for network initialization of multimedia playback device
KR101978590B1 (en) Message updating method, device and terminal
CN107094294B (en) Network connection method and device
WO2015090248A1 (en) Server overload protection method and device
CN105491135B (en) Establish the method and device of data connection
CN107147549B (en) Intelligent household equipment networking method and device
CN106470234B (en) Equipment discovery method and device
CN108255683B (en) Method for prompting message in terminal and terminal
CN107317828B (en) File downloading method and device
CN109495769B (en) Video communication method, terminal, smart television, server and storage medium
CN106817370B (en) Method and device for transmitting network data
CN106815077B (en) Data processing method based on intelligent device architecture and intelligent device
CN106535229B (en) WiFi signal receiving sensitivity testing method and mobile terminal
CN105635379B (en) Noise suppression method and device
CN112867171A (en) WIFI connection method and device, storage medium and mobile terminal
CN107371212B (en) Method and device for sending data
CN110891262A (en) Bluetooth pairing method, system and terminal equipment
CN107315623B (en) Method and device for reporting statistical data
CN108111553B (en) Method and device for providing service
CN107872791B (en) Access point connection method and device
CN108476238B (en) Terminal equipment and control method thereof
CN105278967B (en) System updating method, device and system of mobile terminal
CN110870289B (en) Method and device for restoring surfing Internet of local area network equipment
CN106879046B (en) Network scanning method and terminal equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant