Any one experienced enet with Unity3D

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?

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.

In the light of UNET deprecation I’d like to bump this topic :slight_smile: 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: ENet for C# (or even better GitHub - NateShoffner/ENetSharp: C# ENet Wrapper)
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 :slight_smile:

2 Likes

And it looks like there’s an interesting wrapper by @nxrighthere GitHub - nxrighthere/ENet-CSharp: Reliable UDP networking library! However its README doesn’t mention any build instructions for the native library.

1 Like

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.

3 Likes

Way too awesome.

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.

1 Like

Im interested bit it doesnt seem to support mobile platforms.

Here’s an answer to a question regarding support for mobile platforms.

1 Like

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.

1 Like

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 ).

1 Like

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.

1 Like

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.

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.

One, two, three.

Nice! didn’t know these existed, we should probably compile a thread with a list of all available networking options if not already done :slight_smile:

The easiest way to find all the stuff is to use the search on GitHub with appropriate keywords.

Try these networking library benchmarks by @nxrighthere or this page about networking and the benchmarks

All the API and information about eNet is available at github.

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…

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.

1 Like