Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Why use both public and private endpoints when establishing peer-to-peer sessions?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Wooh   Members   -  Reputation: 638

Like
0Likes
Like

Posted 14 May 2013 - 07:04 PM

I read about establishing peer-to-peer sessions but what I don't understand is why the clients should try to send using both the public and private endpoints. If A and B has the same public IP isn't it always best to use the private endpoints and otherwise always use the public endpoints?

Sponsor:

#2 Ashaman73   Crossbones+   -  Reputation: 7876

Like
0Likes
Like

Posted 15 May 2013 - 05:23 AM

Take a look at the following scenario:

 

client A at local network 192.168.1.1:8080

client B at same local network 192.168.1.2:8080

behind global NAT 2.2.2.2

and

server at global network 1.1.1.1:9000

 

now A and B send requests to server and getting the following public endpoint:

client A: 2.2.2.2:9000

client B: 2.2.2.2:9001

 

The problem is, if client A tries to contact client B by 2.2.2.2:9001 it would send a message through the router to itself, which will most likely not work. In this case it just needs to use its local (aka private) endpoint (192.168.1.2:8080) to contact it. Therefor you send requests to both, private (if behind the same NAT) and public (if behind other NAT).


Edited by Ashaman73, 15 May 2013 - 05:27 AM.


#3 Wooh   Members   -  Reputation: 638

Like
0Likes
Like

Posted 15 May 2013 - 08:08 AM

I understand what you say. What I don't get is why A don't compare the public endpoints of A and B and if they have the same IP use the private endpoint to contact B, otherwise use the public endpoint to contact B.

#4 hplus0603   Moderators   -  Reputation: 5548

Like
0Likes
Like

Posted 15 May 2013 - 09:40 AM

Yes, it is totally possible, and sometimes preferrable, for A to talk to B using the private IP address. The main problem is establishing that A and B are, in fact, both on the same private network. If their public IP is the same, then that's a good clue.

In fact, certain NAT gateways don't support "hairpin NAT" -- if A tries to talk to B using the B public IP/port, the router just drops the packet, rather than properly forwarding and re--re-writing it. Thus, you may *have* to support the direct mode for these kinds of clients if you want a very robust NAT traversal solution.


enum Bool { True, False, FileNotFound };

#5 Ashaman73   Crossbones+   -  Reputation: 7876

Like
0Likes
Like

Posted 15 May 2013 - 11:42 PM

why A don't compare the public endpoints of A and B and if they have the same IP use the private endpoint to contact B

The client do not know its own public endpoint, only the server know it. Either the server would check if two clients have the same public endpoint and send therefor only the private endpoint to the client, or the server sends the clients public endpoint to the client itself. But all this is more complex and very theoretically, just testing if one of the two possible endpoints works is more practically.



#6 Dave Weinstein   Members   -  Reputation: 513

Like
0Likes
Like

Posted 16 May 2013 - 07:33 PM

No, it's an excellent question. There is no reason to probe both, and given that internal networks share a common address space, I'd say it is bad form.

 

NAT tunneling is mediated by the Matchmaker anyway. Have each client report its internal IP address and port when it contacts the Matchmaker. When coordinating matches, if the external IP is the same, the Matchmaker returns the external IP/Port that it determined for the parties, otherwise it returns the internal version. No additional information is sent, and no duplicate connecting is needed.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS