John WH Smith
John WH Smith

Reputation: 2773

Opening a network application to the world without router setup

Please consider the following basic network setup :

Basic home network setup

As you can see, machine A is running a homemade server application, called myserverapp. This application is made in C, and listens on port 5000 for incoming packets/connections. It follows basic networking concepts, through IP sockets. With the above configuration, only machines A and B can reach this application (through 192.168.1.60:5000).

By setting a network port forwarding rule in the first router's configuration, I can allow 1.2.3.4:5000 to resolve to 192.168.1.60:5000 locally. Please note that this requires an actual router setup.

My objective here is to allow access to ./serverapp, without setting up a forwarding rule in the router's configuration. I would like my application to request worldwide IP binding by itself. As examples, Skype (not that much of a good example these days), Transmission, and many others, are reachable worldwide, but do not require me to set up a port forwarding rule for them.

Now, I am aware that this is a very recurrent question, but here are some additional circumstances :

Also note that this is programming-related : I know this is mostly a network problem, but I am looking implementation solutions. I am not looking for help setting up the network itself (actually, this is precisely what I want to avoid).

Now, my question would be : is there a well-known technique, applicable in C, to allow peer-to-peer communication behind a router ? Are there associated libraries ? Many pieces of P2P software can be ran on most computers, even mine (for which I was unable to make a UDP hole), and I just can't figure out how they achieve this.

Upvotes: 2

Views: 808

Answers (2)

Pavel Šimerda
Pavel Šimerda

Reputation: 6163

http://en.wikipedia.org/wiki/Interactive_Connectivity_Establishment

Use the above Wikipedia article as a starting point where you get links to specific IETF standards regarding connectivity establishment behind IPv4 NAT. By crawling from that article you will get more and better information than you can ever get at stack exchange, as it's a pretty much known field.

The basic answer is that techniques based on STUN work in some environments while techniques based on TURN work in all environments except those that explicitly block traffic. The TURN based techniques are basically based on the idea that the machines that are not part of Internet use IPv4 UDP/TCP NAT to connect to a machine that is in Internet and on top of those connections they can exchange messages with each other.

Upvotes: 1

abligh
abligh

Reputation: 25129

Many of the applications you quote use central servers without NAT, if only to bounce the packets of. Both client devices contact a central server, which effectively puts the two endpoints in touch with each other.

What you want to do is called NAT traversal. Here are two well known ways to do this: STUN (see here) and TURN (see here).

Upvotes: 1

Related Questions