WO2014190643A1 - 一种数据交互的方法、装置及系统 - Google Patents

一种数据交互的方法、装置及系统 Download PDF

Info

Publication number
WO2014190643A1
WO2014190643A1 PCT/CN2013/084145 CN2013084145W WO2014190643A1 WO 2014190643 A1 WO2014190643 A1 WO 2014190643A1 CN 2013084145 W CN2013084145 W CN 2013084145W WO 2014190643 A1 WO2014190643 A1 WO 2014190643A1
Authority
WO
WIPO (PCT)
Prior art keywords
address
host
channel
client host
client
Prior art date
Application number
PCT/CN2013/084145
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 华为技术有限公司
Priority to EP13863673.3A priority Critical patent/EP2822256B1/en
Priority to KR1020147019342A priority patent/KR101776648B1/ko
Priority to JP2015518840A priority patent/JP5930449B2/ja
Priority to US14/310,727 priority patent/US9432330B2/en
Publication of WO2014190643A1 publication Critical patent/WO2014190643A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/25Mapping addresses of the same type
    • H04L61/2503Translation of Internet protocol [IP] addresses
    • H04L61/256NAT traversal
    • H04L61/2589NAT traversal over a relay server, e.g. traversal using relay for network address translation [TURN]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/10Mapping addresses of different types
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/25Mapping addresses of the same type
    • H04L61/2503Translation of Internet protocol [IP] addresses
    • H04L61/2592Translation of Internet protocol [IP] addresses using tunnelling or encapsulation

Definitions

  • the present invention relates to the field of communications technologies, and in particular, to a method, device, and system for data interaction. Background technique
  • NAT Network Address Translation
  • IP Internet Protocol
  • HTTP hypertext transfer protocol
  • the HTTP Tunnel technology proposes to encapsulate the user communication data packet in the HTTP format, simulate the HTTP communication behavior, and send the data packet to the external network relay device.
  • the relay device restores the data packet and then forwards the data packet to the destination address.
  • the network environment detection of HTTP Tunnel technology is as follows:
  • the client sends a probe request packet to the relay device of the public network by using the User Data Protocol (UDP). If the response is successfully received, the NAT host allows UDP communication on the port to terminate the probe. Otherwise, the probe is terminated. No further steps are allowed.
  • the client sends a probe request packet to the relay device of the public network by using the Transmission Control Protocol (TCP). If the response is successfully received, the NAT host allows TCP communication on the port to terminate the probe. Otherwise, the probe is disabled. Continue to the next step.
  • UDP User Data Protocol
  • TCP Transmission Control Protocol
  • the inventor of the present invention has found that the HTTP tunneling technology adopts the single-step detection mode, and the next detection needs to wait for the detection result of the previous step. This causes the HTTP module to be traversed too slowly if the HTTP module is enabled. Summary of the invention
  • the embodiment of the invention provides a method for data interaction, which can improve the efficiency of traversing a NAT host during address detection, thereby shortening the pull-up delay of data interaction between two client hosts.
  • Embodiments of the present invention also provide corresponding apparatus and systems.
  • a first aspect of the present invention provides a data interaction method, including:
  • Channel connectivity detection is performed according to the paired address, and the channel with the highest priority among the detected valid channels is selected to perform data interaction with the peer client host.
  • the method before the step of performing address exchange and address pairing with the peer client host, the method further includes:
  • the host addresses of the three types of channels include the host address of the UDP channel, the host address of the TCP channel, and the host address of the HTTP channel.
  • performing address matching and address matching with the peer client host includes: The host address of the three types of channels of the local client host and the collected two types of addresses are collected with the host address of the three types of channels of the peer client host and the peer client host.
  • the two types of addresses are exchanged and paired.
  • the host address of the three types of channels of the local client host and the collected two types of addresses are The host address of the three types of channels of the peer client host and the two types of addresses collected by the peer client host are exchanged and paired, including:
  • the mapped address assigned by the outer NAT host is exchanged and paired with the relay address of the peer relay device.
  • the channel connectivity detection is performed according to the paired address, and the channel with the highest priority among the detected valid channels is selected.
  • the client host performs data interaction, including:
  • the UDP channel When the UDP channel is successfully connected, the UDP channel is selected as the channel with the highest priority when the local client host performs data interaction with the client client.
  • any one of the first to the third possible implementation manners of the first aspect in a fourth possible implementation, the method further includes:
  • a second aspect of the present invention provides a data interaction method, including:
  • the method further includes: receiving data sent by the local client host, where the destination address of the data indicates that the receiver of the data is End client host;
  • the method further includes: receiving data in a UDP format sent by the peer relay device;
  • the channel with the highest priority between the local relay device and the local client host is non-UDP Channel, converting the data in the UDP format to a format corresponding to the channel with the highest priority;
  • the format converted data is sent to the local client host.
  • a third aspect of the present invention provides a client host, including:
  • a sending unit configured to simultaneously send an address detection request of a user data packet protocol UDP channel and an address detection request of a data transmission protocol TCP channel, and send when the address detection of the UDP channel and the address detection of the TCP channel fail An address detection request of the HTTP channel of the Hypertext Transfer Protocol;
  • a receiving unit configured to collect two types of addresses corresponding to each channel in the at least one channel when the at least one channel is successfully detected, where the two types of addresses include an outermost network The address translation address assigned by the NAT host and the relay address of the local relay device;
  • An address processing unit configured to perform address exchange and address matching between the address received by the receiving unit and the peer client host; and select and select the channel with the highest priority among the detected valid channels and the peer client host Data Interaction.
  • the client host further includes: an address obtaining unit,
  • the address obtaining unit is configured to obtain a host address of three types of channels of the local client host, where the host addresses of the three types of channels include a host address of the UDP channel, a host address of the TCP channel, and a host address of the HTTP channel;
  • the address processing unit is configured to use a host address of the three types of channels of the local client host and the collected two types of addresses, and a host address of the three types of channels of the peer client host, and The two types of addresses collected by the peer client host are exchanged and paired.
  • the address processing unit is configured to use a host address of the UDP channel of the client host, a host address of a TCP channel, and The host address of the HTTP channel, and the mapping address assigned by the outermost network address translation NAT host of each channel in the at least one channel collected by the client host, and the relay address of the local relay device, and the other party's client
  • the host address of the UDP channel of the host, the host address of the TCP channel, and the host address of the HTTP channel, and the mapped address assigned by the outermost NAT host collected by the client host and the relay address of the peer relay device are exchanged. And pairing.
  • the channel processing unit is configured to detect a host location of a UDP channel of the paired local client host
  • the UDP channel When the UDP channel is successfully connected, the UDP channel is selected as the channel with the highest priority when the local client host interacts with the peer client host.
  • the address processing unit is further configured to perform address exchange with the peer client host through the proxy server when performing address exchange.
  • a fourth aspect of the present invention provides a relay device, including:
  • a receiving unit configured to receive an address detection request sent by the local client host
  • An address collecting unit configured to: according to the type of the packet of the address detection request received by the receiving unit, Collecting two types of addresses corresponding to the packet type, the two types of addresses including the outermost network address translation
  • a sending unit configured to send, to the local client host, the two types of addresses corresponding to the text type collected by the address collecting unit, so that the local client host and the peer client host perform The addresses are exchanged and paired, so that the local client host performs channel connectivity detection according to the paired address, and selects the channel with the highest priority among the detected valid channels to perform data interaction with the peer client host.
  • the relay device further includes: a first format conversion unit,
  • the receiving unit is further configured to receive data sent by the local client host, where a destination address of the data indicates that the receiver of the data is a peer client host;
  • the first format conversion unit is configured to convert the data received by the receiving unit into data in a UDP format; and send the data in the UDP format to the peer relay device.
  • the relay device further includes: a determining unit and a second format converting unit,
  • the receiving unit is further configured to receive data in a UDP format that is sent by the peer relay device, where the determining unit is configured to determine a highest priority between the local relay device and the local client host. If the channel with the highest priority between the local client hosts is a non-UDP channel, the data in the UDP format is converted to a format corresponding to the channel with the highest priority;
  • the sending unit is configured to send the data converted by the second format conversion unit to the local client host.
  • a fifth aspect of the present invention provides a data interaction system, including: a first client host, a second client host, a first network address translation NAT host, a second NAT host, a first relay device, and a second relay device. ;
  • the first client host, the first NAT host, and the first relay device belong to a first network;
  • the second client host, the second NAT host, and the second relay device belong to a second network
  • the first NAT host is the outermost NAT host in the first network, and when receiving the address probe request sent by the first client host, assigning a mapping address to the first client host;
  • the second NAT host is the outermost NAT host in the second network, and when receiving the address probe request sent by the second client host, assigning a mapping address to the second client host;
  • the first client host and the second client host are the client hosts described in the foregoing technical solution;
  • a sixth aspect of the present invention provides a data interaction system, including: a first client host, a second client host, a network address translation NAT host, and a relay device, and the first client host and the second client The hosts belong to the same network;
  • the NAT host is the outermost NAT host of the network where the first client host and the second client host are located, and receives at least one of the first client host and the second client host. Assigning a mapping address to at least one of the first client host and the second client host when the address probe request is sent;
  • the first client host and the second client host are the client hosts described in the foregoing technical solution;
  • the relay device is the relay device described in the above technical solution.
  • the embodiment of the present invention adopts an address detection request for simultaneously transmitting a user data packet protocol UDP channel and an address detection request of a data transmission protocol TCP channel, and when the address detection of the UDP channel and the address detection of the TCP channel fail, the method further transmits An address detection request of the Hypertext Transfer Protocol HTTP channel; when at least one channel is successfully detected, collecting two types of addresses corresponding to each of the at least one channel, the two types of addresses including the outermost layer of each channel.
  • the network address translates the mapped address assigned by the NAT host and the relay address of the local relay device; performs address exchange with the peer client host and performs address matching; performs channel connectivity detection according to the paired address, and selects to detect The channel with the highest priority among the valid channels interacts with the peer client host.
  • the embodiment of the present invention performs address detection by simultaneously transmitting an address detection request of a user data packet protocol UDP channel and an address detection request of a data transmission protocol TCP channel, thereby improving traversal of the NAT host during address detection.
  • the efficiency which shortens the pull-up delay for data exchange between two client hosts.
  • FIG. 1 is a schematic flow chart of a method for data interaction according to an embodiment of the present invention
  • FIG. 2 is a schematic flow chart of another method for data interaction according to an embodiment of the present invention.
  • FIG. 3 is a timing diagram of a method for data interaction in an application scenario in an embodiment of the present invention.
  • FIG. 4 is a timing diagram of a method for data interaction in another application scenario in the embodiment of the present invention.
  • FIG. 5 is a schematic diagram of networking of an application scenario in the embodiment of the present invention.
  • FIG. 5B is a schematic diagram of networking of another application scenario in the embodiment of the present invention.
  • FIG. 6 is a schematic structural diagram of a client host in an embodiment of the present invention.
  • FIG. 7 is a schematic structural diagram of another client host in an embodiment of the present invention.
  • FIG. 8 is a schematic structural diagram of a relay device according to an embodiment of the present invention.
  • FIG. 9 is a schematic structural diagram of another relay device according to an embodiment of the present invention.
  • FIG. 10 is a schematic structural diagram of still another relay device according to an embodiment of the present invention.
  • FIG. 11 is a schematic structural diagram of another client host in the embodiment of the present invention.
  • FIG. 12 is a schematic structural diagram of still another relay device according to an embodiment of the present invention.
  • FIG. 13 is a schematic structural diagram of a data interaction system according to an embodiment of the present invention.
  • FIG. 14 is a schematic structural diagram of another data interaction system in an embodiment of the present invention.
  • the embodiment of the invention provides a method for data interaction, which can improve the efficiency of traversing a NAT host during address detection, thereby shortening the pull-up delay of data interaction between two client hosts.
  • the embodiments of the present invention also provide corresponding devices and systems. The details are described below separately.
  • an embodiment of a data interaction method provided by an embodiment of the present invention may be a client host, where the client host may be, for example, a personal computer (PC) or a mobile phone.
  • the device of the embodiment of the present invention may include: a device such as a personal digital assistant (PDA).
  • PDA personal digital assistant
  • the client can establish three types of channels, namely the User Datagram Protocol (UDP) channel, the Transmission Control Protocol (TCP) channel, and the Hypertext Transfer Protocol (HTTP) channel.
  • UDP User Datagram Protocol
  • TCP Transmission Control Protocol
  • HTTP Hypertext Transfer Protocol
  • the client host creates the host addresses for these three channels.
  • the UDP channel has the highest priority
  • the TCP channel has the highest priority
  • the HTTP channel has the lowest priority. Therefore, when any of the UDP channel or TCP channel is available, the HTTP channel is not required, only the UDP channel and the TCP channel. The HTTP channel is used when it is not available.
  • the network where the client host resides can have multiple layers of NAT hosts.
  • the process of address detection is as follows: The client host sends an address probe request.
  • the address probe request traverses the NAT host in the network one by one. Only when the outermost NAT host is traversed. It is considered that the traversal of the NAT host is successful.
  • the NAT host that traverses one layer of the probe request carries the mapping address assigned by the previous NAT host in the probe request.
  • the mapped address assigned by the NAT host replaces the mapped address assigned by the previous layer of the NAT host. Therefore, when the probe request arrives at the relay device, the relay device only collects the most The mapped address assigned by the outer NAT host.
  • the HTTP probe will not be sent. Therefore, there are four cases.
  • the network address translates the mapped address assigned by the NAT host and the relay address of the local relay device; a mapping address assigned by the outermost network address translation NAT host that successfully collects the TCP channel for the TCP probe request to traverse the NAT.
  • the relay address of the local relay device the mapping address assigned by the outermost NAT host that collects the UDP channel and the TCP channel and the local relay device. Trunking address; a UDP probe request and a TCP probe request failing at the same time, the HTTP probe request traversing the NAT successfully, collecting the mapped address assigned by the HTTP host of the HTTP channel, and the local relay device providing the relay service Following the address.
  • Multiple channels can be used after connectivity detection, but the channel with the highest priority is selected.
  • the embodiment of the present invention performs address detection by simultaneously transmitting an address detection request of a user data packet protocol UDP channel and an address detection request of a data transmission protocol TCP channel, thereby improving address detection.
  • the efficiency of traversing the NAT host reduces the delay of data exchange between the two client hosts.
  • the pull-up delay may be a start delay of the data interaction, for example, the original two client hosts need 200 seconds to initiate the interaction before the data interaction, and then the pull-up delay is 200.
  • the start delay of the data interaction may be 100 seconds, thereby shortening the pull-up delay of the data interaction.
  • the method can also include:
  • the host addresses of the three types of channels include the host address of the UDP channel, the host address of the TCP channel, and the host address of the HTTP channel.
  • the address matching and the address matching with the peer client host may include: the host address of the three types of channels of the local client host and the collected two types of addresses, and the pair The host addresses of the three types of channels of the end client host and the two types of addresses collected by the peer client host are exchanged and paired.
  • each channel has three types of addresses, respectively, for
  • the UDP channel is the host address of the UDP channel of the client host, the mapping address assigned by the outermost NAT host to the UDP channel, and the relay device address assigned by the relay device to the UDP channel.
  • the TCP channel is the client host. The host address of the TCP channel, the mapped address assigned by the outermost NAT host for the TCP channel, and the address of the relay device assigned by the relay device to the TCP channel.
  • the HTTP channel the host address of the HTTP channel of the client host, the most The mapped address assigned by the outer NAT host for the HTTP channel and the relay device address assigned by the relay device to the HTTP channel.
  • the local client host and the peer client host exchange the host address of the UDP channel, the host address of the TCP channel, and the host address of the HTTP channel, and the collected types of addresses.
  • the host address of the UDP channel and the host address of the TCP channel are added during the address exchange, thereby increasing the diversity of channel selection.
  • the three types of channels of the local client host are selected.
  • the host address and the collected two types of addresses are exchanged and paired with the host addresses of the three types of channels of the peer client host and the two types of addresses collected by the peer client host.
  • the host address of the UDP channel, the host address of the TCP channel, and the host address of the HTTP channel are included, so that the UDP probe request and the TCP probe request traverse fail immediately, and the HTTP probe request traverses successfully.
  • the host addresses of the channels are exchanged and paired.
  • the priority of the UDP channel and the TCP channel are higher than the priority of the HTTP channel, so the host address of the UDP channel of the local client host and the UDP channel of the peer client host are After the host address is successfully paired, or the host address of the TCP channel of the local client host is successfully paired with the host of the TCP channel of the peer client host, you can select UDP channel or TCP channel for data interaction, thus improving data interaction.
  • the priority of the transmission channel is higher than the priority of the HTTP channel, so the host address of the UDP channel of the local client host and the UDP channel of the peer client host are After the host address is successfully paired, or the host address of the TCP channel of the local client host is successfully paired with the host of the TCP channel of the peer client host, you can select UDP channel or TCP channel for data interaction, thus improving data interaction.
  • the priority of the transmission channel is higher than the priority of the HTTP channel
  • the channel connectivity detection is performed according to the paired address, and the detection is selected.
  • the data with the highest priority channel in the valid channel and the peer client host can include:
  • the UDP channel When the UDP channel is successfully connected, the UDP channel is selected as the channel with the highest priority when the local client host performs data interaction with the client client.
  • the UDP channel has the highest priority and the TCP channel has a higher priority than the HTTP channel
  • the host address of the UDP channel of the local client host and the UDP channel connection between the pair are preferentially detected.
  • the two client hosts select this UDP channel for data interaction.
  • relay devices are also required for transit.
  • the UDP address and the TCP address of the client host are In this way, even if NAT does not allow UDP or TCP packets to pass, when two client hosts are on the same network, UDP channels or TCP channels can be used for data interaction. UDP channels are usually preferred.
  • the method also includes:
  • the address exchange When the address is exchanged, the address exchange with the peer client host through the proxy server.
  • the address exchange when performing address exchange with the peer client host, the address exchange may be directly performed through a proxy server, such as: The Extensible Messaging and Presence Protocol (Xmpp) signaling protocol server.
  • Xmpp Extensible Messaging and Presence Protocol
  • the implementation manner may be: sending Xmpp signaling to the signaling protocol server, or performing address exchange through extended attributes of Xmpp signaling.
  • another embodiment of the method for data interaction provided by the embodiment of the present invention may be a relay device, where the relay device may be, for example, a router, a switch, a hub, or a network. Server and so on.
  • the method of the embodiment of the present invention may include:
  • the 202 Collect, according to the packet type of the address detection request, two types of addresses corresponding to the packet type, where the two types of addresses include a mapping address allocated by an outermost network address translation NAT host, and a local relay. The relay address of the device.
  • the local client host sends, to the local client host, the collected two types of addresses corresponding to the text type, so that the local client host and the peer client host perform address exchange and pairing, thereby The local client host performs channel connectivity detection according to the paired address, and selects the channel with the highest priority among the detected valid channels to perform data interaction with the peer client host.
  • the data interaction method provided by the embodiment of the present invention can enable the client host to collect corresponding channels when one of the address detection request of the UDP channel and the address detection request of the TCP channel successfully traverse the NAT.
  • the two types of addresses enable the client host to improve the efficiency of traversing the NAT host during address detection, thereby shortening the pull-up delay of data exchange between the two client hosts.
  • an optional embodiment of the data interaction method provided by the embodiment of the present invention may further include: Receiving data sent by the local client host, where the destination address of the data indicates that the receiver of the data is a peer client host;
  • the channel between the local relay device and the peer relay device is a fixed UDP channel. Therefore, when the data format received by the relay device is a non-UDP format, the data is format converted. , converted to UDP format data, transmitted between two relay devices.
  • another optional embodiment of the data interaction method provided by the embodiment of the present invention may further include:
  • the channel with the highest priority between the local relay device and the local client host is non-UDP Channel, converting the data in the UDP format to a format corresponding to the channel with the highest priority;
  • the format converted data is sent to the local client host.
  • the relay device receives the data sent by the peer relay device in UDP format, and first determines the channel with the highest priority between the local relay device and the local client, and determines the priority.
  • the highest channel is not UDP channel, the data is formatted.
  • the channel with the highest priority is TCP channel, the data is converted to TCP format. If it is HTTP channel, the data is converted to HTTP format, and then converted. The subsequent data is sent to the local client host through the corresponding channel.
  • FIG. 3 there are two networks, namely a first network and a second network, and the first client host in the first network and the second client host in the second network perform data interaction.
  • the first client host of the first network acquires a host data address of a first client host, a host address of a UDP channel, a host address of a data transmission protocol TCP channel, and a hypertext transfer protocol.
  • the host address of the HTTP channel is a host address of the HTTP channel.
  • the first client host of the first network simultaneously initiates a UDP address probe request and a TCP address probe request to the first relay device in the first network.
  • Step S110 is performed to initiate an HTTP address detection request to the relay device in the first network.
  • the first client host of the first network initiates an HTTP address probe request to the first relay device in the first network.
  • the first relay device of the first network returns, by using an HTTP channel, a mapping address allocated by an outermost NAT host on a network side where the first client host is located, and a first relay device that provides a relay service for the client host. Following the address.
  • the second client host in the second network acquires a user data packet protocol of the second client host, a host address of the UDP channel, a host address of the data transmission protocol TCP channel, and a host address of the hypertext transfer protocol HTTP channel.
  • the second client host of the second network simultaneously initiates a UDP address probe request and a TCP address probe request to the second relay device in the second network.
  • the second relay device in the second network returns the address of the NAT host on the network side of the second client host and the address of the second relay device in the second network where the second client host is located through the UDP channel.
  • S120 The first client host of the first network exchanges addresses with the second client host of the second network.
  • the first client host of the first network and the second client host of the second network respectively perform address detection by using address pairing, and determine a data transmission channel with the highest priority.
  • the first client host of the first network sends data to the second relay device of the first network by using an HTTP channel.
  • the first relay device of the first network converts data in an HTTP format into data in a UDP format.
  • the first relay device of the first network sends the converted data in the UDP format to the second relay device of the second network.
  • the second relay device of the second network sends the data in the UDP format to the second client host of the second network by using the UDP channel.
  • the client host of the second network sends data in UDP format to the second relay device of the second network through the UDP channel, and the second relay device of the second network sends the data in the UDP format to the first network.
  • the relay device sends, after receiving the data in the UDP format, the first relay device of the first network converts the data in the UDP format into the data in the HTTP format, and the first relay device in the first network uses the HTTP channel to send the HTTP format.
  • the data is sent to the first client host of the first network.
  • the client host in the data interaction scenario provided by the embodiment of the present invention performs address detection by simultaneously transmitting an address detection request of the UDP channel of the user data packet protocol and an address detection request of the TCP channel of the data transmission protocol, thereby improving NAT over the address detection.
  • the efficiency of the host which shortens the pull-up delay for data interaction between the two client hosts.
  • Figure 4 is a scenario in which a connected user makes a call with a telecommunications user, which is described as follows:
  • the Unicom client requests DNS resolution from the Domain Name System (DNS) relay device.
  • DNS Domain Name System
  • the DNS relay device returns the Unicom address IP1.
  • A115 After timeout or failure, initiate an HTTP address probe request to the HTTP relay device.
  • A120 Receives the outermost NAT host address and the relay device address through the HTTP channel.
  • the telecom client requests DNS resolution.
  • Telecom IP1 acts as the host address of the telecom client.
  • the telecommunication client simultaneously initiates a UDP address probe request and a TCP address probe request to the relay device of the telecommunication terminal.
  • the telecommunication relay device sends the NAT host address and the relay device address to the telecommunication client through the UDP channel.
  • the Unicom client and the telecom client exchange addresses and perform connectivity detection to determine the channel with the highest priority.
  • the Unicom relay device converts data in HTTP format to data in UDP format.
  • the Unicom relay device sends the converted data in UDP format to the telecommunication relay device.
  • A140 The telecommunication relay device sends the UDP format data to the telecommunication client through the UDP channel.
  • the client host in the data interaction scenario provided by the embodiment of the present invention performs address detection by simultaneously transmitting an address detection request of the UDP channel of the user data packet protocol and an address detection request of the TCP channel of the data transmission protocol, thereby improving NAT over the address detection. The efficiency of the host, which shortens the pull-up delay for data interaction between the two client hosts.
  • an application scenario example provided by an embodiment of the present invention is as follows:
  • Address collection process 1 Client host A obtains the host address hostA (192.168.1.10:1000), and first initiates an address probe request to the server 01 through the UDP channel and the TCP channel, which is used to collect the mapping address of NAT A; The outermost NAT A only allows HTTP packets to pass, so the address detection request of the UDP channel and the TCP channel fails. After the address probe request of the UDP channel and the TCP channel fails, the address detection request of the HTTP channel is initiated, and the outermost NAT A is allocated.
  • IP2: 218.17.55.173:1000 After the address probe request arrives at the server, the server allocates the transit resource (IP3: 192.168.3.10: 10001) and the server 01 feeds the NAT A address IP2 and IP3 to the client host A at the same time. Complete the address collection process.
  • the client host B obtains the host address hostB (192.168.2.20:2000), and initiates an address probe request to the server 02 through the UDP channel and the TCP channel, because the outermost NAT B does not limit the packet type. Therefore, the UDP channel and TCP channel address probe request traverses the outermost NAT B, reaches the server 02, the server 02 allocates the transit resource IP5: 192.168.3.15: 10001), and the server 02 feeds back the NAT B allocation address (IP4: 245.110. 88.155:2000) and relay address (IP5: 192.168.3.15:10001), client host B completes the address collection process.
  • IP4 245.110. 88.155:2000
  • relay address IP5: 192.168.3.15:10001
  • Client host A and client host B complete the address exchange by other means (such as xmpp signaling): For example, client host A sends hostA address, IP2 and IP3 to client host B, while waiting for client host B to send its hostB, IP4 and IP5.
  • client host A sends hostA address, IP2 and IP3 to client host B, while waiting for client host B to send its hostB, IP4 and IP5.
  • the client host A pairs the address of the local end after the exchange with the address sent by the client host B, such as (address pair 01: HOSTA->HOSTB, address pair 02:HOSTA->IP4, Address pair 03: IP3->IP5), the client host B pairing process is the same as the client host A, and then both parties initiate channel detection for each pair of addresses, and finally assume that the relay channels of server 01 and server 02 are opened.
  • client host A and client host B start data communication.
  • the process is as follows: Client host A sends data to server 01 through HTTP message format, and data reaches IP3 of server 01. Then, the HTTP packet is converted into a UDP packet, and the UDP packet is forwarded to the IP5 of the server 02. After receiving the UDP packet, the server 02 forwards the packet to the client host B. Otherwise, the process is the same.
  • the client host in the data interaction scenario provided by the embodiment of the present invention performs address detection by simultaneously transmitting the address detection request of the UDP channel of the user data packet protocol and the address detection request of the TCP channel of the data transmission protocol, thereby improving the traversal during address detection.
  • the efficiency of the NAT host which shortens the pull-up delay for data exchange between two client hosts.
  • an embodiment of a client host provided by an embodiment of the present invention includes:
  • a sending unit 301 configured to simultaneously send an address detection request of a user data packet protocol UDP channel and an address detection request of a data transmission protocol TCP channel, when the address detection of the UDP channel and the address detection of the TCP channel fail, Sending an address probe request for the Hypertext Transfer Protocol HTTP channel;
  • the receiving unit 302 is configured to receive, when the at least one channel is successfully detected, two types of addresses corresponding to each channel in the at least one channel, where the two types of addresses include a mapping address allocated by an outermost network address translation NAT host.
  • the address processing unit 303 is configured to perform address exchange and address matching between the address received by the receiving unit 302 and the peer client host. Through the detection, and select the channel with the highest priority among the detected valid channels to perform data interaction with the peer client.
  • the sending unit 301 simultaneously sends an address detection request of the UDP channel of the user data packet protocol and an address detection request of the TCP channel of the data transmission protocol, and the address detection of the UDP channel and the address detection of the TCP channel fail.
  • the layer network address translates the mapping address assigned by the NAT host and the relay address of the relay device providing the relay service; the address processing unit 303 exchanges the address received by the receiving unit 302 with the peer client host and performs address exchange
  • the address processing unit 304 performs channel connectivity detection according to the address paired by the address processing unit 303, and selects the channel with the highest priority among the detected valid channels to perform data interaction with the peer client host.
  • the client Compared with the single-step detection method in the prior art, the client provided by the embodiment of the present invention performs address detection by simultaneously transmitting an address detection request of a user data packet protocol UDP channel and an address detection request of a data transmission protocol TCP channel. Improves the efficiency of traversing the NAT host during address detection, thereby shortening the pull-up delay of data exchange between two client hosts.
  • the client host further includes: an address obtaining unit 305.
  • the address obtaining 305 is used to obtain the host address of the three types of channels of the local client host.
  • the host addresses of the three types of channels include the host address of the UDP channel, the host address of the TCP channel, and the host address of the HTTP channel.
  • the address processing unit 303 is configured to: use the host address of the three types of channels of the local client host and the collected two types of addresses, and the host addresses of the three types of channels of the peer client host, and The two types of addresses collected by the peer client host are exchanged and paired.
  • the address processing unit 303 is configured to: the host address of the UDP channel of the client host, the host address of the TCP channel, and the host address of the HTTP channel, and the host collected by the client host.
  • the mapping address of the outermost network address translation NAT host of each channel in at least one channel and the relay address of the local relay device, the host address of the UDP channel of the opposite client host, the host address of the TCP channel, and The host address of the HTTP channel, and the mapped address assigned by the outermost NAT host collected by the client host and the relay address of the peer relay device are exchanged and paired.
  • the channel processing unit 304 is configured to detect that the UDP channel of the UDP channel of the paired local client host is successfully connected, and select the UDP channel as the local client host to perform data interaction with the peer client host. The channel with the highest priority.
  • the address processing unit 303 is further configured to perform address exchange with the peer client host through the proxy server when performing address exchange.
  • an embodiment of a relay device includes:
  • the receiving unit 401 is configured to receive an address detection request sent by the local client host.
  • the local client host is the client host A
  • the server 02 is opposite to the server 02.
  • the client host is the client host B.
  • the client host A and the client host B are both local client hosts with respect to the server.
  • the address collection unit 402 is configured to collect two types of addresses corresponding to the >3 ⁇ 4 text type according to the message type of the address detection request received by the receiving unit 401, where the two types of addresses include an outermost network address translation NAT.
  • the sending unit 403 is configured to send, to the local client host, the two types of addresses corresponding to the text type collected by the address collecting unit 402, so that the local client host and the peer client
  • the host performs address exchange and pairing, so that the local client host performs channel connectivity detection according to the paired address, and selects the channel with the highest priority among the detected valid channels to perform data interaction with the peer client host.
  • the receiving unit 401 receives the address detection sent by the local client host.
  • the address collection unit 402 collects two types of addresses corresponding to the packet type according to the packet type of the address detection request received by the receiving unit 401, where the two types of addresses include the outermost network address translation NAT host.
  • the mapping address and the relay address of the local relay device; the sending unit 403 sends the two types of addresses corresponding to the packet type collected by the address collecting unit 402 to the local client host, Performing address exchange and pairing between the local client host and the peer client host, so that the local client host performs channel connectivity detection according to the paired address, and selects the highest effective channel among the detected valid channels.
  • the channel interacts with the peer client host.
  • the relay device provided by the embodiment of the present invention can enable the client host to collect the corresponding channel when one of the address detection request of the UDP channel and the address detection request of the TCP channel successfully traverse the NAT.
  • the two types of addresses enable the client host to improve the efficiency of traversing the NAT host during address detection, thereby shortening the pull-up delay of data exchange between the two client hosts.
  • the relay device provided by the embodiment of the present invention further includes: a first format conversion unit 404,
  • the receiving unit 401 is further configured to receive data sent by the local client host, where a destination address of the data indicates that the receiver of the data is a peer client host;
  • the first format converting unit 404 is configured to convert the data received by the receiving unit 401 into data in a UDP format; and send the data in the UDP format to the peer relay device.
  • the relay device provided by the embodiment of the present invention further includes: a determining unit 405 and a second format converting unit 406.
  • the receiving unit 401 is further configured to receive data in a UDP format that is sent by the peer relay device, where the determining unit 405 is configured to determine a priority between the local relay device and the local client host. Highest passage;
  • the second format conversion unit 406 is configured to: when the determining unit 405 determines that the channel with the highest priority between the local relay device and the local client host is a non-UDP channel, the UDP is The formatted data is converted to a format corresponding to the channel with the highest priority;
  • the sending unit 403 is configured to send the second format conversion list to the local client host Meta formatted data.
  • the embodiment of the present invention further provides a computer readable storage medium, where the program stores a program, and the program includes some or all of the steps of the client host side data interaction.
  • FIG. 11 is a schematic structural diagram of a client host 30 according to an embodiment of the present invention.
  • Client host 30 can include input device 310, output device 320, processor 330, and memory 340.
  • Memory 340 can include read only memory and random access memory and provides instructions and data to processor 330. A portion of memory 340 may also include non-volatile random access memory (NVRAM).
  • NVRAM non-volatile random access memory
  • Memory 340 stores the following elements, executable modules or data structures, or a subset thereof, or their extended set:
  • Operation instructions Includes various operation instructions for implementing various operations.
  • Operating System Includes a variety of system programs for implementing basic services and handling hardware-based tasks.
  • the processor 330 performs the following operations by calling an operation instruction stored in the memory 340 (the operation instruction can be stored in the operating system):
  • the address detection request of the user data packet protocol UDP channel and the address detection request of the data transmission protocol TCP channel are simultaneously transmitted by the output device 320, and when the address detection of the UDP channel and the address detection of the TCP channel fail, the device is output again.
  • 320 sending an address detection request of the Hypertext Transfer Protocol HTTP channel; when at least one channel is successfully detected, collecting two types of addresses corresponding to each channel in the at least one channel by the input device 310, where the two types of addresses include the The outermost network address of the channel translates the mapped address assigned by the NAT host and the relay address of the local relay device; performs address exchange with the peer client host and performs address matching; and performs channel according to the paired address
  • the connectivity is detected, and the channel with the highest priority among the detected valid channels is selected to perform data interaction with the peer client.
  • the client host sends the user data packet protocol UDP channel at the same time.
  • the address detection request and the data transmission protocol TCP channel address detection request are used for address detection to improve the efficiency of traversing the NAT host during address detection, thereby shortening the pull-up delay of data exchange between the two client hosts.
  • the processor 330 controls the operation of the client host 30, which may also be referred to as a CPU (Central Processing Unit).
  • Memory 340 can include read only memory and random access memory and provides instructions and data to processor 330. A portion of memory 340 may also include non-volatile random access memory (NVRAM).
  • NVRAM non-volatile random access memory
  • the components of the client host 30 are coupled together by a bus system 350.
  • the bus system 350 may include a power bus, a control bus, and a status signal bus in addition to the data bus. However, for clarity of description, various buses are labeled as bus system 350 in the figure.
  • Processor 330 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method may be completed by an integrated logic circuit of hardware in the processor 330 or an instruction in the form of software.
  • the processor 330 described above may be a general purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware. Component.
  • DSP digital signal processor
  • ASIC application specific integrated circuit
  • FPGA off-the-shelf programmable gate array
  • the methods, steps, and logic blocks disclosed in the embodiments of the present invention may be implemented or carried out.
  • the general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
  • the steps of the method disclosed in the embodiments of the present invention may be directly implemented as a hardware decoding processor, or may be performed by a combination of hardware and software modules in a decoding processor.
  • the software modules can be located in a conventional storage medium such as random access memory, flash memory, read only memory, programmable read only memory or electrically erasable programmable memory, registers, and the like.
  • the storage medium is located in the memory 340, and the processor 330 reads the information in the memory 340 and combines the hardware to perform the steps of the above method.
  • the processor 330 can also obtain the host address of the three types of channels of the local client host, where the host addresses of the three types of channels include a host address of the UDP channel, a host address of the TCP channel, and a host address of the HTTP channel; The host address of the three types of channels of the local client host and the collected two types of addresses are collected with the host address of the three types of channels of the peer client host and the peer client host. The two types of addresses are exchanged and paired.
  • the processor 330 may further include a host address of the UDP channel of the client host, a host address of the TCP channel, and a host address of the HTTP channel, and each of the at least one channel collected by the client host.
  • the outermost network address of the channel translates the mapped address assigned by the NAT host and the relay address of the local relay device, the host address of the UDP channel of the other client host, the host address of the TCP channel, and the host address of the HTTP channel. And the mapping address allocated by the outermost NAT host collected by the client host and the relay address of the peer relay device are exchanged and paired.
  • the processor 330 specifically detects that the UDP channel of the UDP channel of the paired local client host is successfully connected, and selects the UDP channel as the local client host and the peer client host perform data interaction. The channel with the highest priority.
  • FIG. 12 is a schematic structural diagram of a relay device 40 according to an embodiment of the present invention.
  • the relay device 40 can include an input device 410, an output device 420, a processor 430, and a memory 440.
  • Memory 440 can include read only memory and random access memory and provides instructions and data to processor 430. A portion of memory 440 may also include non-volatile random access memory (NVRAM).
  • NVRAM non-volatile random access memory
  • Memory 440 stores the following elements, executable modules or data structures, or a subset thereof, or their extended set:
  • Operation instructions Includes various operation instructions for implementing various operations.
  • Operating System Includes a variety of system programs for implementing basic services and handling hardware-based tasks.
  • the processor 430 performs the following operations by calling an operation instruction stored in the memory 440 (the operation instruction can be stored in the operating system):
  • the network address translation NAT host allocates the mapped address and the local relay device. Sending the two types of addresses corresponding to the type of the message to the local client host through the output device 420, so that the local client host and the peer client host are The address exchange is performed and paired, so that the local client host performs channel connectivity detection according to the paired address, and selects the channel with the highest priority among the detected valid channels to perform data interaction with the peer client host.
  • the relay device provided by the embodiment of the present invention can enable the client host to collect two types of addresses of the corresponding channel when the client host successfully traverses the NAT in the address detection request of the UDP channel and the address detection request of the TCP channel, so that the client The host improves the efficiency of traversing the NAT host during address detection, thereby shortening the pull-up delay of data exchange between the two client hosts.
  • the processor 430 controls the operation of the relay device 40, which may also be referred to as a CPU (Central Processing Unit).
  • Memory 440 can include read only memory and random access memory and provides instructions and data to processor 430. A portion of memory 440 may also include non-volatile random access memory (NVRAM).
  • NVRAM non-volatile random access memory
  • the components of the client host 30 are coupled together by a bus system 450.
  • the bus system 450 may include a power bus, a control bus, and a status signal bus in addition to the data bus. However, for clarity of description, various buses are labeled as bus system 450 in the figure.
  • Processor 430 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the foregoing method may be completed by an integrated logic circuit of hardware in the processor 430 or an instruction in a form of software.
  • the processor 430 described above may be a general purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware. Component.
  • DSP digital signal processor
  • ASIC application specific integrated circuit
  • FPGA off-the-shelf programmable gate array
  • the methods, steps, and logical block diagrams disclosed in the embodiments of the present invention may be implemented or executed.
  • the general purpose processor may be a microprocessor or the processor or any conventional processor or the like.
  • the steps of the method disclosed in the embodiments of the present invention may be directly implemented by the hardware decoding processor, or may be performed by a combination of hardware and software modules in the decoding processor.
  • the software module can be located in a conventional storage medium such as random access memory, flash memory, read only memory, programmable read only memory or electrically erasable programmable memory, registers, and the like.
  • the storage medium is located in the memory 440, and the processor 430 reads the information in the memory 440. The steps of the above method are completed in combination with the hardware.
  • the input device 410 receives the data sent by the local client host, where the destination address of the data indicates that the receiver of the data is the peer client host; the processor 430 converts the data into The UDP format data is sent by the output device 420 to the peer relay device through the UDP channel between the local relay device and the peer relay device.
  • the input device 410 receives the data in the UDP format sent by the peer relay device; the processor 430 determines the channel with the highest priority between the local relay device and the local client host; When the channel with the highest priority between the local relay device and the local client host is a non-UDP channel, the data in the UDP format is converted into a format corresponding to the channel with the highest priority; 420: Send the format converted data to the local client host.
  • an embodiment of the data interaction system provided by the embodiment of the present invention includes: a first client host 30A, a second client host 30B, a first NAT host 50A, a second NAT host 50B, and a first relay device. 40 A and second relay device 40B;
  • the first client host 30A, the first NAT host 50A, and the first relay device 40A belong to the first network;
  • the second client host 30B, the second NAT host 50B, and the second relay device 40B belong to the second network;
  • the first NAT host 50A is the outermost NAT host in the first network.
  • the first NAT host 50A allocates a mapping for the first client host 30A. Address
  • the second NAT host 50B is the outermost NAT host in the second network.
  • the second client host 30B is configured to map the second client host 30B. Address
  • the first client host 30A is configured to simultaneously send an address detection request of a user data packet protocol UDP channel and an address detection request of a data transmission protocol TCP channel, when the address of the UDP channel is detected and the TCP channel is When the address detection fails, the address detection request of the Hypertext Transfer Protocol HTTP channel is sent; when the at least one channel is successfully detected, two types of addresses corresponding to each channel in the at least one channel are collected, and the two types of addresses include The network address of the outermost layer of each channel translates the mapping address allocated by the NAT host and the relay address of the local relay device;
  • the second client host 30B is configured to simultaneously send an address detection request of a user data packet protocol UDP channel and an address detection request of a data transmission protocol TCP channel, when the address detection of the UDP channel and the address detection of the TCP channel When both fail, the address detection request of the Hypertext Transfer Protocol HTTP channel is sent; when the at least one channel is successfully detected, two types of addresses corresponding to each channel in the at least one channel are collected, and the two
  • the first client host 30A and the second client host 30B perform address exchange and address pairing;
  • the first client host 30A and the second client host 30B respectively perform channel connectivity detection according to the paired address, and select the channel with the highest priority among the detected valid channels to perform data interaction with the peer client host. .
  • the client host in the data interaction system provided by the embodiment of the present invention performs address detection by simultaneously transmitting an address detection request of a user data packet protocol UDP channel and an address detection request of a data transmission protocol TCP channel, thereby improving NAT through address detection.
  • the efficiency of the host which shortens the pull-up delay for data interaction between the two client hosts.
  • an embodiment of the data interaction system provided by the embodiment of the present invention includes: a first client host 30A, a second client host 30B, a NAT host 50, and a relay device 40, where the first client The host 30A and the second client host 30B belong to the same network;
  • the NAT host 50 is the outermost NAT host of the network where the first client host 30A and the second client host 30B are located, and receives the first client host 30A and the second client host. Assigning a mapping address to at least one of the first client host and the second client host when the address detection request is sent by at least one of the 30Bs;
  • the first client host 30A is configured to simultaneously send an address detection request of a user data packet protocol UDP channel and an address detection request of a data transmission protocol TCP channel, when the address detection of the UDP channel and the address detection of the TCP channel When both fail, the address detection request of the Hypertext Transfer Protocol HTTP channel is sent; when the at least one channel is successfully detected, two types of addresses corresponding to each channel in the at least one channel are collected, and the two types of addresses include the foregoing The outermost network address of the channel is translated by the mapping address assigned by the NAT host and the relay address of the local relay device;
  • the second client host 30B is configured to simultaneously send an address detection request of a user data packet protocol UDP channel and an address detection request of a data transmission protocol TCP channel, when the address detection of the UDP channel and the address detection of the TCP channel When both fail, the address detection request of the Hypertext Transfer Protocol HTTP channel is sent; when the at least one channel is successfully detected, two types of addresses corresponding to each channel in the at least one channel are collected, and
  • the first client host 30A and the second client host 30B perform address exchange and address pairing;
  • the first client host 30A and the second client host 30B respectively perform channel connectivity detection according to the paired address, and select the channel with the highest priority among the detected valid channels to perform data interaction with the peer client host. .
  • the client host in the data interaction system performs address detection by simultaneously transmitting an address detection request of a user data packet protocol UDP channel and an address detection request of a data transmission protocol TCP channel, thereby improving NAT through address detection.
  • the efficiency of the host which shortens the pull-up delay for data interaction between the two client hosts.
  • a person of ordinary skill in the art may understand that all or part of the steps of the foregoing embodiments may be implemented by a program to instruct related hardware (for example, a processor), and the program may be stored in a computer readable storage medium.
  • the storage medium may include: a ROM, a RAM, a magnetic disk or an optical disk, and the like.

Landscapes

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

Abstract

本发明公开了一种数据交互的方法,包括:同时发送UDP通道的地址探测请求和TCP通道的地址探测请求,当所述UDP通道的地址探测和所述TCP通道的地址探测均失败时,再发送HTTP通道的地址探测请求;当至少一个通道探测成功时,收集所述至少一个通道中每个通道对应的两类地址,所述两类地址包括所述每个通道的最外层的网络地址转换NAT主机所分配的映射地址和本端中继设备的中继地址;与对端客户端主机进行地址交换并进行地址配对;按照配对的地址进行通道连通性检测,并选择检测出的有效通道中优先级最高的通道与对端客户端主机进行数据交互。提高了地址探测时穿越NAT主机的效率。

Description

一种数据交互的方法、 装置及系统 技术领域
本发明涉及通信技术领域, 具体涉及一种数据交互的方法、 装置及系统。 背景技术
采用网络地址转换 ( Network Address Translation, NAT )接入互联网已经 是公司, 高校或者政府机关的主要上网方式。 通过在局域网出口处设置 NAT 主机, 一方面可以节省网络互连协议 ( Internet Protocol, IP )地址资源, 另一 方面可以保证局域网内部的安全并控制内部人员的访问权限。 但是, NAT主 机的存在同时也成了普通网络通信的障碍, 在通信时必须具备穿越 NAT主机 的能力, 才能实现端到端的数据传输。
目前, 已经有不少方案用于解决穿越 NAT主机的问题, 应用比较广泛的 有针对 NAT主机的会话穿越功能( Session Traversal Utilities for NAT , STUN ), 基于 Relay的 NAT主机穿透功能( Traversal Using Relays around NAT , TURN ) 和交互式连接建立( Interactive Connectivity Establishment , ICE )等。 这些方 法都是针对地址映射以及 NAT 主机对外来数据包的过滤规则提出的解决方 案。 而当 NAT主机对外出的通讯端口或者协议进行限制时, 上述方法都将无 能为力。
由于 NAT—般都会容许超文本传输协议(Hypertext transfer protocol, HTTP )通信, 因此, 现有技术中提出了一种 HTTP Tunnel技术。
HTTP Tunnel技术提出将用户通信数据包按照 HTTP的格式进行封装,模 拟 HTTP的通讯行为,将数据包发送给外网中继设备, 由中继设备将数据包还 原后再转发到目的地址。
HTTP Tunnel技术的网络环境探测, 筒述如下:
客户端以用户数据报协议(User Data Protocol, UDP )向公网的中继设备 发送探测请求包,如果成功收到响应,则说明该 NAT主机容许该端口上的 UDP 通信, 终止探测, 否则为禁止继续下一步。 客户端以传输控制协议( Transmission Control Protocol , TCP ) 向公网的 中继设备发送探测请求包, 如果成功收到响应, 则说明该 NAT主机容许该端 口上的 TCP通信, 终止探测, 否则为禁止继续下一步。
如果 UDP和 TCP均失败, 只有 80端口或者 HTTP包通讯被容许, 则 启动 HTTP Tunnel模块,在客户端和中继设备之间构建 HTTP通道实现无阻碍 的数据通讯, 最后如果探测都失败则整个穿越 NAT主机过程以失败告终。
本发明的发明人发现, HTTP Tunnel技术采用单步探测方式, 下一步探测 开始均需要等待上一步探测结果, 这样导致如果启用 HTTP模块时耗时过长, 导致 NAT主机穿越的速度很慢。 发明内容
本发明实施例提供一种数据交互的方法, 可以提高地址探测时穿越 NAT 主机的效率,从而缩短了两个客户端主机进行数据交互的拉起时延。本发明实 施例还提供了相应的设备及系统。
本发明第一方面提供一种数据交互的方法, 包括:
同时发送用户数据包协议 UDP通道的地址探测请求和数据传输协议 TCP 通道的地址探测请求, 当所述 UDP通道的地址探测和所述 TCP通道的地址探测 均失败时, 再发送超文本传输协议 HTTP通道的地址探测请求;
当至少一个通道探测成功时 ,收集所述至少一个通道中每个通道对应的两 类地址,所述两类地址包括所述每个通道的最外层的网络地址转换 NAT主机所 分配的映射地址和本端中继设备的中继地址;
与对端客户端主机进行地址交换并进行地址配对;
按照配对的地址进行通道连通性检测,并选择检测出的有效通道中优先级 最高的通道与对端客户端主机进行数据交互。
结合第一方面,在第一种可能的实现方式中,在所述与对端客户端主机进 行地址交换并进行地址配对的步骤之前, 所述方法还包括:
获取本端客户端主机的三类通道的主机地址,所述三类通道的主机地址包 括 UDP通道的主机地址、 TCP通道的主机地址和 HTTP通道的主机地址;
对应的, 所述与对端客户端主机进行地址并进行地址配对, 包括: 将所述本端客户端主机的三类通道的主机地址以及收集到的所述两类地 址,与所述对端客户端主机的三类通道的主机地址以及所述对端客户端主机收 集到的所述两类地址进行交换并配对。
结合第一方面第一种可能的实现方式,在第二种可能的实现方式中, 所述 将所述本端客户端主机的三类通道的主机地址以及收集到的所述两类地址,与 所述对端客户端主机的三类通道的主机地址以及所述对端客户端主机收集到 的所述两类地址进行交换并配对, 包括:
将所述本客户端主机的 UDP通道的主机地址、 TCP通道的主机地址和 HTTP通道的主机地址, 以及本客户端主机收集到的所述至少一个通道中每个 通道的最外层网络地址转换 NAT主机分配的映射地址和本端中继设备的中继 地址,与对方客户端主机的 UDP通道的主机地址、 TCP通道的主机地址和 HTTP 通道的主机地址,以及对方客户端主机收集到的最外层 NAT主机分配的映射地 址和对端中继设备的中继地址进行交换并配对。
结合第一方面第二种可能的实现方式,在第三种可能的实现方式中, 所述 按照配对的地址进行通道连通性检测,并选择检测出的有效通道中优先级最高 的通道与对端客户端主机进行数据交互, 包括:
检测配对的本端客户端主机的 UDP通道的主机地址与对端客户端主机的 UDP通道的主机地址之间的 UDP通道的连通性;
当所述 UDP通道连接成功时,选择所述 UDP通道作为本端客户端主机与对 端客户端主机进行数据交互时优先级最高的通道。
结合第一方面、 第一方面第一种至第三种可能的实现方式中的任意一种, 在第四种可能的实现方式中, 所述方法还包括:
在进行地址交换时, 与对端客户端主机通过代理服务器进行地址交换。 本发明第二方面提供一种数据交互的方法, 包括:
接收本端客户端主机发送来的地址探测请求;
根据所述地址探测请求的报文类型, 收集对应于所述报文类型的两类地 址,所述两类地址包括最外层网络地址转换 NAT主机所分配的映射地址和本端 中继设备的中继地址; 向所述本端客户端主机发送所述收集到的对应所述^艮文类型的所述两类 地址, 以使所述本端客户端主机与对端客户端主机进行地址交换并配对,从而 使所述本端客户端主机按照配对的地址进行通道连通性检测 ,并选择检测出的 有效通道中优先级最高的通道与对端客户端主机进行数据交互。
结合第二方面, 在第一种可能的实现方式中, 所述方法还包括: 接收所述本端客户端主机发来的数据,所述数据的目的端地址表示所述数 据的接收方为对端客户端主机;
将所述数据转换为 UDP格式的数据; 发送所述 UDP格式的数据。
结合第二方面, 在第二种可能的实现方式中, 所述方法还包括: 接收对端中继设备发送来的 UDP格式的数据;
确定本端中继设备与所述本端客户端主机之间的优先级最高的通道; 当所述本端中继设备与所述本端客户端主机之间的优先级最高的通道为 非 UDP通道时,将所述 UDP格式的数据转换为对应于所述优先级最高的通道的 格式;
向所述本端客户端主机发送格式转换后的数据。
本发明第三方面提供一种客户端主机, 包括:
发送单元,用于同时发送用户数据包协议 UDP通道的地址探测请求和数据 传输协议 TCP通道的地址探测请求, 当所述 UDP通道的地址探测和所述 TCP通 道的地址探测均失败时, 再发送超文本传输协议 HTTP通道的地址探测请求; 接收单元, 用于当至少一个通道探测成功时, 收集所述至少一个通道中每 个通道对应的两类地址,所述两类地址包括最外层网络地址转换 NAT主机所分 配的映射地址和本端中继设备的中继地址;
地址处理单元,用于将所述接收单元接收到的地址与对端客户端主机进行 地址交换并进行地址配对; 测,并选择检测出的有效通道中优先级最高的通道与对端客户端主机进行数据 交互。
结合第三方面, 在第一种可能的实现方式中, 所述客户端主机还包括: 地 址获取单元,
所述地址获取单元, 用于获取本端客户端主机的三类通道的主机地址, 所 述三类通道的主机地址包括 UDP通道的主机地址、 TCP通道的主机地址和 HTTP通道的主机地址;
所述地址处理单元,用于将所述本端客户端主机的三类通道的主机地址以 及收集到的所述两类地址,与所述对端客户端主机的三类通道的主机地址以及 所述对端客户端主机收集到的所述两类地址进行交换并配对。
结合第三方面第一种可能的实现方式, 在第二种可能的实现方式中, 所述地址处理单元, 用于将所述本客户端主机的 UDP通道的主机地址、 TCP通道的主机地址和 HTTP通道的主机地址, 以及本客户端主机收集到的所 述至少一个通道中每个通道的最外层网络地址转换 NAT主机分配的映射地址 和本端中继设备的中继地址, 与对方客户端主机的 UDP通道的主机地址、 TCP 通道的主机地址和 HTTP通道的主机地址, 以及对方客户端主机收集到的最外 层 NAT主机分配的映射地址和对端中继设备的中继地址进行交换并配对。
结合第三方面第二种可能的实现方式, 在第三种可能的实现方式中, 所述通道处理单元,用于检测配对的本端客户端主机的 UDP通道的主机地
UDP通道连接成功时,选择所述 UDP通道作为本端客户端主机与对端客户端主 机进行数据交互时优先级最高的通道。
结合第三方面、 第三方面第一种至第三种可能的实现方式种的任意一种, 在第四种可能的实现方式中,
所述地址处理单元,还用于在进行地址交换时, 与对端客户端主机通过代 理服务器进行地址交换。
本发明第四方面提供一种中继设备, 包括:
接收单元, 用于接收本端客户端主机发送来的地址探测请求;
地址收集单元, 用于根据所述接收单元接收的地址探测请求的报文类型, 收集对应于所述报文类型的两类地址,所述两类地址包括最外层网络地址转换
NAT主机所分配的映射地址和本端中继设备的中继地址;
发送单元,用于向所述本端客户端主机发送所述地址收集单元收集到的对 应所述 文类型的所述两类地址,以使所述本端客户端主机与对端客户端主机 进行地址交换并配对,从而使所述本端客户端主机按照配对的地址进行通道连 通性检测,并选择检测出的有效通道中优先级最高的通道与对端客户端主机进 行数据交互。
结合第四方面, 在第一种可能的实现方式中, 所述中继设备还包括: 第一 格式转换单元,
所述接收单元,还用于接收所述本端客户端主机发来的数据, 所述数据的 目的端地址表示所述数据的接收方为对端客户端主机;
所述第一格式转换单元, 用于将所述接收单元接收到的所述数据转换为 UDP格式的数据; 向所述对端中继设备发送所述 UDP格式的数据。
结合第四方面, 在第二种可能的实现方式中, 所述中继设备还包括: 确定 单元和第二格式转换单元,
所述接收单元, 还用于接收对端中继设备发送来的 UDP格式的数据; 所述确定单元,用于确定本端中继设备与所述本端客户端主机之间的优先 级最高的通道; 本端客户端主机之间的优先级最高的通道为非 UDP通道时,将所述 UDP格式的 数据转换为对应于所述优先级最高的通道的格式;
所述发送单元,用于向所述本端客户端主机发送所述第二格式转换单元格 式转换后的数据。
本发明第五方面提供一种数据交互系统, 包括: 第一客户端主机、 第二客 户端主机、 第一网络地址转换 NAT主机、 第二 NAT主机、 第一中继设备、 第二 中继设备; 所述第一客户端主机、所述第一 NAT主机和所述第一中继设备属于第一网 络;
所述第二客户端主机、所述第二 NAT主机和所述第二中继设备属于第二网 络;
所述第一 NAT主机为所述第一网络中最外层的 NAT主机,在接收到所述第 一客户端主机发送的地址探测请求时, 为所述第一客户端主机分配映射地址; 所述第二 NAT主机为所述第二网络中最外层的 NAT主机,在接收到所述第 二客户端主机发送的地址探测请求时, 为所述第二客户端主机分配映射地址; 所述第一客户端主机和所述第二客户端主机为上述技术方案所述的客户 端主机;
所述第一中继设备和所述第二中继设备为上述技术方案所述的中继设备。 本发明第六方面提供一种数据交互系统, 包括: 第一客户端主机、 第二客 户端主机、 网络地址转换 NAT主机和中继设备, 所述第一客户端主机和所述第 二客户端主机属于同一个网络;
所述 NAT主机为所述第一客户端主机和第二客户端主机所在网络的最外 层的 NAT主机,在接收到所述第一客户端主机和所述第二客户端主机中的至少 一个发送的地址探测请求时,为所述第一客户端主机和所述第二客户端主机中 的至少一个分配映射地址;
所述第一客户端主机和所述第二客户端主机为上述技术方案所述的客户 端主机;
所述中继设备为上述技术方案所述的中继设备。
本发明实施例采用同时发送用户数据包协议 UDP通道的地址探测请求和 数据传输协议 TCP通道的地址探测请求, 当所述 UDP通道的地址探测和所述 TCP通道的地址探测均失败时, 再发送超文本传输协议 HTTP通道的地址探测 请求; 当至少一个通道探测成功时, 收集所述至少一个通道中每个通道对应的 两类地址,所述两类地址包括所述每个通道的最外层的网络地址转换 NAT主机 所分配的映射地址和本端中继设备的中继地址;与对端客户端主机进行地址交 换并进行地址配对; 按照配对的地址进行通道连通性检测, 并选择检测出的有 效通道中优先级最高的通道与对端客户端主机进行数据交互。从而与现有技术 中单步探测方式相比,本发明实施例通过同时发送用户数据包协议 UDP通道的 地址探测请求和数据传输协议 TCP通道的地址探测请求的方式来进行地址探 测, 提高了地址探测时穿越 NAT主机的效率, 从而缩短了两个客户端主机进行 数据交互的拉起时延。 附图说明
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所 需要使用的附图作筒单地介绍,显而易见地, 下面描述中的附图仅仅是本发明 的一些实施例, 对于本领域技术人员来讲, 在不付出创造性劳动的前提下, 还 可以根据这些附图获得其他的附图。
图 1是本发明实施例的一种数据交互的方法的流程示意图;
图 2是本发明实施例的另一种数据交互的方法的流程示意图;
图 3是本发明实施例中的一种应用场景下的数据交互的方法的时序示意 图;
图 4是本发明实施例中的另一种应用场景下的数据交互的方法的时序示意 图;
图 5 A是本发明实施例中的一种应用场景的组网示意图;
图 5B是本发明实施例中的另一种应用场景的组网示意图;
图 6是本发明实施例中的一种客户端主机的结构示意图;
图 7是本发明实施例中的另一种客户端主机的结构示意图;
图 8是本发明实施例中的一种中继设备的结构示意图;
图 9是本发明实施例中的另一种中继设备的结构示意图;
图 10是本发明实施例中的再一种中继设备的结构示意图;
图 11是本发明实施例中的另一种客户端主机的结构示意图;
图 12是本发明实施例中的再一种中继设备的结构示意图;
图 13是本发明实施例中的一种数据交互系统的结构示意图;
图 14是本发明实施例中的另一种数据交互系统的结构示意图。 具体实施方式 本发明实施例提供一种数据交互的方法, 可以提高地址探测时穿越 NAT 主机的效率,从而缩短了两个客户端主机进行数据交互的拉起时延。本发明实 施例还提供了相应的设备及系统。 以下分别进行详细说明。
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清 楚、 完整地描述, 显然, 所描述的实施例仅仅是本发明一部分实施例, 而不是 全部的实施例。基于本发明中的实施例, 本领域技术人员在没有作出创造性劳 动前提下所获得的所有其他实施例, 都属于本发明保护的范围。
参阅图 1 , 本发明实施例提供的数据交互的方法的一实施例, 该数据交互 的方法的执行主体可以是客户端主机,这里的客户端主机例如可以是个人计算 机 ( personalcomputer, PC )、 手机、 私人数字助理 ( PersonalDigitalAssistant, PDA )等设备, 本发明实施例方法可以包括:
101、 同时发送用户数据包协议 UDP通道的地址探测请求和数据传输协议 TCP通道的地址探测请求, 当所述 UDP通道的地址探测和所述 TCP通道的地址 探测均失败时, 再发送超文本传输协议 HTTP通道的地址探测请求。
客户端可以建立三种类型的通道,分别为用户数据包协议( User Datagram Protocol, UDP )通道, 数据传输协议( Transmission Control Protocol , TCP ) 通道和超文本传输协议(Hypertext transfer protocol, HTTP )通道, 客户端主 机创建这三种通道的主机地址。
因 UDP通道的优先级最高, TCP通道的优先级次高, HTTP通道的优先级 最低, 所以, 在 UDP通道或 TCP通道的任一可用时, 不需要使用 HTTP通道, 只有在 UDP通道和 TCP通道都不可用时, 才使用 HTTP通道。
102、 当至少一个通道探测成功时, 收集所述至少一个通道中每个通道对 应的两类地址,所述两类地址包括所述每个通道的最外层的网络地址转换 NAT 主机所分配的映射地址和所述本端中继设备的中继地址。
客户端主机所在的网络可以有多层 NAT主机, 地址探测的过程为: 客户端 主机发送地址探测请求, 该地址探测请求逐一穿越网络中的 NAT主机, 只有穿 越出最外层的 NAT主机时, 才认为是穿越 NAT主机成功, 实际上探测请求每穿 越一层的 NAT主机都会在探测请求中携带上一个该 NAT主机分配的映射地址, 但当穿越下一层的 NAT主机时,这个 NAT主机分配的映射地址会替换掉前一层 NAT主机分配的映射地址, 所以, 当探测请求到达中继设备时, 中继设备只会 收集到最外层的 NAT主机所分配的映射地址。
当 UDP探测请求和 TCP探测请求中有一个穿越 NAT成功, 就不会发送 HTTP探测, 所以, 有会有四种情况存在, 一种为 UDP探测请求穿越 NAT成功, 收集到 UDP通道的最外层网络地址转换 NAT主机所分配的映射地址和本端中 继设备的中继地址; 一种为 TCP探测请求穿越 NAT成功, 收集到 TCP通道的最 外层网络地址转换 NAT主机所分配的映射地址和本端中继设备的中继地址;一 种为 UDP探测请求和 TCP探测请求同时穿越 NAT成功, 收集到 UDP通道和 TCP 通道的最外层 NAT主机所分配的映射地址和本端中继设备的中继地址;一种为 UDP探测请求和 TCP探测请求同时穿越失败, HTTP探测请求穿越 NAT成功, 收集到 HTTP通道的 NAT主机所分配的映射地址和提供中继服务的本端中继设 备的中继地址。
103、 与对端客户端主机进行地址交换并进行地址配对。
104、 按照配对的地址进行通道连通性检测, 并选择检测出的有效通道中 优先级最高的通道与对端客户端主机进行数据交互。
连通性检测后可以有多个通道可用, 但选择优先级最高的通道使用。
与现有技术中单步探测方式相比,本发明实施例通过同时发送用户数据包 协议 UDP通道的地址探测请求和数据传输协议 TCP通道的地址探测请求的方 式来进行地址探测, 提高地址探测时穿越 NAT主机的效率, 从而缩短了两个客 户端主机进行数据交互的拉起时延。
本发明实施例中, 拉起时延可以为数据交互的启动延时, 如: 原来两个客 户端主机在进行数据交互前, 需要 200秒才能启动交互, 那么这时的拉起时延 为 200秒, 本发明实施例中, 数据交互的启动时延可以为 100秒, 那么就缩短了 数据交互的拉起时延。
可选地, 在上述图 1对应的实施例的基础上, 本发明实施例提供的数据交 互的方法的另一实施例中,
在所述与对端客户端主机进行地址交换并进行地址配对的步骤之前,所述 方法还可以包括:
获取本端客户端主机的三类通道的主机地址,所述三类通道的主机地址包 括 UDP通道的主机地址、 TCP通道的主机地址和 HTTP通道的主机地址;
对应的, 所述与对端客户端主机进行地址并进行地址配对, 可以包括: 将所述本端客户端主机的三类通道的主机地址以及收集到的所述两类地 址,与所述对端客户端主机的三类通道的主机地址以及所述对端客户端主机收 集到的所述两类地址进行交换并配对。
本发明实施例中, 本发明实施例中, 在同一个网络中, 从客户端主机到中 继设备的 UDP通道、 TCP通道和 HTTP通道中, 每个通道都对应有三类地址, 分别为, 对于 UDP通道为客户端主机的 UDP通道的主机地址、 最外层 NAT主机 为 UDP通道所分配的映射地址和中继设备为 UDP通道所分配的中继设备地址, 同样, 对于 TCP通道为客户端主机的 TCP通道的主机地址、 最外层 NAT主机为 TCP通道所分配的映射地址和中继设备为 TCP通道所分配的中继设备地址, 对 于 HTTP通道为客户端主机的 HTTP通道的主机地址、 最外层 NAT主机为 HTTP 通道所分配的映射地址和中继设备为 HTTP通道所分配的中继设备地址。
在进行地址交换时,本端客户端主机与对端客户端主机要将 UDP通道的主 机地址、 TCP通道的主机地址和 HTTP通道的主机地址, 以及收集到的所述两 类地址进行交换。
本发明实施例中在只有 HTTP通道穿越成功时, 在地址交换时增加了 UDP 通道的主机地址和 TCP通道的主机地址, 从而增加了通道选择的多样性。
可选地, 在上述图 1对应的可选实施例的基础上, 本发明实施例提供的数 据交互的方法的一可选实施例中,所述将所述本端客户端主机的三类通道的主 机地址以及收集到的所述两类地址,与所述对端客户端主机的三类通道的主机 地址以及所述对端客户端主机收集到的所述两类地址进行交换并配对,可以包 括:
将所述本客户端主机的 UDP通道的主机地址、 TCP通道的主机地址和 HTTP通道的主机地址, 以及本客户端主机收集到的所述至少一个通道中每个 通道的最外层网络地址转换 NAT主机分配的映射地址和本端中继设备的中继 地址,与对方客户端主机的 UDP通道的主机地址、 TCP通道的主机地址和 HTTP 通道的主机地址,以及对方客户端主机收集到的最外层 NAT主机分配的映射地 址和对端中继设备的中继地址进行交换并配对。
本发明实施例中, 在地址交换时, 包含了 UDP通道的主机地址、 TCP通道 的主机地址和 HTTP通道的主机地址, 这样即时在 UDP探测请求和 TCP探测请 求穿越失败, HTTP探测请求穿越成功时, 还可以对本端客户端主机的 UDP通 道的主机地址与对端客户端主机的 UDP通道的主机地址进行交换并配对;对本 端客户端主机的 TCP通道的主机地址与对端客户端主机的 TCP通道的主机地 址进行交换并配对。
本发明实施例中, 因 UDP的通道和 TCP通道的优先级都高于 HTTP通道的 优先级, 所以,在当本端客户端主机的 UDP通道的主机地址与对端客户端主机 的 UDP通道的主机地址配对成功后,或者本端客户端主机的 TCP通道的主机地 址与对端客户端主机的 TCP通道的主机配对成功后, 可以选择 UDP通道或者 TCP通道进行数据交互, 从而提高了数据交互时传输通道的优先级。
可选地,在上述另一可选实施例的基础上, 本发明实施例提供的数据交互 的方法的另一可选实施例中, 所述按照配对的地址进行通道连通性检测, 并选 择检测出的有效通道中优先级最高的通道与对端客户端主机进行数据交互,可 以包括:
检测配对的本端客户端主机的 UDP通道的主机地址与对端客户端主机的 UDP通道的主机地址之间的 UDP通道的连通性;
当所述 UDP通道连接成功时,选择所述 UDP通道作为本端客户端主机与对 端客户端主机进行数据交互时优先级最高的通道。
本发明实施例中,因为 UDP通道的优先级最高、 TCP通道的优先级较 HTTP 通道的优先级高,所以要优先检测本端客户端主机的 UDP通道的主机地址与对 之间的 UDP通道连接成功时,这两个客户端主机就选择这个 UDP通道进行数据 交互。 不像 HTTP通道还需要中继设备进行中转。
本发明实施例中,在数据交互时,带有客户端主机的 UDP地址和 TCP地址, 这样, 即使 NAT不允许 UDP或者 TCP格式的报文通过, 在两个客户端主机位于 同一网络时, 也可以采用 UDP通道或者 TCP通道进行数据交互, 通常优先选择 UDP通道。
可选地,在上述图 1对应的实施例及图 1对应的可选实施例中任一实施例的 基础上, 本发明实施例提供的数据交互的方法的另一可选实施例中, 所述方法 还包括:
在进行地址交换时, 与对端客户端主机通过代理服务器进行地址交换。 本发明实施例中,在与对端客户端主机进行地址交换时, 可以直接通过代理服 务器, 如: 可扩展消息处理现场协议 ( The Extensible Messaging and Presence Protocol, Xmpp )信令协议服务器等进行地址交换, 实现方式可以是, 向信令 协议服务器发送 Xmpp信令, 或者通过 Xmpp信令的扩展属性进行地址交换。
参阅图 2, 本发明实施例提供的数据交互的方法的另一实施例, 该数据交 互的方法的执行主体可以是中继设备, 这里的中继设备例如可以是路由器、 交 换器、 集线器、 网络服务器等等。 本发明实施例方法可以包括:
201、 接收本端客户端主机发送来的地址探测请求。
202、 根据所述地址探测请求的报文类型, 收集对应于所述报文类型的两 类地址,所述两类地址包括最外层网络地址转换 NAT主机所分配的映射地址和 本端中继设备的中继地址。
203、 向所述本端客户端主机发送所述收集到的对应所述 文类型的所述 两类地址, 以使所述本端客户端主机与对端客户端主机进行地址交换并配对, 从而使所述本端客户端主机按照配对的地址进行通道连通性检测,并选择检测 出的有效通道中优先级最高的通道与对端客户端主机进行数据交互。
与现有技术相比,本发明实施例提供的数据交互的方法可以使客户端主机 在同时发送的 UDP通道的地址探测请求和 TCP通道的地址探测请求中的一个 成功穿越 NAT时, 收集对应通道的两类地址, 使客户端主机提高了地址探测时 穿越 NAT主机的效率, 从而缩短了两个客户端主机进行数据交互的拉起时延。
可选地, 在上述图 2对应的实施例的基础上, 本发明实施例提供的数据交 互的方法的一可选实施例还可以包括: 接收所述本端客户端主机发来的数据,所述数据的目的端地址表示所述数 据的接收方为对端客户端主机;
将所述数据转换为 UDP格式的数据; 发送所述 UDP格式的数据。
本发明实施例中,本端中继设备与对端中继设备之间的通道是固定的 UDP 通道, 所以, 当中继设备接收到的数据格式为非 UDP格式时, 就会将数据进行 格式转换, 转换为 UDP格式的数据, 在两个中继设备之间传输。
可选地, 在上述图 2对应的实施例的基础上, 本发明实施例提供的数据交 互的方法的另一可选实施例还可以包括:
接收对端中继设备发送来的 UDP格式的数据;
确定本端中继设备与所述本端客户端主机之间的优先级最高的通道; 当所述本端中继设备与所述本端客户端主机之间的优先级最高的通道为 非 UDP通道时,将所述 UDP格式的数据转换为对应于所述优先级最高的通道的 格式;
向所述本端客户端主机发送格式转换后的数据。
本发明实施例中,中继设备接收到对端中继设备发送来的数据为 UDP格式 的数据, 先确定与本端中继设备与本端客户端间优先级最高的通道, 当确定出 优先级最高的通道不是 UDP通道后,要对数据进行格式转换, 当优先级最高的 通道是 TCP通道, 那么将数据转换为 TCP格式, 如果是 HTTP通道, 那么将数 据转换为 HTTP格式, 然后将转换后的数据通过对应的通道发送给本端客户端 主机。
为了便于理解, 下面以几个应用场景为例,详细说明本发明实施例中数据 交互的过程:
参阅图 3, 有两个网络, 分别为第一网络和第二网络, 第一网络中的第一 客户端主机与第二网络中的第二客户端主机要进行数据交互。
S 100、第一网络的第一客户端主机获取第一客户端主机的用户数据包协议 UDP通道的主机地址、 数据传输协议 TCP通道的主机地址和超文本传输协议 HTTP通道的主机地址。
S105、第一网络的第一客户端主机向第一网络中的第一中继设备同时发起 UDP地址探测请求和 TCP地址探测请求。
在等待 39秒后, 还未收到响应, 认定 UDP地址探测请求和 TCP地址探测请 求失败, 执行步骤 S110, 向第一网络中的中继设备发起 HTTP地址探测请求。
S110、 第一网络的第一客户端主机向第一网络中的第一中继设备发起 HTTP地址探测请求。
S115、 第一网络的第一中继设备通过 HTTP通道返回第一客户端主机所在 网络侧的最外层 NAT主机分配的映射地址和为客户端主机提供中继服务的第 一中继设备的中继地址。
S200、第二网络中的第二客户端主机获取第二客户端主机的用户数据包协 议 UDP通道的主机地址、数据传输协议 TCP通道的主机地址和超文本传输协议 HTTP通道的主机地址。
S205、第二网络的第二客户端主机向第二网络中的第二中继设备同时发起 UDP地址探测请求和 TCP地址探测请求。
S210、第二网络中的第二中继设备通过 UDP通道返回的第二客户端主机所 在网络侧的 NAT主机的地址和第二客户端主机所在第二网络的第二中继设备 的地址。
S 120、第一网络的第一客户端主机与第二网络的第二客户端主机进行地址 交换。
S121、第一网络的第一客户端主机与第二网络的第二客户端主机分别通过 地址配对, 进行连通性检测, 确定优先级最高的数据传输通道。
S125、 第一网络的第一客户端主机通过 HTTP通道向第一网络的第二中继 设备发送数据。
S130、 第一网络的第一中继设备将 HTTP格式的数据转换为 UDP格式的数 据。
S135、第一网络的第一中继设备将转换后的 UDP格式的数据发送到第二网 络的第二中继设备。 S140、第二网络的第二中继设备通过 UDP通道向第二网络的第二客户端主 机发送 UDP格式的数据。
反过来,第二网络的客户端主机通过 UDP通道向第二网络的第二中继设备 发送 UDP格式的数据,第二网络的第二中继设备将 UDP格式的数据向第一网络 的第一中继设备发送, 第一网络的第一中继设备接收到 UDP格式的数据后,将 UDP格式的数据转换为 HTTP格式的数据,第一网络的第一中继设备通过 HTTP 通道, 将 HTTP格式的数据发送给第一网络的第一客户端主机。
本发明实施例提供的数据交互场景中的客户端主机通过同时发送用户数 据包协议 UDP通道的地址探测请求和数据传输协议 TCP通道的地址探测请求 的方式来进行地址探测, 提高地址探测时穿越 NAT主机的效率, 从而缩短了两 个客户端主机进行数据交互的拉起时延。
参阅图 4, 图 4为一个联通的用户与一个电信的用户打电话的场景, 具体描 述如下:
A100、 联通客户端向域名系统( Domain Name System, DNS)中继设备请 求 DNS解析。
A105、 DNS中继设备返回联通地址 IP1。
连通 IP1地址作为连通客户端的主机地址。 和 TCP地址探测请求。
A115、 超时或者失败后, 向 HTTP中继设备发起 HTTP地址探测请求。
A120、 通过 HTTP通道接收到最外层 NAT主机地址和中继设备地址。
A200、 电信客户端请求 DNS解析。
A205、 返回电信 IP1。
电信 IP1作为电信客户端的主机地址。
A210、 电信客户同时向电信端的中继设备同时发起 UDP地址探测请求和 TCP地址探测请求。
A215、 电信中继设备向电信客户端通过 UDP通道发送 NAT主机地址和中 继设备地址。 A121、 联通客户端与电信客户端进行地址交换并进行联通性检测, 确定 优先级最高的通道。
A130、 联通中继设备将 HTTP格式的数据转换为 UDP格式的数据。
A135、 联通中继设备将转换后的 UDP格式的数据发送给电信中继设备。 A140、 电信中继设备通过 UDP通道将 UDP格式的数据发送给电信客户端。 本发明实施例提供的数据交互场景中的客户端主机通过同时发送用户数 据包协议 UDP通道的地址探测请求和数据传输协议 TCP通道的地址探测请求 的方式来进行地址探测, 提高地址探测时穿越 NAT主机的效率, 从而缩短了两 个客户端主机进行数据交互的拉起时延。
参阅图 5A, 本发明实施例提供的应用场景实例:
( 1 ) 地址收集流程一: 客户端主机 A获取主机地址 hostA ( 192.168.1.10:1000 ),先同时通过 UDP通道和 TCP通道向服务器 01发起地址探 测请求, 用于收集 NAT A的映射地址; 由于最外层 NAT A只容许 HTTP报文通 过, 故 UDP通道和 TCP通道的地址探测请求失败; 等待 UDP通道和 TCP通道的 地址探测请求失败后发起 HTTP通道的地址探测请求, 最外层 NAT A分配映射 地址 ( IP2: 218.17.55.173:1000 ) , 地址探测请求到达服务器后, 服务器分配 中转资源 ( IP3: 192.168.3.10: 10001 ) 同时将服务器 01将 NAT A地址 IP2和 IP3 反馈给客户端主机 A , 完成地址收集流程。
( 2 ) 地址收集流程二: 客户端主机 B获取主机地址 hostB ( 192.168.2.20:2000 ), 同时通过 UDP通道和 TCP通道向服务器 02发起地址探测 请求, 由于最外层 NAT B不限制报文类型, 故 UDP通道和 TCP通道地址探测请 求穿越最外层 NAT B , 到达服务器 02 , 服务器 02分配中转资源 IP5: 192.168.3.15: 10001 ) , 月良务器 02反馈 NAT B分配地址(IP4: 245.110.88.155:2000)和中继地址 ( IP5:192.168.3.15:10001 ), 客户端主机 B完成 地址收集流程。
( 3 )地址交换: 客户端主机 A和客户端主机 B通过其他方式 (如 xmpp信令) 完成地址交换: 如客户端主机 A把 hostA地址, IP2和 IP3发送给客户端主机 B , 同时等待 客户端主机 B将它的 hostB、 IP4和 IP5发送过来。
( 4 )连通性检测: 客户端主机 A将交换后的本端的地址和客户端主机 B发 送来的地址进行配对,如(地址对 01: HOSTA->HOSTB,地址对 02:HOSTA->IP4, 地址对 03: IP3->IP5 ), 客户端主机 B配对过程与客户端主机 A相同, 然后双方 针对每对地址发起通道检测, 最后假设服务器 01和服务器 02的中继通道打通。
( 5 )数据通讯: 选择服务器中继通道后客户端主机 A和客户端主机 B开始 数据通讯, 过程如下: 客户端主机 A通过 HTTP报文格式将数据发送给服务器 01 , 数据到达服务器 01的 IP3后将 HTTP报文转换成 UDP报文, 再将 UDP报文转 发给服务器 02的 IP5,服务器 02收到 UDP报文后转发给客户端主机 B,反之过程 一样。
本发明实施例提供的数据交互场景中的客户端主机通过同时发送用户数 据包协议 UDP通道的地址探测请求和数据传输协议 TCP通道的地址探测请求 的方式来进行地址探测, 提高了地址探测时穿越 NAT主机的效率, 从而缩短了 两个客户端主机进行数据交互的拉起时延。
参阅图 5B, 在客户端主机 A与客户端主机 B在同一网络中时, 客户端主机 A可以与客户端主机 B选择 UDP通道, 直接通信。 参阅图 6, 本发明实施例提供的客户端主机的一实施例包括:
发送单元 301, 用于同时发送用户数据包协议 UDP通道的地址探测请求和 数据传输协议 TCP通道的地址探测请求, 当所述 UDP通道的地址探测和所述 TCP通道的地址探测均失败时, 再发送超文本传输协议 HTTP通道的地址探测 请求;
接收单元 302, 用于当至少一个通道探测成功时, 接收所述至少一个通道 中每个通道对应的两类地址,所述两类地址包括最外层网络地址转换 NAT主机 所分配的映射地址和提供中继服务的中继设备的中继地址;
地址处理单元 303,用于将所述接收单元 302接收到的地址与对端客户端主 机进行地址交换并进行地址配对; 通性检测,并选择检测出的有效通道中优先级最高的通道与对端客户端主机进 行数据交互。
本发明实施例中, 发送单元 301同时发送用户数据包协议 UDP通道的地址 探测请求和数据传输协议 TCP通道的地址探测请求, 当所述 UDP通道的地址探 测和所述 TCP通道的地址探测均失败时, 再发送超文本传输协议 HTTP通道的 地址探测请求; 接收单元 302当至少一个通道探测成功时, 接收所述至少一个 通道中每个通道对应的两类地址 ,所述两类地址包括最外层网络地址转换 NAT 主机所分配的映射地址和提供中继服务的中继设备的中继地址;地址处理单元 303将所述接收单元 302接收到的地址与对端客户端主机进行地址交换并进行 地址配对;通道处理单元 304按照所述地址处理单元 303配对的地址进行通道连 通性检测,并选择检测出的有效通道中优先级最高的通道与对端客户端主机进 行数据交互。 与现有技术中单步探测方式相比, 本发明实施例提供的客户端, 通过同时发送用户数据包协议 UDP通道的地址探测请求和数据传输协议 TCP 通道的地址探测请求的方式来进行地址探测,提高地址探测时穿越 NAT主机的 效率, 从而缩短了两个客户端主机进行数据交互的拉起时延。
可选地, 在上述图 6对应的实施例的基础上, 参阅图 7, 本发明实施例提供 的客户端主机的另一实施例中, 所述客户端主机还包括: 地址获取单元 305, 所述地址获取单 305, 用于获取本端客户端主机的三类通道的主机地址, 所述三类通道的主机地址包括 UDP通道的主机地址、 TCP通道的主机地址和 HTTP通道的主机地址;
所述地址处理单元 303, 用于将所述本端客户端主机的三类通道的主机地 址以及收集到的所述两类地址,与所述对端客户端主机的三类通道的主机地址 以及所述对端客户端主机收集到的所述两类地址进行交换并配对。
可选地, 在上述图 7对应的实施例的基础上, 本发明实施例提供的客户端 主机的另一实施例中,
所述地址处理单元 303,用于将所述本客户端主机的 UDP通道的主机地址、 TCP通道的主机地址和 HTTP通道的主机地址, 以及本客户端主机收集到的所 述至少一个通道中每个通道的最外层网络地址转换 NAT主机分配的映射地址 和本端中继设备的中继地址, 与对方客户端主机的 UDP通道的主机地址、 TCP 通道的主机地址和 HTTP通道的主机地址, 以及对方客户端主机收集到的最外 层 NAT主机分配的映射地址和对端中继设备的中继地址进行交换并配对。
可选地, 在上述图 7对应的可选实施例的基础上, 本发明实施例提供的客 户端主机的另一实施例中,
所述通道处理单元 304, 用于检测配对的本端客户端主机的 UDP通道的主 所述 UDP通道连接成功时,选择所述 UDP通道作为本端客户端主机与对端客户 端主机进行数据交互时优先级最高的通道。
可选地,在上述实施例的基础上, 本发明实施例提供的客户端主机的另一 实施例中,
所述地址处理单元 303, 还用于在进行地址交换时, 与对端客户端主机通 过代理服务器进行地址交换。
参阅图 8, 本发明实施例提供的中继设备的一实施例包括:
接收单元 401 , 用于接收本端客户端主机发送来的地址探测请求, 例如, 在图 5A中, 相对于服务器 01来说, 本端客户端主机为客户端主机 A, 相对于服 务器 02来说, 本客户端主机为客户端主机 B; 在图 5B中, 客户端主机 A和客户 端主机 B相对于服务器来说都是本端客户端主机。
地址收集单元 402,用于根据所述接收单元 401接收的地址探测请求的报文 类型, 收集对应于所述>¾文类型的两类地址, 所述两类地址包括最外层网络地 址转换 NAT主机所分配的映射地址和本端中继设备的中继地址;
发送单元 403,用于向所述本端客户端主机发送所述地址收集单元 402收集 到的对应所述 文类型的所述两类地址,以使所述本端客户端主机与对端客户 端主机进行地址交换并配对,从而使所述本端客户端主机按照配对的地址进行 通道连通性检测,并选择检测出的有效通道中优先级最高的通道与对端客户端 主机进行数据交互。
本发明实施例中, 接收单元 401接收本端客户端主机发送来的地址探测请 求; 地址收集单元 402根据所述接收单元 401接收的地址探测请求的报文类型, 收集对应于所述报文类型的两类地址,所述两类地址包括最外层网络地址转换 NAT主机所分配的映射地址和本端中继设备的中继地址; 发送单元 403向所述 本端客户端主机发送所述地址收集单元 402收集到的对应所述报文类型的所述 两类地址, 以使所述本端客户端主机与对端客户端主机进行地址交换并配对, 从而使所述本端客户端主机按照配对的地址进行通道连通性检测,并选择检测 出的有效通道中优先级最高的通道与对端客户端主机进行数据交互。与现有技 术相比, 本发明实施例提供的中继设备可以使客户端主机在同时发送的 UDP 通道的地址探测请求和 TCP通道的地址探测请求中的一个成功穿越 NAT时, 收 集对应通道的两类地址, 使客户端主机提高了地址探测时穿越 NAT主机的效 率, 从而缩短了两个客户端主机进行数据交互的拉起时延。
在上述图 8对应的实施例的基础上, 参与图 9, 本发明实施例提供的中继设 备还包括: 第一格式转换单元 404,
所述接收单元 401 , 还用于接收所述本端客户端主机发来的数据, 所述数 据的目的端地址表示所述数据的接收方为对端客户端主机;
所述第一格式转换单元 404,用于将所述接收单元 401接收到的所述数据转 换为 UDP格式的数据; 道, 向所述对端中继设备发送所述 UDP格式的数据。
在上述图 8对应的实施例的基础上, 参与图 10, 本发明实施例提供的中继 设备还包括: 确定单元 405和第二格式转换单元 406,
所述接收单元 401 , 还用于接收对端中继设备发送来的 UDP格式的数据; 所述确定单元 405 , 用于确定本端中继设备与所述本端客户端主机之间的 优先级最高的通道;
所述第二格式转换单元 406,用于当所述确定单元 405确定出本端中继设备 与所述本端客户端主机之间的优先级最高的通道为非 UDP通道时,将所述 UDP 格式的数据转换为对应于所述优先级最高的通道的格式;
所述发送单元 403, 用于向所述本端客户端主机发送所述第二格式转换单 元格式转换后的数据。
本发明实施例还提供了一种计算机可读存储介质, 该介质中存储有程序, 该程序执行时包括上述客户端主机侧数据交互的方法中的部分或者全部步骤。
本发明实施例还提供了一种计算机可读存储介质, 该介质中存储有程序, 该程序执行时包括上述中继设备侧数据交互的方法中的部分或者全部步骤。 图 11是本发明实施例客户端主机 30的结构示意图。客户端主机 30可包括输 入设备 310、 输出设备 320、 处理器 330和存储器 340。
存储器 340可以包括只读存储器和随机存取存储器,并向处理器 330提供指 令和数据。 存储器 340的一部分还可以包括非易失性随机存取存储器 ( NVRAM )。
存储器 340存储了如下的元素, 可执行模块或者数据结构, 或者它们的子 集, 或者它们的扩展集:
操作指令: 包括各种操作指令, 用于实现各种操作。
操作系统: 包括各种系统程序, 用于实现各种基础业务以及处理基于硬件 的任务。
在本发明实施例中, 处理器 330通过调用存储器 340存储的操作指令(该操 作指令可存储在操作系统中), 执行如下操作:
通过输出设备 320同时发送用户数据包协议 UDP通道的地址探测请求和数 据传输协议 TCP通道的地址探测请求, 当所述 UDP通道的地址探测和所述 TCP 通道的地址探测均失败时,再输出设备 320发送超文本传输协议 HTTP通道的地 址探测请求; 当至少一个通道探测成功时, 通过输入设备 310收集所述至少一 个通道中每个通道对应的两类地址,所述两类地址包括所述每个通道的最外层 的网络地址转换 NAT主机所分配的映射地址和所述本端中继设备的中继地址; 与对端客户端主机进行地址交换并进行地址配对;按照配对的地址进行通道连 通性检测,并选择检测出的有效通道中优先级最高的通道与对端客户端主机进 行数据交互。
本发明实施例中,客户端主机通过同时发送用户数据包协议 UDP通道的地 址探测请求和数据传输协议 TCP通道的地址探测请求的方式来进行地址探测, 提高地址探测时穿越 NAT主机的效率,从而缩短了两个客户端主机进行数据交 互的拉起时延。
处理器 330控制客户端主机 30的操作, 处理器 330还可以称为 CPU ( Central Processing Unit, 中央处理单元)。 存储器 340可以包括只读存储器和随机存取 存储器, 并向处理器 330提供指令和数据。存储器 340的一部分还可以包括非易 失性随机存取存储器(NVRAM )。 具体的应用中, 客户端主机 30的各个组件 通过总线系统 350耦合在一起, 其中总线系统 350除包括数据总线之外,还可以 包括电源总线、 控制总线和状态信号总线等。 但是为了清楚说明起见, 在图中 将各种总线都标为总线系统 350。
上述本发明实施例揭示的方法可以应用于处理器 330中,或者由处理器 330 实现。 处理器 330可能是一种集成电路芯片, 具有信号的处理能力。 在实现过 程中, 上述方法的各步骤可以通过处理器 330中的硬件的集成逻辑电路或者软 件形式的指令完成。 上述的处理器 330可以是通用处理器、 数字信号处理器 ( DSP )、 专用集成电路(ASIC )、 现成可编程门阵列 (FPGA )或者其他可编 程逻辑器件、 分立门或者晶体管逻辑器件、 分立硬件组件。 可以实现或者执行 本发明实施例中的公开的各方法、 步骤及逻辑框图。通用处理器可以是微处理 器或者该处理器也可以是任何常规的处理器等。结合本发明实施例所公开的方 法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬 件及软件模块组合执行完成。 软件模块可以位于随机存储器, 闪存、 只读存储 器, 可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存 储介质中。 该存储介质位于存储器 340, 处理器 330读取存储器 340中的信息, 结合其硬件完成上述方法的步骤。
可选地, 处理器 330还可获取本端客户端主机的三类通道的主机地址, 所 述三类通道的主机地址包括 UDP通道的主机地址、 TCP通道的主机地址和 HTTP通道的主机地址; 将所述本端客户端主机的三类通道的主机地址以及收 集到的所述两类地址,与所述对端客户端主机的三类通道的主机地址以及所述 对端客户端主机收集到的所述两类地址进行交换并配对。 可选地,处理器 330还可将所述本客户端主机的 UDP通道的主机地址、 TCP 通道的主机地址和 HTTP通道的主机地址, 以及本客户端主机收集到的所述至 少一个通道中每个通道的最外层网络地址转换 NAT主机分配的映射地址和本 端中继设备的中继地址, 与对方客户端主机的 UDP通道的主机地址、 TCP通道 的主机地址和 HTTP通道的主机地址, 以及对方客户端主机收集到的最外层 NAT主机分配的映射地址和对端中继设备的中继地址进行交换并配对。
可选地, 处理器 330具体可检测配对的本端客户端主机的 UDP通道的主机 述 UDP通道连接成功时,选择所述 UDP通道作为本端客户端主机与对端客户端 主机进行数据交互时优先级最高的通道。
可选地, 处理器 330还可在进行地址交换时, 与对端客户端主机通过信令 协议服务器进行地址交换。 图 12是本发明实施例中继设备 40的结构示意图。中继设备 40可包括输入设 备 410、 输出设备 420、 处理器 430和存储器 440。
存储器 440可以包括只读存储器和随机存取存储器,并向处理器 430提供指 令和数据。 存储器 440的一部分还可以包括非易失性随机存取存储器 ( NVRAM )。
存储器 440存储了如下的元素, 可执行模块或者数据结构, 或者它们的子 集, 或者它们的扩展集:
操作指令: 包括各种操作指令, 用于实现各种操作。
操作系统: 包括各种系统程序, 用于实现各种基础业务以及处理基于硬件 的任务。
在本发明实施例中, 处理器 430通过调用存储器 440存储的操作指令(该操 作指令可存储在操作系统中), 执行如下操作:
通过输入设备 410接收本端客户端主机发送来的地址探测请求; 根据所述 地址探测请求的报文类型, 收集对应于所述报文类型的两类地址, 所述两类地 址包括最外层网络地址转换 NAT主机所分配的映射地址和本端中继设备的中 继地址; 通过输出设备 420向所述本端客户端主机发送所述收集到的对应所述 4艮文类型的所述两类地址,以使所述本端客户端主机与对端客户端主机进行地 址交换并配对,从而使所述本端客户端主机按照配对的地址进行通道连通性检 测,并选择检测出的有效通道中优先级最高的通道与对端客户端主机进行数据 交互。
本发明实施例提供的中继设备可以使客户端主机在同时发送的 UDP通道 的地址探测请求和 TCP通道的地址探测请求中的一个成功穿越 NAT时, 收集对 应通道的两类地址, 使客户端主机提高了地址探测时穿越 NAT主机的效率, 从 而缩短了两个客户端主机进行数据交互的拉起时延。
处理器 430控制中继设备 40的操作, 处理器 430还可以称为 CPU ( Central Processing Unit, 中央处理单元)。 存储器 440可以包括只读存储器和随机存取 存储器, 并向处理器 430提供指令和数据。存储器 440的一部分还可以包括非易 失性随机存取存储器(NVRAM )。 具体的应用中, 客户端主机 30的各个组件 通过总线系统 450耦合在一起, 其中总线系统 450除包括数据总线之外,还可以 包括电源总线、 控制总线和状态信号总线等。 但是为了清楚说明起见, 在图中 将各种总线都标为总线系统 450。
上述本发明实施例揭示的方法可以应用于处理器 430中,或者由处理器 430 实现。 处理器 430可能是一种集成电路芯片, 具有信号的处理能力。 在实现过 程中, 上述方法的各步骤可以通过处理器 430中的硬件的集成逻辑电路或者软 件形式的指令完成。 上述的处理器 430可以是通用处理器、 数字信号处理器 ( DSP )、 专用集成电路(ASIC )、 现成可编程门阵列 (FPGA )或者其他可编 程逻辑器件、 分立门或者晶体管逻辑器件、 分立硬件组件。 可以实现或者执行 本发明实施例中的公开的各方法、 步骤及逻辑框图。通用处理器可以是微处理 器或者该处理器也可以是任何常规的处理器等。结合本发明实施例所公开的方 法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬 件及软件模块组合执行完成。 软件模块可以位于随机存储器, 闪存、 只读存储 器, 可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存 储介质中。 该存储介质位于存储器 440, 处理器 430读取存储器 440中的信息, 结合其硬件完成上述方法的步骤。
可选地, 输入设备 410接收所述本端客户端主机发来的数据, 所述数据的 目的端地址表示所述数据的接收方为对端客户端主机; 处理器 430将所述数据 转换为 UDP格式的数据; 输出设备 420通过本端中继设备与对端中继设备之间 的 UDP通道, 向所述对端中继设备发送所述 UDP格式的数据。
可选地, 输入设备 410接收对端中继设备发送来的 UDP格式的数据; 处理 器 430确定本端中继设备与所述本端客户端主机之间的优先级最高的通道; 当 所述本端中继设备与所述本端客户端主机之间的优先级最高的通道为非 UDP 通道时, 将所述 UDP格式的数据转换为对应于所述优先级最高的通道的格式; 输出设备 420向所述本端客户端主机发送格式转换后的数据。
参阅图 13、本发明实施例提供的数据交互系统的一实施例包括: 第一客户 端主机 30A、 第二客户端主机 30B、 第一 NAT主机 50A、 第二 NAT主机 50B、 第 一中继设备 40 A和第二中继设备 40B;
所述第一客户端主机 30A、 第一 NAT主机 50A和第一中继设备 40A属于第 一网络;
所述第二客户端主机 30B、第二 NAT主机 50B和第二中继设备 40B属于第二 网络;
所述第一 NAT主机 50A为所述第一网络中最外层的 NAT主机, 在接收到所 述第一客户端主机 30A发送的地址探测请求时, 为所述第一客户端主机 30A分 配映射地址;
所述第二 NAT主机 50B为所述第二网络中最外层的 NAT主机, 在接收到所 述第二客户端主机 30B发送的地址探测请求时, 为所述第二客户端主机 30B配 映射地址;
其中, 所述第一客户端主机 30A, 用于同时发送用户数据包协议 UDP通道 的地址探测请求和数据传输协议 TCP通道的地址探测请求, 当所述 UDP通道的 地址探测和所述 TCP通道的地址探测均失败时, 再发送超文本传输协议 HTTP 通道的地址探测请求; 当至少一个通道探测成功时, 收集所述至少一个通道中 每个通道对应的两类地址,所述两类地址包括所述每个通道的最外层的网络地 址转换 NAT主机所分配的映射地址和所述本端中继设备的中继地址; 所述第二客户端主机 30B, 用于同时发送用户数据包协议 UDP通道的地址 探测请求和数据传输协议 TCP通道的地址探测请求, 当所述 UDP通道的地址探 测和所述 TCP通道的地址探测均失败时, 再发送超文本传输协议 HTTP通道的 地址探测请求; 当至少一个通道探测成功时, 收集所述至少一个通道中每个通 道对应的两类地址,所述两类地址包括所述每个通道的最外层的网络地址转换 NAT主机所分配的映射地址和所述本端中继设备的中继地址;
所述第一客户端主机 30A和所述第二客户端主机 30B进行地址交换并进行 地址配对;
所述第一客户端主机 30A和所述第二客户端主机 30B分别按照配对的地址 进行通道连通性检测,并选择检测出的有效通道中优先级最高的通道与对端客 户端主机进行数据交互。
本发明实施例提供的数据交互系统中的客户端主机通过同时发送用户数 据包协议 UDP通道的地址探测请求和数据传输协议 TCP通道的地址探测请求 的方式来进行地址探测, 提高地址探测时穿越 NAT主机的效率, 从而缩短了两 个客户端主机进行数据交互的拉起时延。
参阅图 14、 本发明实施例提供的数据交互系统的一实施例包括: 包括: 第 一客户端主机 30A、 第二客户端主机 30B、 NAT主机 50和中继设备 40, 所述第 一客户端主机 30A和所述第二客户端主机 30B属于同一个网络;
所述 NAT主机 50为所述第一客户端主机 30A和第二客户端主机 30B所在网 络的最外层的 NAT主机, 在接收到所述第一客户端主机 30A和所述第二客户端 主机 30B中的至少一个发送的地址探测请求时, 为所述第一客户端主机和所述 第二客户端主机中的至少一个分配映射地址;
所述第一客户端主机 30A, 用于同时发送用户数据包协议 UDP通道的地址 探测请求和数据传输协议 TCP通道的地址探测请求, 当所述 UDP通道的地址探 测和所述 TCP通道的地址探测均失败时, 再发送超文本传输协议 HTTP通道的 地址探测请求; 当至少一个通道探测成功时, 收集所述至少一个通道中每个通 道对应的两类地址,所述两类地址包括所述每个通道的最外层的网络地址转换 NAT主机所分配的映射地址和所述本端中继设备的中继地址; 所述第二客户端主机 30B, 用于同时发送用户数据包协议 UDP通道的地址 探测请求和数据传输协议 TCP通道的地址探测请求, 当所述 UDP通道的地址探 测和所述 TCP通道的地址探测均失败时, 再发送超文本传输协议 HTTP通道的 地址探测请求; 当至少一个通道探测成功时, 收集所述至少一个通道中每个通 道对应的两类地址,所述两类地址包括所述每个通道的最外层的网络地址转换 NAT主机所分配的映射地址和所述本端中继设备的中继地址;
所述第一客户端主机 30A和所述第二客户端主机 30B进行地址交换并进行 地址配对;
所述第一客户端主机 30A和所述第二客户端主机 30B分别按照配对的地址 进行通道连通性检测,并选择检测出的有效通道中优先级最高的通道与对端客 户端主机进行数据交互。
本发明实施例提供的数据交互系统中的客户端主机通过同时发送用户数 据包协议 UDP通道的地址探测请求和数据传输协议 TCP通道的地址探测请求 的方式来进行地址探测, 提高地址探测时穿越 NAT主机的效率, 从而缩短了两 个客户端主机进行数据交互的拉起时延。 本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步 骤是可以通过程序来指令相关的硬件(例如处理器)来完成, 该程序可以存储 于一计算机可读存储介质中, 存储介质可以包括: ROM、 RAM, 磁盘或光盘 等。
以上对本发明实施例所提供的数据交互的方法、装置以及系统进行了详细 施例的说明只是用于帮助理解本发明的方法及其核心思想; 同时,对于本领域 的一般技术人员,依据本发明的思想,在具体实施方式及应用范围上均会有改 变之处, 综上所述, 本说明书内容不应理解为对本发明的限制。

Claims

权 利 要 求
1、 一种数据交互的方法, 其特征在于, 包括:
同时发送用户数据包协议 UDP通道的地址探测请求和数据传输协议 TCP 通道的地址探测请求, 当所述 UDP通道的地址探测和所述 TCP通道的地址探测 均失败时, 再发送超文本传输协议 HTTP通道的地址探测请求;
当至少一个通道探测成功时 ,收集所述至少一个通道中每个通道对应的两 类地址,所述两类地址包括所述每个通道的最外层的网络地址转换 NAT主机所 分配的映射地址和本端中继设备的中继地址;
与对端客户端主机进行地址交换并进行地址配对;
按照配对的地址进行通道连通性检测,并选择检测出的有效通道中优先级 最高的通道与对端客户端主机进行数据交互。
2、 根据权利要求 1所述的方法, 其特征在于, 在所述与对端客户端主机进 行地址交换并进行地址配对的步骤之前, 所述方法还包括:
获取本端客户端主机的三类通道的主机地址,所述三类通道的主机地址包 括 UDP通道的主机地址、 TCP通道的主机地址和 HTTP通道的主机地址;
对应的, 所述与对端客户端主机进行地址并进行地址配对, 包括: 将所述本端客户端主机的三类通道的主机地址以及收集到的所述两类地 址,与所述对端客户端主机的三类通道的主机地址以及所述对端客户端主机收 集到的所述两类地址进行交换并配对。
3、 根据权利要求 2所述的方法, 其特征在于, 所述将所述本端客户端主机 的三类通道的主机地址以及收集到的所述两类地址,与所述对端客户端主机的 三类通道的主机地址以及所述对端客户端主机收集到的所述两类地址进行交 换并配对, 包括:
将所述本客户端主机的 UDP通道的主机地址、 TCP通道的主机地址和 HTTP通道的主机地址, 以及本客户端主机收集到的所述至少一个通道中每个 通道的最外层网络地址转换 NAT主机分配的映射地址和本端中继设备的中继 地址,与对方客户端主机的 UDP通道的主机地址、 TCP通道的主机地址和 HTTP 通道的主机地址,以及对方客户端主机收集到的最外层 NAT主机分配的映射地 址和对端中继设备的中继地址进行交换并配对。
4、 根据权利要求 3所述的方法, 其特征在于, 所述按照配对的地址进行通 道连通性检测,并选择检测出的有效通道中优先级最高的通道与对端客户端主 机进行数据交互, 包括:
检测配对的本端客户端主机的 UDP通道的主机地址与对端客户端主机的 UDP通道的主机地址之间的 UDP通道的连通性;
当所述 UDP通道连接成功时,选择所述 UDP通道作为本端客户端主机与对 端客户端主机进行数据交互时优先级最高的通道。
5、 根据权利要求 1-4任一项所述的方法, 其特征在于, 所述方法还包括: 在进行地址交换时, 与对端客户端主机通过代理服务器进行地址交换。
6、 一种数据交互的方法, 其特征在于, 包括:
接收本端客户端主机发送来的地址探测请求;
根据所述地址探测请求的报文类型, 收集对应于所述报文类型的两类地 址,所述两类地址包括最外层网络地址转换 NAT主机所分配的映射地址和本端 中继设备的中继地址;
向所述本端客户端主机发送所述收集到的对应所述^艮文类型的所述两类 地址, 以使所述本端客户端主机与对端客户端主机进行地址交换并配对,从而 使所述本端客户端主机按照配对的地址进行通道连通性检测 ,并选择检测出的 有效通道中优先级最高的通道与对端客户端主机进行数据交互。
7、 根据权利要求 6所述的方法, 其特征在于, 所述方法还包括: 接收所述本端客户端主机发来的数据,所述数据的目的端地址表示所述数 据的接收方为对端客户端主机;
将所述数据转换为 UDP格式的数据; 发送所述 UDP格式的数据。
8、 根据权利要求 6所述的方法, 其特征在于, 所述方法还包括: 接收对端中继设备发送来的 UDP格式的数据;
确定本端中继设备与所述本端客户端主机之间的优先级最高的通道; 当所述本端中继设备与所述本端客户端主机之间的优先级最高的通道为 非 UDP通道时,将所述 UDP格式的数据转换为对应于所述优先级最高的通道的 格式;
向所述本端客户端主机发送格式转换后的数据。
9、 一种客户端主机, 其特征在于, 包括:
发送单元,用于同时发送用户数据包协议 UDP通道的地址探测请求和数据 传输协议 TCP通道的地址探测请求, 当所述 UDP通道的地址探测和所述 TCP通 道的地址探测均失败时, 再发送超文本传输协议 HTTP通道的地址探测请求; 接收单元, 用于当至少一个通道探测成功时, 收集所述至少一个通道中每 个通道对应的两类地址,所述两类地址包括最外层网络地址转换 NAT主机所分 配的映射地址和本端中继设备的中继地址;
地址处理单元,用于将所述接收单元接收到的地址与对端客户端主机进行 地址交换并进行地址配对; 测,并选择检测出的有效通道中优先级最高的通道与对端客户端主机进行数据 交互。
10、 根据权利要求 9所述的客户端主机, 其特征在于, 所述客户端主机还 包括: 地址获取单元,
所述地址获取单元, 用于获取本端客户端主机的三类通道的主机地址, 所 述三类通道的主机地址包括 UDP通道的主机地址、 TCP通道的主机地址和 HTTP通道的主机地址;
所述地址处理单元,用于将所述本端客户端主机的三类通道的主机地址以 及收集到的所述两类地址,与所述对端客户端主机的三类通道的主机地址以及 所述对端客户端主机收集到的所述两类地址进行交换并配对。
11、 根据权利要求 10所述的客户端主机, 其特征在于,
所述地址处理单元, 用于将所述本客户端主机的 UDP通道的主机地址、 TCP通道的主机地址和 HTTP通道的主机地址, 以及本客户端主机收集到的所 述至少一个通道中每个通道的最外层网络地址转换 NAT主机分配的映射地址 和本端中继设备的中继地址, 与对方客户端主机的 UDP通道的主机地址、 TCP 通道的主机地址和 HTTP通道的主机地址, 以及对方客户端主机收集到的最外 层 NAT主机分配的映射地址和对端中继设备的中继地址进行交换并配对。
12、 根据权利要求 11所述的客户端主机, 其特征在于,
所述通道处理单元,用于检测配对的本端客户端主机的 UDP通道的主机地
UDP通道连接成功时,选择所述 UDP通道作为本端客户端主机与对端客户端主 机进行数据交互时优先级最高的通道。
13、 根据权利要求 9-12任一所述的客户端主机, 其特征在于,
所述地址处理单元,还用于在进行地址交换时, 与对端客户端主机通过代 理服务器进行地址交换。
14、 一种中继设备, 其特征在于, 包括:
接收单元, 用于接收本端客户端主机发送来的地址探测请求;
地址收集单元, 用于根据所述接收单元接收的地址探测请求的报文类型, 收集对应于所述报文类型的两类地址,所述两类地址包括最外层网络地址转换 NAT主机所分配的映射地址和本端中继设备的中继地址;
发送单元,用于向所述本端客户端主机发送所述地址收集单元收集到的对 应所述 文类型的所述两类地址,以使所述本端客户端主机与对端客户端主机 进行地址交换并配对,从而使所述本端客户端主机按照配对的地址进行通道连 通性检测,并选择检测出的有效通道中优先级最高的通道与对端客户端主机进 行数据交互。
15、根据权利要求 14所述的中继设备,其特征在于,所述中继设备还包括: 第一格式转换单元,
所述接收单元,还用于接收所述本端客户端主机发来的数据, 所述数据的 目的端地址表示所述数据的接收方为对端客户端主机;
所述第一格式转换单元, 用于将所述接收单元接收到的所述数据转换为 UDP格式的数据; 向所述对端中继设备发送所述 UDP格式的数据。
16、根据权利要求 14所述的中继设备,其特征在于,所述中继设备还包括: 确定单元和第二格式转换单元,
所述接收单元, 还用于接收对端中继设备发送来的 UDP格式的数据; 所述确定单元,用于确定本端中继设备与所述本端客户端主机之间的优先 级最高的通道; 本端客户端主机之间的优先级最高的通道为非 UDP通道时,将所述 UDP格式的 数据转换为对应于所述优先级最高的通道的格式;
所述发送单元,用于向所述本端客户端主机发送所述第二格式转换单元格 式转换后的数据。
17、 一种数据交互系统, 其特征在于, 包括: 第一客户端主机、 第二客户 端主机、 第一网络地址转换 NAT主机、 第二 NAT主机、 第一中继设备、 第二中 继设备;
所述第一客户端主机、所述第一 NAT主机和所述第一中继设备属于第一网 络;
所述第二客户端主机、所述第二 NAT主机和所述第二中继设备属于第二网 络;
所述第一 NAT主机为所述第一网络中最外层的 NAT主机,在接收到所述第 一客户端主机发送的地址探测请求时, 为所述第一客户端主机分配映射地址; 所述第二 NAT主机为所述第二网络中最外层的 NAT主机,在接收到所述第 二客户端主机发送的地址探测请求时, 为所述第二客户端主机分配映射地址; 所述第一客户端主机和所述第二客户端主机为上述权利要求 9~13任意一 项所述的客户端主机;
所述第一中继设备和所述第二中继设备为上述权利要求 14~16任意一项所 述的中继设备。
18、 一种数据交互系统, 其特征在于, 包括: 第一客户端主机、 第二客户 端主机、 网络地址转换 NAT主机和中继设备, 所述第一客户端主机和所述第二 客户端主机属于同一个网络; 所述 NAT主机为所述第一客户端主机和第二客户端主机所在网络的最外 层的 NAT主机,在接收到所述第一客户端主机和所述第二客户端主机中的至少 一个发送的地址探测请求时,为所述第一客户端主机和所述第二客户端主机中 的至少一个分配映射地址;
所述第一客户端主机和所述第二客户端主机为上述权利要求 9~13任意一 项所述的客户端主机;
所述中继设备为上述权利要求 14~16任意一项所述的中继设备。
PCT/CN2013/084145 2013-05-29 2013-09-25 一种数据交互的方法、装置及系统 WO2014190643A1 (zh)

Priority Applications (4)

Application Number Priority Date Filing Date Title
EP13863673.3A EP2822256B1 (en) 2013-05-29 2013-09-25 Nat traversal using udp, tcp or http
KR1020147019342A KR101776648B1 (ko) 2013-05-29 2013-09-25 데이터 상호작용 방법, 장치, 및 시스템
JP2015518840A JP5930449B2 (ja) 2013-05-29 2013-09-25 データ対話方法、装置、およびシステム
US14/310,727 US9432330B2 (en) 2013-05-29 2014-06-20 Data interaction method, apparatus, and system

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310206758.6 2013-05-29
CN201310206758.6A CN103347099B (zh) 2013-05-29 2013-05-29 一种数据交互的方法、装置及系统

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US14/310,727 Continuation US9432330B2 (en) 2013-05-29 2014-06-20 Data interaction method, apparatus, and system

Publications (1)

Publication Number Publication Date
WO2014190643A1 true WO2014190643A1 (zh) 2014-12-04

Family

ID=49281873

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2013/084145 WO2014190643A1 (zh) 2013-05-29 2013-09-25 一种数据交互的方法、装置及系统

Country Status (6)

Country Link
EP (1) EP2822256B1 (zh)
JP (1) JP5930449B2 (zh)
KR (1) KR101776648B1 (zh)
CN (1) CN103347099B (zh)
TW (1) TWI527414B (zh)
WO (1) WO2014190643A1 (zh)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105262853A (zh) * 2015-09-23 2016-01-20 上海斐讯数据通信技术有限公司 一种p2p连接nat穿越的路径建立方法、装置及系统
CN106357836B (zh) * 2016-09-07 2019-09-06 新华三技术有限公司 一种连接建立方法和装置
CN107395653B (zh) * 2017-09-13 2020-07-07 上海奇夜语网络科技有限公司 一种基于安全隔离网闸的企业即时通讯系统及方法
CN110503935B (zh) * 2019-07-16 2020-11-06 北京达佳互联信息技术有限公司 音频数据处理方法、装置、电子设备及存储介质
CN112565430B (zh) * 2020-12-08 2023-01-24 上证所信息网络有限公司 一种多市场行情数据在广域网的低时延可靠传输方法
CN112394300B (zh) * 2021-01-20 2021-04-09 上海国微思尔芯技术股份有限公司 一种组网检测方法及系统
CN118316842B (zh) * 2024-06-07 2024-08-06 中国科学技术大学 一种基于ntp流量特征的nat局域网设备探测方法

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050195799A1 (en) * 2004-03-04 2005-09-08 Wiline Networks, Inc. Method and device for coupling a POTS terminal to a non-PSTN communications network
CN1805388A (zh) * 2005-01-12 2006-07-19 腾讯科技(深圳)有限公司 一种建立对等直连通道的方法
CN101938532A (zh) * 2010-09-17 2011-01-05 北京神州泰岳软件股份有限公司 基于udp的穿越nat设备的方法及系统
CN102685262A (zh) * 2012-04-16 2012-09-19 中兴通讯股份有限公司 一种探测网络地址转换信息的方法、装置及系统
CN102904813A (zh) * 2012-11-05 2013-01-30 华为技术有限公司 一种报文转发的方法及相应设备

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100539504C (zh) * 2006-02-28 2009-09-09 诺基亚西门子通信系统技术(北京)有限公司 一种网络地址转换和/或防火墙穿越平台、系统及其方法
JP4961368B2 (ja) * 2008-02-26 2012-06-27 エヌ・ティ・ティ・コミュニケーションズ株式会社 端末装置、nat越え方法、及びプログラム
JP5091887B2 (ja) 2009-02-23 2012-12-05 エヌ・ティ・ティ・コミュニケーションズ株式会社 端末装置、通信処理方法、及びプログラム
JP5303403B2 (ja) 2009-08-28 2013-10-02 エヌ・ティ・ティ・コミュニケーションズ株式会社 端末装置、通信方法、及びプログラム
KR101263783B1 (ko) * 2010-12-27 2013-05-13 삼성에스디에스 주식회사 릴레이 서버를 이용한 데이터 전송 시스템 및 방법

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050195799A1 (en) * 2004-03-04 2005-09-08 Wiline Networks, Inc. Method and device for coupling a POTS terminal to a non-PSTN communications network
CN1805388A (zh) * 2005-01-12 2006-07-19 腾讯科技(深圳)有限公司 一种建立对等直连通道的方法
CN101938532A (zh) * 2010-09-17 2011-01-05 北京神州泰岳软件股份有限公司 基于udp的穿越nat设备的方法及系统
CN102685262A (zh) * 2012-04-16 2012-09-19 中兴通讯股份有限公司 一种探测网络地址转换信息的方法、装置及系统
CN102904813A (zh) * 2012-11-05 2013-01-30 华为技术有限公司 一种报文转发的方法及相应设备

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP2822256A4 *

Also Published As

Publication number Publication date
JP2015522880A (ja) 2015-08-06
TWI527414B (zh) 2016-03-21
KR20150016201A (ko) 2015-02-11
CN103347099A (zh) 2013-10-09
EP2822256B1 (en) 2016-06-22
KR101776648B1 (ko) 2017-09-08
JP5930449B2 (ja) 2016-06-08
EP2822256A1 (en) 2015-01-07
TW201445960A (zh) 2014-12-01
CN103347099B (zh) 2016-08-10
EP2822256A4 (en) 2015-01-21

Similar Documents

Publication Publication Date Title
TWI527414B (zh) 資料交互的方法、裝置及系統
US8631155B2 (en) Network address translation traversals for peer-to-peer networks
US20100088427A1 (en) Selective Routing of Data Transmission Between Clients
US9516114B2 (en) Data packet transmission method and related device and system
WO2006089481A1 (fr) Méthode de contrôle de communication de pénétration directe dont deux parties sont dans différents nat et dispositif correspondant
TW201320691A (zh) 網路系統之資料管理方法及其相關系統
WO2014114058A1 (zh) 一种数据报文转发方法、用户驻地设备和系统
JP6386166B2 (ja) IPv4とIPv6との間の翻訳方法及び装置
WO2007019809A1 (fr) Procede et systeme d'etablissement d'un canal direct point par point
JP2023542398A (ja) データ処理方法、装置、関連機器及び記憶媒体
US9432330B2 (en) Data interaction method, apparatus, and system
CN102457580B (zh) Nat穿越方法及系统
WO2016078235A1 (zh) 基于PNAT向IPv6过渡的网络转换实现方法、装置
WO2013167086A2 (zh) 一种网络地址转换穿透方法及设备
WO2011044810A1 (zh) 实现多方通信的方法、装置及系统
CN103391271B (zh) 数据包转发方法和装置
WO2024045857A1 (zh) 数据传输的方法和装置
CN117439815B (zh) 一种基于反向透明桥接的内网穿透系统及方法
JP2002190827A (ja) 異なるネットワーク間におけるインターネット電話の接続方式
CN113067908B (zh) 一种nat穿越方法、装置、电子设备和存储介质
KR100793340B1 (ko) 네트웍 주소 변환 기능을 이용한 홈 네트웍 통신 방법
KR100606350B1 (ko) 스태킹된 라우팅 시스템에서의 에이알피 공유 장치
Geng et al. Research on interconnection mechanism between 6LoWPAN and Internet
JP4993133B2 (ja) 中継装置
KR100399431B1 (ko) 망 접속장치 및 접속방법

Legal Events

Date Code Title Description
WWE Wipo information: entry into national phase

Ref document number: 2013863673

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 2015518840

Country of ref document: JP

Kind code of ref document: A

ENP Entry into the national phase

Ref document number: 20147019342

Country of ref document: KR

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE