Author Topic: Question about NAT Punch-through  (Read 20822 times)

Trevor

  • Jr. Member
  • **
  • Posts: 77
  • Karma: 2
    • View Profile
    • LackeyCCG: Play any CCG online
Question about NAT Punch-through
« on: June 29, 2014, 05:02:45 PM »
Iíve been trying to get NAT PunchThrough to work and Iíve been looking at the NATCompleteServer sample. My understanding is that it wonít work unless I also have a NAT_TYPE_DETECTION_SERVER, but I donít quite understand how this works. (Or can I successfully use NAT Punchthrough without a NAT Type detection server?)

According to the documentation Iíve read (http://www.jenkinssoftware.com/raknet/manual/Doxygen/classRakNet_1_1NatTypeDetectionServer.html), I need to have a single server with 4 different IP addresses. Iím not exactly sure what that means. Do I run some exe with RakNet on a single server that has 4 external IP address? What exactly would that exe code look like? I didnít see anything in the sample code that looks like it makes anything like a NatTypeDetectionServer.exe that I could run on a server. Could I run this NatTypeDetectionServer on 4 different servers with different IPs, or does it need to be a single server with 4 different IPs.

If anyone can help me figure out how to implement NAT PunchThrough, Iíd really appreciate it.

ppparkje

  • Not-a-newbie
  • *
  • Posts: 2
  • Karma: 0
    • View Profile
Re: Question about NAT Punch-through
« Reply #1 on: June 30, 2014, 07:07:33 AM »
I'm also trying to NAT Punchthrough using RakNet and succeeded with sample.

In short, you don't need NAT type detection server to do NAT punchthrough.

NATPunchThroughClient and NATPunchThroughServer have own methods and protocols to make NAT traverse working. They must interact each other.

There are no seat for NATTypeDetectionServer. It just gives hint which NAT the client in. This server is optional, not must for NAT punchthrough.

Trevor

  • Jr. Member
  • **
  • Posts: 77
  • Karma: 2
    • View Profile
    • LackeyCCG: Play any CCG online
Re: Question about NAT Punch-through
« Reply #2 on: July 01, 2014, 08:05:11 PM »
Thanks. I've also found out some more information that I apparently missed before that was in the documentation for NATCompleteClient.

I still have some questions about how to use it. According to Rak'kar in another post, you should first try UPNP before trying NAT Punch through. But I am wondering how you know if UPNP was unsuccessful?
Suppose my game host runs the UPNP code such as upnpDiscover and it successfully gets device->descURL and device->st. I'm still learning about how to use UPNP, but it is my current understanding that just because the game host can use UPNP, that doesn't mean the game client will also be able to use UPNP (and as far as the NATCompleteClient example goes, nothing besides UPNP is attempted if the game host appears to be successful with UPNP). But I don't see how the game client could notify the game host that it failed to use UPNP. In other words, as far as the game host knows, it could think it is just waiting for a game client to connect and never know the game client wasn't successful.
So therefore, it seems to me that the game host would need to advertise his connection via UPNP, and then also proceed to listen via a NAT Punch Through server. And the game client would just need to try UPNP, and then try to connect through the NAT Punch Through server.

Should the UPNP method and NAT Punch through method be done simultaneously? Or can the host (who is just listening for a connection) ever know when one method has failed from the client's side?