TCP to realize Peer-to-peer communication, TCP pass through NAT and TCP hole

Source: Internet
Author: User
Tags port number

This title uses two comma three names, actually said is the same thing, but the internet has a different version of it, and also seems to have someone called TCP drilling (my friend, I heard after the girl asked "to punch Ah, or I help you to borrow an electric drill to come?" "" ~! ¥%......! ”)。

Gossip Less, we first look at the technical background:

The rapid development of the Internet and the limitation of the number of IPV4 addresses make network address translation (Nat,network addresses trans2lation) devices widely used. NAT devices allow multiple hosts to share a public network after the same NAT (this article will be in the same NAT network called private network, in front of the NAT network called Public network) IP address. A private network IP address communicates with other hosts on the public network through a NAT device. Public and private network IP address domain, as shown in the following figure:

The sketch of WAN and private network

In general, private network host (such as the "Computer A-01") initiative to initiate a connection, the packet after the NAT address translation sent to the public network server (such as the "server" in the above), the connection is established after the two-way transmission of data, NAT devices allow private network host to send data to the public network host actively, but the reverse direction of the active transmission, but in a number of special occasions in different private network host to interconnect (such as Peer-to-peer software, network conferencing, video transmission, etc.), TCP through the NAT problem must be resolved. The internet about UDP through the NAT article a lot of, but also have matching source code, but I personally think that although the UDP data speed, but there is no guarantee, and NAT for UDP prepared temporary port number has life cycle limit, not easy to use, TCP connections are preferred on applications that require quality of transmission (for example, file transfers).

There are a lot of internet about TCP through NAT (that is, TCP hole) introduction article, but unfortunately I have not found the relevant source code can refer to, I use the free time to write a TCP through the NAT, so that different private network within the host to establish direct TCP communication sources.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.