WO2020199396A1 - Nat穿透方法和系统、电子设备和存储介质 - Google Patents

Nat穿透方法和系统、电子设备和存储介质 Download PDF

Info

Publication number
WO2020199396A1
WO2020199396A1 PCT/CN2019/093679 CN2019093679W WO2020199396A1 WO 2020199396 A1 WO2020199396 A1 WO 2020199396A1 CN 2019093679 W CN2019093679 W CN 2019093679W WO 2020199396 A1 WO2020199396 A1 WO 2020199396A1
Authority
WO
WIPO (PCT)
Prior art keywords
terminal
network address
server
operator
target
Prior art date
Application number
PCT/CN2019/093679
Other languages
English (en)
French (fr)
Inventor
庞登
Original Assignee
深圳市网心科技有限公司
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 深圳市网心科技有限公司 filed Critical 深圳市网心科技有限公司
Publication of WO2020199396A1 publication Critical patent/WO2020199396A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming

Definitions

  • the present invention relates to the field of communication technology, in particular to a NAT penetration method and system, electronic equipment and storage medium.
  • NAT Network Address Translation
  • hole punching refers to establishing a connection between hosts in a private network that uses NAT devices.
  • each hole-punching server may contain multiple IPs (for example, three IPs belonging to China Telecom, China Mobile, and China Unicom). Both sides of the hole (that is, the hole-punched object and the hole-pushed object) may be registered on different hole-punching servers, and when signaling is sent, the punching party (such as the hole-punching object) registers with the other punching party.
  • IPs on the hole server send request packets, resulting in cross-operator signaling packets. Sending signaling packets across operators will cause the message to be unreachable or have a long delay, and it will also cause continuous sending of retry signaling packets. This leads to an increase in the load on the hole punch server.
  • the main purpose of the present invention is to provide a NAT penetration method and system, an electronic device and a storage medium, which aim to improve the success rate of data transmission during hole punching and reduce the load of the hole punch server.
  • the present invention provides a NAT traversal method, the method includes:
  • the first terminal and the second terminal belong to the same operator
  • the hole punching server registered by the first terminal and the first terminal belong to the same operator
  • the second terminal is registered The hole punching server and the second terminal belong to the same operator.
  • the method further includes:
  • the network information of the hole punching server belonging to the target operator is sent to the second terminal, and the second terminal is registered with the hole punching server belonging to the target operator through the network information.
  • the networking information of the second terminal includes the second network address of the second terminal, and the determining the target operator to which the second terminal belongs according to the networking information includes:
  • the first network address of the first terminal is an external network address of the first terminal, and the target of the operator belonging to the same operator as the first network address is obtained from the plurality of network addresses
  • the network address includes:
  • the present invention further provides an electronic device, the memory stores a NAT traversal program that can run on the processor, and the NAT traversal program is executed by the processor to achieve the NAT penetration method.
  • the present invention further provides a NAT traversal system, the system includes:
  • the first acquiring unit is configured to receive a connection request sent by the first terminal to connect with the second terminal, and acquire the first network address of the first terminal;
  • the second acquiring unit is configured to acquire the hole punching server registered by the second terminal and multiple network addresses included in the hole punching server;
  • a third obtaining unit configured to obtain a target network address belonging to the same operator as the first network address from the multiple network addresses
  • the sending unit is configured to send the target network address to the first terminal, so that the first terminal sends connection information to the target network address to perform data transmission with the second terminal.
  • the first terminal and the second terminal belong to the same operator
  • the hole punching server registered by the first terminal and the first terminal belong to the same operator
  • the second terminal is registered The hole punching server and the second terminal belong to the same operator.
  • the device further includes:
  • a fourth obtaining unit configured to receive an access request sent by the second terminal, and obtain network connection information of the second terminal
  • a determining unit configured to determine the target operator to which the second terminal belongs according to the networking information
  • the fifth acquiring unit is used to acquire the hole punching server belonging to the target operator
  • the sending unit is further configured to send network information of the hole punching server belonging to the target operator to the second terminal, and the second terminal registers with the punching server belonging to the target operator through the network information. Hole server.
  • the networking information of the second terminal includes the second network address of the second terminal, and the determining module is specifically configured to:
  • the first network address of the first terminal is an external network address of the first terminal
  • the third obtaining module is specifically configured to:
  • a NAT penetration method applied to a first terminal includes:
  • the connection information is sent to the target network address to perform data transmission with the second terminal, and the target network address is for the server to obtain the hole punching registered by the second terminal After the server and the multiple network addresses included in the hole punching server, obtain the network address of the same operator as the first network address from the multiple network addresses.
  • a NAT penetration method applied to a second terminal includes:
  • the present invention further provides a computer-readable storage medium, the computer-readable storage medium stores a NAT traversal program, and the NAT traversal program can be executed by one or more processors to achieve The NAT penetration method.
  • the present invention receives a connection request sent by a first terminal to connect with a second terminal, obtains the first network address of the first terminal; obtains the hole punching server registered by the second terminal and the hole punching server. A network address; obtaining a target network address belonging to the same operator as the first network address from the multiple network addresses; sending the target network address to the first terminal so that the first terminal Send connection information to the target network address, and perform data transmission with the second terminal.
  • the network address on the hole punching server registered by the second terminal is returned to the first terminal, and the network address belongs to the same as the first terminal Operators, thereby avoiding the problems of unreachable messages or delays caused by cross-operator signaling and continuous retry of signaling packets, achieving the purpose of improving the success rate of data transmission during hole punching and reducing the load of the hole punch server .
  • FIG. 1 is a schematic flowchart of an embodiment of a NAT traversal method according to the present invention
  • FIG. 2 is a schematic diagram of functional modules of an embodiment of the NAT penetration system of the present invention.
  • FIG. 3 is a schematic diagram of the internal structure of an electronic device provided by an embodiment of the present invention.
  • the invention provides a NAT penetration method.
  • FIG. 1 is a schematic flowchart of a first embodiment of a NAT traversal method of the present invention.
  • the method includes:
  • the first terminal and the second terminal are two parties that perform NAT penetration, or are called two parties that perform hole punching, and the first terminal may be the hole punched party or the hole punched party.
  • the first terminal and the second terminal may be electronic devices of the same type or different types.
  • the hole punch server receives a connection request sent by the first terminal to connect with the second terminal, and obtains the first network address of the first terminal.
  • the hole punch server may be a hole punch registered by the first terminal. Server, or the main hole-punching server in the hole-punching server cluster.
  • the first network address of the first terminal is the IP address of the first terminal.
  • the first terminal and the second terminal belong to the same operator.
  • the first terminal and the second terminal belong to the same operator, it indicates that the first terminal and the second terminal are in the network provided by the same operator.
  • both the first terminal and the second terminal are in the network provided by the telecom operator.
  • S12 Acquire a hole punch server registered by the second terminal and multiple network addresses included in the hole punch server.
  • the first terminal and the second terminal may be registered on different hole punching servers, and both the hole punching server registered by the first terminal and the hole punching server registered by the second terminal may include multiple network addresses.
  • the multiple network addresses included in the hole punching server registered by the second terminal belong to telecommunication network addresses, mobile network addresses, and China Unicom network addresses, respectively.
  • the hole punch server registered by the first terminal belongs to the same operator as the first terminal
  • the hole punch server registered by the second terminal belongs to the same operator as the second terminal. Operator.
  • the hole punch server registered by the first terminal and the operator to which the first terminal belongs are both telecommunications
  • the hole punch server registered by the second terminal and the operator to which the second terminal belongs are both telecommunications.
  • the hole punching server registered by the first terminal and the second terminal is also in the network provided by the same operator.
  • the first terminal is registered to the network address belonging to the same operator as the first terminal among the multiple network addresses; when the punching server registered by the second terminal When the hole server has multiple network addresses, the second terminal is registered to the network address belonging to the same operator as the second terminal among the multiple network addresses.
  • registering the second terminal to a hole punching server that belongs to the same operator as the second terminal is implemented through the following steps, and the method further includes:
  • the network information of the hole punching server belonging to the target operator is sent to the second terminal, and the second terminal is registered with the hole punching server belonging to the target operator through the network information.
  • the network information of the second terminal is obtained, and then the hole punching server belonging to the same operator as the second terminal is determined according to the network information of the second terminal. And return the network information of the hole punching server to the second terminal, where the network information may be a network address, so that the second terminal sends a registration request to the hole punching server, and then registers with the hole punching server.
  • the registration of the first terminal to the hole punching server belonging to the same operator as the first terminal can also be performed through the above-mentioned similar steps.
  • the main hole punch server in the hole punch server cluster sends the network information of the hole punch server belonging to the same operator as the second terminal to the second terminal according to the above steps, and sends to the first terminal the network information of the hole punch server belonging to the same operator as the first terminal. Network information of the hole punch server.
  • the networking information of the second terminal includes the second network address of the second terminal, and the target to which the second terminal belongs is determined according to the networking information Operators include:
  • the second network address of the second terminal is the IP address of the second terminal.
  • the target operator to which the second terminal belongs can be accurately determined.
  • the target network address is that after the server obtains the hole punching server registered by the second terminal and the multiple network addresses included in the hole punching server, the server obtains data from the multiple network addresses and The first network address belongs to the network address of the same operator.
  • the first network address of the first terminal is an external network address of the first terminal, and the acquisition of a target belonging to the same operator as the first network address from the multiple network addresses
  • the network address includes:
  • the target network address belonging to the telecommunication operator among the multiple network addresses is acquired.
  • connection information includes information about connecting with the second terminal. After the first terminal and the second terminal establish a connection, the first terminal and the second terminal can perform data transmission with each other.
  • the first terminal after sending the target network address to the first terminal, can send connection information to the target network address on the hole punching server registered by the second terminal without registering with the second terminal.
  • the connection information is sent by network addresses other than the target network address on the hole punching server, which avoids cross-operator signaling and improves the reliability of signaling.
  • This embodiment receives a connection request sent by a first terminal to connect with a second terminal, obtains the first network address of the first terminal; obtains the hole punching server registered by the second terminal and the hole punching server includes Multiple network addresses; obtain a target network address belonging to the same operator as the first network address from the multiple network addresses; send the target network address to the first terminal so that the first The terminal sends connection information to the target network address, and performs data transmission with the second terminal.
  • the network address on the hole punching server registered by the second terminal is returned to the first terminal, and the network address belongs to the same as the first terminal Operators, thereby avoiding the problems of unreachable messages or delays caused by cross-operator signaling and continuous retry of signaling packets, achieving the purpose of improving the success rate of data transmission during hole punching and reducing the load of the hole punch server .
  • FIG. 2 is a schematic diagram of functional modules of an embodiment of the NAT traversal system of the invention, which is applied to electronic devices.
  • the NAT penetration system may include: a first acquiring unit 201, a second acquiring unit 202, a third acquiring unit 203, and a sending unit 204.
  • the first obtaining unit 201 is configured to receive a connection request to connect with the second terminal sent by the first terminal, and obtain the first network address of the first terminal.
  • the first terminal and the second terminal are two parties that perform NAT penetration, or are called two parties that perform hole punching, and the first terminal may be the hole punched party or the hole punched party.
  • the first terminal and the second terminal may be electronic devices of the same type or different types.
  • the hole punch server receives a connection request sent by the first terminal to connect with the second terminal, and obtains the first network address of the first terminal.
  • the hole punch server may be a hole punch registered by the first terminal. Server, or the main hole-punching server in the hole-punching server cluster.
  • the first network address of the first terminal is the IP address of the first terminal.
  • the first terminal and the second terminal belong to the same operator.
  • the first terminal and the second terminal belong to the same operator, it indicates that the first terminal and the second terminal are in the network provided by the same operator.
  • both the first terminal and the second terminal are in the network provided by the telecommunications operator.
  • the second obtaining unit 202 is configured to obtain a hole punching server registered by the second terminal and multiple network addresses included in the hole punching server.
  • the first terminal and the second terminal may be registered on different hole punching servers, and both the hole punching server registered by the first terminal and the hole punching server registered by the second terminal may include multiple network addresses.
  • the multiple network addresses included in the hole punching server registered by the second terminal belong to telecommunication network addresses, mobile network addresses, and China Unicom network addresses, respectively.
  • the hole punch server registered by the first terminal belongs to the same operator as the first terminal
  • the hole punch server registered by the second terminal belongs to the same operator as the second terminal. Operator.
  • the hole punch server registered by the first terminal and the operator to which the first terminal belongs are both telecommunications
  • the hole punch server registered by the second terminal and the operator to which the second terminal belongs are both telecommunications.
  • the hole punching server registered by the first terminal and the second terminal is also in the network provided by the same operator.
  • the first terminal is registered to the network address belonging to the same operator as the first terminal among the multiple network addresses; when the punching server registered by the second terminal When the hole server has multiple network addresses, the second terminal is registered to the network address belonging to the same operator as the second terminal among the multiple network addresses.
  • the third obtaining unit 203 is configured to obtain a target network address belonging to the same operator as the first network address from the multiple network addresses.
  • the target network address is that after the server obtains the hole punching server registered by the second terminal and multiple network addresses included in the hole punching server, the server obtains the data from the multiple network addresses and The first network address belongs to the network address of the same operator.
  • the first network address of the first terminal is an external network address of the first terminal
  • the third acquiring module is specifically configured to:
  • the target network address belonging to the telecommunication operator among the multiple network addresses is acquired.
  • the sending unit 204 is configured to send the target network address to the first terminal, so that the first terminal sends connection information to the target network address to perform data transmission with the second terminal.
  • connection information includes information about connecting with the second terminal. After the first terminal and the second terminal establish a connection, the first terminal and the second terminal can perform data transmission with each other.
  • the first terminal after sending the target network address to the first terminal, can send connection information to the target network address on the hole punching server registered by the second terminal without registering with the second terminal.
  • the connection information is sent by network addresses other than the target network address on the hole punching server, which avoids cross-operator signaling and improves the reliability of signaling.
  • the second terminal is registered to a hole punching server that belongs to the same operator as the second terminal through the following units, and the device further includes:
  • a fourth obtaining unit configured to receive an access request sent by the second terminal, and obtain network connection information of the second terminal
  • a determining unit configured to determine the target operator to which the second terminal belongs according to the networking information
  • the fifth acquiring unit is used to acquire the hole punching server belonging to the target operator
  • the sending unit is further configured to send network information of the hole punching server belonging to the target operator to the second terminal, and the second terminal registers with the punching server belonging to the target operator through the network information. Hole server.
  • the network information of the second terminal is obtained, and then the hole punching server belonging to the same operator as the second terminal is determined according to the network information of the second terminal. And return the network information of the hole punching server to the second terminal, where the network information may be a network address, so that the second terminal sends a registration request to the hole punching server, and then registers with the hole punching server.
  • the registration of the first terminal to the hole punching server belonging to the same operator as the first terminal can also be performed through the above-mentioned similar steps.
  • the main hole punch server in the hole punch server cluster sends the network information of the hole punch server belonging to the same operator as the second terminal to the second terminal according to the above steps, and sends to the first terminal the network information of the hole punch server belonging to the same operator as the first terminal. Network information of the hole punch server.
  • the networking information of the second terminal includes the second network address of the second terminal, and the determining unit is specifically configured to:
  • the second network address of the second terminal is the IP address of the second terminal.
  • the target operator to which the second terminal belongs can be accurately determined.
  • This embodiment receives a connection request sent by a first terminal to connect with a second terminal, obtains the first network address of the first terminal; obtains the hole punching server registered by the second terminal and the hole punching server includes Multiple network addresses; obtain a target network address belonging to the same operator as the first network address from the multiple network addresses; send the target network address to the first terminal so that the first The terminal sends connection information to the target network address, and performs data transmission with the second terminal.
  • the network address on the hole punching server registered by the second terminal is returned to the first terminal, and the network address belongs to the same as the first terminal Operators, thereby avoiding the problems of unreachable messages or delays caused by cross-operator signaling and continuous retry of signaling packets, achieving the purpose of improving the success rate of data transmission during hole punching and reducing the load of the hole punch server .
  • the electronic device 1 may be a PC (Personal Computer, personal computer), or a mobile terminal such as a smart phone, a tablet computer, a palmtop computer, and a portable computer.
  • PC Personal Computer
  • mobile terminal such as a smart phone, a tablet computer, a palmtop computer, and a portable computer.
  • the electronic device 1 may include a memory 11, a processor 12, and a bus 13.
  • the memory 11 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), magnetic memory, magnetic disk, optical disk, etc.
  • the memory 11 may be an internal storage unit of the electronic device 1 in some embodiments, such as a hard disk of the electronic device 1.
  • the memory 11 may also be an external storage device of the electronic device 1, for example, a plug-in hard disk equipped on the electronic device 1, a smart memory card (Smart Media Card, SMC), and a Secure Digital (SD). Card, Flash Card, etc.
  • the memory 11 may also include both an internal storage unit of the electronic device 1 and an external storage device.
  • the memory 11 can be used not only to store application software and various data installed in the electronic device 1, such as the code of the NAT penetration program 01, etc., but also to temporarily store data that has been output or will be output.
  • the processor 12 may be a central processing unit (CPU), controller, microcontroller, microprocessor or other data processing chip in some embodiments, and is used to run the program code or processing stored in the memory 11 Data, such as executing NAT traversal program 01, etc.
  • CPU central processing unit
  • controller microcontroller
  • microprocessor or other data processing chip in some embodiments, and is used to run the program code or processing stored in the memory 11 Data, such as executing NAT traversal program 01, etc.
  • the bus 13 may be a peripheral component interconnect standard (PCI) bus or an extended industry standard architecture (EISA) bus, etc.
  • PCI peripheral component interconnect standard
  • EISA extended industry standard architecture
  • the bus can be divided into address bus, data bus, control bus, etc.
  • only one thick line is used in FIG. 3 to represent, but it does not mean that there is only one bus or one type of bus.
  • the electronic device may also include a network interface.
  • the network interface may optionally include a wired interface and/or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is usually used to connect the electronic device 1 with other electronic devices. Establish a communication connection between.
  • the electronic device 1 may also include a user interface.
  • the user interface may include a display (Display) and an input unit such as a keyboard (Keyboard).
  • the optional user interface may also include a standard wired interface and a wireless interface.
  • the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode, organic light emitting diode) touch device, etc.
  • the display can also be appropriately called a display screen or a display unit, which is used to display the information processed in the electronic device 1 and to display visualized user controls.
  • FIG. 3 only shows the electronic device 1 with components 11-13 and the NAT traversal program 01.
  • FIG. 3 does not constitute a limitation on the electronic device 1, and may include Fewer or more parts are shown, or some parts are combined, or different parts are arranged.
  • the computer program product includes one or more computer instructions.
  • the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.
  • the computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium.
  • the computer instructions may be transmitted from a website, computer, server, or data center. Transmission to another website site, computer, server or data center via wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.).
  • wired such as coaxial cable, optical fiber, digital subscriber line (DSL)
  • wireless such as infrared, wireless, microwave, etc.
  • the computer-readable storage medium may be any available medium that can be stored by a computer or a data storage device such as a server or data center integrated with one or more available media.
  • the usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk (SSD)), etc.
  • the disclosed system, device, and method may be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of the units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components can be combined or It can be integrated into another system, or some features can be ignored or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • each unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated unit can be implemented in the form of hardware or software functional unit.
  • the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium.
  • the technical solution of this application essentially or the part that contributes to the existing technology or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , Including several instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the method described in each embodiment of the present application.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program code .

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

本发明公开了一种NAT穿透方法,包括:接收第一终端发送的与第二终端进行连接的连接请求,获取所述第一终端的第一网络地址;获取所述第二终端注册的打洞服务器以及所述打洞服务器包括的多个网络地址;从所述多个网络地址中获取与所述第一网络地址属于相同的运营商的目标网络地址;向所述第一终端发送所述目标网络地址,以使所述第一终端向所述目标网络地址发送连接信息,与所述第二终端进行数据传输。本发明还公开了一种NAT穿透系统、电子设备和计算机可读存储介质。本发明能够提高打洞时数据发送的成功率,减少打洞服务器的负载。

Description

NAT穿透方法和系统、电子设备和存储介质
本申请要求于2019年03月29日提交中国专利局,申请号为201910248670.8、发明名称为“NAT穿透方法和系统、电子设备和存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及通信技术领域,尤其涉及NAT穿透方法和系统、电子设备和存储介质。
背景技术
网络地址转换(Network Address Translation,NAT)是一种网络地址翻译技术。NAT穿透(也可称打洞)是指在使用了NAT设备的私有网络中将主机之间建立连接。
一般情况下,需要穿透的对象处在比较复杂的网络运营商环境中,比如联通网络、电信网络、移动网络、教育网络、广电网络等,因此在实现NAT穿透时往往将多个打洞服务器部署在三线机房或者BGP多线机房中,这种情况下每个打洞服务器上可能包含多个IP(例如分别属于电信、移动、联通的三个IP),在进行NAT穿透时,打洞双方(即打洞对象和被打洞对象)可能注册到不同的打洞服务器上,进而在发送信令时,出现打洞的一方(如打洞对象)向打洞的另一方注册的打洞服务器上的多个IP发送请求包,从而产生跨运营商发送信令包,跨运营商发送信令包会导致消息不可达或者延时较大,也会导致不断发送重试信令包,导致打洞服务器的负载增加。
发明内容
本发明的主要目的在于提供NAT穿透方法和系统、电子设备和存储介质, 旨在提高打洞时数据发送的成功率,减少打洞服务器的负载。
为实现上述目的,本发明提供一种NAT穿透方法,所述方法包括:
接收第一终端发送的与第二终端进行连接的连接请求,获取所述第一终端的第一网络地址;
获取所述第二终端注册的打洞服务器以及所述打洞服务器包括的多个网络地址;
从所述多个网络地址中获取与所述第一网络地址属于相同的运营商的目标网络地址;
向所述第一终端发送所述目标网络地址,以使所述第一终端向所述目标网络地址发送连接信息,与所述第二终端进行数据传输。
可选地,所述第一终端与所述第二终端属于相同的运营商,所述第一终端注册的打洞服务器与所述第一终端属于相同的运营商,所述第二终端注册的打洞服务器与所述第二终端属于相同的运营商。
可选地,所述方法还包括:
接收所述第二终端发送的访问请求,获取所述第二终端的连网信息;
根据所述连网信息确定所述第二终端所属的目标运营商;
获取属于所述目标运营商的打洞服务器;
将属于所述目标运营商的打洞服务器的网络信息发送至所述第二终端,所述第二终端通过所述网络信息注册至属于所述目标运营商的打洞服务器。
可选地,所述第二终端的连网信息包括所述第二终端的第二网络地址,所述根据所述连网信息确定所述第二终端所属的目标运营商包括:
从预设IP数据库匹配所述第二终端的第二网络地址对应的网络运营商,确定所述网络运营商为所述第二终端所属的目标运营商。
可选地,所述第一终端的第一网络地址为所述第一终端的外网地址,所述从所述多个网络地址中获取与所述第一网络地址属于相同的运营商的目标网络地址包括:
根据所述外网地址确定所述第一终端所属的第一运营商;
获取所述多个网络地址中属于所述第一运营商的目标网络地址。
为实现上述目的,本发明进一步提供一种电子设备,所述存储器上存储有可在所述处理器上运行的NAT穿透程序,所述NAT穿透程序被所述处理器执行时实现所述NAT穿透方法。
为实现上述目的,本发明进一步提供一种NAT穿透系统,所述系统包括:
第一获取单元,用于接收第一终端发送的与第二终端进行连接的连接请求,获取所述第一终端的第一网络地址;
第二获取单元,用于获取所述第二终端注册的打洞服务器以及所述打洞服务器包括的多个网络地址;
第三获取单元,用于从所述多个网络地址中获取与所述第一网络地址属于相同的运营商的目标网络地址;
发送单元,用于向所述第一终端发送所述目标网络地址,以使所述第一终端向所述目标网络地址发送连接信息,与所述第二终端进行数据传输。
可选地,所述第一终端与所述第二终端属于相同的运营商,所述第一终端注册的打洞服务器与所述第一终端属于相同的运营商,所述第二终端注册的打洞服务器与所述第二终端属于相同的运营商。
可选地,所述装置还包括:
第四获取单元,用于接收所述第二终端发送的访问请求,获取所述第二终端的连网信息;
确定单元,用于根据所述连网信息确定所述第二终端所属的目标运营商;
第五获取单元,用于获取属于所述目标运营商的打洞服务器;
所述发送单元,还用于将属于所述目标运营商的打洞服务器的网络信息发送至所述第二终端,所述第二终端通过所述网络信息注册至属于所述目标运营商的打洞服务器。
可选地,所述第二终端的连网信息包括所述第二终端的第二网络地址, 所述确定模块具体用于:
从预设IP数据库匹配所述第二终端的第二网络地址对应的网络运营商,确定所述网络运营商为所述第二终端所属的目标运营商。
可选地,所述第一终端的第一网络地址为所述第一终端的外网地址,所述第三获取模块具体用于:
根据所述外网地址确定所述第一终端所属的第一运营商;
获取所述多个网络地址中属于所述第一运营商的目标网络地址。
一种NAT穿透方法,应用于第一终端,所述方法包括:
向服务器发送与第二终端进行连接的连接请求;
当接收到所述服务器发送的目标网络地址时,向所述目标网络地址发送连接信息,与第二终端进行数据传输,所述目标网络地址为所述服务器获取所述第二终端注册的打洞服务器以及所述打洞服务器包括的多个网络地址后,从所述多个网络地址中获取与所述第一网络地址属于相同的运营商的网络地址。
一种NAT穿透方法,应用于第二终端,所述方法包括:
注册打洞服务器,所述打洞服务器包括多个网络地址;
当检测到第一终端向所述目标网络地址发送连接信息时,与所述第一终端进行数据传输。
为实现上述目的,本发明进一步提供一种计算机可读存储介质,所述计算机可读存储介质上存储有NAT穿透程序,所述NAT穿透程序可被一个或者多个处理器执行,以实现所述NAT穿透方法。
本发明接收第一终端发送的与第二终端进行连接的连接请求,获取所述第一终端的第一网络地址;获取所述第二终端注册的打洞服务器以及所述打洞服务器包括的多个网络地址;从所述多个网络地址中获取与所述第一网络地址属于相同的运营商的目标网络地址;向所述第一终端发送所述目标网络地址,以使所述第一终端向所述目标网络地址发送连接信息,与所述第二终 端进行数据传输。由于在接收到第一终端发送的与第二终端进行连接的连接请求之后,向第一终端返回了第二终端注册的打洞服务器上的网络地址,并且该网络地址与第一终端属于相同的运营商,从而避免了跨运营商发送信令导致的消息不可达或延时以及不断重试信令包的问题,实现了提高打洞时数据发送的成功率,减少打洞服务器的负载的目的。
附图说明
图1为本发明NAT穿透方法一实施例的流程示意图;
图2为本发明NAT穿透系统一实施例功能模块示意图;
图3为本发明实施例提供的电子设备的内部结构示意图。
本发明目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
具体实施方式
为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本发明,并不用于限定本发明。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”、“第三”、“第四”等(如果存在)是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的实施例能够以除了在这里图示或描述的内容以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于 这些过程、方法、产品或设备固有的其它步骤或单元。
需要说明的是,在本发明中涉及“第一”、“第二”等的描述仅用于描述目的,而不能理解为指示或暗示其相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括至少一个该特征。另外,各个实施例之间的技术方案可以相互结合,但是必须是以本领域普通技术人员能够实现为基础,当技术方案的结合出现相互矛盾或无法实现时应当认为这种技术方案的结合不存在,也不在本发明要求的保护范围之内。
本发明提供一种NAT穿透方法。
参照图1,图1为本发明NAT穿透方法的第一实施例的流程示意图。
在NAT穿透方法的第一实施例中,该方法包括:
S11,接收第一终端发送的与第二终端进行连接的连接请求,获取所述第一终端的第一网络地址。
本实施例中,所述第一终端以及所述第二终端为进行NAT穿透的双方,或者称为进行打洞的双方,其中第一终端可以是被打洞方,或者是打洞方。并且,所述第一终端以及所述第二终端可以为相同类型或者不同类型的电子设备。
在一可选实施例中,打洞服务器接收第一终端发送的与第二终端进行连接的连接请求,获取第一终端的第一网络地址,该打洞服务器可以是第一终端注册的打洞服务器,或者是打洞服务器集群中的主打洞服务器。
本实施例中,所述第一终端的第一网络地址为第一终端的IP地址。
在本发明一实施例中,所述第一终端与所述第二终端属于相同的运营商。
当第一终端与第二终端属于相同的运营商,表明第一终端与第二终端处于相同的运营商提供的网络内。
例如,第一终端属于电信运营商,并且第二终端也属于电信运营商,则 第一终端与第二终端都处于电信运营商提供的网络内。
S12,获取所述第二终端注册的打洞服务器以及所述打洞服务器包括的多个网络地址。
在本实施例中,第一终端和第二终端可以注册到不同的打洞服务器上,并且第一终端注册的打洞服务器以及第二终端注册的打洞服务器上都可以包括多个网络地址。
例如,第二终端注册的打洞服务器包括的多个网络地址分别属于电信网络地址、移动网路地址和联通网络地址。
在本发明一可选实施例中,所述第一终端注册的打洞服务器与所述第一终端属于相同的运营商,所述第二终端注册的打洞服务器与所述第二终端属于相同的运营商。
例如,第一终端注册的打洞服务器与第一终端属于的运营商都为电信,第二终端注册的打洞服务器与第二终端属于的运营商都为电信。
当第一终端与第二终端也都属于相同的运营商时,第一终端与第二终端注册的打洞服务器也在相同的运营商提供的网络内。
进一步的,当第一终端注册的打洞服务器有多个网络地址时,第一终端注册到多个网路地址中与第一终端属于相同运营商的网络地址上;当第二终端注册的打洞服务器有多个网络地址时,第二终端注册到多个网路地址中与第二终端属于相同运营商的网络地址上。
可选的,在本发明另一实施例中,通过以下步骤实现将第二终端注册到与第二终端属于相同运营商的打洞服务器上,所述方法还包括:
接收所述第二终端发送的访问请求,获取所述第二终端的连网信息;
根据所述连网信息确定所述第二终端所属的目标运营商;
获取属于所述目标运营商的打洞服务器;
将属于所述目标运营商的打洞服务器的网络信息发送至所述第二终端,所述第二终端通过所述网络信息注册至属于所述目标运营商的打洞服务器。
在本实施例中,在接收到第二终端发送的访问请求之后,获取第二终端的连网信息,进而根据第二终端的连网信息确定与第二终端属于相同运营商的打洞服务器,并向第二终端返回该打洞服务器的网络信息,其中网络信息可以为网络地址,从而使得第二终端向该打洞服务器发送注册请求,进而注册至该打洞服务器。
在本发明其他实施例中,将第一终端注册到与第一终端属于相同运营商的打洞服务器上也可以通过上述类似步骤进行。例如,由打洞服务器集群中的主打洞服务器根据上述步骤向第二终端发送与第二终端属于相同运营商的打洞服务器的网络信息,以及向第一终端发送与第一终端属于相同运营商的打洞服务器的网络信息。
通过本实施例,可以使得第二终端在注册到打洞服务器时,不会跨运营商发送注册请求,避免接收不到发送注册请求之后的反馈信息,以及避免因没有接收到反馈信息导致的不断重复发送注册请求,避免增加系统负载。
进一步的,在本发明另一实施例中,所述第二终端的连网信息包括所述第二终端的第二网络地址,所述根据所述连网信息确定所述第二终端所属的目标运营商包括:
从预设IP数据库匹配所述第二终端的第二网络地址对应的网络运营商,确定所述网络运营商为所述第二终端所属的目标运营商。
其中,所述第二终端的第二网络地址即为第二终端的IP地址。
本实施例中,通过从预设IP数据库匹配第二终端的第二网络地址对应的网络运营商可以准确的确定第二终端所属的目标运营商。
S13,从所述多个网络地址中获取与所述第一网络地址属于相同的运营商的目标网络地址。
可选的,所述目标网络地址为所述服务器获取所述第二终端注册的打洞服务器以及所述打洞服务器包括的多个网络地址后,从所述多个网络地址中获取与所述第一网络地址属于相同的运营商的网络地址。
可选的,所述第一终端的第一网络地址为所述第一终端的外网地址,所述从所述多个网络地址中获取与所述第一网络地址属于相同的运营商的目标网络地址包括:
根据所述外网地址确定所述第一终端所属的第一运营商;
获取所述多个网络地址中属于所述第一运营商的目标网络地址。
例如,第一网络地址属于电信运营商,则获取多个网络地址中属于电信运营商的目标网络地址。
S14,向所述第一终端发送所述目标网络地址,以使所述第一终端向所述目标网络地址发送连接信息,与所述第二终端进行数据传输。
本实施例中,所述连接信息包括与第二终端进行连接的信息,当第一终端与第二终端建立连接后,第一终端与第二终端之间可以互相进行数据传输。
在本实施例中,当向第一终端发送目标网络地址之后,使得第一终端可以向第二终端注册的打洞服务器上的该目标网络地址发送连接信息,而不会向第二终端注册的打洞服务器上的目标网络地址以外的其他网络地址发送连接信息,避免了跨运营商的信令发送,提高了信令发送的可靠性。
本实施例接收第一终端发送的与第二终端进行连接的连接请求,获取所述第一终端的第一网络地址;获取所述第二终端注册的打洞服务器以及所述打洞服务器包括的多个网络地址;从所述多个网络地址中获取与所述第一网络地址属于相同的运营商的目标网络地址;向所述第一终端发送所述目标网络地址,以使所述第一终端向所述目标网络地址发送连接信息,与所述第二终端进行数据传输。由于在接收到第一终端发送的与第二终端进行连接的连接请求之后,向第一终端返回了第二终端注册的打洞服务器上的网络地址,并且该网络地址与第一终端属于相同的运营商,从而避免了跨运营商发送信令导致的消息不可达或延时以及不断重试信令包的问题,实现了提高打洞时数据发送的成功率,减少打洞服务器的负载的目的。
图2为发明NAT穿透系统的一实施例的功能模块示意图,所述NAT穿透系统应用于电子设备中。
如图2所示,所述NAT穿透系统可以包括:第一获取单元201,第二获取单元202,第三获取单元203和发送单元204。
第一获取单元201,用于接收第一终端发送的与第二终端进行连接的连接请求,获取所述第一终端的第一网络地址。
本实施例中,所述第一终端以及所述第二终端为进行NAT穿透的双方,或者称为进行打洞的双方,其中第一终端可以是被打洞方,或者是打洞方。并且,所述第一终端以及所述第二终端可以为相同类型或者不同类型的电子设备。
在一可选实施例中,打洞服务器接收第一终端发送的与第二终端进行连接的连接请求,获取第一终端的第一网络地址,该打洞服务器可以是第一终端注册的打洞服务器,或者是打洞服务器集群中的主打洞服务器。
本实施例中,所述第一终端的第一网络地址为第一终端的IP地址。
在本发明一实施例中,所述第一终端与所述第二终端属于相同的运营商。
当第一终端与第二终端属于相同的运营商,表明第一终端与第二终端处于相同的运营商提供的网络内。
例如,第一终端属于电信运营商,并且第二终端也属于电信运营商,则第一终端与第二终端都处于电信运营商提供的网络内。
第二获取单元202,用于获取所述第二终端注册的打洞服务器以及所述打洞服务器包括的多个网络地址。
在本实施例中,第一终端和第二终端可以注册到不同的打洞服务器上,并且第一终端注册的打洞服务器以及第二终端注册的打洞服务器上都可以包括多个网络地址。
例如,第二终端注册的打洞服务器包括的多个网络地址分别属于电信网络地址、移动网路地址和联通网络地址。
在本发明一可选实施例中,所述第一终端注册的打洞服务器与所述第一终端属于相同的运营商,所述第二终端注册的打洞服务器与所述第二终端属于相同的运营商。
例如,第一终端注册的打洞服务器与第一终端属于的运营商都为电信,第二终端注册的打洞服务器与第二终端属于的运营商都为电信。
当第一终端与第二终端也都属于相同的运营商时,第一终端与第二终端注册的打洞服务器也在相同的运营商提供的网络内。
进一步的,当第一终端注册的打洞服务器有多个网络地址时,第一终端注册到多个网路地址中与第一终端属于相同运营商的网络地址上;当第二终端注册的打洞服务器有多个网络地址时,第二终端注册到多个网路地址中与第二终端属于相同运营商的网络地址上。
第三获取单元203,用于从所述多个网络地址中获取与所述第一网络地址属于相同的运营商的目标网络地址。
可选的,所述目标网络地址为所述服务器获取所述第二终端注册的打洞服务器以及所述打洞服务器包括的多个网络地址后,从所述多个网络地址中获取与所述第一网络地址属于相同的运营商的网络地址。
可选的,所述第一终端的第一网络地址为所述第一终端的外网地址,所述第三获取模块具体用于:
根据所述外网地址确定所述第一终端所属的第一运营商;
获取所述多个网络地址中属于所述第一运营商的目标网络地址。
例如,第一网络地址属于电信运营商,则获取多个网络地址中属于电信运营商的目标网络地址。
发送单元204,用于向所述第一终端发送所述目标网络地址,以使所述第一终端向所述目标网络地址发送连接信息,与所述第二终端进行数据传输。
本实施例中,所述连接信息包括与第二终端进行连接的信息,当第一终端与第二终端建立连接后,第一终端与第二终端之间可以互相进行数据传输。
在本实施例中,当向第一终端发送目标网络地址之后,使得第一终端可以向第二终端注册的打洞服务器上的该目标网络地址发送连接信息,而不会向第二终端注册的打洞服务器上的目标网络地址以外的其他网络地址发送连接信息,避免了跨运营商的信令发送,提高了信令发送的可靠性。
可选的,在本发明另一实施例中,通过以下单元实现将第二终端注册到与第二终端属于相同运营商的打洞服务器上,所述装置还包括:
第四获取单元,用于接收所述第二终端发送的访问请求,获取所述第二终端的连网信息;
确定单元,用于根据所述连网信息确定所述第二终端所属的目标运营商;
第五获取单元,用于获取属于所述目标运营商的打洞服务器;
所述发送单元,还用于将属于所述目标运营商的打洞服务器的网络信息发送至所述第二终端,所述第二终端通过所述网络信息注册至属于所述目标运营商的打洞服务器。
在本实施例中,在接收到第二终端发送的访问请求之后,获取第二终端的连网信息,进而根据第二终端的连网信息确定与第二终端属于相同运营商的打洞服务器,并向第二终端返回该打洞服务器的网络信息,其中网络信息可以为网络地址,从而使得第二终端向该打洞服务器发送注册请求,进而注册至该打洞服务器。
在本发明其他实施例中,将第一终端注册到与第一终端属于相同运营商的打洞服务器上也可以通过上述类似步骤进行。例如,由打洞服务器集群中的主打洞服务器根据上述步骤向第二终端发送与第二终端属于相同运营商的打洞服务器的网络信息,以及向第一终端发送与第一终端属于相同运营商的打洞服务器的网络信息。
通过本实施例,可以使得第二终端在注册到打洞服务器时,不会跨运营商发送注册请求,避免接收不到发送注册请求之后的反馈信息,以及避免因没有接收到反馈信息导致的不断重复发送注册请求,避免增加系统负载。
进一步的,在本发明另一实施例中,所述第二终端的连网信息包括所述第二终端的第二网络地址,所述确定单元具体用于:
从预设IP数据库匹配所述第二终端的第二网络地址对应的网络运营商,确定所述网络运营商为所述第二终端所属的目标运营商。
其中,所述第二终端的第二网络地址即为第二终端的IP地址。
本实施例中,通过从预设IP数据库匹配第二终端的第二网络地址对应的网络运营商可以准确的确定第二终端所属的目标运营商。
本实施例接收第一终端发送的与第二终端进行连接的连接请求,获取所述第一终端的第一网络地址;获取所述第二终端注册的打洞服务器以及所述打洞服务器包括的多个网络地址;从所述多个网络地址中获取与所述第一网络地址属于相同的运营商的目标网络地址;向所述第一终端发送所述目标网络地址,以使所述第一终端向所述目标网络地址发送连接信息,与所述第二终端进行数据传输。由于在接收到第一终端发送的与第二终端进行连接的连接请求之后,向第一终端返回了第二终端注册的打洞服务器上的网络地址,并且该网络地址与第一终端属于相同的运营商,从而避免了跨运营商发送信令导致的消息不可达或延时以及不断重试信令包的问题,实现了提高打洞时数据发送的成功率,减少打洞服务器的负载的目的。
在本实施例中,电子设备1可以是PC(Personal Computer,个人电脑),也可以是智能手机、平板电脑、掌上电脑、便携计算机等移动终端。
该电子设备1可以包括存储器11、处理器12和总线13。
其中,存储器11至少包括一种类型的可读存储介质,所述可读存储介质包括闪存、硬盘、多媒体卡、卡型存储器(例如,SD或DX存储器等)、磁性存储器、磁盘、光盘等。存储器11在一些实施例中可以是电子设备1的内部存储单元,例如该电子设备1的硬盘。存储器11在另一些实施例中也可以是电子设备1的外部存储设备,例如电子设备1上配备的插接式硬盘,智能 存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。进一步地,存储器11还可以既包括电子设备1的内部存储单元也包括外部存储设备。存储器11不仅可以用于存储安装于电子设备1的应用软件及各类数据,例如NAT穿透程序01的代码等,还可以用于暂时地存储已经输出或者将要输出的数据。
处理器12在一些实施例中可以是一中央处理器(Central Processing Unit,CPU)、控制器、微控制器、微处理器或其他数据处理芯片,用于运行存储器11中存储的程序代码或处理数据,例如执行NAT穿透程序01等。
该总线13可以是外设部件互连标准(peripheral component interconnect,简称PCI)总线或扩展工业标准结构(extended industry standard architecture,简称EISA)总线等。该总线可以分为地址总线、数据总线、控制总线等。为便于表示,图3中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。
进一步地,电子设备还可以包括网络接口,网络接口可选的可以包括有线接口和/或无线接口(如WI-FI接口、蓝牙接口等),通常用于在该电子设备1与其他电子设备之间建立通信连接。
可选地,该电子设备1还可以包括用户接口,用户接口可以包括显示器(Display)、输入单元比如键盘(Keyboard),可选的用户接口还可以包括标准的有线接口、无线接口。可选地,在一些实施例中,显示器可以是LED显示器、液晶显示器、触控式液晶显示器以及OLED(Organic Light-Emitting Diode,有机发光二极管)触摸器等。其中,显示器也可以适当的称为显示屏或显示单元,用于显示在电子设备1中处理的信息以及用于显示可视化的用户控件。
图3仅示出了具有组件11-13以及NAT穿透程序01的电子设备1,本领域技术人员可以理解的是,图3示出的结构并不构成对电子设备1的限定,可以包括比图示更少或者更多的部件,或者组合某些部件,或者不同的部件 布置。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。
所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本发明实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存储的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘Solid State Disk(SSD))等
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个 系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。
需要说明的是,上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。并且本文中的术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、装置、物品或者方法不仅包括 那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、装置、物品或者方法所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、装置、物品或者方法中还存在另外的相同要素。
以上仅为本发明的优选实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本发明的专利保护范围内。

Claims (10)

  1. 一种NAT穿透方法,应用于服务器,其特征在于,所述方法包括:
    接收第一终端发送的与第二终端进行连接的连接请求,获取所述第一终端的第一网络地址;
    获取所述第二终端注册的打洞服务器以及所述打洞服务器包括的多个网络地址;
    从所述多个网络地址中获取与所述第一网络地址属于相同的运营商的目标网络地址;
    向所述第一终端发送所述目标网络地址,以使所述第一终端向所述目标网络地址发送连接信息,与所述第二终端进行数据传输。
  2. 如权利要求1所述的方法,其特征在于,所述第一终端与所述第二终端属于相同的运营商,所述第一终端注册的打洞服务器与所述第一终端属于相同的运营商,所述第二终端注册的打洞服务器与所述第二终端属于相同的运营商。
  3. 如权利要求2所述的方法,其特征在于,所述方法还包括:
    接收所述第二终端发送的访问请求,获取所述第二终端的连网信息;
    根据所述连网信息确定所述第二终端所属的目标运营商;
    获取属于所述目标运营商的打洞服务器;
    将属于所述目标运营商的打洞服务器的网络信息发送至所述第二终端,所述第二终端通过所述网络信息注册至属于所述目标运营商的打洞服务器。
  4. 如权利要求3所述的方法,其特征在于,所述第二终端的连网信息包括所述第二终端的第二网络地址,所述根据所述连网信息确定所述第二终端所属的目标运营商包括:
    从预设IP数据库匹配所述第二终端的第二网络地址对应的网络运营商,确定所述网络运营商为所述第二终端所属的目标运营商。
  5. 如权利要求1所述的方法,其特征在于,所述第一终端的第一网络地址为所述第一终端的外网地址,所述从所述多个网络地址中获取与所述第一网络地址属于相同的运营商的目标网络地址包括:
    根据所述外网地址确定所述第一终端所属的第一运营商;
    获取所述多个网络地址中属于所述第一运营商的目标网络地址。
  6. 一种电子设备,其特征在于,所述电子设备包括存储器和处理器,所述存储器上存储有可在所述处理器上运行的NAT穿透程序,所述NAT穿透程序被所述处理器执行时实现如权利要求1-5任一项所述的方法。
  7. 一种NAT穿透系统,其特征在于,所述系统包括:
    第一获取单元,用于接收第一终端发送的与第二终端进行连接的连接请求,获取所述第一终端的第一网络地址;
    第二获取单元,用于获取所述第二终端注册的打洞服务器以及所述打洞服务器包括的多个网络地址;
    第三获取单元,用于从所述多个网络地址中获取与所述第一网络地址属于相同的运营商的目标网络地址;
    发送单元,用于向所述第一终端发送所述目标网络地址,以使所述第一终端向所述目标网络地址发送连接信息,与所述第二终端进行数据传输。
  8. 一种NAT穿透方法,应用于第一终端,其特征在于,所述方法包括:
    向服务器发送与第二终端进行连接的连接请求;
    当接收到所述服务器发送的目标网络地址时,向所述目标网络地址发送连接信息,与第二终端进行数据传输,所述目标网络地址为所述服务器获取所述第二终端注册的打洞服务器以及所述打洞服务器包括的多个网络地址后,从所述多个网络地址中获取与所述第一网络地址属于相同的运营商的网络地址。
  9. 一种NAT穿透方法,应用于第二终端,其特征在于,所述方法包括:
    注册打洞服务器,所述打洞服务器包括多个网络地址;
    当检测到第一终端向所述目标网络地址发送连接信息时,与所述第一终端进行数据传输。
  10. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储有NAT穿透程序,所述NAT穿透程序可被一个或者多个处理器执行,以实现如权利要求1至5中任一项所述的NAT穿透方法。
PCT/CN2019/093679 2019-03-29 2019-06-28 Nat穿透方法和系统、电子设备和存储介质 WO2020199396A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910248670.8A CN109951562B (zh) 2019-03-29 2019-03-29 Nat穿透方法和系统、电子设备和存储介质
CN201910248670.8 2019-03-29

Publications (1)

Publication Number Publication Date
WO2020199396A1 true WO2020199396A1 (zh) 2020-10-08

Family

ID=67013042

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/093679 WO2020199396A1 (zh) 2019-03-29 2019-06-28 Nat穿透方法和系统、电子设备和存储介质

Country Status (2)

Country Link
CN (1) CN109951562B (zh)
WO (1) WO2020199396A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116436929A (zh) * 2023-06-14 2023-07-14 深圳市玩物科技有限公司 利用服务器组装udp报文的辅助p2p打洞方法和服务器

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110809045B (zh) * 2019-11-05 2022-12-13 深圳市网心科技有限公司 一种数据通信方法及其相关设备
CN112073540B (zh) * 2020-11-10 2021-02-12 腾讯科技(深圳)有限公司 数据处理方法、装置、相关设备及存储介质
CN113315808B (zh) * 2021-04-21 2022-09-30 深圳市捷视飞通科技股份有限公司 网络地址匹配方法、装置、计算机设备和存储介质

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2009083872A2 (en) * 2007-12-20 2009-07-09 Koninklijke Philips Electronics N.V. Methode of connecting a voice over internet protocol terminal to a remote server
CN104539982A (zh) * 2014-12-18 2015-04-22 新浪网技术(中国)有限公司 一种视频点对点资源共享调度方法、系统及节点终端
CN107979656A (zh) * 2017-11-22 2018-05-01 安徽皖通邮电股份有限公司 一种静态nat业务支持动态识别入向流量的方法

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130304927A1 (en) * 2012-05-14 2013-11-14 King Abdulaziz City For Science And Technology Network address translation-based method of bypassing internet access denial
WO2013189725A1 (en) * 2012-06-21 2013-12-27 Telefonica, S.A. Method and system for spam detection and mitigation
CN103259791B (zh) * 2013-04-28 2016-03-09 华为技术有限公司 一种穿越通信选路方法、终端及系统
CN103414798B (zh) * 2013-07-31 2016-04-13 中国联合网络通信集团有限公司 基于网络地址转换的通信方法、设备和系统
RO131306A2 (ro) * 2014-12-16 2016-07-29 Ixia, A California Corporation Metode, sisteme şi suport citibil pe calculator pentru iniţierea şi execuţia testelor de performanţă a unei reţele private şi/sau a componentelor acesteia
CN105262853A (zh) * 2015-09-23 2016-01-20 上海斐讯数据通信技术有限公司 一种p2p连接nat穿越的路径建立方法、装置及系统
CN105959251B (zh) * 2015-11-06 2019-12-06 杭州迪普科技股份有限公司 一种防止nat穿越认证的方法及装置
CN106656649B (zh) * 2016-09-14 2021-01-01 腾讯科技(深圳)有限公司 一种实时通话过程中基于测速的通道切换方法、客户端与服务器
CN107819889B (zh) * 2016-09-14 2021-09-07 华为技术有限公司 一种网络地址转换nat的方法、设备及系统

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2009083872A2 (en) * 2007-12-20 2009-07-09 Koninklijke Philips Electronics N.V. Methode of connecting a voice over internet protocol terminal to a remote server
CN104539982A (zh) * 2014-12-18 2015-04-22 新浪网技术(中国)有限公司 一种视频点对点资源共享调度方法、系统及节点终端
CN107979656A (zh) * 2017-11-22 2018-05-01 安徽皖通邮电股份有限公司 一种静态nat业务支持动态识别入向流量的方法

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116436929A (zh) * 2023-06-14 2023-07-14 深圳市玩物科技有限公司 利用服务器组装udp报文的辅助p2p打洞方法和服务器
CN116436929B (zh) * 2023-06-14 2023-09-08 深圳市玩物科技有限公司 利用服务器组装udp报文的辅助p2p打洞方法和服务器

Also Published As

Publication number Publication date
CN109951562A (zh) 2019-06-28
CN109951562B (zh) 2020-12-25

Similar Documents

Publication Publication Date Title
WO2020199396A1 (zh) Nat穿透方法和系统、电子设备和存储介质
JP6726426B2 (ja) 端末間のログイン不要方法及び装置
US9774697B2 (en) Method, apparatus, and system for pushing notification
WO2018126853A1 (zh) 数据传输方法及装置
EP2787696B1 (en) Method and device for transferring web real-time communication session
CN110636115B (zh) 跨云服务调用的处理方法、网关服务器及请求者服务器
CN110602270B (zh) 域名解析方法、装置、计算机设备及存储介质
US9319449B2 (en) Method, apparatus, and computer program product for processing data requests
CN111343048B (zh) 压力测试方法及装置、计算机装置及存储介质
CN110677493B (zh) 服务状态确定方法及装置、计算机装置及存储介质
CN111314458A (zh) P2p网络的打洞方法、打洞装置及计算机可读存储介质
US20170034345A1 (en) Method and device for marking an unrecognized number
CN112769837A (zh) 基于WebSocket的通信传输方法、装置、设备、系统及存储介质
CN109462659B (zh) 嵌入式设备远程访问控制系统、方法及存储介质
CN106549989A (zh) 一种数据传输方法及其系统、用户终端、应用服务器
CN110417789B (zh) 服务器连接方法、电子设备、系统及介质
CN111224878B (zh) 路由转发方法、装置、电子设备及存储介质
WO2022188614A1 (zh) 图像形成装置监控装置、方法、系统和存储介质
CN107404456A (zh) 错误定位方法及装置
CN106028311A (zh) 一种终端注册方法及装置
EP3029917A1 (en) Method and system for telecommunication device monitoring
CN107222365B (zh) 数据处理方法、装置及服务器
CN113873057A (zh) 数据处理方法和装置
US11265807B2 (en) Method for network sharing on a terminal, apparatus, air conditioner and storage medium
CN110809045B (zh) 一种数据通信方法及其相关设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19923706

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 24/01/2022)

122 Ep: pct application non-entry in european phase

Ref document number: 19923706

Country of ref document: EP

Kind code of ref document: A1