How/where is NAT traversal implemented?

How/where is NAT traversal implemented?

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
User avatar
SpliFF
Posts: 1224
Joined: 28 Jul 2008, 06:51

How/where is NAT traversal implemented?

Post by SpliFF »

Been looking through files in rts/System/ and rts/System/Net but not seeing anything related to hole punching or nat traversal. Does that mean it's handled by the lobbies? Also does LuaLobby support NAT traversal?
Last edited by SpliFF on 03 Dec 2012, 06:47, edited 1 time in total.
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: How/where is NAT traversal implemented?

Post by abma »

Last edited by abma on 03 Dec 2012, 06:53, edited 1 time in total.
User avatar
SpliFF
Posts: 1224
Joined: 28 Jul 2008, 06:51

Re: How/where is NAT traversal implemented?

Post by SpliFF »

Thanks, how about LuaLobby? I added that after you answered.
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: How/where is NAT traversal implemented?

Post by abma »

hehe, edited my answer, too..

lualobby will be removed in the next release, superseded by LuaSocket

and no, it didn't support nat transversal (afaik)


to implement hole-punching you've just to regulary send an udp packet to the game host+port... HolePunching.txt should answer all questions i think
User avatar
SpliFF
Posts: 1224
Joined: 28 Jul 2008, 06:51

Re: How/where is NAT traversal implemented?

Post by SpliFF »

Thanks, I did mean LuaSocket.

My understanding is that for LuaSocket or other connections not already tunnelled by the lobby server I would need a STUN server or TURN server (symmetric NAT) or UPnP implementation.

I'll be running at least one public server so I have the basic requirements except for the actual code.

Note, your UDP example assumes the server is public, I'm talking about a server hosted behind a NAT. The server would need to discover it's own public IP using a public server and that is basically what STUN does. I'm guessing Spring lobbies do the same thing but using the lobby protocol instead of STUN.
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: How/where is NAT traversal implemented?

Post by abma »

What do you want to do?

If i understood hole-punching right it works like this:

- lobby client S (spring server?!) connects with tcp to lobby.springrts.com:8200

- client S creates a battle saying i'm hole punching
- client X join
- lobby server sends ip/ports of X to client S
- client S sends udp packets to the known ip/ports

-> X should be able to connect to S...

what do you mean with tunnelled? afaik there is no tunnel? (tunnel in my understanding is to "tunnel" some connectiong trough a foreign / different protocol, like a tcp connection over a ssh session)
a1983
Posts: 55
Joined: 02 Dec 2009, 12:01

Re: How/where is NAT traversal implemented?

Post by a1983 »

Host has local ip, behind the NAT that has external ip. TASServer should report in command BATTLEOPENED external ip. But when I create nat traversal battle in spring lobby, TASServer report local ip in BATTLEOPENED ( 192.168.x.x ). Thus hole punching failed.
Am I right, or hole punching work in other way?
Post Reply

Return to “Engine”