I know how works NAT, i have read Unity - Scripting API: Network.useProxy but i have no clear what is a proxy server exactly, i know it is used so that a client can communicate a remote server through a proxy server but i am not sure how this works and why is related to the nat punch and masterserver
If server just will accept their own packages which have the info needed to match in their nat table how communicates proxy with the server when receives a petition of a client to communicate con that server? using nat punch?
Also Unity doesnt tell how to make a proxy server, is it easy or should i pay for a proxy server?
The setup i thought was clients connecting to a public ip and that ip is redirected to a masterserver and through that masterserver you connect to other private address which would be the servers, that would work?
That is from the Legacy networking.
Proxy is refered to as Relay in the new system.
And a nat facilitator is what you use when you want to use STUN punchthrough. Which is only used in Legacy networking. Relay is the “new” way.
And how works the relay system? I see the relay is withing the Unity networking service, how this works, i use that service that and it automatically will use nat punch to be able to connect clients without needing to connect to a server with ip address?
No need for punch through. A relay is just a proxy. You send traffic to the relay that has a public IP. And it then forwards it to the right destination.
But how is posible if a client makes a petition to connect to certain server to the proxy server this must send that petition to that server but that server just will accept incoming petitions from a package he sent before with a ip and port that matches his nat table
Dont understand what you mean. The client is who tells what to do, and anyways the relay if wanted to make a connection to a client that client would not reply as the client just would accept packages he sent before
You are saying is the proxy server which connects to clients. Clients would have problems with nat if other computer try to connect them before client has connected to them previously. Clients map the outgoing package in the nat table so any package that has not the port and ip he sent wont be routed to any private address
Let’s put it this way without going into details about why it works.
If we just use plain old sockets. And assume all are behind NAT. ONLY the Host would have to map their port.
With relay it’s kindoff the same bussiness. Everyone can talk to the proxy cause it has a public IP.
In addition. Look up STUN. I think that is part of the reason of why it works like this.
Not too skilled on the NAT stuff anymore. We only utilize dedicated servers
If you have a network of one host(server/client) and other clients, clients must know the ip of the host to be able to connect to it, and that ip must be public with redirection to a private ip in the router
Lets put an example with 2 computers both with nats and not public ip
If Computer A wants to connect to computer B he maps the outgoing port and ip in the nat table of its router, then when package reaches router of computer B that router checks its nat to see if it send previously any package with that port and ip and as wont find any wont accept the package. Needs to have a public ip and redirection to specific private address