Is there is a way Peer-to-peer in all platforms? (mobile-pc)

Godot Version

3.5.1

Question

Hi,
Is there is a way to make peer-to-peer connection with godot in all platforms?
I know there is UPNP but it doesnt works on mobile.
Is there is another way?
If ıpv4 cant, maybe ıpv6 do this?
Is there is a way to do it without server?
Thanks! :smiley:

The problem with peer-to-peer is that all clients need to be directly reachable, and this can’t be done on mobile connections due to their use of CGNAT or similar features that make their IPv4 not directly routable. Also, IPv6 support on mobile connections isn’t that widespread yet in most countries – and when you do have IPv6, it’s often firewalled with no way for users to opt out of that firewall.

The only alternative you have is to rely on STUN and TURN servers (via WebRTC), but this isn’t supported by ENet.

Also, while some free STUN servers exist, you’ll have to pay to host a TURN server for the ~10% of clients who can’t rely on a STUN server alone. This is because TURN requires much more bandwidth as it relies all traffic through the server, as opposed to using the server only to perform the initial hole punching.

STUN only works in situations where the client has their own IPv4 or IPv6 behind a standard firewall. It won’t suffice for users behind a CGNAT, a mobile connection, or a corporate/university connection with aggressive firewall rules.

This is a very complicated topic. Browsers try this for WebRTC video-conferencing:

Maybe you can somewhere find a library that implements this procedure. You would still need TURN servers for some clients though AND you initially need a signalling connection that can relay information between the clients, so they can coordinate while searching for a path.

Thanks for you reply @Calinou
That means without server it cant be done in mobile?
And can I make my STUN/TURN server,
Or can I use a regular website server as STUN/TURN server?

And can you answer this question also: (if you know) Thanks!

Thanks @joviansettler ,
This protocol look interest.
Is there is a tutorial about it or it can be apply to godot?

Have you looked at this: GitHub - libp2p/libp2p: A modular and extensible networking stack which solves many challenges of peer-to-peer applications. ?

There are implementations in different programming languages. Maybe you can encapsulate one of those into an extension for Godot.

Thanks @joviansettler !
I will check it.

Yes of course it can possible. But I dont have enough knowledge with making plugins for godot. If you can show me a tutorial for it, it will help so much :smiley:

I don’t have a lot of experience with extensions either.

One of the available languages for this library is Rust. I have followed this tutorial the other day and the result was an extension that gave me a custom node in Godot:
https://godot-rust.github.io/book/intro/setup.html

Getting your plan to work is probably possible, but very complicated.

thanks for your reply @joviansettler ! :smiley:
I found some tutorials about making plugins. I will check what it gives.
I dont know anything about rust but I can try to understand.
But anyway the libp2p looks very interest. Do you have more source about it?

No, I just googled it.

okey thanks