CN117640722A - Network communication method, device, equipment and storage medium - Google Patents

Network communication method, device, equipment and storage medium Download PDF

Info

Publication number
CN117640722A
CN117640722A CN202311667476.6A CN202311667476A CN117640722A CN 117640722 A CN117640722 A CN 117640722A CN 202311667476 A CN202311667476 A CN 202311667476A CN 117640722 A CN117640722 A CN 117640722A
Authority
CN
China
Prior art keywords
network
things
internet
client
target
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
CN202311667476.6A
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.)
Agricultural Bank of China
Original Assignee
Agricultural Bank of China
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 Agricultural Bank of China filed Critical Agricultural Bank of China
Priority to CN202311667476.6A priority Critical patent/CN117640722A/en
Publication of CN117640722A publication Critical patent/CN117640722A/en
Pending legal-status Critical Current

Links

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The embodiment of the invention discloses a network communication method, a device, equipment and a storage medium, wherein the method comprises the following steps: under the condition that a network communication request instruction sent by a client is obtained, determining the Internet of things to be connected according to the network communication request instruction; determining a target network connection mode according to the network association relation between the client and the to-be-connected Internet of things; and establishing a target communication connection channel between the client and the to-be-connected Internet of things based on the target network connection mode. The technical scheme of the embodiment of the invention solves the problems that the flow for establishing the communication channel is complex and the occupied resources are more in the existing cross-regional network communication technology, can directly establish the corresponding communication connection channel according to the network association relation between the client and the to-be-connected Internet of things, improves the efficiency of establishing network communication and reduces the occupied resources of the network communication.

Description

Network communication method, device, equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of data communication, in particular to a network communication method, a device, equipment and a storage medium.
Background
The Internet of things is widely applied to the field of intelligent home. The general idea is that a user can remotely communicate with intelligent home equipment in the home by using mobile communication equipment carried around by the user, so that functions of remote access, monitoring, control and the like are realized. This requires a communication system that is adaptable to different network environments. The existing network communication technology of the cross-regional network often needs corresponding manual authorization operations to open the communication channel, the process of establishing the communication channel is complex, and the problem of more occupied resources exists.
Disclosure of Invention
The embodiment of the invention provides a network communication method, a device, equipment and a storage medium, which can directly establish a corresponding communication connection channel according to the network association relation between a client and an internet of things to be connected, thereby improving the efficiency of establishing network communication and reducing the occupied resources of the network communication.
In a first aspect, an embodiment of the present invention provides a network communication method, where the method includes:
under the condition that a network communication request instruction sent by a client is obtained, determining the Internet of things to be connected according to the network communication request instruction;
determining a target network connection mode according to the network association relation between the client and the to-be-connected Internet of things;
And establishing a target communication connection channel between the client and the to-be-connected Internet of things based on the target network connection mode.
In a second aspect, an embodiment of the present invention provides a network communication device, including:
the system comprises an Internet of things determining module, a network communication request module and a network connection module, wherein the Internet of things determining module is used for determining the Internet of things to be connected according to a network communication request instruction sent by a client;
the network association relation determining module is used for determining a target network connection mode according to the network association relation between the client and the to-be-connected Internet of things;
and the communication connection channel establishment module is used for establishing a target communication connection channel between the client and the to-be-connected Internet of things based on the target network connection mode.
In a third aspect, an embodiment of the present invention provides a computer apparatus, including:
one or more processors;
a memory for storing one or more programs;
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the network communication method of any of the embodiments.
In a fourth aspect, an embodiment of the present invention provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the network communication method according to any of the embodiments.
According to the technical scheme provided by the embodiment of the invention, the Internet of things to be connected is determined according to the network communication request instruction under the condition that the network communication request instruction sent by the client is acquired; determining a target network connection mode according to the network association relation between the client and the to-be-connected Internet of things; and establishing a target communication connection channel between the client and the to-be-connected Internet of things based on the target network connection mode. The technical scheme of the embodiment of the invention solves the problems that the flow for establishing the communication channel is complex and the occupied resources are more in the existing cross-regional network communication technology, can directly establish the corresponding communication connection channel according to the network association relation between the client and the to-be-connected Internet of things, improves the efficiency of establishing network communication and reduces the occupied resources of the network communication.
Drawings
Fig. 1 is a flowchart of a network communication method according to an embodiment of the present invention;
FIG. 2 is a flow chart of yet another network communication method provided by an embodiment of the present invention;
FIG. 3 is an interaction diagram of a local area network according to an embodiment of the present invention;
fig. 4 is a direct channel interaction diagram of a public network environment according to an embodiment of the present invention;
FIG. 5 is an interaction diagram of an indirect channel of a public network environment provided by an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a network communication device according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a network communication system according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of yet another network communication system according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of a computer device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Fig. 1 is a flowchart of a network communication method provided by an embodiment of the present invention, where the embodiment of the present invention is applicable to a scenario in which a communication channel is established between a client and the internet of things, the method may be performed by a network communication device, and the device may be implemented by software and/or hardware.
As shown in fig. 1, the network communication method includes the steps of:
and S110, under the condition that a network communication request instruction sent by the client is acquired, determining the Internet of things to be connected according to the network communication request instruction.
The network communication request instruction may be an instruction sent by the client to request communication with the target internet of things. The network communication request instruction may include relevant identification information of the client and identification information of the target internet of things. The to-be-connected internet of things can be the internet of things which needs to be in communication connection with the client, and specifically, under the condition that a network communication request instruction sent by the client is obtained, the to-be-connected internet of things can be determined according to the identification information of the target internet of things in the network communication request instruction.
S120, determining a target network connection mode according to the network association relation between the client and the to-be-connected Internet of things.
The network association relationship may be an association relationship between the client and the internet to be connected in an intranet or a public network. The internal network manager may be a server that manages network connection relationships in a local area network where the client is located. The internet of things search instruction may be an instruction for requesting to search whether the internet of things to be connected exists in the local area network where the client is located. And sending the Internet of things searching instruction to the internal network manager. The internal network manager can search the internal local area network corresponding to the client for the Internet of things to be connected, so that whether a communication channel between the client and the Internet to be connected can be established based on the local area network can be conveniently determined according to the search result. By determining the target network connection mode based on the network association relation between the client and the internet to be connected, a more suitable communication connection mode can be matched according to the network connection relation between the client and the internet to be connected, and the communication connection efficiency is improved.
S130, establishing a target communication connection channel between the client and the to-be-connected Internet of things based on the target network connection mode.
The target communication connection channel may be a communication connection channel established between the client and the internet of things to be connected. Specifically, a corresponding communication connection channel can be established according to the type of the target network connection mode, and the established communication connection channel is used as a target communication connection channel.
Specifically, when a target communication connection channel is established between a client and the internet of things to be connected based on a target network connection mode, the method can be divided into multiple cases. The method comprises the steps of establishing a target local area network communication channel based on a local area network association relation between a client and an internet of things to be connected under the condition that a target network connection mode is a local area network connection mode; under the condition that the target network connection mode is a public network direct connection mode, a target public network direct communication channel is established based on a public gateway connection relation between a client and the to-be-connected Internet of things; and under the condition that the target network connection mode is a public network direct connection mode, establishing a target public network indirect communication channel according to network addresses of the client and the to-be-connected Internet of things in the public network.
The target lan communication channel may be a connection channel established based on the client lan and capable of direct communication. Specifically, under the condition that the target network connection mode is determined to be the local area network connection mode, the client side and the internet to be connected are indicated to be under the same local area network. Therefore, a target local area network communication channel can be established between the client and the to-be-connected internet of things based on the same local area network. The target public network direct communication channel may be a connection channel established based on a public network address and capable of direct communication. Specifically, when the target network connection mode is determined to be the public network direct connection mode, it is indicated that the client and the internet to be connected can directly communicate through the public network address, so that a target public network direct communication channel can be established between the client and the internet to be connected. Further, the target public network indirect communication channel may be an indirect communication connection channel that requires a public network as a communication medium. Specifically, when the target network connection mode is determined to be the public network indirect connection mode, it is indicated that the client and the internet of things to be connected cannot directly communicate through the public network address, so that the public network is required to be used as a communication medium for communication between the client and the internet of things to be connected, and a target public network indirect communication channel is established between the client and the internet of things to be connected.
According to the technical scheme provided by the embodiment of the invention, the Internet of things to be connected is determined according to the network communication request instruction under the condition that the network communication request instruction sent by the client is acquired; determining a target network connection mode according to the network association relation between the client and the to-be-connected Internet of things; and establishing a target communication connection channel between the client and the to-be-connected Internet of things based on the target network connection mode. The technical scheme of the embodiment of the invention solves the problems that the flow for establishing the communication channel is complex and the occupied resources are more in the existing cross-regional network communication technology, can directly establish the corresponding communication connection channel according to the network association relation between the client and the to-be-connected Internet of things, improves the efficiency of establishing network communication and reduces the occupied resources of the network communication.
Fig. 2 is a flowchart of another network communication method provided by the embodiment of the present invention, where the embodiment of the present invention is applicable to a scenario in which a communication channel is established between a client and an internet of things, and further illustrates how to determine a target network connection mode according to a network association relationship between the client and the internet of things to be connected based on the above embodiment.
As shown in fig. 2, the network communication method includes the steps of:
s210, under the condition that a network communication request instruction sent by a client is obtained, determining the Internet of things to be connected according to the network communication request instruction.
The network communication request instruction may be an instruction sent by the client to request communication with the target internet of things. The network communication request instruction may include relevant identification information of the client and identification information of the target internet of things. The to-be-connected internet of things can be the internet of things which needs to be in communication connection with the client, and specifically, under the condition that a network communication request instruction sent by the client is obtained, the to-be-connected internet of things can be determined according to the identification information of the target internet of things in the network communication request instruction.
S220, determining a target network connection mode according to the network association relation between the client and the to-be-connected Internet of things.
The network association relationship may be an association relationship between the client and the internet to be connected in an intranet or a public network. The internal network manager may be a server that manages network connection relationships in a local area network where the client is located. The internet of things search instruction may be an instruction for requesting to search whether the internet of things to be connected exists in the local area network where the client is located. And sending the Internet of things searching instruction to the internal network manager. The internal network manager can search the internal local area network corresponding to the client for the Internet of things to be connected, so that whether a communication channel between the client and the Internet to be connected can be established based on the local area network can be conveniently determined according to the search result.
S230, the internal network manager searches the internal local area network corresponding to the client for the to-be-connected Internet of things, and determines the target network connection mode according to the Internet of things search result.
The internet of things search result may be a result of searching whether the internet of things to be connected is in an internal local area network corresponding to the client. Specifically, the search results of the internet of things include searched results and searched results. The fact that the internet of things to be connected are not in the internal local area network corresponding to the client is not searched. The searched result indicates that the to-be-connected internet of things is in the internal local area network corresponding to the client. The target network connection mode may be a mode of performing communication connection between the finally determined client and the internet of things to be connected. Specifically, the target network connection mode includes: at least one of a local area network connection mode and a public network connection mode.
The local area network connection mode may be a mode of performing communication connection between the client and the internet to be connected based on an internal local area network corresponding to the client. The public network connection mode can be a mode of carrying out communication connection on the client and the internet of things to be connected based on the public network. Further, the target network connection mode may be determined by the search result of the internet of things, and in an exemplary case where the search result of the internet of things is a searched result, the target network connection mode may be determined to be a local area network connection mode. Correspondingly, under the condition that the search result of the internet of things is not searched, the target network connection mode can be determined to be a public network connection mode.
Further, under the condition that the target network connection mode is determined to be the local area network connection mode, a direct communication channel between the client and the internet of things to be connected can be established based on the local area network, so that the communication rate between the client and the internet is improved. Further, under the condition that the target network connection mode is the public network connection mode, further determination can be made whether a direct communication channel between the client and the Internet of things can be established based on the public network.
Optionally, after determining that the target network connection mode is a public network connection mode, direct communication attempt instructions can be sent to the client and the internet of things to be connected respectively; the method comprises the steps that a client sends client hole punching data to the to-be-connected Internet of things based on a public network, and the to-be-connected Internet of things sends the Internet of things hole punching data to the client based on the public network; and determining a target public network connection mode based on the receiving result of the client and the to-be-connected Internet of things on the hole punching data.
The direct communication attempt instruction may be a request instruction for attempting to directly communicate between the client and the internet of things to be connected. The direct communication attempt instruction can be sent to the client and the internet of things to be connected respectively, so that the direct communication attempt is carried out between the client and the internet of things to be connected based on the public network address, and whether a communication channel between the client and the internet of things to be connected can be established is further determined. Further, the client hole punching data may be hole punching data sent by the client to attempt to directly communicate with the internet of things to be connected. The internet of things hole punching data may be hole punching data to be connected to the internet of things in an attempt to directly communicate with the client.
The target public network connection mode can be a mode of communication connection between the client and the internet to be connected based on the public network. Specifically, the target public network connection mode includes a public network direct connection mode and a public network indirect connection mode. The public network direct connection mode may be a communication connection mode that can directly communicate without a public network. The subsequent client can directly communicate with the to-be-connected internet of things without using a public network as a communication medium. The public network indirect connection mode may be a communication connection mode that can perform communication only through the public network. That is, the client cannot directly communicate with the internet of things to be connected, and a public network is required to be used as a communication medium. For example, when the client and the internet of things send messages to each other, the message sender is required to forward the message to the public network, and then forward the message to the message receiver from the public network.
Specifically, when determining the target public network connection mode based on the receiving result of the client and the internet of things to be connected on the hole punching data, the target public network connection mode can be determined to be the public network direct connection mode when the client receives the internet of things hole punching data and the internet of things to be connected receives the client hole punching data; otherwise, determining that the target public network connection mode is a public network indirect connection mode.
S240, establishing a target communication connection channel between the client and the to-be-connected Internet of things based on the target network connection mode.
The target communication connection channel may be a communication connection channel established between the client and the internet of things to be connected. Specifically, a corresponding communication connection channel can be established according to the type of the target network connection mode, and the established communication connection channel is used as a target communication connection channel.
Specifically, when a target communication connection channel is established between a client and the internet of things to be connected based on a target network connection mode, the method can be divided into multiple cases. The method comprises the steps of establishing a target local area network communication channel based on a local area network association relation between a client and an internet of things to be connected under the condition that a target network connection mode is a local area network connection mode; under the condition that the target network connection mode is a public network direct connection mode, a target public network direct communication channel is established based on a public gateway connection relation between a client and the to-be-connected Internet of things; and under the condition that the target network connection mode is a public network direct connection mode, establishing a target public network indirect communication channel according to network addresses of the client and the to-be-connected Internet of things in the public network.
The target lan communication channel may be a connection channel established based on the client lan and capable of direct communication. Specifically, under the condition that the target network connection mode is determined to be the local area network connection mode, the client side and the internet to be connected are indicated to be under the same local area network. Therefore, a target local area network communication channel can be established between the client and the to-be-connected internet of things based on the same local area network. The target public network direct communication channel may be a connection channel established based on a public network address and capable of direct communication. Specifically, when the target network connection mode is determined to be the public network direct connection mode, it is indicated that the client and the internet to be connected can directly communicate through the public network address, so that a target public network direct communication channel can be established between the client and the internet to be connected. Further, the target public network indirect communication channel may be an indirect communication connection channel that requires a public network as a communication medium. Specifically, when the target network connection mode is determined to be the public network indirect connection mode, it is indicated that the client and the internet of things to be connected cannot directly communicate through the public network address, so that the public network is required to be used as a communication medium for communication between the client and the internet of things to be connected, and a target public network indirect communication channel is established between the client and the internet of things to be connected.
Optionally, before the target communication connection channel is established, preset heartbeat data may also be sent to the candidate gateway device; and acquiring heartbeat feedback information aiming at preset heartbeat data and sent by the candidate gateway equipment, and determining target gateway equipment according to the heartbeat feedback information.
The candidate gateway device may be a gateway device with probability of being a communication connection between the client and the internet of things. The preset heartbeat data may be preset data for checking whether the candidate network device operates normally. By sending the preset heartbeat data to the candidate gateway device, whether the candidate network device operates normally can be determined based on feedback data of the candidate network device to the preset heartbeat data. Further, the heartbeat feedback data may be feedback data of the candidate gateway device to preset heartbeat data. The target gateway device may be a gateway device that is finalized as a communication connection between the client and the internet. Specifically, the heartbeat feedback information may be used to further determine the target gateway device from the candidate gateway devices. For example, whether the heartbeat feedback data and the preset heartbeat data can be successfully matched can be judged, and if the heartbeat feedback data and the preset heartbeat data can be successfully matched, the candidate gateway device sending the heartbeat feedback information can be determined as the target network device. I.e. the gateway device that is operating normally is the gateway device that connects between the client and the internet.
Fig. 3 is an interaction diagram of a local area network according to an embodiment of the present invention. Fig. 4 is a direct channel interaction diagram of a public network environment according to an embodiment of the present invention. Fig. 5 is an interaction diagram of an indirect channel of a public network environment according to an embodiment of the present invention. Referring to fig. 2, 3 and 4, the network communication method provided by the embodiment of the invention includes the following steps;
step 1, starting a public network server module, starting a worker thread pool by adopting a communication protocol based on a Netty communication framework and UDP (User Datagram Protocl, user datagram protocol), performing message processing on the thread pool, binding a host port, generating a channel handle, and connecting an Internet of things gateway monitoring submodule with a client monitoring submodule monitoring port.
Step 2, starting the gateway module of the internet of things:
2a) Starting a worker thread pool by adopting a Netty communication framework and a UDP communication protocol, performing message processing on the thread pool, binding a host port, generating a channel handle, and connecting a monitoring port of a monitoring submodule of a client monitoring submodule;
2b) Establishing a communication channel, sending a channel authentication request to a public network server, detecting a device ID and a password of the request after the public network server receives the request, feeding back a successful authentication message without errors, sending a heartbeat data packet to a public network server module after the internet of things gateway receives the fed-back successful authentication message, monitoring a heartbeat feedback message sent by the public network server, and completing the establishment of the communication channel, wherein when the heartbeat feedback message cannot be received, the internet of things gateway actively performs disconnection reconnection attempt, and giving up the reconnection attempt after a plurality of attempts fail.
Step 3, starting a client module:
3a) Starting a worker thread pool by adopting a Netty communication framework and a UDP communication protocol, performing message processing on the thread pool, binding a host port, generating a channel handle, and processing message data sent by a public network server and an Internet of things gateway by a message processing module;
3b) Establishing a local area network communication channel, firstly detecting whether an Internet of things gateway to be connected exists in the local area network, if so, directly sending a channel authentication request to the Internet of things gateway, wherein the Internet of things gateway can detect a client alias, a client ID and a password after receiving the channel authentication request message, can reply an authentication feedback message after passing authentication, and after successful authentication, a client module can maintain a channel between the Internet through a heartbeat data packet and monitor the heartbeat feedback information of the Internet of things gateway module to support a disconnection reconnection function;
3c) When detecting that the Internet of things gateway to be connected does not exist in the local area network, the client module sends a channel authentication request to the public network server, the authentication success maintains a channel between the Internet through a heartbeat data packet, monitors heartbeat feedback information of the public network server, supports a disconnection reconnection function, inquires the public network server about the on-line state and address information of the designated Internet of things gateway through the communication channel between the client and the public network server, gives up the channel connection if the Internet of things gateway is not on-line, and transfers the Internet of things address between the client and the Internet of things gateway to each other by the public network server if the Internet of things gateway is on-line, and the client and the Internet of things gateway try to send UDP hole-making data packets to each other for a plurality of times, so that the method penetrates NAT equipment of the local area network where each other is located, and the establishment of the direct communication channel crossing the local area network is realized;
3d) When the public network forwarding communication channel is established, and the direct communication channel under the public network environment cannot be successfully established, the communication between the client and the gateway of the Internet of things needs to establish the forwarding communication channel through the channels of the client and the gateway of the Internet of things, the forwarding communication channel is used for sending message data to the public network server firstly, then the public network server analyzes and forwards the message data to a designated destination address through the message processing module, so that the network-based penetrating NAT communication between the client and the gateway of the Internet of things is realized, and the message data can be sent and received mutually.
And 4, the client module exits, after the client module exits, the heartbeat data packet sent to the public network server and the Internet of things gateway module is stopped, the Internet of things gateway and the public network server module both detect the exit of the client, the heartbeat feedback data is stopped to be sent to the client, the online information of the client is not maintained, and the client offline message is detected and displayed.
And 5, exiting the gateway module of the Internet of things, stopping a heartbeat data packet sent by the gateway module of the Internet of things to the public network server module after exiting the gateway module of the Internet of things, stopping sending heartbeat feedback data to the gateway of the Internet of things after the public network server module detects exiting of the gateway of the Internet of things, not maintaining on-line information of the gateway of the Internet of things, updating state information and address information of the corresponding gateway of the Internet of things in a database, and detecting and displaying an on-line message of the gateway of the Internet of things.
And 6, exiting the public network server module, and ending the whole system after exiting the public network server module.
According to the technical scheme provided by the embodiment of the invention, the Internet of things to be connected is determined according to the network communication request instruction under the condition that the network communication request instruction sent by the client is acquired; sending a target internet of things searching instruction to an internal network manager corresponding to the client; the method comprises the steps that an internal network manager searches an internal local area network corresponding to a client for the Internet of things to be connected, and a target network connection mode is determined according to the search result of the Internet of things; and establishing a target communication connection channel between the client and the to-be-connected Internet of things based on the target network connection mode. The technical scheme of the embodiment of the invention solves the problems that the flow for establishing the communication channel is complex and the occupied resources are more in the existing cross-regional network communication technology, can directly establish the corresponding communication connection channel according to the network association relation between the client and the to-be-connected Internet of things, improves the efficiency of establishing network communication and reduces the occupied resources of the network communication.
Fig. 6 is a schematic structural diagram of a network communication device provided by the embodiment of the present invention, where the embodiment of the present invention is applicable to a scenario in which a communication channel is established between a client and the internet of things, and the device may be implemented by software and/or hardware, and integrated into a computer device with an application development function.
As shown in fig. 6, the network communication device includes: the system comprises an internet of things determining module 310, a network association determining module 320 and a communication connection channel establishing module 330.
The internet of things determining module 310 is configured to determine, according to a network communication request instruction sent by a client, that an internet of things is to be connected when the network communication request instruction is acquired; the network association relation determining module 320 is configured to determine a target network connection mode according to the network association relation between the client and the to-be-connected internet of things; the communication connection channel establishing module 330 is configured to establish a target communication connection channel between the client and the to-be-connected internet of things based on the target network connection mode.
According to the technical scheme provided by the embodiment of the invention, the Internet of things to be connected is determined according to the network communication request instruction under the condition that the network communication request instruction sent by the client is acquired; determining a target network connection mode according to the network association relation between the client and the to-be-connected Internet of things; and establishing a target communication connection channel between the client and the to-be-connected Internet of things based on the target network connection mode. The technical scheme of the embodiment of the invention solves the problems that the flow for establishing the communication channel is complex and the occupied resources are more in the existing cross-regional network communication technology, can directly establish the corresponding communication connection channel according to the network association relation between the client and the to-be-connected Internet of things, improves the efficiency of establishing network communication and reduces the occupied resources of the network communication.
In an alternative embodiment, the network association determining module 320 is specifically configured to: sending a target internet of things searching instruction to an internal network manager corresponding to the client; the internal network manager searches the internal local area network corresponding to the client for the Internet of things to be connected, and determines the target network connection mode according to the Internet of things search result; the target network connection mode comprises the following steps: at least one of a local area network connection mode and a public network connection mode.
In an alternative embodiment, the network association determining module 320 includes: the public network connection mode determining unit is used for: after the target network connection mode is determined to be a public network connection mode, respectively sending a direct communication attempt instruction to the client and the to-be-connected Internet of things; the client sends client hole punching data to the to-be-connected Internet of things based on a public network, and the to-be-connected Internet of things sends Internet of things hole punching data to the client based on the public network; and determining a target public network connection mode based on the receiving results of the client and the to-be-connected Internet of things on the hole punching data.
In an optional implementation manner, the public network connection mode determining unit includes: the target public network connection mode determining subunit is configured to: determining that the target public network connection mode is a public network direct connection mode under the condition that the client receives the internet of things hole punching data and the internet of things to be connected receives the client hole punching data; otherwise, determining that the target public network connection mode is a public network indirect connection mode.
In an alternative embodiment, the communication connection channel establishment module 330 is specifically configured to: establishing a target local area network communication channel based on the local area network association relation between the client and the to-be-connected Internet of things under the condition that the target network connection mode is the local area network connection mode; establishing a target public network direct communication channel based on a public gateway connection relationship between the client and the to-be-connected Internet of things under the condition that the target network connection mode is the public network direct connection mode; and under the condition that the target network connection mode is the public network direct connection mode, establishing a target public network indirect communication channel according to the network addresses of the client and the to-be-connected Internet of things in the public network.
In an alternative embodiment, the network communication device further comprises: gateway device determining module for: before the target communication connection channel is established, sending preset heartbeat data to candidate gateway equipment; and acquiring heartbeat feedback information aiming at the preset heartbeat data and sent by the candidate gateway equipment, and determining target gateway equipment according to the heartbeat feedback information.
The network communication device provided by the embodiment of the invention can execute the network communication method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Fig. 7 is a schematic structural diagram of a network communication system provided by the embodiment of the present invention, where the embodiment of the present invention is applicable to a scenario in which a communication channel is established between a client and the internet of things, and the system may be implemented by software and/or hardware, and integrated into a computer device with an application development function.
As shown in fig. 7, the system includes: the system comprises a network manager, a client and the Internet of things; the network manager is configured to determine a target network connection mode according to a network association relationship between the client and the internet of things under the condition that a network communication request instruction sent by the client is acquired; the client is used for establishing a target communication connection channel with the Internet of things based on the target network connection mode and carrying out network communication based on the target communication connection channel and the Internet of things; the internet of things is used for establishing a target communication connection channel with the client based on the target network connection mode and carrying out network communication with the client based on the target communication connection channel.
Optionally, the network manager includes: the system comprises an Internet of things determining module, a network association determining module and a communication connection channel establishing module. The system comprises an Internet of things determining module, a client and a server, wherein the Internet of things determining module is used for determining the Internet of things according to a network communication request instruction sent by the client under the condition that the network communication request instruction is acquired; the network association relation determining module is used for determining a target network connection mode according to the network association relation between the client and the Internet of things; and the communication connection channel establishment module is used for establishing a target communication connection channel between the client and the Internet of things based on the target network connection mode.
According to the technical scheme provided by the embodiment of the invention, the Internet of things is determined according to the network communication request instruction under the condition that the network communication request instruction sent by the client is acquired; determining a target network connection mode according to the network association relation between the client and the Internet of things; and establishing a target communication connection channel between the client and the Internet of things based on the target network connection mode. The technical scheme of the embodiment of the invention solves the problems that the flow for establishing the communication channel is complex and the occupied resources are more in the existing cross-regional network communication technology, can directly establish the corresponding communication connection channel according to the network association relation between the client and the Internet of things, improves the efficiency of establishing network communication and reduces the occupied resources of the network communication.
In an optional implementation manner, the network association relationship determining module is specifically configured to: sending a target internet of things searching instruction to an internal network manager corresponding to the client; the internal network manager searches the Internet of things in the internal local area network corresponding to the client, and determines the target network connection mode according to the Internet of things search result; the target network connection mode comprises the following steps: at least one of a local area network connection mode and a public network connection mode.
In an alternative embodiment, the network association determining module includes: the public network connection mode determining unit is used for: after the target network connection mode is determined to be a public network connection mode, sending direct communication attempt instructions to the client and the Internet of things respectively; the client sends the client hole punching data to the Internet of things based on a public network, and the Internet of things sends the Internet of things hole punching data to the client based on the public network; and determining a target public network connection mode based on the receiving results of the client and the Internet of things on the hole punching data.
In an optional implementation manner, the public network connection mode determining unit includes: the target public network connection mode determining subunit is configured to: determining that the target public network connection mode is a public network direct connection mode under the condition that the client receives the internet of things hole punching data and the internet of things receives the client hole punching data; otherwise, determining that the target public network connection mode is a public network indirect connection mode.
In an alternative embodiment, the communication connection channel establishment module is specifically configured to: establishing a target local area network communication channel based on the local area network association relation between the client and the Internet of things under the condition that the target network connection mode is the local area network connection mode; establishing a target public network direct communication channel based on the public gateway connection relation of the client and the Internet of things under the condition that the target network connection mode is the public network direct connection mode; and under the condition that the target network connection mode is the public network direct connection mode, establishing a target public network indirect communication channel according to the network addresses of the client and the Internet of things in the public network.
In an alternative embodiment, the network manager further comprises: gateway device determining module for: before the target communication connection channel is established, sending preset heartbeat data to candidate gateway equipment; and acquiring heartbeat feedback information aiming at the preset heartbeat data and sent by the candidate gateway equipment, and determining target gateway equipment according to the heartbeat feedback information.
Fig. 8 is a schematic structural diagram of another network communication system according to an embodiment of the present invention, where, as shown in fig. 8, the network communication system mainly includes a public network server module, an internet of things gateway module, and a client module. Wherein: public network server module: the system is used for managing and maintaining state information of the gateway module of the Internet of things and the client module, has the functions of sending and receiving information, and helps the gateway module of the Internet of things and the client module to establish a direct communication channel and a forwarding communication channel. Gateway module of Internet of things: for responding to requests from the client modules and for communicating messages with the online client modules and for detecting the online status of the client modules. Client module: the system is used for carrying out message communication with the public network server and the gateway of the Internet of things, carrying out remote communication as a mobile terminal and supporting the function of disconnecting reconnection.
The network communication system provided by the embodiment of the invention can execute the network communication method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Fig. 9 is a schematic structural diagram of a computer device according to an embodiment of the present invention. Fig. 9 illustrates a block diagram of an exemplary computer device 12 suitable for use in implementing embodiments of the present invention. The computer device 12 shown in fig. 9 is merely an example and should not be construed as limiting the functionality and scope of use of embodiments of the present invention. Computer device 12 may be any terminal device having computing capabilities and may be configured in a network communication device.
As shown in fig. 9, the computer device 12 is in the form of a general purpose computing device. Components of computer device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, a bus 18 that connects the various system components, including the system memory 28 and the processing units 16.
Bus 18 may be one or more of several types of bus structures including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures. By way of example, and not limitation, such architectures include Industry Standard Architecture (ISA) bus, micro channel architecture (MAC) bus, enhanced ISA bus, video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Computer device 12 typically includes a variety of computer system readable media. Such media can be any available media that is accessible by computer device 12 and includes both volatile and nonvolatile media, removable and non-removable media.
The system memory 28 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM) 30 and/or cache memory 32. The computer device 12 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 34 may be used to read from or write to non-removable, nonvolatile magnetic media (not shown in FIG. 9, commonly referred to as a "hard disk drive"). Although not shown in fig. 9, a magnetic disk drive for reading from and writing to a removable non-volatile magnetic disk (e.g., a "floppy disk"), and an optical disk drive for reading from or writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In such cases, each drive may be coupled to bus 18 through one or more data medium interfaces. The system memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to carry out the functions of the embodiments of the invention.
A program/utility 40 having a set (at least one) of program modules 42 may be stored in, for example, system memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each or some combination of which may include an implementation of a network environment. Program modules 42 generally perform the functions and/or methods of the embodiments described herein.
The computer device 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), one or more devices that enable a user to interact with the computer device 12, and/or any devices (e.g., network card, modem, etc.) that enable the computer device 12 to communicate with one or more other computing devices. Such communication may occur through an input/output (I/O) interface 22. Moreover, computer device 12 may also communicate with one or more networks such as a Local Area Network (LAN), a Wide Area Network (WAN) and/or a public network, such as the Internet, through network adapter 20. As shown in fig. 9, the network adapter 20 communicates with other modules of the computer device 12 via the bus 18. It should be appreciated that although not shown in fig. 9, other hardware and/or software modules may be used in connection with computer device 12, including, but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, data backup storage systems, and the like.
The processing unit 16 executes various functional applications and data processing by running a program stored in the system memory 28, for example, implementing a network communication method provided by the present embodiment, the method including:
under the condition that a network communication request instruction sent by a client is obtained, determining the Internet of things to be connected according to the network communication request instruction;
determining a target network connection mode according to the network association relation between the client and the to-be-connected Internet of things;
and establishing a target communication connection channel between the client and the to-be-connected Internet of things based on the target network connection mode.
The present embodiment provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements a network communication method as provided by any embodiment of the present invention, comprising:
under the condition that a network communication request instruction sent by a client is obtained, determining the Internet of things to be connected according to the network communication request instruction;
determining a target network connection mode according to the network association relation between the client and the to-be-connected Internet of things;
and establishing a target communication connection channel between the client and the to-be-connected Internet of things based on the target network connection mode.
The computer storage media of embodiments of the invention may take the form of any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium may be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations of the present invention may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
It will be appreciated by those of ordinary skill in the art that the modules or steps of the invention described above may be implemented in a general purpose computing device, they may be centralized on a single computing device, or distributed over a network of computing devices, or they may alternatively be implemented in program code executable by a computer device, such that they are stored in a memory device and executed by the computing device, or they may be separately fabricated as individual integrated circuit modules, or multiple modules or steps within them may be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.
Note that the above is only a preferred embodiment of the present invention and the technical principle applied. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, while the invention has been described in connection with the above embodiments, the invention is not limited to the embodiments, but may be embodied in many other equivalent forms without departing from the spirit or scope of the invention, which is set forth in the following claims.

Claims (10)

1. A method of network communication, comprising:
under the condition that a network communication request instruction sent by a client is obtained, determining the Internet of things to be connected according to the network communication request instruction;
determining a target network connection mode according to the network association relation between the client and the to-be-connected Internet of things;
and establishing a target communication connection channel between the client and the to-be-connected Internet of things based on the target network connection mode.
2. The method of claim 1, wherein the determining the target network connection mode according to the network association relationship between the client and the to-be-connected internet of things comprises:
Sending a target internet of things searching instruction to an internal network manager corresponding to the client;
the internal network manager searches the internal local area network corresponding to the client for the Internet of things to be connected, and determines the target network connection mode according to the Internet of things search result;
the target network connection mode comprises the following steps: at least one of a local area network connection mode and a public network connection mode.
3. The method of claim 2, further comprising, after determining that the target network connection is a public network connection:
a direct communication attempt instruction is sent to the client and the internet of things to be connected respectively;
the client sends client hole punching data to the to-be-connected Internet of things based on a public network, and the to-be-connected Internet of things sends Internet of things hole punching data to the client based on the public network;
and determining a target public network connection mode based on the receiving results of the client and the to-be-connected Internet of things on the hole punching data.
4. The method of claim 3, wherein the determining the target public network connection mode based on the receiving results of the hole punching data by the client and the internet of things to be connected comprises:
Determining that the target public network connection mode is a public network direct connection mode under the condition that the client receives the internet of things hole punching data and the internet of things to be connected receives the client hole punching data;
otherwise, determining that the target public network connection mode is a public network indirect connection mode.
5. The method according to claim 2, wherein the public network connection mode includes: the public network direct connection mode and the public network indirect connection mode, the establishing a target communication connection channel between the client and the to-be-connected internet of things based on the target network connection mode comprises the following steps:
establishing a target local area network communication channel based on the local area network association relation between the client and the to-be-connected Internet of things under the condition that the target network connection mode is the local area network connection mode;
establishing a target public network direct communication channel based on a public gateway connection relationship between the client and the to-be-connected Internet of things under the condition that the target network connection mode is the public network direct connection mode;
and under the condition that the target network connection mode is the public network direct connection mode, establishing a target public network indirect communication channel according to the network addresses of the client and the to-be-connected Internet of things in the public network.
6. The method of claim 5, further comprising, prior to establishing the target communication connection path:
sending preset heartbeat data to candidate gateway equipment;
and acquiring heartbeat feedback information aiming at the preset heartbeat data and sent by the candidate gateway equipment, and determining target gateway equipment according to the heartbeat feedback information.
7. A network communication device, the device comprising:
the system comprises an Internet of things determining module, a network communication request module and a network connection module, wherein the Internet of things determining module is used for determining the Internet of things to be connected according to a network communication request instruction sent by a client;
the network association relation determining module is used for determining a target network connection mode according to the network association relation between the client and the to-be-connected Internet of things;
and the communication connection channel establishment module is used for establishing a target communication connection channel between the client and the to-be-connected Internet of things based on the target network connection mode.
8. A network communication system, the system comprising: the system comprises a network manager, a client and the Internet of things;
the network manager is configured to determine a target network connection mode according to a network association relationship between the client and the internet of things under the condition that a network communication request instruction sent by the client is acquired;
The client is used for establishing a target communication connection channel with the Internet of things based on the target network connection mode and carrying out network communication based on the target communication connection channel and the Internet of things;
the internet of things is used for establishing a target communication connection channel with the client based on the target network connection mode and carrying out network communication with the client based on the target communication connection channel.
9. A computer device, the computer device comprising:
one or more processors;
a memory for storing one or more programs;
when executed by the one or more processors, causes the one or more processors to implement the network communication method of any of claims 1-7.
10. A computer readable storage medium having stored thereon a computer program, which when executed by a processor implements the network communication method according to any of claims 1-7.
CN202311667476.6A 2023-12-06 2023-12-06 Network communication method, device, equipment and storage medium Pending CN117640722A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311667476.6A CN117640722A (en) 2023-12-06 2023-12-06 Network communication method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311667476.6A CN117640722A (en) 2023-12-06 2023-12-06 Network communication method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117640722A true CN117640722A (en) 2024-03-01

Family

ID=90035449

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311667476.6A Pending CN117640722A (en) 2023-12-06 2023-12-06 Network communication method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117640722A (en)

Similar Documents

Publication Publication Date Title
CN110166432B (en) Method for accessing intranet target service and method for providing intranet target service
US9253129B2 (en) Instant messaging with browser collaboration
CN106790758B (en) Method and device for accessing network object in NAT network
CN113067882A (en) Message processing method and device, electronic equipment and medium
US9065788B2 (en) Method, device and system for voice communication
WO2022127118A1 (en) File transmission method and apparatus, and electronic device and storage medium
CN114221955B (en) Device cross-region access method and device, electronic device and storage medium
CN111414208A (en) Application program starting method, device and equipment
CN112769876B (en) Method, device, equipment and medium for acquiring equipment channel information
CN111737022A (en) Interface calling method, system, equipment and medium based on micro-service
CN109286684B (en) Communication connection processing method and device, proxy server and storage medium
US7779130B1 (en) Method and apparatus to transfer a new data object from a data acquisition device to a user storage device
US20220022036A1 (en) Security verification method and system, computer device and medium
CN108540552B (en) Device interconnection method, apparatus, system, device and storage medium
CN113382056A (en) Data reporting method, device, equipment, storage medium and system
CN109151033B (en) Communication method and device based on distributed system, electronic equipment and storage medium
CN113992382A (en) Service data processing method and device, electronic equipment and storage medium
CN117640722A (en) Network communication method, device, equipment and storage medium
US20200274786A1 (en) Apparatus and method for managing message transmission delay
CN114553663B (en) Abnormality detection method, abnormality detection device, abnormality detection equipment and storage medium
CN114390239B (en) Communication method, device, system, electronic device, and storage medium
CN103380593B (en) A kind of in system upgrade process to method, device and equipment that business processes
CN114785861A (en) Service request forwarding system, method, computer equipment and storage medium
CN110213310A (en) A kind of method for obtaining path, device and the storage medium of network service
CN109309583B (en) Information acquisition method and device based on distributed system, electronic equipment and 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