Hi everyone,
I’ve been using the com.unity.transport layer for a good week now and I’ve enjoyed working with it so far. For me it’s the perfect balance between a “low level” & “high level” networking framework.
However for the past couple of days I’ve been wrapping my head around NAT Punchtrough in order for players to allow to connect to eachother without port forwarding.
After reading up on many great articles such as:
https://bford.info/pub/net/p2pnat/
And reading though source repositories of implementations such as:
https://github.com/MidLevel/MLAPI.Puncher
I’ve come to the conclusion that the game server needs to be able to send packets from the same public port as it is listening to.
But the only packet you can send without establishing a connection first is… a connect packet.
So my question is: Can you send a packet without connecting?
Because when you send a connection packet from a new NetworkDriver, it uses a different external port than the one listening (logical, I think). And when I want to bind the same port as the NetworkDriver that is listening it doesn’t work.
Sending a connect message from the NetworkDriver that is listening is also not really working. (and feels very awkward anyway)
So is there a way to do this? Or any other way to implement NAT Punchthrough with this transport layer? (I would prefer not to mix multiple networking layers)
Thank you guys so much in advance!
EDIT: Mayor edit as I’ve done more research.
1 Like
Unfortunately, there isn’t really a way to send data in UTP without establishing a connection first.
Currently to connect two peers that are both behind NAT, we support connections through the Unity Relay service. Otherwise we don’t really have a good story regarding NAT punch-through at the moment.
Thanks for your reply!
Do you have any idea if this will ever be supported or does it go against the architecture of the transport package? (as it’s build upon the connectionless protocol UDP)
EDIT: Fixed my post as I found out that UTP stands for Unity Transport Package
Can it be supported? Yes. Technically speaking, there’s nothing that would prevent UTP from implementing NAT punch-through. In fact, it’s probably possible (but not necessarily easy) to implement your own through a custom INetworkInterface
(maybe something that wraps the default BaselibNetworkInterface
). These are uncharted waters, though.
Now will it ever be supported? I quite frankly have no idea (sorry!).
Alright thanks, that clears everything up!
NAT Punchthrough is listed as “in consideration” on the roadmap: Multiplayer Networking roadmap | Unity so that gives me hope ^^
I’m excited to see where this package goes after 1.0.0, thank you once again!
NAT Punchthrough is a must have feature for UTP and I can’t believe it’s just under consideration after 1.0
I can’t even connect to other computers on the same office network because of the firewall.
I know a small % of players can’t do NAT Punchthrough so I understand the need for Unity Relay, but as things are now almost all players need to use Unity Relay.
Just like LiteNetLib, RakNet, SteamNetworkingSockets etc… I would like this to be a core feature in UTP.
1 Like
Thanks for your feedback. The roadmap that Kapistijn linked to allows voting on items (and submit new ones). These votes are taken into account when deciding what to work on next, so if you feel strongly that NAT punchthrough is a critical feature for UTP, I invite you to indicate so on the roadmap.
1 Like