Splitting packets

Hi,
Is there a UDP library that does packet splitting?
for example, if I have 10kb of data and want it split into 1.4kb packets, how can I do this? and how do I reconstruct them?
Thanks,
roland

Edit: I am looking for something like ENet but in java

There was jenet project that is java port of enet. But looks like it’s abandoned since 2005 and now disapppeared at all from java.net.
However i found one link.

What sort of gain do you perceive you’ll get from splitting an already small packet into even smaller ones?

Thanks. Can I download the code with SVN? I can’t find the url to use.

Not sure, I am very new to networking, especially UDP. But I am trying to follow the Quake 3 Network model, which uses a maximum packet size of 1400 bytes (I think it’s slightly more reliable?)

Kryo can do delta compression. Don’t think anyone has used it for a game though. The heart of it is this class:
https://code.google.com/p/kryo/source/browse/trunk/src/com/esotericsoftware/kryo/compress/Delta.java
Basically you use it like this:


delta = new Delta(2048, 8);
...
delta.compress(remoteData, latestData, deltaData);
...
delta.decompress(localData, deltaData, newLocalData);

You can grab the Delta class and use it like above outside of Kryo. It uses ByteBuffers though. You could just use ByteBuffer.wrap(byte[]) or modify it to use byte[] directly.

If you split UDP packets and the split packets are not useful unless both are received, you increase the damage done by pack loss, since if any of the split packets are not received it is as if none were received. For each split packet you’ll need to encode the order in the sequence of split packets it is, and whether it is the last packet in the sequence.

IMO it would be better to get something working using TCP first, or at least don’t worry about packet splitting until you have something working in UDP.

Thanks Nate :slight_smile: I don’t want to use TCP because I want the networking to be as fast as possible. I will take your advice about making UDP work without splitting packets first (And maybe that might be fine) I don’t think I want to use Kryonet at this stage but I may change my mind.
Thanks again,
roland

TCP is not slower than UPD with reliable and ordered packet delivery. It is UDP with reliable ordered packet delivery.

Don’t forget if you want to do this yourself with UDP you need to also have flow control if you want to work on the real internet and not just on a lan. In fact you have to implement the whole TCP protocol/stack.

In some cases TCP can even be faster than UDP, for example on ADSL with DSLAMs optimized for TCP which most ISP do.

This idea of UDP is faster is based mostly on myth.