Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Configuring P2P Direct Through LAN

Discussion in 'Netcode for GameObjects' started by najaa3d, Oct 1, 2023.

  1. najaa3d

    najaa3d

    Joined:
    Jan 22, 2022
    Posts:
    29
    We'd like our game to do the Client-Host RPC communications directly over LAN, without ever going to the internet (or Relay). Is there a way to ensure this? (for lowest-latency)

    We have large-map collaborative-editing mode, which allows multiple authors to edit the same map (all edits are done via serializable commands). In this mode, we want low-latency, and also may want to be sending large amount of map/resource data from one PC to the other. And so low-latency LAN-only communications are highly desired.

    Before committing to NGO's, I'd like some assurances that Unity is not going to try and force us to send traffic through Relay (or other server mechanism) -- adding delay, and racking up costs, for no good reason.

    We get that Unity needs more revenue, but it shouldn't be done "artificially" by forcing data through Relay. We want Unity to succeed, and get their revenue, but not via shady schemes.

    Otherwise, we just use Fishnet.
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,013
    Yes. That's what routing does. ;)

    Unity Relay is an optional service. You'd have to sign up for it and set it up in your networking code. There is nothing shady about it.

    If you don't use a relay service all connections are directly between the host/server and the client(s). The reason why you'd need a relay service is to allow any client to connect to the hosting client, without the hosting client having to make changes to local router configurations (port forwarding, firewall rules).

    You don't need a relay service if:
    • you have a dedicated server properly configured to be reachable over the Internet
    • you want to host a LAN-only session
     
    najaa3d likes this.
  3. najaa3d

    najaa3d

    Joined:
    Jan 22, 2022
    Posts:
    29
    Thank you for your response! I appreciate you.

    I just now googled "Unity3d Netcode Routing" - and it gave me no hits. Is this an undocumented or unadvertised mode of operation for NetCode? After hours of dinking with things, the only way I can two separate PC's on my LAN to connect is via the Relay service. All other methods are failing, and there seems to be little help available for those not using Relay.

    The shady parts here are:
    1. The UGS web portal page reporting Usage/Costs doesn't relate it back to my thresholds. I can only assume I understand the contract (shown nowhere on this set of pages) - and hope that I'm calculating it right. The portal page itself should reference these thresholds directly - because it's appropriate - unless you don't want users to be aware of when they are about to go over a threshold.
    2. No Shut-off Limits is shady/dangerous. This protection should be the default; instead, it's not even available.
    3. The lack of documentation/support for Netcode to function without Relay, is pushing us towards using Relay, when it should not be necessary (via NAT Hole Punching techniques, you don't even have to much with router).

    This hasn't been my experience in self-rolled network solutions. Why doesn't NetCode support "NAT Hole Punching" techniques out-of-box? (from the Lobby) - This should be a checkbox option. I assume you know how Hole Punching works -- the Lobby simply tells each client the IPAddress of the other clients, and then they each send the other clients UDP messages through the port -- which opens up the port for return messages.

    Why isn't "NAT Hole Punching" supported out-of-box, as an option? It would allow most people the option of avoiding the use of Relay Service almost entirely, except for some very rare cases (that I can't even name).

    So this is part of the "shady feel" I get from NetCode, in that they're telling "most games" (who don't have dedicated static IP Servers online) that they will need to use Relay Svc, introducing Cost Risks (with no auto-shut-off), along with added lag.

    Granted my custom network coding experience is a decade old - so maybe I'm missing something big.
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,013
    Routing => https://en.wikipedia.org/wiki/Routing

    Then that's an issue with the LAN network. The PCs could be on a different subnet. The Router or the local OS or "security" software on either or both machines may be blocking connection attempts.

    There is no engine-specific help for this. This is generally a matter of network setup and configuration. For that you'll find tips and tutorials though. At the very least, check that both machines can see each other. If the other machine appears on both ends in Explorer's Network tab for instance. If that's not the case, try ping the other machine's IP. And so on ...

    Not familiar with UGS but typically such reports are delayed by hours if not days, rarely are they reporting usage in realtime.

    The problem with shut-off is that it would actually be harmful for your users. Imagine how damaging that were for the service when published games would frequently start failing to make connections due to the developer's shut-off thresholds. Worse yet, if some game gets a sudden spike in users due to some influencer mentioning it, and users are buying the game in droves only to find that the game wouldn't let them connect, that would be terrible for everyone involved. And we're talking about a really minor fee compared to what the game could make in revenue.

    It would be nice to get some fair warning by email ahead of reaching 80% of the free usage or so. Don't know if that's implemented.

    Again, that's the default. There is no "How to use Netcode without Relay" documentation because that's the default operating mode. If you need to use Relay to make a LAN connection, this is clearly an issue with the LAN network config.

    I can only speculate but the main issue remains those "rare cases" where it just won't work. So you still have to have a Relay service for those clients where it won't work. On top of that, the process of whole punching takes time, mainly to determine when it failed there needs to be a timeout and that ought to be at least a couple seconds which adds to the overall connection time for all game sessions.

    The relay service just works out of the box, and it's only needed in the relatively rare use cases where the game wants to offer self-hosted game sessions. And the gaming experience in that self-hosted scenario is often terrible, I'm playing that way across many games for years and there's always something ... one or more clients can't connect for whatever reason, there are connection drops, desynchronizations, high latency, lag spikes, you'd have to have the machine with the best Internet connection or CPU speed be the host, preferably both at the same time.
     
    najaa3d likes this.
  5. najaa3d

    najaa3d

    Joined:
    Jan 22, 2022
    Posts:
    29
    Thank you for your kind attention! I really appreciate you.

    For the LAN failure - we did those typical steps of shutting off Firewalls and Pinging. Router shouldn't be the issue here. Plus I do home software development where I regularly share UDP across numerous devices - never an issue. But for Unity NetCode -- no dice. In the NetworkManager script, we set the IP Address to the internal "10.0.0.{x}" address of the host, and tried both PC's as host -- nothing works (following a Code Monkey tutorial where it worked for him 6 months ago). But Relay works. So this "smells funny" to me... the only working solution for us is Relay. Maybe the most recent version of Netcode (1.6) has a bug that breaks the LAN.

    We definitely want Hosted mode to work, and our bandwidth needs are low -- it's a turn-based game similar to Civilization.

    Regarding "No Auto-Shutoff" - this is intolerable. If you don't want a Limit, then you can set it to "Unlimited" for your project. But that should be a conscious decision to "remove the limits" if you have this confidence. As is, Unity is forcing everyone to assume this unlimited/uncontrollable risk. With auto-shutoff - you should be able to configure other Email Triggers at like 50%, 75%, 90% -- so that they don't come to your limit without warning. Then you can decide to EXTEND THE LIMIT, or not... I don't like the idea of forcing us to write a "blank check".

    We're currently using Netcode, but are currently *planning* to switch to FishNet, if NetCode doesn't address our chief concerns:

    1. Auto-Shutoff Thresholds for Relay (along with Warning emails as it gets closer)

    2. Some support for NAT Hole Punching (you need a well-known address, like Relay Server - to make this happen). Unity should supply this... it's easy. Unless they are trying to coerce usage of Relay for client Hosted games.

    3. Some support for local LAN discovery.

    4. Efficient means to send massive data files from Host to Client (e.g. a new Map).


    That's where we currently stand with this.