CN113765967A - Device searching method, device and storage medium - Google Patents

Device searching method, device and storage medium Download PDF

Info

Publication number
CN113765967A
CN113765967A CN202010953014.0A CN202010953014A CN113765967A CN 113765967 A CN113765967 A CN 113765967A CN 202010953014 A CN202010953014 A CN 202010953014A CN 113765967 A CN113765967 A CN 113765967A
Authority
CN
China
Prior art keywords
address
equipment
request message
searched
response message
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.)
Pending
Application number
CN202010953014.0A
Other languages
Chinese (zh)
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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology 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 Beijing Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202010953014.0A priority Critical patent/CN113765967A/en
Publication of CN113765967A publication Critical patent/CN113765967A/en
Pending legal-status Critical Current

Links

Images

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/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks
    • H04L67/1061Peer-to-peer [P2P] networks using node-based peer discovery mechanisms
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/164Adaptation or special uses of UDP protocol

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer And Data Communications (AREA)

Abstract

The application provides a device searching method, a device and a storage medium, which are applied to the fields of communication technology, information processing technology and the like. In the technical scheme, the IP address of first equipment is a first IP address, the first equipment generates a request message according to the first IP address, the request message carries protocol information, the first IP address and a second IP address, the second IP address is the IP address of second equipment, the first IP address and the second IP address are located in the same network segment, and the protocol information is used for indicating searched equipment which carries out point-to-point data communication with the first equipment; sending a request message to the second equipment; and receiving a response message, wherein the response message is sent by the second equipment when the second equipment is determined to belong to the searched equipment according to the protocol information, and the response message carries the IP address of the searched equipment. The method and the device realize the function of searching and discovering the equipment in a unicast mode, and can reduce the failure rate of searching.

Description

Device searching method, device and storage medium
Technical Field
The present application relates to the field of communications technologies, and in particular, to a device search method, apparatus, device, and storage medium.
Background
The local area network is a regional network formed by local areas. The devices in the same lan can implement peer-to-peer data communication, but the Internet Protocol (IP) address of the other party needs to be known before data communication.
At present, commonly used ways to obtain the IP address of the other party include broadcast search and multicast search. Specifically, a message carrying protocol information sent by a search initiator is forwarded to all devices in a local area network (broadcast search) or devices in the same IP address field (multicast search) through a network connection device; the device receiving the message analyzes the message to obtain the protocol information, wherein the device conforming to the protocol information responds to the message and sends the IP address of the message to the search initiator so that the search initiator can obtain the IP address of the device, and therefore the two parties can realize point-to-point data communication.
However, considering that the performance of the network connection devices is different, some network connection devices discard some packets when the forwarding amount is difficult to support, which results in failure of broadcast/multicast search, and a problem of high search failure rate exists.
Disclosure of Invention
The application provides a device searching method, a device and a storage medium, which are used for reducing the searching failure rate.
In a first aspect, an embodiment of the present application provides an apparatus searching method, including: the method comprises the steps that a first device generates a request message according to a first IP address, wherein the request message carries protocol information, the first IP address and a second IP address, the IP address of the first device is the first IP address, the second IP address is the IP address of a second device, the first IP address and the second IP address are located in the same network segment, and the protocol information is used for indicating a searched device which carries out point-to-point data communication with the first device; sending a request message to the second equipment; and receiving a response message, wherein the response message is sent by the second equipment when the second equipment is determined to belong to the searched equipment according to the protocol information, and the response message carries the IP address of the searched equipment.
In a possible implementation manner, generating the request packet according to the first IP address may include: determining a second IP address according to the first IP address; and generating a request message according to the second IP address.
In one possible embodiment, determining the second IP address according to the first IP address includes: and traversing the IP addresses in the network segment in the first IP address according to a preset sequence to determine a second IP address.
In a possible implementation manner, sending the request packet to the second device includes: and sending the request message to the second equipment according to a preset time sequence, wherein the second IP addresses carried in the request messages sent by different preset time sequences are different.
In a second aspect, an embodiment of the present application provides an apparatus searching method, which is applied to a second apparatus, where an IP address of the second apparatus is a second IP address, and the method includes:
receiving a request message from first equipment, wherein the IP address of the first equipment is a first IP address, the request message carries protocol information, the first IP address and a second IP address, the first IP address and the second IP address are located in the same network segment, and the protocol information is used for indicating searched equipment which performs point-to-point data communication with the first equipment;
determining that the second device belongs to the searched device according to the protocol information;
and sending a response message to the first equipment, wherein the response message carries the IP address of the searched equipment.
In a third aspect, an embodiment of the present application provides an apparatus for searching for a device, which is applied to a first device, where an IP address of the first device is a first IP address, and the apparatus includes:
the processing module is used for generating a request message according to the first IP address, wherein the request message carries protocol information, the first IP address and a second IP address, the second IP address is the IP address of the second device, the first IP address and the second IP address are located in the same network segment, and the protocol information is used for indicating a searched device which performs point-to-point data communication with the first device;
the sending module is used for sending the request message to the second equipment;
and the receiving module is used for receiving a response message, wherein the response message is sent by the second equipment when the second equipment is determined to belong to the searched equipment according to the protocol information, and the response message carries the IP address of the searched equipment.
In a possible implementation, the processing module is specifically configured to: determining a second IP address according to the first IP address; and generating a request message according to the second IP address.
In a possible implementation manner, when the processing module is configured to determine the second IP address according to the first IP address, the processing module is specifically configured to: and traversing the IP addresses in the network segment in the first IP address according to a preset sequence to determine a second IP address.
In a possible implementation, the sending module is specifically configured to: and sending the request message to the second equipment according to a preset time sequence, wherein the second IP addresses carried in the request messages sent by different preset time sequences are different.
In a fourth aspect, an embodiment of the present application provides an apparatus searching device, which is applied to a second apparatus, and is applied to the second apparatus, where an IP address of the second apparatus is a second IP address. The device search apparatus includes:
the device comprises a receiving module, a searching module and a sending module, wherein the receiving module is used for receiving a request message from first equipment, the IP address of the first equipment is a first IP address, the request message carries protocol information, the first IP address and a second IP address, the first IP address and the second IP address are located in the same network segment, and the protocol information is used for indicating searched equipment which carries out point-to-point data communication with the first equipment;
the processing module is used for determining that the second equipment belongs to the searched equipment according to the protocol information;
and the sending module is used for sending a response message to the first equipment, wherein the response message carries the IP address of the searched equipment.
On the basis of the possible embodiments described above:
optionally, a Protocol used by the request message and the response message is a User Datagram Protocol (UDP).
Optionally, the receiving port of the request message is a preset port.
Optionally, the number of the preset ports is at least one.
Optionally, the preset sequence includes:
from high to low;
from low to high or vice versa;
and based on the first IP address, alternating the order to the left and right sides of the first IP address.
In a fifth aspect, an embodiment of the present application provides an electronic device, including a processor, a memory, and a computer program stored on the memory and executable on the processor, where the processor implements the method according to any one of the first aspect or the second aspect when executing the computer program.
In a sixth aspect, the present application further provides a computer-readable storage medium, in which a computer program is stored, and when the computer program runs on an electronic device, the electronic device is caused to execute the method of any one of the first aspect or the second aspect.
According to the device searching method, the device and the storage medium, the first device generates a request message according to a first IP address, the request message carries protocol information, the first IP address and a second IP address, the IP address of the first device is the first IP address, the second IP address is the IP address of the second device, the first IP address and the second IP address are located in the same network segment, and the protocol information is used for indicating a searched device which performs point-to-point data communication with the first device; sending a request message to the second equipment; and receiving a response message, wherein the response message is sent by the second equipment when the second equipment is determined to belong to the searched equipment according to the protocol information, and the response message carries the IP address of the searched equipment. Traversing the IP address in the network segment where the first IP address is located as a second IP address, sending a request message to second equipment with the second IP address, after the second equipment receives the request message, if the second equipment is determined to be searched equipment which performs point-to-point data communication with the first equipment according to protocol information carried in the request message, carrying the IP address of the searched equipment in a response message and sending the response message to the first equipment, thereby realizing the exchange of the IP addresses of the first equipment and the searched equipment, realizing the function of searching and discovering the equipment by the unicast mode, and reducing the failure rate of searching.
Drawings
Fig. 1 is a schematic view of an application scenario of a device search method provided in the present application;
fig. 2 is a schematic flowchart of a device search method according to an embodiment of the present application;
fig. 3 is a schematic diagram illustrating alternate traversal of IP addresses according to an embodiment of the present application;
fig. 4 is a schematic diagram of a request message sending timing sequence according to an embodiment of the present application;
fig. 5 is a schematic flowchart of a device search method according to another embodiment of the present application;
fig. 6 is a schematic structural diagram of an apparatus searching device according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The local area network has a limited distribution area range, and can be large or small, namely, the local area network is connected between one building and an adjacent building, and the local area network is connected between offices. The local area network has the advantages of higher transmission speed, more stable performance, simple framework and closure compared with other networks. Local area network searches for equipment and establishes point-to-point communication, which has become an indispensable function for emerging network applications such as current internet of things, smart homes, smart factories and the like.
In this application, a local area network refers to a local communication network formed under the same switch or router, typically within or near a building, such as a small network in a home, office, or factory. Local area networks are widely used to connect personal computers and consumer electronic devices, enabling them to share resources and exchange information. The IP addresses of the devices under the same local area network are unique, direct point-to-point data communication can be realized between the devices, but the existence of each other needs to be known before the point-to-point data communication is carried out, namely the IP addresses of the other sides need to be known. The current methods for acquiring the IP address of the other party include the following methods:
(1) broadcast searching: the search initiator transmits a request message with protocol information and the IP address of the search initiator to all local area network devices through the router by UDP broadcast; the devices in the local area network can receive the request message and can simultaneously acquire the IP address of the search initiator, the devices in the local area network can analyze the request message to acquire the protocol information, the devices which conform to the protocol information can send the response message to the search initiator, and the search initiator can acquire the IP address of the devices while receiving the response message, so that the two parties can find each other, and further point-to-point bidirectional data communication is realized.
(2) Multicast search: similar to broadcast search, multicast transmission is also performed on a request message carrying protocol information and an IP address, and unlike broadcast search, in multicast search, the router transmits a smaller range, and transmits the request message to local area network devices in the same IP segment. The devices can also reply after receiving the request message, so that the search initiator can acquire the IP address of the device while receiving the response message, and the two parties can discover each other to further perform point-to-point bidirectional data communication.
For example, in a home lan, both broadcast and multicast require routers to forward, and a great burden is imposed on the routers during forwarding. Because the performance of the routers is different, some routers discard some messages when the forwarding amount is difficult to support, and the searching difficulty is caused; even some routers and network connection devices, such as smartphones, may default to turning off the broadcast/multicast receive or transmit functionality. Therefore, the multicast search and broadcast search schemes have the problems of high search failure rate and poor compatibility, and have affected the use of users.
In order to solve the above problems, the present application provides a device search method, apparatus, device and storage medium, which implement a device search function by using a unicast point-to-point communication principle, and solve the problem that a router or other network connection devices do not support or support relatively poorly; in addition, for devices that do not support broadcast or multicast, a device search function can still be implemented.
The basic principle of the scheme is as follows: the end initiating the search obtains its own IP address to obtain the network segment information of the IP address, then sends request messages to the devices with all IP addresses in the network segment one by one in a certain time, the searched device replies the response message after receiving the request message, and the end initiating the search can obtain the IP address of the searched device after receiving the response message, thereby realizing the function of searching (finding) the device.
Exemplarily, fig. 1 is a schematic view of an application scenario of the device search method provided in the present application. As shown in fig. 1, the application scenario may include: the router comprises a router and at least two electronic devices, wherein point-to-point data communication can be carried out between the at least two electronic devices. In this example, fig. 1 shows 6 electronic devices, which are a computer, a cellular phone, a PDA, a facsimile machine, a notebook, and a printer, respectively. Wherein each electronic device can communicate with the router through the local area network.
Optionally, if the mobile phone is to search for a printer in the local area network, and for convenience of description, the IP address of the mobile phone is set as the first IP address, the mobile phone sends a request message to the router, where the request message carries the first IP address, protocol information, and a second IP address, where the second IP address is any IP address in a network segment where the first IP address is located, and the protocol information is used to indicate a searched device performing peer-to-peer data communication with the mobile phone, and the router forwards the searched device to an electronic device corresponding to the second IP address, for example, assuming that the searched device is a notebook; after the notebook receives the request message, the notebook analyzes the request message to obtain protocol information, then the notebook determines whether the notebook belongs to the searched equipment according to the protocol information, if the notebook determines that the notebook is the searched equipment according to the protocol information, a response message is replied to the mobile phone, wherein the response message carries the IP address of the notebook, so that the mobile phone and the notebook can know the IP address of the opposite party, complete equipment search and further perform point-to-point data communication. In addition, if the notebook determines that the notebook is not the searched equipment according to the protocol information, the response message is not replied to the mobile phone.
It should be noted that fig. 1 is only a schematic diagram of an application scenario provided in an embodiment of the present application, and the present application does not limit the devices included in fig. 1, nor does it limit the position relationship between the devices in fig. 1, for example, in the application scenario illustrated in fig. 1, other electronic devices may also be included; in addition, the number of the electronic devices in the local area network is not limited by the application.
The technical solution of the present application will be described in detail below with reference to specific examples. It should be noted that the following specific embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
It will be appreciated that the implementation of the search function involves two roles: a search initiator (sender) and a searched device (receiver). In any embodiment of the present application, the first device is a search initiator (sender). The technical solution is described below from these two roles, respectively:
fig. 2 is a schematic flowchart of a device search method according to an embodiment of the present application. The embodiment of the application provides a device searching method, which is applied to first devices, wherein the IP address of the first device is a first IP address.
As shown in fig. 2, the method comprises the steps of:
s201, the first device generates a request message according to the first IP address, wherein the request message carries protocol information, the first IP address and the second IP address.
The second IP address is the IP address of the second device, the first IP address and the second IP address are located in the same network segment, and the protocol information is used for indicating the searched device which performs point-to-point data communication with the first device.
In the same network segment, the value range of the IP address is as follows: 192.168.xxx.1 to 192.168.xxx.255 for a total of 255 IP addresses, where 192.168.xxx.1 is the IP address of the router and 192.168.xxx.255 is the multicast IP address, excluding the first device's own IP address, the second IP address is 252, i.e. there is a possibility of 252 IP addresses for the searched device. Since the request message sent by the first device each time carries a second IP address, the first device needs to traverse the 252 possibilities to search the searched device, that is, the first device needs to traverse the 252 second IP addresses to send the request message until receiving the response message.
In this step, the request packet is directional and is sent from the first device to the second device having the second IP address, and since the IP address in the same network segment is unique, the request packet is sent in a unicast manner. Thus, even if the electronic device defaults to close the receiving or sending function of broadcast/multicast, the request message in the embodiment of the application can be received; and unicast is a function that the router necessarily has, and the search difficulty caused by the performance of the router can be avoided, so that the compatibility of equipment search is improved.
S202, the first equipment sends a request message to the second equipment.
Correspondingly, the second device receives the request message, analyzes the request message and obtains the protocol information and the first IP address. Then, the second equipment determines whether the second equipment belongs to the searched equipment or not according to the protocol information; if the second equipment is determined to belong to the searched equipment, sending a response message to the first equipment, wherein the response message carries the IP address of the searched equipment; and if the second equipment is determined not to belong to the searched equipment, not sending a response message to the first equipment. As can be seen, the response message is sent by the second device when the second device is determined to belong to the searched device according to the protocol information.
S203, the first device receives the response message, and the response message carries the IP address of the searched device.
In this embodiment, through S202, the searched device acquires the IP address of the first device, and through S203, the first device acquires the IP address of the searched device, thereby implementing device discovery between the first device and the searched device.
According to the device searching method provided by the embodiment of the application, a first device generates a request message according to a first IP address, the request message carries protocol information, the first IP address and a second IP address, the IP address of the first device is the first IP address, the second IP address is the IP address of the second device, the first IP address and the second IP address are located in the same network segment, and the protocol information is used for indicating a searched device which performs point-to-point data communication with the first device; sending a request message to the second equipment; and receiving a response message, wherein the response message is sent by the second equipment when the second equipment is determined to belong to the searched equipment according to the protocol information, and the response message carries the IP address of the searched equipment. Traversing the IP address in the network segment where the first IP address is located as a second IP address, sending a request message to second equipment with the second IP address, after the second equipment receives the request message, if the second equipment is determined to be searched equipment which carries out point-to-point data communication with the first equipment according to protocol information carried in the request message, carrying the IP address of the searched equipment in a response message and sending the response message to the first equipment, thereby realizing the exchange of the IP addresses of the first equipment and the searched equipment, realizing the function of searching and discovering the equipment by the unicast mode, and reducing the failure rate of searching.
On the basis of the above embodiment, since the first device and the searched device have not established a communication connection, in the device searching process, data/information transmission between the first device and the searched device is based on a connectionless transmission protocol, such as UDP. UDP provides a way for applications to send messages to different destination IP addresses without establishing a connection. Therefore, the protocol used for the request message and the response message mentioned above is UDP.
In addition, since the UDP uses the port number to reserve its respective data transmission channel for different applications, the sending port used by the first device to send the request packet may be a preset port. Alternatively, to prevent the preset ports from being occupied, the number of the preset ports may be increased, for example, two or more preset ports may be provided. That is, in the present application, the number of the preset ports may be at least one.
In some embodiments, the generating, by the first device, the request packet according to the first IP address may include: the first equipment determines a second IP address according to the first IP address; and the first equipment generates a request message according to the second IP address.
Optionally, the determining, by the first device, the second IP address according to the first IP address includes: and in the network segment where the first IP address is located, the first equipment traverses the IP addresses in the network segment in a preset sequence to determine a second IP address. In practical application, the first device obtains its own IP address, namely a first IP address, and determines a network segment where the first IP address is located; except for the IP address with special significance and the first IP address, the first device traverses other IP addresses in the network segment to determine a second IP address.
Wherein the preset sequence may include:
from high to low;
from low to high or vice versa;
and based on the first IP address, alternating the order to the left and right sides of the first IP address.
As for the preset order, it is understood that since the router may set the range of IP addresses of the connected devices, e.g. from 192.168.xxx.100 to 192.168.xxx.200, if the first device starts traversing from 192.168.xxx.2, it traverses in order from low to high; alternatively, the first device starts the traversal from 192.168.xxx.254, i.e. the traversal is performed in order from high to low, the search efficiency will be low. In consideration of the problem, the search efficiency can be effectively improved by starting from the first IP address and traversing to the left and right sides of the first IP address alternately. Exemplarily, as shown in fig. 3: the first IP address is 192.168.xxx.123, the first device determines the first second IP address to be 192.168.xxx.124, the second IP address to be 192.168.xxx.122, and then 192.168.xxx.125, 192.168.xxx.121, so that the device search is faster by traversing to two sides alternately.
After the current preset port is traversed once, if the searched equipment is not searched yet, the first equipment switches the port number to be traversed for another preset port so as to prevent the current preset port from being occupied.
In a specific implementation, the sending, by the first device, the request packet to the second device may specifically be: the first equipment sends a request message to the second equipment according to a preset time sequence. And the second IP addresses carried in the request messages sent by different preset time sequences are different. This implementation is to consider that sending a large number of request packets in a route may affect the normal operation of the router. In order to reduce the influence on the router and search for the device quickly, the inventor has made a timing sequence as shown in fig. 4 through experiments.
Referring to fig. 4, the time interval for the first device to send the request message may be set to 20ms, the port number (preset port, here, two preset ports are taken as an example) is changed after traversing one time, and then the request message is sent by continuously traversing the IP address through the changed preset port; and waiting for receiving while sending the request message, and stopping sending the request message after receiving the response message. The time consumption of one request message is about 5 seconds for 252 request messages in 20ms, 5 seconds are consumed again after port number change, and the router does not need to forward the request messages in the process of changing the port number, so that one cycle corresponding to two preset ports is about 15 seconds. The design has the advantages that: one is to discover equipment quickly, and the theoretical discovery time is less than 10 seconds; in addition, the risk of the port number being occupied is excluded; in addition, the router is not occupied, and the normal function of the router is not influenced.
Fig. 5 is a flowchart illustrating a device search method according to another embodiment of the present application. The embodiment of the application provides a device searching method, which is applied to a second device, wherein the IP address of the first device is a first IP address, and the IP address of the second device is a second IP address.
As shown in fig. 5, the method includes the steps of:
s501, the second device receives a request message from the first device, wherein the request message carries protocol information, a first IP address and a second IP address.
S502, the second device determines that the second device belongs to the searched device according to the protocol information.
S503, the second device sends a response message to the first device, and the response message carries the IP address of the searched device.
This embodiment corresponds to the flow shown in fig. 2, and the steps performed by the second device in the device search process are described from the perspective of the second device, and the related description may refer to the embodiment shown in fig. 2, which is not described herein again.
Specifically, the second device starts monitoring, for example, UDP monitoring, and waits for the request message sent by the first device. The second device needs to bind the port number when starting the monitoring, and the bound port number is a preset port of the first device for sending the request message. And if the binding fails, replacing another port for binding so as to prevent the port from being occupied and the situation that the data cannot be received.
Optionally, the second device sends the response message to the first device multiple times. In this embodiment, in view of the fact that the connectionless transmission is unreliable data transmission, to prevent data loss, the second device may continuously send two identical reply messages to the first device, where the sending interval of the two reply messages is a preset time, for example, 10 ms. This embodiment guarantees the validity of the transmission by multiple acknowledgements.
Compared with broadcast search and multicast search, the device search scheme provided by the application has at least the following advantages:
first, unicast search. The aim of searching equipment is achieved by adopting a technical means that a search initiator unicasts to send request messages based on a connectionless transmission protocol to all target IP addresses in a local area network and monitors the response of the searched equipment;
secondly, IP address alternate traversal method and time sequence: an efficient traversal method is adopted, and the search equipment starts to traverse from the IP address of the search equipment to two sides alternately, so that the efficiency of the search equipment is improved; meanwhile, a time sequence is established through practice, and the equipment is quickly discovered while the route consumption is reduced.
The following are embodiments of the apparatus of the present application that may be used to perform embodiments of the method of the present application. For details which are not disclosed in the embodiments of the apparatus of the present application, reference is made to the embodiments of the method of the present application.
Fig. 6 is a schematic structural diagram of an apparatus searching device according to an embodiment of the present application. The device searching apparatus may be integrated on the electronic device, or the device searching apparatus is the electronic device. Here, the device search apparatus is integrated into an electronic device as an example. In this embodiment, the electronic device integrated with the device search apparatus is a first device, and the IP address of the first device is a first IP address.
As shown in fig. 6, the device search apparatus 60 includes: a processing module 61, a sending module 62 and a receiving module 63. Wherein:
and the processing module 61 is configured to generate a request message according to the first IP address. The request message carries protocol information, a first IP address and a second IP address. The second IP address is an IP address of the second device. The first IP address and the second IP address are located in the same network segment. The protocol information is used to indicate a searched device for point-to-point data communication with the first device.
And a sending module 62, configured to send the request message to the second device.
And the receiving module 63 is configured to receive the response message. The response message is sent by the second device when the second device is determined to belong to the searched device according to the protocol information. The response message carries the IP address of the searched device.
The apparatus provided in the embodiment of the present application may be used to execute the method in the embodiment shown in fig. 2, and the implementation principle and the technical effect are similar, which are not described herein again.
Optionally, the processing module 61 is specifically configured to: determining a second IP address according to the first IP address; and generating a request message according to the second IP address.
Further, when the processing module 61 is configured to determine the second IP address according to the first IP address, specifically, to: and traversing the IP addresses in the network segment in the first IP address according to a preset sequence to determine a second IP address.
In some embodiments, the sending module 62 is specifically configured to: and sending the request message to the second equipment according to the preset time sequence. And the second IP addresses carried in the request messages sent by different preset time sequences are different.
Or, the electronic device integrated with the device search apparatus is a second device, the IP address of the first device is a first IP address, and the IP address of the second device is a second IP address. Still taking the structure shown in fig. 6 as an example, in this embodiment:
the receiving module 63 is configured to receive a request packet from a first device.
And the processing module 61 is configured to determine that the second device belongs to the searched device according to the protocol information.
And a sending module 62, configured to send the response message to the first device.
The apparatus provided in the embodiment of the present application may be used to execute the method in the embodiment shown in fig. 5, and the implementation principle and the technical effect are similar, which are not described herein again.
In any embodiment of the present application, the protocol used for the request message and the response message may be UDP; a receiving port of the request message is a preset port; the number of the preset ports may be at least one.
It should be noted that, in the present application, the first device and the second device are relative concepts, and one electronic device may be the first device or the second device, so that one electronic device may have functions of both the first device and the second device.
It should be noted that the division of the modules of the above apparatus is only a logical division, and the actual implementation may be wholly or partially integrated into one physical entity, or may be physically separated. And these modules can be realized in the form of software called by processing element; or may be implemented entirely in hardware; and part of the modules can be realized in the form of calling software by the processing element, and part of the modules can be realized in the form of hardware. For example, the processing module may be a processing element separately set up, or may be implemented by being integrated in a chip of the apparatus, or may be stored in a memory of the apparatus in the form of program code, and a function of the processing module may be called and executed by a processing element of the apparatus. Other modules are implemented similarly. In addition, all or part of the modules can be integrated together or can be independently realized. The processing element described herein may be an integrated circuit having signal processing capabilities. In implementation, each step of the above method or each module above may be implemented by an integrated logic circuit of hardware in a processor element or an instruction in the form of software.
For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as: one or more Application Specific Integrated Circuits (ASICs), or one or more microprocessors (DSPs), or one or more Field Programmable Gate Arrays (FPGAs), among others. For another example, when one of the above modules is implemented in the form of a processing element scheduler code, the processing element may be a general-purpose processor, such as a Central Processing Unit (CPU) or other processor capable of calling program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the application to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer program can be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, the computer program can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wire (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
Fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application. As shown in fig. 7, the server may include: a processor 71, a memory 72, a communication interface 73, and a system bus 74. The memory 72 and the communication interface 73 are connected to the processor 71 through a system bus 74 and complete communication therebetween, the memory 72 is used for storing computer programs, the communication interface 73 is used for communicating with other devices, and the processor 71 implements the scheme of any one of the above method embodiments when executing the computer programs.
The system bus mentioned in fig. 7 may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The system bus may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus. The communication interface is used for realizing communication between the database access device and other equipment (such as a client, a read-write library and a read-only library). The memory may include a Random Access Memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
The processor may be a general-purpose processor, and includes a central processing unit CPU, a Network Processor (NP), and the like; but also a digital signal processor DSP, an application specific integrated circuit ASIC, a field programmable gate array FPGA or other programmable logic device, discrete gate or transistor logic, discrete hardware components.
Embodiments of the present application further provide a computer-readable storage medium, where a computer program is stored, and when the computer program runs on an electronic device, the electronic device is caused to execute the method according to any one of the above method embodiments.
The embodiment of the present application further provides a chip for executing the instructions, where the chip is used to execute the method described in any of the above method embodiments.
Embodiments of the present application further provide a computer program product, which includes a computer program stored in a computer-readable storage medium, from which the computer program can be read by at least one processor, and the computer program can be executed by the at least one processor to implement the method according to any one of the above method embodiments.
In the present application, "at least one" means one or more, "a plurality" means two or more. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone, wherein A and B can be singular or plural. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship; in the formula, the character "/" indicates that the preceding and following related objects are in a relationship of "division". "at least one of the following" or similar expressions refer to any combination of these items, including any combination of the singular or plural items. For example, at least one (one) of a, b, or c, may represent: a, b, c, a-b, a-c, b-c, or a-b-c, wherein a, b, c may be single or multiple.
It is to be understood that the various numerical references referred to in the embodiments of the present application are merely for descriptive convenience and are not intended to limit the scope of the embodiments of the present application. In the embodiment of the present application, the sequence numbers of the above-mentioned processes do not mean the execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiment of the present application.
Finally, it should be noted that: the above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present application.

Claims (16)

1. A device search method applied to a first device, wherein an Internet Protocol (IP) address of the first device is a first IP address, the method comprising:
generating a request message according to the first IP address, wherein the request message carries protocol information, the first IP address and a second IP address, the second IP address is an IP address of second equipment, the first IP address and the second IP address are located in the same network segment, and the protocol information is used for indicating searched equipment which performs point-to-point data communication with the first equipment;
sending the request message to the second device;
and receiving a response message, wherein the response message is sent by the second equipment when the second equipment is determined to belong to the searched equipment according to the protocol information, and the response message carries the IP address of the searched equipment.
2. The method according to claim 1, wherein the protocol used for the request message and the response message is user datagram protocol UDP.
3. The method according to claim 1 or 2, wherein the generating a request message according to the first IP address comprises:
determining the second IP address according to the first IP address;
and generating the request message according to the second IP address.
4. The method of claim 3, wherein determining the second IP address from the first IP address comprises:
and traversing the IP addresses in the network segment in the first IP address according to a preset sequence to determine the second IP address.
5. The method of claim 4, wherein the predetermined order comprises:
from high to low;
from low to high or vice versa;
an order of alternating to left and right sides of the first IP address based on the first IP address.
6. The method according to claim 1 or 2, wherein the sending the request message to the second device comprises:
and sending the request message to the second device according to a preset time sequence, wherein the second IP addresses carried in the request messages sent by different preset time sequences are different.
7. The method according to claim 1 or 2, wherein the sending port of the request message is a preset port.
8. The method of claim 7, wherein the number of the predetermined ports is at least one.
9. A device search method applied to a second device whose internet protocol IP address is a second IP address, the method comprising:
receiving a request message from a first device, wherein an IP address of the first device is a first IP address, the request message carries protocol information, the first IP address and a second IP address, the first IP address and the second IP address are located in the same network segment, and the protocol information is used for indicating a searched device which performs point-to-point data communication with the first device;
determining that the second device belongs to the searched device according to the protocol information;
and sending a response message to the first equipment, wherein the response message carries the IP address of the searched equipment.
10. The method according to claim 9, wherein the protocol used for the request message and the response message is user datagram protocol UDP.
11. The method according to claim 9 or 10, wherein the receiving port of the request message is a predetermined port.
12. The method of claim 11, wherein the number of the predetermined ports is at least one.
13. An apparatus searching device, applied to a first device, wherein an internet protocol IP address of the first device is a first IP address, the apparatus comprising:
a processing module, configured to generate a request message according to the first IP address, where the request message carries protocol information, the first IP address, and a second IP address, the second IP address is an IP address of a second device, the first IP address and the second IP address are located in the same network segment, and the protocol information is used to indicate a searched device performing peer-to-peer data communication with the first device;
a sending module, configured to send the request packet to the second device;
and the receiving module is used for receiving a response message, wherein the response message is sent by the second equipment when the second equipment is determined to belong to the searched equipment according to the protocol information, and the response message carries the IP address of the searched equipment.
14. An apparatus searching device, applied to a second device, wherein an internet protocol IP address of the second device is a second IP address, the apparatus comprising:
a receiving module, configured to receive a request packet from a first device, where an IP address of the first device is a first IP address, the request packet carries protocol information, the first IP address, and the second IP address, the first IP address and the second IP address are located in a same network segment, and the protocol information is used to indicate a searched device that performs peer-to-peer data communication with the first device;
the processing module is used for determining that the second equipment belongs to the searched equipment according to the protocol information;
and the sending module is used for sending a response message to the first equipment, wherein the response message carries the IP address of the searched equipment.
15. An electronic device comprising a processor, a memory, and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of any of claims 1 to 12 when executing the computer program.
16. A computer-readable storage medium, in which a computer program is stored which, when run on an electronic device, causes the electronic device to perform the method of any one of claims 1 to 12.
CN202010953014.0A 2020-09-11 2020-09-11 Device searching method, device and storage medium Pending CN113765967A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010953014.0A CN113765967A (en) 2020-09-11 2020-09-11 Device searching method, device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010953014.0A CN113765967A (en) 2020-09-11 2020-09-11 Device searching method, device and storage medium

Publications (1)

Publication Number Publication Date
CN113765967A true CN113765967A (en) 2021-12-07

Family

ID=78785736

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010953014.0A Pending CN113765967A (en) 2020-09-11 2020-09-11 Device searching method, device and storage medium

Country Status (1)

Country Link
CN (1) CN113765967A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114422568A (en) * 2021-12-27 2022-04-29 北京策腾教育科技集团有限公司 Method, system, computer terminal and storage medium for quickly establishing communication connection
CN116996476A (en) * 2023-09-27 2023-11-03 深圳市纽创信安科技开发有限公司 Information processing method, electronic device, and storage medium
WO2024012292A1 (en) * 2022-07-15 2024-01-18 北京字跳网络技术有限公司 Remote photographing method and apparatus, device, and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105897943A (en) * 2015-11-19 2016-08-24 乐视致新电子科技(天津)有限公司 Intelligent device searching method and device
CN108200567A (en) * 2018-01-18 2018-06-22 浙江大华技术股份有限公司 A kind of method for discovering equipment and equipment
CN109194754A (en) * 2018-09-11 2019-01-11 深圳市比特跳动技术有限公司 Equipment searching method and device
CN110213355A (en) * 2019-05-21 2019-09-06 卓尔购电子商务(武汉)有限公司 The method and its application of search terminal in local area network

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105897943A (en) * 2015-11-19 2016-08-24 乐视致新电子科技(天津)有限公司 Intelligent device searching method and device
CN108200567A (en) * 2018-01-18 2018-06-22 浙江大华技术股份有限公司 A kind of method for discovering equipment and equipment
CN109194754A (en) * 2018-09-11 2019-01-11 深圳市比特跳动技术有限公司 Equipment searching method and device
CN110213355A (en) * 2019-05-21 2019-09-06 卓尔购电子商务(武汉)有限公司 The method and its application of search terminal in local area network

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114422568A (en) * 2021-12-27 2022-04-29 北京策腾教育科技集团有限公司 Method, system, computer terminal and storage medium for quickly establishing communication connection
WO2024012292A1 (en) * 2022-07-15 2024-01-18 北京字跳网络技术有限公司 Remote photographing method and apparatus, device, and storage medium
CN116996476A (en) * 2023-09-27 2023-11-03 深圳市纽创信安科技开发有限公司 Information processing method, electronic device, and storage medium
CN116996476B (en) * 2023-09-27 2023-12-12 深圳市纽创信安科技开发有限公司 Information processing method, electronic device, and storage medium

Similar Documents

Publication Publication Date Title
EP3542557B1 (en) Application based intelligent edge computing in a low power wide area network environment
CN113765967A (en) Device searching method, device and storage medium
US10230577B2 (en) Packet broadcast mechanism in a split architecture network
US9369375B2 (en) Link-layer level link aggregation autoconfiguration
US9191219B2 (en) Network multicast peer discovery methods
US10103962B1 (en) Return path trace
US20120254922A1 (en) Method and apparatus for sending a packet from a source to a destination node
JP6551547B2 (en) Traffic-aware group reconfiguration in multi-group P2P networks
EP3041198B1 (en) Finding services in a service-oriented architecture (soa) network
TWI599201B (en) Network system and method for establishing data connection
US9191227B2 (en) Determining a route advertisement in a reactive routing environment
CN111107672B (en) Method, device and system for establishing sub-streams of multi-path connection
CN113055295A (en) Communication method, communication device and communication system
CN105657571A (en) Bandwidth-saving method for video transmission in local area network
WO2019041371A1 (en) Internet of things number-of-connections-based router switching method and device
CN102685009B (en) A kind of detection method of multicast transmission path and device
WO2020147081A1 (en) Data transmission method, related device, and computer storage medium
EP3258654B1 (en) Method and system for reducing pim protocol dr change
CN114827908A (en) VN group communication method, device, equipment and storage medium
JP7250822B2 (en) Connectivity management for critical path nodes
CN112511443A (en) Message processing method, device, equipment, storage medium and system
JP6698700B2 (en) Aggregating target and exploration queries
CN103780503A (en) Load balancing realization method and apparatus
CN106034344B (en) Data transmission method and device
CN114025016B (en) Data forwarding method, device and storage medium

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