Search Unity

Any one experienced enet with Unity3D

Discussion in 'Multiplayer' started by benzsuankularb, Feb 4, 2018.

  1. benzsuankularb

    benzsuankularb

    Joined:
    Apr 10, 2013
    Posts:
    132
    I'm choosing between enet and LiteNet

    LiteNet is very active and supported for Unity.

    however enet gain a lot of performance, anyone here experienced these lib with Unity before.

    P.S. Is that general to have only 500 CCU per server machine?
    P.S.2 Will I going to gain more CCU by moving from reliable UDP to TCP?
     
    Last edited: Feb 4, 2018
  2. Whippets

    Whippets

    Joined:
    Feb 28, 2013
    Posts:
    1,775
    ENet looks by far the best option, and most gentle on your servers. Not moved to ENet yet, but it's on my list of updates.

    I think 500 CCU per server is pushing the upper limit, once you figure in NPCs, MOBs and other things that the server is simulating and broadcasting changes from. Any more than that and you'd want to think about different servers controlling pieces of the map and passing players between them as needed.

    I'm going with 4km square maps, and a 500 CCU max, maybe less; see how it goes and adjust to realities.

    I would guess that moving from reliable UDP to TCP would reduce max CCU. Sequenced UDP is ideal for movement and other server broadcast packets that are not 100% important, with reliable UDP for the more important things like client to server packets.
     
    Last edited: Feb 4, 2018
  3. pachash

    pachash

    Joined:
    Apr 2, 2014
    Posts:
    55
    In the light of UNET deprecation I'd like to bump this topic :) I only need a reliable and fast transport layer and I thought LLAPI would fit my needs but it looks like it a) has its own performance issues b) is going to be deprecated some day.

    So the question is whether anyone had positive experience of using enet native library with Unity? Specifically in a Unity application built for a mobile device.

    After googling around I found C# bindings for enet: https://www.zer7.com/software/enetcs (or even better https://github.com/NateShoffner/ENetSharp)
    At the first glance it includes MacOS and Linux native libs. However no Android and iOS native libraries are mentioned there. Of course I can give it a try and build the required libraries but maybe someone already did that in the past :)
     
    Last edited: Aug 18, 2018
    datne and benzsuankularb like this.
  4. pachash

    pachash

    Joined:
    Apr 2, 2014
    Posts:
    55
    benzsuankularb likes this.
  5. nxrighthere

    nxrighthere

    Joined:
    Mar 2, 2014
    Posts:
    567
    There's nothing special. You only need CMake with GNU Make or Visual Studio. You can just grab compiled libraries from the release section by the way.
     
    Last edited: Aug 20, 2018
  6. benzsuankularb

    benzsuankularb

    Joined:
    Apr 10, 2013
    Posts:
    132
    Way too awesome.
     
  7. nxrighthere

    nxrighthere

    Joined:
    Mar 2, 2014
    Posts:
    567
    If you encountered some problems, please check this section. I answered many basic questions there, so this may help. By the way, API reference is ready for use.
     
    Deleted User likes this.
  8. Njb_

    Njb_

    Joined:
    Jun 3, 2015
    Posts:
    20
    Im interested bit it doesnt seem to support mobile platforms.
     
  9. nxrighthere

    nxrighthere

    Joined:
    Mar 2, 2014
    Posts:
    567
    Here's an answer to a question regarding support for mobile platforms.
     
    pachash likes this.
  10. nxrighthere

    nxrighthere

    Joined:
    Mar 2, 2014
    Posts:
    567
    In the latest version, I've added support for a custom memory allocator. So, now you have full control over memory allocations, and you can use whatever you want instead of malloc. A simple example is here.
     
    pachash likes this.
  11. nxrighthere

    nxrighthere

    Joined:
    Mar 2, 2014
    Posts:
    567
    I've added support for iOS in the latest version. You can compile your project in XCode with the native library. The wrapper now works with IL2CPP (thanks to @JoshPeterson).
     
    p87 likes this.
  12. nxrighthere

    nxrighthere

    Joined:
    Mar 2, 2014
    Posts:
    567
    In the latest version, I've added packet-level LZ4 compression. It works especially well when multiple packets combined into one for a particular peer. In my tests ~100 mbps upstream bandwidth down to ~80 mbps on average. To enable compression just call enet_host_enable_compression(ENetHost *host) with the native library or Host.EnableCompression() with the wrapper after a host is created.
     
    Last edited: Oct 30, 2018
    PixelMind likes this.
  13. nxrighthere

    nxrighthere

    Joined:
    Mar 2, 2014
    Posts:
    567
    I've implemented round-trip time calculation using Jacobson’s algorithm to achieve smooth and precise values. So you will see 1 ms on a local machine as it should be, and even under lag simulation, round-trip time values will be still smooth and precise. Also, the wrapper now fully supports .NET Standard 2.0.
     
  14. Lelon

    Lelon

    Joined:
    May 24, 2015
    Posts:
    79
    Awesome work! I have been using the original c++ ENET library long time ago in one of my custom game engines, it is by far the best, lightweight, and powerful networking library I ever used.
    Anyone managed to create a high level API for Unity? something similar to how Unet works? I would love to use this library and would be awesome if we can have something like [command] and [CLientRpc] to speedup development.
     
  15. nxrighthere

    nxrighthere

    Joined:
    Mar 2, 2014
    Posts:
    567
  16. Lelon

    Lelon

    Joined:
    May 24, 2015
    Posts:
    79
    Nice! didn't know these existed, we should probably compile a thread with a list of all available networking options if not already done :)
     
  17. nxrighthere

    nxrighthere

    Joined:
    Mar 2, 2014
    Posts:
    567
    The easiest way to find all the stuff is to use the search on GitHub with appropriate keywords.
     
  18. LukeDawn

    LukeDawn

    Joined:
    Nov 10, 2016
    Posts:
    404
  19. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    Great job and nice lib!

    Is there a way to read the current sequence id of the package or should I just send my own?

    In respect to the delta compression of FPS-Sample...
     
  20. nxrighthere

    nxrighthere

    Joined:
    Mar 2, 2014
    Posts:
    567
    I'm afraid that you need a custom mechanism for this since sequencing is used only internally for protocol commands and it's not suited for usage at the application level in the current state.
     
    Spy-Shifty likes this.