LiteNetLib - another reliable udp library.

Thanks :slight_smile:

Some news:

  • Added .NET Core support
  • Added small packets merging
  • 100 stars at github :slight_smile:

This looks great :slight_smile:

Can I use multiple netClients in the same context (app/game) and connect to different servers?

Sure you can! :slight_smile: Sample project (LibSample) uses two or more clients for tests.

Master branch update:

  • Full PeerToPeer support
  • Additional data can be send with disconnect message
  • As always fixes and optimizations
1 Like

I’m going to have to check this out this weekend. I like how lean and clean its usage is. Thanks for your efforts!

Added simple and fast serializer (instead of RPC).
Check at master branch.
How-to: GitHub - RevenantX/LiteNetLib: Lite reliable UDP library for Mono and .NET

Very nice.
by the way…I love this:
_netSerializer.Subscribe(OnSamplePacketReceived);

Something I was wondering, for non-structs, could you implement something like an ILiteNetSerialized interface, with Serialize and Deserialize methods, passing in a serializer. For objects that implement that interface, their serialize methods would be responsible for their serialization. Sort of like:

class MyCreature : ILiteNetSerialized
{
private float Damage;
private int OwnerID;

void Serialize(Serializer writer)
{
writer.Put(transform.position.x);

writer.Put(Damage);
writer.Put(OwnerID);
}

// The deserializer would perform the same patern, but in reverse obviously.
}
Calling serializer.Put(MyCreature) see it implements ILiteNetSerialized, and call the serializer for the creature. Or is this simply a violation of the single responsibility principle?
Would this be of use, or even work well in LiteNetLib’s situation?

You can implement this feature with extension without NetSerializer;

interface ILiteNetSerialized ...

public static void Serialize(this NetDataWriter writer, ILiteNetSerialized obj)
{
   obj.Serialize(writer);
}

And look at NetDataWriter at all)

Hi,

Can this library be used for massive data transfers over high latency-bandwidth product networks?
Is it able to saturate the bandwidth of high latency links? (say 500ms)

How does it cope with congestion? Is this addressed?
I’m highly interested in moving from UDT, because I am currently using a mixed-mode c++ wrapper which limits me to windows platforms and I’m currently aiming for .Net Core.

Thanks!

As far as I know, it seems that udp may not work over 3g network. Did you test your library over 3g?

Thanks

I tested over 3g. And it works. Android mobile game (on Unity3d) uses this library for PVP multiplayer.

Hi! I didn’t test this library in that circumstances.
I tested high latency ( i have simulator ), and tested on bad mobile network. And all was fine.
LiteNetLib have bandwith control.

 public void AddFlowMode(int startRtt, int packetsPerSecond)

But that mechanism not tested well. You can try. And if you found some bugs i will fix them :slight_smile:

Hey,

Thanks for your reply!

Apart from bandwidth control is there also a congestion control implemented?

congestion depends on bandwith control. maybe i misunderstood you

Well, not entirely…
Congestion also depends on network conditions.
And if the network happens to be the Internet… then the conditions change a lot.
The protocol needs to be able to auto adjust the sending rate to cope with the way the dropped packets count and RTT varies.

So I guess there’s no such thing implemented so far…

Have a look at TCP congestion control, just to get a better ideea.

Cheers!

I have flow control. That reduces send rate when RTT less than values that you add via “AddFlowMode” method.

I am using Lidgren right now but I am on a point that I can change to other solutions.
I am scared about some things of Lidgren, but how stable is yours? Nat punching and flow control are too good to be true and I really want to use this library, before Lidgren punches me with its lack of flow control.

Thank you for this. I don’t want to use the convoluted UNET if I can and I don’t care about webgl

Also, a latency simulator with bursts of packet loss for some milliseconds would be great as it is common in a lot of wifi networkos and more but it was not testable in Lidgren. I can try to implement it if you say that is is stable enough and it is not already done :smile:

I am created this library because lidgren works unstable with Reliable packets (packet drops with deadlocks).
LiteNetLib version 0.6.1 stable and used in some commercial games.
About “Nat punching”. Lidgren-network has NAT punching too. And my code based on lidgren method :slight_smile:
And if you find some bugs i will try fix them asap (library code is clean and simple :)). I think this is main advantage over lidgren now (Lidgren network is not supported accroding to github page)

3 Likes

Hey RevenantX, I found your library really nice and simple to use, thank you!
I just wanted to ask you about your implementation of the NAT punch module. I couldn’t properly figure out how it works even after researching about it.
As far as I understood, both clients first need to communicate with a master server through a public address, this server actually “punches” its way in and forwards the NAT info to those clients, so that they can connect directly.
I’m not so sure I got it right, in any case, how did you do it?

1 Like