Larus, or anyone else who is a P2P guru - how would you recommend serializing a FileStream, byte array or something similar to send over P2P, and what kind of reliability methods would you put in place?
I was thinking about indexing the packets and firing them out via RPC, but I remembered we are using UDP, or maybe RUDP (I’m not sure what you guys have done to Raknet under the hood) and sending a 1000 RPC calls per second might not be very nice.
So I’d like to know if you have any suggestions for this before I blow up my client peers.
You don’t need to slice and dice your data into packets. That is done automatically internally. At the moment you can send arbitrary data in a string parameter in an RPC function. However, this carries a 4K character limit, so you might end up needing to slice and dice your data after all. You could then, for example, just have an RPC function which has a string parameter, a chunk number and total chunk numbers. The chunks are buffered on the receiving end and the data can be created when all chunks have arrived. Sending 1000 RPCs with 4K of data each will have an effect on the network so you might limit yourself to doing only one or a few RPCs per frame update.
I know this is inconvenient but the next release of Unity will include byte array support where you can send any sized chunk of data in a single RPC call.
Thanks - The limit isn’t so bad, as we can still get the job done nicely.
I’ve built the basic RPC stuff to put the file in a byte array and send it over the network (it was based on the chat app, funnily enough) it just needs timing and reliability control.
I’ll post the result when it’s useful
I’m new to networking side part and i was wondering if i could send/receive byte Array in the 2.1.0f5 version.
What i want to do is to use some opencv tracking tech on a computer ( http://forum.unity3d.com/viewtopic.php?t=17868 ) and send a Vector3 Array to a 2nd comptuer who will do the graphical stuff so i need the fastest transmission ability.
void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info) {
Vector3[] test = new Vector3[4000]; // Don't need so much !!
for (int j = 0; j < 4000; j ++) {
if (stream.isWriting)
test[j] = Random.insideUnitSphere;
stream.Serialize(ref test[j]);
}
}
And so far, in local networking with sendrate @ 15 , it seems like it 's doing fine…
Each times i discover a new aspect of Unity, i feel like working on the best solution ever made. I’m glad that the next release comes to Windows vista. I bet Unity is going to have a hudge succes.
That code will definitely not work for anything near realtime …
thats 3000 * 12 byte per send, thats 36000 bytes or 36kb per send
so with a send rate of 15 thats 540kb + overhead per second per player in your P2P network on the upstream end, the downstream end is numPlayer times that value.
You definitely need to seriously cut what you intend to send there.
This was just an incoming test…
My purpose is to not to make GAMES. It 's just exchanging process behaviour between several computers on a local network.
I’ll keep inform about my testing straight forward.