CN104010037A - Communication method and device - Google Patents

Communication method and device Download PDF

Info

Publication number
CN104010037A
CN104010037A CN201410241052.8A CN201410241052A CN104010037A CN 104010037 A CN104010037 A CN 104010037A CN 201410241052 A CN201410241052 A CN 201410241052A CN 104010037 A CN104010037 A CN 104010037A
Authority
CN
China
Prior art keywords
computer
router
wireless connection
address
direct wireless
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
CN201410241052.8A
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.)
Kingsoft Guangzhou Network Technology Co Ltd
Original Assignee
Kingsoft Guangzhou Network 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 Kingsoft Guangzhou Network Technology Co Ltd filed Critical Kingsoft Guangzhou Network Technology Co Ltd
Priority to CN201410241052.8A priority Critical patent/CN104010037A/en
Publication of CN104010037A publication Critical patent/CN104010037A/en
Pending legal-status Critical Current

Links

Landscapes

  • Mobile Radio Communication Systems (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention provides a communication method and device. The communication method comprises the steps that whether a computer can be directly and wirelessly connected with a mobile device is judged, wherein the computer and the mobile device are not in the same subnet; if direct wireless connection can be set up, the direct wireless connection is set up so that data packets between the computer and the mobile device can be transmitted through the direct wireless connection. The method can save the bandwidth resource of a server.

Description

Communication method and device
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a communication method and apparatus.
Background
The mobile device can obtain data from the computer, and a connection between the mobile device and the computer needs to be established before the mobile device obtains the data from the computer. The mobile device and the computer may be connected by a Universal Serial Bus (USB) line, but this approach requires a USB line.
When no USB line exists, the mobile equipment and the computer need to adopt wireless connection to transmit data packets. When the mobile device and the computer are not in the same ethernet subnet, the data packets transmitted between the mobile device and the computer need to be transferred through the server, which causes the server to consume more bandwidth resources.
Disclosure of Invention
The present invention is directed to solving, at least to some extent, one of the technical problems in the related art.
To this end, an object of the present invention is to provide a communication method, which can transmit data packets through a direct wireless connection between a mobile device and a computer, without a server relay, thereby saving bandwidth resources of the server.
Another object of the present invention is to provide a communication device.
In order to achieve the above object, an embodiment of the first aspect of the present invention provides a communication method, including: judging whether a direct wireless connection between a computer and a mobile device can be established, wherein the computer and the mobile device are not in the same subnet; and if the direct wireless connection can be established, establishing the direct wireless connection so as to transmit the data packet between the computer and the mobile equipment through the direct wireless connection.
In the communication method provided in the first aspect of the present invention, by establishing the direct wireless connection between the computer and the mobile device and transmitting the data packet through the direct wireless connection, the data transfer by the server is not required, and the bandwidth resource of the server can be saved.
In order to achieve the above object, a communication device according to an embodiment of a second aspect of the present invention includes: the system comprises a judging module, a judging module and a judging module, wherein the judging module is used for judging whether the direct wireless connection between a computer and mobile equipment can be established or not, and the computer and the mobile equipment are not in the same subnet; and the establishing module is used for establishing the direct wireless connection if the direct wireless connection can be established so as to transmit the data packet between the computer and the mobile equipment through the direct wireless connection.
The communication device according to the second aspect of the present invention establishes the direct wireless connection between the computer and the mobile device, and transmits the data packet through the direct wireless connection, so that the data transfer by the server is not required, and the bandwidth resource of the server can be saved.
In order to achieve the above object, a communication device according to a third embodiment of the present invention includes: the device comprises a shell, a processor, a memory, a circuit board and a power circuit, wherein the circuit board is arranged in a space enclosed by the shell, and the processor and the memory are arranged on the circuit board; the power supply circuit is used for supplying power to each circuit or device of the server; the memory is used for storing executable program codes; the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory for performing the steps of: judging whether a direct wireless connection between a computer and a mobile device can be established, wherein the computer and the mobile device are not in the same subnet; and if the direct wireless connection can be established, establishing the direct wireless connection so as to transmit the data packet between the computer and the mobile equipment through the direct wireless connection.
In the communication device according to the third aspect of the present invention, the direct wireless connection between the computer and the mobile device is established, and the data packet is transmitted through the direct wireless connection, so that the data transfer by the server is not required, and the bandwidth resource of the server can be saved.
Additional aspects and advantages of the invention will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the invention.
Drawings
The foregoing and/or additional aspects and advantages of the present invention will become apparent and readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings of which:
fig. 1 is a flowchart illustrating a communication method according to an embodiment of the present invention;
fig. 2 is a flow chart of a communication method according to another embodiment of the present invention;
fig. 3 is a flow chart of a communication method according to another embodiment of the present invention;
fig. 4 is a schematic structural diagram of a communication device according to another embodiment of the present invention;
fig. 5 is a schematic structural diagram of a communication device according to another embodiment of the present invention.
Detailed Description
Reference will now be made in detail to embodiments of the present invention, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the accompanying drawings are illustrative only for the purpose of explaining the present invention, and are not to be construed as limiting the present invention. On the contrary, the embodiments of the invention include all changes, modifications and equivalents coming within the spirit and terms of the claims appended hereto.
Fig. 1 is a schematic flow chart of a communication method according to an embodiment of the present invention, where the method includes:
s11: and judging whether the direct wireless connection between the computer and the mobile equipment can be established or not, wherein the computer and the mobile equipment are not in the same subnet.
The Computer may be a Personal Computer (PC), and the mobile device may be a mobile phone or a tablet Computer.
The computer can be accessed to the Internet by adopting a public Internet Protocol (IP) address; or, the computer can also surf the internet through the router, and the computer does not use the public network IP address at the moment.
The mobile device can surf the internet through Wi-Fi or a mobile network, and in both cases, the mobile device is equivalent to surfing the internet by using a router.
The direct wireless connection refers to connection which does not need transfer of a server when communication is established after connection, and for a scene including a router, the direct wireless connection between the computer and the mobile equipment comprises the corresponding router. For example, when a computer uses a public network IP address, a router at the mobile device end is called a second router, and the direct wireless connection between the computer and the mobile device is as follows: computer-second router-mobile device. For another example, when the computer accesses the internet through the first router, the direct wireless connection between the computer and the mobile device is as follows: computer-first router-second router-mobile device.
The direct wireless connection between the computer and the mobile device may be a direct connection that can be established without server assistance, or may be a direct connection that can be established without server assistance.
Specifically, the scenarios that can establish a direct connection without server assistance include:
the computer uses the public network IP address; or,
at least one of the first router and the second router meets a preset condition, wherein the preset condition comprises that:
the Network Address Translation (NAT) type of the router is a full cone NAT (full cone NAT); or,
and the computer or the mobile equipment successfully completes the port mapping at the router.
Scenarios that require server assistance to be able to establish a direct connection include:
the NAT type of the first router and the second router is a case other than the following cases: both are symmetric nats (symmetric nats); alternatively, one is a symmetric NAT and the other is a Port-restricted cone NAT.
The NAT types can be classified into full cone NAT (full cone NAT), Port Restricted cone NAT (addressed Restricted cone NAT), Port-Restricted cone NAT (Port-Restricted cone NAT) and symmetric NAT (symmetric NAT).
In addition, the connection in the embodiment of the present invention is not limited to a Transmission Control Protocol (TCP) connection, but when one side sends data and the other side can receive the data, the connection is successful.
S12: and if the direct wireless connection can be established, establishing the direct wireless connection so as to transmit the data packet between the computer and the mobile equipment through the direct wireless connection.
The server can send the address information of one party to the other party in a scene without the assistance of the server, and simultaneously send the address information of the two parties to the other party respectively in a scene with the assistance of the server. The address information may include an IP address and a port number.
Specifically, when the computer uses the public network IP address, the IP address and the port number of the computer can be sent to the mobile device, and after receiving the IP address and the port number, the mobile device initiates establishment of direct wireless connection with the computer according to the IP address and the port number.
When the NAT type of at least one of the first router and the second router is a full cone NAT, the server may transmit the IP address of the router that is the full cone NAT and the temporarily assigned port number to the other party. For example, when the NAT type of the first router is a full cone NAT, the server may send the IP address and the temporarily assigned port number of the first router to the mobile device through the second router, so that the mobile device initiates establishment of a direct wireless connection with the computer according to the IP address and the port number. Because the number of ports of the router is limited, a port number is usually allocated to the intranet device in a port multiplexing manner during communication, and therefore, the port number temporarily allocated by the first router refers to a port number currently allocated to the computer.
When at least one of the first router and the second router successfully completes the port mapping, the server may transmit an IP address of the router that successfully completes the port mapping and the mapped port number to the other. For example, when the first router successfully completes the port mapping, the IP address of the first router and the mapped port number may be sent to the mobile device through the second router, so that the mobile device initiates establishment of a direct connection with the computer according to the IP address and the port number. Different from the temporarily allocated port number, a certain designated port may be fixedly allocated to the intranet device during port mapping, and therefore, the port number mapped by the first router is a port number fixedly allocated to the computer.
In addition, it should be noted that when both routers meet the preset condition, one address information may be optionally sent to the other end.
When the server is needed to assist, the server can simultaneously send the address information of the other end to the two ends, so that the computer and the mobile equipment establish the direct connection between the computer and the mobile equipment by adopting a UDP (user Datagram protocol) hole punching mode after receiving the address information of the opposite end.
In the embodiment, the direct wireless connection between the computer and the mobile device is established, and the data packet is transmitted through the direct wireless connection, so that the data transfer by the server is not needed, and the bandwidth resource of the server can be saved.
Fig. 2 is a schematic flow chart of a communication method according to another embodiment of the present invention, and this embodiment takes establishing a connection between a PC and a mobile phone as an example.
Referring to fig. 2, the method of the present embodiment includes:
s201: when the PC needs to be connected with the mobile phone, a request message is sent to the server, and the first address information, the identification information of the PC and the identification information of the mobile phone are carried in the request message.
Wherein, when the PC uses the public network IP address, the first address information is the IP address and the port number of the PC. If the PC uses the subnet IP address, the first address information is the IP address of the first router and a temporary port number assigned to the PC by the first router.
S202: the server judges whether the PC uses the public network IP address, if so, executes S203-S205, otherwise, executes S206 and the subsequent steps.
The PC and the mobile phone can be registered with the server in advance, address information of the PC, identification information of the PC, address information of the mobile phone and identification information of the mobile phone are correspondingly stored in the registration information, and the address information comprises an IP address and a port number.
And after receiving the request message, the server acquires the identification information of the PC and the IP address in the first address information from the request message, acquires the IP address from the registration information according to the identification information of the PC, determines that the PC uses the public network IP address if the received IP address is the same as the acquired IP address, and otherwise, does not use the public network IP address.
S203: and the server sends the first address information to the mobile phone.
The server can acquire the address information of the mobile phone from the registration information according to the identification information of the mobile phone contained in the request message, and send the first address information to the mobile phone according to the address information.
S204: and the mobile phone initiates to establish direct wireless connection with the PC according to the first address information.
S205: the PC and the mobile phone transmit data packets through the direct wireless connection.
S206: the server obtains the NAT type of the first router and the NAT type of the second router, judges whether at least one of the NAT types is a complete cone type NAT, if so, executes S207-209, otherwise, executes S210 and the subsequent steps.
The PC and the mobile phone may detect the NAT type of the first router and the NAT type of the second router through a Session transfer application NAT (STUN) and store the detected types in the registration information of the server in correspondence with the identification information, and the server may obtain the NAT type of the first router from the registration information according to the identification information of the PC and obtain the NAT type of the second router according to the identification information of the mobile phone.
In this embodiment, assuming that the NAT type of the first router is a full cone NAT, the following process is performed:
s207: and the server sends the first address information to the mobile phone.
Wherein the first address information is an IP address of the first router and a temporary port number assigned to the PC by the first router. When sending, the server may obtain address information of the mobile phone from the registration information according to the identification information of the mobile phone included in the request message, and send the first address information to the mobile phone according to the address information.
S208: and the mobile phone initiates to establish direct wireless connection with the PC according to the first address information.
Similarly, when the NAT type of the second router is the full cone NAT, the server may send second address information to the PC, and the PC initiates establishment of a direct wireless connection with the mobile phone according to the second address information, where the second address information is an IP address of the second router and a temporary port number assigned to the mobile phone by the second router.
S209: the PC and the mobile phone transmit data packets through the direct wireless connection.
S210: the server determines whether the direct connection can be established, if so, performs S211-S213, otherwise, performs S214.
Wherein when the NAT type of the first router and the NAT type of the second router are other types than the following types, determining that the direct connection can be established in an assisting manner:
both parties are symmetric NATs; or, one party is a symmetric NAT, and the other party is a port-restricted conical NAT.
S211: the server simultaneously sends the first address information to the mobile phone and sends the second address information to the PC.
The first address information is an IP address of the first router and a temporary port number assigned to the PC by the first router, and the second address information is an IP address of the second router and a temporary port number assigned to the handset by the second router. The first address information and the second address information can be stored in the server together with the corresponding identifier in advance, and the server acquires the corresponding address information according to the identifier, or the server receives a request message sent by a PC and/or a mobile phone and acquires the first address information and/or the second address information from the request message.
S212: the PC and the mobile phone establish direct wireless connection by adopting a User Datagram Protocol (UDP) punching mode.
After receiving the address information of the opposite party, the PC and the mobile phone try to repeatedly send UDP data packets to the address, if the opposite party receives the data packets, the connection is successful, and in the process, after the data packets are sent to the other end, the router allows the other end to send the packets to the port on the router, namely UDP hole punching.
S213: the PC and the mobile phone transmit data packets through the direct wireless connection.
S214: the server transfers the data packet transmitted between the PC and the mobile phone.
In the embodiment, the direct wireless connection between the computer and the mobile device is established, and the data packet is transmitted through the direct wireless connection, so that the data transfer by the server is not needed, and the bandwidth resource of the server can be saved. The embodiment can establish the direct wireless connection without the assistance of the server, or the server assists in establishing the direct wireless connection, so that the application range can be improved.
Fig. 3 is a schematic flow chart of a communication method according to another embodiment of the present invention, and this embodiment takes establishing a connection between a PC and a mobile phone as an example.
S301: the PC detects whether the first router supports Universal Plug and Play (UPNP) protocol, if so, executes S302, otherwise, executes S307.
The PC may detect whether the first router supports the UPNP protocol when determining that the PC does not use the public network IP address.
The PC may send a Simple Service Discovery Protocol (SSDP) multicast packet, and the first router replies after receiving the SSDP multicast packet, where the reply includes whether the UPNP Protocol is supported.
S302: the PC adds port mapping on the first router, and maps the communication port of the PC to the designated fixed port on the first router.
Specifically, the PC may send a Hypertext transfer Protocol (HTTP) request to the first router, where the first router returns Extensible markup language (XML) description to the PC according to the HTTP request, the XML description includes device description, the PC parses the device description to obtain Simple Object Access Protocol (SOAP) description for controlling port mapping, sends a SOAP request to add a port mapping according to the SOAP description, and the first router maps the port to a specified fixed port.
S303: the PC successfully completes port mapping on the first router and sends first address information to the server, wherein the first address information is the IP address of the first router and the mapped port number.
S304: and the server sends the first address information to the mobile phone.
S305: and the mobile phone initiates to establish direct wireless connection with the PC according to the first address information.
In this embodiment, for example, the first address information is sent to the mobile phone, optionally, the server may also send second address information to the PC, the PC initiates establishment of a direct wireless connection with the mobile phone, and the second address information is an IP address of the second router and a mapped port number that are sent after the mobile phone successfully completes port mapping on the second router.
S306: the PC and the mobile phone transmit data packets through the direct wireless connection.
Optionally, after the PC and the handset are no longer in communication, the PC and/or the handset may send a SOAP request to the corresponding router to delete the previously created port mapping.
S307: and (6) ending.
The ending means that the port mapping process is not performed any more, and at this time, the server may also request to assist in establishing the direct wireless connection, and the like.
In the embodiment, the direct wireless connection between the computer and the mobile device is established, and the data packet is transmitted through the direct wireless connection, so that the data transfer by the server is not needed, and the bandwidth resource of the server can be saved. In the embodiment, the direct wireless connection is established in a port mapping manner, so that the diversity of the establishing manner can be realized.
Fig. 4 is a schematic structural diagram of a communication apparatus according to another embodiment of the present invention, where the apparatus 40 includes a determining module 41 and a establishing module 42.
The judging module 41 is configured to judge whether a direct wireless connection between a computer and a mobile device can be established, where the computer and the mobile device are not in the same subnet;
the Computer may be a Personal Computer (PC), and the mobile device may be a mobile phone or a tablet Computer.
The computer can surf the internet by adopting a public network IP address; or, the computer can also surf the internet through the router, and the computer does not use the public network IP address at the moment.
The mobile device can surf the internet through Wi-Fi or a mobile network, and in both cases, the mobile device is equivalent to surfing the internet by using a router.
The direct wireless connection refers to connection which does not need transfer of a server when communication is established after connection, and for a scene including a router, the direct wireless connection between the computer and the mobile equipment comprises the corresponding router. For example, when a computer uses a public network IP address, a router at the mobile device end is called a second router, and the direct wireless connection between the computer and the mobile device is as follows: computer-second router-mobile device. For another example, when the computer accesses the internet through the first router, the direct wireless connection between the computer and the mobile device is as follows: computer-first router-second router-mobile device.
The direct wireless connection between the computer and the mobile device may be a direct connection that can be established without server assistance, or may be a direct connection that can be established without server assistance.
The establishing module 42 is configured to establish the direct wireless connection if the direct wireless connection can be established, so as to transmit the data packet between the computer and the mobile device through the direct wireless connection.
In one embodiment, referring to fig. 5, the determining module 41 may include a first unit 411 and a second unit 412, where the first unit 411 is used to determine whether the computer uses a public network IP address; the second unit 412 is configured to determine that the direct wireless connection between the computer and the mobile device can be established when the first unit determines whether the computer uses the public network IP address.
Correspondingly, the establishing module 42 is specifically configured to: and sending the IP address and the port number of the computer to the mobile equipment so that the mobile equipment initiates to establish the direct wireless connection according to the IP address and the port number of the computer.
In an embodiment, the determining module 41 further includes a third unit 413 and a fourth unit 414, where the third unit 413 is configured to determine whether at least one of the first router and the second router satisfies a predetermined condition if the computer does not use the public network IP address; the fourth unit 414 is configured to determine that a direct wireless connection between the computer and the mobile device can be established when at least one of the first router and the second router meets a preset condition, where the preset condition includes: the NAT type of the router is a complete cone type NAT, or a computer or mobile equipment successfully completes port mapping on the router; the first router is a router of a subnet where the computer is located, and the second router is a router of a subnet where the mobile device is located.
Correspondingly, the establishing module 42 is specifically configured to: and sending the IP address and the port number of the router meeting the preset conditions to the other end so that the other end can initiate to establish the direct wireless connection according to the IP address and the port number, wherein the port number is the mapped port number after the port mapping is successfully completed.
In an embodiment, the determining module 41 further includes a fifth unit 415, where the fifth unit 415 is configured to determine whether the NAT type of the first router and the NAT type of the second router belong to the following situations if the computer does not use a public network IP address and the first router and the second router do not meet the preset condition, and if not, determine that a direct wireless connection between the computer and the mobile device can be established: both are symmetric NATs; alternatively, one is a symmetric NAT and the other is a port-restricted cone NAT.
Correspondingly, the establishing module 42 is specifically configured to: and simultaneously sending first address information to the mobile equipment and second address information to the computer through the server, wherein the first address information is the IP address of the first router and the port number temporarily allocated to the computer, and the second address information is the IP address of the second router and the port number temporarily allocated to the mobile equipment, so that the direct wireless connection is established between the mobile equipment and the computer by adopting a UDP (user Datagram protocol) punching mode according to the address information of the other party.
The apparatus is an apparatus for executing the method, and specific contents may refer to descriptions in the method, which are not described herein again.
In the embodiment, the direct wireless connection between the computer and the mobile device is established, and the data packet is transmitted through the direct wireless connection, so that the data transfer by the server is not needed, and the bandwidth resource of the server can be saved.
The embodiment of the invention also provides a communication device, which comprises a shell, a processor, a memory, a circuit board and a power circuit, wherein the circuit board is arranged in the space enclosed by the shell, and the processor and the memory are arranged on the circuit board; a power supply circuit for supplying power to each circuit or device of the communication apparatus; the memory is used for storing executable program codes; the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory for performing the steps of:
s11': and judging whether the direct wireless connection between the computer and the mobile equipment can be established or not, wherein the computer and the mobile equipment are not in the same subnet.
The Computer may be a Personal Computer (PC), and the mobile device may be a mobile phone or a tablet Computer.
The computer can surf the internet by adopting a public network IP address; or, the computer can also surf the internet through the router, and the computer does not use the public network IP address at the moment.
The mobile device can surf the internet through Wi-Fi or a mobile network, and in both cases, the mobile device is equivalent to surfing the internet by using a router.
The direct wireless connection refers to connection which does not need transfer of a server when communication is established after connection, and for a scene including a router, the direct wireless connection between the computer and the mobile equipment comprises the corresponding router. For example, when a computer uses a public network IP address, a router at the mobile device end is called a second router, and the direct wireless connection between the computer and the mobile device is as follows: computer-second router-mobile device. For another example, when the computer accesses the internet through the first router, the direct wireless connection between the computer and the mobile device is as follows: computer-first router-second router-mobile device.
The direct wireless connection between the computer and the mobile device may be a direct connection that can be established without server assistance, or may be a direct connection that can be established without server assistance.
Specifically, the scenarios that can establish a direct connection without server assistance include:
the computer uses the public network IP address; or,
at least one of the first router and the second router meets a preset condition, wherein the preset condition comprises that:
the NAT type of the router is a complete cone type NAT (full cone NAT); or,
and the computer or the mobile equipment successfully completes the port mapping at the router.
Scenarios that require server assistance to be able to establish a direct connection include:
the NAT type of the first router and the second router is a case other than the following cases: both are symmetric nats (symmetric nats); alternatively, one is a symmetric NAT and the other is a Port-restricted cone NAT.
The NAT types can be classified into full cone NAT (full cone NAT), Port Restricted cone NAT (addressed Restricted cone NAT), Port-Restricted cone NAT (Port-Restricted cone NAT) and symmetric NAT (symmetric NAT).
In addition, the connection in the embodiment of the present invention is not limited to a Transmission Control Protocol (TCP) connection, but when one side sends data and the other side can receive the data, the connection is successful.
S12': and if the direct wireless connection can be established, establishing the direct wireless connection so as to transmit the data packet between the computer and the mobile equipment through the direct wireless connection.
The server can send the address information of one party to the other party in a scene without the assistance of the server, and simultaneously send the address information of the two parties to the other party respectively in a scene with the assistance of the server. The address information may include an IP address and a port number.
Specifically, when the computer uses the public network IP address, the IP address and the port number of the computer can be sent to the mobile device, and after receiving the IP address and the port number, the mobile device initiates establishment of direct wireless connection with the computer according to the IP address and the port number.
When the NAT type of at least one of the first router and the second router is a full cone NAT, the server may transmit the IP address of the router that is the full cone NAT and the temporarily assigned port number to the other party. For example, when the NAT type of the first router is a full cone NAT, the server may send the IP address and the temporarily assigned port number of the first router to the mobile device through the second router, so that the mobile device initiates establishment of a direct wireless connection with the computer according to the IP address and the port number. Because the number of ports of the router is limited, a port number is usually allocated to the intranet device in a port multiplexing manner during communication, and therefore, the port number temporarily allocated by the first router refers to a port number currently allocated to the computer.
When at least one of the first router and the second router successfully completes the port mapping, the server may transmit an IP address of the router that successfully completes the port mapping and the mapped port number to the other. For example, when the first router successfully completes the port mapping, the IP address of the first router and the mapped port number may be sent to the mobile device through the second router, so that the mobile device initiates establishment of a direct connection with the computer according to the IP address and the port number. Different from the temporarily allocated port number, a certain designated port may be fixedly allocated to the intranet device during port mapping, and therefore, the port number mapped by the first router is a port number fixedly allocated to the computer.
In addition, it should be noted that when both routers meet the preset condition, one address information may be optionally sent to the other end.
When the server is needed to assist, the server can simultaneously send the address information of the other end to the two ends, so that the computer and the mobile equipment establish the direct connection between the computer and the mobile equipment by adopting a UDP (user Datagram protocol) hole punching mode after receiving the address information of the opposite end.
In the embodiment, the direct wireless connection between the computer and the mobile device is established, and the data packet is transmitted through the direct wireless connection, so that the data transfer by the server is not needed, and the bandwidth resource of the server can be saved.
It should be noted that the terms "first," "second," and the like in the description of the present invention are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. In addition, in the description of the present invention, "a plurality" means two or more unless otherwise specified.
Any process or method descriptions in flow charts or otherwise described herein may be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing specific logical functions or steps of the process, and alternate implementations are included within the scope of the preferred embodiment of the present invention in which functions may be executed out of order from that shown or discussed, including substantially concurrently or in reverse order, depending on the functionality involved, as would be understood by those reasonably skilled in the art of the present invention.
It should be understood that portions of the present invention may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, the various steps or methods may be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, any one or combination of the following techniques, which are known in the art, may be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application specific integrated circuit having an appropriate combinational logic gate circuit, a Programmable Gate Array (PGA), a Field Programmable Gate Array (FPGA), or the like.
It will be understood by those skilled in the art that all or part of the steps carried by the method for implementing the above embodiments may be implemented by hardware related to instructions of a program, which may be stored in a computer readable storage medium, and when the program is executed, the program includes one or a combination of the steps of the method embodiments.
In addition, functional units in the embodiments of the present invention may be integrated into one processing module, or each unit may exist alone physically, or two or more units are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may also be stored in a computer readable storage medium.
The storage medium mentioned above may be a read-only memory, a magnetic or optical disk, etc.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention, and that variations, modifications, substitutions and alterations can be made to the above embodiments by those of ordinary skill in the art within the scope of the present invention.

Claims (14)

1. A method of communication, comprising:
judging whether a direct wireless connection between a computer and a mobile device can be established, wherein the computer and the mobile device are not in the same subnet;
and if the direct wireless connection can be established, establishing the direct wireless connection so as to transmit the data packet between the computer and the mobile equipment through the direct wireless connection.
2. The method of claim 1, wherein determining whether a direct wireless connection between the computer and the mobile device can be established comprises:
and judging whether the computer uses a public network IP address, if so, judging that the direct wireless connection between the computer and the mobile equipment can be established.
3. The method of claim 2, wherein the establishing the direct wireless connection comprises:
and sending the IP address and the port number of the computer to the mobile equipment so that the mobile equipment initiates to establish the direct wireless connection according to the IP address and the port number of the computer.
4. The method of claim 2, wherein determining whether a direct wireless connection between the computer and the mobile device can be established further comprises:
if the computer does not use the public network IP address, judging whether at least one of the first router and the second router meets a preset condition, if so, judging that the direct wireless connection between the computer and the mobile equipment can be established, wherein the preset condition comprises the following steps: the NAT type of the router is a complete cone type NAT, or a computer or mobile equipment successfully completes port mapping on the router;
the first router is a router of a subnet where the computer is located, and the second router is a router of a subnet where the mobile device is located.
5. The method of claim 4, wherein the establishing the direct wireless connection comprises:
and sending the IP address and the port number of the router meeting the preset conditions to the other end so that the other end can initiate to establish the direct wireless connection according to the IP address and the port number, wherein the port number is the mapped port number after the port mapping is successfully completed.
6. The method of claim 4, wherein determining whether a direct wireless connection between the computer and the mobile device can be established further comprises:
if the computer does not use a public network IP address, and the first router and the second router do not meet the preset conditions, judging whether the NAT type of the first router and the NAT type of the second router belong to the following conditions, and if not, judging that the direct wireless connection between the computer and the mobile equipment can be established: both are symmetric NATs; alternatively, one is a symmetric NAT and the other is a port-restricted cone NAT.
7. The method of claim 6, wherein the establishing the direct wireless connection comprises:
and simultaneously sending first address information to the mobile equipment and second address information to the computer through the server, wherein the first address information is the IP address of the first router and the port number temporarily allocated to the computer, and the second address information is the IP address of the second router and the port number temporarily allocated to the mobile equipment, so that the direct wireless connection is established between the mobile equipment and the computer by adopting a UDP (user Datagram protocol) punching mode according to the address information of the other party.
8. A communications apparatus, comprising:
the system comprises a judging module, a judging module and a judging module, wherein the judging module is used for judging whether the direct wireless connection between a computer and mobile equipment can be established or not, and the computer and the mobile equipment are not in the same subnet;
and the establishing module is used for establishing the direct wireless connection if the direct wireless connection can be established so as to transmit the data packet between the computer and the mobile equipment through the direct wireless connection.
9. The apparatus of claim 8, wherein the determining module comprises:
the first unit is used for judging whether the computer uses a public network IP address;
and the second unit is used for judging that the direct wireless connection between the computer and the mobile equipment can be established when the first unit judges whether the computer uses the public network IP address.
10. The apparatus of claim 9, wherein the establishing module is specifically configured to:
and sending the IP address and the port number of the computer to the mobile equipment so that the mobile equipment initiates to establish the direct wireless connection according to the IP address and the port number of the computer.
11. The apparatus of claim 9, wherein the determining module further comprises:
a third unit, configured to determine whether at least one of the first router and the second router satisfies a preset condition if the computer does not use the public network IP address;
a fourth unit, configured to determine that a direct wireless connection between the computer and the mobile device can be established when at least one of the first router and the second router satisfies a preset condition, where the preset condition includes: the NAT type of the router is a complete cone type NAT, or a computer or mobile equipment successfully completes port mapping on the router; the first router is a router of a subnet where the computer is located, and the second router is a router of a subnet where the mobile device is located.
12. The apparatus of claim 11, wherein the establishing module is specifically configured to:
and sending the IP address and the port number of the router meeting the preset conditions to the other end so that the other end can initiate to establish the direct wireless connection according to the IP address and the port number, wherein the port number is the mapped port number after the port mapping is successfully completed.
13. The apparatus of claim 11, wherein the determining module further comprises:
a fifth unit, configured to determine whether the NAT type of the first router and the NAT type of the second router belong to the following situations if the computer does not use a public network IP address and the first router and the second router do not satisfy the preset condition, and if not, determine that a direct wireless connection between the computer and the mobile device can be established: both are symmetric NATs; alternatively, one is a symmetric NAT and the other is a port-restricted cone NAT.
14. The apparatus of claim 13, wherein the establishing module is specifically configured to:
and simultaneously sending first address information to the mobile equipment and second address information to the computer through the server, wherein the first address information is the IP address of the first router and the port number temporarily allocated to the computer, and the second address information is the IP address of the second router and the port number temporarily allocated to the mobile equipment, so that the direct wireless connection is established between the mobile equipment and the computer by adopting a UDP (user Datagram protocol) punching mode according to the address information of the other party.
CN201410241052.8A 2014-05-30 2014-05-30 Communication method and device Pending CN104010037A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410241052.8A CN104010037A (en) 2014-05-30 2014-05-30 Communication method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410241052.8A CN104010037A (en) 2014-05-30 2014-05-30 Communication method and device

Publications (1)

Publication Number Publication Date
CN104010037A true CN104010037A (en) 2014-08-27

Family

ID=51370528

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410241052.8A Pending CN104010037A (en) 2014-05-30 2014-05-30 Communication method and device

Country Status (1)

Country Link
CN (1) CN104010037A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105681584A (en) * 2016-03-21 2016-06-15 珠海格力电器股份有限公司 Remote control method and device for mobile terminal
CN113179315A (en) * 2021-04-26 2021-07-27 缀初网络技术(上海)有限公司 Method, system and readable storage medium for providing communication between devices in multiple local area networks

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1794212A (en) * 2005-12-14 2006-06-28 王宏源 Method of controlling computer random procedure and its peripheral equipment by using hand mobile equipment
CN1859314A (en) * 2006-03-02 2006-11-08 华为技术有限公司 Communication method
CN101820630A (en) * 2010-04-16 2010-09-01 武汉道凯科技有限公司 Method and equipment for remotely operating computer through wireless terminal
US20120020318A1 (en) * 2009-03-27 2012-01-26 Hirokazu Naoe Mobile communication system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1794212A (en) * 2005-12-14 2006-06-28 王宏源 Method of controlling computer random procedure and its peripheral equipment by using hand mobile equipment
CN1859314A (en) * 2006-03-02 2006-11-08 华为技术有限公司 Communication method
US20120020318A1 (en) * 2009-03-27 2012-01-26 Hirokazu Naoe Mobile communication system
CN101820630A (en) * 2010-04-16 2010-09-01 武汉道凯科技有限公司 Method and equipment for remotely operating computer through wireless terminal

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105681584A (en) * 2016-03-21 2016-06-15 珠海格力电器股份有限公司 Remote control method and device for mobile terminal
CN113179315A (en) * 2021-04-26 2021-07-27 缀初网络技术(上海)有限公司 Method, system and readable storage medium for providing communication between devices in multiple local area networks
CN113179315B (en) * 2021-04-26 2022-11-29 缀初网络技术(上海)有限公司 Method, system and readable storage medium for providing communication between devices in multiple local area networks

Similar Documents

Publication Publication Date Title
KR101176144B1 (en) System and method for peer-to-peer connection in multiple network environment
EP3145161B1 (en) Automatic wireless access network configuration synchronization method and apparatus
TWI766009B (en) D2d communication method, remote user equipment, and relay user equipment
US20210204202A1 (en) Network access technology indication
EP3675462B1 (en) Communication method, device and system for cleaning robot and mobile terminal
JP2017076974A (en) Communication system, address notification device, communication control device, terminal, communication method, and program
CN101980508B (en) Network adaptive operation mode on network monitoring system
EP2987295B1 (en) Local control of additional media session for a packet based call
CN104010037A (en) Communication method and device
US20150289194A1 (en) Communication apparatus, control method for the same, communication system, and non-transitory computer-readable storage medium
JP6802530B2 (en) Communication method
US9866644B2 (en) Terminal, message distribution system, message distribution method, and computer-readable medium
KR20210068464A (en) Apparatus and method for performing group communication
WO2017161866A1 (en) Network connection method and device
US9226223B2 (en) Network connection system of network electronic device and method allowing a terminal device to access an electronic device connected behind a router without a NAT loopback function
US8305968B2 (en) Solicitation triggers for opening a network link
CN112368976A (en) Terminal and method for performing group communication
US9516575B2 (en) Mobile device based proxy for browser-originated procedures
EP3264852A1 (en) Method for allocating ip address in d2d communication, and user equipment
CN111654390A (en) Data transmission method, device, terminal equipment and storage medium
JP6531540B2 (en) Network connection device, method of switching operation mode of network connection device
EP3249875A1 (en) Wireless communication method, remote user equipment and relay user equipment
JP2015109637A (en) Data communication system, transfer device and relay device used for the same, and program
US8396978B2 (en) Proxy response apparatus, proxy response method in proxy response apparatus, and communication system
JP2008048100A (en) Radio base station, radio base station program, and control method

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 510623 Guangdong, Tianhe District, Huaxia Road, No. 26 agile Music Center, floor 07,, 08A unit fifteenth

Applicant after: Guangzhou cheetah Network Technology Co., Ltd.

Address before: 510623 unit 01-B, Guangzhou bank building, No. 30 Zhujiang Road, Guangzhou, Guangdong, Tianhe District, China

Applicant before: Kingsoft, Guangzhou network technology Co., Ltd

CB02 Change of applicant information
RJ01 Rejection of invention patent application after publication

Application publication date: 20140827

RJ01 Rejection of invention patent application after publication