技术领域technical field
本发明涉及计算机网络技术领域,具体涉及一种数据传输方法及装置、计算机设备和计算机可读存储介质。The present invention relates to the technical field of computer networks, in particular to a data transmission method and device, computer equipment, and a computer-readable storage medium.
背景技术Background technique
网络中进行需要在不同设备之间进行数据传输。然而,现有的数据传输方法可以很方便地从外网节点进行数据传输,与内网节点进行数据传输却比较繁琐。Data transmission between different devices is required in the network. However, the existing data transmission method can conveniently transmit data from external network nodes, but it is cumbersome to perform data transmission with internal network nodes.
发明内容Contents of the invention
鉴于以上内容,有必要提出一种数据传输方法、数据传输装置、计算机设备、计算机可读存储介质和计算机程序产品,其可以支持计算机设备与内网节点进行数据传输。In view of the above, it is necessary to propose a data transmission method, data transmission device, computer equipment, computer readable storage medium and computer program product, which can support data transmission between computer equipment and intranet nodes.
本申请的第一方面提供一种数据传输方法,应用于计算机设备,所述方法包括:The first aspect of the present application provides a data transmission method applied to a computer device, the method comprising:
获取目标节点的打洞传输ID、打洞传输协议端口和路由器外部IP地址;Obtain the hole punching transmission ID, hole punching transmission protocol port and router external IP address of the target node;
根据所述打洞传输ID和所述路由器外部IP地址判断所述目标节点的类型;judging the type of the target node according to the hole punching ID and the external IP address of the router;
若所述目标节点是内网节点,则根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址建立到所述目标节点的打洞传输通道;If the target node is an intranet node, establishing a hole punching transmission channel to the target node according to the hole punching transmission ID, the hole punching transmission protocol port, and the router external IP address;
通过所述打洞传输通道与所述目标节点进行数据传输。Data transmission is performed with the target node through the hole punched transmission channel.
另一种可能的实现方式中,所述目标节点存储目标文件,所述获取目标节点的打洞传输ID、打洞传输协议端口和路由器外部IP地址包括:In another possible implementation, the target node stores the target file, and the acquisition of the target node's hole punching ID, hole punching protocol port, and router external IP address includes:
发出对所述目标文件的下载请求;issuing a download request for the target file;
接收索引节点响应于所述下载请求返回的所述目标文件的索引信息;receiving the index information of the target file returned by the index node in response to the download request;
从所述索引信息中获取所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址。Obtain the hole punching ID, the hole punching protocol port, and the external IP address of the router from the index information.
另一种可能的实现方式中,所述根据所述打洞传输ID和所述路由器外部IP地址判断所述目标节点的类型包括:In another possible implementation manner, the determining the type of the target node according to the hole punching transmission ID and the external IP address of the router includes:
获取所述目标节点的外网IP地址;Obtain the external network IP address of the target node;
判断所述目标节点的外网IP地址是否等于所述目标节点的路由器外部IP地址以及判断所述目标节点的打洞传输ID是否为空;Judging whether the external network IP address of the target node is equal to the router external IP address of the target node and judging whether the hole-punching transmission ID of the target node is empty;
若所述目标节点的外网IP地址不等于所述目标节点的路由器外部IP地址并且所述目标节点的打洞传输ID不为空,则所述目标节点为内网节点。If the external network IP address of the target node is not equal to the external IP address of the router of the target node and the hole punching ID of the target node is not empty, then the target node is an internal network node.
另一种可能的实现方式中,所述根据所述打洞传输ID和所述路由器外部IP地址判断所述目标节点的类型还包括:In another possible implementation manner, the determining the type of the target node according to the hole punching transmission ID and the external IP address of the router further includes:
若所述目标节点的外网IP地址等于所述目标节点的路由器外部IP地址并且所述目标节点的打洞传输ID为空,则所述目标节点为外网节点;If the external network IP address of the target node is equal to the external IP address of the router of the target node and the hole-punching transmission ID of the target node is empty, then the target node is an external network node;
所述方法还包括:The method also includes:
若所述目标节点是外网节点,则通过直接通信与所述目标节点进行数据传输。If the target node is an external network node, data transmission is performed with the target node through direct communication.
另一种可能的实现方式中,在所述根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址建立到所述目标节点的打洞传输通道之前,所述方法还包括:In another possible implementation manner, before the hole punching transmission channel to the target node is established according to the hole punching transmission ID, the hole punching transmission protocol port and the router external IP address, the method Also includes:
根据所述计算机设备和所述目标节点的NAT类型判断所述计算机设备和所述目标节点之间是否支持打洞传输;judging whether hole-punching transmission is supported between the computer device and the target node according to the NAT types of the computer device and the target node;
若所述计算机设备和所述目标节点之间支持打洞传输,则根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址建立到所述目标节点的打洞传输通道。If hole-punching transmission is supported between the computer device and the target node, then establish a hole-punching transmission to the target node according to the hole-punching transmission ID, the hole-punching transmission protocol port and the router external IP address aisle.
另一种可能的实现方式中,所述方法还包括:In another possible implementation, the method further includes:
若所述计算机设备和所述目标节点之间不支持打洞传输,则通过中间节点与所述目标节点进行数据传输。If hole-punching transmission is not supported between the computer device and the target node, data transmission is performed with the target node through an intermediate node.
另一种可能的实现方式中,所述根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址建立到所述目标节点的打洞传输通道包括:In another possible implementation manner, the establishing the hole punching transmission channel to the target node according to the hole punching transmission ID, the hole punching transmission protocol port, and the router external IP address includes:
根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址向打洞服务器发送打洞请求消息;sending a hole punching request message to the hole punching server according to the hole punching transmission ID, the hole punching transmission protocol port and the router external IP address;
接收所述打洞服务器响应于所述打洞请求消息返回的所述目标节点的地址信息;receiving the address information of the target node returned by the hole punching server in response to the hole punch request message;
根据所述目标节点的地址信息向所述目标节点发送UDP数据包。sending a UDP data packet to the target node according to the address information of the target node.
本申请的第二方面提供一种计算机设备,所述计算机设备包括存储器和处理器,所述存储器上存储有可在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行时实现所述数据传输方法。The second aspect of the present application provides a computer device, the computer device includes a memory and a processor, the memory stores a computer program that can run on the processor, and the computer program is executed by the processor When implementing the data transmission method.
本申请的第三方面提供一种数据传输装置,应用于计算机设备,所述装置包括:A third aspect of the present application provides a data transmission device applied to computer equipment, the device comprising:
获取单元,用于获取目标节点的打洞传输ID、打洞传输协议端口和路由器外部IP地址;The obtaining unit is used to obtain the hole-punching transmission ID of the target node, the hole-punching transmission protocol port and the external IP address of the router;
判断单元,用于根据所述打洞传输ID和所述路由器外部IP地址判断所述目标节点的类型;a judging unit, configured to judge the type of the target node according to the hole punching ID and the external IP address of the router;
打洞单元,用于若所述目标节点是内网节点,则根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址建立到所述目标节点的打洞传输通道;A hole-punching unit, configured to establish a hole-punching transmission channel to the target node according to the hole-punching transmission ID, the hole-punching transmission protocol port, and the external IP address of the router if the target node is an intranet node ;
传输单元,用于通过所述打洞传输通道与所述目标节点进行数据传输。A transmission unit, configured to perform data transmission with the target node through the hole punched transmission channel.
另一种可能的实现方式中,所述目标节点存储目标文件,所述获取目标节点的打洞传输ID、打洞传输协议端口和路由器外部IP地址包括:In another possible implementation, the target node stores the target file, and the acquisition of the target node's hole punching ID, hole punching protocol port, and router external IP address includes:
发出对所述目标文件的下载请求;issuing a download request for the target file;
接收索引节点响应于所述下载请求返回的所述目标文件的索引信息;receiving the index information of the target file returned by the index node in response to the download request;
从所述索引信息中获取所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址。Obtain the hole punching ID, the hole punching protocol port, and the external IP address of the router from the index information.
另一种可能的实现方式中,所述根据所述打洞传输ID和所述路由器外部IP地址判断所述目标节点的类型包括:In another possible implementation manner, the determining the type of the target node according to the hole punching transmission ID and the external IP address of the router includes:
获取所述目标节点的外网IP地址;Obtain the external network IP address of the target node;
判断所述目标节点的外网IP地址是否等于所述目标节点的路由器外部IP地址以及判断所述目标节点的打洞传输ID是否为空;Judging whether the external network IP address of the target node is equal to the router external IP address of the target node and judging whether the hole-punching transmission ID of the target node is empty;
若所述目标节点的外网IP地址不等于所述目标节点的路由器外部IP地址并且所述目标节点的打洞传输ID不为空,则所述目标节点为内网节点。If the external network IP address of the target node is not equal to the external IP address of the router of the target node and the hole punching ID of the target node is not empty, then the target node is an internal network node.
另一种可能的实现方式中,所述根据所述打洞传输ID和所述路由器外部IP地址判断所述目标节点的类型还包括:In another possible implementation manner, the determining the type of the target node according to the hole punching transmission ID and the external IP address of the router further includes:
若所述目标节点的外网IP地址等于所述目标节点的路由器外部IP地址并且所述目标节点的打洞传输ID为空,则所述目标节点为外网节点;If the external network IP address of the target node is equal to the external IP address of the router of the target node and the hole-punching transmission ID of the target node is empty, then the target node is an external network node;
所述传输单元还用于:The transfer unit is also used for:
若所述目标节点是外网节点,则通过直接通信与所述目标节点进行数据传输。If the target node is an external network node, data transmission is performed with the target node through direct communication.
另一种可能的实现方式中,在所述根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址建立到所述目标节点的打洞传输通道之前,所述方法还包括:In another possible implementation manner, before the hole punching transmission channel to the target node is established according to the hole punching transmission ID, the hole punching transmission protocol port and the router external IP address, the method Also includes:
根据所述计算机设备和所述目标节点的NAT类型判断所述计算机设备和所述目标节点之间是否支持打洞传输;judging whether hole-punching transmission is supported between the computer device and the target node according to the NAT types of the computer device and the target node;
若所述计算机设备和所述目标节点之间支持打洞传输,则根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址建立到所述目标节点的打洞传输通道。If hole-punching transmission is supported between the computer device and the target node, then establish a hole-punching transmission to the target node according to the hole-punching transmission ID, the hole-punching transmission protocol port and the router external IP address aisle.
另一种可能的实现方式中,所述传输单元还用于:In another possible implementation manner, the transmission unit is further configured to:
若所述计算机设备和所述目标节点之间不支持打洞传输,则通过中间节点与所述目标节点进行数据传输。If hole-punching transmission is not supported between the computer device and the target node, data transmission is performed with the target node through an intermediate node.
另一种可能的实现方式中,所述根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址建立到所述目标节点的打洞传输通道包括:In another possible implementation manner, the establishing the hole punching transmission channel to the target node according to the hole punching transmission ID, the hole punching transmission protocol port, and the router external IP address includes:
根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址向打洞服务器发送打洞请求消息;sending a hole punching request message to the hole punching server according to the hole punching transmission ID, the hole punching transmission protocol port and the router external IP address;
接收所述打洞服务器响应于所述打洞请求消息返回的所述目标节点的地址信息;receiving the address information of the target node returned by the hole punching server in response to the hole punch request message;
根据所述目标节点的地址信息向所述目标节点发送UDP数据包。sending a UDP data packet to the target node according to the address information of the target node.
本申请的第四方面提供一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现所述数据传输方法。A fourth aspect of the present application provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the data transmission method is implemented.
本申请的第五方面提供一种计算机程序产品,包括计算机指令,当其在计算机设备上运行时,使得计算机设备执行所述数据传输方法。A fifth aspect of the present application provides a computer program product, including computer instructions, which, when run on a computer device, cause the computer device to execute the data transmission method.
本发明获取目标节点的打洞传输ID、打洞传输协议端口和路由器外部IP地址;根据目标文件的目标节点的打洞传输ID和路由器外部IP判断目标节点是否为内网节点,当目标节点为内网节点时根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址建立到所述目标节点的打洞传输通道,利用所述打洞传输通道与所述目标节点进行数据传输。本发明支持计算机设备与内网节点进行数据传输,解决了现有技术不能与内网节点进行数据传输的技术问题。The present invention obtains the hole-punching transmission ID of the target node, the hole-punching transmission protocol port and the external IP address of the router; judges whether the target node is an intranet node according to the hole-punching transmission ID of the target node of the target file and the external IP of the router, when the target node is When an intranet node establishes a hole-punching transmission channel to the target node according to the hole-punching transmission ID, the hole-punching transmission protocol port and the external IP address of the router, use the hole-punching transmission channel to communicate with the target node for data transfer. The invention supports data transmission between computer equipment and internal network nodes, and solves the technical problem that the prior art cannot perform data transmission with internal network nodes.
附图说明Description of drawings
图1是本发明实施例提供的数据传输方法的流程图。FIG. 1 is a flowchart of a data transmission method provided by an embodiment of the present invention.
图2是本发明实施例提供的数据传输装置的流程图。Fig. 2 is a flowchart of a data transmission device provided by an embodiment of the present invention.
图3是本发明实施例提供的计算机设备的示意图。Fig. 3 is a schematic diagram of a computer device provided by an embodiment of the present invention.
具体实施方式Detailed ways
为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本发明,并不用于限定本发明。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the object, technical solution and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the present invention, not to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”、“第三”、“第四”等(如果存在)是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。术语“第一”、“第二”、“第三”、“第四”等仅用于描述目的,而不能理解为指示或暗示其相对重要性或者隐含指明所指示的技术特征的数量。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、装置、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above drawings are used to distinguish similar objects, and not necessarily Used to describe a specific sequence or sequence. The terms "first", "second", "third", "fourth" and so on are used for descriptive purposes only, and should not be understood as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Furthermore, the terms "comprising" and "having", as well as any variations thereof, are intended to cover a non-exclusive inclusion, for example, a process, method, means, product or equipment comprising a series of steps or elements need not be limited to the expressly listed instead, may include other steps or elements not explicitly listed or inherent to the process, method, product or apparatus.
本申请的各个实施例之间的技术方案可以相互结合,但是必须是以本领域普通技术人员能够实现为基础,当技术方案的结合出现相互矛盾或无法实现时应当认为这种技术方案的结合不存在,也不在本发明要求的保护范围之内。The technical solutions of the various embodiments of this application can be combined with each other, but it must be based on the realization of those skilled in the art. When the combination of technical solutions is contradictory or cannot be realized, it should be considered that the combination of technical solutions is not Exist, also not within the scope of protection required by the present invention.
优选地,本发明的数据传输方法应用在一个或者多个计算机设备中。所述计算机设备是一种能够按照事先设定或存储的指令,自动进行数值计算和/或信息处理的设备,其硬件包括但不限于微处理器、专用集成电路(Application Specific IntegratedCircuit,ASIC)、可编程门阵列(Field-Programmable Gate Array,FPGA)、数字处理器(Digital Signal Processor,DSP)、嵌入式设备等。Preferably, the data transmission method of the present invention is applied in one or more computer devices. The computer device is a device that can automatically perform numerical calculations and/or information processing according to pre-set or stored instructions, and its hardware includes but not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), Programmable gate array (Field-Programmable Gate Array, FPGA), digital processor (Digital Signal Processor, DSP), embedded devices, etc.
所述计算机设备包括但不限于台式计算机、膝上型便携计算机、个人数字助理、平板电脑、个人云盘、智能手机、电子书阅读器、MP3(Moving Picture Experts Group AudioLayer III,动态影像专家压缩标准音频层面3)或MP4(Moving Picture Experts GroupAudio Layer IV,动态影像专家压缩标准音频层面4)播放器、POS终端和车载电脑等。所述计算机设备可以与用户通过键盘、鼠标、遥控器、触摸板或声控设备等方式进行人机交互。Said computer equipment includes but not limited to desktop computer, laptop portable computer, personal digital assistant, tablet computer, personal cloud disk, smart phone, e-book reader, MP3 (Moving Picture Experts Group AudioLayer III, moving picture expert compression standard Audio layer 3) or MP4 (Moving Picture Experts GroupAudio Layer IV, moving picture experts compressed standard audio layer 4) player, POS terminal and vehicle computer, etc. The computer device can perform human-computer interaction with the user through keyboard, mouse, remote controller, touch panel or voice control device.
所述计算机设备可以是组成CDN(Content Delivery Network,内容分发网络)网络或者区块链网络的节点。The computer device may be a node forming a CDN (Content Delivery Network, content distribution network) network or a block chain network.
实施例一Embodiment one
图1是本发明实施例提供的数据传输方法的流程图。所述数据传输方法应用于计算机设备中。所述数据传输方法支持计算机设备与处于内部网络的目标节点(即内网节点)进行数据传输。所述计算机设备可以位于网络地址转换(Network Address Translation,NAT)设备之后。所述NAT设备是一个IETF(Internet Engineering Task Force,Internet工程任务组)标准,允许一个整体机构以一个公用IP(Internet Protocol,互联网协议)地址出现在Internet上。所述NAT设备可以包括,但不限于:运营商电信、联通网络出口设备。FIG. 1 is a flowchart of a data transmission method provided by an embodiment of the present invention. The data transmission method is applied to computer equipment. The data transmission method supports data transmission between a computer device and a target node in an internal network (that is, an internal network node). The computer device may be located behind a Network Address Translation (NAT) device. The NAT device is an IETF (Internet Engineering Task Force, Internet Engineering Task Force) standard, allowing an entire organization to appear on the Internet with a public IP (Internet Protocol, Internet Protocol) address. The NAT device may include, but is not limited to: network egress devices of telecom operators and China Unicom.
所述计算机设备可以处于与所述目标节点不同的内部网络(即可以是内网节点),也可以处于外部网络(即可以是外网节点)。The computer device may be in an internal network different from the target node (that is, it may be an internal network node), or it may be in an external network (that is, it may be an external network node).
所述目标节点可以是桌上型计算机、笔记本、掌上电脑及云端服务器等。The target node may be a desktop computer, a notebook, a palmtop computer, a cloud server, and the like.
在一实施例中,所述计算机设备和所述目标节点可以是个人云盘,例如玩客云。In an embodiment, the computer device and the target node may be a personal cloud disk, such as a player cloud.
参阅1所示,所述数据传输方法具体包括以下步骤:Referring to 1, the data transmission method specifically includes the following steps:
101,获取目标节点的打洞传输ID、打洞传输协议端口和路由器外部IP地址。101. Obtain the hole punching transmission ID, the hole punching transmission protocol port, and the external IP address of the router of the target node.
目标节点的打洞传输ID用于标识所述目标节点。The hole punching ID of the target node is used to identify the target node.
打洞传输协议端口是指打洞服务器的服务端口,用于通过打洞服务器建立打洞传输通道。The hole punching transmission protocol port refers to the service port of the hole punching server, which is used to establish a hole punching transmission channel through the hole punching server.
目标节点的路由器外部IP地址是目标节点同路由器通信,从路由器获取的外部IP地址。The external IP address of the router of the target node is the external IP address obtained from the router by the target node communicating with the router.
在一实施例中,所述目标节点存储目标文件,所述获取目标节点的打洞传输ID、打洞传输协议端口和路由器外部IP地址包括:In one embodiment, the target node stores the target file, and the acquisition of the target node's hole-punching ID, hole-punching protocol port, and router external IP address includes:
(1)发出对所述目标文件的下载请求。(1) Sending a download request for the target file.
所述下载请求包括所述目标文件的文件名。The download request includes the file name of the target file.
可以提供文件下载界面,计算机设备通过所述文件下载界面发出所述下载请求。例如,所述文件下载界面可以包括文件名输入框,计算机设备通过在所述文件名输入框输入目标文件的文件名来发出所述下载请求。又如,所述文件下载界面包括热门文件下载栏,所述热门文件下载栏显示多个热门文件,计算机设备通过点击所述热门文件下载栏中的热门文件发出所述下载请求。A file download interface may be provided, and the computer device sends the download request through the file download interface. For example, the file download interface may include a file name input box, and the computer device sends the download request by inputting the file name of the target file in the file name input box. As another example, the file download interface includes a popular file download column, and the popular file download column displays a plurality of popular files, and the computer device sends the download request by clicking a popular file in the popular file download column.
(2)接收索引节点响应于所述下载请求返回的所述目标文件的索引信息。(2) Receiving the index information of the target file returned by the index node in response to the download request.
可以利用索引节点查找所述目标文件的索引信息。所述索引节点根据所述目标文件的文件名从索引数据库查找所述目标文件的索引信息,将所述索引信息返回所述计算机装置。The index information of the target file can be searched by using the index node. The index node searches the index database for index information of the target file according to the file name of the target file, and returns the index information to the computer device.
在本实施例中,目标文件分片存储在目标节点中,目标文件的存储索引为二级索引结构,即目标文件的索引信息包括第一级索引和第二级索引。第一级索引主要记录目标文件的大小和分片信息(包括分片数量、分片名称、分片大小等),第二级索引记录目标文件的各个分片的目标节点的节点信息(包括打洞传输ID、打洞传输协议端口、路由器外部IP地址等)。索引节点根据目标文件的文件名查找所述目标文件的第一级索引,根据所述目标文件的第一级索引查找所述目标文件的第二级索引,从所述第二级索引中获取所述目标文件的各个分片的目标节点(可以对应多个目标节点)的节点信息。In this embodiment, the target file is stored in pieces in the target node, and the storage index of the target file is a secondary index structure, that is, the index information of the target file includes a first-level index and a second-level index. The first-level index mainly records the size and fragmentation information of the target file (including the number of fragments, the name of the fragmentation, and the Hole transmission ID, hole punching transport protocol port, router external IP address, etc.). The index node searches for the first-level index of the target file according to the file name of the target file, searches for the second-level index of the target file according to the first-level index of the target file, and obtains all Describe the node information of the target node (may correspond to multiple target nodes) of each fragment of the target file.
在其他的实施例中,目标文件可以整个(即不分片)存储在目标节点中。相应地,索引节点根据目标文件的文件名查找所述目标文件的目标节点(对应一个目标节点)的节点信息。In other embodiments, the target file may be stored in the target node as a whole (ie without fragments). Correspondingly, the index node searches for the node information of the target node (corresponding to one target node) of the target file according to the file name of the target file.
所述数据传输方法可以使用其他的索引结构,例如一级索引结构、三级索引结构等。The data transmission method may use other index structures, such as a first-level index structure, a third-level index structure, and the like.
(3)从所述索引信息中获取所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址。(3) Obtain the hole punching ID, the hole punching protocol port, and the external IP address of the router from the index information.
目标文件是计算机设备需要下载的文件。所述目标文件可以是不同类型的文件,例如视频文件、音频文件、文本文件、图片文件等。The target file is the file that the computer device needs to download. The target files may be different types of files, such as video files, audio files, text files, picture files and so on.
在一实施例中,索引节点返回的所述目标文件的索引信息中还包括所述目标节点的NAT类型。In an embodiment, the index information of the target file returned by the index node further includes the NAT type of the target node.
目标节点的NAT类型可以包括全锥型、限制型锥型、端口限制型锥型、对称型。The NAT type of the target node may include full cone, restricted cone, port restricted cone, and symmetric.
102,根据所述打洞传输ID和所述路由器外部IP地址判断所述目标节点的类型。102. Determine the type of the target node according to the hole punching ID and the external IP address of the router.
在本实施例中,所述根据所述打洞传输ID和所述路由器外部IP地址判断所述目标节点的类型包括:In this embodiment, the determining the type of the target node according to the hole punching transmission ID and the external IP address of the router includes:
获取所述目标节点的外网IP地址;Obtain the external network IP address of the target node;
判断所述目标节点的外网IP地址是否等于所述目标节点的路由器外部IP地址以及判断所述目标节点的打洞传输ID是否为空;Judging whether the external network IP address of the target node is equal to the router external IP address of the target node and judging whether the hole-punching transmission ID of the target node is empty;
若所述目标节点的外网IP地址不等于所述目标节点的路由器外部IP地址并且所述目标节点的打洞传输ID不为空,则所述目标节点为内网节点;If the external network IP address of the target node is not equal to the router external IP address of the target node and the hole-punching transmission ID of the target node is not empty, then the target node is an internal network node;
若所述目标节点的外网IP地址等于所述目标节点的路由器外部IP地址并且所述目标节点的打洞传输ID为空,则所述目标节点为外网节点。If the external IP address of the target node is equal to the external IP address of the router of the target node and the hole punching ID of the target node is empty, then the target node is an external network node.
所述目标节点的外网IP地址是所述目标节点接入网络时为其分配的IP地址。The external network IP address of the target node is the IP address assigned to the target node when it accesses the network.
103,若所述目标节点是内网节点,则根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址建立到所述目标节点的打洞传输通道。103. If the target node is an intranet node, establish a hole punching transmission channel to the target node according to the hole punching transmission ID, the hole punching transmission protocol port, and the external IP address of the router.
在一实施例中,在所述根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址建立到所述目标节点的打洞传输通道之前,所述方法还包括:In an embodiment, before establishing the hole punching transmission channel to the target node according to the hole punching transmission ID, the hole punching transmission protocol port and the external IP address of the router, the method further includes:
根据所述计算机设备和所述目标节点的NAT类型判断所述计算机设备和所述目标节点之间是否支持打洞传输。It is judged according to the NAT types of the computer device and the target node whether hole-punching transmission is supported between the computer device and the target node.
若所述计算机设备和所述目标节点之间支持打洞传输,则根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址建立到所述目标节点的打洞传输通道;If hole-punching transmission is supported between the computer device and the target node, then establish a hole-punching transmission to the target node according to the hole-punching transmission ID, the hole-punching transmission protocol port and the router external IP address aisle;
若所述计算机设备和所述目标节点之间不支持打洞传输,则通过中间节点与所述目标节点进行数据传输。If hole-punching transmission is not supported between the computer device and the target node, data transmission is performed with the target node through an intermediate node.
中间节点是既能与计算机设备进行数据传输,又能与目标节点进行数据传输的节点。中间节点在计算机设备和目标节点间进行数据中转。The intermediate node is a node that can not only carry out data transmission with computer equipment, but also carry out data transmission with the target node. The intermediate node performs data transfer between the computer equipment and the target node.
计算机设备的NAT类型可以包括全锥型、限制型锥型、端口限制型锥型、对称型。NAT types for computer devices may include full cone, restricted cone, port restricted cone, and symmetric.
所述根据所述计算机设备和所述目标节点的NAT类型判断所述计算机设备和所述目标节点之间是否支持打洞传输包括:The determining whether hole-punching transmission is supported between the computer device and the target node according to the NAT type of the computer device and the target node includes:
若所述计算机设备和所述目标节点中的任意一方的NAT类型是对称型、另一方的NAT类型是端口限制型锥型,或者若所述计算机设备和所述目标节点的NAT类型都是对称型,则所述计算机设备和所述目标节点之间不支持打洞传输。If the NAT type of any one of the computer device and the target node is symmetric, and the NAT type of the other is port-restricted cone, or if the NAT types of the computer device and the target node are both symmetric type, hole punching transmission is not supported between the computer device and the target node.
在一实施例中,所述根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址建立到所述目标节点的打洞传输通道包括:In an embodiment, the establishment of the hole punching transmission channel to the target node according to the hole punching transmission ID, the hole punching transmission protocol port and the external IP address of the router includes:
根据所述打洞传输协议端口和所述路由器外部IP地址向打洞服务器发送打洞请求消息,请求所述打洞服务器帮助建立与所述目标节点的UDP连接;Send a hole punching request message to a hole punching server according to the hole punching transport protocol port and the router external IP address, requesting the hole punching server to help establish a UDP connection with the target node;
接收所述打洞服务器响应于所述打洞请求消息返回的所述目标节点的地址信息;receiving the address information of the target node returned by the hole punching server in response to the hole punch request message;
根据所述目标节点的地址信息向所述目标节点发送UDP数据包。sending a UDP data packet to the target node according to the address information of the target node.
打洞服务器接收到打洞请求消息后,将所述目标节点的地址信息发送给计算机设备,同时将计算机设备的地址信息发送给目标节点。计算机设备的地址信息可以包括计算机设备的IP地址和端口号,目标节点的地址信息可以包括目标节点的IP地址和端口号。After receiving the hole punching request message, the hole punching server sends the address information of the target node to the computer device, and at the same time sends the address information of the computer device to the target node. The address information of the computer device may include the IP address and port number of the computer device, and the address information of the target node may include the IP address and port number of the target node.
目标节点接收到打洞服务器返回的计算机设备的地址信息后,根据计算机设备的地址信息向计算机设备发送UDP数据包。一旦计算机设备与目标节点都向对方发送了数据包,就建立好计算机设备到目标节点的打洞传输通道。After receiving the address information of the computer device returned by the hole punching server, the target node sends a UDP data packet to the computer device according to the address information of the computer device. Once both the computer device and the target node have sent data packets to each other, a hole punching transmission channel from the computer device to the target node is established.
104,通过所述打洞传输通道与所述目标节点进行数据传输。104. Perform data transmission with the target node through the hole punched transmission channel.
例如,通过所述打洞传输通道从所述目标节点下载目标文件。For example, the target file is downloaded from the target node through the hole punched transmission channel.
所述打洞传输通道从所述目标节点下载目标文件可以包括:The downloading of the target file from the target node by the hole punching transmission channel may include:
通过所述打洞传输通道向所述目标节点发送文件请求;sending a file request to the target node through the hole punched transmission channel;
接收所述目标节点通过所述打洞传输通道返回的所述目标文件。and receiving the target file returned by the target node through the hole punching transmission channel.
实施例一的数据传输方法中,获取目标节点的打洞传输ID、打洞传输协议端口和路由器外部IP地址,根据目标文件的目标节点的打洞传输ID和路由器外部IP判断目标节点是否为内网节点,当目标节点为内网节点时根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址建立到所述目标节点的打洞传输通道,利用所述打洞传输通道进行数据传输。所述数据传输方法支持计算机设备与内网节点进行数据传输,解决了现有技术不能与内网节点进行数据传输的技术问题。In the data transmission method of embodiment one, obtain the hole-punching transmission ID of the target node, the hole-punching transmission protocol port and the external IP address of the router, judge whether the target node is an internal IP address according to the hole-punching transmission ID of the target node of the target file and the router external IP The network node, when the target node is an intranet node, establishes a hole-punching transmission channel to the target node according to the hole-punching transmission ID, the hole-punching transmission protocol port and the router external IP address, and utilizes the hole-punching transmission channel to the target node. Transmission channel for data transmission. The data transmission method supports data transmission between computer equipment and internal network nodes, and solves the technical problem that the prior art cannot perform data transmission with internal network nodes.
在另一实施例中,所述方法还包括:In another embodiment, the method also includes:
若所述目标节点是外网节点,则通过直接通信与所述目标节点进行数据传输。If the target node is an external network node, data transmission is performed with the target node through direct communication.
实施例二Embodiment two
图2为本发明实施例提供的数据传输装置的结构图。所述数据传输装置20应用于计算机设备。所述数据传输装置20支持计算机设备与处于内部网络的目标节点(即内网节点)进行数据传输。所述计算机设备可以位于网络地址转换(Network AddressTranslation,NAT)设备之后。所述NAT设备是一个IETF(Internet Engineering TaskForce,Internet工程任务组)标准,允许一个整体机构以一个公用IP(Internet Protocol,互联网协议)地址出现在Internet上。所述NAT设备可以包括,但不限于:运营商电信、联通网络出口设备。FIG. 2 is a structural diagram of a data transmission device provided by an embodiment of the present invention. The data transmission device 20 is applied to computer equipment. The data transmission device 20 supports data transmission between computer equipment and target nodes in the internal network (ie internal network nodes). The computer device may be located behind a Network Address Translation (NAT) device. The NAT device is an IETF (Internet Engineering Task Force, Internet Engineering Task Force) standard, allowing an entire organization to appear on the Internet with a public IP (Internet Protocol, Internet Protocol) address. The NAT device may include, but is not limited to: network egress devices of telecom operators and China Unicom.
所述计算机设备可以处于与所述目标节点不同的内部网络(即可以是内网节点),也可以处于外部网络(即可以是外网节点)。The computer device may be in an internal network different from the target node (that is, it may be an internal network node), or it may be in an external network (that is, it may be an external network node).
所述目标节点可以是桌上型计算机、笔记本、掌上电脑及云端服务器等。The target node may be a desktop computer, a notebook, a palmtop computer, a cloud server, and the like.
在一实施例中,所述计算机设备和所述目标节点可以是个人云盘,例如玩客云。In an embodiment, the computer device and the target node may be a personal cloud disk, such as a player cloud.
如图2所示,所述数据传输装置20可以包括:获取单元201、判断单元202、打洞单元203、传输单元204。As shown in FIG. 2 , the data transmission device 20 may include: an acquisition unit 201 , a judging unit 202 , a punching unit 203 , and a transmission unit 204 .
获取单元201,用于获取目标节点的打洞传输ID、打洞传输协议端口和路由器外部IP地址。The obtaining unit 201 is configured to obtain the hole punching transmission ID, the hole punching transmission protocol port and the external IP address of the router of the target node.
目标节点的打洞传输ID用于标识所述目标节点。The hole punching ID of the target node is used to identify the target node.
打洞传输协议端口是指打洞服务器的服务端口,用于通过打洞服务器建立打洞传输通道。The hole punching transmission protocol port refers to the service port of the hole punching server, which is used to establish a hole punching transmission channel through the hole punching server.
目标节点的路由器外部IP地址是目标节点同路由器通信,从路由器获取的外部IP地址。The external IP address of the router of the target node is the external IP address obtained from the router by the target node communicating with the router.
在一实施例中,所述目标节点存储目标文件,所述获取目标节点的打洞传输ID、打洞传输协议端口和路由器外部IP地址包括:In one embodiment, the target node stores the target file, and the acquisition of the target node's hole-punching ID, hole-punching protocol port, and router external IP address includes:
(1)发出对所述目标文件的下载请求。(1) Sending a download request for the target file.
所述下载请求包括所述目标文件的文件名。The download request includes the file name of the target file.
可以提供文件下载界面,计算机设备通过所述文件下载界面发出所述下载请求。例如,所述文件下载界面可以包括文件名输入框,计算机设备通过在所述文件名输入框输入目标文件的文件名来发出所述下载请求。又如,所述文件下载界面包括热门文件下载栏,所述热门文件下载栏显示多个热门文件,计算机设备通过点击所述热门文件下载栏中的热门文件发出所述下载请求。A file download interface may be provided, and the computer device sends the download request through the file download interface. For example, the file download interface may include a file name input box, and the computer device sends the download request by inputting the file name of the target file in the file name input box. As another example, the file download interface includes a popular file download column, and the popular file download column displays a plurality of popular files, and the computer device sends the download request by clicking a popular file in the popular file download column.
(2)接收索引节点响应于所述下载请求返回的所述目标文件的索引信息。(2) Receiving the index information of the target file returned by the index node in response to the download request.
可以利用索引节点查找所述目标文件的索引信息。所述索引节点根据所述目标文件的文件名从索引数据库查找所述目标文件的索引信息,将所述索引信息返回所述计算机装置。The index information of the target file can be searched by using the index node. The index node searches the index database for index information of the target file according to the file name of the target file, and returns the index information to the computer device.
在本实施例中,目标文件分片存储在目标节点中,目标文件的存储索引为二级索引结构,即目标文件的索引信息包括第一级索引和第二级索引。第一级索引主要记录目标文件的大小和分片信息(包括分片数量、分片名称、分片大小等),第二级索引记录目标文件的各个分片的目标节点的节点信息(包括打洞传输ID、打洞传输协议端口、路由器外部IP地址等)。索引节点根据目标文件的文件名查找所述目标文件的第一级索引,根据所述目标文件的第一级索引查找所述目标文件的第二级索引,从所述第二级索引中获取所述目标文件的各个分片的目标节点(可以对应多个目标节点)的节点信息。In this embodiment, the target file is stored in pieces in the target node, and the storage index of the target file is a secondary index structure, that is, the index information of the target file includes a first-level index and a second-level index. The first-level index mainly records the size and fragmentation information of the target file (including the number of fragments, the name of the fragmentation, and the Hole transmission ID, hole punching transport protocol port, router external IP address, etc.). The index node searches for the first-level index of the target file according to the file name of the target file, searches for the second-level index of the target file according to the first-level index of the target file, and obtains all Describe the node information of the target node (may correspond to multiple target nodes) of each fragment of the target file.
在其他的实施例中,目标文件可以整个(即不分片)存储在目标节点中。相应地,索引节点根据目标文件的文件名查找所述目标文件的目标节点(对应一个目标节点)的节点信息。In other embodiments, the target file may be stored in the target node as a whole (ie without fragments). Correspondingly, the index node searches for the node information of the target node (corresponding to one target node) of the target file according to the file name of the target file.
所述数据传输方法可以使用其他的索引结构,例如一级索引结构、三级索引结构等。The data transmission method may use other index structures, such as a first-level index structure, a third-level index structure, and the like.
(3)从所述索引信息中获取所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址。(3) Obtain the hole punching ID, the hole punching protocol port, and the external IP address of the router from the index information.
目标文件是计算机设备需要下载的文件。所述目标文件可以是不同类型的文件,例如视频文件、音频文件、文本文件、图片文件等。The target file is the file that the computer device needs to download. The target files may be different types of files, such as video files, audio files, text files, picture files and so on.
在一实施例中,索引节点返回的所述目标文件的索引信息中还包括所述目标节点的NAT类型。In an embodiment, the index information of the target file returned by the index node further includes the NAT type of the target node.
目标节点的NAT类型可以包括全锥型、限制型锥型、端口限制型锥型、对称型。The NAT type of the target node may include full cone, restricted cone, port restricted cone, and symmetric.
判断单元202,用于根据所述打洞传输ID和所述路由器外部IP地址判断所述目标节点的类型。A judging unit 202, configured to judge the type of the target node according to the hole punching ID and the external IP address of the router.
在本实施例中,所述根据所述打洞传输ID和所述路由器外部IP地址判断所述目标节点的类型包括:In this embodiment, the determining the type of the target node according to the hole punching transmission ID and the external IP address of the router includes:
获取所述目标节点的外网IP地址;Obtain the external network IP address of the target node;
判断所述目标节点的外网IP地址是否等于所述目标节点的路由器外部IP地址以及判断所述目标节点的打洞传输ID是否为空;Judging whether the external network IP address of the target node is equal to the router external IP address of the target node and judging whether the hole-punching transmission ID of the target node is empty;
若所述目标节点的外网IP地址不等于所述目标节点的路由器外部IP地址并且所述目标节点的打洞传输ID不为空,则所述目标节点为内网节点;If the external network IP address of the target node is not equal to the router external IP address of the target node and the hole-punching transmission ID of the target node is not empty, then the target node is an internal network node;
若所述目标节点的外网IP地址等于所述目标节点的路由器外部IP地址并且所述目标节点的打洞传输ID为空,则所述目标节点为外网节点。If the external IP address of the target node is equal to the external IP address of the router of the target node and the hole punching ID of the target node is empty, then the target node is an external network node.
所述目标节点的外网IP地址是所述目标节点接入网络时为其分配的IP地址。The external network IP address of the target node is the IP address assigned to the target node when it accesses the network.
打洞单元203,用于若所述目标节点是内网节点,则根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址建立到所述目标节点的打洞传输通道。A hole punching unit 203, configured to establish a hole punch transmission to the target node according to the hole punch transmission ID, the hole punch transmission protocol port, and the router external IP address if the target node is an intranet node aisle.
在一实施例中,在所述根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址建立到所述目标节点的打洞传输通道之前,所述方法还包括:In an embodiment, before establishing the hole punching transmission channel to the target node according to the hole punching transmission ID, the hole punching transmission protocol port and the external IP address of the router, the method further includes:
根据所述计算机设备和所述目标节点的NAT类型判断所述计算机设备和所述目标节点之间是否支持打洞传输。It is judged according to the NAT types of the computer device and the target node whether hole-punching transmission is supported between the computer device and the target node.
若所述计算机设备和所述目标节点之间支持打洞传输,则根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址建立到所述目标节点的打洞传输通道;If hole-punching transmission is supported between the computer device and the target node, then establish a hole-punching transmission to the target node according to the hole-punching transmission ID, the hole-punching transmission protocol port and the router external IP address aisle;
若所述计算机设备和所述目标节点之间不支持打洞传输,则通过中间节点与所述目标节点进行数据传输。If hole-punching transmission is not supported between the computer device and the target node, data transmission is performed with the target node through an intermediate node.
中间节点是既能与计算机设备进行数据传输,又能与目标节点进行数据传输的节点。中间节点在计算机设备和目标节点间进行数据中转。The intermediate node is a node that can not only carry out data transmission with computer equipment, but also carry out data transmission with the target node. The intermediate node performs data transfer between the computer equipment and the target node.
计算机设备的NAT类型可以包括全锥型、限制型锥型、端口限制型锥型、对称型。NAT types for computer devices may include full cone, restricted cone, port restricted cone, and symmetric.
所述根据所述计算机设备和所述目标节点的NAT类型判断所述计算机设备和所述目标节点之间是否支持打洞传输包括:The determining whether hole-punching transmission is supported between the computer device and the target node according to the NAT type of the computer device and the target node includes:
若所述计算机设备和所述目标节点中的任意一方的NAT类型是对称型、另一方的NAT类型是端口限制型锥型,或者若所述计算机设备和所述目标节点的NAT类型都是对称型,则所述计算机设备和所述目标节点之间不支持打洞传输。If the NAT type of any one of the computer device and the target node is symmetric, and the NAT type of the other is port-restricted cone, or if the NAT types of the computer device and the target node are both symmetric type, hole punching transmission is not supported between the computer device and the target node.
在一实施例中,所述根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址建立到所述目标节点的打洞传输通道包括:In an embodiment, the establishment of the hole punching transmission channel to the target node according to the hole punching transmission ID, the hole punching transmission protocol port and the external IP address of the router includes:
根据所述打洞传输协议端口和所述路由器外部IP地址向打洞服务器发送打洞请求消息,请求所述打洞服务器帮助建立与所述目标节点的UDP连接;Send a hole punching request message to a hole punching server according to the hole punching transport protocol port and the router external IP address, requesting the hole punching server to help establish a UDP connection with the target node;
接收所述打洞服务器响应于所述打洞请求消息返回的所述目标节点的地址信息;receiving the address information of the target node returned by the hole punching server in response to the hole punch request message;
根据所述目标节点的地址信息向所述目标节点发送UDP数据包。sending a UDP data packet to the target node according to the address information of the target node.
打洞服务器接收到打洞请求消息后,将所述目标节点的地址信息发送给计算机设备,同时将计算机设备的地址信息发送给目标节点。计算机设备的地址信息可以包括计算机设备的IP地址和端口号,目标节点的地址信息可以包括目标节点的IP地址和端口号。After receiving the hole punching request message, the hole punching server sends the address information of the target node to the computer device, and at the same time sends the address information of the computer device to the target node. The address information of the computer device may include the IP address and port number of the computer device, and the address information of the target node may include the IP address and port number of the target node.
目标节点接收到打洞服务器返回的计算机设备的地址信息后,根据计算机设备的地址信息向计算机设备发送UDP数据包。一旦计算机设备与目标节点都向对方发送了数据包,就建立好计算机设备到目标节点的打洞传输通道。After receiving the address information of the computer device returned by the hole punching server, the target node sends a UDP data packet to the computer device according to the address information of the computer device. Once both the computer device and the target node have sent data packets to each other, a hole punching transmission channel from the computer device to the target node is established.
传输单元204,用于通过所述打洞传输通道与所述目标节点进行数据传输。The transmission unit 204 is configured to perform data transmission with the target node through the hole punched transmission channel.
例如,通过所述打洞传输通道从所述目标节点下载目标文件。For example, the target file is downloaded from the target node through the hole punched transmission channel.
所述打洞传输通道从所述目标节点下载目标文件可以包括:The downloading of the target file from the target node by the hole punching transmission channel may include:
通过所述打洞传输通道向所述目标节点发送文件请求;sending a file request to the target node through the hole punched transmission channel;
接收所述目标节点通过所述打洞传输通道返回的所述目标文件。and receiving the target file returned by the target node through the hole punching transmission channel.
实施例二的数据传输装置20获取目标节点的打洞传输ID、打洞传输协议端口和路由器外部IP地址,根据目标文件的目标节点的打洞传输ID和路由器外部IP判断目标节点是否为内网节点,当目标节点为内网节点时根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址建立到所述目标节点的打洞传输通道,利用所述打洞传输通道进行数据传输。所述数据传输装置20支持计算机设备与内网节点进行数据传输,解决了现有技术不能与内网节点进行数据传输的技术问题。The data transmission device 20 of the second embodiment obtains the hole-punching transmission ID, the hole-punching transmission protocol port and the external IP address of the router of the target node, and judges whether the target node is an intranet according to the hole-punching transmission ID of the target node of the target file and the external IP of the router A node, when the target node is an intranet node, establishes a hole-punching transmission channel to the target node according to the hole-punching transmission ID, the hole-punching transmission protocol port, and the external IP address of the router, and utilizes the hole-punching transmission channel for data transmission. The data transmission device 20 supports data transmission between computer equipment and intranet nodes, which solves the technical problem that the prior art cannot perform data transmission with intranet nodes.
在另一实施例中,所述传输单元204还用于:In another embodiment, the transmission unit 204 is also used for:
若所述目标节点是外网节点,则通过直接通信与所述目标节点进行数据传输。If the target node is an external network node, data transmission is performed with the target node through direct communication.
实施例三Embodiment three
本实施例提供一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器执行时实现上述数据传输方法实施例中的步骤,例如图1所示的101-104:This embodiment provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium. When the computer program is executed by a processor, the steps in the above-mentioned data transmission method embodiment are implemented, for example, 101 shown in FIG. 1 -104:
101,获取目标节点的打洞传输ID、打洞传输协议端口和路由器外部IP地址;101. Obtain the hole-punching transmission ID, the hole-punching transmission protocol port, and the external IP address of the router of the target node;
102,根据所述打洞传输ID和所述路由器外部IP地址判断所述目标节点的类型;102. Determine the type of the target node according to the hole punching ID and the external IP address of the router;
103,若所述目标节点是内网节点,则根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址建立到所述目标节点的打洞传输通道;103. If the target node is an intranet node, establish a hole punching transmission channel to the target node according to the hole punching transmission ID, the hole punching transmission protocol port, and the router external IP address;
104,通过所述打洞传输通道与所述目标节点进行数据传输。104. Perform data transmission with the target node through the hole punched transmission channel.
或者,该计算机程序被处理器执行时实现上述装置实施例中各模块/单元的功能,例如图2中的单元201-204:Alternatively, when the computer program is executed by the processor, the functions of the modules/units in the above-mentioned device embodiments are realized, such as units 201-204 in FIG. 2:
获取单元201,用于获取目标节点的打洞传输ID、打洞传输协议端口和路由器外部IP地址;The obtaining unit 201 is used to obtain the hole-punching transmission ID, the hole-punching transmission protocol port and the external IP address of the router of the target node;
判断单元202,用于根据所述打洞传输ID和所述路由器外部IP地址判断所述目标节点的类型;A judging unit 202, configured to judge the type of the target node according to the hole punching ID and the external IP address of the router;
打洞单元203,用于若所述目标节点是内网节点,则根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址建立到所述目标节点的打洞传输通道;A hole punching unit 203, configured to establish a hole punch transmission to the target node according to the hole punch transmission ID, the hole punch transmission protocol port, and the router external IP address if the target node is an intranet node aisle;
传输单元204,用于通过所述打洞传输通道与所述目标节点进行数据传输。The transmission unit 204 is configured to perform data transmission with the target node through the hole punched transmission channel.
实施例四Embodiment four
图3为本发明实施例提供的计算机设备的示意图。所述计算机设备3包括存储器30、处理器31、总线33以及存储在所述存储器30中并可在所述处理器31上运行的计算机程序32。所述处理器31执行所述计算机程序32时实现上述数据传输方法实施例中的步骤,例如图1所示的101-104:Fig. 3 is a schematic diagram of a computer device provided by an embodiment of the present invention. The computer device 3 includes a memory 30 , a processor 31 , a bus 33 and a computer program 32 stored in the memory 30 and executable on the processor 31 . When the processor 31 executes the computer program 32, the steps in the above data transmission method embodiment are implemented, such as 101-104 shown in FIG. 1:
101,获取目标节点的打洞传输ID、打洞传输协议端口和路由器外部IP地址;101. Obtain the hole-punching transmission ID, the hole-punching transmission protocol port, and the external IP address of the router of the target node;
102,根据所述打洞传输ID和所述路由器外部IP地址判断所述目标节点的类型;102. Determine the type of the target node according to the hole punching ID and the external IP address of the router;
103,若所述目标节点是内网节点,则根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址建立到所述目标节点的打洞传输通道;103. If the target node is an intranet node, establish a hole punching transmission channel to the target node according to the hole punching transmission ID, the hole punching transmission protocol port, and the router external IP address;
104,通过所述打洞传输通道与所述目标节点进行数据传输。104. Perform data transmission with the target node through the hole punched transmission channel.
或者,所述处理器31执行所述计算机程序32时实现上述装置实施例中各模块/单元的功能,例如图2中的单元201-204:Alternatively, when the processor 31 executes the computer program 32, the functions of the modules/units in the above-mentioned device embodiments are implemented, for example, the units 201-204 in FIG. 2:
获取单元201,用于获取目标节点的打洞传输ID、打洞传输协议端口和路由器外部IP地址;The obtaining unit 201 is used to obtain the hole-punching transmission ID, the hole-punching transmission protocol port and the external IP address of the router of the target node;
判断单元202,用于根据所述打洞传输ID和所述路由器外部IP地址判断所述目标节点的类型;A judging unit 202, configured to judge the type of the target node according to the hole punching ID and the external IP address of the router;
打洞单元203,用于若所述目标节点是内网节点,则根据所述打洞传输ID、所述打洞传输协议端口和所述路由器外部IP地址建立到所述目标节点的打洞传输通道;A hole punching unit 203, configured to establish a hole punch transmission to the target node according to the hole punch transmission ID, the hole punch transmission protocol port, and the router external IP address if the target node is an intranet node aisle;
传输单元204,用于通过所述打洞传输通道与所述目标节点进行数据传输。The transmission unit 204 is configured to perform data transmission with the target node through the hole punched transmission channel.
示例性的,所述计算机程序32可以被分割成一个或多个模块/单元,所述一个或者多个模块/单元被存储在所述存储器30中,并由所述处理器31执行,以完成本发明。所述一个或多个模块/单元可以是能够完成特定功能的一系列计算机程序指令段,该指令段用于描述所述计算机程序32在所述计算机设备3中的执行过程。Exemplarily, the computer program 32 can be divided into one or more modules/units, and the one or more modules/units are stored in the memory 30 and executed by the processor 31 to complete this invention. The one or more modules/units may be a series of computer program instruction segments capable of accomplishing specific functions, and the instruction segments are used to describe the execution process of the computer program 32 in the computer device 3 .
所述计算机设备3可以是PC(Personal Computer,个人电脑),也可以是智能手机、平板电脑、掌上电脑、便携计算机、智能路由器、矿机、网络存储设备等终端设备。The computer device 3 may be a PC (Personal Computer, personal computer), or may be a terminal device such as a smart phone, a tablet computer, a palmtop computer, a portable computer, an intelligent router, a mining machine, or a network storage device.
所称处理器31可以是中央处理单元(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器31也可以是任何常规的处理器等,所述处理器31是所述计算机设备3的控制中心,利用各种接口和线路连接整个计算机设备3的各个部分。The so-called processor 31 can be a central processing unit (Central Processing Unit, CPU), and can also be other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. General-purpose processor can be microprocessor or this processor 31 also can be any conventional processor etc., and described processor 31 is the control center of described computer equipment 3, utilizes various interfaces and lines to connect the whole computer equipment 3 various parts.
所述存储器30可用于存储所述计算机程序32和/或模块/单元,所述处理器31通过运行或执行存储在所述存储器30内的计算机程序和/或模块/单元,以及调用存储在存储器30内的数据,实现所述计算机设备3的各种功能。所述存储器30可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序(比如声音播放功能、图像播放功能等)等;存储数据区可存储根据计算机设备3的使用所创建的数据。此外,存储器30可以包括非易失性存储器,例如硬盘、内存、插接式硬盘,智能存储卡(SmartMedia Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)、至少一个磁盘存储器件、闪存器件、或其他非易失性固态存储器件。The memory 30 can be used to store the computer program 32 and/or module/unit, and the processor 31 runs or executes the computer program and/or module/unit stored in the memory 30, and calls the computer program stored in the memory 30 30 to realize various functions of the computer device 3. The memory 30 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application program (such as a sound playback function, an image playback function, etc.) required by at least one function; the storage data area can be Data created according to the use of the computer device 3 is stored. In addition, the memory 30 may include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash memory card (Flash Card), at least A disk storage device, flash memory device, or other non-volatile solid-state storage device.
所述总线33以是外设部件互连标准(peripheral component interconnect,简称PCI)总线或扩展工业标准结构(extended industry standard architecture,简称EISA)总线等。所述总线33可以分为地址总线、数据总线、控制总线等。为便于表示,图3中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。The bus 33 may be a peripheral component interconnect (PCI for short) bus or an extended industry standard architecture (EISA for short) bus or the like. The bus 33 can be divided into address bus, data bus, control bus and so on. For ease of representation, only one thick line is used in FIG. 3 , but it does not mean that there is only one bus or one type of bus.
进一步地,计算机设备3还可以包括网络接口,网络接口可选的可以包括有线接口和/或无线接口(如WI-FI接口、蓝牙接口等),通常用于在该计算机设备3与其他电子设备之间建立通信连接。Further, the computer device 3 can also include a network interface, and the network interface can optionally include a wired interface and/or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which are usually used for connecting the computer device 3 with other electronic devices. establish a communication connection between them.
可选地,该计算机设备3还可以包括用户接口,用户接口可以包括显示器(Display)、输入单元比如键盘(Keyboard),可选的用户接口还可以包括标准的有线接口、无线接口。可选地,在一些实施例中,显示器可以是LED显示器、液晶显示器、触控式液晶显示器以及OLED(Organic Light-Emitting Diode,有机发光二极管)触摸器等。其中,显示器也可以适当的称为显示屏或显示单元,用于显示在计算机设备3中处理的信息以及用于显示可视化的用户界面。Optionally, the computer device 3 may also include a user interface, which may include a display (Display), an input unit such as a keyboard (Keyboard), and optional user interfaces may also include standard wired interfaces and wireless interfaces. Optionally, in some embodiments, 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, and the like. Wherein, the display may also be appropriately called a display screen or a display unit, and is used for displaying information processed in the computer device 3 and for displaying a visualized user interface.
本领域技术人员可以理解,所述示意图3仅仅是计算机设备3的示例,并不构成对计算机设备3的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件。Those skilled in the art can understand that the schematic diagram 3 is only an example of the computer device 3, and does not constitute a limitation to the computer device 3, and may include more or less components than those shown in the figure, or combine certain components, or be different parts.
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。In the above embodiments, all or part of them may be implemented by software, hardware, firmware or any combination thereof. When implemented using software, it may be implemented in whole or in part in the form of a computer program product.
所述计算机程序产品包括一个或多个计算机指令。在计算机设备上加载和执行所述计算机程序指令时,全部或部分地产生按照本发明实施例所述的流程或功能。所述计算机设备可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存储的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘Solid State Disk(SSD))等。The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer device, the processes or functions according to the embodiments of the present invention will be generated in whole or in part. The computer equipment may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website, computer, server, or data center Transmission to another website site, computer, server, or data center by wired (eg, coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (eg, 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 a data center integrated with one or more available media. The available medium may be a magnetic medium (for example, a floppy disk, a hard disk, or a magnetic tape), an optical medium (for example, DVD), or a semiconductor medium (for example, a Solid State Disk (SSD)).
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that for the convenience and brevity of the description, the specific working process of the above-described system, device and unit can refer to the corresponding process in the foregoing method embodiment, which will not be repeated here.
在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个装置,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed system, device and method can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or It may be integrated into another device, or some features may be omitted, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-OnlyMemory)、磁碟或者光盘等各种可以存储程序代码的介质。If the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or part of the contribution to the prior art 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 may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: various media capable of storing program codes such as a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a magnetic disk, or an optical disk.
需要说明的是,上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。并且本文中的术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、装置、物品或者方法不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、装置、物品或者方法所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、装置、物品或者方法中还存在另外的相同要素。It should be noted that the serial numbers of the above embodiments of the present invention are only for description, and do not represent the advantages and disadvantages of the embodiments. And herein the term "comprises", "comprises" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, apparatus, article or method comprising a set of elements includes not only those elements, but also includes the elements not expressly included. other elements listed, or also include elements inherent in the process, apparatus, article, or method. Without further limitations, an element defined by the phrase "comprising a ..." does not preclude the presence of additional same elements in the process, apparatus, article or method comprising the element.
以上仅为本发明的优选实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本发明的专利保护范围内。The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process conversion made by using the description of the present invention and the contents of the accompanying drawings, or directly or indirectly used in other related technical fields , are all included in the scope of patent protection of the present invention in the same way.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201911399560.8ACN111147186B (en) | 2019-12-30 | 2019-12-30 | Data transmission method and device, computer equipment and storage medium |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201911399560.8ACN111147186B (en) | 2019-12-30 | 2019-12-30 | Data transmission method and device, computer equipment and storage medium |
| Publication Number | Publication Date |
|---|---|
| CN111147186A CN111147186A (en) | 2020-05-12 |
| CN111147186Btrue CN111147186B (en) | 2023-07-18 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201911399560.8AActiveCN111147186B (en) | 2019-12-30 | 2019-12-30 | Data transmission method and device, computer equipment and storage medium |
| Country | Link |
|---|---|
| CN (1) | CN111147186B (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114095470B (en)* | 2020-07-29 | 2024-08-20 | 顺丰科技有限公司 | Block chain node uplink method and device and block chain link point |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101741914A (en)* | 2010-02-03 | 2010-06-16 | 上海悠络客电子科技有限公司 | Method and system for penetrating NAT to establish overlay network in P2P network |
| CN101873359A (en)* | 2010-06-28 | 2010-10-27 | 北京神州泰岳软件股份有限公司 | Method for implementing UDP hole punching |
| WO2016201966A1 (en)* | 2015-06-18 | 2016-12-22 | 中兴通讯股份有限公司 | Nat traversal method, apparatus and system |
| CN108600316A (en)* | 2018-03-23 | 2018-09-28 | 深圳市网心科技有限公司 | Data managing method, system and the equipment of cloud storage service |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101895590A (en)* | 2010-07-23 | 2010-11-24 | 华南理工大学 | UDT-based system and method for realizing network address translator traversal |
| CN106550058A (en)* | 2015-09-17 | 2017-03-29 | 群晖科技股份有限公司 | Network address translation penetration method and system using same |
| US11074226B2 (en)* | 2017-05-24 | 2021-07-27 | 3S International, LLC | Hierarchical computing network and methods thereof |
| CN109660639B (en)* | 2018-12-11 | 2022-02-25 | 深圳市迅雷网络技术有限公司 | A data uploading method, device, system and medium |
| CN109788051A (en)* | 2019-01-02 | 2019-05-21 | 深圳市网心科技有限公司 | Network resource transmission method and system based on distributed file system |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101741914A (en)* | 2010-02-03 | 2010-06-16 | 上海悠络客电子科技有限公司 | Method and system for penetrating NAT to establish overlay network in P2P network |
| CN101873359A (en)* | 2010-06-28 | 2010-10-27 | 北京神州泰岳软件股份有限公司 | Method for implementing UDP hole punching |
| WO2016201966A1 (en)* | 2015-06-18 | 2016-12-22 | 中兴通讯股份有限公司 | Nat traversal method, apparatus and system |
| CN108600316A (en)* | 2018-03-23 | 2018-09-28 | 深圳市网心科技有限公司 | Data managing method, system and the equipment of cloud storage service |
| Title |
|---|
| 基于NAT穿透P2P即时通讯系统的设计与实现;张静颐;赵雪岩;陈爱网;;电子设计工程(第07期);全文* |
| Publication number | Publication date |
|---|---|
| CN111147186A (en) | 2020-05-12 |
| Publication | Publication Date | Title |
|---|---|---|
| CN109951562B (en) | NAT traversal method and system, electronic device and storage medium | |
| CN108038114A (en) | A kind of path query method, terminal, computer-readable recording medium | |
| CN110677493B (en) | Service state determination method and device, computer device and storage medium | |
| CN106874471A (en) | Information-pushing method and device | |
| CN111343048A (en) | Stress testing method and device, computer device and storage medium | |
| CN110049059A (en) | A kind of outer net equipment and Intranet communication between devices method and relevant apparatus | |
| CN111314458A (en) | P2P network hole punching method, hole punching device and computer readable storage medium | |
| CN110191204A (en) | Communication method, system, device and computer storage medium between intranet devices | |
| CN110855525A (en) | Flow statistical method, electronic device, system and medium | |
| CN108536617A (en) | Buffer memory management method, medium, system and electronic equipment | |
| CN104619039A (en) | Terminal equipment interconnection method and system in wireless local area network (WLAN) and terminal equipment | |
| CN107294811A (en) | Network detection method, network detection device and intelligent terminal | |
| CN111147186B (en) | Data transmission method and device, computer equipment and storage medium | |
| CN110347648B (en) | File deployment method and device, computer device and storage medium | |
| CN114745324A (en) | Device identification method, device, storage medium and routing device | |
| CN110808974A (en) | Data acquisition method and device, computer device and storage medium | |
| CN110417789A (en) | Server connection method, electronic device, system and medium | |
| CN115484246A (en) | Page loading method and device, storage medium and electronic device | |
| CN114089997A (en) | Method and device for processing page stack, storage medium and electronic device | |
| CN110300182A (en) | Network node dispatching method and device, computer installation and storage medium | |
| WO2021227661A1 (en) | Method and apparatus for installing application program, and terminal device and storage medium | |
| WO2018032705A1 (en) | Method and device for providing wireless access point information packet | |
| CN110266802A (en) | Reverse proxy service method, server, system and medium based on ID identification | |
| CN110166575A (en) | A kind of http Proxy Method, system, device and computer media | |
| CN110535977B (en) | File distribution method and device, computer device and storage medium |
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |